<div dir="ltr">On 1 August 2013 09:34, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 08/01/2013 07:17 AM, Paul Berry wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On 31 July 2013 17:42, Ian Romanick <<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a><br></div><div class="im">
<mailto:<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>>> wrote:<br>
<br>
On 07/28/2013 11:03 PM, Paul Berry wrote:<br>
<br></div>
From: Eric Anholt <<a href="mailto:eric@anholt.net" target="_blank">eric@anholt.net</a> <mailto:<a href="mailto:eric@anholt.net" target="_blank">eric@anholt.net</a>>><div class="im"><br>
<br>
Next step is to validate them at link time.<br>
<br>
v2 (Paul Berry <<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.com</a><br></div>
<mailto:<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.<u></u>com</a>>>): Don't attempt to export the<div class="im"><br>
layout qualifiers in the event of a compile error, since some of<br>
them<br>
are set up by ast_to_hir(), and ast_to_hir() isn't guaranteed to<br>
have<br>
run in the event of a compile error.<br>
---<br></div>
src/glsl/glsl_parser_extras.__<u></u>cpp | 31<br>
++++++++++++++++++++++++++++++<u></u>__+<div class="im"><br>
src/mesa/main/mtypes.h | 18 ++++++++++++++++++<br>
2 files changed, 49 insertions(+)<br>
<br></div>
diff --git a/src/glsl/glsl_parser_extras.<u></u>__cpp<br>
b/src/glsl/glsl_parser_extras.<u></u>__cpp<br>
index 6b8fb45..2311447 100644<br>
--- a/src/glsl/glsl_parser_extras.<u></u>__cpp<br>
+++ b/src/glsl/glsl_parser_extras.<u></u>__cpp<br>
@@ -1446,6 +1446,34 @@<br>
ast_struct_specifier::ast___<u></u>struct_specifier(const char *identifier,<div class="im"><br>
is_declaration = true;<br>
}<br>
<br>
+static void<br></div>
+set_shader_inout_layout(__<u></u>struct gl_shader *shader,<div class="im"><br>
+ struct _mesa_glsl_parse_state *state)<br>
+{<br>
+ if (shader->Type != GL_GEOMETRY_SHADER) {<br>
+ /* Should have been prevented by the parser. */<br></div>
+ assert(!state->gs_input_prim__<u></u>_type_specified);<br>
+ assert(!state->out_qualifier-><u></u>__flags.i);<div class="im"><br>
+ return;<br>
+ }<br>
+<br>
+ shader->Geom.VerticesOut = 0;<br></div>
+ if (state->out_qualifier->flags._<u></u>_q.max_vertices)<br>
+ shader->Geom.VerticesOut =<br>
state->out_qualifier->max___<u></u>vertices;<br>
+<br>
+ if (state->gs_input_prim_type___<u></u>specified) {<div class="im"><br>
+ shader->Geom.InputType = state->gs_input_prim_type;<br>
+ } else {<br>
+ shader->Geom.InputType = ~0;<br>
+ }<br>
+<br></div>
+ if (state->out_qualifier->flags._<u></u>_q.prim_type) {<br>
+ shader->Geom.OutputType = state->out_qualifier->prim___<u></u>type;<div class="im"><br>
+ } else {<br>
+ shader->Geom.OutputType = ~0;<br>
+ }<br>
+}<br>
+<br>
extern "C" {<br>
<br>
void<br></div>
@@ -1521,6 +1549,9 @@ _mesa_glsl_compile_shader(__<u></u>struct<div class="im"><br>
gl_context *ctx, struct gl_shader *shader,<br>
shader->UniformBlocks = state->uniform_blocks;<br>
ralloc_steal(shader, shader->UniformBlocks);<br>
<br>
+ if (!state->error)<br></div>
+ set_shader_inout_layout(__<u></u>shader, state);<div><div class="h5"><br>
+<br>
/* Retain any live IR, but trash the rest. */<br>
reparent_ir(shader->ir, shader->ir);<br>
<br>
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h<br>
index 33075bd..bc90d09 100644<br>
--- a/src/mesa/main/mtypes.h<br>
+++ b/src/mesa/main/mtypes.h<br>
@@ -2170,6 +2170,24 @@ struct gl_shader<br>
/** Shaders containing built-in functions that are used<br>
for linking. */<br>
struct gl_shader *builtins_to_link[16];<br>
unsigned num_builtins_to_link;<br>
+<br>
+ /**<br>
+ * Geometry shader state from GLSL 1.50 layout qualifiers.<br>
+ */<br>
+ struct {<br>
+ GLint VerticesOut;<br>
+ /**<br>
+ * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB,<br>
GL_TRIANGLES, or<br>
+ * GL_TRIANGLES_ADJACENCY_ARB, or ~0 if it's not set in<br>
this shader<br>
+ * (since GL_POINTS is 0).<br>
+ */<br>
<br>
<br>
After looking at the next patch, I wonder if we should make a<br>
descriptive #define for ~0u for this. Thoughts?<br>
<br>
Hmm, maybe we should use mtypes.h's PRIM_UNKNOWN.<br>
</div></div></blockquote>
<br>
Good call! I had forgotten that PRIM_UNKNOWN existed and was defined in terms of the other GL_<prim> enums.</blockquote><div><br></div><div>Ok, done.<br></div></div></div></div>