]> git.cworth.org Git - apitrace/commitdiff
Rudimentary support for D3D10.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 28 Sep 2009 10:33:36 +0000 (11:33 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 28 Sep 2009 10:33:36 +0000 (11:33 +0100)
.gitignore
SConstruct
base.py
compat.h [new file with mode: 0644]
d3d10.def [new file with mode: 0644]
d3d10_1.def [new file with mode: 0644]
d3d10_1.py [new file with mode: 0644]
d3d10misc.py [new file with mode: 0644]
d3d9.py
windows.py

index 9df1b8100f17ac1c60e22e8cdac898ea462cf917..facbfdb1560d26d7f861dc10a9dada2a7984286e 100644 (file)
 *.pyo
 *.xml
 *.zip
+MD5SUM
 config.log
 ddraw.cpp
 d3d8.cpp
 d3d9.cpp
+d3d10.cpp
+d3d10_1.cpp
+dxsdk
 opengl32.cpp
index 07b729de3f9e9061e2545fbbf868ef27e433f657..bdac74f93514243e3d11af7e059e783686531a6b 100644 (file)
@@ -183,12 +183,19 @@ SConscript('zlib/SConscript')
 env.Tool('dxsdk', toolpath = ['scons'])
 
 conf = Configure(env)
-has_d3d9 = conf.CheckCHeader('d3d9.h')
-has_d3d8 = conf.CheckCHeader('d3d8.h')
-has_d3d7 = conf.CheckCHeader('ddraw.h')
+has_d3d7 = conf.CheckCXXHeader('ddraw.h')
+has_d3d8 = conf.CheckCXXHeader('d3d8.h')
+has_d3d9 = conf.CheckCXXHeader('d3d9.h')
+if env['toolchain'] != 'crossmingw':
+    has_d3d10 = conf.CheckCXXHeader('d3d10.h')
+    has_d3d10_1 = conf.CheckCXXHeader('d3d10_1.h')
+else:
+    # The above checks do not give reliable results for MinGW
+    has_d3d10 = True
+    has_d3d10_1 = True
 env = conf.Finish()
 
-if has_d3d7:
+if has_d3d7 and False:
     env.Command(
         target = 'ddraw.cpp', 
         source = ['ddraw.py', 'd3d.py', 'd3dtypes.py', 'd3dcaps.py', 'windows.py', 'base.py'],
@@ -242,6 +249,42 @@ if has_d3d9:
 
     env.Default(d3d9)
 
+if has_d3d10:
+    env.Command(
+        target = 'd3d10.cpp', 
+        source = ['d3d10misc.py', 'windows.py', 'base.py'],
+        action = 'python $SOURCE > $TARGET',
+    )
+        
+    d3d10 = env.SharedLibrary(
+        target = 'd3d10',
+        source = [
+            'd3d10.def',
+            'd3d10.cpp',
+            'log.cpp',
+        ]
+    )
+
+    env.Default(d3d10)
+
+if has_d3d10_1:
+    env.Command(
+        target = 'd3d10_1.cpp', 
+        source = ['d3d10_1.py', 'windows.py', 'base.py'],
+        action = 'python $SOURCE > $TARGET',
+    )
+        
+    d3d10_1 = env.SharedLibrary(
+        target = 'd3d10_1',
+        source = [
+            'd3d10_1.def',
+            'd3d10_1.cpp',
+            'log.cpp',
+        ]
+    )
+
+    env.Default(d3d10_1)
+
 env.Command(
     target = 'opengl32.cpp', 
     source = ['opengl32.py', 'gl.py', 'windows.py', 'base.py'],
diff --git a/base.py b/base.py
index 822f4fc510bee1b769927c7a2783b4507fb0c8e6..3082351f08d98f09e586c466a2340fc5142ed138 100644 (file)
--- a/base.py
+++ b/base.py
@@ -490,6 +490,7 @@ UInt = Intrinsic("unsigned int", "%u")
 ULong = Intrinsic("unsigned long", "%lu")
 Float = Intrinsic("float", "%f")
 Double = Intrinsic("double", "%f")
+SizeT = Intrinsic("size_t", "%lu")
 
 
 def wrap():
diff --git a/compat.h b/compat.h
new file mode 100644 (file)
index 0000000..b6c0843
--- /dev/null
+++ b/compat.h
@@ -0,0 +1,27 @@
+#ifdef __MINGW32__
+#define __in /**/
+#define __out /**/
+#define __inout /**/
+#define __inout_opt /**/
+#define __in_opt /**/
+#define __out_opt /**/
+#define __in_bcount(x) /**/
+#define __out_bcount(x) /**/
+#define __in_bcount_opt(x) /**/
+#define __out_bcount_opt(x) /**/
+#define __in_range(x,y) /**/
+#define __in_ecount(x) /**/
+#define __out_ecount(x) /**/
+#define __in_ecount_opt(x) /**/
+#define __out_ecount_opt(x) /**/
+#define __field_bcount(x) /**/
+#define __field_ecount(x) /**/
+#define __field_ecount_full(x) /**/
+#define __inline static __inline__
+
+#define DECLSPEC_DEPRECATED /**/
+
+#define UINT8 uint8_t
+
+#endif
+
diff --git a/d3d10.def b/d3d10.def
new file mode 100644 (file)
index 0000000..5482ab5
--- /dev/null
+++ b/d3d10.def
@@ -0,0 +1,6 @@
+LIBRARY        "d3d10"
+
+EXPORTS
+        D3D10CreateDevice
+        D3D10CreateDeviceAndSwapChain
+        D3D10CreateBlob
diff --git a/d3d10_1.def b/d3d10_1.def
new file mode 100644 (file)
index 0000000..48bfe14
--- /dev/null
@@ -0,0 +1,6 @@
+LIBRARY        "d3d10_1"
+
+EXPORTS
+        D3D10CreateDevice1
+        D3D10CreateDeviceAndSwapChain1
+        D3D10CreateBlob
diff --git a/d3d10_1.py b/d3d10_1.py
new file mode 100644 (file)
index 0000000..270ffa2
--- /dev/null
@@ -0,0 +1,71 @@
+#############################################################################
+#
+# Copyright 2009 VMware, Inc.
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+#############################################################################
+
+"""d3d10_1.h"""
+
+from windows import *
+
+ID3D10Blob = Interface("ID3D10Blob", IUnknown)
+LPD3D10BLOB = Pointer(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",
+    "D3D10_DRIVER_TYPE_NULL",
+    "D3D10_DRIVER_TYPE_SOFTWARE",
+    "D3D10_DRIVER_TYPE_WARP",
+])
+
+D3D10_FEATURE_LEVEL1 = Enum("D3D10_FEATURE_LEVEL1", [
+    "D3D10_FEATURE_LEVEL_10_0",
+    "D3D10_FEATURE_LEVEL_10_1",
+       "D3D10_FEATURE_LEVEL_9_1",
+       "D3D10_FEATURE_LEVEL_9_2",
+       "D3D10_FEATURE_LEVEL_9_3",
+])
+
+# TODO
+IDXGIAdapter = Alias("IDXGIAdapter", Void)
+ID3D10Device1 = Alias("ID3D10Device1", Void)
+IDXGISwapChain = Alias("IDXGISwapChain", Void)
+DXGI_SWAP_CHAIN_DESC = Alias("DXGI_SWAP_CHAIN_DESC", Void)
+
+d3d10_1 = Dll("d3d10")
+d3d10_1.functions += [
+    DllFunction(HRESULT, "D3D10CreateDevice1", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (D3D10_FEATURE_LEVEL1, "HardwareLevel"), (UINT, "SDKVersion"), (OutPointer(Pointer(ID3D10Device1)), "ppDevice")]),
+    DllFunction(HRESULT, "D3D10CreateDeviceAndSwapChain1", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (D3D10_FEATURE_LEVEL1, "HardwareLevel"), (UINT, "SDKVersion"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pSwapChainDesc"), (OutPointer(Pointer(IDXGISwapChain)), "ppSwapChain"), (OutPointer(Pointer(ID3D10Device1)), "ppDevice")]),
+    DllFunction(HRESULT, "D3D10CreateBlob", [(SIZE_T, "NumBytes"), (OutPointer(LPD3D10BLOB), "ppBuffer")]),
+]
+
+if __name__ == '__main__':
+    print '#include <windows.h>'
+    print '#include <tchar.h>'
+    print
+    print '#include "compat.h"'
+    print
+    print '#include <d3d10_1.h>'
+    print
+    print '#include "log.hpp"'
+    print
+    wrap()
diff --git a/d3d10misc.py b/d3d10misc.py
new file mode 100644 (file)
index 0000000..1fe56fb
--- /dev/null
@@ -0,0 +1,63 @@
+#############################################################################
+#
+# Copyright 2009 VMware, Inc.
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+#############################################################################
+
+"""d3d10misc.h"""
+
+from windows import *
+
+ID3D10Blob = Interface("ID3D10Blob", IUnknown)
+LPD3D10BLOB = Pointer(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",
+    "D3D10_DRIVER_TYPE_NULL",
+    "D3D10_DRIVER_TYPE_SOFTWARE",
+    "D3D10_DRIVER_TYPE_WARP",
+])
+
+# TODO
+IDXGIAdapter = Alias("IDXGIAdapter", Void)
+ID3D10Device = Alias("ID3D10Device", Void)
+IDXGISwapChain = Alias("IDXGISwapChain", Void)
+DXGI_SWAP_CHAIN_DESC = Alias("DXGI_SWAP_CHAIN_DESC", Void)
+
+d3d10 = Dll("d3d10")
+d3d10.functions += [
+    DllFunction(HRESULT, "D3D10CreateDevice", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (UINT, "SDKVersion"), (OutPointer(Pointer(ID3D10Device)), "ppDevice")]),
+    DllFunction(HRESULT, "D3D10CreateDeviceAndSwapChain", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (UINT, "SDKVersion"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pSwapChainDesc"), (OutPointer(Pointer(IDXGISwapChain)), "ppSwapChain"), (OutPointer(Pointer(ID3D10Device)), "ppDevice")]),
+    DllFunction(HRESULT, "D3D10CreateBlob", [(SIZE_T, "NumBytes"), (OutPointer(LPD3D10BLOB), "ppBuffer")]),
+]
+
+if __name__ == '__main__':
+    print '#include <windows.h>'
+    print '#include <tchar.h>'
+    print
+    print '#include "compat.h"'
+    print
+    print '#include <d3d10.h>'
+    print
+    print '#include "log.hpp"'
+    print
+    wrap()
diff --git a/d3d9.py b/d3d9.py
index 1b95014617cf72852d94fee3392ec90ef31b5958..ae63b81fde1aad4b77b4e1c7876f2ce52d8085d6 100644 (file)
--- a/d3d9.py
+++ b/d3d9.py
@@ -400,6 +400,9 @@ d3d9.functions += [
 if __name__ == '__main__':
     print '#include <windows.h>'
     print '#include <tchar.h>'
+    print
+    print '#include "compat.h"'
+    print
     print '#include <d3d9.h>'
     print
     print '#include "log.hpp"'
index 4202f06781648d39ee7616e769e4005e43d37520..48a3f3f3a5fe3abec7ec6f3442334c84c18551c5 100644 (file)
@@ -50,6 +50,7 @@ LPWSTR = WString
 LPCWSTR = Const(WString)
 
 LARGE_INTEGER = Intrinsic("LARGE_INTEGER", "0x%llx")
+SIZE_T = Alias("SIZE_T", SizeT)
 
 HRESULT = Alias("HRESULT", Int)
 
@@ -128,6 +129,7 @@ RGNDATA = Struct("RGNDATA", [
 ])
 LPRGNDATA = Pointer(RGNDATA)
 
+HMODULE = Alias("HMODULE", LPVOID)
 
 IUnknown = Interface("IUnknown")