if (!res || !(res->StageReferences & (1 << MESA_SHADER_FRAGMENT)))
return -1;
+ /* From OpenGL 4.5 spec, 7.3 Program Objects
+ * "The value -1 will be returned by either command...
+ * ... or if name identifies an active variable that does not have a
+ * valid location assigned.
+ */
+ if (RESOURCE_VAR(res)->location == -1)
+ return -1;
return RESOURCE_VAR(res)->index;
}
default:
goto invalid_operation;
}
- case GL_LOCATION_INDEX:
+ case GL_LOCATION_INDEX: {
+ int tmp;
if (res->Type != GL_PROGRAM_OUTPUT)
goto invalid_operation;
- *val = RESOURCE_VAR(res)->index;
+ tmp = program_resource_location(res, 0);
+ if (tmp == -1)
+ *val = -1;
+ else
+ *val = _mesa_program_resource_location_index(shProg, res->Type,
+ RESOURCE_VAR(res)->name);
return 1;
-
+ }
case GL_NUM_COMPATIBLE_SUBROUTINES:
if (res->Type != GL_VERTEX_SUBROUTINE_UNIFORM &&
res->Type != GL_FRAGMENT_SUBROUTINE_UNIFORM &&