1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-14 18:23:52 +01:00
dxvk/src/d3d11/d3d11_shader.h

97 lines
2.0 KiB
C
Raw Normal View History

2017-12-06 14:16:14 +01:00
#pragma once
#include <mutex>
#include <unordered_map>
#include "../dxbc/dxbc_module.h"
#include "../dxvk/dxvk_device.h"
2017-12-06 14:16:14 +01:00
2018-08-12 00:52:39 +02:00
#include "../d3d10/d3d10_shader.h"
#include "../util/sha1/sha1_util.h"
#include "../util/util_env.h"
2017-12-06 14:16:14 +01:00
#include "d3d11_device_child.h"
#include "d3d11_interfaces.h"
namespace dxvk {
class D3D11Device;
/**
* \brief Common shader object
*
* Stores the compiled SPIR-V shader and the SHA-1
* hash of the original DXBC shader, which can be
* used to identify the shader.
*/
class D3D11CommonShader {
public:
D3D11CommonShader();
D3D11CommonShader(
D3D11Device* pDevice,
const DxvkShaderKey* pShaderKey,
const DxbcModuleInfo* pDxbcModuleInfo,
const void* pShaderBytecode,
size_t BytecodeLength);
~D3D11CommonShader();
2017-12-07 10:12:48 +01:00
Rc<DxvkShader> GetShader() const {
return m_shader;
}
Rc<DxvkBuffer> GetIcb() const {
return m_buffer;
}
std::string GetName() const {
return m_shader->debugName();
}
2017-12-07 10:12:48 +01:00
private:
2017-12-07 10:12:48 +01:00
Rc<DxvkShader> m_shader;
Rc<DxvkBuffer> m_buffer;
};
2017-12-06 14:16:14 +01:00
/**
* \brief Shader module set
*
* Some applications may compile the same shader multiple
* times, so we should cache the resulting shader modules
* and reuse them rather than creating new ones. This
* class is thread-safe.
*/
class D3D11ShaderModuleSet {
public:
D3D11ShaderModuleSet();
~D3D11ShaderModuleSet();
HRESULT GetShaderModule(
D3D11Device* pDevice,
const DxvkShaderKey* pShaderKey,
const DxbcModuleInfo* pDxbcModuleInfo,
const void* pShaderBytecode,
size_t BytecodeLength,
D3D11CommonShader* pShader);
private:
std::mutex m_mutex;
std::unordered_map<
DxvkShaderKey,
D3D11CommonShader,
DxvkHash, DxvkEq> m_modules;
};
2017-12-06 14:16:14 +01:00
}