st/mesa: account for "loose", per-mipmap level textures in CopyImageSubData
authorDanylo Piliaiev <danylo.piliaiev@globallogic.com>
Fri, 12 Jun 2020 13:04:44 +0000 (16:04 +0300)
committerMarge Bot <eric+marge@anholt.net>
Thu, 18 Jun 2020 11:44:14 +0000 (11:44 +0000)
We may have "loose", per-image gallium resources. The src_image->Level
may not match the gallium resource texture level. In such case it is
prescribed (in st_AllocTextureImageBuffer) to specify mipmap level
as zero.

Fixes: f04f13622f3e71bee057d60a6be9c53b92b56cc9
Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5477>

src/mesa/state_tracker/st_cb_copyimage.c

index a58cdf62703397640d310352c824b721ef0a5220..5d9c77fdedea40eb1e235e2869b9a0a59de3b8a8 100644 (file)
@@ -645,8 +645,9 @@ st_CopyImageSubData(struct gl_context *ctx,
 
    if (src_image) {
       struct st_texture_image *src = st_texture_image(src_image);
+      struct st_texture_object *stObj = st_texture_object(src_image->TexObject);
       src_res = src->pt;
-      src_level = src_image->Level;
+      src_level = stObj->pt != src_res ? 0 : src_image->Level;
       src_z += src_image->Face;
       if (src_image->TexObject->Immutable) {
          src_level += src_image->TexObject->MinLevel;
@@ -660,8 +661,9 @@ st_CopyImageSubData(struct gl_context *ctx,
 
    if (dst_image) {
       struct st_texture_image *dst = st_texture_image(dst_image);
+      struct st_texture_object *stObj = st_texture_object(dst_image->TexObject);
       dst_res = dst->pt;
-      dst_level = dst_image->Level;
+      dst_level = stObj->pt != dst_res ? 0 : dst_image->Level;
       dst_z += dst_image->Face;
       if (dst_image->TexObject->Immutable) {
          dst_level += dst_image->TexObject->MinLevel;