From d001a7b5eee4400150816e9962adaff183bfff35 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 19 Oct 2023 03:49:42 -0700 Subject: Add a tool to dump/replay compute pipeline creation from gfx. (#3275) * Add a tool to dump/replay compute pipeline creation from gfx. * Fix x86 build. --------- Co-authored-by: Yong He --- tools/gfx/vulkan/vk-device.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tools/gfx/vulkan/vk-device.cpp') diff --git a/tools/gfx/vulkan/vk-device.cpp b/tools/gfx/vulkan/vk-device.cpp index f8bc9c3aa..fe3680eda 100644 --- a/tools/gfx/vulkan/vk-device.cpp +++ b/tools/gfx/vulkan/vk-device.cpp @@ -15,9 +15,12 @@ #include "vk-swap-chain.h" #include "vk-transient-heap.h" #include "vk-vertex-layout.h" +#include "vk-pipeline-dump-layer.h" #include "vk-helper-functions.h" +#include "source/core/slang-platform.h" + #ifdef GFX_NV_AFTERMATH # include "GFSDK_Aftermath.h" # include "GFSDK_Aftermath_Defines.h" @@ -32,8 +35,20 @@ using namespace Slang; namespace vk { +static bool shouldDumpPipeline() +{ + StringBuilder dumpPipelineSettings; + PlatformUtil::getEnvironmentVariable(toSlice("SLANG_GFX_DUMP_PIPELINE"), dumpPipelineSettings); + return dumpPipelineSettings.produceString() == "1"; +} + DeviceImpl::~DeviceImpl() { + if (shouldDumpPipeline()) + { + writePipelineDump(toSlice("gfx-vk-pipeline-dump.bin")); + } + // Check the device queue is valid else, we can't wait on it.. if (m_deviceQueue.isValid()) { @@ -782,6 +797,10 @@ Result DeviceImpl::initVulkanInstanceAndDevice( SLANG_RETURN_ON_FAIL(m_api.initDeviceProcs(m_device)); + if (shouldDumpPipeline()) + { + installPipelineDumpLayer(m_api); + } return SLANG_OK; } -- cgit v1.2.3