st: Add cubeMapFace parameter to st_finalize_texture.
authorMichal Srb <msrb@suse.com>
Tue, 28 Mar 2017 20:39:28 +0000 (23:39 +0300)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Sat, 1 Apr 2017 07:03:23 +0000 (09:03 +0200)
st_finalize_texture always accesses image at face 0, but it may not be
set if we are working with cubemap that had other face set.

This fixes crash in piglit
same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/state_trackers/dri/dri2.c
src/mesa/state_tracker/st_atom_image.c
src/mesa/state_tracker/st_atom_texture.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_cb_texture.h
src/mesa/state_tracker/st_gen_mipmap.c

index b50e09644319c83d50050ff7105ace716878c896..ed6004f836d60ff2ca375f07a838243b5fb8d2f2 100644 (file)
@@ -1808,7 +1808,7 @@ dri2_interop_export_object(__DRIcontext *_ctx,
          return MESA_GLINTEROP_INVALID_MIP_LEVEL;
       }
 
-      if (!st_finalize_texture(ctx, st->pipe, obj)) {
+      if (!st_finalize_texture(ctx, st->pipe, obj, 0)) {
          mtx_unlock(&ctx->Shared->Mutex);
          return MESA_GLINTEROP_OUT_OF_RESOURCES;
       }
index 5dd2cd64f904aa22827f47c012f66e58e0179c15..4101552dff4e5bb9bc7204ac94cc47dc3bc980a4 100644 (file)
@@ -64,7 +64,7 @@ st_bind_images(struct st_context *st, struct gl_program *prog,
       struct pipe_image_view *img = &images[i];
 
       if (!_mesa_is_image_unit_valid(st->ctx, u) ||
-          !st_finalize_texture(st->ctx, st->pipe, u->TexObj) ||
+          !st_finalize_texture(st->ctx, st->pipe, u->TexObj, 0) ||
           !stObj->pt) {
          memset(img, 0, sizeof(*img));
          continue;
index 92023e0dc3ab9946a4972a5832252d313f4f66ef..5b481ec43443d8c16c2ae1c8192f88bf124aba35 100644 (file)
@@ -73,7 +73,7 @@ update_single_texture(struct st_context *st,
    }
    stObj = st_texture_object(texObj);
 
-   retval = st_finalize_texture(ctx, st->pipe, texObj);
+   retval = st_finalize_texture(ctx, st->pipe, texObj, 0);
    if (!retval) {
       /* out of mem */
       return GL_FALSE;
index 78433bff046626548c55d959cadbb90c19c3cde8..dce4239438a23ce6dcb6cb0b04dfda15c0236189 100644 (file)
@@ -488,7 +488,7 @@ st_render_texture(struct gl_context *ctx,
    struct st_renderbuffer *strb = st_renderbuffer(rb);
    struct pipe_resource *pt;
 
-   if (!st_finalize_texture(ctx, pipe, att->Texture))
+   if (!st_finalize_texture(ctx, pipe, att->Texture, att->CubeMapFace))
       return;
 
    pt = st_get_texobj_resource(att->Texture);
index bc6f108a860599f3a517a001deb46021952ed62d..1b486d7c3c84d1a71014cfce01b2a9243000832d 100644 (file)
@@ -2434,7 +2434,8 @@ copy_image_data_to_texture(struct st_context *st,
 GLboolean
 st_finalize_texture(struct gl_context *ctx,
                    struct pipe_context *pipe,
-                   struct gl_texture_object *tObj)
+                   struct gl_texture_object *tObj,
+                   GLuint cubeMapFace)
 {
    struct st_context *st = st_context(ctx);
    struct st_texture_object *stObj = st_texture_object(tObj);
@@ -2478,7 +2479,7 @@ st_finalize_texture(struct gl_context *ctx,
 
    }
 
-   firstImage = st_texture_image_const(_mesa_base_tex_image(&stObj->base));
+   firstImage = st_texture_image_const(stObj->base.Image[cubeMapFace][stObj->base.BaseLevel]);
    assert(firstImage);
 
    /* If both firstImage and stObj point to a texture which can contain
index 415d59ffe98d006bf09d99b816dfcba65f48a613..f647b16c8dcd5f2504991673375689caf403d509 100644 (file)
@@ -47,7 +47,8 @@ st_get_blit_mask(GLenum srcFormat, GLenum dstFormat);
 extern GLboolean
 st_finalize_texture(struct gl_context *ctx,
                    struct pipe_context *pipe, 
-                   struct gl_texture_object *tObj);
+                   struct gl_texture_object *tObj,
+                   GLuint cubeMapFace);
 
 
 extern void
index 10af11e17b4f2af72be7e90179838e09de93086f..16b914a88459e995cd676c4a41b03813c382eaf8 100644 (file)
@@ -125,7 +125,7 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
        *
        * After this, we'll have all mipmap levels in one resource.
        */
-      st_finalize_texture(ctx, st->pipe, texObj);
+      st_finalize_texture(ctx, st->pipe, texObj, 0);
    }
 
    pt = stObj->pt;