]> git.cworth.org Git - apitrace/blobdiff - retrace/d3d10state.cpp
common: Add more comments.
[apitrace] / retrace / d3d10state.cpp
index f9b3661cfdf8a3a3b7d0fa077187033a93c99783..d5e41da04146d3597264ed8f1dbea2e74c0f46c6 100644 (file)
 
 #include <iostream>
 
-#include "d3d11imports.hpp"
-#include "json.hpp"
-#include "d3dshader.hpp"
-#include "d3dstate.hpp"
+#include "d3d10imports.hpp"
+#include "d3d10state.hpp"
 
 
 namespace d3dstate {
@@ -41,46 +39,6 @@ const GUID
 GUID_D3DSTATE = {0x7D71CAC9,0x7F58,0x432C,{0xA9,0x75,0xA1,0x9F,0xCF,0xCE,0xFD,0x14}};
 
 
-template< class T >
-inline void
-dumpShader(JSONWriter &json, const char *name, T *pShader) {
-    if (!pShader) {
-        return;
-    }
-
-    HRESULT hr;
-
-    /*
-     * There is no method to get the shader byte code, so the creator is supposed to
-     * attach it via the SetPrivateData method.
-     */
-    UINT BytecodeLength = 0;
-    char dummy;
-    hr = pShader->GetPrivateData(GUID_D3DSTATE, &BytecodeLength, &dummy);
-    if (hr != DXGI_ERROR_MORE_DATA) {
-        return;
-    }
-
-    void *pShaderBytecode = malloc(BytecodeLength);
-    if (!pShaderBytecode) {
-        return;
-    }
-
-    hr = pShader->GetPrivateData(GUID_D3DSTATE, &BytecodeLength, pShaderBytecode);
-    if (SUCCEEDED(hr)) {
-        IDisassemblyBuffer *pDisassembly = NULL;
-        hr = DisassembleShader(pShaderBytecode, BytecodeLength, &pDisassembly);
-        if (SUCCEEDED(hr)) {
-            json.beginMember(name);
-            json.writeString((const char *)pDisassembly->GetBufferPointer() /*, pDisassembly->GetBufferSize() */);
-            json.endMember();
-            pDisassembly->Release();
-        }
-    }
-
-    free(pShaderBytecode);
-}
-
 static void
 dumpShaders(JSONWriter &json, ID3D10Device *pDevice)
 {
@@ -90,14 +48,21 @@ dumpShaders(JSONWriter &json, ID3D10Device *pDevice)
     ID3D10VertexShader *pVertexShader = NULL;
     pDevice->VSGetShader(&pVertexShader);
     if (pVertexShader) {
-        dumpShader(json, "vertex", pVertexShader);
+        dumpShader<ID3D10DeviceChild>(json, "VS", pVertexShader);
         pVertexShader->Release();
     }
 
+    ID3D10GeometryShader *pGeometryShader = NULL;
+    pDevice->GSGetShader(&pGeometryShader);
+    if (pGeometryShader) {
+        dumpShader<ID3D10DeviceChild>(json, "GS", pGeometryShader);
+        pGeometryShader->Release();
+    }
+
     ID3D10PixelShader *pPixelShader = NULL;
     pDevice->PSGetShader(&pPixelShader);
     if (pPixelShader) {
-        dumpShader(json, "pixel", pPixelShader);
+        dumpShader<ID3D10DeviceChild>(json, "PS", pPixelShader);
     }
 
     json.endObject();