summaryrefslogtreecommitdiff
path: root/vulkan/libvulkan/swapchain.cpp
AgeCommit message (Collapse)Author
2025-02-21Extract GPDIFP2 getProducerUsage path to seperate function Tom Murphy
Extracting the GPDIFP2 logic to its own function makes it easier to exit early from the GPDIFP2 path when we need to fall back to the GetSwapchainGrallocUsage*ANDROID path. This change also fixes an issue where we would exit getProducerUsage early instead of falling back to the gralloc paths if GPDIFP2 would return an error when called with an unsupported format. Bug: 379230826 Test: atest libvulkan_test Flag: EXEMPT bugfix Change-Id: I42f1fe31e5e4a01c472a12854a1f4e989d2786dc
2024-08-30Merge "Implement the VK_KHR_swapchain_mutable_format device extension in the ↵ Tom Murphy
vulkan loader" into main
2024-08-27Fix GetPhysicalDeviceSurfaceFormats2KHR for compression control struct handling Tom Murphy
As per the spec, vkGetPhysicalDeviceImageFormatProperties2 may return VK_ERROR_FORMAT_NOT_SUPPORTED when an invalid combination of parameters appears in VkPhysicalDeviceImageFormatInfo2 pImageFormatInfo argument which is not handled by the loader. i.e.. loader doesn't loop through all surface formats Fix this by correctly handling vkGetPhysicalDeviceImageFormatProperties2 return value Test: Working separately on testing strategy for this: 361626599 Bug: 357903074 Flag: EXEMPT bugfix Change-Id: Id0712387e3249ac6118990441a4bb19102cd4a84
2024-08-15Implement the VK_KHR_swapchain_mutable_format device extension in the vulkan ↵ Tom Murphy
loader Add an implementation for the VK_KHR_swapchain_mutable_format extension. Test: Stepped through changes in debugger Test: Ran sample app with VVL which used the extension Test: Ran dEQP-VK.image.swapchain_mutable.android.* dEQP tests Flag: com.android.graphics.libvulkan.flags.swapchain_mutable_format_ext Bug: 341978292 Change-Id: Ib0e5b9f750cd5a94ab65419542898db207716fcc
2024-06-17Tidy up dispatch to GPDIFP2 in swapchain Chris Forbes
Bug: b/346650750 Test: n/a Change-Id: I22eba5cffcd86b671b69097ba087b795ad1732b2
2024-06-05Dispatch properly to either GPDIFP2 or KHR variant Chris Forbes
The KHR function pointer may not be populated. We can accept either. Bug: b/341758459 Change-Id: Idc7f2db78dff35d6120dab35bb5f25a7fa81ccb4
2024-05-01Revert "EGL/ANGLE/Vulkan: respect EGL resolved RGBX format" Android Culprit Assistant
This revert was created by Android Culprit Assistant. The culprit was identified in the following culprit search session (http://go/aca-get/96953fd0-49c9-4874-bc2a-cdc3b220bf45). Change-Id: Icb89f5d5b9c59e0d611191871db8d8c40106ee86
2024-04-20EGL/ANGLE/Vulkan: respect EGL resolved RGBX format Yiwei Zhang
Platform EGL is able to resolve rgb8 config to rgbx hal format but it currently skips setting the resolved format to the surface if ANGLE is detected in use. Meanwhile, Vulkan surface and swapchain lacks info to properly resolve RGBA8 vk format to rgbx hal format like platform EGL. So we'd wire through such info from the EGL side to the surface so that EGL->ANGLE->Vulkan can end up picking up the same format. Summary: 1. allow EGL to resolve and set surface format even with angle 2. vk surface to query default format for OPAQUE advertisement 3. angle already picks up OPAQUE only without sized alpha 4. (optional) besides format, also allows to set resolved dataspace Bug: b/335925862, b/328125698 Test: encoder cts is passing, and no regression to ImageReader use cases Change-Id: I4e977a278fc0659b6c5e91cad7b5755c9da3a28c
2024-03-15Revert "swapchain: support RGBX backed opaque swapchain for offs..." George Verhaegen
Revert submission 26542013 Reason for revert: DroidMonitor: Potential culprit for Bug b/329753804 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted. Reverted changes: /q/submissionid:26542013 Change-Id: I6ec4eba91fc62cd8e8ab631722fd2a9ec129aa30
2024-03-12swapchain: support RGBX backed opaque swapchain for offscreen Yiwei Zhang
When a swapchain is connected to SurfaceFlinger, it makes sense to only advertise INHERIT bit on Android. However, for offscreen scenarios, e.g. a video encoder surface, that currently shuts the door for preferring RGBX over RGBA for the requested VK_FORMAT_R8G8B8A8_* format, ending up with suboptimal performance when using Vulkan swapchain. This change advertises the OPAQUE bit for offscreen scenarios, and adds the code path to prefer RGBX as the backing storage when OPAQUE is used. This bridges a gap against EGL where GL_RGB8 is used for such encoder surface, which internally picks RGBX. This casts no regressions for anything currently going to the display via KHR_swapchain. Bug: b/328125698, b/328122401 Test: below tests pass with ANGLE on Zork device (AMD chromebook) 1. android.media.encoder.cts.SurfaceEncodeTimestampTest 2. android.media.codec.cts.EncodeDecodeTest - testEncodeDecodeVideoFromSurfaceToPersistentSurface - testEncodeDecodeVideoFromSurfaceToPersistentSurfaceNdk Change-Id: I82a7ac741dc70a3e3b5fdd4f7499c937c4dce6d8
2024-03-12swapchain: pass VkFormat to GetNativeDataspace directly Yiwei Zhang
No need for the extra convert just to workaround bt2020 linear ext mapping. This change also refactors to clean up the format population. Bug: b/328125698 Test: compile Change-Id: Iab875a90be1b240415dc1630dad0790d74c13871
2024-02-09Add more supported vulkan color space Yuxin Hu
This change lists the vulkan color space that is said to be supported by VK_EXT_swapchain_colorspace extension, and enable them on the VkFormat that is supported by AHardwareBuffer. VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT and VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT are enabled on VK_FORMAT_R16G16B16A16_SFLOAT VkFormat surfaces only as the transfer function is only meaningful for FP16 pixel formats. VK_COLOR_SPACE_PASS_THROUGH_EXT is the only VK_EXT_swapchain_colorspace color space that is enabled on VK_FORMAT_R8_UNORM VkFormat. Color space doesn't apply to single-channel pixel format, and we should use pass through to keep the original pixel color value. VK_COLOR_SPACE_DOLBYVISION_EXT is not supported on Android platform, and it is excluded from the VK_EXT_swapchain_colorspace supported color space lists. Bug: b/322044839 Test: atest --verbose CtsViewTestCases:android.view.cts.TextureViewTest Change-Id: I6ee3cbf9c6c61fc353ec9f3e515884645382c665
2024-02-08Add VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT to FP16 surface Yuxin Hu
VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT is not enabled on any VkFormat. This means ANGLE on Vulkan is not exposing EGL_EXT_gl_colorspace_display_p3_linear EGL colorspace, because ANGLE's query of VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT vulkan color space returns nothing. This causes TextureViewTest that relies on EGL_EXT_gl_colorspace_display_p3_linear color space support to fail on ANGLE. To fix it, enable the VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT color space on VK_FORMAT_R16G16B16A16_SFLOAT VkFormat first. Test: atest --verbose CtsViewTestCases:android.view.cts.TextureViewTest Bug: b/322044839 Change-Id: I95b6b425aef4b7870797e406dce59f596f1f50c3
2024-02-06Add VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT to FP16 surface Yuxin Hu
Test: atest --verbose CtsViewTestCases:android.view.cts.TextureViewTest#testGetBitmap_FP16_PassthroughP3 Bug: b/322044839 Change-Id: Ic1dfec7ea8d128881077a3c00f7454230f15f3a3
2024-01-17Check for USAGE_FRONT_BUFFER after GPDIFP2 Trevor David Black
Bug: 288286529 Test: atest CtsDeqpTestCases -- --module-arg 'CtsDeqpTestCases:include-filter:dEQP-VK.wsi.*' Change-Id: I2ee886b18b194016e638f44907aa8e2fdcb8fe6e
2023-12-26bound the swapchain num_image by the min and max image count Trevor David Black
Bug: 313353712 Bug: 316517849 Bug: 296019634 Test: atest CtsDeqpTestCases -- --module-arg 'CtsDeqpTestCases:include-filter:dEQP-VK.wsi.*' Change-Id: I0726b39aacaba87a531af9bef23c8a214bc38425
2023-12-12Add AHardwareBuffer* to VkNativeBufferANDROID Trevor David Black
Bug: 275906506 Test: atest CtsDeqpTestCases -- --module-arg 'CtsDeqpTestCases:include-filter:dEQP-VK.wsi.*' Change-Id: I9c7d28fe3498f77001d8b6512462fa7787305abf
2023-11-14Pass in VkImageCompressionControlEXT for swapchain usage query Vamsidhar reddy Gaddam
When using vkGetPhysicalDeviceImageFormatProperties2KHR to query usage flags, pass the application provided VkImageCompressionControlEXT struct to get the correct usage flags. Bug: 307696078 Change-Id: Idcad0589a1e05bd8e7574fbb1bdd1346aad325f9
2023-10-09Merge changes from topic "bump android.hardware.graphics.common to V5" into main Sergiu Ferentz
* changes: Refactoring HAL Dataspace to AIDL Dataspace Bump android.hardware.graphics.common V4->V5
2023-10-04Merge "Deprecate GetSwapchainGrallocUsageANDROID from the platform" into main Trevor Black
2023-10-04Deprecate GetSwapchainGrallocUsageANDROID from the platform Trevor David Black
Bug: 259437988 Change-Id: I9ae19978c7ea5f73292343fb187395ed5dbde270
2023-10-03Refactoring HAL Dataspace to AIDL Dataspace sergiuferentz
Bug: 291142745 Test: Build Change-Id: Icfa9562f03d58c4cb8d90151c3c5a4617c404375
2023-09-26Clarified value of 2 for default buffers in vulkan swapchain Trevor David Black
Bug: 296019634 Test: atest CtsDeqpTestCases -- --module-arg 'CtsDeqpTestCases:include-filter:dEQP-VK.wsi.*' Change-Id: Ie690fdb87c42d1000550d3f92fb7d0527cba3ca9
2023-09-07remove min_undequeued_buffers from VkCreateSwapchainKHR Trevor David Black
min_undequeued_buffers is already added in GetPhysicalDeviceSurfaceCapabilities2KHR Meaning that it was getting counted a second time in VkCreateSwapchainKHR Bug: 296019634 Test: atest CtsDeqpTestCases -- --module-arg 'CtsDeqpTestCases:include-filter:dEQP-VK.wsi.*' Change-Id: I298b0f6dfe257ff94d8831e9ac9832c830bfc4b8
2023-08-30Move swapchain GetPhysicalDeviceSurfaceCapabilities2KHR to switch-case Trevor David Black
Bug: 296019634 Test: atest CtsDeqpTestCases -- --module-arg 'CtsDeqpTestCases:include-filter:dEQP-VK.wsi.*' Change-Id: I0e814068290c543ef3046a57d30d4ee070aa9d33
2023-08-05Merge "Add swapchainImageUsage to VkGrallocUsageInfo2" into udc-qpr-dev am: ↵ Trevor Black
92edf5398b am: 3cee757220 Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/24314871 Change-Id: Iac4ddf3161d414da318d47bd626efaa76140bd23 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-04Merge "Add swapchainImageUsage to VkGrallocUsageInfo2" into udc-qpr-dev am: ↵ Trevor Black
92edf5398b Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/24314871 Change-Id: I9d2741c1448e31d11a518083bf6033dd963d7d20 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-03Add swapchainImageUsage to VkGrallocUsageInfo2 Trevor David Black
Bug: 288286529 Test: Build Change-Id: I8091d9c4db11394b85ceb1d266f97d35a00cc246
2023-07-19Fix bt2020 linear ext mapping issue in EGL and Vulkan. Sally Qi
- EGL_EXT_BT2020_LINEAR should be mapped to extend bt2020 linear if output format is FP16. Bug: 261485283 Test: builds Change-Id: Ifd68cc10afc0b5b38b15af2a938d02bb3bcd3764
2023-07-18Merge "Move vulkan swapchain from pixelformat to aidl" into main am: ↵ Trevor Black
39a9427c02 am: a442c73691 am: 92b2ae9ed2 am: 9453eecc42 Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2656945 Change-Id: Id5ac4dfacfc3faddc928cd2f0e8223dc9701ce4d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-18Merge "Move vulkan swapchain from pixelformat to aidl" into main am: ↵ Trevor Black
39a9427c02 am: a442c73691 Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2656945 Change-Id: I471b9548f3cbe3926b061b6a06d556cd77f7ea84 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-17Move vulkan swapchain from pixelformat to aidl Trevor David Black
Bug: 291142745 Test: Build Change-Id: I3abe992f7d7cd2a79704a3189958e51b3c2f0bdb
2023-06-26Fix the bug in image compression that failed to specify correct usage, type, ↵ Trevor David Black
flags The previous implementation of the vulkan swapchain incorrectly implemented vkGetPhysicalDeviceSurfaceFormats2KHR. As a workaround at least one driver vendor resorted to a code workaround in their driver to correct the bad call in flight. The failure was during a call to vkGetDeviceImageFormatProperties2 where the swapchain was failing to include the correct image usage and image type, along with a failure to include the correct image compression flags. This CL amends the mistake to add these missing components to the vulkan vkGetDeviceImageFormatProperties2 call. Any driver vendors that have not yet finalized their image compression implementations will benefit from not needing to add an android specific workaround for this bug. The CL as written does not require the driver workaround that was already written to be revised. The driver will work correctly without source changes. When the driver is updated the workaround can cleanly be removed without side-effects. Bug: 288100893 Test: dEQP-VK.api.image_compression_control.swapchain.android Change-Id: Id10e5f3e42ae4e16b2cf4874a0ff4e0e2f21cd2d
2023-06-08Correctly implement minImageCount for swapchain Trevor David Black
Bug: 284807752 Test: atest CtsDeqpTestCases -- --module-arg 'CtsDeqpTestCases:include-filter:dEQP-VK.wsi.android.maintenance1.release_images.*' Change-Id: I36bd7a3dac8f8a3f6b913733fbd0ba140ee0b092
2023-04-19swapchain: avoid redundant disconnect/connect for new surface Yiwei Zhang
Platform API contract ensures VkSurfaceKHR is created with a new or disconnected ANativeWindow. Then the first swapchain created against the new surface can skip the disconnect/connect of the native window, which saves 2 binder IPC calls. In theory, the same can be skipped until the first successful present call. We dirty the bit at the end of swapchain creation to avoid extra external synchronization. Bug: 275176234 Bug: 265763295 Test: no deadlock against ANGLE eglCreateWindowSurface Change-Id: Ic2d09e4547e0ec7e910863c77a4657d52e9366fd
2023-04-14Processing native_window_get_refresh_cycle_duration error Alina Kalyakina
Added processing the situation when native_window_get_refresh_cycle_duration returns error in CreateSwapchainKHR. Bug: 271795577 Test: dEQP-VK.wsi.android.display_timing.mailbox.display_timing and CtsDeqpTestCases:include-filter:dEQP-VK.wsi.android.display_timing.fifo.display_timing pass Test: other existing dEQP-VK.wsi.* tests still pass Change-Id: Ib990ab1178dea9d75c27028ed1df2b91b3a7cabb
2023-03-22Merge "Explicitly query for VK_EXT_rgba10x6_formats in Vulkan" am: ↵ Trevor Black
7ac34d3210 am: 56df2453e7 am: 600b5dd247 Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2472765 Change-Id: I31739e231f1f5d554e72a301333b246d6473ed82 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-22Explicitly query for VK_EXT_rgba10x6_formats in Vulkan Trevor David Black
Bug: 271535435 Bug: 266596259 Test: Build Change-Id: If41bceba8db1004da0212cde85bc6638ff125781
2022-12-28Revert "Revert "Reland: "libvulkan: Implement EXT_swapchain_maintenance1"""" Chris Forbes
This reverts commit 334a4105c8d52848c48c4c843a33522423010c4c. Reason for revert: all failures tracked to original CL, not the reland. No issues seen now in manual hwasan tests. Change-Id: Icd2f12f18b5f1a77237703983e11bced16cb8865
2022-12-22Revert "Reland: "libvulkan: Implement EXT_swapchain_maintenance1""" Ian Elliott
This reverts commit 2dcb4f0064d3d6a01105d2c8a12368c347d85227. Reason for revert: Appears to cause HWASAN failures. See b/263442454, b/263446408, b/263444233, and b/263445588. Change-Id: I6de0027ae2db803445a66de575dda97826b8eb6a
2022-12-22Reland: "libvulkan: Implement EXT_swapchain_maintenance1"" Chris Forbes
This reverts commit ac40c1e284453e10a7c2b6f2c6090fc4be322398 and incorporates a fix for the memory corruption that caused us to revert it initially. Bug: b/255376900 Change-Id: I3d8ab1977ea705bebdb8cd2c69d39f06ab5c4158
2022-12-21Merge "Revert "libvulkan: Implement EXT_swapchain_maintenance1"" Ian Elliott
2022-12-21Revert "libvulkan: Implement EXT_swapchain_maintenance1" Ian Elliott
This reverts commit 08c7bb1fdb33d6ad34ba1b2de3ac0579750456fe. Reason for revert: Possibly the cause of b/263412882 (will revert and see if that clears up the problem) Change-Id: If217e36c67fcea8b5270dbf20b0c13c42d1da09a
2022-12-21Merge "libvulkan: Implement EXT_swapchain_maintenance1" Ian Elliott
2022-12-21libvulkan: Implement EXT_swapchain_maintenance1 Chris Forbes
The loader now implements EXT_swapchain_maintenance1 and EXT_surface_maintenance1, which fix assorted issues with the original swapchain extension. Our implementation of EXT_swapchain_maintenance1 is conditional on the underlying driver having support for importing sync fds as external fences (which requires Vulkan 1.1 + support for VK_KHR_external_fence_fd). Bug: b/255376900 Change-Id: I72ce770a7296e4e97cccf13bad420aa5a1001a6a
2022-12-21Merge changes from topic "AHB_format_r_16+" am: 112211eef1 am: 7f60bfb5f9 ↵ Trevor Black
am: 3e2c8537b7 Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2329034 Change-Id: Ibe6411103895e96e8ffb6f0ed1c623f1da492614 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-12-16The ahb changes necessary for Trevor David Black
- AHARDWAREBUFFER_FORMAT_R16_UINT - AHARDWAREBUFFER_FORMAT_R16G16_UINT - AHARDWAREBUFFER_FORMAT_R10G10B10A10_UNORM Bug: 233033456 Test: Build Change-Id: Id56fd83b033c899c40648ef64bcfd65aedc5cd24
2022-12-16swapchain: Don't call native_window_get_wide_color_support Chris Forbes
This query is deprecated and hardcoded to return true. While we're adjusting this, fix the set of surface formats to be valid when the EXT_swapchain_colorspace extension is not enabled. Bug: b/242763577 Change-Id: I9a7fe692b552f8ade39c5530d4cf8c8027979699
2022-12-13Merge "Adding new Vulkan metrics to GPU Stats" Serdar Kocdemir
2022-12-12Adding new Vulkan metrics to GPU Stats Serdar Kocdemir
Following fields are added into GpuStatsAppInfo for tracking: bool createdGlesContext = false; bool createdVulkanDevice = false; bool createdVulkanSwapchain = false; uint32_t vulkanApiVersion = 0; uint64_t vulkanDeviceFeaturesEnabled = 0; std::vector<int32_t> vulkanInstanceExtensions = {}; std::vector<int32_t> vulkanDeviceExtensions = {}; Extensions are tracked as 32-bit hashes. setTargetStatsArray GPU service function added to provide an array of stat values, used for reporting list of extensions. Bug: b/244286661 Test: adb shell dumpsys gpu Test: atest GpuStatsTest Change-Id: I4ae4e3b687cd6274a9b4127a336dd0f91f5f9e39