| 1 |
/***********************************************************************\ |
|---|
| 2 |
* d3d10shader.d * |
|---|
| 3 |
* * |
|---|
| 4 |
* Windows API header module * |
|---|
| 5 |
* * |
|---|
| 6 |
* Placed into public domain * |
|---|
| 7 |
\***********************************************************************/ |
|---|
| 8 |
module win32.directx.d3d10shader; |
|---|
| 9 |
|
|---|
| 10 |
private import win32.windows; |
|---|
| 11 |
private import win32.directx.d3d10; |
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
uint D3D10_TX_VERSION(uint _Major, uint _Minor) { |
|---|
| 15 |
return ('T' << 24) | ('X' << 16) | (_Major << 8) | _Minor; |
|---|
| 16 |
} |
|---|
| 17 |
|
|---|
| 18 |
const D3D10_SHADER_DEBUG = 1 << 0; |
|---|
| 19 |
const D3D10_SHADER_SKIP_VALIDATION = 1 << 1; |
|---|
| 20 |
const D3D10_SHADER_SKIP_OPTIMIZATION = 1 << 2; |
|---|
| 21 |
const D3D10_SHADER_PACK_MATRIX_ROW_MAJOR = 1 << 3; |
|---|
| 22 |
const D3D10_SHADER_PACK_MATRIX_COLUMN_MAJOR = 1 << 4; |
|---|
| 23 |
const D3D10_SHADER_PARTIAL_PRECISION = 1 << 5; |
|---|
| 24 |
const D3D10_SHADER_FORCE_VS_SOFTWARE_NO_OPT = 1 << 6; |
|---|
| 25 |
const D3D10_SHADER_FORCE_PS_SOFTWARE_NO_OPT = 1 << 7; |
|---|
| 26 |
const D3D10_SHADER_NO_PRESHADER = 1 << 8; |
|---|
| 27 |
const D3D10_SHADER_AVOID_FLOW_CONTROL = 1 << 9; |
|---|
| 28 |
const D3D10_SHADER_PREFER_FLOW_CONTROL = 1 << 10; |
|---|
| 29 |
const D3D10_SHADER_ENABLE_STRICTNESS = 1 << 11; |
|---|
| 30 |
const D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY = 1 << 12; |
|---|
| 31 |
const D3D10_SHADER_IEEE_STRICTNESS = 1 << 13; |
|---|
| 32 |
const D3D10_SHADER_OPTIMIZATION_LEVEL0 = 1 << 14; |
|---|
| 33 |
const D3D10_SHADER_OPTIMIZATION_LEVEL1 = 0; |
|---|
| 34 |
const D3D10_SHADER_OPTIMIZATION_LEVEL2 = (1 << 14) | (1 << 15); |
|---|
| 35 |
const D3D10_SHADER_OPTIMIZATION_LEVEL3 = 1 << 15; |
|---|
| 36 |
|
|---|
| 37 |
struct D3D10_SHADER_MACRO { |
|---|
| 38 |
LPCSTR Name; |
|---|
| 39 |
LPCSTR Definition; |
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
enum D3D10_SHADER_VARIABLE_CLASS { |
|---|
| 43 |
D3D10_SVC_SCALAR, |
|---|
| 44 |
D3D10_SVC_VECTOR, |
|---|
| 45 |
D3D10_SVC_MATRIX_ROWS, |
|---|
| 46 |
D3D10_SVC_MATRIX_COLUMNS, |
|---|
| 47 |
D3D10_SVC_OBJECT, |
|---|
| 48 |
D3D10_SVC_STRUCT, |
|---|
| 49 |
D3D10_SVC_FORCE_DWORD = 0x7fffffff |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|
| 52 |
enum D3D10_SHADER_VARIABLE_FLAGS { |
|---|
| 53 |
D3D10_SVF_USERPACKED = 1, |
|---|
| 54 |
D3D10_SVF_USED = 2, |
|---|
| 55 |
D3D10_SVF_FORCE_DWORD = 0x7fffffff |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
enum D3D10_SHADER_VARIABLE_TYPE { |
|---|
| 59 |
D3D10_SVT_VOID = 0, |
|---|
| 60 |
D3D10_SVT_BOOL = 1, |
|---|
| 61 |
D3D10_SVT_INT = 2, |
|---|
| 62 |
D3D10_SVT_FLOAT = 3, |
|---|
| 63 |
D3D10_SVT_STRING = 4, |
|---|
| 64 |
D3D10_SVT_TEXTURE = 5, |
|---|
| 65 |
D3D10_SVT_TEXTURE1D = 6, |
|---|
| 66 |
D3D10_SVT_TEXTURE2D = 7, |
|---|
| 67 |
D3D10_SVT_TEXTURE3D = 8, |
|---|
| 68 |
D3D10_SVT_TEXTURECUBE = 9, |
|---|
| 69 |
D3D10_SVT_SAMPLER = 10, |
|---|
| 70 |
D3D10_SVT_PIXELSHADER = 15, |
|---|
| 71 |
D3D10_SVT_VERTEXSHADER = 16, |
|---|
| 72 |
D3D10_SVT_UINT = 19, |
|---|
| 73 |
D3D10_SVT_UINT8 = 20, |
|---|
| 74 |
D3D10_SVT_GEOMETRYSHADER = 21, |
|---|
| 75 |
D3D10_SVT_RASTERIZER = 22, |
|---|
| 76 |
D3D10_SVT_DEPTHSTENCIL = 23, |
|---|
| 77 |
D3D10_SVT_BLEND = 24, |
|---|
| 78 |
D3D10_SVT_BUFFER = 25, |
|---|
| 79 |
D3D10_SVT_CBUFFER = 26, |
|---|
| 80 |
D3D10_SVT_TBUFFER = 27, |
|---|
| 81 |
D3D10_SVT_TEXTURE1DARRAY = 28, |
|---|
| 82 |
D3D10_SVT_TEXTURE2DARRAY = 29, |
|---|
| 83 |
D3D10_SVT_RENDERTARGETVIEW = 30, |
|---|
| 84 |
D3D10_SVT_DEPTHSTENCILVIEW = 31, |
|---|
| 85 |
D3D10_SVT_TEXTURE2DMS = 32, |
|---|
| 86 |
D3D10_SVT_TEXTURE2DMSARRAY = 33, |
|---|
| 87 |
D3D10_SVT_TEXTURECUBEARRAY = 34, |
|---|
| 88 |
D3D10_SVT_FORCE_DWORD = 0x7fffffff |
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
enum D3D10_SHADER_INPUT_FLAGS { |
|---|
| 92 |
D3D10_SIF_USERPACKED = 1, |
|---|
| 93 |
D3D10_SIF_COMPARISON_SAMPLER = 2, |
|---|
| 94 |
D3D10_SIF_TEXTURE_COMPONENT_0 = 4, |
|---|
| 95 |
D3D10_SIF_TEXTURE_COMPONENT_1 = 8, |
|---|
| 96 |
D3D10_SIF_TEXTURE_COMPONENTS = 12, |
|---|
| 97 |
D3D10_SIF_FORCE_DWORD = 0x7fffffff |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
enum D3D10_SHADER_INPUT_TYPE { |
|---|
| 101 |
D3D10_SIT_CBUFFER, |
|---|
| 102 |
D3D10_SIT_TBUFFER, |
|---|
| 103 |
D3D10_SIT_TEXTURE, |
|---|
| 104 |
D3D10_SIT_SAMPLER |
|---|
| 105 |
} |
|---|
| 106 |
|
|---|
| 107 |
enum D3D10_SHADER_CBUFFER_FLAGS { |
|---|
| 108 |
D3D10_CBF_USERPACKED = 1, |
|---|
| 109 |
D3D10_CBF_FORCE_DWORD = 0x7fffffff |
|---|
| 110 |
} |
|---|
| 111 |
|
|---|
| 112 |
enum D3D10_CBUFFER_TYPE { |
|---|
| 113 |
D3D10_CT_CBUFFER, |
|---|
| 114 |
D3D10_CT_TBUFFER |
|---|
| 115 |
} |
|---|
| 116 |
|
|---|
| 117 |
enum D3D10_NAME { |
|---|
| 118 |
D3D10_NAME_UNDEFINED = 0, |
|---|
| 119 |
D3D10_NAME_POSITION = 1, |
|---|
| 120 |
D3D10_NAME_CLIP_DISTANCE = 2, |
|---|
| 121 |
D3D10_NAME_CULL_DISTANCE = 3, |
|---|
| 122 |
D3D10_NAME_RENDER_TARGET_ARRAY_INDEX = 4, |
|---|
| 123 |
D3D10_NAME_VIEWPORT_ARRAY_INDEX = 5, |
|---|
| 124 |
D3D10_NAME_VERTEX_ID = 6, |
|---|
| 125 |
D3D10_NAME_PRIMITIVE_ID = 7, |
|---|
| 126 |
D3D10_NAME_INSTANCE_ID = 8, |
|---|
| 127 |
D3D10_NAME_IS_FRONT_FACE = 9, |
|---|
| 128 |
D3D10_NAME_SAMPLE_INDEX = 10, |
|---|
| 129 |
D3D10_NAME_TARGET = 64, |
|---|
| 130 |
D3D10_NAME_DEPTH = 65, |
|---|
| 131 |
D3D10_NAME_COVERAGE = 66 |
|---|
| 132 |
} |
|---|
| 133 |
|
|---|
| 134 |
enum D3D10_RESOURCE_RETURN_TYPE { |
|---|
| 135 |
D3D10_RETURN_TYPE_UNORM = 1, |
|---|
| 136 |
D3D10_RETURN_TYPE_SNORM, |
|---|
| 137 |
D3D10_RETURN_TYPE_SINT, |
|---|
| 138 |
D3D10_RETURN_TYPE_UINT, |
|---|
| 139 |
D3D10_RETURN_TYPE_FLOAT, |
|---|
| 140 |
D3D10_RETURN_TYPE_MIXED |
|---|
| 141 |
} |
|---|
| 142 |
|
|---|
| 143 |
enum D3D10_REGISTER_COMPONENT_TYPE { |
|---|
| 144 |
D3D10_REGISTER_COMPONENT_UNKNOWN = 0, |
|---|
| 145 |
D3D10_REGISTER_COMPONENT_UINT32, |
|---|
| 146 |
D3D10_REGISTER_COMPONENT_SINT32, |
|---|
| 147 |
D3D10_REGISTER_COMPONENT_FLOAT32 |
|---|
| 148 |
} |
|---|
| 149 |
|
|---|
| 150 |
enum D3D10_INCLUDE_TYPE { |
|---|
| 151 |
D3D10_INCLUDE_LOCAL, |
|---|
| 152 |
D3D10_INCLUDE_SYSTEM, |
|---|
| 153 |
D3D10_INCLUDE_FORCE_DWORD = 0x7fffffff |
|---|
| 154 |
} |
|---|
| 155 |
|
|---|
| 156 |
interface ID3D10Include { |
|---|
| 157 |
/* TODO: fix vtbl[0] bug |
|---|
| 158 |
extern(Windows) : |
|---|
| 159 |
HRESULT Open(D3D10_INCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID* ppData, UINT* pBytes); |
|---|
| 160 |
HRESULT Close(LPCVOID pData); |
|---|
| 161 |
*/ |
|---|
| 162 |
} |
|---|
| 163 |
|
|---|
| 164 |
struct D3D10_SHADER_DESC { |
|---|
| 165 |
UINT Version; |
|---|
| 166 |
LPCSTR Creator; |
|---|
| 167 |
UINT Flags; |
|---|
| 168 |
UINT ConstantBuffers; |
|---|
| 169 |
UINT BoundResources; |
|---|
| 170 |
UINT InputParameters; |
|---|
| 171 |
UINT OutputParameters; |
|---|
| 172 |
UINT InstructionCount; |
|---|
| 173 |
UINT TempRegisterCount; |
|---|
| 174 |
UINT TempArrayCount; |
|---|
| 175 |
UINT DefCount; |
|---|
| 176 |
UINT DclCount; |
|---|
| 177 |
UINT TextureNormalInstructions; |
|---|
| 178 |
UINT TextureLoadInstructions; |
|---|
| 179 |
UINT TextureCompInstructions; |
|---|
| 180 |
UINT TextureBiasInstructions; |
|---|
| 181 |
UINT TextureGradientInstructions; |
|---|
| 182 |
UINT FloatInstructionCount; |
|---|
| 183 |
UINT IntInstructionCount; |
|---|
| 184 |
UINT UintInstructionCount; |
|---|
| 185 |
UINT StaticFlowControlCount; |
|---|
| 186 |
UINT DynamicFlowControlCount; |
|---|
| 187 |
UINT MacroInstructionCount; |
|---|
| 188 |
UINT ArrayInstructionCount; |
|---|
| 189 |
UINT CutInstructionCount; |
|---|
| 190 |
UINT EmitInstructionCount; |
|---|
| 191 |
D3D10_PRIMITIVE_TOPOLOGY GSOutputTopology; |
|---|
| 192 |
UINT GSMaxOutputVertexCount; |
|---|
| 193 |
} |
|---|
| 194 |
|
|---|
| 195 |
struct D3D10_SHADER_BUFFER_DESC { |
|---|
| 196 |
LPCSTR Name; |
|---|
| 197 |
D3D10_CBUFFER_TYPE Type; |
|---|
| 198 |
UINT Variables; |
|---|
| 199 |
UINT Size; |
|---|
| 200 |
UINT uFlags; |
|---|
| 201 |
} |
|---|
| 202 |
|
|---|
| 203 |
struct D3D10_SHADER_VARIABLE_DESC { |
|---|
| 204 |
LPCSTR Name; |
|---|
| 205 |
UINT StartOffset; |
|---|
| 206 |
UINT Size; |
|---|
| 207 |
UINT uFlags; |
|---|
| 208 |
LPVOID DefaultValue; |
|---|
| 209 |
} |
|---|
| 210 |
|
|---|
| 211 |
struct D3D10_SHADER_TYPE_DESC { |
|---|
| 212 |
D3D10_SHADER_VARIABLE_CLASS Class; |
|---|
| 213 |
D3D10_SHADER_VARIABLE_TYPE Type; |
|---|
| 214 |
UINT Rows; |
|---|
| 215 |
UINT Columns; |
|---|
| 216 |
UINT Elements; |
|---|
| 217 |
UINT Members; |
|---|
| 218 |
UINT Offset; |
|---|
| 219 |
} |
|---|
| 220 |
|
|---|
| 221 |
struct D3D10_SHADER_INPUT_BIND_DESC { |
|---|
| 222 |
LPCSTR Name; |
|---|
| 223 |
D3D10_SHADER_INPUT_TYPE Type; |
|---|
| 224 |
UINT BindPoint; |
|---|
| 225 |
UINT BindCount; |
|---|
| 226 |
UINT uFlags; |
|---|
| 227 |
D3D10_RESOURCE_RETURN_TYPE ReturnType; |
|---|
| 228 |
D3D10_SRV_DIMENSION Dimension; |
|---|
| 229 |
UINT NumSamples; |
|---|
| 230 |
} |
|---|
| 231 |
|
|---|
| 232 |
struct D3D10_SIGNATURE_PARAMETER_DESC { |
|---|
| 233 |
LPCSTR SemanticName; |
|---|
| 234 |
UINT SemanticIndex; |
|---|
| 235 |
UINT Register; |
|---|
| 236 |
D3D10_NAME SystemValueType; |
|---|
| 237 |
D3D10_REGISTER_COMPONENT_TYPE ComponentType; |
|---|
| 238 |
BYTE Mask; |
|---|
| 239 |
BYTE ReadWriteMask; |
|---|
| 240 |
} |
|---|
| 241 |
|
|---|
| 242 |
extern(C) const GUID IID_ID3D10ShaderReflectionType = {0xc530ad7d, 0x9b16, 0x4395, [0xa9, 0x79, 0xba, 0x2e, 0xcf, 0xf8, 0x3a, 0xdd]}; |
|---|
| 243 |
|
|---|
| 244 |
interface ID3D10ShaderReflectionType { |
|---|
| 245 |
/* TODO: fix vtbl[0] bug |
|---|
| 246 |
extern(Windows) : |
|---|
| 247 |
HRESULT GetDesc(D3D10_SHADER_TYPE_DESC* pDesc); |
|---|
| 248 |
ID3D10ShaderReflectionType* GetMemberTypeByIndex(UINT Index); |
|---|
| 249 |
ID3D10ShaderReflectionType* GetMemberTypeByName(LPCSTR Name); |
|---|
| 250 |
LPCSTR GetMemberTypeName(UINT Index); |
|---|
| 251 |
*/ |
|---|
| 252 |
} |
|---|
| 253 |
|
|---|
| 254 |
extern(C) const GUID IID_ID3D10ShaderReflectionVariable = {0x1bf63c95, 0x2650, 0x405d, [0x99, 0xc1, 0x36, 0x36, 0xbd, 0x1d, 0xa0, 0xa1]}; |
|---|
| 255 |
|
|---|
| 256 |
interface ID3D10ShaderReflectionVariable { |
|---|
| 257 |
/* TODO: fix vtbl[0] bug |
|---|
| 258 |
extern(Windows) : |
|---|
| 259 |
HRESULT GetDesc(D3D10_SHADER_VARIABLE_DESC* pDesc); |
|---|
| 260 |
ID3D10ShaderReflectionType* GetType(); |
|---|
| 261 |
*/ |
|---|
| 262 |
} |
|---|
| 263 |
|
|---|
| 264 |
extern(C) const GUID IID_ID3D10ShaderReflectionConstantBuffer = {0x66c66a94, 0xdddd, 0x4b62, [0xa6, 0x6a, 0xf0, 0xda, 0x33, 0xc2, 0xb4, 0xd0]}; |
|---|
| 265 |
|
|---|
| 266 |
interface ID3D10ShaderReflectionConstantBuffer { |
|---|
| 267 |
/* TODO: fix vtbl[0] bug |
|---|
| 268 |
extern(Windows) : |
|---|
| 269 |
HRESULT GetDesc(D3D10_SHADER_BUFFER_DESC* pDesc); |
|---|
| 270 |
ID3D10ShaderReflectionVariable* GetVariableByIndex(UINT Index); |
|---|
| 271 |
ID3D10ShaderReflectionVariable* GetVariableByName(LPCSTR Name); |
|---|
| 272 |
*/ |
|---|
| 273 |
} |
|---|
| 274 |
|
|---|
| 275 |
extern(C) const GUID IID_ID3D10ShaderReflection = {0xd40e20b6, 0xf8f7, 0x42ad, [0xab, 0x20, 0x4b, 0xaf, 0x8f, 0x15, 0xdf, 0xaa]}; |
|---|
| 276 |
|
|---|
| 277 |
interface ID3D10ShaderReflection : IUnknown { |
|---|
| 278 |
extern(Windows) : |
|---|
| 279 |
HRESULT QueryInterface(REFIID iid, LPVOID* ppv); |
|---|
| 280 |
ULONG AddRef(); |
|---|
| 281 |
ULONG Release(); |
|---|
| 282 |
HRESULT GetDesc(D3D10_SHADER_DESC* pDesc); |
|---|
| 283 |
ID3D10ShaderReflectionConstantBuffer* GetConstantBufferByIndex(UINT Index); |
|---|
| 284 |
ID3D10ShaderReflectionConstantBuffer* GetConstantBufferByName(LPCSTR Name); |
|---|
| 285 |
HRESULT GetResourceBindingDesc(UINT ResourceIndex, D3D10_SHADER_INPUT_BIND_DESC* pDesc); |
|---|
| 286 |
HRESULT GetInputParameterDesc(UINT ParameterIndex, D3D10_SIGNATURE_PARAMETER_DESC* pDesc); |
|---|
| 287 |
HRESULT GetOutputParameterDesc(UINT ParameterIndex, D3D10_SIGNATURE_PARAMETER_DESC* pDesc); |
|---|
| 288 |
} |
|---|
| 289 |
|
|---|
| 290 |
HRESULT D3D10CompileShader(LPCSTR pSrcData, SIZE_T SrcDataLen, LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, ID3D10Include pInclude, LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, ID3D10Blob* ppShader, ID3D10Blob* ppErrorMsgs); |
|---|
| 291 |
HRESULT D3D10DisassembleShader(void* pShader, SIZE_T BytecodeLength, BOOL EnableColorCode, LPCSTR pComments, ID3D10Blob* ppDisassembly); |
|---|
| 292 |
LPCSTR D3D10GetPixelShaderProfile(ID3D10Device pDevice); |
|---|
| 293 |
LPCSTR D3D10GetVertexShaderProfile(ID3D10Device pDevice); |
|---|
| 294 |
LPCSTR D3D10GetGeometryShaderProfile(ID3D10Device pDevice); |
|---|
| 295 |
HRESULT D3D10ReflectShader(void* pShaderBytecode, SIZE_T BytecodeLength, ID3D10ShaderReflection* ppReflector); |
|---|
| 296 |
HRESULT D3D10PreprocessShader(LPCSTR pSrcData, SIZE_T SrcDataSize, LPCSTR pFileName, D3D10_SHADER_MACRO* pDefines, ID3D10Include pInclude, ID3D10Blob* ppShaderText, ID3D10Blob* ppErrorMsgs); |
|---|
| 297 |
HRESULT D3D10GetInputSignatureBlob(void* pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob* ppSignatureBlob); |
|---|
| 298 |
HRESULT D3D10GetOutputSignatureBlob(void* pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob* ppSignatureBlob); |
|---|
| 299 |
HRESULT D3D10GetInputAndOutputSignatureBlob(void* pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob* ppSignatureBlob); |
|---|
| 300 |
HRESULT D3D10GetShaderDebugInfo(void* pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob* ppDebugInfo); |
|---|