diff options
author | Jose Fonseca <jfonseca@vmware.com> | 2015-05-01 12:38:03 +0100 |
---|---|---|
committer | Jose Fonseca <jfonseca@vmware.com> | 2015-05-01 12:48:35 +0100 |
commit | e8ba07965b69920be45c2ea061e05fee506ed98d (patch) | |
tree | ebd719d9f1528442538a90d3bb725fa3423888a7 /retrace/d3d9state.cpp | |
parent | 0627790166dccd8dd370fa7d9f434ed9fc027fb4 (diff) |
retrace: Put JSON writer behind an ABC.
So that we can later dump state in formats other than JSON.
Diffstat (limited to 'retrace/d3d9state.cpp')
-rw-r--r-- | retrace/d3d9state.cpp | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/retrace/d3d9state.cpp b/retrace/d3d9state.cpp index c30114ea..29851f9b 100644 --- a/retrace/d3d9state.cpp +++ b/retrace/d3d9state.cpp @@ -28,7 +28,7 @@ #include <iostream> -#include "json.hpp" +#include "state_writer.hpp" #include "com_ptr.hpp" #include "d3d9imports.hpp" #include "d3dshader.hpp" @@ -40,7 +40,7 @@ namespace d3dstate { template< class T > inline void -dumpShader(JSONWriter &json, const char *name, T *pShader) { +dumpShader(StateWriter &writer, const char *name, T *pShader) { if (!pShader) { return; } @@ -59,9 +59,9 @@ dumpShader(JSONWriter &json, const char *name, T *pShader) { com_ptr<IDisassemblyBuffer> pDisassembly; hr = DisassembleShader((const DWORD *)pData, &pDisassembly); if (SUCCEEDED(hr)) { - json.beginMember(name); - json.writeString((const char *)pDisassembly->GetBufferPointer() /*, pDisassembly->GetBufferSize() */); - json.endMember(); + writer.beginMember(name); + writer.writeString((const char *)pDisassembly->GetBufferPointer() /*, pDisassembly->GetBufferSize() */); + writer.endMember(); } } @@ -71,45 +71,43 @@ dumpShader(JSONWriter &json, const char *name, T *pShader) { } static void -dumpShaders(JSONWriter &json, IDirect3DDevice9 *pDevice) +dumpShaders(StateWriter &writer, IDirect3DDevice9 *pDevice) { - json.beginMember("shaders"); + writer.beginMember("shaders"); HRESULT hr; - json.beginObject(); + writer.beginObject(); com_ptr<IDirect3DVertexShader9> pVertexShader; hr = pDevice->GetVertexShader(&pVertexShader); if (SUCCEEDED(hr)) { - dumpShader<IDirect3DVertexShader9>(json, "vertex", pVertexShader); + dumpShader<IDirect3DVertexShader9>(writer, "vertex", pVertexShader); } com_ptr<IDirect3DPixelShader9> pPixelShader; hr = pDevice->GetPixelShader(&pPixelShader); if (SUCCEEDED(hr)) { - dumpShader<IDirect3DPixelShader9>(json, "pixel", pPixelShader); + dumpShader<IDirect3DPixelShader9>(writer, "pixel", pPixelShader); } - json.endObject(); - json.endMember(); // shaders + writer.endObject(); + writer.endMember(); // shaders } void -dumpDevice(std::ostream &os, IDirect3DDevice9 *pDevice) +dumpDevice(StateWriter &writer, IDirect3DDevice9 *pDevice) { - JSONWriter json(os); - /* TODO */ - json.beginMember("parameters"); - json.beginObject(); - json.endObject(); - json.endMember(); // parameters + writer.beginMember("parameters"); + writer.beginObject(); + writer.endObject(); + writer.endMember(); // parameters - dumpShaders(json, pDevice); + dumpShaders(writer, pDevice); - dumpTextures(json, pDevice); + dumpTextures(writer, pDevice); - dumpFramebuffer(json, pDevice); + dumpFramebuffer(writer, pDevice); } |