Upgrade CMP Core.
This commit is contained in:
204
extern/CMP_Core/shaders/Common_Def.h
vendored
204
extern/CMP_Core/shaders/Common_Def.h
vendored
@ -1,8 +1,5 @@
|
||||
#ifndef _COMMON_DEFINITIONS_H
|
||||
#define _COMMON_DEFINITIONS_H
|
||||
|
||||
//===============================================================================
|
||||
// Copyright (c) 2007-2019 Advanced Micro Devices, Inc. All rights reserved.
|
||||
// Copyright (c) 2007-2020 Advanced Micro Devices, Inc. All rights reserved.
|
||||
// Copyright (c) 2004-2006 ATI Technologies Inc.
|
||||
//===============================================================================
|
||||
//
|
||||
@ -25,11 +22,26 @@
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
//
|
||||
// File Name: Common_Def.h
|
||||
// File Name: Common_Def
|
||||
// Description: common definitions used for CPU/HPC/GPU
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _COMMON_DEFINITIONS_H
|
||||
#define _COMMON_DEFINITIONS_H
|
||||
|
||||
// The shaders for UE4 require extension in the form of .ush in place of standard .h
|
||||
// this directive is used to make the change without users requiring to modify all of the include extensions
|
||||
// specific to UE4
|
||||
|
||||
#ifdef ASPM_HLSL_UE4
|
||||
#pragma once
|
||||
#define INC_cmp_math_vec4 "cmp_math_vec4.ush"
|
||||
#define INC_cmp_math_func "cmp_math_func.ush"
|
||||
#else
|
||||
#define INC_cmp_math_vec4 "cmp_math_vec4.h"
|
||||
#define INC_cmp_math_func "cmp_math_func.h"
|
||||
#endif
|
||||
|
||||
// Features
|
||||
#ifdef _WIN32
|
||||
@ -44,15 +56,24 @@
|
||||
// Using OpenCL Compiler
|
||||
#ifdef __OPENCL_VERSION__
|
||||
#define ASPM_GPU
|
||||
#define ASPM_OPENCL
|
||||
#endif
|
||||
|
||||
// Using DirectX fxc Compiler
|
||||
// Note use the /DASPM_HLSL command line to define this
|
||||
#ifdef ASPM_HLSL
|
||||
#define ASPM_GPU
|
||||
#endif
|
||||
|
||||
#ifdef _LINUX
|
||||
#undef ASPM_GPU
|
||||
#undef ASPM_OPENCL
|
||||
#ifndef ASPM_HLSL
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
#include <stdio.h>
|
||||
#include "cmp_math_vec4.h"
|
||||
#include INC_cmp_math_vec4
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef CMP_MAX
|
||||
@ -63,6 +84,13 @@
|
||||
#define CMP_MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#ifndef ASPM_GPU
|
||||
#define CMP_STATIC_CAST(x,y) static_cast<x>(y)
|
||||
#else
|
||||
#define CMP_STATIC_CAST(x,y) (x)(y)
|
||||
#endif
|
||||
|
||||
|
||||
#define CMP_SET_BC13_DECODER_RGBA // Sets mapping BC1, BC2 & BC3 to decode Red,Green,Blue and Alpha
|
||||
// RGBA to channels [0,1,2,3] else BGRA maps to [0,1,2,3]
|
||||
// BC4 alpha always maps as AAAA to channels [0,1,2,3]
|
||||
@ -70,8 +98,8 @@
|
||||
|
||||
//#define USE_BLOCK_LINEAR
|
||||
|
||||
#define CMP_FLOAT_MAX 3.402823466e+38F // max value used to detect an Error in processing
|
||||
#define CMP_FLOAT_MAX_EXP 38
|
||||
#define CMP_FLOAT_MAX 3.402823466e+38F // max value used to detect an Error in processing
|
||||
#define CMP_FLOAT_MAX_EXP 38
|
||||
#define USE_PROCESS_SEPERATE_ALPHA // Enable this to use higher quality code using CompressDualIndexBlock
|
||||
#define COMPRESSED_BLOCK_SIZE 16 // Size of a compressed block in bytes
|
||||
#define MAX_DIMENSION_BIG 4 // Max number of channels (RGBA)
|
||||
@ -84,6 +112,75 @@
|
||||
//#define USE_BLOCK_LINEAR // Source Data is organized in linear form for each block : Experimental Code not fully developed
|
||||
//#define USE_DOUBLE // Default is to use float, enable to use double data types only for float definitions
|
||||
|
||||
//---------------------------------------------
|
||||
// Predefinitions for GPU and CPU compiled code
|
||||
//---------------------------------------------
|
||||
|
||||
#ifdef ASPM_HLSL
|
||||
// ==== Vectors ====
|
||||
typedef float2 CGU_Vec2f;
|
||||
typedef float2 CGV_Vec2f;
|
||||
typedef float3 CGU_Vec3f;
|
||||
typedef float3 CGV_Vec3f;
|
||||
typedef float4 CGU_Vec4f;
|
||||
typedef float4 CGV_Vec4f;
|
||||
|
||||
typedef int2 CGU_Vec2i;
|
||||
typedef int2 CGV_Vec2i;
|
||||
typedef uint2 CGU_Vec2ui;
|
||||
typedef uint2 CGV_Vec2ui;
|
||||
|
||||
typedef int3 CGU_Vec3i;
|
||||
typedef int3 CGV_Vec3i;
|
||||
typedef uint3 CGU_Vec3ui;
|
||||
typedef uint3 CGV_Vec3ui;
|
||||
|
||||
typedef uint4 CGU_Vec4ui;
|
||||
typedef uint4 CGV_Vec4ui;
|
||||
|
||||
// ==== Scalar Types ==== to remove from code
|
||||
typedef int CGU_INT8;
|
||||
typedef uint CGU_INT;
|
||||
typedef int CGV_INT;
|
||||
typedef uint CGU_UINT8;
|
||||
typedef uint CGU_UINT;
|
||||
|
||||
// ==== Scalar Types ====
|
||||
typedef int CGU_BOOL;
|
||||
typedef int CGV_BOOL;
|
||||
typedef int CGU_INT32;
|
||||
typedef int CGV_INT32;
|
||||
typedef uint CGU_UINT32;
|
||||
typedef uint CGV_UINT32;
|
||||
typedef float CGV_FLOAT;
|
||||
typedef float CGU_FLOAT;
|
||||
typedef min16float CGU_MIN16_FLOAT; // FP16 GPU support defaults to 32 bit if no HW support
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#define CMP_CDECL
|
||||
|
||||
#define BC7_ENCODECLASS
|
||||
#define CMP_EXPORT
|
||||
#define INLINE
|
||||
#define uniform
|
||||
#define varying
|
||||
#define CMP_GLOBAL
|
||||
#define CMP_KERNEL
|
||||
#define CMP_CONSTANT
|
||||
#define CMP_STATIC
|
||||
#define CMP_REFINOUT
|
||||
#define CMP_PTRINOUT
|
||||
#define CMP_INOUT inout
|
||||
#define CMP_OUT out
|
||||
#define CMP_IN in
|
||||
#define CMP_UNUSED(x) (x);
|
||||
#define CMP_UNROLL [unroll]
|
||||
|
||||
|
||||
|
||||
#else
|
||||
|
||||
typedef enum {
|
||||
CGU_CORE_OK = 0, // No errors, call was successfull
|
||||
CGU_CORE_ERR_UNKOWN, // An unknown error occurred
|
||||
@ -95,26 +192,41 @@ typedef enum {
|
||||
} CGU_ERROR_CODES;
|
||||
|
||||
|
||||
//---------------------------------------------
|
||||
// Predefinitions for GPU and CPU compiled code
|
||||
//---------------------------------------------
|
||||
|
||||
#ifdef ASPM_GPU // GPU Based code
|
||||
#ifdef ASPM_OPENCL // GPU Based code using OpenCL
|
||||
// ==== Vectors ====
|
||||
typedef float2 CGU_Vec2f;
|
||||
typedef float2 CGV_Vec2f;
|
||||
typedef float3 CMP_Vec3f;
|
||||
typedef float3 CGU_Vec3f;
|
||||
typedef float3 CGV_Vec3f;
|
||||
typedef float4 CGU_Vec4f;
|
||||
typedef float4 CGV_Vec4f;
|
||||
|
||||
typedef uchar3 CGU_Vec3uc;
|
||||
typedef uchar3 CGV_Vec3uc;
|
||||
|
||||
typedef uchar4 CMP_Vec4uc;
|
||||
typedef uchar4 CGU_Vec4uc;
|
||||
typedef uchar4 CGV_Vec4uc;
|
||||
|
||||
typedef int2 CGU_Vec2i;
|
||||
typedef int2 CGV_Vec2i;
|
||||
typedef int3 CGU_Vec3i;
|
||||
typedef int3 CGV_Vec3i;
|
||||
typedef int4 CGU_Vec4i;
|
||||
typedef int4 CGV_Vec4i;
|
||||
|
||||
typedef uint2 CGU_Vec2ui;
|
||||
typedef uint2 CGV_Vec2ui;
|
||||
typedef uint3 CGU_Vec3ui;
|
||||
typedef uint3 CGV_Vec3ui;
|
||||
typedef uint4 CGU_Vec4ui;
|
||||
typedef uint4 CGV_Vec4ui;
|
||||
|
||||
|
||||
#define USE_BC7_SP_ERR_IDX
|
||||
#define ASPM_PRINT(args) printf args
|
||||
#define BC7_ENCODECLASS
|
||||
#define ASPM_PRINT(args) printf args
|
||||
|
||||
#define CMP_EXPORT
|
||||
#define INLINE
|
||||
@ -124,13 +236,20 @@ typedef enum {
|
||||
#define CMP_KERNEL __kernel
|
||||
#define CMP_CONSTANT __constant
|
||||
#define CMP_STATIC
|
||||
|
||||
#define CMP_REFINOUT &
|
||||
#define CMP_PTRINOUT *
|
||||
#define CMP_INOUT
|
||||
#define CMP_OUT
|
||||
#define CMP_IN
|
||||
#define CMP_UNUSED(x)
|
||||
#define CMP_UNROLL
|
||||
|
||||
typedef unsigned int CGU_DWORD; //32bits
|
||||
typedef int CGU_INT; //32bits
|
||||
typedef int CGU_BOOL;
|
||||
typedef bool CGU_BOOL;
|
||||
typedef unsigned short CGU_SHORT; //16bits
|
||||
typedef float CGU_FLOAT;
|
||||
typedef half CGU_MIN16_FLOAT; // FP16 GPU support defaults to 32 bit if no HW support
|
||||
typedef unsigned int uint32; // need to remove this def
|
||||
|
||||
typedef int CGV_INT;
|
||||
@ -163,6 +282,15 @@ typedef enum {
|
||||
#else
|
||||
// CPU & ASPM definitions
|
||||
|
||||
#define CMP_REFINOUT &
|
||||
#define CMP_PTRINOUT *
|
||||
#define CMP_INOUT
|
||||
#define CMP_OUT
|
||||
#define CMP_IN
|
||||
#define CMP_UNUSED(x) (void)(x);
|
||||
#define CMP_UNROLL
|
||||
|
||||
|
||||
#ifdef ASPM // SPMD ,SIMD CPU code
|
||||
// using hybrid (CPU/GPU) aspm compiler
|
||||
#define ASPM_PRINT(args) print args
|
||||
@ -185,6 +313,8 @@ typedef enum {
|
||||
typedef unsigned int64 uint64;
|
||||
typedef uniform float CGU_FLOAT;
|
||||
typedef varying float CGV_FLOAT;
|
||||
typedef uniform float CGU_MIN16_FLOAT;
|
||||
|
||||
typedef uniform uint8 CGU_UINT8;
|
||||
typedef varying uint8 CGV_UINT8;
|
||||
|
||||
@ -192,18 +322,24 @@ typedef enum {
|
||||
typedef CGV_UINT8<4> CGV_Vec4uc;
|
||||
typedef CGU_UINT8<4> CGU_Vec4uc;
|
||||
|
||||
typedef CGU_FLOAT<3> CGU_Vec3f;
|
||||
typedef CGV_FLOAT<3> CGV_Vec3f;
|
||||
|
||||
typedef CGU_FLOAT<2> CGU_Vec2f;
|
||||
typedef CGV_FLOAT<2> CGV_Vec2f;
|
||||
typedef CGU_FLOAT<3> CGU_Vec3f;
|
||||
typedef CGV_FLOAT<3> CGV_Vec3f;
|
||||
typedef CGU_FLOAT<4> CGU_Vec4f;
|
||||
typedef CGV_FLOAT<4> CGV_Vec4f;
|
||||
|
||||
typedef CGU_UINT32<3> CGU_Vec3ui;
|
||||
typedef CGV_UINT32<3> CGV_Vec3ui;
|
||||
|
||||
typedef CGU_UINT32<4> CGU_Vec4ui;
|
||||
typedef CGV_UINT32<4> CGV_Vec4ui;
|
||||
|
||||
#define CMP_CDECL
|
||||
|
||||
#else // standard CPU code
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include "cmp_math_vec4.h"
|
||||
#include INC_cmp_math_vec4
|
||||
|
||||
// using CPU compiler
|
||||
#define ASPM_PRINT(args) printf args
|
||||
@ -227,7 +363,7 @@ typedef enum {
|
||||
typedef unsigned long uint64;
|
||||
|
||||
typedef int8 CGV_BOOL;
|
||||
typedef int8 CGU_BOOL;
|
||||
typedef bool CGU_BOOL;
|
||||
typedef int16 CGU_WORD;
|
||||
typedef uint8 CGU_SHORT;
|
||||
typedef int64 CGU_LONG;
|
||||
@ -235,8 +371,19 @@ typedef enum {
|
||||
|
||||
typedef uniform float CGU_FLOAT;
|
||||
typedef varying float CGV_FLOAT;
|
||||
typedef uniform float CGU_MIN16_FLOAT;
|
||||
|
||||
typedef uniform uint8 CGU_UINT8;
|
||||
typedef varying uint8 CGV_UINT8;
|
||||
|
||||
typedef CMP_Vec3ui CGU_Vec3ui;
|
||||
typedef CMP_Vec3ui CGV_Vec3ui;
|
||||
|
||||
typedef CMP_Vec4ui CGU_Vec4ui;
|
||||
typedef CMP_Vec4ui CGV_Vec4ui;
|
||||
typedef CMP_Vec4f CGU_Vec4f;
|
||||
typedef CMP_Vec4f CGV_Vec4f;
|
||||
|
||||
#if defined(WIN32) || defined(_WIN64)
|
||||
#define CMP_CDECL __cdecl
|
||||
#else
|
||||
@ -275,9 +422,10 @@ typedef enum {
|
||||
typedef uint16 CGV_UINT16;
|
||||
typedef uint32 CGV_UINT32;
|
||||
typedef uint64 CGV_UINT64;
|
||||
#endif // ASPM_GPU
|
||||
|
||||
|
||||
#endif // else ASPM_GPU
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CGU_UINT32 m_src_width;
|
||||
@ -287,14 +435,20 @@ typedef struct
|
||||
CGU_FLOAT m_fquality;
|
||||
} Source_Info;
|
||||
|
||||
typedef unsigned char* CGU_PTR;
|
||||
|
||||
// Ref Compute_CPU_HPC
|
||||
struct texture_surface
|
||||
{
|
||||
CGU_UINT8* ptr;
|
||||
CGU_PTR ptr;
|
||||
CGU_INT width,
|
||||
height,
|
||||
stride;
|
||||
CGU_INT channels;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // else ASPM_HLSL
|
||||
|
||||
#endif // Common_Def.h
|
||||
|
Reference in New Issue
Block a user