st/mesa: use surface format to generate mipmaps when available
authorIlia Mirkin <imirkin@alum.mit.edu>
Thu, 14 Jan 2016 18:44:54 +0000 (13:44 -0500)
committerIlia Mirkin <imirkin@alum.mit.edu>
Thu, 14 Jan 2016 19:28:04 +0000 (14:28 -0500)
This fixes the recently posted mipmap + texture views piglit test.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "11.0 11.1" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/mesa/state_tracker/st_gen_mipmap.c

index 3e6c0a73bc75fb060f385af8f80ca30edf0c5db1..c4b3492b0d3b86f9f4f34d22ee3478560f6fb74f 100644 (file)
@@ -80,6 +80,7 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
    struct st_texture_object *stObj = st_texture_object(texObj);
    struct pipe_resource *pt = st_get_texobj_resource(texObj);
    const uint baseLevel = texObj->BaseLevel;
+   enum pipe_format format;
    uint lastLevel, first_layer, last_layer;
    uint dstLevel;
 
@@ -149,16 +150,21 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
       last_layer = util_max_layer(pt, baseLevel);
    }
 
+   if (stObj->surface_based)
+      format = stObj->surface_format;
+   else
+      format = pt->format;
+
    /* First see if the driver supports hardware mipmap generation,
     * if not then generate the mipmap by rendering/texturing.
     * If that fails, use the software fallback.
     */
    if (!st->pipe->screen->get_param(st->pipe->screen,
                                     PIPE_CAP_GENERATE_MIPMAP) ||
-       !st->pipe->generate_mipmap(st->pipe, pt, pt->format, baseLevel,
+       !st->pipe->generate_mipmap(st->pipe, pt, format, baseLevel,
                                   lastLevel, first_layer, last_layer)) {
 
-      if (!util_gen_mipmap(st->pipe, pt, pt->format, baseLevel, lastLevel,
+      if (!util_gen_mipmap(st->pipe, pt, format, baseLevel, lastLevel,
                            first_layer, last_layer, PIPE_TEX_FILTER_LINEAR)) {
          _mesa_generate_mipmap(ctx, target, texObj);
       }