From 0b8fea1cf5bea68fd15b5ddaf80f25578190768e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 28 Sep 2009 11:33:36 +0100 Subject: [PATCH] Rudimentary support for D3D10. --- .gitignore | 4 +++ SConstruct | 51 ++++++++++++++++++++++++++++++++++--- base.py | 1 + compat.h | 27 ++++++++++++++++++++ d3d10.def | 6 +++++ d3d10_1.def | 6 +++++ d3d10_1.py | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++ d3d10misc.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++ d3d9.py | 3 +++ windows.py | 2 ++ 10 files changed, 230 insertions(+), 4 deletions(-) create mode 100644 compat.h create mode 100644 d3d10.def create mode 100644 d3d10_1.def create mode 100644 d3d10_1.py create mode 100644 d3d10misc.py diff --git a/.gitignore b/.gitignore index 9df1b81..facbfdb 100644 --- a/.gitignore +++ b/.gitignore @@ -16,8 +16,12 @@ *.pyo *.xml *.zip +MD5SUM config.log ddraw.cpp d3d8.cpp d3d9.cpp +d3d10.cpp +d3d10_1.cpp +dxsdk opengl32.cpp diff --git a/SConstruct b/SConstruct index 07b729d..bdac74f 100644 --- a/SConstruct +++ b/SConstruct @@ -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 822f4fc..3082351 100644 --- 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 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 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 index 0000000..48bfe14 --- /dev/null +++ b/d3d10_1.def @@ -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 index 0000000..270ffa2 --- /dev/null +++ b/d3d10_1.py @@ -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 . +# +############################################################################# + +"""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 ' + print '#include ' + print + print '#include "compat.h"' + print + print '#include ' + print + print '#include "log.hpp"' + print + wrap() diff --git a/d3d10misc.py b/d3d10misc.py new file mode 100644 index 0000000..1fe56fb --- /dev/null +++ b/d3d10misc.py @@ -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 . +# +############################################################################# + +"""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 ' + print '#include ' + print + print '#include "compat.h"' + print + print '#include ' + print + print '#include "log.hpp"' + print + wrap() diff --git a/d3d9.py b/d3d9.py index 1b95014..ae63b81 100644 --- a/d3d9.py +++ b/d3d9.py @@ -400,6 +400,9 @@ d3d9.functions += [ if __name__ == '__main__': print '#include ' print '#include ' + print + print '#include "compat.h"' + print print '#include ' print print '#include "log.hpp"' diff --git a/windows.py b/windows.py index 4202f06..48a3f3f 100644 --- a/windows.py +++ b/windows.py @@ -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") -- 2.43.0