Mesa (master): r300g: do not use TXPITCH_EN if the width is POT and the height is NPOT
Marek Olšák
mareko at kemper.freedesktop.org
Sun Jul 25 09:07:30 UTC 2010
Module: Mesa
Branch: master
Commit: 49330fc5ac13e25cb201e62995329cffaf5046f0
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=49330fc5ac13e25cb201e62995329cffaf5046f0
Author: Marek Olšák <maraeo at gmail.com>
Date: Sat Jul 24 23:05:40 2010 +0200
r300g: do not use TXPITCH_EN if the width is POT and the height is NPOT
---
src/gallium/drivers/r300/r300_context.h | 13 ++++++-------
src/gallium/drivers/r300/r300_fs.c | 2 +-
src/gallium/drivers/r300/r300_state.c | 2 +-
src/gallium/drivers/r300/r300_state_derived.c | 2 +-
src/gallium/drivers/r300/r300_texture.c | 3 ++-
src/gallium/drivers/r300/r300_texture_desc.c | 4 ++++
6 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index 06e4e12..b4256c6 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -361,13 +361,12 @@ struct r300_texture_desc {
*/
unsigned stride_in_bytes_override;
- /* Whether this texture has non-power-of-two dimensions
- * or a user-specified stride.
- * It can be either a regular texture or a rectangle one.
- *
- * This flag says that hardware must use the stride for addressing
- * instead of the width.
- */
+ /* Whether this texture has non-power-of-two dimensions.
+ * It can be either a regular texture or a rectangle one. */
+ boolean is_npot;
+
+ /* This flag says that hardware must use the stride for addressing
+ * instead of the width. */
boolean uses_stride_addressing;
/* Whether CBZB fast color clear is allowed on the miplevel. */
diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c
index 6eac12b..db52699 100644
--- a/src/gallium/drivers/r300/r300_fs.c
+++ b/src/gallium/drivers/r300/r300_fs.c
@@ -173,7 +173,7 @@ static void get_external_state(
t = (struct r300_texture*)texstate->sampler_views[i]->base.texture;
/* XXX this should probably take into account STR, not just S. */
- if (t->desc.uses_stride_addressing) {
+ if (t->desc.is_npot) {
switch (s->state.wrap_s) {
case PIPE_TEX_WRAP_REPEAT:
state->unit[i].wrap_mode = RC_WRAP_REPEAT;
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 6e2a6ca..bbea7e1 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -1296,7 +1296,7 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe,
/* Set the texrect factor in the fragment shader.
* Needed for RECT and NPOT fallback. */
texture = r300_texture(views[i]->texture);
- if (texture->desc.uses_stride_addressing) {
+ if (texture->desc.is_npot) {
r300->fs_rc_constant_state.dirty = TRUE;
}
diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c
index e20d8d0..48912e1 100644
--- a/src/gallium/drivers/r300/r300_state_derived.c
+++ b/src/gallium/drivers/r300/r300_state_derived.c
@@ -583,7 +583,7 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300)
texstate->filter0 |= R300_TX_WRAP_T(R300_TX_CLAMP_TO_EDGE);
}
- if (tex->desc.uses_stride_addressing) {
+ if (tex->desc.is_npot) {
/* NPOT textures don't support mip filter, unfortunately.
* This prevents incorrect rendering. */
texstate->filter0 &= ~R300_TX_MIN_FILTER_MIP_MASK;
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index e99a463..f1118df 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -552,7 +552,8 @@ static void r300_texture_setup_immutable_state(struct r300_screen* screen,
f->format0 |= R300_TX_PITCH_EN;
f->format2 = (tex->desc.stride_in_pixels[0] - 1) & 0x1fff;
} else {
- /* power of two textures (3D, mipmaps, and no pitch) */
+ /* Power of two textures (3D, mipmaps, and no pitch),
+ * also NPOT textures with a width being POT. */
f->format0 |= R300_TX_DEPTH(util_logbase2(pt->depth0) & 0xf);
}
diff --git a/src/gallium/drivers/r300/r300_texture_desc.c b/src/gallium/drivers/r300/r300_texture_desc.c
index becaa59..02591aa 100644
--- a/src/gallium/drivers/r300/r300_texture_desc.c
+++ b/src/gallium/drivers/r300/r300_texture_desc.c
@@ -272,6 +272,10 @@ static void r300_setup_flags(struct r300_texture_desc *desc)
(desc->stride_in_bytes_override &&
stride_to_width(desc->b.b.format,
desc->stride_in_bytes_override) != desc->b.b.width0);
+
+ desc->is_npot =
+ desc->uses_stride_addressing ||
+ !util_is_power_of_two(desc->b.b.height0);
}
static void r300_setup_cbzb_flags(struct r300_screen *rscreen,
More information about the mesa-commit
mailing list