Put async PSO debug printing behind a macro.

This commit is contained in:
Skyth 2024-11-26 20:06:47 +03:00
parent 172bc6683e
commit f356aa665a

View file

@ -36,6 +36,8 @@
#include "shader/resolve_msaa_depth_8x.hlsl.dxil.h" #include "shader/resolve_msaa_depth_8x.hlsl.dxil.h"
#include "shader/resolve_msaa_depth_8x.hlsl.spirv.h" #include "shader/resolve_msaa_depth_8x.hlsl.spirv.h"
//#define ASYNC_PSO_DEBUG
extern "C" extern "C"
{ {
__declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001; __declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
@ -235,9 +237,11 @@ static TextureDescriptorAllocator g_textureDescriptorAllocator;
static std::unique_ptr<RenderPipelineLayout> g_pipelineLayout; static std::unique_ptr<RenderPipelineLayout> g_pipelineLayout;
static xxHashMap<std::unique_ptr<RenderPipeline>> g_pipelines; static xxHashMap<std::unique_ptr<RenderPipeline>> g_pipelines;
#ifdef ASYNC_PSO_DEBUG
static std::atomic<uint32_t> g_pipelinesCreatedInRenderThread; static std::atomic<uint32_t> g_pipelinesCreatedInRenderThread;
static std::atomic<uint32_t> g_pipelinesCreatedAsynchronously; static std::atomic<uint32_t> g_pipelinesCreatedAsynchronously;
static std::atomic<uint32_t> g_pipelinesDropped; static std::atomic<uint32_t> g_pipelinesDropped;
#endif
static std::atomic<uint32_t> g_compilingModelCount; static std::atomic<uint32_t> g_compilingModelCount;
static std::atomic<uint32_t> g_pendingModelCount; static std::atomic<uint32_t> g_pendingModelCount;
@ -1670,6 +1674,7 @@ static void DrawImGui()
ImGui_ImplSDL2_NewFrame(); ImGui_ImplSDL2_NewFrame();
ImGui::NewFrame(); ImGui::NewFrame();
#ifdef ASYNC_PSO_DEBUG
if (ImGui::Begin("Async PSO Stats")) if (ImGui::Begin("Async PSO Stats"))
{ {
ImGui::Text("Pipelines Created In Render Thread: %d", g_pipelinesCreatedInRenderThread.load()); ImGui::Text("Pipelines Created In Render Thread: %d", g_pipelinesCreatedInRenderThread.load());
@ -1679,6 +1684,7 @@ static void DrawImGui()
ImGui::Text("Pending Model Count: %d", g_pendingModelCount.load()); ImGui::Text("Pending Model Count: %d", g_pendingModelCount.load());
} }
ImGui::End(); ImGui::End();
#endif
ImGui::Render(); ImGui::Render();
@ -2729,10 +2735,12 @@ static RenderPipeline* CreateGraphicsPipelineInRenderThread(PipelineState pipeli
{ {
pipeline = CreateGraphicsPipeline(pipelineState); pipeline = CreateGraphicsPipeline(pipelineState);
#ifdef ASYNC_PSO_DEBUG
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)); pipeline->setName(std::format("Render Thread Pipeline {:X}", hash));
#endif
} }
return pipeline.get(); return pipeline.get();
@ -2934,11 +2942,15 @@ static void ProcAddPipeline(const RenderCommand& cmd)
if (pipeline == nullptr) if (pipeline == nullptr)
{ {
pipeline = std::unique_ptr<RenderPipeline>(args.pipeline); pipeline = std::unique_ptr<RenderPipeline>(args.pipeline);
#ifdef ASYNC_PSO_DEBUG
++g_pipelinesCreatedAsynchronously; ++g_pipelinesCreatedAsynchronously;
#endif
} }
else else
{ {
#ifdef ASYNC_PSO_DEBUG
++g_pipelinesDropped; ++g_pipelinesDropped;
#endif
delete args.pipeline; delete args.pipeline;
} }
} }