mirror of
https://github.com/xenia-project/xenia.git
synced 2025-12-06 07:12:03 +01:00
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 =
|
descriptor_pool_info.flags =
|
||||||
VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
|
VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
|
||||||
descriptor_pool_info.maxSets = 256;
|
descriptor_pool_info.maxSets = 256;
|
||||||
VkDescriptorPoolSize pool_sizes[1];
|
VkDescriptorPoolSize pool_sizes[2];
|
||||||
pool_sizes[0].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
pool_sizes[0].type = VK_DESCRIPTOR_TYPE_SAMPLER;
|
||||||
pool_sizes[0].descriptorCount = 256;
|
pool_sizes[0].descriptorCount = 32;
|
||||||
descriptor_pool_info.poolSizeCount = 1;
|
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;
|
descriptor_pool_info.pPoolSizes = pool_sizes;
|
||||||
auto err = vkCreateDescriptorPool(device_, &descriptor_pool_info, nullptr,
|
auto err = vkCreateDescriptorPool(device_, &descriptor_pool_info, nullptr,
|
||||||
&descriptor_pool_);
|
&descriptor_pool_);
|
||||||
|
|
@ -45,24 +47,29 @@ TextureCache::TextureCache(RegisterFile* register_file,
|
||||||
|
|
||||||
// Create the descriptor set layout used for rendering.
|
// Create the descriptor set layout used for rendering.
|
||||||
// We always have the same number of samplers but only some are used.
|
// We always have the same number of samplers but only some are used.
|
||||||
VkDescriptorSetLayoutBinding texture_bindings[1];
|
VkDescriptorSetLayoutBinding bindings[2];
|
||||||
for (int i = 0; i < 1; ++i) {
|
auto& sampler_binding = bindings[0];
|
||||||
auto& texture_binding = texture_bindings[i];
|
sampler_binding.binding = 0;
|
||||||
texture_binding.binding = 0;
|
sampler_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;
|
||||||
texture_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
|
sampler_binding.descriptorCount = kMaxTextureSamplers;
|
||||||
texture_binding.descriptorCount = kMaxTextureSamplers;
|
sampler_binding.stageFlags =
|
||||||
texture_binding.stageFlags =
|
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||||
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT;
|
sampler_binding.pImmutableSamplers = nullptr;
|
||||||
texture_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;
|
VkDescriptorSetLayoutCreateInfo descriptor_set_layout_info;
|
||||||
descriptor_set_layout_info.sType =
|
descriptor_set_layout_info.sType =
|
||||||
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||||
descriptor_set_layout_info.pNext = nullptr;
|
descriptor_set_layout_info.pNext = nullptr;
|
||||||
descriptor_set_layout_info.flags = 0;
|
descriptor_set_layout_info.flags = 0;
|
||||||
descriptor_set_layout_info.bindingCount =
|
descriptor_set_layout_info.bindingCount =
|
||||||
static_cast<uint32_t>(xe::countof(texture_bindings));
|
static_cast<uint32_t>(xe::countof(bindings));
|
||||||
descriptor_set_layout_info.pBindings = texture_bindings;
|
descriptor_set_layout_info.pBindings = bindings;
|
||||||
err = vkCreateDescriptorSetLayout(device_, &descriptor_set_layout_info,
|
err = vkCreateDescriptorSetLayout(device_, &descriptor_set_layout_info,
|
||||||
nullptr, &texture_descriptor_set_layout_);
|
nullptr, &texture_descriptor_set_layout_);
|
||||||
CheckResult(err, "vkCreateDescriptorSetLayout");
|
CheckResult(err, "vkCreateDescriptorSetLayout");
|
||||||
|
|
|
||||||
|
|
@ -484,7 +484,8 @@ bool VulkanCommandProcessor::PopulateSamplers(VkCommandBuffer command_buffer,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
has_setup_sampler[texture_binding.fetch_constant] = true;
|
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.
|
// Pixel shader texture sampler.
|
||||||
|
|
@ -493,7 +494,8 @@ bool VulkanCommandProcessor::PopulateSamplers(VkCommandBuffer command_buffer,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
has_setup_sampler[texture_binding.fetch_constant] = true;
|
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;
|
return !any_failed;
|
||||||
|
|
@ -508,7 +510,8 @@ bool VulkanCommandProcessor::PopulateSampler(
|
||||||
auto group = reinterpret_cast<const xe_gpu_fetch_group_t*>(®s.values[r]);
|
auto group = reinterpret_cast<const xe_gpu_fetch_group_t*>(®s.values[r]);
|
||||||
auto& fetch = group->texture_fetch;
|
auto& fetch = group->texture_fetch;
|
||||||
|
|
||||||
// ?
|
// Disabled?
|
||||||
|
// TODO(benvanik): reset sampler.
|
||||||
if (!fetch.type) {
|
if (!fetch.type) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue