Vulkan: Emit a warning if the physical device is unable to support texture cache requirements

This commit is contained in:
DrChat 2017-02-12 21:24:38 -06:00
parent ba8e315a69
commit 7a9c33fcfe
1 changed files with 17 additions and 1 deletions

View File

@ -123,10 +123,25 @@ TextureCache::TextureCache(Memory* memory, RegisterFile* register_file,
*device_, 32768, *device_, 32768,
std::vector<VkDescriptorPoolSize>(pool_sizes, std::end(pool_sizes))); std::vector<VkDescriptorPoolSize>(pool_sizes, std::end(pool_sizes)));
// Check some device limits
// On low sampler counts: Rarely would we experience over 16 unique samplers.
// This code could be refactored to scale up/down to the # of samplers.
auto& limits = device_->device_info().properties.limits;
if (limits.maxPerStageDescriptorSamplers < kMaxTextureSamplers * 4 ||
limits.maxPerStageDescriptorSampledImages < kMaxTextureSamplers * 4) {
XELOGE(
"Physical device is unable to support required number of sampled "
"images! Expect instability! (maxPerStageDescriptorSamplers=%d, "
"maxPerStageDescriptorSampledImages=%d)",
limits.maxPerStageDescriptorSamplers,
limits.maxPerStageDescriptorSampledImages);
assert_always();
}
// 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 bindings[4]; VkDescriptorSetLayoutBinding bindings[4];
for (int i = 0; i < 4; ++i) { for (int i = 0; i < xe::countof(bindings); ++i) {
auto& texture_binding = bindings[i]; auto& texture_binding = bindings[i];
texture_binding.binding = i; texture_binding.binding = i;
texture_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; texture_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
@ -135,6 +150,7 @@ TextureCache::TextureCache(Memory* memory, RegisterFile* register_file,
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT; VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT;
texture_binding.pImmutableSamplers = nullptr; 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;