1 ##########################################################################
3 # Copyright 2012 Jose Fonseca
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 ##########################################################################/
27 from d3dcommon import *
31 D3D10_SHADER = Flags(UINT, [
33 "D3D10_SHADER_SKIP_VALIDATION",
34 "D3D10_SHADER_SKIP_OPTIMIZATION",
35 "D3D10_SHADER_PACK_MATRIX_ROW_MAJOR",
36 "D3D10_SHADER_PACK_MATRIX_COLUMN_MAJOR",
37 "D3D10_SHADER_PARTIAL_PRECISION",
38 "D3D10_SHADER_FORCE_VS_SOFTWARE_NO_OPT",
39 "D3D10_SHADER_FORCE_PS_SOFTWARE_NO_OPT",
40 "D3D10_SHADER_NO_PRESHADER",
41 "D3D10_SHADER_AVOID_FLOW_CONTROL",
42 "D3D10_SHADER_PREFER_FLOW_CONTROL",
43 "D3D10_SHADER_ENABLE_STRICTNESS",
44 "D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY",
45 "D3D10_SHADER_IEEE_STRICTNESS",
46 "D3D10_SHADER_WARNINGS_ARE_ERRORS",
47 "D3D10_SHADER_OPTIMIZATION_LEVEL0",
48 "D3D10_SHADER_OPTIMIZATION_LEVEL1",
49 "D3D10_SHADER_OPTIMIZATION_LEVEL2",
50 "D3D10_SHADER_OPTIMIZATION_LEVEL3",
53 D3D10_SHADER_DESC = Struct("D3D10_SHADER_DESC", [
57 (UINT, "ConstantBuffers"),
58 (UINT, "BoundResources"),
59 (UINT, "InputParameters"),
60 (UINT, "OutputParameters"),
61 (UINT, "InstructionCount"),
62 (UINT, "TempRegisterCount"),
63 (UINT, "TempArrayCount"),
66 (UINT, "TextureNormalInstructions"),
67 (UINT, "TextureLoadInstructions"),
68 (UINT, "TextureCompInstructions"),
69 (UINT, "TextureBiasInstructions"),
70 (UINT, "TextureGradientInstructions"),
71 (UINT, "FloatInstructionCount"),
72 (UINT, "IntInstructionCount"),
73 (UINT, "UintInstructionCount"),
74 (UINT, "StaticFlowControlCount"),
75 (UINT, "DynamicFlowControlCount"),
76 (UINT, "MacroInstructionCount"),
77 (UINT, "ArrayInstructionCount"),
78 (UINT, "CutInstructionCount"),
79 (UINT, "EmitInstructionCount"),
80 (D3D10_PRIMITIVE_TOPOLOGY, "GSOutputTopology"),
81 (UINT, "GSMaxOutputVertexCount"),
84 D3D10_SHADER_BUFFER_DESC = Struct("D3D10_SHADER_BUFFER_DESC", [
86 (D3D10_CBUFFER_TYPE, "Type"),
92 D3D10_SHADER_VARIABLE_DESC = Struct("D3D10_SHADER_VARIABLE_DESC", [
94 (UINT, "StartOffset"),
97 (LPVOID, "DefaultValue"),
100 D3D10_SHADER_TYPE_DESC = Struct("D3D10_SHADER_TYPE_DESC", [
101 (D3D10_SHADER_VARIABLE_CLASS, "Class"),
102 (D3D10_SHADER_VARIABLE_TYPE, "Type"),
110 D3D10_SHADER_INPUT_BIND_DESC = Struct("D3D10_SHADER_INPUT_BIND_DESC", [
112 (D3D10_SHADER_INPUT_TYPE, "Type"),
116 (D3D10_RESOURCE_RETURN_TYPE, "ReturnType"),
117 (D3D10_SRV_DIMENSION, "Dimension"),
118 (UINT, "NumSamples"),
121 D3D10_SIGNATURE_PARAMETER_DESC = Struct("D3D10_SIGNATURE_PARAMETER_DESC", [
122 (LPCSTR, "SemanticName"),
123 (UINT, "SemanticIndex"),
125 (D3D10_NAME, "SystemValueType"),
126 (D3D10_REGISTER_COMPONENT_TYPE, "ComponentType"),
128 (BYTE, "ReadWriteMask"),
131 ID3D10ShaderReflectionType = Interface("ID3D10ShaderReflectionType")
132 ID3D10ShaderReflectionType.methods += [
133 StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D10_SHADER_TYPE_DESC), "pDesc")]),
134 StdMethod(ObjPointer(ID3D10ShaderReflectionType), "GetMemberTypeByIndex", [(UINT, "Index")]),
135 StdMethod(ObjPointer(ID3D10ShaderReflectionType), "GetMemberTypeByName", [(LPCSTR, "Name")]),
136 StdMethod(LPCSTR, "GetMemberTypeName", [(UINT, "Index")]),
139 ID3D10ShaderReflectionVariable = Interface("ID3D10ShaderReflectionVariable")
140 ID3D10ShaderReflectionVariable.methods += [
141 StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D10_SHADER_VARIABLE_DESC), "pDesc")]),
142 StdMethod(ObjPointer(ID3D10ShaderReflectionType), "GetType", []),
145 ID3D10ShaderReflectionConstantBuffer = Interface("ID3D10ShaderReflectionConstantBuffer")
146 ID3D10ShaderReflectionConstantBuffer.methods += [
147 StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D10_SHADER_BUFFER_DESC), "pDesc")]),
148 StdMethod(ObjPointer(ID3D10ShaderReflectionVariable), "GetVariableByIndex", [(UINT, "Index")]),
149 StdMethod(ObjPointer(ID3D10ShaderReflectionVariable), "GetVariableByName", [(LPCSTR, "Name")]),
152 ID3D10ShaderReflection = Interface("ID3D10ShaderReflection", IUnknown)
153 ID3D10ShaderReflection.methods += [
154 StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D10_SHADER_DESC), "pDesc")]),
155 StdMethod(ObjPointer(ID3D10ShaderReflectionConstantBuffer), "GetConstantBufferByIndex", [(UINT, "Index")]),
156 StdMethod(ObjPointer(ID3D10ShaderReflectionConstantBuffer), "GetConstantBufferByName", [(LPCSTR, "Name")]),
157 StdMethod(HRESULT, "GetResourceBindingDesc", [(UINT, "ResourceIndex"), Out(Pointer(D3D10_SHADER_INPUT_BIND_DESC), "pDesc")]),
158 StdMethod(HRESULT, "GetInputParameterDesc", [(UINT, "ParameterIndex"), Out(Pointer(D3D10_SIGNATURE_PARAMETER_DESC), "pDesc")]),
159 StdMethod(HRESULT, "GetOutputParameterDesc", [(UINT, "ParameterIndex"), Out(Pointer(D3D10_SIGNATURE_PARAMETER_DESC), "pDesc")]),
164 StdFunction(HRESULT, "D3D10CompileShader", [(LPCSTR, "pSrcData"), (SIZE_T, "SrcDataSize"), (LPCSTR, "pFileName"), (Pointer(Const(D3D10_SHADER_MACRO)), "pDefines"), (LPD3D10INCLUDE, "pInclude"), (LPCSTR, "pFunctionName"), (LPCSTR, "pProfile"), (UINT, "Flags"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppShader"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppErrorMsgs")]),
165 StdFunction(HRESULT, "D3D10DisassembleShader", [(Blob(Const(Void), "BytecodeLength"), "pShader"), (SIZE_T, "BytecodeLength"), (BOOL, "EnableColorCode"), (LPCSTR, "pComments"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppDisassembly")]),
166 StdFunction(LPCSTR, "D3D10GetPixelShaderProfile", [(ObjPointer(ID3D10Device), "pDevice")]),
167 StdFunction(LPCSTR, "D3D10GetVertexShaderProfile", [(ObjPointer(ID3D10Device), "pDevice")]),
168 StdFunction(LPCSTR, "D3D10GetGeometryShaderProfile", [(ObjPointer(ID3D10Device), "pDevice")]),
169 StdFunction(HRESULT, "D3D10ReflectShader", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10ShaderReflection)), "ppReflector")]),
170 StdFunction(HRESULT, "D3D10PreprocessShader", [(LPCSTR, "pSrcData"), (SIZE_T, "SrcDataSize"), (LPCSTR, "pFileName"), (Pointer(Const(D3D10_SHADER_MACRO)), "pDefines"), (LPD3D10INCLUDE, "pInclude"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppShaderText"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppErrorMsgs")]),
171 StdFunction(HRESULT, "D3D10GetInputSignatureBlob", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppSignatureBlob")]),
172 StdFunction(HRESULT, "D3D10GetOutputSignatureBlob", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppSignatureBlob")]),
173 StdFunction(HRESULT, "D3D10GetInputAndOutputSignatureBlob", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppSignatureBlob")]),
174 StdFunction(HRESULT, "D3D10GetShaderDebugInfo", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppDebugInfo")]),