[Mesa-dev] [PATCH 3/3] st/mesa: set PIPE_RESOURCE_FLAG_TEXTURE_RECT_SEMANTICS for GL_TEXTURE_RECTANGLE (v3)

Luca Barbieri luca at luca-barbieri.com
Tue Aug 17 12:54:31 PDT 2010


Changes in v3:
- Renamed flag from PIPE_RESOURCE_FLAG_UNNORMALIZED_COORDS_HINT

Changes in v2:
- No longer set the flag in compress_with_blit depending on NPOT, let the
  driver do that if needed

Allow to pass flags to st_texture_create and take advantage of that
to tell the pipe driver that a texture is going to be used with unnormalized
coordinates.

This is useful for hardware with no mipmapped NPOT support that needs to
allocate texture rectangles in a special way (e.g. nv30).
---
 src/mesa/state_tracker/st_atom_pixeltransfer.c |    2 +-
 src/mesa/state_tracker/st_cb_bitmap.c          |    4 ++--
 src/mesa/state_tracker/st_cb_drawpixels.c      |    2 +-
 src/mesa/state_tracker/st_cb_texture.c         |   17 ++++++++++++++---
 src/mesa/state_tracker/st_gen_mipmap.c         |    3 ++-
 src/mesa/state_tracker/st_texture.c            |    5 +++--
 src/mesa/state_tracker/st_texture.h            |    3 ++-
 7 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c
index 8a8d175..449847c 100644
--- a/src/mesa/state_tracker/st_atom_pixeltransfer.c
+++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c
@@ -128,7 +128,7 @@ create_color_map_texture(GLcontext *ctx)
 
    /* create texture for color map/table */
    pt = st_texture_create(st, PIPE_TEXTURE_2D, format, 0,
-                          texSize, texSize, 1, PIPE_BIND_SAMPLER_VIEW);
+                          texSize, texSize, 1, PIPE_BIND_SAMPLER_VIEW, 0);
    return pt;
 }
 
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index f3e2230..df74741 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -277,7 +277,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
     */
    pt = st_texture_create(st, PIPE_TEXTURE_2D, st->bitmap.tex_format,
                           0, width, height, 1,
-                          PIPE_BIND_SAMPLER_VIEW);
+                          PIPE_BIND_SAMPLER_VIEW, 0);
    if (!pt) {
       _mesa_unmap_pbo_source(ctx, unpack);
       return NULL;
@@ -550,7 +550,7 @@ reset_cache(struct st_context *st)
                                       st->bitmap.tex_format, 0,
                                       BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT,
                                       1,
-				      PIPE_BIND_SAMPLER_VIEW);
+				      PIPE_BIND_SAMPLER_VIEW, 0);
 }
 
 
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index b074c13..68347c5 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -306,7 +306,7 @@ alloc_texture(struct st_context *st, GLsizei width, GLsizei height,
    struct pipe_resource *pt;
 
    pt = st_texture_create(st, PIPE_TEXTURE_2D, texFormat, 0,
-                          width, height, 1, PIPE_BIND_SAMPLER_VIEW);
+                          width, height, 1, PIPE_BIND_SAMPLER_VIEW, 0);
 
    return pt;
 }
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 4c3e368..2ef5451 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -265,7 +265,7 @@ guess_and_alloc_texture(struct st_context *st,
 {
    const GLuint dims = get_texture_dims(stObj->base.Target);
    GLuint level, lastLevel, width, height, depth;
-   GLuint bindings;
+   GLuint bindings, flags;
    enum pipe_format fmt;
 
    DBG("%s\n", __FUNCTION__);
@@ -343,6 +343,11 @@ guess_and_alloc_texture(struct st_context *st,
 
    bindings = default_bindings(st, fmt);
 
+   flags = 0;
+
+   if(stObj->base.Target == GL_TEXTURE_RECTANGLE)
+      flags |= PIPE_RESOURCE_FLAG_TEXTURE_RECT_SEMANTICS;
+
    stObj->pt = st_texture_create(st,
                                  gl_target_to_pipe(stObj->base.Target),
                                  fmt,
@@ -350,7 +355,8 @@ guess_and_alloc_texture(struct st_context *st,
                                  width,
                                  height,
                                  depth,
-                                 bindings);
+                                 bindings,
+                                 flags);
 
    DBG("%s returning %d\n", __FUNCTION__, (stObj->pt != NULL));
 
@@ -1867,6 +1873,10 @@ st_finalize_texture(GLcontext *ctx,
     */
    if (!stObj->pt) {
       GLuint bindings = default_bindings(st, firstImageFormat);
+      GLuint flags = 0;
+
+      if(stObj->base.Target == GL_TEXTURE_RECTANGLE)
+         flags |= PIPE_RESOURCE_FLAG_TEXTURE_RECT_SEMANTICS;
 
       stObj->pt = st_texture_create(st,
                                     gl_target_to_pipe(stObj->base.Target),
@@ -1875,7 +1885,8 @@ st_finalize_texture(GLcontext *ctx,
                                     stObj->width0,
                                     stObj->height0,
                                     stObj->depth0,
-                                    bindings);
+                                    bindings,
+                                    flags);
 
       if (!stObj->pt) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index 2d587df..7fdf574 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -348,7 +348,8 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
                                     oldTex->width0,
                                     oldTex->height0,
                                     oldTex->depth0,
-                                    oldTex->bind);
+                                    oldTex->bind,
+                                    0);
 
       /* 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().
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index add6e94..95abb3b 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -59,7 +59,8 @@ st_texture_create(struct st_context *st,
 		  GLuint width0,
 		  GLuint height0,
 		  GLuint depth0,
-                  GLuint bind )
+                  GLuint bind,
+                  GLuint flags)
 {
    struct pipe_resource pt, *newtex;
    struct pipe_screen *screen = st->pipe->screen;
@@ -86,7 +87,7 @@ st_texture_create(struct st_context *st,
    pt.depth0 = depth0;
    pt.usage = PIPE_USAGE_DEFAULT;
    pt.bind = bind;
-   pt.flags = 0;
+   pt.flags = flags;
 
    newtex = screen->resource_create(screen, &pt);
 
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index ed5d271..3908e2a 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -158,7 +158,8 @@ st_texture_create(struct st_context *st,
                   GLuint width0,
                   GLuint height0,
                   GLuint depth0,
-                  GLuint tex_usage );
+                  GLuint tex_usage,
+                  GLuint flags);
 
 
 /* Check if an image fits into an existing texture object.
-- 
1.7.0.4



More information about the mesa-dev mailing list