split SPVParseData from SPVData
This commit is contained in:
parent
34679a632d
commit
a9df8965ea
81
glsl2spv.cpp
81
glsl2spv.cpp
@ -296,12 +296,6 @@ struct SPVData
|
|||||||
uint32_t *spv_data;
|
uint32_t *spv_data;
|
||||||
uint32_t spv_length;
|
uint32_t spv_length;
|
||||||
|
|
||||||
ShaderAttributeData input,
|
|
||||||
output;
|
|
||||||
ShaderDescriptorResource resource;
|
|
||||||
ShaderResourceData<PushConstant> push_constant;
|
|
||||||
ShaderResourceData<SubpassInput> subpass_input;
|
|
||||||
|
|
||||||
void Init()
|
void Init()
|
||||||
{
|
{
|
||||||
memset(this,0,sizeof(SPVData));
|
memset(this,0,sizeof(SPVData));
|
||||||
@ -341,6 +335,29 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
~SPVData()
|
~SPVData()
|
||||||
|
{
|
||||||
|
delete[] log;
|
||||||
|
delete[] debug_log;
|
||||||
|
delete[] spv_data;
|
||||||
|
}
|
||||||
|
};//struct SPVData
|
||||||
|
|
||||||
|
struct SPVParseData
|
||||||
|
{
|
||||||
|
ShaderAttributeData input,
|
||||||
|
output;
|
||||||
|
ShaderDescriptorResource resource;
|
||||||
|
ShaderResourceData<PushConstant> push_constant;
|
||||||
|
ShaderResourceData<SubpassInput> subpass_input;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SPVParseData()
|
||||||
|
{
|
||||||
|
memset(this,0,sizeof(SPVParseData));
|
||||||
|
}
|
||||||
|
|
||||||
|
~SPVParseData()
|
||||||
{
|
{
|
||||||
for(uint32_t i=0;i<VK_DESCRIPTOR_TYPE_COUNT;i++)
|
for(uint32_t i=0;i<VK_DESCRIPTOR_TYPE_COUNT;i++)
|
||||||
delete[] resource[i].items;
|
delete[] resource[i].items;
|
||||||
@ -350,12 +367,8 @@ public:
|
|||||||
|
|
||||||
delete[] input.items;
|
delete[] input.items;
|
||||||
delete[] output.items;
|
delete[] output.items;
|
||||||
|
|
||||||
delete[] log;
|
|
||||||
delete[] debug_log;
|
|
||||||
delete[] spv_data;
|
|
||||||
}
|
}
|
||||||
};//struct SPVData
|
};
|
||||||
|
|
||||||
void OutputShaderAttributes(ShaderAttributeData *ssd,ShaderParse *sp,const SPVResVector &stages)
|
void OutputShaderAttributes(ShaderAttributeData *ssd,ShaderParse *sp,const SPVResVector &stages)
|
||||||
{
|
{
|
||||||
@ -553,26 +566,34 @@ extern "C"
|
|||||||
|
|
||||||
glslang::GlslangToSpv(*program.getIntermediate(stage),spirv);
|
glslang::GlslangToSpv(*program.getIntermediate(stage),spirv);
|
||||||
|
|
||||||
SPVData *spv=new SPVData(spirv);
|
return(new SPVData(spirv));
|
||||||
|
}
|
||||||
|
|
||||||
{
|
SPVParseData *ParseSPV(SPVData *spv_data)
|
||||||
ShaderParse sp(spirv.data(),(uint32_t)spirv.size()*sizeof(uint32_t));
|
{
|
||||||
|
ShaderParse sp(spv_data->spv_data,spv_data->spv_length);
|
||||||
|
|
||||||
OutputShaderAttributes(&(spv->input),&sp,sp.GetStageInputs());
|
SPVParseData *spv=new SPVParseData;
|
||||||
OutputShaderAttributes(&(spv->output),&sp,sp.GetStageOutputs());
|
|
||||||
|
|
||||||
OutputShaderResource(spv->resource+VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, &sp,sp.GetUBO());
|
OutputShaderAttributes(&(spv->input),&sp,sp.GetStageInputs());
|
||||||
OutputShaderResource(spv->resource+VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, &sp,sp.GetSSBO());
|
OutputShaderAttributes(&(spv->output),&sp,sp.GetStageOutputs());
|
||||||
OutputShaderResource(spv->resource+VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, &sp,sp.GetSampledImages());
|
|
||||||
OutputShaderResource(spv->resource+VK_DESCRIPTOR_TYPE_SAMPLER, &sp,sp.GetSeparateSamplers());
|
|
||||||
OutputShaderResource(spv->resource+VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, &sp,sp.GetSeparateImages());
|
|
||||||
OutputShaderResource(spv->resource+VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, &sp,sp.GetStorageImages());
|
|
||||||
|
|
||||||
OutputPushConstant (&(spv->push_constant), &sp,sp.GetPushConstant());
|
OutputShaderResource(spv->resource+VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, &sp,sp.GetUBO());
|
||||||
OutputSubpassInput (&(spv->subpass_input), &sp,sp.GetSubpassInputs());
|
OutputShaderResource(spv->resource+VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, &sp,sp.GetSSBO());
|
||||||
}
|
OutputShaderResource(spv->resource+VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, &sp,sp.GetSampledImages());
|
||||||
|
OutputShaderResource(spv->resource+VK_DESCRIPTOR_TYPE_SAMPLER, &sp,sp.GetSeparateSamplers());
|
||||||
|
OutputShaderResource(spv->resource+VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, &sp,sp.GetSeparateImages());
|
||||||
|
OutputShaderResource(spv->resource+VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, &sp,sp.GetStorageImages());
|
||||||
|
|
||||||
return(spv);
|
OutputPushConstant (&(spv->push_constant), &sp,sp.GetPushConstant());
|
||||||
|
OutputSubpassInput (&(spv->subpass_input), &sp,sp.GetSubpassInputs());
|
||||||
|
|
||||||
|
return spv;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FreeSPVParse(SPVParseData *spv)
|
||||||
|
{
|
||||||
|
delete spv;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPVData *CompileFromPath(
|
SPVData *CompileFromPath(
|
||||||
@ -642,6 +663,9 @@ extern "C"
|
|||||||
SPVData * (*CompileFromPath)(const uint32_t stage,const char *shader_filename, const CompileInfo *compile_info);
|
SPVData * (*CompileFromPath)(const uint32_t stage,const char *shader_filename, const CompileInfo *compile_info);
|
||||||
|
|
||||||
void (*Free)(SPVData *);
|
void (*Free)(SPVData *);
|
||||||
|
|
||||||
|
SPVParseData *(*ParseSPV)(SPVData *spv_data);
|
||||||
|
void (*FreeParseSPVData)(SPVParseData *);
|
||||||
};
|
};
|
||||||
|
|
||||||
static GLSLCompilerInterface plug_in_interface
|
static GLSLCompilerInterface plug_in_interface
|
||||||
@ -653,7 +677,10 @@ extern "C"
|
|||||||
&GetShaderStageFlagByExtName,
|
&GetShaderStageFlagByExtName,
|
||||||
&Shader2SPV,
|
&Shader2SPV,
|
||||||
&CompileFromPath,
|
&CompileFromPath,
|
||||||
&FreeSPVData
|
&FreeSPVData,
|
||||||
|
|
||||||
|
&ParseSPV,
|
||||||
|
&FreeSPVParse
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
Loading…
x
Reference in New Issue
Block a user