1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05:52:11 +01:00

[dxvk] Use null descriptors for unbound resources

This way we won't have to recompile pipelines any time the app
unbinds a resource.
This commit is contained in:
Philip Rebohle 2020-04-27 10:04:14 +02:00 committed by Philip Rebohle
parent 6ea9d83f94
commit 7b8a65589e
3 changed files with 44 additions and 3 deletions

View File

@ -17,7 +17,8 @@ namespace dxvk {
m_gfxBarriers (DxvkCmdBuffer::ExecBuffer), m_gfxBarriers (DxvkCmdBuffer::ExecBuffer),
m_queryManager(m_common->queryPool()), m_queryManager(m_common->queryPool()),
m_staging (device) { m_staging (device) {
if (m_device->features().extRobustness2.nullDescriptor)
m_features.set(DxvkContextFeature::NullDescriptors);
} }
@ -237,7 +238,8 @@ namespace dxvk {
m_state.vi.vertexBuffers[binding] = buffer; m_state.vi.vertexBuffers[binding] = buffer;
m_flags.set(DxvkContextFlag::GpDirtyVertexBuffers); m_flags.set(DxvkContextFlag::GpDirtyVertexBuffers);
if (unlikely(!buffer.defined())) if (unlikely(!m_features.test(DxvkContextFeature::NullDescriptors))
&& unlikely(!buffer.defined()))
stride = 0; stride = 0;
if (unlikely(m_state.vi.vertexStrides[binding] != stride)) { if (unlikely(m_state.vi.vertexStrides[binding] != stride)) {
@ -3911,7 +3913,6 @@ namespace dxvk {
if (m_rcTracked.set(binding.slot)) if (m_rcTracked.set(binding.slot))
m_cmd->trackResource<DxvkAccess::None>(res.sampler); m_cmd->trackResource<DxvkAccess::None>(res.sampler);
} else { } else {
bindMask.clr(i);
descriptors[i].image = m_common->dummyResources().samplerDescriptor(); descriptors[i].image = m_common->dummyResources().samplerDescriptor();
} break; } break;
@ -3928,6 +3929,10 @@ namespace dxvk {
m_cmd->trackResource<DxvkAccess::None>(res.imageView); m_cmd->trackResource<DxvkAccess::None>(res.imageView);
m_cmd->trackResource<DxvkAccess::Read>(res.imageView->image()); m_cmd->trackResource<DxvkAccess::Read>(res.imageView->image());
} }
} else if (m_features.test(DxvkContextFeature::NullDescriptors)) {
descriptors[i].image.sampler = VK_NULL_HANDLE;
descriptors[i].image.imageView = VK_NULL_HANDLE;
descriptors[i].image.imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
} else { } else {
bindMask.clr(i); bindMask.clr(i);
descriptors[i].image = m_common->dummyResources().imageViewDescriptor(binding.view, true); descriptors[i].image = m_common->dummyResources().imageViewDescriptor(binding.view, true);
@ -3946,6 +3951,10 @@ namespace dxvk {
m_cmd->trackResource<DxvkAccess::None>(res.imageView); m_cmd->trackResource<DxvkAccess::None>(res.imageView);
m_cmd->trackResource<DxvkAccess::Write>(res.imageView->image()); m_cmd->trackResource<DxvkAccess::Write>(res.imageView->image());
} }
} else if (m_features.test(DxvkContextFeature::NullDescriptors)) {
descriptors[i].image.sampler = VK_NULL_HANDLE;
descriptors[i].image.imageView = VK_NULL_HANDLE;
descriptors[i].image.imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
} else { } else {
bindMask.clr(i); bindMask.clr(i);
descriptors[i].image = m_common->dummyResources().imageViewDescriptor(binding.view, false); descriptors[i].image = m_common->dummyResources().imageViewDescriptor(binding.view, false);
@ -3966,6 +3975,8 @@ namespace dxvk {
m_cmd->trackResource<DxvkAccess::None>(res.imageView); m_cmd->trackResource<DxvkAccess::None>(res.imageView);
m_cmd->trackResource<DxvkAccess::Read>(res.imageView->image()); m_cmd->trackResource<DxvkAccess::Read>(res.imageView->image());
} }
} else if (m_features.test(DxvkContextFeature::NullDescriptors)) {
descriptors[i].image = m_common->dummyResources().samplerDescriptor();
} else { } else {
bindMask.clr(i); bindMask.clr(i);
descriptors[i].image = m_common->dummyResources().imageSamplerDescriptor(binding.view); descriptors[i].image = m_common->dummyResources().imageSamplerDescriptor(binding.view);
@ -3980,6 +3991,8 @@ namespace dxvk {
m_cmd->trackResource<DxvkAccess::None>(res.bufferView); m_cmd->trackResource<DxvkAccess::None>(res.bufferView);
m_cmd->trackResource<DxvkAccess::Read>(res.bufferView->buffer()); m_cmd->trackResource<DxvkAccess::Read>(res.bufferView->buffer());
} }
} else if (m_features.test(DxvkContextFeature::NullDescriptors)) {
descriptors[i].texelBuffer = VK_NULL_HANDLE;
} else { } else {
bindMask.clr(i); bindMask.clr(i);
descriptors[i].texelBuffer = m_common->dummyResources().bufferViewDescriptor(); descriptors[i].texelBuffer = m_common->dummyResources().bufferViewDescriptor();
@ -3994,6 +4007,8 @@ namespace dxvk {
m_cmd->trackResource<DxvkAccess::None>(res.bufferView); m_cmd->trackResource<DxvkAccess::None>(res.bufferView);
m_cmd->trackResource<DxvkAccess::Write>(res.bufferView->buffer()); m_cmd->trackResource<DxvkAccess::Write>(res.bufferView->buffer());
} }
} else if (m_features.test(DxvkContextFeature::NullDescriptors)) {
descriptors[i].texelBuffer = VK_NULL_HANDLE;
} else { } else {
bindMask.clr(i); bindMask.clr(i);
descriptors[i].texelBuffer = m_common->dummyResources().bufferViewDescriptor(); descriptors[i].texelBuffer = m_common->dummyResources().bufferViewDescriptor();
@ -4005,6 +4020,10 @@ namespace dxvk {
if (m_rcTracked.set(binding.slot)) if (m_rcTracked.set(binding.slot))
m_cmd->trackResource<DxvkAccess::Read>(res.bufferSlice.buffer()); m_cmd->trackResource<DxvkAccess::Read>(res.bufferSlice.buffer());
} else if (m_features.test(DxvkContextFeature::NullDescriptors)) {
descriptors[i].buffer.buffer = VK_NULL_HANDLE;
descriptors[i].buffer.offset = 0;
descriptors[i].buffer.range = 0;
} else { } else {
bindMask.clr(i); bindMask.clr(i);
descriptors[i].buffer = m_common->dummyResources().bufferDescriptor(); descriptors[i].buffer = m_common->dummyResources().bufferDescriptor();
@ -4016,6 +4035,10 @@ namespace dxvk {
if (m_rcTracked.set(binding.slot)) if (m_rcTracked.set(binding.slot))
m_cmd->trackResource<DxvkAccess::Write>(res.bufferSlice.buffer()); m_cmd->trackResource<DxvkAccess::Write>(res.bufferSlice.buffer());
} else if (m_features.test(DxvkContextFeature::NullDescriptors)) {
descriptors[i].buffer.buffer = VK_NULL_HANDLE;
descriptors[i].buffer.offset = 0;
descriptors[i].buffer.range = 0;
} else { } else {
bindMask.clr(i); bindMask.clr(i);
descriptors[i].buffer = m_common->dummyResources().bufferDescriptor(); descriptors[i].buffer = m_common->dummyResources().bufferDescriptor();
@ -4028,6 +4051,10 @@ namespace dxvk {
if (m_rcTracked.set(binding.slot)) if (m_rcTracked.set(binding.slot))
m_cmd->trackResource<DxvkAccess::Read>(res.bufferSlice.buffer()); m_cmd->trackResource<DxvkAccess::Read>(res.bufferSlice.buffer());
} else if (m_features.test(DxvkContextFeature::NullDescriptors)) {
descriptors[i].buffer.buffer = VK_NULL_HANDLE;
descriptors[i].buffer.offset = 0;
descriptors[i].buffer.range = 0;
} else { } else {
bindMask.clr(i); bindMask.clr(i);
descriptors[i].buffer = m_common->dummyResources().bufferDescriptor(); descriptors[i].buffer = m_common->dummyResources().bufferDescriptor();
@ -4157,6 +4184,9 @@ namespace dxvk {
if (m_vbTracked.set(binding)) if (m_vbTracked.set(binding))
m_cmd->trackResource<DxvkAccess::Read>(m_state.vi.vertexBuffers[binding].buffer()); m_cmd->trackResource<DxvkAccess::Read>(m_state.vi.vertexBuffers[binding].buffer());
} else if (m_features.test(DxvkContextFeature::NullDescriptors)) {
buffers[i] = VK_NULL_HANDLE;
offsets[i] = 0;
} else { } else {
buffers[i] = m_common->dummyResources().bufferHandle(); buffers[i] = m_common->dummyResources().bufferHandle();
offsets[i] = 0; offsets[i] = 0;

View File

@ -1018,6 +1018,7 @@ namespace dxvk {
DxvkContextFlags m_flags; DxvkContextFlags m_flags;
DxvkContextState m_state; DxvkContextState m_state;
DxvkContextFeatures m_features;
DxvkBarrierSet m_sdmaAcquires; DxvkBarrierSet m_sdmaAcquires;
DxvkBarrierSet m_sdmaBarriers; DxvkBarrierSet m_sdmaBarriers;

View File

@ -57,6 +57,16 @@ namespace dxvk {
using DxvkContextFlags = Flags<DxvkContextFlag>; using DxvkContextFlags = Flags<DxvkContextFlag>;
/**
* \brief Context feature bits
*/
enum class DxvkContextFeature {
NullDescriptors,
};
using DxvkContextFeatures = Flags<DxvkContextFeature>;
/** /**
* \brief Barrier control flags * \brief Barrier control flags
* *