mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-27 22:54:16 +01:00
[dxvk] Simplified resource binding
The backend no longer differentiates between compute pipeline resources and graphics pipeline resources.
This commit is contained in:
parent
7a7a1faa63
commit
82b2c40405
@ -1579,11 +1579,6 @@ namespace dxvk {
|
|||||||
UINT StartSlot,
|
UINT StartSlot,
|
||||||
UINT NumBuffers,
|
UINT NumBuffers,
|
||||||
ID3D11Buffer* const* ppConstantBuffers) {
|
ID3D11Buffer* const* ppConstantBuffers) {
|
||||||
const VkPipelineBindPoint bindPoint
|
|
||||||
= ShaderStage == DxbcProgramType::ComputeShader
|
|
||||||
? VK_PIPELINE_BIND_POINT_COMPUTE
|
|
||||||
: VK_PIPELINE_BIND_POINT_GRAPHICS;
|
|
||||||
|
|
||||||
const uint32_t slotId = computeResourceSlotId(
|
const uint32_t slotId = computeResourceSlotId(
|
||||||
ShaderStage, DxbcBindingType::ConstantBuffer,
|
ShaderStage, DxbcBindingType::ConstantBuffer,
|
||||||
StartSlot);
|
StartSlot);
|
||||||
@ -1596,10 +1591,10 @@ namespace dxvk {
|
|||||||
|
|
||||||
if (newBuffer != nullptr) {
|
if (newBuffer != nullptr) {
|
||||||
m_context->bindResourceBuffer(
|
m_context->bindResourceBuffer(
|
||||||
bindPoint, slotId + i, newBuffer->GetBufferSlice(0));
|
slotId + i, newBuffer->GetBufferSlice(0));
|
||||||
} else {
|
} else {
|
||||||
m_context->bindResourceBuffer(
|
m_context->bindResourceBuffer(
|
||||||
bindPoint, slotId + i, DxvkBufferSlice());
|
slotId + i, DxvkBufferSlice());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1612,11 +1607,6 @@ namespace dxvk {
|
|||||||
UINT StartSlot,
|
UINT StartSlot,
|
||||||
UINT NumSamplers,
|
UINT NumSamplers,
|
||||||
ID3D11SamplerState* const* ppSamplers) {
|
ID3D11SamplerState* const* ppSamplers) {
|
||||||
const VkPipelineBindPoint bindPoint
|
|
||||||
= ShaderStage == DxbcProgramType::ComputeShader
|
|
||||||
? VK_PIPELINE_BIND_POINT_COMPUTE
|
|
||||||
: VK_PIPELINE_BIND_POINT_GRAPHICS;
|
|
||||||
|
|
||||||
const uint32_t slotId = computeResourceSlotId(
|
const uint32_t slotId = computeResourceSlotId(
|
||||||
ShaderStage, DxbcBindingType::ImageSampler,
|
ShaderStage, DxbcBindingType::ImageSampler,
|
||||||
StartSlot);
|
StartSlot);
|
||||||
@ -1629,10 +1619,10 @@ namespace dxvk {
|
|||||||
|
|
||||||
if (sampler != nullptr) {
|
if (sampler != nullptr) {
|
||||||
m_context->bindResourceSampler(
|
m_context->bindResourceSampler(
|
||||||
bindPoint, slotId + i, sampler->GetDXVKSampler());
|
slotId + i, sampler->GetDXVKSampler());
|
||||||
} else {
|
} else {
|
||||||
m_context->bindResourceSampler(
|
m_context->bindResourceSampler(
|
||||||
bindPoint, slotId + i, nullptr);
|
slotId + i, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1645,11 +1635,6 @@ namespace dxvk {
|
|||||||
UINT StartSlot,
|
UINT StartSlot,
|
||||||
UINT NumResources,
|
UINT NumResources,
|
||||||
ID3D11ShaderResourceView* const* ppResources) {
|
ID3D11ShaderResourceView* const* ppResources) {
|
||||||
const VkPipelineBindPoint bindPoint
|
|
||||||
= ShaderStage == DxbcProgramType::ComputeShader
|
|
||||||
? VK_PIPELINE_BIND_POINT_COMPUTE
|
|
||||||
: VK_PIPELINE_BIND_POINT_GRAPHICS;
|
|
||||||
|
|
||||||
const uint32_t slotId = computeResourceSlotId(
|
const uint32_t slotId = computeResourceSlotId(
|
||||||
ShaderStage, DxbcBindingType::ShaderResource,
|
ShaderStage, DxbcBindingType::ShaderResource,
|
||||||
StartSlot);
|
StartSlot);
|
||||||
@ -1665,17 +1650,16 @@ namespace dxvk {
|
|||||||
if (resView->GetResourceType() == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
if (resView->GetResourceType() == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
||||||
Logger::warn("D3D11: Texel buffers not yet supported");
|
Logger::warn("D3D11: Texel buffers not yet supported");
|
||||||
m_context->bindResourceTexelBuffer(
|
m_context->bindResourceTexelBuffer(
|
||||||
bindPoint, slotId + i, nullptr);
|
slotId + i, nullptr);
|
||||||
} else {
|
} else {
|
||||||
m_context->bindResourceImage(bindPoint,
|
m_context->bindResourceImage(
|
||||||
slotId + i, resView->GetDXVKImageView());
|
slotId + i, resView->GetDXVKImageView());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// When unbinding a resource, it doesn't really matter if
|
// When unbinding a resource, it doesn't really matter if
|
||||||
// the resource type is correct, so we'll just bind a null
|
// the resource type is correct, so we'll just bind a null
|
||||||
// image to the given resource slot
|
// image to the given resource slot
|
||||||
m_context->bindResourceImage(
|
m_context->bindResourceImage(slotId + i, nullptr);
|
||||||
bindPoint, slotId + i, nullptr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,12 +191,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
m_context->setViewports(1, &viewport, &scissor);
|
m_context->setViewports(1, &viewport, &scissor);
|
||||||
|
|
||||||
m_context->bindResourceSampler(
|
m_context->bindResourceSampler(BindingIds::Sampler, m_sampler);
|
||||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
m_context->bindResourceImage (BindingIds::Texture, m_backBufferView);
|
||||||
BindingIds::Sampler, m_sampler);
|
|
||||||
m_context->bindResourceImage(
|
|
||||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
|
||||||
BindingIds::Texture, m_backBufferView);
|
|
||||||
m_context->draw(4, 1, 0, 0);
|
m_context->draw(4, 1, 0, 0);
|
||||||
|
|
||||||
m_device->submitCommandList(
|
m_device->submitCommandList(
|
||||||
|
@ -70,45 +70,53 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
void DxvkContext::bindResourceBuffer(
|
void DxvkContext::bindResourceBuffer(
|
||||||
VkPipelineBindPoint pipe,
|
|
||||||
uint32_t slot,
|
uint32_t slot,
|
||||||
const DxvkBufferSlice& buffer) {
|
const DxvkBufferSlice& buffer) {
|
||||||
if (m_rc[slot].bufferSlice != buffer) {
|
if (m_rc[slot].bufferSlice != buffer) {
|
||||||
m_flags.set(getResourceDirtyFlag(pipe));
|
|
||||||
m_rc[slot].bufferSlice = buffer;
|
m_rc[slot].bufferSlice = buffer;
|
||||||
|
|
||||||
|
m_flags.set(
|
||||||
|
DxvkContextFlag::CpDirtyResources,
|
||||||
|
DxvkContextFlag::GpDirtyResources);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkContext::bindResourceTexelBuffer(
|
void DxvkContext::bindResourceTexelBuffer(
|
||||||
VkPipelineBindPoint pipe,
|
|
||||||
uint32_t slot,
|
uint32_t slot,
|
||||||
const Rc<DxvkBufferView>& bufferView) {
|
const Rc<DxvkBufferView>& bufferView) {
|
||||||
if (m_rc[slot].bufferView != bufferView) {
|
if (m_rc[slot].bufferView != bufferView) {
|
||||||
m_flags.set(getResourceDirtyFlag(pipe));
|
|
||||||
m_rc[slot].bufferView = bufferView;
|
m_rc[slot].bufferView = bufferView;
|
||||||
|
|
||||||
|
m_flags.set(
|
||||||
|
DxvkContextFlag::CpDirtyResources,
|
||||||
|
DxvkContextFlag::GpDirtyResources);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkContext::bindResourceImage(
|
void DxvkContext::bindResourceImage(
|
||||||
VkPipelineBindPoint pipe,
|
|
||||||
uint32_t slot,
|
uint32_t slot,
|
||||||
const Rc<DxvkImageView>& image) {
|
const Rc<DxvkImageView>& image) {
|
||||||
if (m_rc[slot].imageView != image) {
|
if (m_rc[slot].imageView != image) {
|
||||||
m_flags.set(getResourceDirtyFlag(pipe));
|
|
||||||
m_rc[slot].imageView = image;
|
m_rc[slot].imageView = image;
|
||||||
|
|
||||||
|
m_flags.set(
|
||||||
|
DxvkContextFlag::CpDirtyResources,
|
||||||
|
DxvkContextFlag::GpDirtyResources);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkContext::bindResourceSampler(
|
void DxvkContext::bindResourceSampler(
|
||||||
VkPipelineBindPoint pipe,
|
|
||||||
uint32_t slot,
|
uint32_t slot,
|
||||||
const Rc<DxvkSampler>& sampler) {
|
const Rc<DxvkSampler>& sampler) {
|
||||||
if (m_rc[slot].sampler != sampler) {
|
if (m_rc[slot].sampler != sampler) {
|
||||||
m_flags.set(getResourceDirtyFlag(pipe));
|
|
||||||
m_rc[slot].sampler = sampler;
|
m_rc[slot].sampler = sampler;
|
||||||
|
|
||||||
|
m_flags.set(
|
||||||
|
DxvkContextFlag::CpDirtyResources,
|
||||||
|
DxvkContextFlag::GpDirtyResources);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -818,17 +826,9 @@ namespace dxvk {
|
|||||||
if (m_flags.test(DxvkContextFlag::CpDirtyResources)) {
|
if (m_flags.test(DxvkContextFlag::CpDirtyResources)) {
|
||||||
m_flags.clr(DxvkContextFlag::CpDirtyResources);
|
m_flags.clr(DxvkContextFlag::CpDirtyResources);
|
||||||
|
|
||||||
auto layout = m_state.cp.pipeline->layout();
|
this->updateShaderResources(
|
||||||
|
VK_PIPELINE_BIND_POINT_COMPUTE,
|
||||||
// TODO refcount used resources
|
m_state.cp.pipeline->layout());
|
||||||
|
|
||||||
// m_cmd->bindResourceDescriptors(
|
|
||||||
// VK_PIPELINE_BIND_POINT_COMPUTE,
|
|
||||||
// layout->pipelineLayout(),
|
|
||||||
// layout->descriptorSetLayout(),
|
|
||||||
// layout->bindingCount(),
|
|
||||||
// layout->bindings(),
|
|
||||||
// m_cResources.descriptors());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -837,12 +837,18 @@ namespace dxvk {
|
|||||||
if (m_flags.test(DxvkContextFlag::GpDirtyResources)) {
|
if (m_flags.test(DxvkContextFlag::GpDirtyResources)) {
|
||||||
m_flags.clr(DxvkContextFlag::GpDirtyResources);
|
m_flags.clr(DxvkContextFlag::GpDirtyResources);
|
||||||
|
|
||||||
auto layout = m_state.gp.pipeline->layout();
|
this->updateShaderResources(
|
||||||
|
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||||
|
m_state.gp.pipeline->layout());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DxvkContext::updateShaderResources(
|
||||||
|
VkPipelineBindPoint bindPoint,
|
||||||
|
const Rc<DxvkBindingLayout>& layout) {
|
||||||
// TODO recreate resource views if the underlying
|
// TODO recreate resource views if the underlying
|
||||||
// resource was marked as dirty after invalidation
|
// resource was marked as dirty after invalidation
|
||||||
// TODO move this into a separate method so that
|
|
||||||
// compute can use this code as well
|
|
||||||
for (uint32_t i = 0; i < layout->bindingCount(); i++) {
|
for (uint32_t i = 0; i < layout->bindingCount(); i++) {
|
||||||
const uint32_t slot = layout->binding(i).slot;
|
const uint32_t slot = layout->binding(i).slot;
|
||||||
const auto& res = m_rc[slot];
|
const auto& res = m_rc[slot];
|
||||||
@ -872,14 +878,13 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_cmd->bindResourceDescriptors(
|
m_cmd->bindResourceDescriptors(
|
||||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
bindPoint,
|
||||||
layout->pipelineLayout(),
|
layout->pipelineLayout(),
|
||||||
layout->descriptorSetLayout(),
|
layout->descriptorSetLayout(),
|
||||||
layout->bindingCount(),
|
layout->bindingCount(),
|
||||||
layout->bindings(),
|
layout->bindings(),
|
||||||
m_descriptors.data());
|
m_descriptors.data());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DxvkContext::updateDynamicState() {
|
void DxvkContext::updateDynamicState() {
|
||||||
@ -1060,13 +1065,4 @@ namespace dxvk {
|
|||||||
m_barriers.recordCommands(m_cmd);
|
m_barriers.recordCommands(m_cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DxvkContextFlag DxvkContext::getResourceDirtyFlag(VkPipelineBindPoint pipe) const {
|
|
||||||
switch (pipe) {
|
|
||||||
default:
|
|
||||||
case VK_PIPELINE_BIND_POINT_GRAPHICS: return DxvkContextFlag::GpDirtyResources;
|
|
||||||
case VK_PIPELINE_BIND_POINT_COMPUTE : return DxvkContextFlag::CpDirtyResources;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -70,12 +70,10 @@ namespace dxvk {
|
|||||||
* \brief Binds buffer as a shader resource
|
* \brief Binds buffer as a shader resource
|
||||||
*
|
*
|
||||||
* Can be used for uniform and storage buffers.
|
* Can be used for uniform and storage buffers.
|
||||||
* \param [in] pipe Target pipeline
|
|
||||||
* \param [in] slot Resource binding slot
|
* \param [in] slot Resource binding slot
|
||||||
* \param [in] buffer Buffer to bind
|
* \param [in] buffer Buffer to bind
|
||||||
*/
|
*/
|
||||||
void bindResourceBuffer(
|
void bindResourceBuffer(
|
||||||
VkPipelineBindPoint pipe,
|
|
||||||
uint32_t slot,
|
uint32_t slot,
|
||||||
const DxvkBufferSlice& buffer);
|
const DxvkBufferSlice& buffer);
|
||||||
|
|
||||||
@ -84,12 +82,10 @@ namespace dxvk {
|
|||||||
*
|
*
|
||||||
* Can be used for both uniform texel
|
* Can be used for both uniform texel
|
||||||
* buffers and storage texel buffers.
|
* buffers and storage texel buffers.
|
||||||
* \param [in] pipe Target pipeline
|
|
||||||
* \param [in] slot Resource binding slot
|
* \param [in] slot Resource binding slot
|
||||||
* \param [in] bufferView Buffer view to bind
|
* \param [in] bufferView Buffer view to bind
|
||||||
*/
|
*/
|
||||||
void bindResourceTexelBuffer(
|
void bindResourceTexelBuffer(
|
||||||
VkPipelineBindPoint pipe,
|
|
||||||
uint32_t slot,
|
uint32_t slot,
|
||||||
const Rc<DxvkBufferView>& bufferView);
|
const Rc<DxvkBufferView>& bufferView);
|
||||||
|
|
||||||
@ -98,12 +94,10 @@ namespace dxvk {
|
|||||||
*
|
*
|
||||||
* Can be used for sampled images with a
|
* Can be used for sampled images with a
|
||||||
* dedicated sampler and storage images.
|
* dedicated sampler and storage images.
|
||||||
* \param [in] pipe Target pipeline
|
|
||||||
* \param [in] slot Resource binding slot
|
* \param [in] slot Resource binding slot
|
||||||
* \param [in] imageView Image view to bind
|
* \param [in] imageView Image view to bind
|
||||||
*/
|
*/
|
||||||
void bindResourceImage(
|
void bindResourceImage(
|
||||||
VkPipelineBindPoint pipe,
|
|
||||||
uint32_t slot,
|
uint32_t slot,
|
||||||
const Rc<DxvkImageView>& image);
|
const Rc<DxvkImageView>& image);
|
||||||
|
|
||||||
@ -112,12 +106,10 @@ namespace dxvk {
|
|||||||
*
|
*
|
||||||
* Binds a sampler that can be used together with
|
* Binds a sampler that can be used together with
|
||||||
* an image in order to read from a texture.
|
* an image in order to read from a texture.
|
||||||
* \param [in] pipe Target pipeline
|
|
||||||
* \param [in] slot Resource binding slot
|
* \param [in] slot Resource binding slot
|
||||||
* \param [in] sampler Sampler view to bind
|
* \param [in] sampler Sampler view to bind
|
||||||
*/
|
*/
|
||||||
void bindResourceSampler(
|
void bindResourceSampler(
|
||||||
VkPipelineBindPoint pipe,
|
|
||||||
uint32_t slot,
|
uint32_t slot,
|
||||||
const Rc<DxvkSampler>& sampler);
|
const Rc<DxvkSampler>& sampler);
|
||||||
|
|
||||||
@ -427,6 +419,10 @@ namespace dxvk {
|
|||||||
void updateComputeShaderResources();
|
void updateComputeShaderResources();
|
||||||
void updateGraphicsShaderResources();
|
void updateGraphicsShaderResources();
|
||||||
|
|
||||||
|
void updateShaderResources(
|
||||||
|
VkPipelineBindPoint bindPoint,
|
||||||
|
const Rc<DxvkBindingLayout>& layout);
|
||||||
|
|
||||||
void updateDynamicState();
|
void updateDynamicState();
|
||||||
void updateViewports();
|
void updateViewports();
|
||||||
void updateBlendConstants();
|
void updateBlendConstants();
|
||||||
@ -446,9 +442,6 @@ namespace dxvk {
|
|||||||
void transformLayoutsRenderPassEnd(
|
void transformLayoutsRenderPassEnd(
|
||||||
const DxvkRenderTargets& renderTargets);
|
const DxvkRenderTargets& renderTargets);
|
||||||
|
|
||||||
DxvkContextFlag getResourceDirtyFlag(
|
|
||||||
VkPipelineBindPoint pipe) const;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user