mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 18:10:35 +00:00
Move SPVModule into header and fill out ShaderReflection from SPIR-V
This commit is contained in:
@@ -39,6 +39,8 @@
|
||||
#include "gl_renderstate.h"
|
||||
#include "gl_replay.h"
|
||||
|
||||
#include "driver/shaders/spirv/spirv_common.h"
|
||||
|
||||
#include <list>
|
||||
using std::list;
|
||||
|
||||
@@ -254,7 +256,7 @@ class WrappedOpenGL : public IFrameCapturer
|
||||
GLenum type;
|
||||
vector<string> sources;
|
||||
vector<string> includepaths;
|
||||
vector<uint32_t> spirv;
|
||||
SPVModule spirv;
|
||||
ShaderReflection reflection;
|
||||
GLuint prog;
|
||||
|
||||
|
||||
@@ -49,11 +49,15 @@ void WrappedOpenGL::ShaderData::Compile(const GLHookSet &gl)
|
||||
prog = sepProg;
|
||||
MakeShaderReflection(gl, type, sepProg, reflection, pointSizeUsed, clipDistanceUsed);
|
||||
|
||||
string s = CompileSPIRV(SPIRVShaderStage(ShaderIdx(type)), sources, spirv);
|
||||
if(!spirv.empty())
|
||||
DisassembleSPIRV(SPIRVShaderStage(ShaderIdx(type)), &spirv.front(), spirv.size(), s);
|
||||
vector<uint32_t> spirvwords;
|
||||
|
||||
reflection.Disassembly = s;
|
||||
string s = CompileSPIRV(SPIRVShaderStage(ShaderIdx(type)), sources, spirvwords);
|
||||
if(!spirvwords.empty())
|
||||
ParseSPIRV(&spirvwords.front(), spirvwords.size(), spirv);
|
||||
|
||||
spirv.Disassemble();
|
||||
|
||||
reflection.Disassembly = spirv.m_Disassembly;
|
||||
|
||||
create_array_uninit(reflection.DebugInfo.files, sources.size());
|
||||
for(size_t i=0; i < sources.size(); i++)
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
using std::string;
|
||||
@@ -44,5 +46,35 @@ enum SPIRVShaderStage
|
||||
void InitSPIRVCompiler();
|
||||
void ShutdownSPIRVCompiler();
|
||||
|
||||
struct SPVInstruction;
|
||||
|
||||
struct SPVModule
|
||||
{
|
||||
SPVModule();
|
||||
~SPVModule();
|
||||
|
||||
uint32_t moduleVersion;
|
||||
uint32_t generator;
|
||||
|
||||
string sourceLang; uint32_t sourceVer;
|
||||
|
||||
vector<SPVInstruction*> operations; // all operations (including those that don't generate an ID)
|
||||
|
||||
vector<SPVInstruction*> ids; // pointers indexed by ID
|
||||
|
||||
vector<SPVInstruction*> sourceexts; // source extensions
|
||||
vector<SPVInstruction*> entries; // entry points
|
||||
vector<SPVInstruction*> globals; // global variables
|
||||
vector<SPVInstruction*> funcs; // functions
|
||||
vector<SPVInstruction*> structs; // struct types
|
||||
|
||||
string m_Disassembly;
|
||||
|
||||
SPVInstruction *GetByID(uint32_t id);
|
||||
void Disassemble();
|
||||
};
|
||||
|
||||
struct ShaderReflection;
|
||||
|
||||
string CompileSPIRV(SPIRVShaderStage shadType, const vector<string> &sources, vector<uint32_t> &spirv);
|
||||
void DisassembleSPIRV(SPIRVShaderStage shadType, uint32_t *spirv, size_t spirvLength, string &disasm);
|
||||
void ParseSPIRV(uint32_t *spirv, size_t spirvLength, SPVModule &module, ShaderReflection *reflection = NULL);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -134,9 +134,11 @@ bool WrappedVulkan::Serialise_vkCreateShaderModule(
|
||||
ResourceId live = GetResourceManager()->WrapResource(Unwrap(device), sh);
|
||||
GetResourceManager()->AddLiveResource(id, sh);
|
||||
|
||||
string disasm;
|
||||
SPVModule spvmod;
|
||||
ShaderReflection refl;
|
||||
|
||||
RDCASSERT(info.codeSize % sizeof(uint32_t) == 0);
|
||||
DisassembleSPIRV(eSPIRVGeneric, (uint32_t *)info.pCode, info.codeSize/sizeof(uint32_t), disasm);
|
||||
ParseSPIRV((uint32_t *)info.pCode, info.codeSize/sizeof(uint32_t), spvmod, &refl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user