From 4469ef1ec1a05adc7bd898d4b415a2fb29e463ca Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 18 Sep 2018 10:21:18 +0200 Subject: [PATCH] [d3d11] Replace shader debug name with shader key --- src/d3d11/d3d11_shader.cpp | 14 +++++++------- src/d3d11/d3d11_shader.h | 3 +-- src/dxvk/dxvk_shader.h | 23 ++++++++++++++--------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/d3d11/d3d11_shader.cpp b/src/d3d11/d3d11_shader.cpp index 069aa90e5..e42e1fce8 100644 --- a/src/d3d11/d3d11_shader.cpp +++ b/src/d3d11/d3d11_shader.cpp @@ -12,9 +12,9 @@ namespace dxvk { const DxvkShaderKey* pShaderKey, const DxbcModuleInfo* pDxbcModuleInfo, const void* pShaderBytecode, - size_t BytecodeLength) - : m_name(pShaderKey->toString()) { - Logger::debug(str::format("Compiling shader ", m_name)); + size_t BytecodeLength) { + const std::string name = pShaderKey->toString(); + Logger::debug(str::format("Compiling shader ", name)); DxbcReader reader( reinterpret_cast(pShaderBytecode), @@ -27,16 +27,16 @@ namespace dxvk { const std::string dumpPath = env::getEnvVar(L"DXVK_SHADER_DUMP_PATH"); if (dumpPath.size() != 0) { - reader.store(std::ofstream(str::format(dumpPath, "/", m_name, ".dxbc"), + reader.store(std::ofstream(str::format(dumpPath, "/", name, ".dxbc"), std::ios_base::binary | std::ios_base::trunc)); } - m_shader = module.compile(*pDxbcModuleInfo, m_name); - m_shader->setDebugName(m_name); + m_shader = module.compile(*pDxbcModuleInfo, name); + m_shader->setShaderKey(*pShaderKey); if (dumpPath.size() != 0) { std::ofstream dumpStream( - str::format(dumpPath, "/", m_name, ".spv"), + str::format(dumpPath, "/", name, ".spv"), std::ios_base::binary | std::ios_base::trunc); m_shader->dump(dumpStream); diff --git a/src/d3d11/d3d11_shader.h b/src/d3d11/d3d11_shader.h index d7ab9101c..75f8c5feb 100644 --- a/src/d3d11/d3d11_shader.h +++ b/src/d3d11/d3d11_shader.h @@ -48,12 +48,11 @@ namespace dxvk { } std::string GetName() const { - return m_name; + return m_shader->debugName(); } private: - std::string m_name; Rc m_shader; Rc m_buffer; diff --git a/src/dxvk/dxvk_shader.h b/src/dxvk/dxvk_shader.h index d05f9e759..ddf596dc1 100644 --- a/src/dxvk/dxvk_shader.h +++ b/src/dxvk/dxvk_shader.h @@ -237,14 +237,19 @@ namespace dxvk { void dump(std::ostream& outputStream) const; /** - * \brief Sets the shader's debug name - * - * Debug names may be used by the backend in - * order to help debug shader compiler issues. - * \param [in] name The shader's name + * \brief Sets the shader key + * \param [in] key Unique key */ - void setDebugName(const std::string& name) { - m_debugName = name; + void setShaderKey(const DxvkShaderKey& key) { + m_key = key; + } + + /** + * \brief Retrieves shader key + * \returns The unique shader key + */ + DxvkShaderKey getShaderKey() const { + return m_key; } /** @@ -252,7 +257,7 @@ namespace dxvk { * \returns The shader's name */ std::string debugName() const { - return m_debugName; + return m_key.toString(); } private: @@ -264,7 +269,7 @@ namespace dxvk { std::vector m_idOffsets; DxvkInterfaceSlots m_interface; DxvkShaderConstData m_constData; - std::string m_debugName; + DxvkShaderKey m_key; };