summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/r300/r300_state.c
diff options
context:
space:
mode:
authorNicolai Haehnle <nhaehnle@gmail.com>2007-03-24 19:08:26 +0100
committerNicolai Haehnle <nhaehnle@gmail.com>2007-03-24 19:09:44 +0100
commitf27991c9165450872c652e2fd27811409957b2a0 (patch)
treee9e5e8d3023498c04c2b04fe5dce9a554d10f2e0 /src/mesa/drivers/dri/r300/r300_state.c
parent0c3ae2ea7fbb9c1087bdbc1048c380ca760b80d2 (diff)
r300: Fix texture coordinate calculation for rectangle textures
R300 hardware takes texcoords in the range 0..1 even for rectangle textures. Previously, the necessary texcoord conversion was applied to the texture coordinate during vertex processing in a render stage. This is obviously wrong when fragment programs are used, which can calculate arbitrary coordinates for TEX instructions. Therefore, we now inject an appropriate MUL instruction before a TEX that reference a rectangle texture.
Diffstat (limited to 'src/mesa/drivers/dri/r300/r300_state.c')
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index 4fd80e60fe..17658efdb2 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -1058,23 +1058,41 @@ r300UpdateDrawBuffer(GLcontext *ctx)
static void r300FetchStateParameter(GLcontext *ctx, const enum state_index state[],
GLfloat *value)
{
- r300ContextPtr r300 = R300_CONTEXT(ctx);
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
- switch(state[0])
- {
- case STATE_INTERNAL:
- switch(state[1])
- {
- case STATE_R300_WINDOW_DIMENSION:
- value[0] = r300->radeon.dri.drawable->w*0.5f;/* width*0.5 */
- value[1] = r300->radeon.dri.drawable->h*0.5f;/* height*0.5 */
- value[2] = 0.5F; /* for moving range [-1 1] -> [0 1] */
- value[3] = 1.0F; /* not used */
- break;
- default:;
+ switch(state[0]) {
+ case STATE_INTERNAL:
+ switch(state[1]) {
+ case STATE_R300_WINDOW_DIMENSION:
+ value[0] = r300->radeon.dri.drawable->w*0.5f;/* width*0.5 */
+ value[1] = r300->radeon.dri.drawable->h*0.5f;/* height*0.5 */
+ value[2] = 0.5F; /* for moving range [-1 1] -> [0 1] */
+ value[3] = 1.0F; /* not used */
+ break;
+
+ case STATE_R300_TEXRECT_FACTOR: {
+ struct gl_texture_object* t = ctx->Texture.Unit[state[2]].CurrentRect;
+
+ if (t && t->Image[0][t->BaseLevel]) {
+ struct gl_texture_image* image = t->Image[0][t->BaseLevel];
+ value[0] = 1.0 / image->Width2;
+ value[1] = 1.0 / image->Height2;
+ } else {
+ value[0] = 1.0;
+ value[1] = 1.0;
+ }
+ value[2] = 1.0;
+ value[3] = 1.0;
+ break; }
+
+ default:
+ break;
+ }
+ break;
+
+ default:
+ break;
}
- default:;
- }
}
/**