def invokeFunction(self, function): if function.name in self.createDeviceFunctionNames: # create windows as neccessary if 'pSwapChainDesc' in function.argNames(): print r' d3dretrace::createWindowForSwapChain(pSwapChainDesc);' # Compensate for the fact we don't trace DXGI object creation if function.name.startswith('D3D11CreateDevice'): print r' if (DriverType == D3D_DRIVER_TYPE_UNKNOWN && !pAdapter) {' print r' DriverType = D3D_DRIVER_TYPE_HARDWARE;' print r' }' if function.name.startswith('D3D10CreateDevice'): # Toggle debugging print r' if (retrace::debug >= 2) {' print r' Flags |= D3D10_CREATE_DEVICE_DEBUG;' print r' } else if (retrace::debug < 0) {' print r' Flags &= ~D3D10_CREATE_DEVICE_DEBUG;' print r' }' # Force driver self.forceDriver('D3D10_DRIVER_TYPE') if function.name.startswith('D3D11CreateDevice'): # Toggle debugging print r' if (retrace::debug >= 2) {' print r' Flags |= D3D11_CREATE_DEVICE_DEBUG;' print r' } else if (retrace::debug < 0) {' print r' Flags &= ~D3D11_CREATE_DEVICE_DEBUG;' print r' }' # Force driver self.forceDriver('D3D_DRIVER_TYPE') Retracer.invokeFunction(self, function)
def invokeFunction(self, function): if function.name in self.createDeviceFunctionNames: # create windows as neccessary if 'pSwapChainDesc' in function.argNames(): print r' d3dretrace::createWindowForSwapChain(pSwapChainDesc);' # Compensate for the fact we don't trace DXGI object creation if function.name.startswith('D3D11CreateDevice'): print r' if (DriverType == D3D_DRIVER_TYPE_UNKNOWN && !pAdapter) {' print r' DriverType = D3D_DRIVER_TYPE_HARDWARE;' print r' }' if function.name.startswith('D3D10CreateDevice'): # Toggle debugging print r' if (retrace::debug) {' print r' Flags |= D3D10_CREATE_DEVICE_DEBUG;' print r' } else {' print r' Flags &= ~D3D10_CREATE_DEVICE_DEBUG;' print r' }' # Force driver self.forceDriver('D3D10_DRIVER_TYPE') if function.name.startswith('D3D11CreateDevice'): # Toggle debugging print r' if (retrace::debug) {' print r' Flags |= D3D11_CREATE_DEVICE_DEBUG;' print r' } else {' print r' Flags &= ~D3D11_CREATE_DEVICE_DEBUG;' print r' }' # Force driver self.forceDriver('D3D_DRIVER_TYPE') Retracer.invokeFunction(self, function)
def invokeFunction(self, function): if function.name in self.createDeviceFunctionNames: # create windows as neccessary if 'pSwapChainDesc' in function.argNames(): print(r' if (pSwapChainDesc) {') print(r' d3dretrace::createWindowForSwapChain(pSwapChainDesc);') print(r' }') # Compensate for the fact we don't trace DXGI object creation if function.name.startswith('D3D11CreateDevice'): print(r' if (DriverType == D3D_DRIVER_TYPE_UNKNOWN && !pAdapter) {') print(r' DriverType = D3D_DRIVER_TYPE_HARDWARE;') print(r' }') if function.name.startswith('D3D10CreateDevice'): # Toggle debugging print(r' if (retrace::debug >= 2) {') print(r' Flags |= D3D10_CREATE_DEVICE_DEBUG;') print(r' } else if (retrace::debug < 0) {') print(r' Flags &= ~D3D10_CREATE_DEVICE_DEBUG;') print(r' }') # Force driver self.forceDriver('D3D10_DRIVER_TYPE') if function.name.startswith('D3D11CreateDevice'): # Toggle debugging print(r' if (retrace::debug >= 2) {') print(r' Flags |= D3D11_CREATE_DEVICE_DEBUG;') print(r' } else if (retrace::debug < 0) {') print(r' Flags &= ~D3D11_CREATE_DEVICE_DEBUG;') print(r' }') print(r' if (IsWindows8OrGreater()) {') print(r' Flags |= D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT;') print(r' }') # Force driver self.forceDriver('D3D_DRIVER_TYPE') Retracer.invokeFunction(self, function) if function.name in self.createDeviceFunctionNames: print(r''' if (retrace::driver != retrace::DRIVER_DEFAULT && ppDevice && *ppDevice) { com_ptr<IDXGIDevice> pDXGIDevice; HRESULT hr = (*ppDevice)->QueryInterface(IID_IDXGIDevice, (void **)&pDXGIDevice); assert(SUCCEEDED(hr)); com_ptr<IDXGIAdapter> pDXGIAdapter; hr = pDXGIDevice->GetAdapter(&pDXGIAdapter); assert(SUCCEEDED(hr)); DXGI_ADAPTER_DESC AdapterDesc; hr = pDXGIAdapter->GetDesc(&AdapterDesc); assert(SUCCEEDED(hr)); std::wcerr << L"info: using " << AdapterDesc.Description << std::endl; } ''')
def invokeFunction(self, function): if function.name in self.createDeviceFunctionNames: # create windows as neccessary if 'pSwapChainDesc' in function.argNames(): print(r' if (pSwapChainDesc) {') print( r' d3dretrace::createWindowForSwapChain(pSwapChainDesc);' ) print(r' }') # Compensate for the fact we don't trace DXGI object creation if function.name.startswith('D3D11CreateDevice'): print( r' if (DriverType == D3D_DRIVER_TYPE_UNKNOWN && !pAdapter) {' ) print(r' DriverType = D3D_DRIVER_TYPE_HARDWARE;') print(r' }') if function.name.startswith('D3D10CreateDevice'): # Toggle debugging print(r' if (retrace::debug >= 2) {') print(r' Flags |= D3D10_CREATE_DEVICE_DEBUG;') print(r' } else if (retrace::debug < 0) {') print(r' Flags &= ~D3D10_CREATE_DEVICE_DEBUG;') print(r' }') # D3D10CreateDevice(D3D10_DRIVER_TYPE_REFERENCE) fails with # DXGI_ERROR_UNSUPPORTED on 64bits. print(r'#ifdef _WIN64') print(r' if (DriverType == D3D10_DRIVER_TYPE_REFERENCE) {') print(r' DriverType = D3D10_DRIVER_TYPE_WARP;') print(r' }') print(r'#endif') # Force driver self.forceDriver('D3D10_DRIVER_TYPE_HARDWARE') if function.name.startswith('D3D11CreateDevice'): # Toggle debugging print(r' if (retrace::debug >= 2) {') print(r' Flags |= D3D11_CREATE_DEVICE_DEBUG;') print(r' } else if (retrace::debug < 0) {') print(r' Flags &= ~D3D11_CREATE_DEVICE_DEBUG;') print(r' }') print(r' if (IsWindows8OrGreater()) {') print( r' Flags |= D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT;' ) print(r' }') # Force driver self.forceDriver('D3D_DRIVER_TYPE_UNKNOWN') Retracer.invokeFunction(self, function)
def invokeFunction(self, function): if function.name in ('Direct3DCreate9', 'Direct3DCreate9Ex'): print 'if (retrace::debug && !g_szD3D9DllName) {' print ' /* ' print ' * XXX: D3D9D only works for simple things, it often introduces errors' print ' * on complex traces, or traces which use unofficial D3D9 features.' print ' */' print ' if (0) {' print ' g_szD3D9DllName = "d3d9d.dll";' print ' }' print '}' Retracer.invokeFunction(self, function)
def invokeFunction(self, function): if function.name in ('Direct3DCreate9', 'Direct3DCreate9Ex'): print 'if (retrace::debug >= 2 && !g_szD3D9DllName && LoadLibraryA("d3d9d.dll")) {' print ' /*' print ' * D3D9D only works for simple applications, it will often report bogus errors' print ' * on complex traces, or traces which use unofficial D3D9 features.' print ' */' print ' g_szD3D9DllName = "d3d9d.dll";' print ' SDKVersion |= 0x80000000;' print '} else {' print ' SDKVersion &= ~0x80000000;' print '}' Retracer.invokeFunction(self, function)
def invokeFunction(self, function): if function.name in self.createDeviceFunctionNames: # create windows as neccessary if 'pSwapChainDesc' in function.argNames(): print r' d3dretrace::createWindowForSwapChain(pSwapChainDesc);' # Compensate for the fact we don't trace DXGI object creation if function.name.startswith('D3D11CreateDevice'): print r' if (DriverType == D3D_DRIVER_TYPE_UNKNOWN && !pAdapter) {' print r' DriverType = D3D_DRIVER_TYPE_HARDWARE;' print r' }' if function.name.startswith('D3D10CreateDevice'): # Toggle debugging print r' Flags &= ~D3D10_CREATE_DEVICE_DEBUG;' print r' if (retrace::debug) {' print r' HMODULE hD3d10SdkLayers = LoadLibraryA("d3d10sdklayers");' print r' if (hD3d10SdkLayers) {' print r' FreeLibrary(hD3d10SdkLayers);' print r' Flags |= D3D10_CREATE_DEVICE_DEBUG;' print r' } else {' print r' retrace::warning(call) << "Direct3D 10.x SDK Debug Layer (d3d10sdklayers.dll) not available, continuing without debug output\n";' print r' }' print r' }' # Force driver self.forceDriver('D3D10_DRIVER_TYPE') if function.name.startswith('D3D11CreateDevice'): # Toggle debugging print r' Flags &= ~D3D11_CREATE_DEVICE_DEBUG;' print r' if (retrace::debug) {' print r' HRESULT hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_NULL, 0, D3D11_CREATE_DEVICE_DEBUG, NULL, 0, D3D11_SDK_VERSION, NULL, NULL, NULL);' print r' if (SUCCEEDED(hr)) {' print r' Flags |= D3D11_CREATE_DEVICE_DEBUG;' print r' } else {' print r' retrace::warning(call) << "Direct3D 11.x SDK Debug Layer (d3d11*sdklayers.dll) not available, continuing without debug output\n";' print r' }' print r' }' # Force driver self.forceDriver('D3D_DRIVER_TYPE') Retracer.invokeFunction(self, function)
def invokeFunction(self, function): if function.name in ("Direct3DCreate9", "Direct3DCreate9Ex"): print 'if (retrace::debug >= 2 && !g_szD3D9DllName && LoadLibraryA("d3d9d.dll")) {' print " /*" print " * D3D9D only works for simple applications, it will often report bogus errors" print " * on complex traces, or traces which use unofficial D3D9 features." print " */" print ' g_szD3D9DllName = "d3d9d.dll";' print " SDKVersion |= 0x80000000;" print "} else {" print " SDKVersion &= ~0x80000000;" print "}" # d3d8d.dll can be found in the Aug 2007 DXSDK. It works on XP, but # not on Windows 7. if function.name in ("Direct3DCreate8"): print 'if (retrace::debug >= 2 && !g_szD3D8DllName && LoadLibraryA("d3d8d.dll")) {' print ' g_szD3D8DllName = "d3d8d.dll";' print "}" Retracer.invokeFunction(self, function)
def invokeFunction(self, function): if function.name in self.createDeviceFunctionNames: # create windows as neccessary if "pSwapChainDesc" in function.argNames(): print r" createWindow(pSwapChainDesc);" # Compensate for the fact we don't trace DXGI object creation if function.name.startswith("D3D11CreateDevice"): print r" if (DriverType == D3D_DRIVER_TYPE_UNKNOWN && !pAdapter) {" print r" DriverType = D3D_DRIVER_TYPE_HARDWARE;" print r" }" if function.name.startswith("D3D10CreateDevice"): # Toggle debugging print r" Flags &= ~D3D10_CREATE_DEVICE_DEBUG;" print r" if (retrace::debug) {" print r' if (LoadLibraryA("d3d10sdklayers")) {' print r" Flags |= D3D10_CREATE_DEVICE_DEBUG;" print r" }" print r" }" # Force driver self.forceDriver("D3D10_DRIVER_TYPE") if function.name.startswith("D3D11CreateDevice"): # Toggle debugging print r" Flags &= ~D3D11_CREATE_DEVICE_DEBUG;" print r" if (retrace::debug) {" print r' if (LoadLibraryA("d3d11sdklayers")) {' print r" Flags |= D3D11_CREATE_DEVICE_DEBUG;" print r" }" print r" }" # Force driver self.forceDriver("D3D_DRIVER_TYPE") Retracer.invokeFunction(self, function)
def invokeFunction(self, function): if function.name in self.createDeviceFunctionNames: # create windows as neccessary if 'pSwapChainDesc' in function.argNames(): print r' d3dretrace::createWindowForSwapChain(pSwapChainDesc);' # Compensate for the fact we don't trace DXGI object creation if function.name.startswith('D3D11CreateDevice'): print r' if (DriverType == D3D_DRIVER_TYPE_UNKNOWN && !pAdapter) {' print r' DriverType = D3D_DRIVER_TYPE_HARDWARE;' print r' }' if function.name.startswith('D3D10CreateDevice'): # Toggle debugging print r' Flags &= ~D3D10_CREATE_DEVICE_DEBUG;' print r' if (retrace::debug) {' print r' if (LoadLibraryA("d3d10sdklayers")) {' print r' Flags |= D3D10_CREATE_DEVICE_DEBUG;' print r' }' print r' }' # Force driver self.forceDriver('D3D10_DRIVER_TYPE') if function.name.startswith('D3D11CreateDevice'): # Toggle debugging print r' Flags &= ~D3D11_CREATE_DEVICE_DEBUG;' print r' if (retrace::debug) {' print r' const char *szD3d11SdkLayers = IsWindows8OrGreater() ? "d3d11_1sdklayers" : "d3d11sdklayers";' print r' if (LoadLibraryA(szD3d11SdkLayers)) {' print r' Flags |= D3D11_CREATE_DEVICE_DEBUG;' print r' }' print r' }' # Force driver self.forceDriver('D3D_DRIVER_TYPE') Retracer.invokeFunction(self, function) # Debug layers with Windows 8 or Windows 7 Platform update are a mess. # It's not possible to know before hand whether they are or not # available, so always retry with debug flag off.. if function.name in self.createDeviceFunctionNames: print r' if (FAILED(_result)) {' if function.name.startswith('D3D10CreateDevice'): print r' if (_result == E_FAIL && (Flags & D3D10_CREATE_DEVICE_DEBUG)) {' print r' retrace::warning(call) << "debug layer (d3d10sdklayers.dll) not installed\n";' print r' Flags &= ~D3D10_CREATE_DEVICE_DEBUG;' Retracer.invokeFunction(self, function) print r' }' elif function.name.startswith('D3D11CreateDevice'): print r' if (_result == E_FAIL && (Flags & D3D11_CREATE_DEVICE_DEBUG)) {' print r' retrace::warning(call) << "debug layer (d3d11sdklayers.dll for Windows 7, d3d11_1sdklayers.dll for Windows 8 or Windows 7 with KB 2670838) not properly installed\n";' print r' Flags &= ~D3D11_CREATE_DEVICE_DEBUG;' Retracer.invokeFunction(self, function) print r' }' else: assert False print r' if (FAILED(_result)) {' print r' exit(1);' print r' }' print r' }'
def invokeFunction(self, function): if function.name in self.createDeviceFunctionNames: # create windows as neccessary if 'pSwapChainDesc' in function.argNames(): print r' createWindow(pSwapChainDesc);' # Compensate for the fact we don't trace DXGI object creation if function.name.startswith('D3D11CreateDevice'): print r' if (DriverType == D3D_DRIVER_TYPE_UNKNOWN && !pAdapter) {' print r' DriverType = D3D_DRIVER_TYPE_HARDWARE;' print r' }' if function.name.startswith('D3D10CreateDevice'): # Toggle debugging print r' Flags &= ~D3D10_CREATE_DEVICE_DEBUG;' print r' if (retrace::debug) {' print r' if (LoadLibraryA("d3d10sdklayers")) {' print r' Flags |= D3D10_CREATE_DEVICE_DEBUG;' print r' }' print r' }' # Force driver self.forceDriver('D3D10_DRIVER_TYPE') if function.name.startswith('D3D11CreateDevice'): # Toggle debugging print r' Flags &= ~D3D11_CREATE_DEVICE_DEBUG;' print r' if (retrace::debug) {' print r' const char *szD3d11SdkLayers = IsWindows8OrGreater() ? "d3d11_1sdklayers" : "d3d11sdklayers";' print r' if (LoadLibraryA(szD3d11SdkLayers)) {' print r' Flags |= D3D11_CREATE_DEVICE_DEBUG;' print r' }' print r' }' # Force driver self.forceDriver('D3D_DRIVER_TYPE') Retracer.invokeFunction(self, function) # Debug layers with Windows 8 or Windows 7 Platform update are a mess. # It's not possible to know before hand whether they are or not # available, so always retry with debug flag off.. if function.name in self.createDeviceFunctionNames: print r' if (FAILED(_result)) {' if function.name.startswith('D3D10CreateDevice'): print r' if (_result == E_FAIL && (Flags & D3D10_CREATE_DEVICE_DEBUG)) {' print r' retrace::warning(call) << "debug layer (d3d10sdklayers.dll) not installed\n";' print r' Flags &= ~D3D10_CREATE_DEVICE_DEBUG;' Retracer.invokeFunction(self, function) print r' }' elif function.name.startswith('D3D11CreateDevice'): print r' if (_result == E_FAIL && (Flags & D3D11_CREATE_DEVICE_DEBUG)) {' print r' retrace::warning(call) << "debug layer (d3d11sdklayers.dll for Windows 7, d3d11_1sdklayers.dll for Windows 8 or Windows 7 with KB 2670838) not properly installed\n";' print r' Flags &= ~D3D11_CREATE_DEVICE_DEBUG;' Retracer.invokeFunction(self, function) print r' }' else: assert False print r' if (FAILED(_result)) {' print r' exit(1);' print r' }' print r' }'
def invokeFunction(self, function): if function.name in self.createDeviceFunctionNames: # create windows as neccessary if 'pSwapChainDesc' in function.argNames(): print r' createWindow(pSwapChainDesc);' # Compensate for the fact we don't trace DXGI object creation if function.name.startswith('D3D11CreateDevice'): print r' if (DriverType == D3D_DRIVER_TYPE_UNKNOWN && !pAdapter) {' print r' DriverType = D3D_DRIVER_TYPE_HARDWARE;' print r' }' if function.name.startswith('D3D10CreateDevice'): # Toggle debugging print r' Flags &= ~D3D10_CREATE_DEVICE_DEBUG;' print r' if (retrace::debug) {' print r' if (LoadLibraryA("d3d10sdklayers")) {' print r' Flags |= D3D10_CREATE_DEVICE_DEBUG;' print r' }' print r' }' # Force driver self.forceDriver('D3D10_DRIVER_TYPE') if function.name.startswith('D3D11CreateDevice'): # Toggle debugging print r' Flags &= ~D3D11_CREATE_DEVICE_DEBUG;' print r' if (retrace::debug) {' print r' OSVERSIONINFO osvi;' print r' BOOL bIsWindows8orLater;' print r' ZeroMemory(&osvi, sizeof osvi);' print r' osvi.dwOSVersionInfoSize = sizeof osvi;' print r' GetVersionEx(&osvi);' print r' bIsWindows8orLater = ' print r' (osvi.dwMajorVersion > 6) ||' print r' (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion >= 2);' print r' const char *szD3d11SdkLayers = bIsWindows8orLater ? "d3d11_1sdklayers" : "d3d11sdklayers";' print r' if (LoadLibraryA(szD3d11SdkLayers)) {' print r' Flags |= D3D11_CREATE_DEVICE_DEBUG;' print r' }' print r' }' # Force driver self.forceDriver('D3D_DRIVER_TYPE') Retracer.invokeFunction(self, function) if function.name in self.createDeviceFunctionNames: print r' if (FAILED(_result)) {' if function.name.startswith('D3D10CreateDevice'): print r' if (_result == E_FAIL && (Flags & D3D10_CREATE_DEVICE_DEBUG)) {' print r' retrace::warning(call) << "debug layer (d3d10sdklayers.dll) not installed\n";' print r' }' if function.name.startswith('D3D11CreateDevice'): print r' if (_result == E_FAIL && (Flags & D3D11_CREATE_DEVICE_DEBUG)) {' print r' retrace::warning(call) << "debug layer (d3d11sdklayers.dll for Windows 7, d3d11_1sdklayers.dll for Windows 8 or Windows 7 with KB 2670838) not properly installed\n";' print r' }' print r' exit(1);' print r' }'
def invokeFunction(self, function): if function.name.startswith('Direct3DCreate9'): print r' if (retrace::debug >= 3 && !g_szD3D9DllName && LoadLibraryA("d3d9d.dll")) {' print r' /*' print r' * D3D9D only works for simple applications, it will often report bogus errors' print r' * on complex traces, or traces which use unofficial D3D9 features.' print r' */' print r' g_szD3D9DllName = "d3d9d.dll";' print r' SDKVersion |= 0x80000000;' print r' } else {' print r' SDKVersion &= ~0x80000000;' print r' }' # d3d8d.dll can be found in the Aug 2007 DXSDK. It works on XP, but # not on Windows 7. if function.name.startswith('Direct3DCreate8'): print r' if (retrace::debug >= 3 && !g_szD3D8DllName && LoadLibraryA("d3d8d.dll")) {' print r' g_szD3D8DllName = "d3d8d.dll";' print r' }' if function.name.startswith('Direct3DCreate9'): print r' // 0: default' print r' // 1: force discrete' print r' // 2/3: force integrated' print r' UINT uHybrid = 0;' print r' if (retrace::driver == retrace::DRIVER_DISCRETE) {' print r' uHybrid = 1;' print r' }' print r' if (retrace::driver == retrace::DRIVER_INTEGRATED) {' print r' uHybrid = 2;' print r' }' print r' if (uHybrid != 0) {' print r' HMODULE hD3D9 = LoadLibraryA("D3D9");' print r' assert(hD3D9);' print r' typedef void (WINAPI *PFNDIRECT3D9FORCEHYBRIDENUMERATION)(UINT);' print r' PFNDIRECT3D9FORCEHYBRIDENUMERATION pfnDirect3D9ForceHybridEnumeration =' print r' (PFNDIRECT3D9FORCEHYBRIDENUMERATION)GetProcAddress(hD3D9, MAKEINTRESOURCEA(16));' print r' if (pfnDirect3D9ForceHybridEnumeration) {' print r' pfnDirect3D9ForceHybridEnumeration(uHybrid);' print r' }' print r' }' Retracer.invokeFunction(self, function) if function.name.startswith('Direct3DCreate'): print r' if (retrace::driver == retrace::DRIVER_DISCRETE ||' print r' retrace::driver == retrace::DRIVER_INTEGRATED) {' if function.name == 'Direct3DCreate9Ex': print r' auto pD3D = SUCCEEDED(_result) ? *ppD3D : nullptr;' else: print r' auto pD3D = _result;' if function.name.startswith('Direct3DCreate9'): print r' D3DADAPTER_IDENTIFIER9 Identifier;' else: assert function.name.startswith('Direct3DCreate8') print r' D3DADAPTER_IDENTIFIER8 Identifier;' print r' if (pD3D) {' print r' if (SUCCEEDED(pD3D->GetAdapterIdentifier(D3DADAPTER_DEFAULT, 0, &Identifier))) {' print r' std::cerr << "info: using " << Identifier.Description << std::endl;' print r' }' print r' }' print r' }'