mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-11-15 02:11:22 +00:00
Don't use SPIR-V entry point name as unique identifier. Closes #2226
This commit is contained in:
9 files changed
+36
-47
No files matched your search
@@ -67,7 +67,7 @@ void AddXFBAnnotations(const ShaderReflection &refl, const SPIRVPatchData &patch
|
||||
rdcspv::Id entryid;
|
||||
for(const rdcspv::EntryPoint &entry : editor.GetEntries())
|
||||
{
|
||||
if(entry.name == entryName)
|
||||
if(entry.name == entryName && MakeShaderStage(entry.executionModel) == refl.stage)
|
||||
{
|
||||
entryid = entry.id;
|
||||
break;
|
||||
@@ -582,23 +582,15 @@ void Reflector::PostParse()
|
||||
memberNames.clear();
|
||||
}
|
||||
|
||||
rdcarray<rdcstr> Reflector::EntryPoints() const
|
||||
rdcarray<ShaderEntryPoint> Reflector::EntryPoints() const
|
||||
{
|
||||
rdcarray<rdcstr> ret;
|
||||
rdcarray<ShaderEntryPoint> ret;
|
||||
ret.reserve(entries.size());
|
||||
for(const EntryPoint &e : entries)
|
||||
ret.push_back(e.name);
|
||||
ret.push_back({e.name, MakeShaderStage(e.executionModel)});
|
||||
return ret;
|
||||
}
|
||||
|
||||
ShaderStage Reflector::StageForEntry(const rdcstr &entryPoint) const
|
||||
{
|
||||
for(const EntryPoint &e : entries)
|
||||
if(entryPoint == e.name)
|
||||
return MakeShaderStage(e.executionModel);
|
||||
return ShaderStage::Count;
|
||||
}
|
||||
|
||||
void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage stage,
|
||||
const rdcstr &entryPoint, const rdcarray<SpecConstant> &specInfo,
|
||||
ShaderReflection &reflection, ShaderBindpointMapping &mapping,
|
||||
@@ -615,7 +607,7 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st
|
||||
const EntryPoint *entry = NULL;
|
||||
for(const EntryPoint &e : entries)
|
||||
{
|
||||
if(entryPoint == e.name)
|
||||
if(entryPoint == e.name && MakeShaderStage(e.executionModel) == stage)
|
||||
{
|
||||
entry = &e;
|
||||
break;
|
||||
@@ -626,7 +618,8 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st
|
||||
|
||||
if(!entry)
|
||||
{
|
||||
RDCERR("Entry point %s not found in module", entryPoint.c_str());
|
||||
RDCERR("Entry point %s for stage %s not found in module", entryPoint.c_str(),
|
||||
ToStr(stage).c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,8 +84,7 @@ public:
|
||||
|
||||
rdcstr Disassemble(const rdcstr &entryPoint, std::map<size_t, uint32_t> &instructionLines) const;
|
||||
|
||||
rdcarray<rdcstr> EntryPoints() const;
|
||||
ShaderStage StageForEntry(const rdcstr &entryPoint) const;
|
||||
rdcarray<ShaderEntryPoint> EntryPoints() const;
|
||||
|
||||
void MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage stage, const rdcstr &entryPoint,
|
||||
const rdcarray<SpecConstant> &specInfo, ShaderReflection &reflection,
|
||||
|
||||
@@ -44,7 +44,7 @@ struct feedbackData
|
||||
uint32_t numEntries;
|
||||
};
|
||||
|
||||
void AnnotateShader(const SPIRVPatchData &patchData, const char *entryName,
|
||||
void AnnotateShader(const SPIRVPatchData &patchData, ShaderStage stage, const char *entryName,
|
||||
const std::map<rdcspv::Binding, feedbackData> &offsetMap, uint32_t maxSlot,
|
||||
VkDeviceAddress addr, bool bufferAddressKHR, rdcarray<uint32_t> &modSpirv)
|
||||
{
|
||||
@@ -227,7 +227,7 @@ void AnnotateShader(const SPIRVPatchData &patchData, const char *entryName,
|
||||
rdcspv::Id entryID;
|
||||
for(const rdcspv::EntryPoint &entry : editor.GetEntries())
|
||||
{
|
||||
if(entry.name == entryName)
|
||||
if(entry.name == entryName && MakeShaderStage(entry.executionModel) == stage)
|
||||
{
|
||||
entryID = entry.id;
|
||||
break;
|
||||
@@ -769,8 +769,8 @@ void VulkanReplay::FetchShaderFeedback(uint32_t eventId)
|
||||
if(!Vulkan_Debug_FeedbackDumpDirPath().empty())
|
||||
FileIO::WriteAll(Vulkan_Debug_FeedbackDumpDirPath() + "/before_" + filename[5], modSpirv);
|
||||
|
||||
AnnotateShader(*pipeInfo.shaders[5].patchData, stage.pName, offsetMap, maxSlot, bufferAddress,
|
||||
useBufferAddressKHR, modSpirv);
|
||||
AnnotateShader(*pipeInfo.shaders[5].patchData, ShaderStage(StageIndex(stage.stage)),
|
||||
stage.pName, offsetMap, maxSlot, bufferAddress, useBufferAddressKHR, modSpirv);
|
||||
|
||||
if(!Vulkan_Debug_FeedbackDumpDirPath().empty())
|
||||
FileIO::WriteAll(Vulkan_Debug_FeedbackDumpDirPath() + "/after_" + filename[5], modSpirv);
|
||||
@@ -800,8 +800,8 @@ void VulkanReplay::FetchShaderFeedback(uint32_t eventId)
|
||||
if(!Vulkan_Debug_FeedbackDumpDirPath().empty())
|
||||
FileIO::WriteAll(Vulkan_Debug_FeedbackDumpDirPath() + "/before_" + filename[idx], modSpirv);
|
||||
|
||||
AnnotateShader(*pipeInfo.shaders[idx].patchData, stage.pName, offsetMap, maxSlot,
|
||||
bufferAddress, useBufferAddressKHR, modSpirv);
|
||||
AnnotateShader(*pipeInfo.shaders[idx].patchData, ShaderStage(StageIndex(stage.stage)),
|
||||
stage.pName, offsetMap, maxSlot, bufferAddress, useBufferAddressKHR, modSpirv);
|
||||
|
||||
if(!Vulkan_Debug_FeedbackDumpDirPath().empty())
|
||||
FileIO::WriteAll(Vulkan_Debug_FeedbackDumpDirPath() + "/after_" + filename[idx], modSpirv);
|
||||
|
||||
@@ -373,6 +373,7 @@ void VulkanCreationInfo::Pipeline::Init(VulkanResourceManager *resourceMan,
|
||||
|
||||
shad.module = shadid;
|
||||
shad.entryPoint = pCreateInfo->pStages[i].pName;
|
||||
shad.stage = ShaderStage(stageIndex);
|
||||
|
||||
ShaderModuleReflectionKey key(shad.entryPoint, ResourceId());
|
||||
|
||||
|
||||
@@ -249,6 +249,7 @@ struct VulkanCreationInfo
|
||||
{
|
||||
Shader() : refl(NULL), mapping(NULL), patchData(NULL) {}
|
||||
ResourceId module;
|
||||
ShaderStage stage;
|
||||
rdcstr entryPoint;
|
||||
ShaderReflection *refl;
|
||||
ShaderBindpointMapping *mapping;
|
||||
|
||||
@@ -284,7 +284,8 @@ struct PixelHistoryShaderCache
|
||||
// Returns a shader that is equivalent to the given shader, but attempts to remove
|
||||
// side effects of shader execution for the given entry point (for ex., writes
|
||||
// to storage buffers/images).
|
||||
VkShaderModule GetShaderWithoutSideEffects(ResourceId shaderId, const rdcstr &entryPoint)
|
||||
VkShaderModule GetShaderWithoutSideEffects(ResourceId shaderId, const rdcstr &entryPoint,
|
||||
ShaderStage stage)
|
||||
{
|
||||
ShaderKey shaderKey = make_rdcpair(shaderId, entryPoint);
|
||||
auto it = m_ShaderReplacements.find(shaderKey);
|
||||
@@ -292,13 +293,14 @@ struct PixelHistoryShaderCache
|
||||
if(it != m_ShaderReplacements.end())
|
||||
return it->second;
|
||||
|
||||
VkShaderModule shaderModule = CreateShaderReplacement(shaderId, entryPoint);
|
||||
VkShaderModule shaderModule = CreateShaderReplacement(shaderId, entryPoint, stage);
|
||||
m_ShaderReplacements.insert(std::make_pair(shaderKey, shaderModule));
|
||||
return shaderModule;
|
||||
}
|
||||
|
||||
private:
|
||||
VkShaderModule CreateShaderReplacement(ResourceId shaderId, const rdcstr &entryName)
|
||||
VkShaderModule CreateShaderReplacement(ResourceId shaderId, const rdcstr &entryName,
|
||||
ShaderStage stage)
|
||||
{
|
||||
const VulkanCreationInfo::ShaderModule &moduleInfo =
|
||||
m_pDriver->GetDebugManager()->GetShaderInfo(shaderId);
|
||||
@@ -308,7 +310,7 @@ private:
|
||||
|
||||
for(const rdcspv::EntryPoint &entry : editor.GetEntries())
|
||||
{
|
||||
if(entry.name == entryName)
|
||||
if(entry.name == entryName && MakeShaderStage(entry.executionModel) == stage)
|
||||
{
|
||||
// In some cases a shader might just be binding a RW resource but not writing to it.
|
||||
// If there are no writes (shader was not modified), no need to replace the shader,
|
||||
@@ -595,8 +597,8 @@ protected:
|
||||
for(size_t i = 0; i < numberOfStages; i++)
|
||||
{
|
||||
if((eventFlags & PipeStageRWEventFlags(StageFromIndex(i))) != EventFlags::NoFlags)
|
||||
replacementShaders[i] =
|
||||
m_ShaderCache->GetShaderWithoutSideEffects(p.shaders[i].module, p.shaders[i].entryPoint);
|
||||
replacementShaders[i] = m_ShaderCache->GetShaderWithoutSideEffects(
|
||||
p.shaders[i].module, p.shaders[i].entryPoint, p.shaders[i].stage);
|
||||
}
|
||||
for(uint32_t i = 0; i < pipeCreateInfo.stageCount; i++)
|
||||
{
|
||||
@@ -1930,8 +1932,8 @@ private:
|
||||
ShaderStage stage = StageFromIndex(i);
|
||||
bool rwInStage = (eventShaderFlags & PipeStageRWEventFlags(stage)) != EventFlags::NoFlags;
|
||||
if(rwInStage || (stage == ShaderStage::Fragment))
|
||||
replacementShaders[i] =
|
||||
m_ShaderCache->GetShaderWithoutSideEffects(p.shaders[i].module, p.shaders[i].entryPoint);
|
||||
replacementShaders[i] = m_ShaderCache->GetShaderWithoutSideEffects(
|
||||
p.shaders[i].module, p.shaders[i].entryPoint, p.shaders[i].stage);
|
||||
}
|
||||
|
||||
VulkanRenderState &pipestate = m_pDriver->GetCmdRenderState();
|
||||
@@ -2506,8 +2508,8 @@ struct VulkanPixelHistoryPerFragmentCallback : VulkanPixelHistoryCallback
|
||||
for(size_t i = 0; i < numberOfStages; i++)
|
||||
{
|
||||
if((eventFlags & PipeStageRWEventFlags(StageFromIndex(i))) != EventFlags::NoFlags)
|
||||
replacementShaders[i] =
|
||||
m_ShaderCache->GetShaderWithoutSideEffects(p.shaders[i].module, p.shaders[i].entryPoint);
|
||||
replacementShaders[i] = m_ShaderCache->GetShaderWithoutSideEffects(
|
||||
p.shaders[i].module, p.shaders[i].entryPoint, p.shaders[i].stage);
|
||||
}
|
||||
for(uint32_t i = 0; i < pipeCreateInfo.stageCount; i++)
|
||||
{
|
||||
|
||||
@@ -450,7 +450,7 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV
|
||||
|
||||
for(const rdcspv::EntryPoint &entry : editor.GetEntries())
|
||||
{
|
||||
if(entry.name == entryName)
|
||||
if(entry.name == entryName && entry.executionModel == rdcspv::ExecutionModel::Vertex)
|
||||
entryID = entry.id;
|
||||
|
||||
entries.insert(entry.id);
|
||||
|
||||
@@ -416,14 +416,7 @@ rdcarray<ShaderEntryPoint> VulkanReplay::GetShaderEntryPoints(ResourceId shader)
|
||||
if(shad == m_pDriver->m_CreationInfo.m_ShaderModule.end())
|
||||
return {};
|
||||
|
||||
rdcarray<rdcstr> entries = shad->second.spirv.EntryPoints();
|
||||
|
||||
rdcarray<ShaderEntryPoint> ret;
|
||||
|
||||
for(const rdcstr &e : entries)
|
||||
ret.push_back({e, shad->second.spirv.StageForEntry(e)});
|
||||
|
||||
return ret;
|
||||
return shad->second.spirv.EntryPoints();
|
||||
}
|
||||
|
||||
ShaderReflection *VulkanReplay::GetShader(ResourceId pipeline, ResourceId shader,
|
||||
@@ -4024,11 +4017,11 @@ void VulkanReplay::RefreshDerivedReplacements()
|
||||
|
||||
if(rm->HasReplacement(shadOrigId))
|
||||
{
|
||||
rdcarray<rdcstr> entries =
|
||||
rdcarray<ShaderEntryPoint> entries =
|
||||
m_pDriver->m_CreationInfo.m_ShaderModule[GetResID(sh.module)].spirv.EntryPoints();
|
||||
if(entries.size() > 1)
|
||||
{
|
||||
if(entries.contains(sh.pName))
|
||||
if(entries.contains({sh.pName, ShaderStage(StageIndex(sh.stage))}))
|
||||
{
|
||||
// nothing to do!
|
||||
}
|
||||
@@ -4037,14 +4030,14 @@ void VulkanReplay::RefreshDerivedReplacements()
|
||||
RDCWARN(
|
||||
"Multiple entry points in edited shader, none matching original, using first "
|
||||
"one '%s'",
|
||||
entries[0].c_str());
|
||||
entrynames.push_back(entries[0]);
|
||||
entries[0].name.c_str());
|
||||
entrynames.push_back(entries[0].name);
|
||||
sh.pName = entrynames.back().c_str();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entrynames.push_back(entries[0]);
|
||||
entrynames.push_back(entries[0].name);
|
||||
sh.pName = entrynames.back().c_str();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2922,7 +2922,7 @@ static void CreatePSInputFetcher(rdcarray<uint32_t> &fragspv, uint32_t &structSt
|
||||
rdcspv::Id entryID;
|
||||
for(const rdcspv::EntryPoint &e : editor.GetEntries())
|
||||
{
|
||||
if(e.name == shadRefl.entryPoint)
|
||||
if(e.name == shadRefl.entryPoint && e.executionModel == rdcspv::ExecutionModel::Fragment)
|
||||
{
|
||||
entryID = e.id;
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user