From f9e6d8e23a871425255bbb2980257218da791a93 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 16 Jun 2022 13:17:49 +0200 Subject: [PATCH] [dxvk] Remove old resource update code --- src/dxvk/dxvk_context.cpp | 193 -------------------------------------- src/dxvk/dxvk_context.h | 12 --- 2 files changed, 205 deletions(-) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index b8063785..da05864f 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -4365,199 +4365,6 @@ namespace dxvk { } - template - void DxvkContext::updateShaderResources(const DxvkPipelineLayout* layout) { - std::array 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(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(res.imageView); - m_cmd->trackResource(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(res.imageView); - m_cmd->trackResource(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(res.sampler); - m_cmd->trackResource(res.imageView); - m_cmd->trackResource(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(res.bufferView); - m_cmd->trackResource(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(res.bufferView); - m_cmd->trackResource(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(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(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(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 - void DxvkContext::updateShaderDescriptorSetBinding( - VkDescriptorSet set, - const DxvkPipelineLayout* layout) { - if (set) { - std::array 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); diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index d5e41db6..62c331a7 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -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 m_vbTracked; DxvkBindingSet m_rcTracked; @@ -1225,15 +1222,6 @@ namespace dxvk { void updateComputeShaderResources(); void updateGraphicsShaderResources(); - template - void updateShaderResources( - const DxvkPipelineLayout* layout); - - template - void updateShaderDescriptorSetBinding( - VkDescriptorSet set, - const DxvkPipelineLayout* layout); - DxvkFramebufferInfo makeFramebufferInfo( const DxvkRenderTargets& renderTargets);