diff -rup mesa-17.2.1/src/mesa/main/transformfeedback.c mesa-17.2.1.new/src/mesa/main/transformfeedback.c --- mesa-17.2.1/src/mesa/main/transformfeedback.c 2017-09-18 01:03:22.000000000 +0200 +++ mesa-17.2.1.new/src/mesa/main/transformfeedback.c 2017-09-20 19:24:54.379197797 +0200 @@ -421,6 +421,10 @@ _mesa_BeginTransformFeedback(GLenum mode if (info->NumOutputs == 0) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginTransformFeedback(no varyings to record)"); + + fprintf(stderr, "Aborted! TFB varyings not correctly set!\n"); + fprintf(stderr, "source->Id = %d\n", source->Id); + exit(1); return; } @@ -815,6 +819,7 @@ _mesa_TransformFeedbackVaryings(GLuint p { struct gl_shader_program *shProg; GLint i; + bool tw3_varying_hack_enabled = false; GET_CURRENT_CONTEXT(ctx); /* From the ARB_transform_feedback2 specification: @@ -889,6 +894,12 @@ _mesa_TransformFeedbackVaryings(GLuint p } free(shProg->TransformFeedback.VaryingNames); + if (count == 0) { + fprintf(stderr, "*** The Witcher 3 SPECIAL HACK ENABLED ***\n"); + tw3_varying_hack_enabled = true; + count = 1; + } + /* allocate new memory for varying names */ shProg->TransformFeedback.VaryingNames = malloc(count * sizeof(GLchar *)); @@ -898,9 +909,13 @@ _mesa_TransformFeedbackVaryings(GLuint p return; } - /* Save the new names and the count */ - for (i = 0; i < count; i++) { - shProg->TransformFeedback.VaryingNames[i] = strdup(varyings[i]); + if (tw3_varying_hack_enabled) { + shProg->TransformFeedback.VaryingNames[0] = strdup("shader_in_out.reg0"); + } else { + /* Save the new names and the count */ + for (i = 0; i < count; i++) { + shProg->TransformFeedback.VaryingNames[i] = strdup(varyings[i]); + } } shProg->TransformFeedback.NumVarying = count;