Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b62df5d authored by Chris Forbes's avatar Chris Forbes
Browse files

libvulkan: Check whether gralloc can do protected content

Certain devices don't support protected allocations at the gralloc level; having libvulkan claim they are supported leads to problems later when an app attempts to create a protected swapchain

Bug: b/416472139
Flag: EXEMPT bugfix
Test: atest CtsDeqpTestCases -- --module-arg CtsDeqpTestCases:include-filter:dEQP-VK.protected_memory.interaction.wsi.android.swapchain.render.basic

Change-Id: I952a205bb98694b746255132dc98988be98d5f19
parent a66a551a
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -1071,7 +1071,18 @@ VkResult GetPhysicalDeviceSurfaceCapabilities2KHR(
            case VK_STRUCTURE_TYPE_SURFACE_PROTECTED_CAPABILITIES_KHR: {
                VkSurfaceProtectedCapabilitiesKHR* protected_caps =
                    reinterpret_cast<VkSurfaceProtectedCapabilitiesKHR*>(pNext);
                protected_caps->supportsProtected = VK_TRUE;

                // Check if the device's gralloc can support protected content
                AHardwareBuffer_Desc desc = {
                    .width = 1,
                    .height = 1,
                    .layers = 1,
                    .format = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM,
                    .usage = AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER | AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
                        AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT
                };

                protected_caps->supportsProtected = AHardwareBuffer_isSupported(&desc) ? VK_TRUE : VK_FALSE;
            } break;

            case VK_STRUCTURE_TYPE_SURFACE_PRESENT_SCALING_CAPABILITIES_EXT: {