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

Lionel Landwerlin lionel.g.landwerlin at intel.com
Tue Dec 11 11:54:48 UTC 2018


On 11/12/2018 11:32, Tapani Pälli wrote:
>
>
> On 12/11/18 12:56 PM, Lionel Landwerlin wrote:
>> On 27/11/2018 10:53, Tapani Pälli wrote:
>>> v2: handle R8G8B8X8 as R8G8B8_UNORM (Jason)
>>> v3: add HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL, we make it define
>>>      for now to avoid direct dependency to minigbm headers
>>>
>>> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
>>> ---
>>>   src/intel/vulkan/vk_format_info.h | 50 
>>> +++++++++++++++++++++++++++++++
>>>   1 file changed, 50 insertions(+)
>>>
>>> diff --git a/src/intel/vulkan/vk_format_info.h 
>>> b/src/intel/vulkan/vk_format_info.h
>>> index a1cc6952c8f..555c67704bc 100644
>>> --- a/src/intel/vulkan/vk_format_info.h
>>> +++ b/src/intel/vulkan/vk_format_info.h
>>> @@ -27,6 +27,56 @@
>>>   #include <stdbool.h>
>>>   #include <vulkan/vulkan.h>
>>> +#ifdef ANDROID
>>> +#include <vndk/hardware_buffer.h>
>>> +/* See i915_private_android_types.h in minigbm. */
>>> +#define HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL 0x100
>>> +
>>> +static inline VkFormat
>>> +vk_format_from_android(unsigned android_format)
>>> +{
>>> +   switch (android_format) {
>>> +   case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
>>> +      return VK_FORMAT_R8G8B8A8_UNORM;
>>> +   case AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM:
>>> +   case AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM:
>>> +      return VK_FORMAT_R8G8B8_UNORM;
>>
>>
>> Hm... I think you could run into issue with a linear buffer 
>> AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM.
>>
>> It seems anv will actually select R8G8B8 in that case and that 
>> probably won't match.
>
> Thinking here was that these would be handled in similar way, both 
> have alpha 1.0 channel. Right now these are not required though so I 
> can also remove them from the list if this is preferred?


Actually I see you're handling that in a later patch at binding time.


>
>>
>>> +   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;
>>
>>
>> Is the android naming inconsistent or are all the other formats 
>> backwards?
>
> I took these from Vulkan spec 'AHardwareBuffer Format Equivalence' so 
> seems to be what is wanted.


Thanks for the details! Without any change :


Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>


>
>>
>>> +   case HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL:
>>> +      return VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
>>> +   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;
>>> +   case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
>>> +      return HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL;
>>> +   default:
>>> +      return AHARDWAREBUFFER_FORMAT_BLOB;
>>> +   }
>>> +}
>>> +#endif
>>> +
>>>   static inline VkImageAspectFlags
>>>   vk_format_aspects(VkFormat format)
>>>   {
>>
>>
>



More information about the mesa-dev mailing list