From f42f708f7257bccc18440e7de86a3407d0a3385a Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 17 Sep 2018 10:40:57 +0200 Subject: [PATCH] [dxvk] Rename DxvkBindingState -> DxvkBindingMask Preparation for some more binding-related work. --- src/dxvk/{dxvk_binding.h => dxvk_bind_mask.h} | 4 +- src/dxvk/dxvk_cmdlist.h | 2 +- src/dxvk/dxvk_compute.cpp | 2 +- src/dxvk/dxvk_compute.h | 4 +- src/dxvk/dxvk_context.cpp | 39 ++++++++----------- src/dxvk/dxvk_context.h | 4 +- src/dxvk/dxvk_graphics.cpp | 2 +- src/dxvk/dxvk_graphics.h | 4 +- 8 files changed, 28 insertions(+), 33 deletions(-) rename src/dxvk/{dxvk_binding.h => dxvk_bind_mask.h} (97%) diff --git a/src/dxvk/dxvk_binding.h b/src/dxvk/dxvk_bind_mask.h similarity index 97% rename from src/dxvk/dxvk_binding.h rename to src/dxvk/dxvk_bind_mask.h index c044d818..bba3b520 100644 --- a/src/dxvk/dxvk_binding.h +++ b/src/dxvk/dxvk_bind_mask.h @@ -9,14 +9,14 @@ namespace dxvk { /** - * \brief Binding state + * \brief Binding mask * * Used to track which resource slots have a compatible * binding and which ones don't. This is used to set up * binding-related specialization constants in shaders. * \tparam N Number of binding slots */ - class DxvkBindingState { + class DxvkBindingMask { constexpr static uint32_t BitCount = 32; constexpr static uint32_t IntCount = (MaxNumActiveBindings + BitCount - 1) / BitCount; public: diff --git a/src/dxvk/dxvk_cmdlist.h b/src/dxvk/dxvk_cmdlist.h index a1e3d6ad..1eadf5d7 100644 --- a/src/dxvk/dxvk_cmdlist.h +++ b/src/dxvk/dxvk_cmdlist.h @@ -2,7 +2,7 @@ #include -#include "dxvk_binding.h" +#include "dxvk_bind_mask.h" #include "dxvk_buffer.h" #include "dxvk_descriptor.h" #include "dxvk_event_tracker.h" diff --git a/src/dxvk/dxvk_compute.cpp b/src/dxvk/dxvk_compute.cpp index 6e597ee7..be6439b9 100644 --- a/src/dxvk/dxvk_compute.cpp +++ b/src/dxvk/dxvk_compute.cpp @@ -107,7 +107,7 @@ namespace dxvk { DxvkSpecConstantData specData; for (uint32_t i = 0; i < MaxNumActiveBindings; i++) - specData.activeBindings[i] = state.bsBindingState.isBound(i) ? VK_TRUE : VK_FALSE; + specData.activeBindings[i] = state.bsBindingMask.isBound(i) ? VK_TRUE : VK_FALSE; VkSpecializationInfo specInfo; specInfo.mapEntryCount = g_specConstantMap.mapEntryCount(); diff --git a/src/dxvk/dxvk_compute.h b/src/dxvk/dxvk_compute.h index 38049e74..4fcedab2 100644 --- a/src/dxvk/dxvk_compute.h +++ b/src/dxvk/dxvk_compute.h @@ -2,7 +2,7 @@ #include -#include "dxvk_binding.h" +#include "dxvk_bind_mask.h" #include "dxvk_pipecache.h" #include "dxvk_pipelayout.h" #include "dxvk_resource.h" @@ -20,7 +20,7 @@ namespace dxvk { bool operator == (const DxvkComputePipelineStateInfo& other) const; bool operator != (const DxvkComputePipelineStateInfo& other) const; - DxvkBindingState bsBindingState; + DxvkBindingMask bsBindingMask; }; diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index a5eaec30..7c37a131 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -1902,7 +1902,7 @@ namespace dxvk { if (m_flags.test(DxvkContextFlag::CpDirtyPipeline)) { m_flags.clr(DxvkContextFlag::CpDirtyPipeline); - m_state.cp.state.bsBindingState.clear(); + m_state.cp.state.bsBindingMask.clear(); m_state.cp.pipeline = m_pipeMgr->createComputePipeline(m_state.cp.cs.shader); if (m_state.cp.pipeline != nullptr) @@ -1944,7 +1944,7 @@ namespace dxvk { if (m_flags.test(DxvkContextFlag::GpDirtyPipeline)) { m_flags.clr(DxvkContextFlag::GpDirtyPipeline); - m_state.gp.state.bsBindingState.clear(); + m_state.gp.state.bsBindingMask.clear(); m_state.gp.pipeline = m_pipeMgr->createGraphicsPipeline( m_state.gp.vs.shader, m_state.gp.tcs.shader, m_state.gp.tes.shader, @@ -2003,6 +2003,7 @@ namespace dxvk { this->updateShaderResources( VK_PIPELINE_BIND_POINT_COMPUTE, + m_state.cp.state.bsBindingMask, m_state.cp.pipeline->layout()); m_flags.set( @@ -2019,7 +2020,6 @@ namespace dxvk { if (m_flags.test(DxvkContextFlag::CpDirtyDescriptorSet)) { m_cpSet = this->updateShaderDescriptors( VK_PIPELINE_BIND_POINT_COMPUTE, - m_state.cp.state.bsBindingState, m_state.cp.pipeline->layout()); } @@ -2046,6 +2046,7 @@ namespace dxvk { this->updateShaderResources( VK_PIPELINE_BIND_POINT_GRAPHICS, + m_state.gp.state.bsBindingMask, m_state.gp.pipeline->layout()); m_flags.set( @@ -2062,7 +2063,6 @@ namespace dxvk { if (m_flags.test(DxvkContextFlag::GpDirtyDescriptorSet)) { m_gpSet = this->updateShaderDescriptors( VK_PIPELINE_BIND_POINT_GRAPHICS, - m_state.gp.state.bsBindingState, m_state.gp.pipeline->layout()); } @@ -2080,12 +2080,8 @@ namespace dxvk { void DxvkContext::updateShaderResources( VkPipelineBindPoint bindPoint, + DxvkBindingMask& bindMask, const DxvkPipelineLayout* layout) { - DxvkBindingState& bindingState = - bindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS - ? m_state.gp.state.bsBindingState - : m_state.cp.state.bsBindingState; - bool updatePipelineState = false; DxvkAttachment depthAttachment; @@ -2100,7 +2096,7 @@ namespace dxvk { switch (binding.type) { case VK_DESCRIPTOR_TYPE_SAMPLER: if (res.sampler != nullptr) { - updatePipelineState |= bindingState.setBound(i); + updatePipelineState |= bindMask.setBound(i); m_descInfos[i].image.sampler = res.sampler->handle(); m_descInfos[i].image.imageView = VK_NULL_HANDLE; @@ -2108,14 +2104,14 @@ namespace dxvk { m_cmd->trackResource(res.sampler); } else { - updatePipelineState |= bindingState.setUnbound(i); + updatePipelineState |= bindMask.setUnbound(i); m_descInfos[i].image = m_device->dummySamplerDescriptor(); } break; case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: if (res.imageView != nullptr && res.imageView->handle(binding.view) != VK_NULL_HANDLE) { - updatePipelineState |= bindingState.setBound(i); + updatePipelineState |= bindMask.setBound(i); m_descInfos[i].image.sampler = VK_NULL_HANDLE; m_descInfos[i].image.imageView = res.imageView->handle(binding.view); @@ -2128,14 +2124,14 @@ namespace dxvk { m_cmd->trackResource(res.imageView); m_cmd->trackResource(res.imageView->image()); } else { - updatePipelineState |= bindingState.setUnbound(i); + updatePipelineState |= bindMask.setUnbound(i); m_descInfos[i].image = m_device->dummyImageViewDescriptor(binding.view); } break; case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: if (res.bufferView != nullptr) { - updatePipelineState |= bindingState.setBound(i); + updatePipelineState |= bindMask.setBound(i); res.bufferView->updateView(); m_descInfos[i].texelBuffer = res.bufferView->handle(); @@ -2143,14 +2139,14 @@ namespace dxvk { m_cmd->trackResource(res.bufferView->viewResource()); m_cmd->trackResource(res.bufferView->bufferResource()); } else { - updatePipelineState |= bindingState.setUnbound(i); + updatePipelineState |= bindMask.setUnbound(i); m_descInfos[i].texelBuffer = m_device->dummyBufferViewDescriptor(); } break; case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: if (res.bufferSlice.defined()) { - updatePipelineState |= bindingState.setBound(i); + updatePipelineState |= bindMask.setBound(i); auto physicalSlice = res.bufferSlice.physicalSlice(); m_descInfos[i].buffer.buffer = physicalSlice.handle(); @@ -2159,14 +2155,14 @@ namespace dxvk { m_cmd->trackResource(physicalSlice.resource()); } else { - updatePipelineState |= bindingState.setUnbound(i); + updatePipelineState |= bindMask.setUnbound(i); m_descInfos[i].buffer = m_device->dummyBufferDescriptor(); } break; case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: if (res.bufferSlice.defined()) { - updatePipelineState |= bindingState.setBound(i); + updatePipelineState |= bindMask.setBound(i); auto physicalSlice = res.bufferSlice.physicalSlice(); m_descInfos[i].buffer.buffer = physicalSlice.handle(); @@ -2175,7 +2171,7 @@ namespace dxvk { m_cmd->trackResource(physicalSlice.resource()); } else { - updatePipelineState |= bindingState.setUnbound(i); + updatePipelineState |= bindMask.setUnbound(i); m_descInfos[i].buffer = m_device->dummyBufferDescriptor(); } break; @@ -2194,7 +2190,6 @@ namespace dxvk { VkDescriptorSet DxvkContext::updateShaderDescriptors( VkPipelineBindPoint bindPoint, - const DxvkBindingState& bindingState, const DxvkPipelineLayout* layout) { VkDescriptorSet descriptorSet = VK_NULL_HANDLE; @@ -2411,7 +2406,7 @@ namespace dxvk { bool requiresBarrier = false; for (uint32_t i = 0; i < layout->bindingCount() && !requiresBarrier; i++) { - if (m_state.cp.state.bsBindingState.isBound(i)) { + if (m_state.cp.state.bsBindingMask.isBound(i)) { const DxvkDescriptorSlot binding = layout->binding(i); const DxvkShaderResourceSlot& slot = m_rc[binding.slot]; @@ -2464,7 +2459,7 @@ namespace dxvk { auto layout = m_state.cp.pipeline->layout(); for (uint32_t i = 0; i < layout->bindingCount(); i++) { - if (m_state.cp.state.bsBindingState.isBound(i)) { + if (m_state.cp.state.bsBindingMask.isBound(i)) { const DxvkDescriptorSlot binding = layout->binding(i); const DxvkShaderResourceSlot& slot = m_rc[binding.slot]; diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index c49234cc..58281a04 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -1,7 +1,7 @@ #pragma once #include "dxvk_barrier.h" -#include "dxvk_binding.h" +#include "dxvk_bind_mask.h" #include "dxvk_cmdlist.h" #include "dxvk_context_state.h" #include "dxvk_data.h" @@ -701,11 +701,11 @@ namespace dxvk { void updateShaderResources( VkPipelineBindPoint bindPoint, + DxvkBindingMask& bindMask, const DxvkPipelineLayout* layout); VkDescriptorSet updateShaderDescriptors( VkPipelineBindPoint bindPoint, - const DxvkBindingState& bindingState, const DxvkPipelineLayout* layout); void updateShaderDescriptorSetBinding( diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index 08f25517..855e81bb 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -165,7 +165,7 @@ namespace dxvk { specData.rasterizerSampleCount = uint32_t(state.msSampleCount); for (uint32_t i = 0; i < MaxNumActiveBindings; i++) - specData.activeBindings[i] = state.bsBindingState.isBound(i) ? VK_TRUE : VK_FALSE; + specData.activeBindings[i] = state.bsBindingMask.isBound(i) ? VK_TRUE : VK_FALSE; VkSpecializationInfo specInfo; specInfo.mapEntryCount = g_specConstantMap.mapEntryCount(); diff --git a/src/dxvk/dxvk_graphics.h b/src/dxvk/dxvk_graphics.h index 03155bf1..aec66bda 100644 --- a/src/dxvk/dxvk_graphics.h +++ b/src/dxvk/dxvk_graphics.h @@ -2,7 +2,7 @@ #include -#include "dxvk_binding.h" +#include "dxvk_bind_mask.h" #include "dxvk_constant_state.h" #include "dxvk_pipecache.h" #include "dxvk_pipelayout.h" @@ -34,7 +34,7 @@ namespace dxvk { bool operator == (const DxvkGraphicsPipelineStateInfo& other) const; bool operator != (const DxvkGraphicsPipelineStateInfo& other) const; - DxvkBindingState bsBindingState; + DxvkBindingMask bsBindingMask; VkPrimitiveTopology iaPrimitiveTopology; VkBool32 iaPrimitiveRestart;