From a078bb947e862d4c85c729c135eb9b39dd9dd94c Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 18 Sep 2018 10:17:32 +0200 Subject: [PATCH] [d3d11] Replace D3D11ShaderKey with DxvkShaderKey --- src/d3d11/d3d11_shader.cpp | 37 +++---------------------------- src/d3d11/d3d11_shader.h | 45 +++----------------------------------- 2 files changed, 6 insertions(+), 76 deletions(-) diff --git a/src/d3d11/d3d11_shader.cpp b/src/d3d11/d3d11_shader.cpp index 09f66c48c..069aa90e5 100644 --- a/src/d3d11/d3d11_shader.cpp +++ b/src/d3d11/d3d11_shader.cpp @@ -3,48 +3,17 @@ namespace dxvk { - D3D11ShaderKey::D3D11ShaderKey( - DxbcProgramType ProgramType, - const void* pShaderBytecode, - size_t BytecodeLength) - : m_type(ProgramType), - m_hash(Sha1Hash::compute( - reinterpret_cast(pShaderBytecode), - BytecodeLength)) { } - - - std::string D3D11ShaderKey::GetName() const { - static const std::array s_prefix - = {{ "PS_", "VS_", "GS_", "HS_", "DS_", "CS_" }}; - - return str::format( - s_prefix.at(uint32_t(m_type)), - m_hash.toString()); - } - - - size_t D3D11ShaderKey::GetHash() const { - DxvkHashState result; - result.add(uint32_t(m_type)); - - for (uint32_t i = 0; i < 5; i++) - result.add(m_hash.dword(i)); - - return result; - } - - D3D11CommonShader:: D3D11CommonShader() { } D3D11CommonShader::~D3D11CommonShader() { } D3D11CommonShader::D3D11CommonShader( D3D11Device* pDevice, - const D3D11ShaderKey* pShaderKey, + const DxvkShaderKey* pShaderKey, const DxbcModuleInfo* pDxbcModuleInfo, const void* pShaderBytecode, size_t BytecodeLength) - : m_name(pShaderKey->GetName()) { + : m_name(pShaderKey->toString()) { Logger::debug(str::format("Compiling shader ", m_name)); DxbcReader reader( @@ -108,7 +77,7 @@ namespace dxvk { size_t BytecodeLength, DxbcProgramType ProgramType) { // Compute the shader's unique key so that we can perform a lookup - D3D11ShaderKey key(ProgramType, pShaderBytecode, BytecodeLength); + DxvkShaderKey key(GetShaderStage(ProgramType), pShaderBytecode, BytecodeLength); { std::unique_lock lock(m_mutex); diff --git a/src/d3d11/d3d11_shader.h b/src/d3d11/d3d11_shader.h index b6c42d68b..d7ab9101c 100644 --- a/src/d3d11/d3d11_shader.h +++ b/src/d3d11/d3d11_shader.h @@ -19,45 +19,6 @@ namespace dxvk { class D3D11Device; - /** - * \brief Shader key - * - * A unique identifier for a shader consisting - * of the program type and the SHA-1 hash of - * the shader's original bytecode. - */ - class D3D11ShaderKey { - - public: - - D3D11ShaderKey( - DxbcProgramType ProgramType, - const void* pShaderBytecode, - size_t BytecodeLength); - - std::string GetName() const; - - size_t GetHash() const; - - bool operator == (const D3D11ShaderKey& other) const { - return m_type == other.m_type - && m_hash == other.m_hash; - } - - private: - - DxbcProgramType m_type; - Sha1Hash m_hash; - - }; - - struct D3D11ShaderKeyHash { - size_t operator () (const D3D11ShaderKey& a) const { - return a.GetHash(); - } - }; - - /** * \brief Common shader object * @@ -72,7 +33,7 @@ namespace dxvk { D3D11CommonShader(); D3D11CommonShader( D3D11Device* pDevice, - const D3D11ShaderKey* pShaderKey, + const DxvkShaderKey* pShaderKey, const DxbcModuleInfo* pDxbcModuleInfo, const void* pShaderBytecode, size_t BytecodeLength); @@ -192,9 +153,9 @@ namespace dxvk { std::mutex m_mutex; std::unordered_map< - D3D11ShaderKey, + DxvkShaderKey, D3D11CommonShader, - D3D11ShaderKeyHash> m_modules; + DxvkHash, DxvkEq> m_modules; };