Pass vulkan shader modules into DisassembleSPIRV

This commit is contained in:
baldurk
2016-02-07 18:41:36 +01:00
parent 1ae521823c
commit 410ada541a
4 changed files with 13 additions and 5 deletions
@@ -51,7 +51,7 @@ void WrappedOpenGL::ShaderData::Compile(const GLHookSet &gl)
string s = CompileSPIRV(SPIRVShaderStage(ShaderIdx(type)), sources, spirv);
if(!spirv.empty())
DisassembleSPIRV(SPIRVShaderStage(ShaderIdx(type)), spirv, s);
DisassembleSPIRV(SPIRVShaderStage(ShaderIdx(type)), &spirv.front(), spirv.size(), s);
reflection.Disassembly = s;
@@ -37,6 +37,7 @@ enum SPIRVShaderStage
eSPIRVGeometry,
eSPIRVFragment,
eSPIRVCompute,
eSPIRVGeneric,
eSPIRVInvalid,
};
@@ -44,4 +45,4 @@ void InitSPIRVCompiler();
void ShutdownSPIRVCompiler();
string CompileSPIRV(SPIRVShaderStage shadType, const vector<string> &sources, vector<uint32_t> &spirv);
void DisassembleSPIRV(SPIRVShaderStage shadType, const vector<uint32_t> &spirv, string &disasm);
void DisassembleSPIRV(SPIRVShaderStage shadType, uint32_t *spirv, size_t spirvLength, string &disasm);
@@ -862,6 +862,7 @@ struct SPVModule
"Geometry Shader",
"Fragment Shader",
"Compute Shader",
"Unknown Shader Target",
};
disasm = header[(int)shadType];
@@ -1410,7 +1411,7 @@ struct SPVModule
}
};
void DisassembleSPIRV(SPIRVShaderStage shadType, const vector<uint32_t> &spirv, string &disasm)
void DisassembleSPIRV(SPIRVShaderStage shadType, uint32_t *spirv, size_t spirvLength, string &disasm)
{
#if 1
return;
@@ -1440,7 +1441,7 @@ void DisassembleSPIRV(SPIRVShaderStage shadType, const vector<uint32_t> &spirv,
SPVBlock *curBlock = NULL;
size_t it = 5;
while(it < spirv.size())
while(it < spirvLength)
{
uint16_t WordCount = spirv[it]>>16;
@@ -2062,7 +2063,7 @@ void DisassembleSPIRV(SPIRVShaderStage shadType, const vector<uint32_t> &spirv,
// second pass now that we have all ids set up, apply decorations/names/etc
it = 5;
while(it < spirv.size())
while(it < spirvLength)
{
uint16_t WordCount = spirv[it]>>16;
spv::Op op = spv::Op(spirv[it]&0xffff);
@@ -24,6 +24,8 @@
#include "../vk_core.h"
#include "driver/shaders/spirv/spirv_common.h"
// Shader functions
bool WrappedVulkan::Serialise_vkCreatePipelineLayout(
VkDevice device,
@@ -131,6 +133,10 @@ bool WrappedVulkan::Serialise_vkCreateShaderModule(
{
ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), sh);
GetResourceManager()->AddLiveResource(id, sh);
string disasm;
RDCASSERT(info.codeSize % sizeof(uint32_t) == 0);
DisassembleSPIRV(eSPIRVGeneric, (uint32_t *)info.pCode, info.codeSize/sizeof(uint32_t), disasm);
}
}