<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sun, Aug 26, 2018 at 11:54 PM 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"><br>
<br>
On 08/24/2018 05:04 PM, Jason Ekstrand wrote:<br>
> On Fri, Aug 24, 2018 at 12:08 AM Tapani Pälli <<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a> <br>
> <mailto:<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a>>> wrote:<br>
> <br>
> <br>
> <br>
> On 08/22/2018 05:18 PM, Jason Ekstrand wrote:<br>
> > On Tue, Aug 21, 2018 at 3:27 AM Tapani Pälli<br>
> <<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a> <mailto:<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a>><br>
> > <mailto:<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a> <mailto:<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a>>>><br>
> wrote:<br>
> ><br>
> > When adding YUV support, we need to figure out<br>
> implementation-defined<br>
> > external format identifier.<br>
> ><br>
> > Signed-off-by: Tapani Pälli <<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a><br>
> <mailto:<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a>><br>
> > <mailto:<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a> <mailto:<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a>>>><br>
> > ---<br>
> > src/intel/vulkan/anv_android.c | 99<br>
> > ++++++++++++++++++++++++++++++++++++++++++<br>
> > 1 file changed, 99 insertions(+)<br>
> ><br>
> > diff --git a/src/intel/vulkan/anv_android.c<br>
> > b/src/intel/vulkan/anv_android.c<br>
> > index 46c41d57861..7d0eb588e2b 100644<br>
> > --- a/src/intel/vulkan/anv_android.c<br>
> > +++ b/src/intel/vulkan/anv_android.c<br>
> > @@ -29,6 +29,8 @@<br>
> > #include <sync/sync.h><br>
> ><br>
> > #include "anv_private.h"<br>
> > +#include "vk_format_info.h"<br>
> > +#include "vk_util.h"<br>
> ><br>
> > static int anv_hal_open(const struct hw_module_t* mod,<br>
> const char*<br>
> > id, struct hw_device_t** dev);<br>
> > static int anv_hal_close(struct hw_device_t *dev);<br>
> > @@ -96,6 +98,103 @@ anv_hal_close(struct hw_device_t *dev)<br>
> > return -1;<br>
> > }<br>
> ><br>
> > +static VkResult<br>
> > +get_ahw_buffer_format_properties(<br>
> > + VkDevice device_h,<br>
> > + const struct AHardwareBuffer *buffer,<br>
> > + VkAndroidHardwareBufferFormatPropertiesANDROID *pProperties)<br>
> > +{<br>
> > + ANV_FROM_HANDLE(anv_device, device, device_h);<br>
> > +<br>
> > + /* Get a description of buffer contents . */<br>
> > + AHardwareBuffer_Desc desc;<br>
> > + AHardwareBuffer_describe(buffer, &desc);<br>
> > +<br>
> > + /* Verify description. */<br>
> > + uint64_t gpu_usage =<br>
> > + AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |<br>
> > + AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT |<br>
> > + AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER;<br>
> > +<br>
> > + /* "Buffer must be a valid Android hardware buffer object<br>
> with<br>
> > at least<br>
> > + * one of the AHARDWAREBUFFER_USAGE_GPU_* usage flags."<br>
> > + */<br>
> > + if (!(desc.usage & (gpu_usage)))<br>
> > + return VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR;<br>
> > +<br>
> > + /* Fill properties fields based on description. */<br>
> > + VkAndroidHardwareBufferFormatPropertiesANDROID *p =<br>
> pProperties;<br>
> > +<br>
> > + p->pNext = NULL;<br>
> ><br>
> ><br>
> > You shouldn't be overwriting pNext. That's used by the client to<br>
> let<br>
> > them chain in multiple structs to fill out in case Google ever<br>
> extends<br>
> > this extension. Also, while we're here, it'd be good to throw in an<br>
> > assert that p->sType is the right thing.<br>
> <br>
> Yes of course, will remove.<br>
> <br>
> > + p->format = vk_format_from_android(desc.format);<br>
> > + p->externalFormat = 1; /* XXX */<br>
> > +<br>
> > + const struct anv_format *anv_format =<br>
> anv_get_format(p->format);<br>
> > + struct anv_physical_device *physical_device =<br>
> > + &device->instance->physicalDevice;<br>
> > + const struct gen_device_info *devinfo =<br>
> &physical_device->info;<br>
> ><br>
> ><br>
> > If all you need is devinfo, that's avilable in the device; you don't<br>
> > need to get the physical device for it. Should be device->info.<br>
> <br>
> OK<br>
> <br>
> > +<br>
> > + p->formatFeatures =<br>
> > + anv_get_image_format_features(devinfo, p->format,<br>
> > + anv_format,<br>
> > VK_IMAGE_TILING_OPTIMAL);<br>
> > +<br>
> > + /* "The formatFeatures member *must* include<br>
> > + * VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT and at least one of<br>
> > + * VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT or<br>
> > + * VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT"<br>
> > + */<br>
> > + p->formatFeatures |=<br>
> > + VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT;<br>
> ><br>
> ><br>
> > Uh... Why not just throw in SAMPLED_BIT? For that matter, all of<br>
> the<br>
> > formats you have in your conversion helpers support sampling. Maybe<br>
> > just replace that with an assert for now.<br>
> <br>
> Yeah, VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT is there. Well thing is that<br>
> dEQP checks explicitly that either<br>
> VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT or<br>
> VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT exists (independent of<br>
> surface format). TBH I'm not sure what to do about that.<br>
> <br>
> <br>
> That's annoying... Is that in a Khronos CTS test or a Google test? <br>
> Either way, we should try to get it corrected. If you don't know how to <br>
> do that, I can send some e-mails.<br>
<br>
But per the Vulkan spec quote above it's not a bug, it says that <br>
"formatFeatures member must include sampled bit and at least one of <br>
MIDPOINT_CHROMA_SAMPLES or COSITED_CHROMA_SAMPLES. So .. I guess I <br>
should limit the supported formats to only those that have <br>
anv_format->can_ycbcr() set?<br></blockquote><div><br></div><div> I'll grant that it's consistent with the spec but it also seems like the spec has a bug. I'll file a spec bug.</div><div><br></div><div>--Jason<br></div></div></div>