mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 11:52:12 +01:00
[d3d11] Implemented shader binding
This commit is contained in:
parent
93c719cadf
commit
bf17c61579
@ -63,7 +63,7 @@ namespace dxvk {
|
||||
// this->IASetVertexBuffers(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, nullptr, nullptr, nullptr);
|
||||
// this->IASetIndexBuffer(nullptr, DXGI_FORMAT_UNKNOWN, 0);
|
||||
|
||||
// this->VSSetShader(nullptr, nullptr, 0);
|
||||
this->VSSetShader(nullptr, nullptr, 0);
|
||||
// this->VSSetConstantBuffers(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, nullptr);
|
||||
// this->VSSetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, nullptr);
|
||||
// this->VSSetSamplers (0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, nullptr);
|
||||
@ -83,7 +83,7 @@ namespace dxvk {
|
||||
// this->GSSetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, nullptr);
|
||||
// this->GSSetSamplers (0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, nullptr);
|
||||
|
||||
// this->PSSetShader(nullptr, nullptr, 0);
|
||||
this->PSSetShader(nullptr, nullptr, 0);
|
||||
// this->PSSetConstantBuffers(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, nullptr);
|
||||
// this->PSSetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, nullptr);
|
||||
// this->PSSetSamplers (0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, nullptr);
|
||||
@ -553,7 +553,17 @@ namespace dxvk {
|
||||
ID3D11VertexShader* pVertexShader,
|
||||
ID3D11ClassInstance* const* ppClassInstances,
|
||||
UINT NumClassInstances) {
|
||||
Logger::err("D3D11DeviceContext::VSSetShader: Not implemented");
|
||||
auto shader = static_cast<D3D11VertexShader*>(pVertexShader);
|
||||
|
||||
if (NumClassInstances != 0)
|
||||
Logger::err("D3D11DeviceContext::VSSetShader: Class instances not supported");
|
||||
|
||||
if (m_state.vs.shader != shader) {
|
||||
m_state.vs.shader = shader;
|
||||
|
||||
m_context->bindShader(VK_SHADER_STAGE_VERTEX_BIT,
|
||||
shader != nullptr ? shader->GetShader() : nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -809,7 +819,17 @@ namespace dxvk {
|
||||
ID3D11PixelShader* pPixelShader,
|
||||
ID3D11ClassInstance* const* ppClassInstances,
|
||||
UINT NumClassInstances) {
|
||||
Logger::err("D3D11DeviceContext::PSSetShader: Not implemented");
|
||||
auto shader = static_cast<D3D11PixelShader*>(pPixelShader);
|
||||
|
||||
if (NumClassInstances != 0)
|
||||
Logger::err("D3D11DeviceContext::VSSetShader: Class instances not supported");
|
||||
|
||||
if (m_state.ps.shader != shader) {
|
||||
m_state.ps.shader = shader;
|
||||
|
||||
m_context->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
shader != nullptr ? shader->GetShader() : nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -638,7 +638,7 @@ namespace dxvk {
|
||||
|
||||
try {
|
||||
*pShaderModule = D3D11ShaderModule(
|
||||
pShaderBytecode, BytecodeLength);
|
||||
this, pShaderBytecode, BytecodeLength);
|
||||
return S_OK;
|
||||
} catch (const DxvkError& e) {
|
||||
Logger::err(e.message());
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "d3d11_device.h"
|
||||
#include "d3d11_shader.h"
|
||||
|
||||
namespace dxvk {
|
||||
@ -23,17 +24,20 @@ namespace dxvk {
|
||||
|
||||
|
||||
D3D11ShaderModule::D3D11ShaderModule(
|
||||
const void* pShaderBytecode,
|
||||
size_t BytecodeLength) {
|
||||
D3D11Device* pDevice,
|
||||
const void* pShaderBytecode,
|
||||
size_t BytecodeLength) {
|
||||
|
||||
DxbcReader reader(
|
||||
reinterpret_cast<const char*>(pShaderBytecode),
|
||||
BytecodeLength);
|
||||
|
||||
DxbcModule module(reader);
|
||||
m_code = module.compile();
|
||||
|
||||
SpirvCodeBuffer spirvCode = module.compile();
|
||||
|
||||
// TODO pre-process shader bindings
|
||||
std::vector<DxvkResourceSlot> resourceSlots;
|
||||
|
||||
// If requested by the user, dump both the raw DXBC
|
||||
// shader and the compiled SPIR-V module to a file.
|
||||
@ -47,9 +51,15 @@ namespace dxvk {
|
||||
reader.store(std::ofstream(str::format(baseName, ".dxbc"),
|
||||
std::ios_base::binary | std::ios_base::trunc));
|
||||
|
||||
m_code.store(std::ofstream(str::format(baseName, ".spv"),
|
||||
spirvCode.store(std::ofstream(str::format(baseName, ".spv"),
|
||||
std::ios_base::binary | std::ios_base::trunc));
|
||||
}
|
||||
|
||||
m_shader = pDevice->GetDXVKDevice()->createShader(
|
||||
module.version().shaderStage(),
|
||||
resourceSlots.size(),
|
||||
resourceSlots.data(),
|
||||
spirvCode);
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,14 +23,18 @@ namespace dxvk {
|
||||
|
||||
D3D11ShaderModule();
|
||||
D3D11ShaderModule(
|
||||
const void* pShaderBytecode,
|
||||
size_t BytecodeLength);
|
||||
D3D11Device* pDevice,
|
||||
const void* pShaderBytecode,
|
||||
size_t BytecodeLength);
|
||||
~D3D11ShaderModule();
|
||||
|
||||
Rc<DxvkShader> GetShader() const {
|
||||
return m_shader;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
SpirvCodeBuffer m_code;
|
||||
Rc<DxvkShader> m_shader;
|
||||
|
||||
Sha1Hash ComputeShaderHash(
|
||||
const void* pShaderBytecode,
|
||||
@ -73,8 +77,8 @@ namespace dxvk {
|
||||
*ppDevice = ref(m_device);
|
||||
}
|
||||
|
||||
const D3D11ShaderModule& GetShaderModule() const {
|
||||
return m_module;
|
||||
Rc<DxvkShader> GetShader() const {
|
||||
return m_module.GetShader();
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user