[Mesa-dev] [PATCH 4/4] anv: Handle VK_WHOLE_SIZE properly for buffer views

Nanley Chery nanleychery at gmail.com
Fri Jul 15 16:57:50 UTC 2016


On Thu, Jul 14, 2016 at 09:20:08PM -0700, Jason Ekstrand wrote:
> The old calculation, which used view->offset, encorporated buffer->offset
> into the size calculation where it doesn't belong.  This meant that, if
> buffer->offset > buffer->size, you would always get a negative size.  This
> fixes 170 dEQP-VK.renderpass.attachment.* Vulkan CTS tests on Haswell.
> 

Nice patch.

> Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
> Cc: "12.0" <mesa-stable at lists.freedesktop.org>
> ---
>  src/intel/vulkan/anv_image.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
> index 23fdd93..fe5b124 100644
> --- a/src/intel/vulkan/anv_image.c
> +++ b/src/intel/vulkan/anv_image.c
> @@ -631,7 +631,7 @@ void anv_buffer_view_init(struct anv_buffer_view *view,
>     view->bo = buffer->bo;
>     view->offset = buffer->offset + pCreateInfo->offset;
>     view->range = pCreateInfo->range == VK_WHOLE_SIZE ?
> -                 buffer->size - view->offset : pCreateInfo->range;
> +                 buffer->size - pCreateInfo->offset : pCreateInfo->range;
>  

This is almost correct. The range member definition (11.2. Buffer Views)
has a corner case for VK_WHOLE_SIZE. It states that if 
R = (buffer_size - buffer_view_offset) is not a multiple of
buffer_view_format_size, then you must set the range member to
the nearest smaller multiple of buffer_view_format_size.

Which is to say,
 if (requested_range == VK_WHOLE_SIZE)
    actual_range = ALIGN_DOWN(R, buffer_view_format_size);

- Nanley

>     if (buffer->usage & VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT) {
>        view->surface_state = alloc_surface_state(device, cmd_buffer);
> -- 
> 2.5.0.400.gff86faf
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list