mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 20:52:10 +01:00
[d3d11] Implemented sampler binding
This commit is contained in:
parent
e335c817bc
commit
1160810687
@ -762,7 +762,11 @@ namespace dxvk {
|
||||
UINT StartSlot,
|
||||
UINT NumSamplers,
|
||||
ID3D11SamplerState* const* ppSamplers) {
|
||||
Logger::err("D3D11DeviceContext::VSSetSamplers: Not implemented");
|
||||
this->BindSamplers(
|
||||
DxbcProgramType::VertexShader,
|
||||
&m_state.vs.samplers,
|
||||
StartSlot, NumSamplers,
|
||||
ppSamplers);
|
||||
}
|
||||
|
||||
|
||||
@ -1032,7 +1036,11 @@ namespace dxvk {
|
||||
UINT StartSlot,
|
||||
UINT NumSamplers,
|
||||
ID3D11SamplerState* const* ppSamplers) {
|
||||
Logger::err("D3D11DeviceContext::PSSetSamplers: Not implemented");
|
||||
this->BindSamplers(
|
||||
DxbcProgramType::PixelShader,
|
||||
&m_state.ps.samplers,
|
||||
StartSlot, NumSamplers,
|
||||
ppSamplers);
|
||||
}
|
||||
|
||||
|
||||
@ -1390,6 +1398,7 @@ namespace dxvk {
|
||||
if (pBindings->at(StartSlot + i) != buffer) {
|
||||
pBindings->at(StartSlot + i) = buffer;
|
||||
|
||||
// Figure out which part of the buffer to bind
|
||||
DxvkBufferBinding bindingInfo;
|
||||
|
||||
if (buffer != nullptr) {
|
||||
@ -1398,12 +1407,13 @@ namespace dxvk {
|
||||
0, VK_WHOLE_SIZE);
|
||||
}
|
||||
|
||||
VkPipelineBindPoint bindPoint
|
||||
// Bind buffer to the DXVK resource slot
|
||||
const VkPipelineBindPoint bindPoint
|
||||
= ShaderStage == DxbcProgramType::ComputeShader
|
||||
? VK_PIPELINE_BIND_POINT_COMPUTE
|
||||
: VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||
|
||||
uint32_t slotId = computeResourceSlotId(
|
||||
const uint32_t slotId = computeResourceSlotId(
|
||||
ShaderStage, DxbcBindingType::ConstantBuffer,
|
||||
StartSlot + i);
|
||||
|
||||
@ -1414,6 +1424,44 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void D3D11DeviceContext::BindSamplers(
|
||||
DxbcProgramType ShaderStage,
|
||||
D3D11SamplerBindings* pBindings,
|
||||
UINT StartSlot,
|
||||
UINT NumSamplers,
|
||||
ID3D11SamplerState* const* ppSamplers) {
|
||||
for (uint32_t i = 0; i < NumSamplers; i++) {
|
||||
D3D11SamplerState* sampler = nullptr;
|
||||
|
||||
if (ppSamplers != nullptr)
|
||||
sampler = static_cast<D3D11SamplerState*>(ppSamplers[i]);
|
||||
|
||||
if (pBindings->at(StartSlot + i) != sampler) {
|
||||
pBindings->at(StartSlot + i) = sampler;
|
||||
|
||||
// Retrieve the DXVK sampler object
|
||||
Rc<DxvkSampler> samplerInfo = nullptr;
|
||||
|
||||
if (sampler != nullptr)
|
||||
samplerInfo = sampler->GetDXVKSampler();
|
||||
|
||||
// Bind sampler to the DXVK resource slot
|
||||
const VkPipelineBindPoint bindPoint
|
||||
= ShaderStage == DxbcProgramType::ComputeShader
|
||||
? VK_PIPELINE_BIND_POINT_COMPUTE
|
||||
: VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||
|
||||
const uint32_t slotId = computeResourceSlotId(
|
||||
ShaderStage, DxbcBindingType::ImageSampler,
|
||||
StartSlot + i);
|
||||
|
||||
m_context->bindResourceSampler(
|
||||
bindPoint, slotId, samplerInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void D3D11DeviceContext::ApplyViewportState() {
|
||||
// We cannot set less than one viewport in Vulkan, and
|
||||
// rendering with no active viewport is illegal anyway.
|
||||
|
@ -561,6 +561,13 @@ namespace dxvk {
|
||||
UINT NumBuffers,
|
||||
ID3D11Buffer* const* ppConstantBuffers);
|
||||
|
||||
void BindSamplers(
|
||||
DxbcProgramType ShaderStage,
|
||||
D3D11SamplerBindings* pBindings,
|
||||
UINT StartSlot,
|
||||
UINT NumSamplers,
|
||||
ID3D11SamplerState* const* ppSamplers);
|
||||
|
||||
void ApplyViewportState();
|
||||
|
||||
void SetupIAStateObjects();
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "d3d11_buffer.h"
|
||||
#include "d3d11_input_layout.h"
|
||||
#include "d3d11_sampler.h"
|
||||
#include "d3d11_shader.h"
|
||||
#include "d3d11_state.h"
|
||||
#include "d3d11_view.h"
|
||||
@ -13,39 +14,50 @@ namespace dxvk {
|
||||
using D3D11ConstantBufferBindings = std::array<
|
||||
Com<D3D11Buffer>, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT>;
|
||||
|
||||
|
||||
using D3D11SamplerBindings = std::array<
|
||||
Com<D3D11SamplerState>, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT>;
|
||||
|
||||
|
||||
struct D3D11ContextStateVS {
|
||||
Com<D3D11VertexShader> shader;
|
||||
D3D11ConstantBufferBindings constantBuffers;
|
||||
D3D11SamplerBindings samplers;
|
||||
};
|
||||
|
||||
|
||||
struct D3D11ContextStateHS {
|
||||
Com<D3D11HullShader> shader;
|
||||
D3D11ConstantBufferBindings constantBuffers;
|
||||
D3D11SamplerBindings samplers;
|
||||
};
|
||||
|
||||
|
||||
struct D3D11ContextStateDS {
|
||||
Com<D3D11DomainShader> shader;
|
||||
D3D11ConstantBufferBindings constantBuffers;
|
||||
D3D11SamplerBindings samplers;
|
||||
};
|
||||
|
||||
|
||||
struct D3D11ContextStateGS {
|
||||
Com<D3D11GeometryShader> shader;
|
||||
D3D11ConstantBufferBindings constantBuffers;
|
||||
D3D11SamplerBindings samplers;
|
||||
};
|
||||
|
||||
|
||||
struct D3D11ContextStatePS {
|
||||
Com<D3D11PixelShader> shader;
|
||||
D3D11ConstantBufferBindings constantBuffers;
|
||||
D3D11SamplerBindings samplers;
|
||||
};
|
||||
|
||||
|
||||
struct D3D11ContextStateCS {
|
||||
Com<D3D11ComputeShader> shader;
|
||||
Com<D3D11ComputeShader> shader;
|
||||
D3D11ConstantBufferBindings constantBuffers;
|
||||
D3D11SamplerBindings samplers;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user