#include "d3dshader.hpp"
#include "d3d9imports.hpp"
+#include "d3dsize.hpp"
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;
firsttime = FALSE;
}
- if (pfnD3DXDisassembleShader) {
- LPD3DXBUFFER pDisassembly = NULL;
- HRESULT hr;
+ LPD3DXBUFFER pDisassembly = NULL;
+ HRESULT hr = E_FAIL;
+ if (pfnD3DXDisassembleShader) {
hr = pfnD3DXDisassembleShader(tokens, FALSE, NULL, &pDisassembly);
- if (hr == D3D_OK) {
- writer.writeString((const char *)pDisassembly->GetBufferPointer());
- }
-
- if (pDisassembly) {
- pDisassembly->Release();
- }
+ }
- if (hr == D3D_OK) {
- return;
- }
+ if (SUCCEEDED(hr)) {
+ writer.beginRepr();
+ writer.writeString((const char *)pDisassembly->GetBufferPointer(), pDisassembly->GetBufferSize());
}
- writer.writePointer((UINT_PTR)tokens);
+ writer.writeBlob(tokens, _shaderSize(tokens));
+
+ if (pDisassembly) {
+ pDisassembly->Release();
+ }
+
+ if (SUCCEEDED(hr)) {
+ writer.endRepr();
+ }
}