2017-12-06 14:16:14 +01:00
|
|
|
#pragma once
|
|
|
|
|
2018-04-06 17:54:02 +02:00
|
|
|
#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"
|
|
|
|
|
2017-12-06 18:54:01 +01:00
|
|
|
#include "../util/sha1/sha1_util.h"
|
|
|
|
|
2017-12-08 01:32:02 +01:00
|
|
|
#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;
|
|
|
|
|
2018-04-06 17:54:02 +02:00
|
|
|
/**
|
2018-07-30 19:34:48 +02:00
|
|
|
* \brief Common shader object
|
2017-12-06 18:54:01 +01:00
|
|
|
*
|
2018-04-06 17:54:02 +02:00
|
|
|
* Stores the compiled SPIR-V shader and the SHA-1
|
|
|
|
* hash of the original DXBC shader, which can be
|
|
|
|
* used to identify the shader.
|
2017-12-06 18:54:01 +01:00
|
|
|
*/
|
2018-07-30 19:34:48 +02:00
|
|
|
class D3D11CommonShader {
|
2017-12-06 18:54:01 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2018-07-30 19:34:48 +02:00
|
|
|
D3D11CommonShader();
|
|
|
|
D3D11CommonShader(
|
2018-07-30 20:15:19 +02:00
|
|
|
D3D11Device* pDevice,
|
2018-09-18 10:17:32 +02:00
|
|
|
const DxvkShaderKey* pShaderKey,
|
2018-06-23 17:14:35 +02:00
|
|
|
const DxbcModuleInfo* pDxbcModuleInfo,
|
2018-04-06 17:54:02 +02:00
|
|
|
const void* pShaderBytecode,
|
|
|
|
size_t BytecodeLength);
|
2018-07-30 19:34:48 +02:00
|
|
|
~D3D11CommonShader();
|
|
|
|
|
2017-12-07 10:12:48 +01:00
|
|
|
Rc<DxvkShader> GetShader() const {
|
|
|
|
return m_shader;
|
|
|
|
}
|
2018-07-30 20:15:19 +02:00
|
|
|
|
|
|
|
Rc<DxvkBuffer> GetIcb() const {
|
|
|
|
return m_buffer;
|
|
|
|
}
|
2017-12-06 18:54:01 +01:00
|
|
|
|
2018-04-06 17:54:02 +02:00
|
|
|
std::string GetName() const {
|
2018-09-18 10:21:18 +02:00
|
|
|
return m_shader->debugName();
|
2018-01-12 00:43:19 +01:00
|
|
|
}
|
|
|
|
|
2017-12-07 10:12:48 +01:00
|
|
|
private:
|
2017-12-06 18:54:01 +01:00
|
|
|
|
2017-12-07 10:12:48 +01:00
|
|
|
Rc<DxvkShader> m_shader;
|
2018-07-30 20:15:19 +02:00
|
|
|
Rc<DxvkBuffer> m_buffer;
|
2017-12-06 18:54:01 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-12-06 14:16:14 +01:00
|
|
|
|
2018-04-06 17:54:02 +02: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();
|
|
|
|
|
2019-10-21 12:09:53 +02:00
|
|
|
HRESULT GetShaderModule(
|
|
|
|
D3D11Device* pDevice,
|
|
|
|
const DxvkShaderKey* pShaderKey,
|
|
|
|
const DxbcModuleInfo* pDxbcModuleInfo,
|
|
|
|
const void* pShaderBytecode,
|
|
|
|
size_t BytecodeLength,
|
|
|
|
D3D11CommonShader* pShader);
|
2018-04-06 17:54:02 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
std::mutex m_mutex;
|
|
|
|
|
|
|
|
std::unordered_map<
|
2018-09-18 10:17:32 +02:00
|
|
|
DxvkShaderKey,
|
2018-07-30 19:34:48 +02:00
|
|
|
D3D11CommonShader,
|
2018-09-18 10:17:32 +02:00
|
|
|
DxvkHash, DxvkEq> m_modules;
|
2018-04-06 17:54:02 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-12-06 14:16:14 +01:00
|
|
|
}
|