]> git.cworth.org Git - apitrace/blobdiff - wrappers/d3dshader.cpp
Fix D3D11 tracing with D3D11_CREATE_DEVICE_DEBUG flag.
[apitrace] / wrappers / d3dshader.cpp
index a2d5c1293c275fce04958e90d0258851358ca12c..b0690dcc39e891e7f87526d30b35d7871733f4f9 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "d3dshader.hpp"
 #include "d3d9imports.hpp"
+#include "d3dsize.hpp"
 
 
 typedef HRESULT
@@ -43,6 +44,12 @@ typedef HRESULT
 void DumpShader(trace::Writer &writer, const DWORD *tokens)
 {
     static BOOL firsttime = TRUE;
+
+    /*
+     * TODO: Consider using d3dcompile_xx.dll per
+     * http://msdn.microsoft.com/en-us/library/windows/desktop/ee663275.aspx
+     */
+
     static HMODULE hD3DXModule = NULL;
     static PD3DXDISASSEMBLESHADER pfnD3DXDisassembleShader = NULL;
 
@@ -74,23 +81,25 @@ found:
         firsttime = FALSE;
     }
 
+    LPD3DXBUFFER pDisassembly = NULL;
+    HRESULT hr = E_FAIL;
+
     if (pfnD3DXDisassembleShader) {
-        LPD3DXBUFFER pDisassembly = NULL;
-        HRESULT hr;
+        hr = pfnD3DXDisassembleShader(tokens, FALSE, NULL, &pDisassembly);
+    }
 
-        hr = pfnD3DXDisassembleShader( (DWORD *)tokens, FALSE, NULL, &pDisassembly);
-        if (hr == D3D_OK) {
-            writer.writeString((const char *)pDisassembly->GetBufferPointer());
-        }
+    if (SUCCEEDED(hr)) {
+        writer.beginRepr();
+        writer.writeString((const char *)pDisassembly->GetBufferPointer(), pDisassembly->GetBufferSize());
+    }
 
-        if (pDisassembly) {
-            pDisassembly->Release();
-        }
+    writer.writeBlob(tokens, _shaderSize(tokens));
 
-        if (hr == D3D_OK) {
-            return;
-        }
+    if (pDisassembly) {
+        pDisassembly->Release();
+    }
+    
+    if (SUCCEEDED(hr)) {
+        writer.endRepr();
     }
-
-    writer.writeOpaque(tokens);
 }