Merge remote branch 'origin/7.8'
[mesa.git] / src / mesa / state_tracker / st_gen_mipmap.c
index 3823a59d37a63149920a40c038b8d86c33558f9c..5b7a96203793cf850c5869891b0f4514baee4477 100644 (file)
@@ -36,7 +36,7 @@
 
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
 #include "util/u_format.h"
 #include "util/u_gen_mipmap.h"
 #include "util/u_math.h"
@@ -79,22 +79,23 @@ st_destroy_generate_mipmap(struct st_context *st)
 static boolean
 st_render_mipmap(struct st_context *st,
                  GLenum target,
-                 struct pipe_texture *pt,
+                 struct st_texture_object *stObj,
                  uint baseLevel, uint lastLevel)
 {
    struct pipe_context *pipe = st->pipe;
    struct pipe_screen *screen = pipe->screen;
+   struct pipe_sampler_view *psv = st_get_texture_sampler_view(stObj, pipe);
    const uint face = _mesa_tex_target_to_face(target);
 
    assert(target != GL_TEXTURE_3D); /* not done yet */
 
    /* check if we can render in the texture's format */
-   if (!screen->is_format_supported(screen, pt->format, pt->target,
-                                    PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
+   if (!screen->is_format_supported(screen, psv->format, psv->texture->target,
+                                    PIPE_BIND_RENDER_TARGET, 0)) {
       return FALSE;
    }
 
-   util_gen_mipmap(st->gen_mipmap, pt, face, baseLevel, lastLevel,
+   util_gen_mipmap(st->gen_mipmap, psv, face, baseLevel, lastLevel,
                    PIPE_TEX_FILTER_LINEAR);
 
    return TRUE;
@@ -106,8 +107,7 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
                          struct gl_texture_object *texObj)
 {
    struct pipe_context *pipe = ctx->st->pipe;
-   struct pipe_screen *screen = pipe->screen;
-   struct pipe_texture *pt = st_get_texobj_texture(texObj);
+   struct pipe_resource *pt = st_get_texobj_resource(texObj);
    const uint baseLevel = texObj->BaseLevel;
    const uint lastLevel = pt->last_level;
    const uint face = _mesa_tex_target_to_face(target), zslice = 0;
@@ -142,11 +142,11 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
                                                u_minify(pt->width0, dstLevel),
                                                u_minify(pt->height0, dstLevel));
 
-      srcData = (ubyte *) screen->transfer_map(screen, srcTrans);
-      dstData = (ubyte *) screen->transfer_map(screen, dstTrans);
+      srcData = (ubyte *) pipe_transfer_map(pipe, srcTrans);
+      dstData = (ubyte *) pipe_transfer_map(pipe, dstTrans);
 
-      srcStride = srcTrans->stride / util_format_get_blocksize(srcTrans->texture->format);
-      dstStride = dstTrans->stride / util_format_get_blocksize(dstTrans->texture->format);
+      srcStride = srcTrans->stride / util_format_get_blocksize(srcTrans->resource->format);
+      dstStride = dstTrans->stride / util_format_get_blocksize(dstTrans->resource->format);
 
       _mesa_generate_mipmap_level(target, datatype, comps,
                                   0 /*border*/,
@@ -161,11 +161,11 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
                                   dstData,
                                   dstStride); /* stride in texels */
 
-      screen->transfer_unmap(screen, srcTrans);
-      screen->transfer_unmap(screen, dstTrans);
+      pipe_transfer_unmap(pipe, srcTrans);
+      pipe_transfer_unmap(pipe, dstTrans);
 
-      screen->tex_transfer_destroy(srcTrans);
-      screen->tex_transfer_destroy(dstTrans);
+      pipe->transfer_destroy(pipe, srcTrans);
+      pipe->transfer_destroy(pipe, dstTrans);
    }
 }
 
@@ -212,7 +212,8 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
                    struct gl_texture_object *texObj)
 {
    struct st_context *st = ctx->st;
-   struct pipe_texture *pt = st_get_texobj_texture(texObj);
+   struct st_texture_object *stObj = st_texture_object(texObj);
+   struct pipe_resource *pt = st_get_texobj_resource(texObj);
    const uint baseLevel = texObj->BaseLevel;
    uint lastLevel;
    uint dstLevel;
@@ -230,8 +231,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
       /* The current gallium texture doesn't have space for all the
        * mipmap levels we need to generate.  So allocate a new texture.
        */
-      struct st_texture_object *stObj = st_texture_object(texObj);
-      struct pipe_texture *oldTex = stObj->pt;
+      struct pipe_resource *oldTex = stObj->pt;
       GLboolean needFlush;
 
       /* create new texture with space for more levels */
@@ -242,7 +242,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
                                     oldTex->width0,
                                     oldTex->height0,
                                     oldTex->depth0,
-                                    oldTex->tex_usage);
+                                    oldTex->bind);
 
       /* The texture isn't in a "complete" state yet so set the expected
        * lastLevel here, since it won't get done in st_finalize_texture().
@@ -255,7 +255,8 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
       st_finalize_texture(ctx, st->pipe, texObj, &needFlush);
 
       /* release the old tex (will likely be freed too) */
-      pipe_texture_reference(&oldTex, NULL);
+      pipe_resource_reference(&oldTex, NULL);
+      pipe_sampler_view_reference(&stObj->sampler_view, NULL);
 
       pt = stObj->pt;
    }
@@ -265,7 +266,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
    /* Recall that the Mesa BaseLevel image is stored in the gallium
     * texture's level[0] position.  So pass baseLevel=0 here.
     */
-   if (!st_render_mipmap(st, target, pt, 0, lastLevel)) {
+   if (!st_render_mipmap(st, target, stObj, 0, lastLevel)) {
       fallback_generate_mipmap(ctx, target, texObj);
    }
 
@@ -298,6 +299,6 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
       dstImage->TexFormat = srcImage->TexFormat;
 
       stImage = (struct st_texture_image *) dstImage;
-      pipe_texture_reference(&stImage->pt, pt);
+      pipe_resource_reference(&stImage->pt, pt);
    }
 }