[Mesa-dev] [PATCH] glsl: move gl_NumSamples enablement with other ARB_sample_shading vars

Ilia Mirkin imirkin at alum.mit.edu
Thu Jun 18 16:06:22 PDT 2015


Hmmm.... actually looking at the GLSL 4.50 doc, it looks like it just
has a list of all uniforms available in one place, unlike the
ARB_sample_shading spec which says it should go into fs only. From
ARB_sample_shading:

    Add the following prototype to the list of built-in uniforms
    accessible from a fragment shader:

        uniform int gl_NumSamples;

>From GLSL 4.50 though:

As an aid to accessing OpenGL processing state, the following uniform
variables are built into the OpenGL Shading Language:

...
uniform int gl_NumSamples;

So I guess I should leave this in generate_uniforms but just add the
enable conditions around it being added?

  -ilia


On Thu, Jun 18, 2015 at 6:57 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> gl_NumSamples should only be enabled when ARB_sample_shading is enabled,
> and only in the fragment shader. Move to the generate_fs_special_vars
> function, next to the other ARB_sample_shading-provided variables.
>
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
>  src/glsl/builtin_variables.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
> index c52b252..d2acbac 100644
> --- a/src/glsl/builtin_variables.cpp
> +++ b/src/glsl/builtin_variables.cpp
> @@ -764,7 +764,6 @@ builtin_variable_generator::generate_constants()
>  void
>  builtin_variable_generator::generate_uniforms()
>  {
> -   add_uniform(int_t, "gl_NumSamples");
>     add_uniform(type("gl_DepthRangeParameters"), "gl_DepthRange");
>     add_uniform(array(vec4_t, VERT_ATTRIB_MAX), "gl_CurrentAttribVertMESA");
>     add_uniform(array(vec4_t, VARYING_SLOT_MAX), "gl_CurrentAttribFragMESA");
> @@ -947,6 +946,7 @@ builtin_variable_generator::generate_fs_special_vars()
>     }
>
>     if (state->is_version(400, 0) || state->ARB_sample_shading_enable) {
> +      add_uniform(int_t, "gl_NumSamples");
>        add_system_value(SYSTEM_VALUE_SAMPLE_ID, int_t, "gl_SampleID");
>        add_system_value(SYSTEM_VALUE_SAMPLE_POS, vec2_t, "gl_SamplePosition");
>        /* From the ARB_sample_shading specification:
> --
> 2.3.6
>


More information about the mesa-dev mailing list