Created attachment 121069 [details]
fragment shader to test segfault
In GLSL, one can specify the location of a subroutine uniform by using something like:
#extension GL_ARB_shader_subroutine : require
#extension GL_ARB_explicit_uniform_location : require
layout(location = 5) subroutine uniform color_t Color;
Assuming this is the only subroutine uniform, you should be able to set it's value by calling:
UniformSubroutinesuiv(GL_FRAGMENT_SHADER, 6, &[0, 0, 0, 0, 0 , subroutin_index]);
According to the spec, the values - should be ignored, and the subroutine uniform at location 5 should be set to `subroutin_index`.
Mesa will segfault when calling this function like that.
Unfortunately, I do not have a complete minimum example program right now (I'm not good with raw opengl), but attached is a fragment shader which can be used to reproduce the problem.
Created attachment 121070 [details]
vertex shader which can be used with the fragment shader
Thanks for the bug report.
Should be fixed by:
mesa: fix segfault in glUniformSubroutinesuiv()
From Section 7.9 (SUBROUTINE UNIFORM VARIABLES) of the OpenGL
4.5 Core spec:
void UniformSubroutinesuiv(enum shadertype, sizei count,
const uint *indices);
will load all active subroutine uniforms for shader stage
shadertype with subroutine indices from indices, storing
indices[i] into the uniform at location i. The indices for
any locations between zero and the value of
ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS minus one which are not
used will be ignored."
V2: simplify NULL check suggested by Jason.
Acked-by: Jason Ekstrand <email@example.com>
Reviewed-by: Dave Airlie <firstname.lastname@example.org>
Cc: "11.0 11.1" email@example.com
on Mar 25, 2017 at 17:25:59.
(provided by the Example extension).