From cda08ff82612654eace1375ce7d69b9b570fc3e1 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 21 Feb 2016 17:17:57 -0800 Subject: [PATCH] Setup descriptor set for textures. --- src/xenia/gpu/vulkan/texture_cache.cc | 39 +++++++++++-------- .../gpu/vulkan/vulkan_command_processor.cc | 9 +++-- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/xenia/gpu/vulkan/texture_cache.cc b/src/xenia/gpu/vulkan/texture_cache.cc index ea051ca52..2a67f1727 100644 --- a/src/xenia/gpu/vulkan/texture_cache.cc +++ b/src/xenia/gpu/vulkan/texture_cache.cc @@ -34,10 +34,12 @@ TextureCache::TextureCache(RegisterFile* register_file, descriptor_pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT; descriptor_pool_info.maxSets = 256; - VkDescriptorPoolSize pool_sizes[1]; - pool_sizes[0].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - pool_sizes[0].descriptorCount = 256; - descriptor_pool_info.poolSizeCount = 1; + VkDescriptorPoolSize pool_sizes[2]; + pool_sizes[0].type = VK_DESCRIPTOR_TYPE_SAMPLER; + pool_sizes[0].descriptorCount = 32; + pool_sizes[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; + pool_sizes[1].descriptorCount = 32; + descriptor_pool_info.poolSizeCount = 2; descriptor_pool_info.pPoolSizes = pool_sizes; auto err = vkCreateDescriptorPool(device_, &descriptor_pool_info, nullptr, &descriptor_pool_); @@ -45,24 +47,29 @@ TextureCache::TextureCache(RegisterFile* register_file, // Create the descriptor set layout used for rendering. // We always have the same number of samplers but only some are used. - VkDescriptorSetLayoutBinding texture_bindings[1]; - for (int i = 0; i < 1; ++i) { - auto& texture_binding = texture_bindings[i]; - texture_binding.binding = 0; - texture_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; - texture_binding.descriptorCount = kMaxTextureSamplers; - texture_binding.stageFlags = - VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT; - texture_binding.pImmutableSamplers = nullptr; - } + VkDescriptorSetLayoutBinding bindings[2]; + auto& sampler_binding = bindings[0]; + sampler_binding.binding = 0; + sampler_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; + sampler_binding.descriptorCount = kMaxTextureSamplers; + sampler_binding.stageFlags = + VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT; + sampler_binding.pImmutableSamplers = nullptr; + auto& texture_binding = bindings[1]; + texture_binding.binding = 1; + texture_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; + texture_binding.descriptorCount = kMaxTextureSamplers; + texture_binding.stageFlags = + VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT; + texture_binding.pImmutableSamplers = nullptr; VkDescriptorSetLayoutCreateInfo descriptor_set_layout_info; descriptor_set_layout_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; descriptor_set_layout_info.pNext = nullptr; descriptor_set_layout_info.flags = 0; descriptor_set_layout_info.bindingCount = - static_cast(xe::countof(texture_bindings)); - descriptor_set_layout_info.pBindings = texture_bindings; + static_cast(xe::countof(bindings)); + descriptor_set_layout_info.pBindings = bindings; err = vkCreateDescriptorSetLayout(device_, &descriptor_set_layout_info, nullptr, &texture_descriptor_set_layout_); CheckResult(err, "vkCreateDescriptorSetLayout"); diff --git a/src/xenia/gpu/vulkan/vulkan_command_processor.cc b/src/xenia/gpu/vulkan/vulkan_command_processor.cc index e568df482..723fa8d07 100644 --- a/src/xenia/gpu/vulkan/vulkan_command_processor.cc +++ b/src/xenia/gpu/vulkan/vulkan_command_processor.cc @@ -484,7 +484,8 @@ bool VulkanCommandProcessor::PopulateSamplers(VkCommandBuffer command_buffer, continue; } has_setup_sampler[texture_binding.fetch_constant] = true; - any_failed = PopulateSampler(command_buffer, texture_binding) || any_failed; + any_failed = + !PopulateSampler(command_buffer, texture_binding) || any_failed; } // Pixel shader texture sampler. @@ -493,7 +494,8 @@ bool VulkanCommandProcessor::PopulateSamplers(VkCommandBuffer command_buffer, continue; } has_setup_sampler[texture_binding.fetch_constant] = true; - any_failed = PopulateSampler(command_buffer, texture_binding) || any_failed; + any_failed = + !PopulateSampler(command_buffer, texture_binding) || any_failed; } return !any_failed; @@ -508,7 +510,8 @@ bool VulkanCommandProcessor::PopulateSampler( auto group = reinterpret_cast(®s.values[r]); auto& fetch = group->texture_fetch; - // ? + // Disabled? + // TODO(benvanik): reset sampler. if (!fetch.type) { return true; }