diff options
-rw-r--r-- | src/gpu/vk/GrVkCaps.h | 12 | ||||
-rw-r--r-- | src/gpu/vk/GrVkDescriptorSetManager.cpp | 5 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/gpu/vk/GrVkCaps.h b/src/gpu/vk/GrVkCaps.h index 44c26c244f..df9c0fb585 100644 --- a/src/gpu/vk/GrVkCaps.h +++ b/src/gpu/vk/GrVkCaps.h @@ -147,6 +147,18 @@ public: // Returns true if it supports ycbcr conversion for samplers bool supportsYcbcrConversion() const { return fSupportsYcbcrConversion; } + // Returns the number of descriptor slots used by immutable ycbcr VkImages. + // + // TODO: We should update this to return a count for a specific format or external format. We + // can use vkGetPhysicalDeviceImageFormatProperties2 with a + // VkSamplerYcbcrConversionImageFormatProperties to query this. However, right now that call + // does not support external android formats which is where the majority of ycbcr images are + // coming from. So for now we stay safe and always return 3 here which is the max value that the + // count could be for any format. + uint32_t ycbcrCombinedImageSamplerDescriptorCount() const { + return 3; + } + // Returns true if the device supports protected memory. bool supportsProtectedMemory() const { return fSupportsProtectedMemory; } diff --git a/src/gpu/vk/GrVkDescriptorSetManager.cpp b/src/gpu/vk/GrVkDescriptorSetManager.cpp index ae99342a19..14cb1b09ee 100644 --- a/src/gpu/vk/GrVkDescriptorSetManager.cpp +++ b/src/gpu/vk/GrVkDescriptorSetManager.cpp @@ -78,6 +78,7 @@ static bool get_layout_and_desc_count(GrVkGpu* gpu, uint32_t numBindings = visibilities.count(); std::unique_ptr<VkDescriptorSetLayoutBinding[]> dsSamplerBindings( new VkDescriptorSetLayoutBinding[numBindings]); + *descCountPerSet = 0; for (uint32_t i = 0; i < numBindings; ++i) { uint32_t visibility = visibilities[i]; dsSamplerBindings[i].binding = i; @@ -86,8 +87,10 @@ static bool get_layout_and_desc_count(GrVkGpu* gpu, dsSamplerBindings[i].stageFlags = visibility_to_vk_stage_flags(visibility); if (VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER == type) { if (immutableSamplers[i]) { + (*descCountPerSet) += gpu->vkCaps().ycbcrCombinedImageSamplerDescriptorCount(); dsSamplerBindings[i].pImmutableSamplers = immutableSamplers[i]->samplerPtr(); } else { + (*descCountPerSet)++; dsSamplerBindings[i].pImmutableSamplers = nullptr; } } @@ -117,8 +120,6 @@ static bool get_layout_and_desc_count(GrVkGpu* gpu, if (result != VK_SUCCESS) { return false; } - - *descCountPerSet = visibilities.count(); } else if (type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) { static constexpr int kUniformDescPerSet = 1; SkASSERT(kUniformDescPerSet == visibilities.count()); |