1 #############################################################################
3 # Copyright 2009 VMware, Inc.
5 # This program is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published
7 # by the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #############################################################################
24 class D3DShader(Type):
26 def __init__(self, version):
27 self.version = version
28 Type.__init__(self, "const DWORD *")
31 print '#include <d3dx9.h>'
32 print '#include <stdio.h>'
34 print 'void Dump%s(const DWORD *tokens);' % (self.id)
39 (WINAPI *PD3DXDISASSEMBLESHADER)(
43 LPD3DXBUFFER *ppDisassembly
46 print 'void Dump%s(const DWORD *tokens)' % (self.id)
48 static BOOL firsttime = TRUE;
49 static HMODULE hD3DXModule = NULL;
50 static PD3DXDISASSEMBLESHADER pfnD3DXDisassembleShader = NULL;
56 for(release = 0; release <= 1; ++release) {
57 /* Version 41 corresponds to Mar 2009 version of DirectX Runtime / SDK */
58 for(version = 41; version >= 24; --version) {
60 _snprintf(filename, sizeof(filename),
61 "d3dx9%s_%u.dll", release ? "" : "d", version);
62 hD3DXModule = LoadLibraryA(filename);
72 if(!pfnD3DXDisassembleShader)
73 pfnD3DXDisassembleShader = (PD3DXDISASSEMBLESHADER)GetProcAddress(hD3DXModule, "D3DXDisassembleShader");
78 if(pfnD3DXDisassembleShader) {
79 LPD3DXBUFFER pDisassembly = NULL;
81 if (pfnD3DXDisassembleShader( (DWORD *)tokens, FALSE, NULL, &pDisassembly) == D3D_OK)
82 Log::DumpString((char *)pDisassembly->GetBufferPointer());
85 pDisassembly->Release();
90 def dump(self, instance):
91 print ' Dump%s(%s);' % (self.id, instance)