summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-01-25 18:27:05 +0100
committerMarek Olšák <[email protected]>2013-01-26 14:58:52 +0100
commit26c872c2a22f25ec95065a71770b19b6a9eb06c7 (patch)
treea2e1f770d43c7a973b6a33f0578089dba0e9919e
parentedc38330da7cc9f87c94d8873f4d2244fc422807 (diff)
r600g: don't use radeon_surface_level::npix_x/y/z
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.
-rw-r--r--src/gallium/drivers/r600/evergreen_state.c2
-rw-r--r--src/gallium/drivers/r600/r600_blit.c28
-rw-r--r--src/gallium/drivers/r600/r600_state.c8
-rw-r--r--src/gallium/drivers/r600/r600_texture.c21
4 files changed, 27 insertions, 32 deletions
diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index 1d491535bd2..ac85fb43659 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -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;
diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c
index c4ce7f7652b..ed23052f548 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -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);
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 3ec21d20ef8..f3f7acb32c2 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -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)
diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c
index 45a30f85df4..340fa112f94 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -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,