1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-14 09:23:53 +01:00

[dxvk] Remove old resource update code

This commit is contained in:
Philip Rebohle 2022-06-16 13:17:49 +02:00
parent 219853aa9f
commit f9e6d8e23a
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 0 additions and 205 deletions

View File

@ -4365,199 +4365,6 @@ namespace dxvk {
}
template<VkPipelineBindPoint BindPoint>
void DxvkContext::updateShaderResources(const DxvkPipelineLayout* layout) {
std::array<DxvkDescriptorInfo, MaxNumActiveBindings> descriptors;
// Assume that all bindings are active as a fast path
DxvkBindingMask bindMask;
bindMask.clear();
bindMask.setRange(0, layout->bindingCount());
for (uint32_t i = 0; i < layout->bindingCount(); i++) {
const auto& binding = layout->binding(i);
const auto& res = m_rc[binding.slot];
switch (binding.type) {
case VK_DESCRIPTOR_TYPE_SAMPLER:
if (res.sampler != nullptr) {
descriptors[i].image.sampler = res.sampler->handle();
descriptors[i].image.imageView = VK_NULL_HANDLE;
descriptors[i].image.imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
if (m_rcTracked.set(binding.slot))
m_cmd->trackResource<DxvkAccess::None>(res.sampler);
} else {
descriptors[i].image = m_common->dummyResources().samplerDescriptor();
} break;
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
if (res.imageView != nullptr && res.imageView->handle(binding.view) != VK_NULL_HANDLE) {
descriptors[i].image.sampler = VK_NULL_HANDLE;
descriptors[i].image.imageView = res.imageView->handle(binding.view);
descriptors[i].image.imageLayout = res.imageView->imageInfo().layout;
if (m_rcTracked.set(binding.slot)) {
m_cmd->trackResource<DxvkAccess::None>(res.imageView);
m_cmd->trackResource<DxvkAccess::Read>(res.imageView->image());
}
} else {
bindMask.clr(i);
descriptors[i].image = m_common->dummyResources().imageViewDescriptor(binding.view, true);
} break;
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
if (res.imageView != nullptr && res.imageView->handle(binding.view) != VK_NULL_HANDLE) {
descriptors[i].image.sampler = VK_NULL_HANDLE;
descriptors[i].image.imageView = res.imageView->handle(binding.view);
descriptors[i].image.imageLayout = res.imageView->imageInfo().layout;
if (m_rcTracked.set(binding.slot)) {
m_cmd->trackResource<DxvkAccess::None>(res.imageView);
m_cmd->trackResource<DxvkAccess::Write>(res.imageView->image());
}
} else {
bindMask.clr(i);
descriptors[i].image = m_common->dummyResources().imageViewDescriptor(binding.view, false);
} break;
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
if (res.sampler != nullptr && res.imageView != nullptr
&& res.imageView->handle(binding.view) != VK_NULL_HANDLE) {
descriptors[i].image.sampler = res.sampler->handle();
descriptors[i].image.imageView = res.imageView->handle(binding.view);
descriptors[i].image.imageLayout = res.imageView->imageInfo().layout;
if (m_rcTracked.set(binding.slot)) {
m_cmd->trackResource<DxvkAccess::None>(res.sampler);
m_cmd->trackResource<DxvkAccess::None>(res.imageView);
m_cmd->trackResource<DxvkAccess::Read>(res.imageView->image());
}
} else {
bindMask.clr(i);
descriptors[i].image = m_common->dummyResources().imageSamplerDescriptor(binding.view);
} break;
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
if (res.bufferView != nullptr) {
res.bufferView->updateView();
descriptors[i].texelBuffer = res.bufferView->handle();
if (m_rcTracked.set(binding.slot)) {
m_cmd->trackResource<DxvkAccess::None>(res.bufferView);
m_cmd->trackResource<DxvkAccess::Read>(res.bufferView->buffer());
}
} else {
bindMask.clr(i);
descriptors[i].texelBuffer = m_common->dummyResources().bufferViewDescriptor();
} break;
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
if (res.bufferView != nullptr) {
res.bufferView->updateView();
descriptors[i].texelBuffer = res.bufferView->handle();
if (m_rcTracked.set(binding.slot)) {
m_cmd->trackResource<DxvkAccess::None>(res.bufferView);
m_cmd->trackResource<DxvkAccess::Write>(res.bufferView->buffer());
}
} else {
bindMask.clr(i);
descriptors[i].texelBuffer = m_common->dummyResources().bufferViewDescriptor();
} break;
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
if (res.bufferSlice.defined()) {
descriptors[i] = res.bufferSlice.getDescriptor();
if (m_rcTracked.set(binding.slot))
m_cmd->trackResource<DxvkAccess::Read>(res.bufferSlice.buffer());
} else {
bindMask.clr(i);
descriptors[i].buffer = m_common->dummyResources().bufferDescriptor();
} break;
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
if (res.bufferSlice.defined()) {
descriptors[i] = res.bufferSlice.getDescriptor();
if (m_rcTracked.set(binding.slot))
m_cmd->trackResource<DxvkAccess::Write>(res.bufferSlice.buffer());
} else {
bindMask.clr(i);
descriptors[i].buffer = m_common->dummyResources().bufferDescriptor();
} break;
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
if (res.bufferSlice.defined()) {
descriptors[i] = res.bufferSlice.getDescriptor();
descriptors[i].buffer.offset = 0;
if (m_rcTracked.set(binding.slot))
m_cmd->trackResource<DxvkAccess::Read>(res.bufferSlice.buffer());
} else {
bindMask.clr(i);
descriptors[i].buffer = m_common->dummyResources().bufferDescriptor();
} break;
default:
Logger::err(str::format("DxvkContext: Unhandled descriptor type: ", binding.type));
}
}
// Allocate and update descriptor set
auto& set = BindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS ? m_gpSet : m_cpSet;
if (layout->bindingCount()) {
set = allocateDescriptorSet(layout->descriptorSetLayout());
m_cmd->updateDescriptorSetWithTemplate(set,
layout->descriptorTemplate(), descriptors.data());
} else {
set = VK_NULL_HANDLE;
}
// Select the active binding mask to update
auto& refMask = BindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS
? m_state.gp.state.bsBindingMask
: m_state.cp.state.bsBindingMask;
// If some resources are not bound, we may need to
// update spec constants and rebind the pipeline
if (refMask != bindMask) {
refMask = bindMask;
m_flags.set(BindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS
? DxvkContextFlag::GpDirtyPipelineState
: DxvkContextFlag::CpDirtyPipelineState);
}
}
template<VkPipelineBindPoint BindPoint>
void DxvkContext::updateShaderDescriptorSetBinding(
VkDescriptorSet set,
const DxvkPipelineLayout* layout) {
if (set) {
std::array<uint32_t, MaxNumActiveBindings> offsets;
for (uint32_t i = 0; i < layout->dynamicBindingCount(); i++) {
const auto& binding = layout->dynamicBinding(i);
const auto& res = m_rc[binding.slot];
offsets[i] = res.bufferSlice.defined()
? res.bufferSlice.getDynamicOffset()
: 0;
}
m_cmd->cmdBindDescriptorSet(BindPoint,
layout->pipelineLayout(), set,
layout->dynamicBindingCount(),
offsets.data());
}
}
DxvkFramebufferInfo DxvkContext::makeFramebufferInfo(
const DxvkRenderTargets& renderTargets) {
auto renderPassFormat = DxvkFramebufferInfo::getRenderPassFormat(renderTargets);

View File

@ -1065,9 +1065,6 @@ namespace dxvk {
VkPipeline m_gpActivePipeline = VK_NULL_HANDLE;
VkPipeline m_cpActivePipeline = VK_NULL_HANDLE;
VkDescriptorSet m_gpSet = VK_NULL_HANDLE;
VkDescriptorSet m_cpSet = VK_NULL_HANDLE;
DxvkBindingSet<MaxNumVertexBindings + 1> m_vbTracked;
DxvkBindingSet<MaxNumResourceSlots> m_rcTracked;
@ -1225,15 +1222,6 @@ namespace dxvk {
void updateComputeShaderResources();
void updateGraphicsShaderResources();
template<VkPipelineBindPoint BindPoint>
void updateShaderResources(
const DxvkPipelineLayout* layout);
template<VkPipelineBindPoint BindPoint>
void updateShaderDescriptorSetBinding(
VkDescriptorSet set,
const DxvkPipelineLayout* layout);
DxvkFramebufferInfo makeFramebufferInfo(
const DxvkRenderTargets& renderTargets);