📄 d3d10shader.h
字号:
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// File: D3D10Shader.h
// Content: D3D10 Shader Types and APIs
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __D3D10SHADER_H__
#define __D3D10SHADER_H__
#include "d3d10.h"
//---------------------------------------------------------------------------
// D3D10_TX_VERSION:
// --------------
// Version token used to create a procedural texture filler in effects
// Used by D3D10Fill[]TX functions
//---------------------------------------------------------------------------
#define D3D10_TX_VERSION(_Major,_Minor) (('T' << 24) | ('X' << 16) | ((_Major) << 8) | (_Minor))
//----------------------------------------------------------------------------
// D3D10SHADER flags:
// -----------------
// D3D10_SHADER_DEBUG
// Insert debug file/line/type/symbol information.
//
// D3D10_SHADER_SKIP_VALIDATION
// Do not validate the generated code against known capabilities and
// constraints. This option is only recommended when compiling shaders
// you KNOW will work. (ie. have compiled before without this option.)
// Shaders are always validated by D3D before they are set to the device.
//
// D3D10_SHADER_SKIP_OPTIMIZATION
// Instructs the compiler to skip optimization steps during code generation.
// Unless you are trying to isolate a problem in your code using this option
// is not recommended.
//
// D3D10_SHADER_PACK_MATRIX_ROW_MAJOR
// Unless explicitly specified, matrices will be packed in row-major order
// on input and output from the shader.
//
// D3D10_SHADER_PACK_MATRIX_COLUMN_MAJOR
// Unless explicitly specified, matrices will be packed in column-major
// order on input and output from the shader. This is generally more
// efficient, since it allows vector-matrix multiplication to be performed
// using a series of dot-products.
//
// D3D10_SHADER_PARTIAL_PRECISION
// Force all computations in resulting shader to occur at partial precision.
// This may result in faster evaluation of shaders on some hardware.
//
// D3D10_SHADER_FORCE_VS_SOFTWARE_NO_OPT
// Force compiler to compile against the next highest available software
// target for vertex shaders. This flag also turns optimizations off,
// and debugging on.
//
// D3D10_SHADER_FORCE_PS_SOFTWARE_NO_OPT
// Force compiler to compile against the next highest available software
// target for pixel shaders. This flag also turns optimizations off,
// and debugging on.
//
// D3D10_SHADER_NO_PRESHADER
// Disables Preshaders. Using this flag will cause the compiler to not
// pull out static expression for evaluation on the host cpu
//
// D3D10_SHADER_AVOID_FLOW_CONTROL
// Hint compiler to avoid flow-control constructs where possible.
//
// D3D10_SHADER_PREFER_FLOW_CONTROL
// Hint compiler to prefer flow-control constructs where possible.
//
// D3D10_SHADER_ENABLE_STRICTNESS
// By default, the HLSL/Effect compilers are not strict on deprecated syntax.
// Specifying this flag enables the strict mode. Deprecated syntax may be
// removed in a future release, and enabling syntax is a good way to make sure
// your shaders comply to the latest spec.
//
// D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY
// This enables older shaders to compile to 4_0 targets.
//
//----------------------------------------------------------------------------
#define D3D10_SHADER_DEBUG (1 << 0)
#define D3D10_SHADER_SKIP_VALIDATION (1 << 1)
#define D3D10_SHADER_SKIP_OPTIMIZATION (1 << 2)
#define D3D10_SHADER_PACK_MATRIX_ROW_MAJOR (1 << 3)
#define D3D10_SHADER_PACK_MATRIX_COLUMN_MAJOR (1 << 4)
#define D3D10_SHADER_PARTIAL_PRECISION (1 << 5)
#define D3D10_SHADER_FORCE_VS_SOFTWARE_NO_OPT (1 << 6)
#define D3D10_SHADER_FORCE_PS_SOFTWARE_NO_OPT (1 << 7)
#define D3D10_SHADER_NO_PRESHADER (1 << 8)
#define D3D10_SHADER_AVOID_FLOW_CONTROL (1 << 9)
#define D3D10_SHADER_PREFER_FLOW_CONTROL (1 << 10)
#define D3D10_SHADER_ENABLE_STRICTNESS (1 << 11)
#define D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY (1 << 12)
#define D3D10_SHADER_IEEE_STRICTNESS (1 << 13)
// optimization level flags
#define D3D10_SHADER_OPTIMIZATION_LEVEL0 (1 << 14)
#define D3D10_SHADER_OPTIMIZATION_LEVEL1 0
#define D3D10_SHADER_OPTIMIZATION_LEVEL2 ((1 << 14) | (1 << 15))
#define D3D10_SHADER_OPTIMIZATION_LEVEL3 (1 << 15)
//----------------------------------------------------------------------------
// D3D10_SHADER_MACRO:
// ----------
// Preprocessor macro definition. The application pass in a NULL-terminated
// array of this structure to various D3D10 APIs. This enables the application
// to #define tokens at runtime, before the file is parsed.
//----------------------------------------------------------------------------
typedef struct _D3D10_SHADER_MACRO
{
LPCSTR Name;
LPCSTR Definition;
} D3D10_SHADER_MACRO, *LPD3D10_SHADER_MACRO;
//----------------------------------------------------------------------------
// D3D10_SHADER_VARIABLE_CLASS:
//----------------------------------------------------------------------------
typedef enum _D3D10_SHADER_VARIABLE_CLASS
{
D3D10_SVC_SCALAR,
D3D10_SVC_VECTOR,
D3D10_SVC_MATRIX_ROWS,
D3D10_SVC_MATRIX_COLUMNS,
D3D10_SVC_OBJECT,
D3D10_SVC_STRUCT,
// force 32-bit size enum
D3D10_SVC_FORCE_DWORD = 0x7fffffff
} D3D10_SHADER_VARIABLE_CLASS, *LPD3D10_SHADER_VARIABLE_CLASS;
typedef enum _D3D10_SHADER_VARIABLE_FLAGS
{
D3D10_SVF_USERPACKED = 1,
D3D10_SVF_USED = 2,
// force 32-bit size enum
D3D10_SVF_FORCE_DWORD = 0x7fffffff
} D3D10_SHADER_VARIABLE_FLAGS, *LPD3D10_SHADER_VARIABLE_FLAGS;
//----------------------------------------------------------------------------
// D3D10_SHADER_VARIABLE_TYPE:
//----------------------------------------------------------------------------
typedef enum _D3D10_SHADER_VARIABLE_TYPE
{
D3D10_SVT_VOID = 0,
D3D10_SVT_BOOL = 1,
D3D10_SVT_INT = 2,
D3D10_SVT_FLOAT = 3,
D3D10_SVT_STRING = 4,
D3D10_SVT_TEXTURE = 5,
D3D10_SVT_TEXTURE1D = 6,
D3D10_SVT_TEXTURE2D = 7,
D3D10_SVT_TEXTURE3D = 8,
D3D10_SVT_TEXTURECUBE = 9,
D3D10_SVT_SAMPLER = 10,
D3D10_SVT_PIXELSHADER = 15,
D3D10_SVT_VERTEXSHADER = 16,
D3D10_SVT_UINT = 19,
D3D10_SVT_UINT8 = 20,
D3D10_SVT_GEOMETRYSHADER = 21,
D3D10_SVT_RASTERIZER = 22,
D3D10_SVT_DEPTHSTENCIL = 23,
D3D10_SVT_BLEND = 24,
D3D10_SVT_BUFFER = 25,
D3D10_SVT_CBUFFER = 26,
D3D10_SVT_TBUFFER = 27,
D3D10_SVT_TEXTURE1DARRAY = 28,
D3D10_SVT_TEXTURE2DARRAY = 29,
D3D10_SVT_RENDERTARGETVIEW = 30,
D3D10_SVT_DEPTHSTENCILVIEW = 31,
D3D10_SVT_TEXTURE2DMS = 32,
D3D10_SVT_TEXTURE2DMSARRAY = 33,
// force 32-bit size enum
D3D10_SVT_FORCE_DWORD = 0x7fffffff
} D3D10_SHADER_VARIABLE_TYPE, *LPD3D10_SHADER_VARIABLE_TYPE;
typedef enum _D3D10_SHADER_INPUT_FLAGS
{
D3D10_SIF_USERPACKED = 1,
D3D10_SIF_COMPARISON_SAMPLER = 2, // is this a comparison sampler?
// force 32-bit size enum
D3D10_SIF_FORCE_DWORD = 0x7fffffff
} D3D10_SHADER_INPUT_FLAGS, *LPD3D10_SHADER_INPUT_FLAGS;
//----------------------------------------------------------------------------
// D3D10_SHADER_INPUT_TYPE
//----------------------------------------------------------------------------
typedef enum _D3D10_SHADER_INPUT_TYPE
{
D3D10_SIT_CBUFFER,
D3D10_SIT_TBUFFER,
D3D10_SIT_TEXTURE,
D3D10_SIT_SAMPLER,
} D3D10_SHADER_INPUT_TYPE, *LPD3D10_SHADER_INPUT_TYPE;
typedef enum _D3D10_SHADER_CBUFFER_FLAGS
{
D3D10_CBF_USERPACKED = 1,
// force 32-bit size enum
D3D10_CBF_FORCE_DWORD = 0x7fffffff
} D3D10_SHADER_CBUFFER_FLAGS, *LPD3D10_SHADER_CBUFFER_FLAGS;
typedef enum _D3D10_CBUFFER_TYPE
{
D3D10_CT_CBUFFER,
D3D10_CT_TBUFFER,
} D3D10_CBUFFER_TYPE, *LPD3D10_CBUFFER_TYPE;
typedef enum D3D10_NAME
{
D3D10_NAME_UNDEFINED = 0,
// Names meaningful to both HLSL and hardware
D3D10_NAME_POSITION = 1,
D3D10_NAME_CLIP_DISTANCE = 2,
D3D10_NAME_CULL_DISTANCE = 3,
D3D10_NAME_RENDER_TARGET_ARRAY_INDEX = 4,
D3D10_NAME_VIEWPORT_ARRAY_INDEX = 5,
D3D10_NAME_VERTEX_ID = 6,
D3D10_NAME_PRIMITIVE_ID = 7,
D3D10_NAME_INSTANCE_ID = 8,
D3D10_NAME_IS_FRONT_FACE = 9,
// Names meaningful to HLSL only
D3D10_NAME_TARGET = 64,
D3D10_NAME_DEPTH = 65,
} D3D10_NAME;
typedef enum D3D10_RESOURCE_RETURN_TYPE
{
D3D10_RETURN_TYPE_UNORM = 1,
D3D10_RETURN_TYPE_SNORM = 2,
D3D10_RETURN_TYPE_SINT = 3,
D3D10_RETURN_TYPE_UINT = 4,
D3D10_RETURN_TYPE_FLOAT = 5,
D3D10_RETURN_TYPE_MIXED = 6,
} D3D10_RESOURCE_RETURN_TYPE;
typedef enum D3D10_REGISTER_COMPONENT_TYPE
{
D3D10_REGISTER_COMPONENT_UNKNOWN = 0,
D3D10_REGISTER_COMPONENT_UINT32 = 1,
D3D10_REGISTER_COMPONENT_SINT32 = 2,
D3D10_REGISTER_COMPONENT_FLOAT32 = 3
} D3D10_REGISTER_COMPONENT_TYPE;
//----------------------------------------------------------------------------
// D3D10_INCLUDE_TYPE:
//----------------------------------------------------------------------------
typedef enum _D3D10_INCLUDE_TYPE
{
D3D10_INCLUDE_LOCAL,
D3D10_INCLUDE_SYSTEM,
// force 32-bit size enum
D3D10_INCLUDE_FORCE_DWORD = 0x7fffffff
} D3D10_INCLUDE_TYPE, *LPD3D10_INCLUDE_TYPE;
//----------------------------------------------------------------------------
// ID3D10Include:
// -------------
// This interface is intended to be implemented by the application, and can
// be used by various D3D10 APIs. This enables application-specific handling
// of #include directives in source files.
//
// Open()
// Opens an include file. If successful, it should fill in ppData and
// pBytes. The data pointer returned must remain valid until Close is
// subsequently called.
// Close()
// Closes an include file. If Open was successful, Close is guaranteed
// to be called before the API using this interface returns.
//----------------------------------------------------------------------------
typedef interface ID3D10Include ID3D10Include;
typedef interface ID3D10Include *LPD3D10INCLUDE;
#undef INTERFACE
#define INTERFACE ID3D10Include
DECLARE_INTERFACE(ID3D10Include)
{
STDMETHOD(Open)(THIS_ D3D10_INCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes) PURE;
STDMETHOD(Close)(THIS_ LPCVOID pData) PURE;
};
//----------------------------------------------------------------------------
// ID3D10ShaderReflection:
//----------------------------------------------------------------------------
//
// Structure definitions
//
typedef struct _D3D10_SHADER_DESC
{
UINT Version; // Shader version
LPCSTR Creator; // Creator string
UINT Flags; // Shader compilation/parse flags
UINT ConstantBuffers; // Number of constant buffers
UINT BoundResources; // Number of bound resources
UINT InputParameters; // Number of parameters in the input signature
UINT OutputParameters; // Number of parameters in the output signature
UINT InstructionCount; // Number of emitted instructions
UINT TempRegisterCount; // Number of temporary registers used
UINT TempArrayCount; // Number of temporary arrays used
UINT DefCount; // Number of constant defines
UINT DclCount; // Number of declarations (input + output)
UINT TextureNormalInstructions; // Number of non-categorized texture instructions
UINT TextureLoadInstructions; // Number of texture load instructions
UINT TextureCompInstructions; // Number of texture comparison instructions
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -