From 81b4ed2a81d7bada71a115efc7fb2347378fb975 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 20 Jul 2017 15:25:35 +1000 Subject: Vulkan: Uber shader support --- Source/Core/VideoBackends/Vulkan/Util.cpp | 40 ++++++++++++++++--------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'Source/Core/VideoBackends/Vulkan/Util.cpp') diff --git a/Source/Core/VideoBackends/Vulkan/Util.cpp b/Source/Core/VideoBackends/Vulkan/Util.cpp index f1f4f42b1b..fc5b2ec8dc 100644 --- a/Source/Core/VideoBackends/Vulkan/Util.cpp +++ b/Source/Core/VideoBackends/Vulkan/Util.cpp @@ -575,8 +575,7 @@ void UtilityShaderDraw::BindDescriptors() { // TODO: This method is a mess, clean it up std::array bind_descriptor_sets = {}; - std::array - set_writes = {}; + std::array set_writes = {}; uint32_t num_set_writes = 0; VkDescriptorBufferInfo dummy_uniform_buffer = { @@ -633,29 +632,32 @@ void UtilityShaderDraw::BindDescriptors() // Check if we have any at all, skip the binding process entirely if we don't if (first_active_sampler != NUM_PIXEL_SHADER_SAMPLERS) { + // We need to fill it with non-empty images. + for (size_t i = 0; i < NUM_PIXEL_SHADER_SAMPLERS; i++) + { + if (m_ps_samplers[i].imageView == VK_NULL_HANDLE) + { + m_ps_samplers[i].imageView = g_object_cache->GetDummyImageView(); + m_ps_samplers[i].sampler = g_object_cache->GetPointSampler(); + } + } + // Allocate a new descriptor set VkDescriptorSet set = g_command_buffer_mgr->AllocateDescriptorSet( g_object_cache->GetDescriptorSetLayout(DESCRIPTOR_SET_LAYOUT_PIXEL_SHADER_SAMPLERS)); if (set == VK_NULL_HANDLE) PanicAlert("Failed to allocate descriptor set for utility draw"); - for (size_t i = 0; i < NUM_PIXEL_SHADER_SAMPLERS; i++) - { - const VkDescriptorImageInfo& info = m_ps_samplers[i]; - if (info.imageView != VK_NULL_HANDLE && info.sampler != VK_NULL_HANDLE) - { - set_writes[num_set_writes++] = {VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, - nullptr, - set, - static_cast(i), - 0, - 1, - VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, - &info, - nullptr, - nullptr}; - } - } + set_writes[num_set_writes++] = {VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, + nullptr, + set, + 0, + 0, + static_cast(NUM_PIXEL_SHADER_SAMPLERS), + VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, + m_ps_samplers.data(), + nullptr, + nullptr}; bind_descriptor_sets[DESCRIPTOR_SET_BIND_POINT_PIXEL_SHADER_SAMPLERS] = set; } -- cgit v1.2.3