Mesa (master): r600g: vertex id support.

Dave Airlie airlied at kemper.freedesktop.org
Sun Jan 15 08:20:28 UTC 2012


Module: Mesa
Branch: master
Commit: 39491d1d31d9f03437816fbb4f2872761ae1157c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=39491d1d31d9f03437816fbb4f2872761ae1157c

Author: Dave Airlie <airlied at redhat.com>
Date:   Sat Jan 14 17:04:50 2012 +0000

r600g: vertex id support.

This requires GLSL 1.30 enabled, which requires integer types enabled,
so don't bother doing an INT to FLT conversion on it.

We should probably remove the instance id flt->int conversion when
turning on native integers.

this passes the three piglit tests with GLSL 1.30 forced on.

Signed-off-by: Dave Airlie <airlied at redhat.com>

---

 src/gallium/drivers/r600/r600_shader.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index 071622d..bc3652b 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -453,8 +453,8 @@ static int tgsi_declaration(struct r600_shader_ctx *ctx)
 			if ((r = r600_bytecode_add_alu(ctx->bc, &alu)))
 				return r;
 			break;
-		}
-
+		} else if (d->Semantic.Name == TGSI_SEMANTIC_VERTEXID)
+			break;
 	default:
 		R600_ERR("unsupported file %d declaration\n", d->Declaration.File);
 		return -EINVAL;
@@ -541,12 +541,19 @@ static void tgsi_src(struct r600_shader_ctx *ctx,
 		r600_src->sel = V_SQ_ALU_SRC_LITERAL;
 		memcpy(r600_src->value, ctx->literals + index * 4, sizeof(r600_src->value));
 	} else if (tgsi_src->Register.File == TGSI_FILE_SYSTEM_VALUE) {
-		/* assume we wan't TGSI_SEMANTIC_INSTANCEID here */
-		r600_src->swizzle[0] = 3;
-		r600_src->swizzle[1] = 3;
-		r600_src->swizzle[2] = 3;
-		r600_src->swizzle[3] = 3;
-		r600_src->sel = 0;
+		if (ctx->info.system_value_semantic_name[tgsi_src->Register.Index] == TGSI_SEMANTIC_INSTANCEID) {
+			r600_src->swizzle[0] = 3;
+			r600_src->swizzle[1] = 3;
+			r600_src->swizzle[2] = 3;
+			r600_src->swizzle[3] = 3;
+			r600_src->sel = 0;
+		} else if (ctx->info.system_value_semantic_name[tgsi_src->Register.Index] == TGSI_SEMANTIC_VERTEXID) {
+			r600_src->swizzle[0] = 0;
+			r600_src->swizzle[1] = 0;
+			r600_src->swizzle[2] = 0;
+			r600_src->swizzle[3] = 0;
+			r600_src->sel = 0;
+		}
 	} else {
 		if (tgsi_src->Register.Indirect)
 			r600_src->rel = V_SQ_REL_RELATIVE;




More information about the mesa-commit mailing list