1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-20 10:54:16 +01:00

[d3d11] Replace D3D11ShaderKey with DxvkShaderKey

This commit is contained in:
Philip Rebohle 2018-09-18 10:17:32 +02:00
parent 0843e2211c
commit a078bb947e
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 6 additions and 76 deletions

View File

@ -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<const uint8_t*>(pShaderBytecode),
BytecodeLength)) { }
std::string D3D11ShaderKey::GetName() const {
static const std::array<const char*, 6> 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<std::mutex> lock(m_mutex);

View File

@ -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;
};