Set pipeline names.

This commit is contained in:
Skyth 2024-11-26 16:11:17 +03:00
parent d3536955e0
commit f50d9d85a5
6 changed files with 43 additions and 6 deletions

View file

@ -2672,6 +2672,10 @@ namespace RT64 {
} }
} }
void D3D12ComputePipeline::setName(const std::string& name) const {
setObjectName(d3d, name);
}
RenderPipelineProgram D3D12ComputePipeline::getProgram(const std::string &name) const { RenderPipelineProgram D3D12ComputePipeline::getProgram(const std::string &name) const {
assert(false && "Compute pipelines can't retrieve shader programs."); assert(false && "Compute pipelines can't retrieve shader programs.");
return RenderPipelineProgram(); return RenderPipelineProgram();
@ -2791,6 +2795,10 @@ namespace RT64 {
} }
} }
void D3D12GraphicsPipeline::setName(const std::string& name) const {
setObjectName(d3d, name);
}
RenderPipelineProgram D3D12GraphicsPipeline::getProgram(const std::string &name) const { RenderPipelineProgram D3D12GraphicsPipeline::getProgram(const std::string &name) const {
assert(false && "Graphics pipelines can't retrieve shader programs."); assert(false && "Graphics pipelines can't retrieve shader programs.");
return RenderPipelineProgram(); return RenderPipelineProgram();
@ -3011,6 +3019,10 @@ namespace RT64 {
} }
} }
void D3D12RaytracingPipeline::setName(const std::string& name) const {
setObjectName(stateObject, name);
}
RenderPipelineProgram D3D12RaytracingPipeline::getProgram(const std::string &name) const { RenderPipelineProgram D3D12RaytracingPipeline::getProgram(const std::string &name) const {
auto it = nameProgramMap.find(name); auto it = nameProgramMap.find(name);
assert((it != nameProgramMap.end()) && "Program must exist in the PSO."); assert((it != nameProgramMap.end()) && "Program must exist in the PSO.");

View file

@ -355,6 +355,7 @@ namespace RT64 {
D3D12ComputePipeline(D3D12Device *device, const RenderComputePipelineDesc &desc); D3D12ComputePipeline(D3D12Device *device, const RenderComputePipelineDesc &desc);
~D3D12ComputePipeline() override; ~D3D12ComputePipeline() override;
virtual void setName(const std::string& name) const override;
virtual RenderPipelineProgram getProgram(const std::string &name) const override; virtual RenderPipelineProgram getProgram(const std::string &name) const override;
}; };
@ -365,6 +366,7 @@ namespace RT64 {
D3D12GraphicsPipeline(D3D12Device *device, const RenderGraphicsPipelineDesc &desc); D3D12GraphicsPipeline(D3D12Device *device, const RenderGraphicsPipelineDesc &desc);
~D3D12GraphicsPipeline() override; ~D3D12GraphicsPipeline() override;
virtual void setName(const std::string& name) const override;
virtual RenderPipelineProgram getProgram(const std::string &name) const override; virtual RenderPipelineProgram getProgram(const std::string &name) const override;
}; };
@ -377,6 +379,7 @@ namespace RT64 {
D3D12RaytracingPipeline(D3D12Device *device, const RenderRaytracingPipelineDesc &desc, const RenderPipeline *previousPipeline); D3D12RaytracingPipeline(D3D12Device *device, const RenderRaytracingPipelineDesc &desc, const RenderPipeline *previousPipeline);
~D3D12RaytracingPipeline() override; ~D3D12RaytracingPipeline() override;
virtual void setName(const std::string& name) const override;
virtual RenderPipelineProgram getProgram(const std::string &name) const override; virtual RenderPipelineProgram getProgram(const std::string &name) const override;
}; };

View file

@ -53,6 +53,7 @@ namespace RT64 {
struct RenderPipeline { struct RenderPipeline {
virtual ~RenderPipeline() { } virtual ~RenderPipeline() { }
virtual void setName(const std::string& name) const = 0;
virtual RenderPipelineProgram getProgram(const std::string &name) const = 0; virtual RenderPipelineProgram getProgram(const std::string &name) const = 0;
}; };

View file

@ -1316,6 +1316,10 @@ namespace RT64 {
} }
} }
void VulkanComputePipeline::setName(const std::string& name) const {
setObjectName(device->vk, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, uint64_t(vk), name);
}
RenderPipelineProgram VulkanComputePipeline::getProgram(const std::string &name) const { RenderPipelineProgram VulkanComputePipeline::getProgram(const std::string &name) const {
assert(false && "Compute pipelines can't retrieve shader programs."); assert(false && "Compute pipelines can't retrieve shader programs.");
return RenderPipelineProgram(); return RenderPipelineProgram();
@ -1552,6 +1556,10 @@ namespace RT64 {
} }
} }
void VulkanGraphicsPipeline::setName(const std::string& name) const {
setObjectName(device->vk, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, uint64_t(vk), name);
}
RenderPipelineProgram VulkanGraphicsPipeline::getProgram(const std::string &name) const { RenderPipelineProgram VulkanGraphicsPipeline::getProgram(const std::string &name) const {
assert(false && "Graphics pipelines can't retrieve shader programs."); assert(false && "Graphics pipelines can't retrieve shader programs.");
return RenderPipelineProgram(); return RenderPipelineProgram();
@ -1752,6 +1760,10 @@ namespace RT64 {
} }
} }
void VulkanRaytracingPipeline::setName(const std::string& name) const {
setObjectName(device->vk, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, uint64_t(vk), name);
}
RenderPipelineProgram VulkanRaytracingPipeline::getProgram(const std::string &name) const { RenderPipelineProgram VulkanRaytracingPipeline::getProgram(const std::string &name) const {
auto it = nameProgramMap.find(name); auto it = nameProgramMap.find(name);
assert((it != nameProgramMap.end()) && "Program must exist in the PSO."); assert((it != nameProgramMap.end()) && "Program must exist in the PSO.");

View file

@ -158,6 +158,7 @@ namespace RT64 {
VulkanComputePipeline(VulkanDevice *device, const RenderComputePipelineDesc &desc); VulkanComputePipeline(VulkanDevice *device, const RenderComputePipelineDesc &desc);
~VulkanComputePipeline() override; ~VulkanComputePipeline() override;
void setName(const std::string& name) const override;
RenderPipelineProgram getProgram(const std::string &name) const override; RenderPipelineProgram getProgram(const std::string &name) const override;
}; };
@ -167,6 +168,7 @@ namespace RT64 {
VulkanGraphicsPipeline(VulkanDevice *device, const RenderGraphicsPipelineDesc &desc); VulkanGraphicsPipeline(VulkanDevice *device, const RenderGraphicsPipelineDesc &desc);
~VulkanGraphicsPipeline() override; ~VulkanGraphicsPipeline() override;
void setName(const std::string& name) const override;
RenderPipelineProgram getProgram(const std::string &name) const override; RenderPipelineProgram getProgram(const std::string &name) const override;
static VkRenderPass createRenderPass(VulkanDevice *device, const VkFormat *renderTargetFormat, uint32_t renderTargetCount, VkFormat depthTargetFormat, VkSampleCountFlagBits sampleCount); static VkRenderPass createRenderPass(VulkanDevice *device, const VkFormat *renderTargetFormat, uint32_t renderTargetCount, VkFormat depthTargetFormat, VkSampleCountFlagBits sampleCount);
}; };
@ -179,6 +181,7 @@ namespace RT64 {
VulkanRaytracingPipeline(VulkanDevice *device, const RenderRaytracingPipelineDesc &desc, const RenderPipeline *previousPipeline); VulkanRaytracingPipeline(VulkanDevice *device, const RenderRaytracingPipelineDesc &desc, const RenderPipeline *previousPipeline);
~VulkanRaytracingPipeline() override; ~VulkanRaytracingPipeline() override;
void setName(const std::string& name) const override;
RenderPipelineProgram getProgram(const std::string &name) const override; RenderPipelineProgram getProgram(const std::string &name) const override;
}; };

View file

@ -2699,12 +2699,16 @@ static RenderPipeline* CreateGraphicsPipelineInRenderThread(PipelineState pipeli
{ {
SanitizePipelineState(pipelineState); SanitizePipelineState(pipelineState);
auto& pipeline = g_pipelines[XXH3_64bits(&pipelineState, sizeof(pipelineState))]; XXH64_hash_t hash = XXH3_64bits(&pipelineState, sizeof(pipelineState));
auto& pipeline = g_pipelines[hash];
if (pipeline == nullptr) if (pipeline == nullptr)
{ {
pipeline = CreateGraphicsPipeline(pipelineState); pipeline = CreateGraphicsPipeline(pipelineState);
if (pipelineState.zEnable) // Should ignore most post effect/2D shaders. if (pipelineState.zEnable) // Should ignore most post effect/2D shaders.
++g_pipelinesCreatedInRenderThread; ++g_pipelinesCreatedInRenderThread;
pipeline->setName(std::format("Render Thread Pipeline {:X}", hash));
} }
return pipeline.get(); return pipeline.get();
@ -4247,7 +4251,7 @@ static std::atomic<uint32_t> g_pendingModelCount;
static ankerl::unordered_dense::set<XXH64_hash_t> g_asyncPipelines; static ankerl::unordered_dense::set<XXH64_hash_t> g_asyncPipelines;
static Mutex g_asyncPipelineMutex; static Mutex g_asyncPipelineMutex;
static void CompileGraphicsPipelineInPipelineThread(const PipelineState& pipelineState) static void CreateGraphicsPipelineInPipelineThread(const PipelineState& pipelineState)
{ {
XXH64_hash_t hash = XXH3_64bits(&pipelineState, sizeof(pipelineState)); XXH64_hash_t hash = XXH3_64bits(&pipelineState, sizeof(pipelineState));
@ -4262,6 +4266,8 @@ static void CompileGraphicsPipelineInPipelineThread(const PipelineState& pipelin
auto pipeline = CreateGraphicsPipeline(pipelineState); auto pipeline = CreateGraphicsPipeline(pipelineState);
++g_pipelinesCreatedAsynchronously; ++g_pipelinesCreatedAsynchronously;
pipeline->setName(std::format("Async Pipeline {:X}", hash));
{ {
std::lock_guard lock(g_asyncPipelineMutex); std::lock_guard lock(g_asyncPipelineMutex);
g_asyncPipelines.emplace(hash); g_asyncPipelines.emplace(hash);
@ -4319,7 +4325,7 @@ static void CompileMeshPipeline(Hedgehog::Mirage::CMeshData* mesh, bool isTransp
pipelineState.specConstants |= SPEC_CONSTANT_ALPHA_TEST; pipelineState.specConstants |= SPEC_CONSTANT_ALPHA_TEST;
SanitizePipelineState(pipelineState); SanitizePipelineState(pipelineState);
CompileGraphicsPipelineInPipelineThread(pipelineState); CreateGraphicsPipelineInPipelineThread(pipelineState);
} }
guest_stack_var<Hedgehog::Base::CStringSymbol> defaultSymbol(reinterpret_cast<const char*>(g_memory.Translate(0x8202DDBC))); guest_stack_var<Hedgehog::Base::CStringSymbol> defaultSymbol(reinterpret_cast<const char*>(g_memory.Translate(0x8202DDBC)));
@ -4334,12 +4340,12 @@ static void CompileMeshPipeline(Hedgehog::Mirage::CMeshData* mesh, bool isTransp
for (auto& [pixelShaderSubPermutations, pixelShader] : defaultFindResult->second.m_PixelShaders) for (auto& [pixelShaderSubPermutations, pixelShader] : defaultFindResult->second.m_PixelShaders)
{ {
if ((pixelShaderSubPermutations & 0x2) != (args.noGI ? 0x2 : 0x0)) if (pixelShader.get() == nullptr || (pixelShaderSubPermutations & 0x2) != (args.noGI ? 0x2 : 0x0))
continue; continue;
for (auto& [vertexShaderSubPermutations, vertexShader] : noneFindResult->second->m_VertexShaders) for (auto& [vertexShaderSubPermutations, vertexShader] : noneFindResult->second->m_VertexShaders)
{ {
if (vertexShader.get() == nullptr || pixelShader.get() == nullptr) if (vertexShader.get() == nullptr)
continue; continue;
PipelineState pipelineState{}; PipelineState pipelineState{};
@ -4385,7 +4391,7 @@ static void CompileMeshPipeline(Hedgehog::Mirage::CMeshData* mesh, bool isTransp
pipelineState.specConstants |= SPEC_CONSTANT_REVERSE_Z; pipelineState.specConstants |= SPEC_CONSTANT_REVERSE_Z;
SanitizePipelineState(pipelineState); SanitizePipelineState(pipelineState);
CompileGraphicsPipelineInPipelineThread(pipelineState); CreateGraphicsPipelineInPipelineThread(pipelineState);
} }
} }
} }