swr: add support for upper-left fragcoord position
authorIlia Mirkin <imirkin@alum.mit.edu>
Sat, 12 Nov 2016 23:58:46 +0000 (18:58 -0500)
committerIlia Mirkin <imirkin@alum.mit.edu>
Wed, 16 Nov 2016 01:26:11 +0000 (20:26 -0500)
Fixes glsl-arb-fragment-coord-conventions.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Tim Rowley <timothy.o.rowley@intel.com>
src/gallium/drivers/swr/swr_shader.cpp

index 38a916e272ce4d938f83fcfa20075555c4f87350..04637e506f87816e7c9976e214bbb9b59885e297 100644 (file)
@@ -480,8 +480,14 @@ BuilderSWR::CompileFS(struct swr_context *ctx, swr_jit_fs_key &key)
          inputs[attrib][3] = wrap(VIMMED1(1.0f));
          continue;
       } else if (semantic_name == TGSI_SEMANTIC_POSITION) { // gl_FragCoord
-         inputs[attrib][0] = wrap(LOAD(pPS, {0, SWR_PS_CONTEXT_vX, PixelPositions_center}, "vX"));
-         inputs[attrib][1] = wrap(LOAD(pPS, {0, SWR_PS_CONTEXT_vY, PixelPositions_center}, "vY"));
+         if (swr_fs->info.base.properties[TGSI_PROPERTY_FS_COORD_PIXEL_CENTER] ==
+             TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER) {
+            inputs[attrib][0] = wrap(LOAD(pPS, {0, SWR_PS_CONTEXT_vX, PixelPositions_center}, "vX"));
+            inputs[attrib][1] = wrap(LOAD(pPS, {0, SWR_PS_CONTEXT_vY, PixelPositions_center}, "vY"));
+         } else {
+            inputs[attrib][0] = wrap(LOAD(pPS, {0, SWR_PS_CONTEXT_vX, PixelPositions_UL}, "vX"));
+            inputs[attrib][1] = wrap(LOAD(pPS, {0, SWR_PS_CONTEXT_vY, PixelPositions_UL}, "vY"));
+         }
          inputs[attrib][2] = wrap(LOAD(pPS, {0, SWR_PS_CONTEXT_vZ}, "vZ"));
          inputs[attrib][3] =
             wrap(LOAD(pPS, {0, SWR_PS_CONTEXT_vOneOverW, PixelPositions_center}, "vOneOverW"));