[Mesa-dev] [PATCH 2/8] anv: add from/to helpers with android and vulkan formats

Tapani Pälli tapani.palli at intel.com
Fri Aug 24 05:04:28 UTC 2018



On 08/22/2018 05:11 PM, Jason Ekstrand wrote:
> On Tue, Aug 21, 2018 at 3:27 AM Tapani Pälli <tapani.palli at intel.com 
> <mailto:tapani.palli at intel.com>> wrote:
> 
>     Signed-off-by: Tapani Pälli <tapani.palli at intel.com
>     <mailto:tapani.palli at intel.com>>
>     ---
>       src/intel/vulkan/vk_format_info.h | 43
>     +++++++++++++++++++++++++++++++++++++++
>       1 file changed, 43 insertions(+)
> 
>     diff --git a/src/intel/vulkan/vk_format_info.h
>     b/src/intel/vulkan/vk_format_info.h
>     index a1cc6952c8f..0ae0a2d43ee 100644
>     --- a/src/intel/vulkan/vk_format_info.h
>     +++ b/src/intel/vulkan/vk_format_info.h
>     @@ -27,6 +27,49 @@
>       #include <stdbool.h>
>       #include <vulkan/vulkan.h>
> 
>     +#ifdef ANDROID
>     +#include <vndk/hardware_buffer.h>
>     +static inline VkFormat
>     +vk_format_from_android(unsigned android_format)
>     +{
>     +   switch (android_format) {
>     +   case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
>     +   case AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM:
> 
> 
> How do you plan on handling the X?  Also, what are the semantics of it?  
> Are images created with this format expected to act as if they have no 
> alpha channel?  If so, then you may want to declare it as R8G8B8_UNORM 
> and we have logic in anv_image to turn that into R8G8B8A8_UNORM and 
> whack blending to treat it as if there is no alpha channel.

Thanks, yes the case is that it should 'ignore alpha' and be always 
opaque. Will change.


>     +      return VK_FORMAT_R8G8B8A8_UNORM;
>     +   case AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM:
>     +      return VK_FORMAT_R8G8B8_UNORM;
>     +   case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM:
>     +      return VK_FORMAT_R5G6B5_UNORM_PACK16;
>     +   case AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT:
>     +      return VK_FORMAT_R16G16B16A16_SFLOAT;
>     +   case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM:
>     +      return VK_FORMAT_A2B10G10R10_UNORM_PACK32;
>     +   case AHARDWAREBUFFER_FORMAT_BLOB:
>     +   default:
>     +      return VK_FORMAT_UNDEFINED;
>     +   }
>     +}
>     +
>     +static inline unsigned
>     +android_format_from_vk(unsigned vk_format)
>     +{
>     +   switch (vk_format) {
>     +   case VK_FORMAT_R8G8B8A8_UNORM:
>     +      return AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
>     +   case VK_FORMAT_R8G8B8_UNORM:
>     +      return AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM;
>     +   case VK_FORMAT_R5G6B5_UNORM_PACK16:
>     +      return AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM;
>     +   case VK_FORMAT_R16G16B16A16_SFLOAT:
>     +      return AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT;
>     +   case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
>     +      return AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM;
>     +   default:
>     +      return AHARDWAREBUFFER_FORMAT_BLOB;
>     +   }
>     +}
>     +#endif
>     +
>       static inline VkImageAspectFlags
>       vk_format_aspects(VkFormat format)
>       {
>     -- 
>     2.14.4
> 
>     _______________________________________________
>     mesa-dev mailing list
>     mesa-dev at lists.freedesktop.org <mailto:mesa-dev at lists.freedesktop.org>
>     https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 


More information about the mesa-dev mailing list