<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Nov 10, 2017 at 10:48 AM, Chad Versace <span dir="ltr"><<a href="mailto:chadversary@chromium.org" target="_blank">chadversary@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu 09 Nov 2017, Jason Ekstrand wrote:<br>
> On Thu, Nov 9, 2017 at 4:23 PM, Chad Versace <[1]<a href="mailto:chadversary@chromium.org">chadversary@chromium.org</a>><br>
<span class="">> wrote:<br>
><br>
> On Wed 08 Nov 2017, Jason Ekstrand wrote:<br>
> > On Wed, Nov 8, 2017 at 1:34 AM, Samuel Iglesias Gonsálvez <[1]<br>
</span><span class="">> > [2]<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>> wrote:<br>
> ><br>
> > The HW has some limits but, according to the spec, we can create<br>
> > the image as it has not yet any memory backing it. When we allocate<br>
> > that memory, then we fail following what Vulkan spec, "10.2. Device<br>
> > Memory" says when talking about vkAllocateMemory():<br>
> ><br>
> > "Some platforms may have a limit on the maximum size of a single<br>
> > allocation. For example, certain systems may fail to create<br>
> > allocations with a size greater than or equal to 4GB. Such a limit<br>
> is<br>
> > implementation-dependent, and if such a failure occurs then the<br>
> error<br>
> > VK_ERROR_OUT_OF_DEVICE_<wbr>MEMORY must be returned."<br>
> ><br>
> > Fixes the crashes on BDW for the following tests:<br>
> ><br>
> > dEQP-VK.pipeline.render_to_<wbr>image.core.2d_array.huge.*<br>
> > dEQP-VK.pipeline.render_to_<wbr>image.core.cube_array.huge.*<br>
> ><br>
</span>> > Signed-off-by: Samuel Iglesias Gonsálvez <[2][3]<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>><br>
<div><div class="h5">> > ---<br>
> ><br>
> > Jason, I was tempted to move this piece of code to anv_AllocateMemory<br>
> ()<br>
> > but then I found the kernel relocation limitation of 32-bit... Is<br>
> that<br>
> > limitation still applicable? Or was it from the BDW age and we forgot<br>
> > to update that limitation for gen9+?<br>
> ><br>
> ><br>
> > We're still using relocations on all hardware so it applies to everything<br>
> > today. One of my 2018 projects is to fix that and get rid of relocations<br>
> on<br>
> > gen8+.<br>
> > <br>
> ><br>
> > Sam<br>
> ><br>
> > src/intel/isl/isl.c | 22 ----------------------<br>
> > 1 file changed, 22 deletions(-)<br>
> ><br>
> > diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c<br>
> > index 59f512fc050..aaadcbaf991 100644<br>
> > --- a/src/intel/isl/isl.c<br>
> > +++ b/src/intel/isl/isl.c<br>
> > @@ -1472,28 +1472,6 @@ isl_surf_init_s(const struct isl_device *dev,<br>
> > base_alignment = MAX(info->min_alignment, tile_size);<br>
> > }<br>
> ><br>
> > - if (ISL_DEV_GEN(dev) < 9) {<br>
> > - /* From the Broadwell PRM Vol 5, Surface Layout:<br>
> > - *<br>
> > - * "In addition to restrictions on maximum height, width,<br>
> and<br>
> > depth,<br>
> > - * surfaces are also restricted to a maximum size in<br>
> bytes. This<br>
> > - * maximum is 2 GB for all products and all surface<br>
> types."<br>
> > - *<br>
> > - * This comment is applicable to all Pre-gen9 platforms.<br>
> > - */<br>
> > - if (size > (uint64_t) 1 << 31)<br>
> > - return false;<br>
> > - } else {<br>
> > - /* From the Skylake PRM Vol 5, Maximum Surface Size in Bytes:<br>
> > - * "In addition to restrictions on maximum height, width,<br>
> and<br>
> > depth,<br>
> > - * surfaces are also restricted to a maximum size of 2^38<br>
> bytes.<br>
> > - * All pixels within the surface must be contained within<br>
> 2^38<br>
> > bytes<br>
> > - * of the base address."<br>
> > - */<br>
> > - if (size > (uint64_t) 1 << 38)<br>
> > - return false;<br>
> > - }<br>
><br>
> I think it very unwise to delete code that enforces requirements defined<br>
> by the hardware spec. Deleting the code doesn't make the hardware<br>
> requirements go away :)<br>
><br>
> > I'm not sure how I feel about removing this from ISL. There are really<br>
> two<br>
> > limitations going on here. One is a limitation imposed by relocations,<br>
> and the<br>
> > other is some sort of fundamental hardware surface size limitation. Most<br>
> > likely, the surface size limitation has to do with how many bits they use<br>
> for<br>
> > image address computations in the hardware. Most likely, on gen8, they<br>
> do all<br>
> > of the internal calculations in 32 bits and only convert to 48 at the end<br>
> when<br>
> > they need to add it to Surface Base Address.<br>
> ><br>
> > If my understanding is correct then we will still have this limitation on<br>
> gen8<br>
> > even after we get rid of relocations and remove the BO size limitation. <br>
> I see<br>
> > a couple of options, neither of which I like very much:<br>
> ><br>
> > 1) Take something like this patch and then keep the BO size limitation<br>
> on BDW<br>
> > to 2GiB when we get rid of relocations even though it's artificial.<br>
> > 2) "Gracefully" handle isl_surf_init failure by doing a debug_log and<br>
> > succeeding but setting the image size (that will be returned by<br>
> > vkGetImageMemoryRequirements) to UINT64_MAX so that the client won't ever<br>
> be<br>
> > able to find memory for it.<br>
> ><br>
> > My feeling is that 1) above is probably the better of the two as 2) seems<br>
> to be<br>
> > a twisting of the spec. That said, I would like to keep the restriction<br>
> in ISL<br>
> > somehow and we need to make sure it still gets applied in GL.<br>
><br>
> I dislike both. I originally designed isl to mimic the VkImage API, so<br>
> let's continue that trend.<br>
><br>
> Option 3) Change isl_surf_init() to return a meaningful result code:<br>
><br>
> ISL_SUCCESS = 0<br>
> ISL_ERROR_SOMETHING_SOMETHING_<wbr>THE_USUAL_FAILURES = -1<br>
> ISL_ERROR_SURFACE_SIZE_TOO_<wbr>LARGE = -2<br>
><br>
> I like option 3 because it avoids secret implicit contracts between isl<br>
> and anvil, and thus avoids hidden hacks.<br>
><br>
><br>
> I mostly agree but that still doesn't answer the question of what do we do with<br>
> that return code? We can't fail the vkCreateImage because our only options<br>
> there are the two OOM errors both of which are lies. The only real option we<br>
> have is to go ahead and create the VkImage but give it a size that doesn't fit<br>
> in any allocatable memory object. So, we're back to options 1 and 2...<br>
<br>
</div></div>Yeah, you're right.<br>
<br>
The Vulkan spec has strange language regarding<br>
VkImageFormatProperties::<wbr>maxResourceSize, which gives the implementatin<br>
two options:<br>
<br>
NOTE<br>
There is no mechanism to query the size of an image before creating it,<br>
to compare that size against maxResourceSize. If an application attempts<br>
to create an image that exceeds this limit, the creation will *fail* or<br>
the image will be *invalid*. While the advertised limit must be at least<br>
2^31, it may not be possible to create an image that approaches that<br>
size, particularly for VK_IMAGE_TYPE_1D.<br>
<br>
[Emphasis on *fail* and *invalid* are mine].<br>
<br>
On the choice to fail:<br>
Like you point out, vkCreateImage has no appropriate result code for<br>
this failure.<br>
<br>
On the choice to return an invalid image:<br>
The spec is silent on what should happen when vkCreateImage succeeds<br>
and returns an invalid image. The spec never refers to an invalid<br>
image (or any invalid resource) except in this paragraph.<br>
<br>
But I think setting anv_image::size = UINT64_MAX complies with the<br>
spec, because it prevents the app from binding the image to memory.<br>
<br>
So I vote for option 2.<br></blockquote><div><br></div><div>Sounds good to me. In the mean time, I filed a spec bug with more-or-less the contents of your e-mail: It's internal issue 1078 if you're interested. <br></div></div></div></div>