From 730bf504f81489d980ee74c42d69fb3c7510abf0 Mon Sep 17 00:00:00 2001 From: PixelyIon Date: Mon, 7 Mar 2022 16:44:08 +0530 Subject: [PATCH] Correct Adreno texture binding quirk We incorrectly determined an Adreno driver bug to require padding between binding slots but the real issue was not supporting consecutive binding writes for `VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER` and was fixed by the padding slot unintentionally requiring individual writes. The quirk has now been corrected to explicitly specify this as the bug and the solution is more apt. --- .../main/cpp/skyline/gpu/interconnect/graphics_context.h | 8 +++++--- app/src/main/cpp/skyline/gpu/trait_manager.cpp | 6 +++--- app/src/main/cpp/skyline/gpu/trait_manager.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h b/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h index fa5ed18d..51154475 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/graphics_context.h @@ -932,16 +932,18 @@ namespace skyline::gpu::interconnect { } if (!program.info.texture_descriptors.empty()) { - if (!gpu.traits.quirks.needsTextureBindingPadding) + if (!gpu.traits.quirks.needsIndividualTextureBindingWrites) descriptorSetWrites.push_back(vk::WriteDescriptorSet{ .dstBinding = bindingIndex, .descriptorCount = static_cast(program.info.texture_descriptors.size()), .descriptorType = vk::DescriptorType::eCombinedImageSampler, .pImageInfo = imageInfo.data() + imageInfo.size(), }); + else + descriptorSetWrites.reserve(descriptorSetWrites.size() + program.info.texture_descriptors.size()); for (auto &texture : program.info.texture_descriptors) { - if (gpu.traits.quirks.needsTextureBindingPadding) + if (gpu.traits.quirks.needsIndividualTextureBindingWrites) descriptorSetWrites.push_back(vk::WriteDescriptorSet{ .dstBinding = bindingIndex, .descriptorCount = 1, @@ -952,7 +954,7 @@ namespace skyline::gpu::interconnect { layoutBindings.push_back(vk::DescriptorSetLayoutBinding{ .binding = bindingIndex++, .descriptorType = vk::DescriptorType::eCombinedImageSampler, - .descriptorCount = gpu.traits.quirks.needsTextureBindingPadding ? 1U : 2U, + .descriptorCount = 1, .stageFlags = pipelineStage.vkStage, }); diff --git a/app/src/main/cpp/skyline/gpu/trait_manager.cpp b/app/src/main/cpp/skyline/gpu/trait_manager.cpp index b1bd53f4..e55889aa 100644 --- a/app/src/main/cpp/skyline/gpu/trait_manager.cpp +++ b/app/src/main/cpp/skyline/gpu/trait_manager.cpp @@ -130,7 +130,7 @@ namespace skyline::gpu { TraitManager::QuirkManager::QuirkManager(const vk::PhysicalDeviceProperties &deviceProperties, const vk::PhysicalDeviceDriverProperties &driverProperties) { switch (driverProperties.driverID) { case vk::DriverId::eQualcommProprietary: { - needsTextureBindingPadding = true; + needsIndividualTextureBindingWrites = true; break; } @@ -141,8 +141,8 @@ namespace skyline::gpu { std::string TraitManager::QuirkManager::Summary() { return fmt::format( - "\n* Needs Texture Binding Padding: {}", - needsTextureBindingPadding + "\n* Needs Individual Texture Binding Writes: {}", + needsIndividualTextureBindingWrites ); } diff --git a/app/src/main/cpp/skyline/gpu/trait_manager.h b/app/src/main/cpp/skyline/gpu/trait_manager.h index 09e7bc73..a69c693d 100644 --- a/app/src/main/cpp/skyline/gpu/trait_manager.h +++ b/app/src/main/cpp/skyline/gpu/trait_manager.h @@ -39,7 +39,7 @@ namespace skyline::gpu { * @brief Manages a list of any vendor/device-specific errata in the host GPU */ struct QuirkManager { - bool needsTextureBindingPadding{}; //!< [Adreno Proprietary] A bug that requires a padding descriptor slot for VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER + bool needsIndividualTextureBindingWrites{}; //!< [Adreno Proprietary] A bug that requires descriptor set writes for VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER to be done individually with descriptorCount = 1 rather than batched QuirkManager() = default;