mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +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->IASetVertexBuffers(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, nullptr, nullptr, nullptr);
|
||||||
// this->IASetIndexBuffer(nullptr, DXGI_FORMAT_UNKNOWN, 0);
|
// 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->VSSetConstantBuffers(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, nullptr);
|
||||||
// this->VSSetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, nullptr);
|
// this->VSSetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, nullptr);
|
||||||
// this->VSSetSamplers (0, D3D11_COMMONSHADER_SAMPLER_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->GSSetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, nullptr);
|
||||||
// this->GSSetSamplers (0, D3D11_COMMONSHADER_SAMPLER_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->PSSetConstantBuffers(0, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, nullptr);
|
||||||
// this->PSSetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, nullptr);
|
// this->PSSetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, nullptr);
|
||||||
// this->PSSetSamplers (0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, nullptr);
|
// this->PSSetSamplers (0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, nullptr);
|
||||||
@ -553,7 +553,17 @@ namespace dxvk {
|
|||||||
ID3D11VertexShader* pVertexShader,
|
ID3D11VertexShader* pVertexShader,
|
||||||
ID3D11ClassInstance* const* ppClassInstances,
|
ID3D11ClassInstance* const* ppClassInstances,
|
||||||
UINT NumClassInstances) {
|
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,
|
ID3D11PixelShader* pPixelShader,
|
||||||
ID3D11ClassInstance* const* ppClassInstances,
|
ID3D11ClassInstance* const* ppClassInstances,
|
||||||
UINT NumClassInstances) {
|
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 {
|
try {
|
||||||
*pShaderModule = D3D11ShaderModule(
|
*pShaderModule = D3D11ShaderModule(
|
||||||
pShaderBytecode, BytecodeLength);
|
this, pShaderBytecode, BytecodeLength);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
} catch (const DxvkError& e) {
|
} catch (const DxvkError& e) {
|
||||||
Logger::err(e.message());
|
Logger::err(e.message());
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include "d3d11_device.h"
|
||||||
#include "d3d11_shader.h"
|
#include "d3d11_shader.h"
|
||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
@ -23,17 +24,20 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
D3D11ShaderModule::D3D11ShaderModule(
|
D3D11ShaderModule::D3D11ShaderModule(
|
||||||
const void* pShaderBytecode,
|
D3D11Device* pDevice,
|
||||||
size_t BytecodeLength) {
|
const void* pShaderBytecode,
|
||||||
|
size_t BytecodeLength) {
|
||||||
|
|
||||||
DxbcReader reader(
|
DxbcReader reader(
|
||||||
reinterpret_cast<const char*>(pShaderBytecode),
|
reinterpret_cast<const char*>(pShaderBytecode),
|
||||||
BytecodeLength);
|
BytecodeLength);
|
||||||
|
|
||||||
DxbcModule module(reader);
|
DxbcModule module(reader);
|
||||||
m_code = module.compile();
|
|
||||||
|
SpirvCodeBuffer spirvCode = module.compile();
|
||||||
|
|
||||||
// TODO pre-process shader bindings
|
// TODO pre-process shader bindings
|
||||||
|
std::vector<DxvkResourceSlot> resourceSlots;
|
||||||
|
|
||||||
// If requested by the user, dump both the raw DXBC
|
// If requested by the user, dump both the raw DXBC
|
||||||
// shader and the compiled SPIR-V module to a file.
|
// shader and the compiled SPIR-V module to a file.
|
||||||
@ -47,9 +51,15 @@ namespace dxvk {
|
|||||||
reader.store(std::ofstream(str::format(baseName, ".dxbc"),
|
reader.store(std::ofstream(str::format(baseName, ".dxbc"),
|
||||||
std::ios_base::binary | std::ios_base::trunc));
|
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));
|
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();
|
||||||
D3D11ShaderModule(
|
D3D11ShaderModule(
|
||||||
const void* pShaderBytecode,
|
D3D11Device* pDevice,
|
||||||
size_t BytecodeLength);
|
const void* pShaderBytecode,
|
||||||
|
size_t BytecodeLength);
|
||||||
~D3D11ShaderModule();
|
~D3D11ShaderModule();
|
||||||
|
|
||||||
|
Rc<DxvkShader> GetShader() const {
|
||||||
|
return m_shader;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Rc<DxvkShader> m_shader;
|
||||||
SpirvCodeBuffer m_code;
|
|
||||||
|
|
||||||
Sha1Hash ComputeShaderHash(
|
Sha1Hash ComputeShaderHash(
|
||||||
const void* pShaderBytecode,
|
const void* pShaderBytecode,
|
||||||
@ -73,8 +77,8 @@ namespace dxvk {
|
|||||||
*ppDevice = ref(m_device);
|
*ppDevice = ref(m_device);
|
||||||
}
|
}
|
||||||
|
|
||||||
const D3D11ShaderModule& GetShaderModule() const {
|
Rc<DxvkShader> GetShader() const {
|
||||||
return m_module;
|
return m_module.GetShader();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user