Permalink
Browse files

Trace all d3d10.dll functions.

  • Loading branch information...
1 parent 0f3195f commit 467a42ac831785ae02386ed2f17f3ad14fe824cb @jrfonseca jrfonseca committed May 4, 2012
Showing with 648 additions and 65 deletions.
  1. +8 −0 specs/d3d10.py
  2. +0 −9 specs/d3d10_1.py
  3. +384 −0 specs/d3d10effect.py
  4. +5 −11 specs/d3d10misc.py
  5. +175 −0 specs/d3d10shader.py
  6. +9 −1 specs/d3dcommon.py
  7. +4 −5 specs/dxgi.py
  8. +0 −12 specs/dxgitype.py
  9. +25 −17 specs/scripts/cdecl.py
  10. +4 −3 specs/winapi.py
  11. +3 −1 wrappers/CMakeLists.txt
  12. +30 −5 wrappers/d3d10.def
  13. +1 −1 wrappers/trace.py
View
@@ -897,3 +897,11 @@
Method(BOOL, "GetMultithreadProtected", []),
]
+
+d3d10 = API("d3d10")
+
+
+from d3d10sdklayers import *
+import d3d10misc
+import d3d10shader
+import d3d10effect
View
@@ -26,17 +26,8 @@
"""d3d10_1.h"""
from winapi import *
-from d3d10sdklayers import *
from d3d10 import *
-ID3D10Blob = Interface("ID3D10Blob", IUnknown)
-LPD3D10BLOB = ObjPointer(ID3D10Blob)
-
-ID3D10Blob.methods += [
- Method(LPVOID, "GetBufferPointer", []),
- Method(SIZE_T, "GetBufferSize", []),
-]
-
D3D10_DRIVER_TYPE = Enum("D3D10_DRIVER_TYPE", [
"D3D10_DRIVER_TYPE_HARDWARE",
"D3D10_DRIVER_TYPE_REFERENCE",
View
Oops, something went wrong.
View
@@ -26,18 +26,9 @@
"""d3d10misc.h"""
from winapi import *
-from d3d10sdklayers import *
from d3d10 import *
-ID3D10Blob = Interface("ID3D10Blob", IUnknown)
-LPD3D10BLOB = ObjPointer(ID3D10Blob)
-
-ID3D10Blob.methods += [
- Method(LPVOID, "GetBufferPointer", []),
- Method(SIZE_T, "GetBufferSize", []),
-]
-
D3D10_DRIVER_TYPE = Enum("D3D10_DRIVER_TYPE", [
"D3D10_DRIVER_TYPE_HARDWARE",
"D3D10_DRIVER_TYPE_REFERENCE",
@@ -47,12 +38,14 @@
])
-d3d10 = API("d3d10")
-
d3d10.addFunctions([
StdFunction(HRESULT, "D3D10CreateDevice", [(ObjPointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (D3D10_CREATE_DEVICE_FLAG, "Flags"), (UINT, "SDKVersion"), Out(Pointer(ObjPointer(ID3D10Device)), "ppDevice")]),
StdFunction(HRESULT, "D3D10CreateDeviceAndSwapChain", [(ObjPointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (D3D10_CREATE_DEVICE_FLAG, "Flags"), (UINT, "SDKVersion"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pSwapChainDesc"), Out(Pointer(ObjPointer(IDXGISwapChain)), "ppSwapChain"), Out(Pointer(ObjPointer(ID3D10Device)), "ppDevice")]),
StdFunction(HRESULT, "D3D10CreateBlob", [(SIZE_T, "NumBytes"), Out(Pointer(LPD3D10BLOB), "ppBuffer")]),
+
+ # Undocumented
+ StdFunction(DWORD, "D3D10GetVersion", []),
+ StdFunction(DWORD, "D3D10RegisterLayers", []),
])
d3d10.addInterfaces([
@@ -64,3 +57,4 @@
ID3D10Multithread,
ID3D10SwitchToRef,
])
+
View
@@ -0,0 +1,175 @@
+##########################################################################
+#
+# Copyright 2012 Jose Fonseca
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+from d3dcommon import *
+from d3d10 import *
+
+
+D3D10_SHADER = Flags(UINT, [
+ "D3D10_SHADER_DEBUG",
+ "D3D10_SHADER_SKIP_VALIDATION",
+ "D3D10_SHADER_SKIP_OPTIMIZATION",
+ "D3D10_SHADER_PACK_MATRIX_ROW_MAJOR",
+ "D3D10_SHADER_PACK_MATRIX_COLUMN_MAJOR",
+ "D3D10_SHADER_PARTIAL_PRECISION",
+ "D3D10_SHADER_FORCE_VS_SOFTWARE_NO_OPT",
+ "D3D10_SHADER_FORCE_PS_SOFTWARE_NO_OPT",
+ "D3D10_SHADER_NO_PRESHADER",
+ "D3D10_SHADER_AVOID_FLOW_CONTROL",
+ "D3D10_SHADER_PREFER_FLOW_CONTROL",
+ "D3D10_SHADER_ENABLE_STRICTNESS",
+ "D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY",
+ "D3D10_SHADER_IEEE_STRICTNESS",
+ "D3D10_SHADER_WARNINGS_ARE_ERRORS",
+ "D3D10_SHADER_OPTIMIZATION_LEVEL0",
+ "D3D10_SHADER_OPTIMIZATION_LEVEL1",
+ "D3D10_SHADER_OPTIMIZATION_LEVEL2",
+ "D3D10_SHADER_OPTIMIZATION_LEVEL3",
+])
+
+D3D10_SHADER_DESC = Struct("D3D10_SHADER_DESC", [
+ (UINT, "Version"),
+ (LPCSTR, "Creator"),
+ (UINT, "Flags"),
+ (UINT, "ConstantBuffers"),
+ (UINT, "BoundResources"),
+ (UINT, "InputParameters"),
+ (UINT, "OutputParameters"),
+ (UINT, "InstructionCount"),
+ (UINT, "TempRegisterCount"),
+ (UINT, "TempArrayCount"),
+ (UINT, "DefCount"),
+ (UINT, "DclCount"),
+ (UINT, "TextureNormalInstructions"),
+ (UINT, "TextureLoadInstructions"),
+ (UINT, "TextureCompInstructions"),
+ (UINT, "TextureBiasInstructions"),
+ (UINT, "TextureGradientInstructions"),
+ (UINT, "FloatInstructionCount"),
+ (UINT, "IntInstructionCount"),
+ (UINT, "UintInstructionCount"),
+ (UINT, "StaticFlowControlCount"),
+ (UINT, "DynamicFlowControlCount"),
+ (UINT, "MacroInstructionCount"),
+ (UINT, "ArrayInstructionCount"),
+ (UINT, "CutInstructionCount"),
+ (UINT, "EmitInstructionCount"),
+ (D3D10_PRIMITIVE_TOPOLOGY, "GSOutputTopology"),
+ (UINT, "GSMaxOutputVertexCount"),
+])
+
+D3D10_SHADER_BUFFER_DESC = Struct("D3D10_SHADER_BUFFER_DESC", [
+ (LPCSTR, "Name"),
+ (D3D10_CBUFFER_TYPE, "Type"),
+ (UINT, "Variables"),
+ (UINT, "Size"),
+ (UINT, "uFlags"),
+])
+
+D3D10_SHADER_VARIABLE_DESC = Struct("D3D10_SHADER_VARIABLE_DESC", [
+ (LPCSTR, "Name"),
+ (UINT, "StartOffset"),
+ (UINT, "Size"),
+ (UINT, "uFlags"),
+ (LPVOID, "DefaultValue"),
+])
+
+D3D10_SHADER_TYPE_DESC = Struct("D3D10_SHADER_TYPE_DESC", [
+ (D3D10_SHADER_VARIABLE_CLASS, "Class"),
+ (D3D10_SHADER_VARIABLE_TYPE, "Type"),
+ (UINT, "Rows"),
+ (UINT, "Columns"),
+ (UINT, "Elements"),
+ (UINT, "Members"),
+ (UINT, "Offset"),
+])
+
+D3D10_SHADER_INPUT_BIND_DESC = Struct("D3D10_SHADER_INPUT_BIND_DESC", [
+ (LPCSTR, "Name"),
+ (D3D10_SHADER_INPUT_TYPE, "Type"),
+ (UINT, "BindPoint"),
+ (UINT, "BindCount"),
+ (UINT, "uFlags"),
+ (D3D10_RESOURCE_RETURN_TYPE, "ReturnType"),
+ (D3D10_SRV_DIMENSION, "Dimension"),
+ (UINT, "NumSamples"),
+])
+
+D3D10_SIGNATURE_PARAMETER_DESC = Struct("D3D10_SIGNATURE_PARAMETER_DESC", [
+ (LPCSTR, "SemanticName"),
+ (UINT, "SemanticIndex"),
+ (UINT, "Register"),
+ (D3D10_NAME, "SystemValueType"),
+ (D3D10_REGISTER_COMPONENT_TYPE, "ComponentType"),
+ (BYTE, "Mask"),
+ (BYTE, "ReadWriteMask"),
+])
+
+ID3D10ShaderReflectionType = Interface("ID3D10ShaderReflectionType")
+ID3D10ShaderReflectionType.methods += [
+ StdMethod(HRESULT, "GetDesc", [(Pointer(D3D10_SHADER_TYPE_DESC), "pDesc")]),
+ StdMethod(ObjPointer(ID3D10ShaderReflectionType), "GetMemberTypeByIndex", [(UINT, "Index")]),
+ StdMethod(ObjPointer(ID3D10ShaderReflectionType), "GetMemberTypeByName", [(LPCSTR, "Name")]),
+ StdMethod(LPCSTR, "GetMemberTypeName", [(UINT, "Index")]),
+]
+
+ID3D10ShaderReflectionVariable = Interface("ID3D10ShaderReflectionVariable")
+ID3D10ShaderReflectionVariable.methods += [
+ StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D10_SHADER_VARIABLE_DESC), "pDesc")]),
+ StdMethod(ObjPointer(ID3D10ShaderReflectionType), "GetType", []),
+]
+
+ID3D10ShaderReflectionConstantBuffer = Interface("ID3D10ShaderReflectionConstantBuffer")
+ID3D10ShaderReflectionConstantBuffer.methods += [
+ StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D10_SHADER_BUFFER_DESC), "pDesc")]),
+ StdMethod(ObjPointer(ID3D10ShaderReflectionVariable), "GetVariableByIndex", [(UINT, "Index")]),
+ StdMethod(ObjPointer(ID3D10ShaderReflectionVariable), "GetVariableByName", [(LPCSTR, "Name")]),
+]
+
+ID3D10ShaderReflection = Interface("ID3D10ShaderReflection", IUnknown)
+ID3D10ShaderReflection.methods += [
+ StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D10_SHADER_DESC), "pDesc")]),
+ StdMethod(ObjPointer(ID3D10ShaderReflectionConstantBuffer), "GetConstantBufferByIndex", [(UINT, "Index")]),
+ StdMethod(ObjPointer(ID3D10ShaderReflectionConstantBuffer), "GetConstantBufferByName", [(LPCSTR, "Name")]),
+ StdMethod(HRESULT, "GetResourceBindingDesc", [(UINT, "ResourceIndex"), Out(Pointer(D3D10_SHADER_INPUT_BIND_DESC), "pDesc")]),
+ StdMethod(HRESULT, "GetInputParameterDesc", [(UINT, "ParameterIndex"), Out(Pointer(D3D10_SIGNATURE_PARAMETER_DESC), "pDesc")]),
+ StdMethod(HRESULT, "GetOutputParameterDesc", [(UINT, "ParameterIndex"), Out(Pointer(D3D10_SIGNATURE_PARAMETER_DESC), "pDesc")]),
+]
+
+
+d3d10.addFunctions([
+ 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")]),
+ StdFunction(HRESULT, "D3D10DisassembleShader", [(OpaquePointer(Const(Void)), "pShader"), (SIZE_T, "BytecodeLength"), (BOOL, "EnableColorCode"), (LPCSTR, "pComments"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppDisassembly")]),
+ StdFunction(LPCSTR, "D3D10GetPixelShaderProfile", [(ObjPointer(ID3D10Device), "pDevice")]),
+ StdFunction(LPCSTR, "D3D10GetVertexShaderProfile", [(ObjPointer(ID3D10Device), "pDevice")]),
+ StdFunction(LPCSTR, "D3D10GetGeometryShaderProfile", [(ObjPointer(ID3D10Device), "pDevice")]),
+ StdFunction(HRESULT, "D3D10ReflectShader", [(OpaquePointer(Const(Void)), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10ShaderReflection)), "ppReflector")]),
+ 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")]),
+ StdFunction(HRESULT, "D3D10GetInputSignatureBlob", [(OpaquePointer(Const(Void)), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppSignatureBlob")]),
+ StdFunction(HRESULT, "D3D10GetOutputSignatureBlob", [(OpaquePointer(Const(Void)), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppSignatureBlob")]),
+ StdFunction(HRESULT, "D3D10GetInputAndOutputSignatureBlob", [(OpaquePointer(Const(Void)), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppSignatureBlob")]),
+ StdFunction(HRESULT, "D3D10GetShaderDebugInfo", [(OpaquePointer(Const(Void)), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppDebugInfo")]),
+])
View
@@ -296,7 +296,7 @@
'D3D11_SRV_DIMENSION_BUFFEREX',
])
-D3D_SHADER_MACRO = Struct('D3D_SHADER_MACRO', [
+D3D10_SHADER_MACRO = Struct('D3D10_SHADER_MACRO', [
(LPCSTR, 'Name'),
(LPCSTR, 'Definition'),
])
@@ -306,6 +306,7 @@
StdMethod(LPVOID, 'GetBufferPointer', []),
StdMethod(SIZE_T, 'GetBufferSize', []),
]
+LPD3D10BLOB = ObjPointer(ID3D10Blob)
D3D_INCLUDE_TYPE = Enum('D3D_INCLUDE_TYPE', [
'D3D_INCLUDE_LOCAL',
@@ -317,6 +318,13 @@
'D3D10_INCLUDE_SYSTEM',
])
+ID3D10Include = Interface("ID3D10Include", IUnknown)
+ID3D10Include.methods += [
+ StdMethod(HRESULT, "Open", [(D3D10_INCLUDE_TYPE, "IncludeType"), (LPCSTR, "pFileName"), (LPCVOID, "pParentData"), (Pointer(LPCVOID), "ppData"), (Pointer(UINT), "pBytes")]),
+ StdMethod(HRESULT, "Close", [(LPCVOID, "pData")]),
+]
+LPD3D10INCLUDE = OpaquePointer(ID3D10Include)
+
D3D_SHADER_VARIABLE_CLASS = Enum('D3D_SHADER_VARIABLE_CLASS', [
'D3D_SVC_SCALAR',
'D3D_SVC_VECTOR',
View
@@ -44,11 +44,10 @@
DXGI_USAGE = Flags(UINT, [
- "DXGI_CPU_ACCESS_FIELD",
- "DXGI_CPU_ACCESS_NONE",
- "DXGI_CPU_ACCESS_DYNAMIC",
- "DXGI_CPU_ACCESS_READ_WRITE",
- "DXGI_CPU_ACCESS_SCRATCH",
+ "DXGI_CPU_ACCESS_NONE", # 0
+ "DXGI_CPU_ACCESS_SCRATCH", # 3
+ "DXGI_CPU_ACCESS_DYNAMIC", # 1
+ "DXGI_CPU_ACCESS_READ_WRITE", # 2
"DXGI_USAGE_SHADER_INPUT",
"DXGI_USAGE_RENDER_TARGET_OUTPUT",
"DXGI_USAGE_BACK_BUFFER",
View
@@ -50,18 +50,6 @@
"DXGI_ERROR_NOT_CURRENTLY_AVAILABLE",
"DXGI_ERROR_REMOTE_CLIENT_DISCONNECTED",
"DXGI_ERROR_REMOTE_OUTOFMEMORY",
- "DXGI_CPU_ACCESS_NONE",
- "DXGI_CPU_ACCESS_DYNAMIC",
- "DXGI_CPU_ACCESS_READ_WRITE",
- "DXGI_CPU_ACCESS_SCRATCH",
- "DXGI_CPU_ACCESS_FIELD",
- "DXGI_USAGE_SHADER_INPUT",
- "DXGI_USAGE_RENDER_TARGET_OUTPUT",
- "DXGI_USAGE_BACK_BUFFER",
- "DXGI_USAGE_SHARED",
- "DXGI_USAGE_READ_ONLY",
- "DXGI_USAGE_DISCARD_ON_PRESENT",
- "DXGI_USAGE_UNORDERED_ACCESS",
])
@@ -308,25 +308,31 @@ def parse_tags(self):
assert tags[0] == '"'
assert tags[-1] == '"'
tags = tags[1:-1]
- try:
- tags, args = tags.split('(')
- except ValueError:
- pass
- assert tags[0] == '_'
- assert tags[-1] == '_'
- tags = tags[1:-1]
- tags = tags.lower()
- tags = tags.split('_')
- if self.lookahead().startswith('__'):
+ tags = parse_sal_annotation(tags)
+ token = self.lookahead()
+ if token[0] == '_' and (token[1] == '_' or token[-1] == '_'):
# Parse __in, __out, etc tags
- tag = self.consume()[2:]
- args = []
+ tag = self.consume()
if self.match('('):
- self.consume()
+ tag += self.consume()
while not self.match(')'):
- self.consume()
- self.consume(')')
- tags.extend(tag.split('_'))
+ tag += self.consume()
+ tag += self.consume(')')
+ tags.extend(self.parse_sal_annotation(tag))
+ return tags
+
+ def parse_sal_annotation(self, tags):
+ try:
+ tags, args = tags.split('(')
+ except ValueError:
+ pass
+ assert tags[0] == '_'
+ if tags[1] == '_':
+ tags = tags[2:]
+ if tags[-1] == '_':
+ tags = tags[1:-1]
+ tags = tags.lower()
+ tags = tags.split('_')
return tags
def parse_named_type(self):
@@ -338,7 +344,9 @@ def parse_named_type(self):
name = self.consume()
if self.match('['):
self.consume()
- length = self.consume()
+ length = ''
+ while not self.match(']'):
+ length += self.consume()
self.consume(']')
try:
int(length)
View
@@ -77,6 +77,7 @@
VOID = Void
PVOID = OpaquePointer(VOID)
LPVOID = PVOID
+LPCVOID = OpaquePointer(Const(VOID))
def DECLARE_HANDLE(expr):
return Handle(expr, IntPointer(expr))
@@ -203,9 +204,9 @@ def MAKE_HRESULT(errors, ok = "S_OK", false = "S_FALSE"):
IUnknown = Interface("IUnknown")
IUnknown.methods = (
- Method(HRESULT, "QueryInterface", ((REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppvObj"))),
- Method(ULONG, "AddRef", (), sideeffects=False),
- Method(ULONG, "Release", ()),
+ StdMethod(HRESULT, "QueryInterface", ((REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppvObj"))),
+ StdMethod(ULONG, "AddRef", (), sideeffects=False),
+ StdMethod(ULONG, "Release", ()),
)
Oops, something went wrong.

0 comments on commit 467a42a

Please sign in to comment.