vulkan/android: Fix hardware buffer usage flags
We now add the correct usage flags for input attachments, storage images, and depth/stencil attachments. Reviewed-by: Lina Versace <lina@kiwitree.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22038>
This commit is contained in:

committed by
Marge Bot

parent
41f88be282
commit
dc0749adab
@@ -35,6 +35,23 @@
|
|||||||
#if ANDROID_API_LEVEL >= 26
|
#if ANDROID_API_LEVEL >= 26
|
||||||
#include <vndk/hardware_buffer.h>
|
#include <vndk/hardware_buffer.h>
|
||||||
|
|
||||||
|
/* From the Android hardware_buffer.h header:
|
||||||
|
*
|
||||||
|
* "The buffer will be written to by the GPU as a framebuffer attachment.
|
||||||
|
*
|
||||||
|
* Note that the name of this flag is somewhat misleading: it does not
|
||||||
|
* imply that the buffer contains a color format. A buffer with depth or
|
||||||
|
* stencil format that will be used as a framebuffer attachment should
|
||||||
|
* also have this flag. Use the equivalent flag
|
||||||
|
* AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER to avoid this confusion."
|
||||||
|
*
|
||||||
|
* The flag was renamed from COLOR_OUTPUT to FRAMEBUFFER at Android API
|
||||||
|
* version 29.
|
||||||
|
*/
|
||||||
|
#if ANDROID_API_LEVEL < 29
|
||||||
|
#define AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Construct ahw usage mask from image usage bits, see
|
/* Construct ahw usage mask from image usage bits, see
|
||||||
* 'AHardwareBuffer Usage Equivalence' in Vulkan spec.
|
* 'AHardwareBuffer Usage Equivalence' in Vulkan spec.
|
||||||
*/
|
*/
|
||||||
@@ -43,14 +60,19 @@ vk_image_usage_to_ahb_usage(const VkImageCreateFlags vk_create,
|
|||||||
const VkImageUsageFlags vk_usage)
|
const VkImageUsageFlags vk_usage)
|
||||||
{
|
{
|
||||||
uint64_t ahb_usage = 0;
|
uint64_t ahb_usage = 0;
|
||||||
if (vk_usage & VK_IMAGE_USAGE_SAMPLED_BIT)
|
if (vk_usage & (VK_IMAGE_USAGE_SAMPLED_BIT |
|
||||||
|
VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT))
|
||||||
ahb_usage |= AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
|
ahb_usage |= AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
|
||||||
|
|
||||||
if (vk_usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)
|
if (vk_usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)
|
||||||
ahb_usage |= AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
|
ahb_usage |= AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
|
||||||
|
|
||||||
if (vk_usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)
|
if (vk_usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
|
||||||
ahb_usage |= AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT;
|
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT))
|
||||||
|
ahb_usage |= AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER;
|
||||||
|
|
||||||
|
if (vk_usage & VK_IMAGE_USAGE_STORAGE_BIT)
|
||||||
|
ahb_usage |= AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER;
|
||||||
|
|
||||||
if (vk_create & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT)
|
if (vk_create & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT)
|
||||||
ahb_usage |= AHARDWAREBUFFER_USAGE_GPU_CUBE_MAP;
|
ahb_usage |= AHARDWAREBUFFER_USAGE_GPU_CUBE_MAP;
|
||||||
|
Reference in New Issue
Block a user