mesa: use split_location_offset() in GetUniform() functions
Commit 5d0e136eff exposed a long-standing
bug in the glGetUniform*() code paths. We weren't properly decoding
the location parameter.
Fixes fd.o bug/regression 28344
Note: this patch should go into the 7.8 branch after the above-mentioned
commit.
This commit is contained in:
+67
-60
@@ -318,65 +318,6 @@ lookup_uniform_parameter(GLcontext *ctx, GLuint program, GLint location,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via ctx->Driver.GetUniformfv().
|
||||
*/
|
||||
static void
|
||||
_mesa_get_uniformfv(GLcontext *ctx, GLuint program, GLint location,
|
||||
GLfloat *params)
|
||||
{
|
||||
struct gl_program *prog;
|
||||
GLint paramPos;
|
||||
|
||||
lookup_uniform_parameter(ctx, program, location, &prog, ¶mPos);
|
||||
|
||||
if (prog) {
|
||||
const struct gl_program_parameter *p =
|
||||
&prog->Parameters->Parameters[paramPos];
|
||||
GLint rows, cols, i, j, k;
|
||||
|
||||
get_uniform_rows_cols(p, &rows, &cols);
|
||||
|
||||
k = 0;
|
||||
for (i = 0; i < rows; i++) {
|
||||
for (j = 0; j < cols; j++ ) {
|
||||
params[k++] = prog->Parameters->ParameterValues[paramPos+i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via ctx->Driver.GetUniformiv().
|
||||
* \sa _mesa_get_uniformfv, only difference is a cast.
|
||||
*/
|
||||
static void
|
||||
_mesa_get_uniformiv(GLcontext *ctx, GLuint program, GLint location,
|
||||
GLint *params)
|
||||
{
|
||||
struct gl_program *prog;
|
||||
GLint paramPos;
|
||||
|
||||
lookup_uniform_parameter(ctx, program, location, &prog, ¶mPos);
|
||||
|
||||
if (prog) {
|
||||
const struct gl_program_parameter *p =
|
||||
&prog->Parameters->Parameters[paramPos];
|
||||
GLint rows, cols, i, j, k;
|
||||
|
||||
get_uniform_rows_cols(p, &rows, &cols);
|
||||
|
||||
k = 0;
|
||||
for (i = 0; i < rows; i++) {
|
||||
for (j = 0; j < cols; j++ ) {
|
||||
params[k++] = (GLint) prog->Parameters->ParameterValues[paramPos+i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GLGL uniform arrays and structs require special handling.
|
||||
*
|
||||
@@ -414,7 +355,7 @@ merge_location_offset(GLint *location, GLint offset)
|
||||
|
||||
|
||||
/**
|
||||
* Seperate the uniform location and parameter offset. See above.
|
||||
* Separate the uniform location and parameter offset. See above.
|
||||
*/
|
||||
static void
|
||||
split_location_offset(GLint *location, GLint *offset)
|
||||
@@ -424,6 +365,72 @@ split_location_offset(GLint *location, GLint *offset)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Called via ctx->Driver.GetUniformfv().
|
||||
*/
|
||||
static void
|
||||
_mesa_get_uniformfv(GLcontext *ctx, GLuint program, GLint location,
|
||||
GLfloat *params)
|
||||
{
|
||||
struct gl_program *prog;
|
||||
GLint paramPos;
|
||||
GLint offset;
|
||||
|
||||
split_location_offset(&location, &offset);
|
||||
|
||||
lookup_uniform_parameter(ctx, program, location, &prog, ¶mPos);
|
||||
|
||||
if (prog) {
|
||||
const struct gl_program_parameter *p =
|
||||
&prog->Parameters->Parameters[paramPos];
|
||||
GLint rows, cols, i, j, k;
|
||||
|
||||
get_uniform_rows_cols(p, &rows, &cols);
|
||||
|
||||
k = 0;
|
||||
for (i = 0; i < rows; i++) {
|
||||
for (j = 0; j < cols; j++ ) {
|
||||
params[k++] = prog->Parameters->ParameterValues[paramPos+i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via ctx->Driver.GetUniformiv().
|
||||
* \sa _mesa_get_uniformfv, only difference is a cast.
|
||||
*/
|
||||
static void
|
||||
_mesa_get_uniformiv(GLcontext *ctx, GLuint program, GLint location,
|
||||
GLint *params)
|
||||
{
|
||||
struct gl_program *prog;
|
||||
GLint paramPos;
|
||||
GLint offset;
|
||||
|
||||
split_location_offset(&location, &offset);
|
||||
|
||||
lookup_uniform_parameter(ctx, program, location, &prog, ¶mPos);
|
||||
|
||||
if (prog) {
|
||||
const struct gl_program_parameter *p =
|
||||
&prog->Parameters->Parameters[paramPos];
|
||||
GLint rows, cols, i, j, k;
|
||||
|
||||
get_uniform_rows_cols(p, &rows, &cols);
|
||||
|
||||
k = 0;
|
||||
for (i = 0; i < rows; i++) {
|
||||
for (j = 0; j < cols; j++ ) {
|
||||
params[k++] = (GLint) prog->Parameters->ParameterValues[paramPos+i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via ctx->Driver.GetUniformLocation().
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user