From 981ea06a9736b0c1ad497946bb22adef379e25b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Tue, 13 Aug 2019 19:22:46 -0700 Subject: [PATCH] Cleanup. --- src/renderer_vk.cpp | 30 +++++++++++++++--------------- src/renderer_vk.h | 16 +++++++++++----- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index 0e8f06837..0bcb201a8 100644 --- a/src/renderer_vk.cpp +++ b/src/renderer_vk.cpp @@ -3210,7 +3210,7 @@ VK_IMPORT_DEVICE } resolveAr[ii].attachment = VK_ATTACHMENT_UNUSED; - resolveAr[ii].layout = ad[ii].initialLayout; // TODO: should know hot to set it appropriately + resolveAr[ii].layout = ad[ii].initialLayout; } VkSubpassDescription sd[1]; @@ -4376,9 +4376,9 @@ VK_DESTROY for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++ii) { - m_bindInfo[ii].uniformHandle = {kInvalidHandle}; - m_bindInfo[ii].type = UNKNOWN; - m_bindInfo[ii].binding = 0; + m_bindInfo[ii].uniformHandle = BGFX_INVALID_HANDLE; + m_bindInfo[ii].type = BindType::Count; + m_bindInfo[ii].binding = 0; m_bindInfo[ii].samplerBinding = 0; } @@ -4418,10 +4418,10 @@ VK_DESTROY } else if (UniformType::End == (~BGFX_UNIFORM_MASK & type)) { - m_bindInfo[num].uniformHandle = {0}; - m_bindInfo[num].type = STORAGE; - m_bindInfo[num].binding = regCount; // regCount is used for buffer binding index - m_bindInfo[num].samplerBinding = regIndex; // regIndex is used for descriptor type + m_bindInfo[num].uniformHandle = { 0 }; + m_bindInfo[num].type = BindType::Storage; + m_bindInfo[num].binding = regCount; // regCount is used for buffer binding index + m_bindInfo[num].samplerBinding = regIndex; // regIndex is used for descriptor type kind = "storage"; } @@ -4430,10 +4430,10 @@ VK_DESTROY const UniformRegInfo* info = s_renderVK->m_uniformReg.find(name); BX_CHECK(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name); - m_bindInfo[num].uniformHandle = info->m_handle; - m_bindInfo[num].type = SAMPLER; - m_bindInfo[num].binding = regIndex; // regIndex is used for image binding index - m_bindInfo[num].samplerBinding = regCount; // regCount is used for sampler binding index + m_bindInfo[num].uniformHandle = info->m_handle; + m_bindInfo[num].type = BindType::Sampler; + m_bindInfo[num].binding = regIndex; // regIndex is used for image binding index + m_bindInfo[num].samplerBinding = regCount; // regCount is used for sampler binding index kind = "sampler"; } @@ -4546,7 +4546,7 @@ VK_DESTROY { switch (m_bindInfo[ii].type) { - case STORAGE: + case BindType::Storage: m_bindings[bidx].stageFlags = VK_SHADER_STAGE_ALL; m_bindings[bidx].descriptorType = (VkDescriptorType)m_bindInfo[ii].samplerBinding; m_bindings[bidx].binding = m_bindInfo[ii].binding; @@ -4555,7 +4555,7 @@ VK_DESTROY bidx++; break; - case SAMPLER: + case BindType::Sampler: m_bindings[bidx].stageFlags = VK_SHADER_STAGE_ALL; m_bindings[bidx].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; m_bindings[bidx].binding = m_bindInfo[ii].binding; @@ -4570,7 +4570,7 @@ VK_DESTROY m_bindings[bidx].descriptorCount = 1; bidx++; break; - + default: break; } diff --git a/src/renderer_vk.h b/src/renderer_vk.h index a351c2d91..98605242a 100644 --- a/src/renderer_vk.h +++ b/src/renderer_vk.h @@ -414,19 +414,25 @@ VK_DESTROY uint8_t m_numPredefined; uint8_t m_numAttrs; - enum BindType + struct BindType { - UNKNOWN, - STORAGE, - SAMPLER, + enum Enum + { + Storage, + Sampler, + + Count + }; }; + struct BindInfo { UniformHandle uniformHandle; - BindType type; + BindType::Enum type; uint32_t binding; uint32_t samplerBinding; }; + BindInfo m_bindInfo[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS]; uint32_t m_uniformBinding; uint16_t m_numBindings;