mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Pass shader specialization data to pipeline state (just data, not in UI)
This commit is contained in:
@@ -141,7 +141,12 @@ struct VulkanPipelineState
|
||||
|
||||
ShaderStageType stage;
|
||||
|
||||
// VKTODOMED specialization info
|
||||
struct SpecInfo
|
||||
{
|
||||
uint32_t specID;
|
||||
rdctype::array<byte> data;
|
||||
};
|
||||
rdctype::array<SpecInfo> specialization;
|
||||
} VS, TCS, TES, GS, FS, CS;
|
||||
|
||||
struct Tessellation
|
||||
|
||||
@@ -93,6 +93,22 @@ void VulkanCreationInfo::Pipeline::Init(VulkanResourceManager *resourceMan, Vulk
|
||||
info.m_ShaderModule[id].spirv.MakeReflection(reflData.entryPoint, &reflData.refl, &reflData.mapping);
|
||||
}
|
||||
|
||||
if(pCreateInfo->pStages[i].pSpecializationInfo)
|
||||
{
|
||||
shad.specdata.resize(pCreateInfo->pStages[i].pSpecializationInfo->dataSize);
|
||||
memcpy(&shad.specdata[0], pCreateInfo->pStages[i].pSpecializationInfo->pData, shad.specdata.size());
|
||||
|
||||
const VkSpecializationMapEntry *maps = pCreateInfo->pStages[i].pSpecializationInfo->pMapEntries;
|
||||
for(uint32_t s=0; s < pCreateInfo->pStages[i].pSpecializationInfo->mapEntryCount; s++)
|
||||
{
|
||||
Shader::SpecInfo spec;
|
||||
spec.specID = maps[s].constantID;
|
||||
spec.data = &shad.specdata[maps[s].offset];
|
||||
// ignore maps[s].size, assume it's enough for the type
|
||||
shad.specialization.push_back(spec);
|
||||
}
|
||||
}
|
||||
|
||||
shad.refl = &reflData.refl;
|
||||
shad.mapping = &reflData.mapping;
|
||||
}
|
||||
@@ -224,6 +240,22 @@ void VulkanCreationInfo::Pipeline::Init(VulkanResourceManager *resourceMan, Vulk
|
||||
info.m_ShaderModule[id].spirv.MakeReflection(reflData.entryPoint, &reflData.refl, &reflData.mapping);
|
||||
}
|
||||
|
||||
if(pCreateInfo->stage.pSpecializationInfo)
|
||||
{
|
||||
shad.specdata.resize(pCreateInfo->stage.pSpecializationInfo->dataSize);
|
||||
memcpy(&shad.specdata[0], pCreateInfo->stage.pSpecializationInfo->pData, shad.specdata.size());
|
||||
|
||||
const VkSpecializationMapEntry *maps = pCreateInfo->stage.pSpecializationInfo->pMapEntries;
|
||||
for(uint32_t s=0; s < pCreateInfo->stage.pSpecializationInfo->mapEntryCount; s++)
|
||||
{
|
||||
Shader::SpecInfo spec;
|
||||
spec.specID = maps[s].constantID;
|
||||
spec.data = &shad.specdata[maps[s].offset];
|
||||
spec.size = maps[s].size;
|
||||
shad.specialization.push_back(spec);
|
||||
}
|
||||
}
|
||||
|
||||
shad.refl = &reflData.refl;
|
||||
shad.mapping = &reflData.mapping;
|
||||
}
|
||||
|
||||
@@ -74,6 +74,15 @@ struct VulkanCreationInfo
|
||||
string entryPoint;
|
||||
ShaderReflection *refl;
|
||||
ShaderBindpointMapping *mapping;
|
||||
|
||||
vector<byte> specdata;
|
||||
struct SpecInfo
|
||||
{
|
||||
uint32_t specID;
|
||||
byte *data;
|
||||
size_t size;
|
||||
};
|
||||
vector<SpecInfo> specialization;
|
||||
};
|
||||
Shader shaders[6];
|
||||
|
||||
|
||||
@@ -2710,6 +2710,13 @@ void VulkanReplay::SavePipelineState()
|
||||
stages[i]->stage = ShaderStageType(eShaderStage_Vertex + i);
|
||||
if(p.shaders[i].mapping)
|
||||
stages[i]->BindpointMapping = *p.shaders[i].mapping;
|
||||
|
||||
create_array_uninit(stages[i]->specialization, p.shaders[i].specialization.size());
|
||||
for(size_t s=0; s < p.shaders[i].specialization.size(); s++)
|
||||
{
|
||||
stages[i]->specialization[s].specID = p.shaders[i].specialization[s].specID;
|
||||
create_array_init(stages[i]->specialization[s].data, p.shaders[i].specialization[s].size, p.shaders[i].specialization[s].data);
|
||||
}
|
||||
}
|
||||
|
||||
// Tessellation
|
||||
|
||||
@@ -182,6 +182,16 @@ namespace renderdoc
|
||||
public ShaderBindpointMapping BindpointMapping;
|
||||
|
||||
public ShaderStageType stage;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct SpecInfo
|
||||
{
|
||||
public UInt32 specID;
|
||||
[CustomMarshalAs(CustomUnmanagedType.TemplatedArray)]
|
||||
public byte[] data;
|
||||
};
|
||||
[CustomMarshalAs(CustomUnmanagedType.TemplatedArray)]
|
||||
SpecInfo[] specialization;
|
||||
};
|
||||
[CustomMarshalAs(CustomUnmanagedType.CustomClass)]
|
||||
public ShaderStage VS, TCS, TES, GS, FS, CS;
|
||||
|
||||
Reference in New Issue
Block a user