libobs-d3d11: Add optional macro to log shader disassembly

master
jp9000 2016-11-25 12:01:31 -08:00
parent c6c58e55b3
commit d2bb7157c2
3 changed files with 26 additions and 0 deletions

View File

@ -201,6 +201,22 @@ void gs_shader::Compile(const char *shaderString, const char *file,
else
throw HRError("Failed to compile shader", hr);
}
#ifdef DISASSEMBLE_SHADERS
ComPtr<ID3D10Blob> asmBlob;
if (!device->d3dDisassemble)
return;
hr = device->d3dDisassemble((*shader)->GetBufferPointer(),
(*shader)->GetBufferSize(), 0, nullptr, &asmBlob);
if (SUCCEEDED(hr) && !!asmBlob && asmBlob->GetBufferSize()) {
blog(LOG_INFO, "=============================================");
blog(LOG_INFO, "Disassembly output for shader '%s':\n%s",
file, asmBlob->GetBufferPointer());
}
#endif
}
inline void gs_shader::UpdateParam(vector<uint8_t> &constData,

View File

@ -181,6 +181,11 @@ void gs_device::InitCompiler()
if (module) {
d3dCompile = (pD3DCompile)GetProcAddress(module,
"D3DCompile");
#ifdef DISASSEMBLE_SHADERS
d3dDisassemble = (pD3DDisassemble)GetProcAddress(
module, "D3DDisassemble");
#endif
if (d3dCompile) {
return;
}

View File

@ -37,6 +37,8 @@
#include <util/windows/ComPtr.hpp>
#include <util/windows/HRError.hpp>
// #define DISASSEMBLE_SHADERS
struct shader_var;
struct shader_sampler;
struct gs_vertex_shader;
@ -801,6 +803,9 @@ struct gs_device {
D3D11_PRIMITIVE_TOPOLOGY curToplogy;
pD3DCompile d3dCompile = nullptr;
#ifdef DISASSEMBLE_SHADERS
pD3DDisassemble d3dDisassemble = nullptr;
#endif
gs_rect viewport;