shader: fix Unigine Heaven 4.0 shader translation

The benchmark fails to start, the translation of gl_Identity is incorrect,

UMAD TEMP[0], SV[0].xxxx, TEMP[0].xxxx, TEMP[1]

is translated to:

temp0[0] = vec4(uintBitsToFloat((gl_InstanceID * floatBitsToUint(temp0[0].xxxx) + floatBitsToUint(temp0[1]))));

Which results in the following error:
shader failed to compile
0:23(34): error: could not implicitly convert operands to arithmetic operator
0:23(34): error: operands to arithmetic operators must be numeric
0:23(17): error: no matching function for call to `uintBitsToFloat(error)'; candidates are:

It seems we can use the same workaround as gl_VertexID, I didn't
observe any regression running various gl_InstanceId tests from
piglit:

temp0[0] = vec4(uintBitsToFloat((floatBitsToUint(vec4(intBitsToFloat(gl_InstanceID))) * floatBitsToUint(temp0[0].xxxx) + floatBitsToUint(temp0[1]))));

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Marc-André Lureau 8 years ago committed by Dave Airlie
parent 42e7a37342
commit b7fd972793
  1. 2
      src/vrend_shader.c

@ -1632,7 +1632,7 @@ iter_instruction(struct tgsi_iterate_context *iter,
} else if (src->Register.File == TGSI_FILE_SYSTEM_VALUE) {
for (j = 0; j < ctx->num_system_values; j++)
if (ctx->system_values[j].first == src->Register.Index) {
if (ctx->system_values[j].name == TGSI_SEMANTIC_VERTEXID)
if (ctx->system_values[j].name == TGSI_SEMANTIC_VERTEXID || ctx->system_values[j].name == TGSI_SEMANTIC_INSTANCEID)
snprintf(srcs[i], 255, "%s(vec4(intBitsToFloat(%s)))", stypeprefix, ctx->system_values[j].glsl_name);
else
snprintf(srcs[i], 255, "%s%s", prefix, ctx->system_values[j].glsl_name);

Loading…
Cancel
Save