<div dir="ltr">Hi Matt,<div><br></div><div>To be sure to not missing something, I used a simple vertex shader I have there and had</div><div>the following line in :</div><div><br></div><div>int a = gl_MaxDrawBuffers;</div><div><br></div><div>At runtime, everything was ok, and GLSL compiler didn't complain about anything. So there is nothing in mesa to prevent the use of some GLSL constants having some specifity to one or more shading stage.</div><div><br></div><div>But a more interesting stuff is when I took a look at GLSL 4.1 spec there :</div><div><a href="https://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.clean.pdf">https://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.clean.pdf</a><br></div><div><br></div><div>See section 7.3</div><div><br></div><div>"Built-In Constants</div><div>The following built-in constants are provided to all shaders. The actual values used are implementation
dependent, but must be at least the value shown. Some are deprecated, as indicated in comments."<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Follows a list where gl_MaxViewports is.</div><div class="gmail_extra"><br><div class="gmail_quote">2014-12-12 22:12 GMT+01:00 Maxence Le Doré <span dir="ltr"><<a href="mailto:maxence.ledore@gmail.com" target="_blank">maxence.ledore@gmail.com</a>></span>:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">I had exactly the same feeling while adding it. How to make it GS specific (and eventually allow access to VS, where <span style="color:rgb(0,0,0);white-space:pre-wrap">AMD_vertex_shader_viewport_index is supported, even if the spec don't say a word about gl_MaxViewports). In that kind of situation, I always take a look at a similar case nearby : gl_MaxDrawBuffers definition specificity to fragment shader stage. And I haven't seen how glsl compiler in its current state prevent it from being enabled in other stage too.</span></div><div class=""><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2014-12-12 18:19 GMT+01:00 Matt Turner <span dir="ltr"><<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>></span>:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">On Tue, Dec 9, 2014 at 11:09 PM, Maxence Le Doré<br><<a href="mailto:maxence.ledore@gmail.com" target="_blank">maxence.ledore@gmail.com</a>> wrote:<br>> It seems to have been forgotten during viewports array implementation time.<br>> ---<br>> src/glsl/builtin_variables.cpp | 4 ++++<br>> src/glsl/glsl_parser_extras.cpp | 3 +++<br>> src/glsl/glsl_parser_extras.h | 3 +++<br>> 3 files changed, 10 insertions(+)<br>><br>> diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp<br>> index c36d198..65e32ad 100644<br>> --- a/src/glsl/builtin_variables.cpp<br>> +++ b/src/glsl/builtin_variables.cpp<br>> @@ -724,6 +724,10 @@ builtin_variable_generator::generate_constants()<br>> add_const("gl_MaxCombinedImageUniforms",<br>> state->Const.MaxCombinedImageUniforms);<br>> }<br>> +<br>> + if (state->is_version(410, 0) ||<br>> + state->ARB_viewport_array_enable)<br>> + add_const("gl_MaxViewports", state->Const.MaxViewports);<br>> }<br><br>Nice find. The only thing that's holding back my review is that the<br>specification says<br><br> Add to the list of built in constants available to geometry shaders in<br> Section 7.4:<br><br> const int gl_MaxViewports = 16;<br><br>and I don't see how we're preventing gl_MaxViewports from being<br>enabled in other shader stages.<br><br>Maybe idr can confirm.</blockquote></div></div></div></div></blockquote></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-12-12 22:12 GMT+01:00 Maxence Le Doré <span dir="ltr"><<a href="mailto:maxence.ledore@gmail.com" target="_blank">maxence.ledore@gmail.com</a>></span>:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I had exactly the same feeling while adding it. How to make it GS specific (and eventually allow access to VS, where <span style="color:rgb(0,0,0);white-space:pre-wrap">AMD_vertex_shader_viewport_index is supported, even if the spec don't say a word about gl_MaxViewports). In that kind of situation, I always take a look at a similar case nearby : gl_MaxDrawBuffers definition specificity to fragment shader stage. And I haven't seen how glsl compiler in its current state prevent it from being enabled in other stage too.</span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2014-12-12 18:19 GMT+01:00 Matt Turner <span dir="ltr"><<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>></span>:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, Dec 9, 2014 at 11:09 PM, Maxence Le Doré<br>
<<a href="mailto:maxence.ledore@gmail.com" target="_blank">maxence.ledore@gmail.com</a>> wrote:<br>
> It seems to have been forgotten during viewports array implementation time.<br>
> ---<br>
> src/glsl/builtin_variables.cpp | 4 ++++<br>
> src/glsl/glsl_parser_extras.cpp | 3 +++<br>
> src/glsl/glsl_parser_extras.h | 3 +++<br>
> 3 files changed, 10 insertions(+)<br>
><br>
> diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp<br>
> index c36d198..65e32ad 100644<br>
> --- a/src/glsl/builtin_variables.cpp<br>
> +++ b/src/glsl/builtin_variables.cpp<br>
> @@ -724,6 +724,10 @@ builtin_variable_generator::generate_constants()<br>
> add_const("gl_MaxCombinedImageUniforms",<br>
> state->Const.MaxCombinedImageUniforms);<br>
> }<br>
> +<br>
> + if (state->is_version(410, 0) ||<br>
> + state->ARB_viewport_array_enable)<br>
> + add_const("gl_MaxViewports", state->Const.MaxViewports);<br>
> }<br>
<br>
Nice find. The only thing that's holding back my review is that the<br>
specification says<br>
<br>
Add to the list of built in constants available to geometry shaders in<br>
Section 7.4:<br>
<br>
const int gl_MaxViewports = 16;<br>
<br>
and I don't see how we're preventing gl_MaxViewports from being<br>
enabled in other shader stages.<br>
<br>
Maybe idr can confirm.<br>
</blockquote></div></div>
</div></div></blockquote></div></div>