st/dri: Set next in template instead of after creation. (v2)
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Wed, 12 Feb 2020 15:54:21 +0000 (16:54 +0100)
committerMarge Bot <eric+marge@anholt.net>
Mon, 27 Apr 2020 21:08:01 +0000 (21:08 +0000)
This should prevent horrors like Iris has with the delayed calls
to iris_resource_finish_aux_import just because info is not
available at allocation time.

AFAICT all drivers just copy the template except radeonsi/r600
which reset the next pointer.

AFAICT there is also no other place we get a state tracker setting
next ptrs on a resource.

v2: Updated Gallium docs.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3792>

src/gallium/docs/source/screen.rst
src/gallium/drivers/r600/r600_texture.c
src/gallium/drivers/radeonsi/si_texture.c
src/gallium/state_trackers/dri/dri2.c

index 3a9ccb4246b392ae823b8bf88bbf32353ecbbe85..a40461fed708b26ebcc09ba94e961c18f6f83160 100644 (file)
@@ -943,7 +943,11 @@ replaced by ``nr_storage_samples``.
 
 **flags** bitmask of PIPE_RESOURCE_FLAG flags.
 
+**next**: Pointer to the next plane for resources that consist of multiple
+memory planes.
 
+As a corollary, this mean resources for an image with multiple planes have
+to be created starting from the highest plane.
 
 resource_changed
 ^^^^^^^^^^^^^^^^
index 5c8b9dd4af997a0b2d4b9d369f682decefc43a63..42cc09e8b7654b1b170af3a760ebee0b0120743d 100644 (file)
@@ -918,7 +918,6 @@ r600_texture_create_object(struct pipe_screen *screen,
 
        resource = &rtex->resource;
        resource->b.b = *base;
-       resource->b.b.next = NULL;
        resource->b.vtbl = &r600_texture_vtbl;
        pipe_reference_init(&resource->b.b.reference, 1);
        resource->b.b.screen = screen;
index f67794c610e9a39515568e2c20481f193bf747bd..db4704575511d0998bdeb8f200c570690f39bef8 100644 (file)
@@ -1210,7 +1210,6 @@ static struct si_texture *si_texture_create_object(struct pipe_screen *screen,
 
    resource = &tex->buffer;
    resource->b.b = *base;
-   resource->b.b.next = NULL;
    resource->b.vtbl = &si_texture_vtbl;
    pipe_reference_init(&resource->b.b.reference, 1);
    resource->b.b.screen = screen;
index 630817b6cbec0836c43b24ffbd780e8abede53ac..ec78d0985ed221919124078b29648ded4d842a31 100644 (file)
@@ -776,6 +776,7 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,
    for (i = (use_lowered ? map->nplanes : num_handles) - 1; i >= 0; i--) {
       struct pipe_resource *tex;
 
+      templ.next = img->texture;
       templ.width0 = width >> map->planes[i].width_shift;
       templ.height0 = height >> map->planes[i].height_shift;
       if (use_lowered)
@@ -793,7 +794,6 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,
          return NULL;
       }
 
-      tex->next = img->texture;
       img->texture = tex;
    }