<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, Aug 21, 2018 at 3:27 AM Tapani Pälli <<a href="mailto:tapani.palli@intel.com">tapani.palli@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Tapani Pälli <<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a>><br>
---<br>
src/intel/vulkan/vk_format_info.h | 43 +++++++++++++++++++++++++++++++++++++++<br>
1 file changed, 43 insertions(+)<br>
<br>
diff --git a/src/intel/vulkan/vk_format_info.h b/src/intel/vulkan/vk_format_info.h<br>
index a1cc6952c8f..0ae0a2d43ee 100644<br>
--- a/src/intel/vulkan/vk_format_info.h<br>
+++ b/src/intel/vulkan/vk_format_info.h<br>
@@ -27,6 +27,49 @@<br>
#include <stdbool.h><br>
#include <vulkan/vulkan.h><br>
<br>
+#ifdef ANDROID<br>
+#include <vndk/hardware_buffer.h><br>
+static inline VkFormat<br>
+vk_format_from_android(unsigned android_format)<br>
+{<br>
+ switch (android_format) {<br>
+ case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:<br>
+ case AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM:<br></blockquote><div><br></div><div>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.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ return VK_FORMAT_R8G8B8A8_UNORM;<br>
+ case AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM:<br>
+ return VK_FORMAT_R8G8B8_UNORM;<br>
+ case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM:<br>
+ return VK_FORMAT_R5G6B5_UNORM_PACK16;<br>
+ case AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT:<br>
+ return VK_FORMAT_R16G16B16A16_SFLOAT;<br>
+ case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM:<br>
+ return VK_FORMAT_A2B10G10R10_UNORM_PACK32;<br>
+ case AHARDWAREBUFFER_FORMAT_BLOB:<br>
+ default:<br>
+ return VK_FORMAT_UNDEFINED;<br>
+ }<br>
+}<br>
+<br>
+static inline unsigned<br>
+android_format_from_vk(unsigned vk_format)<br>
+{<br>
+ switch (vk_format) {<br>
+ case VK_FORMAT_R8G8B8A8_UNORM:<br>
+ return AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;<br>
+ case VK_FORMAT_R8G8B8_UNORM:<br>
+ return AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM;<br>
+ case VK_FORMAT_R5G6B5_UNORM_PACK16:<br>
+ return AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM;<br>
+ case VK_FORMAT_R16G16B16A16_SFLOAT:<br>
+ return AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT;<br>
+ case VK_FORMAT_A2B10G10R10_UNORM_PACK32:<br>
+ return AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM;<br>
+ default:<br>
+ return AHARDWAREBUFFER_FORMAT_BLOB;<br>
+ }<br>
+}<br>
+#endif<br>
+<br>
static inline VkImageAspectFlags<br>
vk_format_aspects(VkFormat format)<br>
{<br>
-- <br>
2.14.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div></div>