aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/softpipe/sp_setup.c
diff options
context:
space:
mode:
authorLuca Barbieri <[email protected]>2010-01-21 05:38:45 +0100
committerLuca Barbieri <[email protected]>2010-01-29 14:14:29 +0100
commitb2299d80b4278b8b6553d4e4da4d40d37881d76e (patch)
treee68e2744fc1e0f916aa2a014404eb37055036870 /src/gallium/drivers/softpipe/sp_setup.c
parent62c673b6ac65d27ed83acc92434874b45f75db5c (diff)
softpipe: support all TGSI fragment coord conventions (v4)
Changes in v4: - Rebase and modify for changes in previous patches Changes in v3: - Use positive caps instead of negative caps Changes in v2: - Now takes the fragment convention directly from the fragment shader Adds internal support for all fragment coord conventions to softpipe. This patch is not required for use with the current state trackers, but it allows softpipe to run any TGSI program and enhances performance.
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_setup.c')
-rw-r--r--src/gallium/drivers/softpipe/sp_setup.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c
index ba1f0f0b2ea..bb1bff581cf 100644
--- a/src/gallium/drivers/softpipe/sp_setup.c
+++ b/src/gallium/drivers/softpipe/sp_setup.c
@@ -504,21 +504,24 @@ static void tri_persp_coeff( struct setup_context *setup,
/**
* Special coefficient setup for gl_FragCoord.
- * X and Y are trivial, though Y has to be inverted for OpenGL.
+ * X and Y are trivial, though Y may have to be inverted for OpenGL.
* Z and W are copied from posCoef which should have already been computed.
* We could do a bit less work if we'd examine gl_FragCoord's swizzle mask.
*/
static void
setup_fragcoord_coeff(struct setup_context *setup, uint slot)
{
+ struct sp_fragment_shader* spfs = setup->softpipe->fs;
/*X*/
- setup->coef[slot].a0[0] = 0;
+ setup->coef[slot].a0[0] = spfs->pixel_center_integer ? 0.0 : 0.5;
setup->coef[slot].dadx[0] = 1.0;
setup->coef[slot].dady[0] = 0.0;
/*Y*/
- setup->coef[slot].a0[1] = 0.0;
+ setup->coef[slot].a0[1] =
+ (spfs->origin_lower_left ? setup->softpipe->framebuffer.height : 0)
+ + (spfs->pixel_center_integer ? 0.0 : 0.5);
setup->coef[slot].dadx[1] = 0.0;
- setup->coef[slot].dady[1] = 1.0;
+ setup->coef[slot].dady[1] = spfs->origin_lower_left ? -1.0 : 1.0;
/*Z*/
setup->coef[slot].a0[2] = setup->posCoef.a0[2];
setup->coef[slot].dadx[2] = setup->posCoef.dadx[2];