r600g: don't use radeon_surface_level::npix_x/y/z
authorMarek Olšák <maraeo@gmail.com>
Fri, 25 Jan 2013 17:27:05 +0000 (18:27 +0100)
committerMarek Olšák <maraeo@gmail.com>
Sat, 26 Jan 2013 13:58:52 +0000 (14:58 +0100)
npix_x/y/z is wrong with NPOT textures, since it's always aligned to POT
if the level is non-zero, so we can't use that.

This fixes piglit/spec/EXT_texture_shared_exponent/fbo-generatemipmap-formats.

src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_blit.c
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_texture.c

index 1d491535bd227fa025ef15efccaf633c0e9b79a1..ac85fb43659ed4bcc835a59434a34a71da49bd03 100644 (file)
@@ -1090,7 +1090,7 @@ evergreen_create_sampler_view_custom(struct pipe_context *ctx,
 
        width = width0;
        height = height0;
-       depth = surflevel[0].npix_z;
+       depth = texture->depth0;
        pitch = surflevel[0].nblk_x * util_format_get_blockwidth(pipe_format);
        non_disp_tiling = tmp->non_disp_tiling;
 
index c4ce7f7652b98fc01adefb570ada83870a918ca3..ed23052f54802d3b2317b99cdeba1b425ea0ad84 100644 (file)
@@ -542,8 +542,6 @@ static void r600_resource_copy_region(struct pipe_context *ctx,
                                      const struct pipe_box *src_box)
 {
        struct r600_context *rctx = (struct r600_context *)ctx;
-       struct r600_texture *rsrc = (struct r600_texture*)src;
-       struct r600_texture *rdst = (struct r600_texture*)dst;
        struct pipe_surface *dst_view, dst_templ;
        struct pipe_sampler_view src_templ, *src_view;
        unsigned dst_width, dst_height, src_width0, src_height0, src_widthFL, src_heightFL;
@@ -565,12 +563,12 @@ static void r600_resource_copy_region(struct pipe_context *ctx,
                return; /* error */
        }
 
-       dst_width = rdst->surface.level[dst_level].npix_x;
-       dst_height = rdst->surface.level[dst_level].npix_y;
+       dst_width = u_minify(dst->width0, dst_level);
+        dst_height = u_minify(dst->height0, dst_level);
        src_width0 = src->width0;
        src_height0 = src->height0;
-       src_widthFL = rsrc->surface.level[src_level].npix_x;
-       src_heightFL = rsrc->surface.level[src_level].npix_y;
+        src_widthFL = u_minify(src->width0, src_level);
+        src_heightFL = u_minify(src->height0, src_level);
 
        util_blitter_default_dst_texture(&dst_templ, dst, dst_level, dstz);
        util_blitter_default_src_texture(&src_templ, src, src_level);
@@ -584,12 +582,12 @@ static void r600_resource_copy_region(struct pipe_context *ctx,
                        src_templ.format = PIPE_FORMAT_R32G32B32A32_UINT; /* 128-bit block */
                dst_templ.format = src_templ.format;
 
-               dst_width = util_format_get_nblocksx(dst->format, rdst->surface.level[dst_level].npix_x);
-               dst_height = util_format_get_nblocksy(dst->format, rdst->surface.level[dst_level].npix_y);
-               src_width0 = util_format_get_nblocksx(src->format, src->width0);
-               src_height0 = util_format_get_nblocksy(src->format, src->height0);
-               src_widthFL = util_format_get_nblocksx(src->format, rsrc->surface.level[src_level].npix_x);
-               src_heightFL = util_format_get_nblocksy(src->format, rsrc->surface.level[src_level].npix_y);
+               dst_width = util_format_get_nblocksx(dst->format, dst_width);
+               dst_height = util_format_get_nblocksy(dst->format, dst_height);
+               src_width0 = util_format_get_nblocksx(src->format, src_width0);
+               src_height0 = util_format_get_nblocksy(src->format, src_height0);
+               src_widthFL = util_format_get_nblocksx(src->format, src_widthFL);
+               src_heightFL = util_format_get_nblocksy(src->format, src_heightFL);
 
                dstx = util_format_get_nblocksx(dst->format, dstx);
                dsty = util_format_get_nblocksy(dst->format, dsty);
@@ -608,9 +606,9 @@ static void r600_resource_copy_region(struct pipe_context *ctx,
                        src_templ.format = PIPE_FORMAT_R8G8B8A8_UINT;
                        dst_templ.format = PIPE_FORMAT_R8G8B8A8_UINT;
 
-                       dst_width = util_format_get_nblocksx(dst->format, rdst->surface.level[dst_level].npix_x);
-                       src_width0 = util_format_get_nblocksx(src->format, src->width0);
-                       src_widthFL = util_format_get_nblocksx(src->format, rsrc->surface.level[src_level].npix_x);
+                       dst_width = util_format_get_nblocksx(dst->format, dst_width);
+                       src_width0 = util_format_get_nblocksx(src->format, src_width0);
+                       src_widthFL = util_format_get_nblocksx(src->format, src_widthFL);
 
                        dstx = util_format_get_nblocksx(dst->format, dstx);
 
index 3ec21d20ef8e8d16d1351f8981b2f7d4f3431283..f3f7acb32c2b1e4b39712a7608c488cca78262a4 100644 (file)
@@ -1071,7 +1071,7 @@ r600_create_sampler_view_custom(struct pipe_context *ctx,
        last_level = state->u.tex.last_level - offset_level;
        width = width_first_level;
        height = height_first_level;
-       depth = tmp->surface.level[offset_level].npix_z;
+        depth = u_minify(texture->depth0, offset_level);
        pitch = tmp->surface.level[offset_level].nblk_x * util_format_get_blockwidth(state->format);
 
        if (texture->target == PIPE_TEXTURE_1D_ARRAY) {
@@ -1135,11 +1135,9 @@ r600_create_sampler_view(struct pipe_context *ctx,
                         struct pipe_resource *tex,
                         const struct pipe_sampler_view *state)
 {
-       struct r600_texture *rtex = (struct r600_texture*)tex;
-
        return r600_create_sampler_view_custom(ctx, tex, state,
-                                              rtex->surface.level[state->u.tex.first_level].npix_x,
-                                              rtex->surface.level[state->u.tex.first_level].npix_y);
+                                               u_minify(tex->width0, state->u.tex.first_level),
+                                               u_minify(tex->height0, state->u.tex.first_level));
 }
 
 static void r600_emit_clip_state(struct r600_context *rctx, struct r600_atom *atom)
index 45a30f85df483c7cbf4bef18eecdf0404ae365ac..340fa112f94b75708db09bbf58fad5db15042f14 100644 (file)
@@ -514,9 +514,9 @@ r600_texture_create_object(struct pipe_screen *screen,
                                       "nblk_z=%u, pitch_bytes=%u, mode=%u\n",
                                       i, (unsigned long long)rtex->surface.level[i].offset,
                                       (unsigned long long)rtex->surface.level[i].slice_size,
-                                      rtex->surface.level[i].npix_x,
-                                      rtex->surface.level[i].npix_y,
-                                      rtex->surface.level[i].npix_z,
+                                      u_minify(rtex->resource.b.b.width0, i),
+                                      u_minify(rtex->resource.b.b.height0, i),
+                                      u_minify(rtex->resource.b.b.depth0, i),
                                       rtex->surface.level[i].nblk_x,
                                       rtex->surface.level[i].nblk_y,
                                       rtex->surface.level[i].nblk_z,
@@ -531,9 +531,9 @@ r600_texture_create_object(struct pipe_screen *screen,
                                       "nblk_z=%u, pitch_bytes=%u, mode=%u\n",
                                       i, (unsigned long long)rtex->surface.stencil_level[i].offset,
                                       (unsigned long long)rtex->surface.stencil_level[i].slice_size,
-                                      rtex->surface.stencil_level[i].npix_x,
-                                      rtex->surface.stencil_level[i].npix_y,
-                                      rtex->surface.stencil_level[i].npix_z,
+                                       u_minify(rtex->resource.b.b.width0, i),
+                                      u_minify(rtex->resource.b.b.height0, i),
+                                      u_minify(rtex->resource.b.b.depth0, i),
                                       rtex->surface.stencil_level[i].nblk_x,
                                       rtex->surface.stencil_level[i].nblk_y,
                                       rtex->surface.stencil_level[i].nblk_z,
@@ -612,15 +612,14 @@ struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe,
 }
 
 static struct pipe_surface *r600_create_surface(struct pipe_context *pipe,
-                                               struct pipe_resource *texture,
+                                               struct pipe_resource *tex,
                                                const struct pipe_surface *templ)
 {
-       struct r600_texture *rtex = (struct r600_texture*)texture;
        unsigned level = templ->u.tex.level;
 
-       return r600_create_surface_custom(pipe, texture, templ,
-                                         rtex->surface.level[level].npix_x,
-                                         rtex->surface.level[level].npix_y);
+       return r600_create_surface_custom(pipe, tex, templ,
+                                          u_minify(tex->width0, level),
+                                         u_minify(tex->height0, level));
 }
 
 static void r600_surface_destroy(struct pipe_context *pipe,