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