Setup descriptor set for textures.
This commit is contained in:
parent
1def5bece9
commit
cda08ff826
|
@ -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<uint32_t>(xe::countof(texture_bindings));
|
||||
descriptor_set_layout_info.pBindings = texture_bindings;
|
||||
static_cast<uint32_t>(xe::countof(bindings));
|
||||
descriptor_set_layout_info.pBindings = bindings;
|
||||
err = vkCreateDescriptorSetLayout(device_, &descriptor_set_layout_info,
|
||||
nullptr, &texture_descriptor_set_layout_);
|
||||
CheckResult(err, "vkCreateDescriptorSetLayout");
|
||||
|
|
|
@ -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<const xe_gpu_fetch_group_t*>(®s.values[r]);
|
||||
auto& fetch = group->texture_fetch;
|
||||
|
||||
// ?
|
||||
// Disabled?
|
||||
// TODO(benvanik): reset sampler.
|
||||
if (!fetch.type) {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue