mesa: remove support for GL_APPLE_client_storage extension
[mesa.git] / src / glsl / ir_variable.cpp
index f3577175691f7cb38313f08d463ca0e905dd558c..e0b6f38f1c910def256831837a548dd42ddbf998 100644 (file)
@@ -584,6 +584,17 @@ generate_120_vs_variables(exec_list *instructions,
 }
 
 
+static void
+generate_130_uniforms(exec_list *instructions,
+                     struct _mesa_glsl_parse_state *state)
+{
+   glsl_symbol_table *const symtab = state->symbols;
+
+   add_builtin_constant(instructions, symtab, "gl_MaxClipDistances",
+                        state->Const.MaxClipPlanes);
+}
+
+
 static void
 generate_130_vs_variables(exec_list *instructions,
                          struct _mesa_glsl_parse_state *state)
@@ -595,9 +606,20 @@ generate_130_vs_variables(exec_list *instructions,
                           & builtin_130_vs_variables[i]);
    }
 
+   generate_130_uniforms(instructions, state);
+
+   /* From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special
+    * Variables):
+    *
+    *   The gl_ClipDistance array is predeclared as unsized and must
+    *   be sized by the shader either redeclaring it with a size or
+    *   indexing it only with integral constant expressions.
+    *
+    * We represent this in Mesa by initially declaring the array as
+    * size 0.
+    */
    const glsl_type *const clip_distance_array_type =
-      glsl_type::get_array_instance(glsl_type::float_type,
-                                   state->Const.MaxClipPlanes);
+      glsl_type::get_array_instance(glsl_type::float_type, 0);
 
    /* FINISHME: gl_ClipDistance needs a real location assigned. */
    add_variable(instructions, state->symbols,
@@ -766,6 +788,22 @@ generate_ARB_shader_stencil_export_variables(exec_list *instructions,
       fd->warn_extension = "GL_ARB_shader_stencil_export";
 }
 
+static void
+generate_AMD_shader_stencil_export_variables(exec_list *instructions,
+                                            struct _mesa_glsl_parse_state *state,
+                                            bool warn)
+{
+   /* gl_FragStencilRefAMD is only available in the fragment shader.
+    */
+   ir_variable *const fd =
+      add_variable(instructions, state->symbols,
+                  "gl_FragStencilRefAMD", glsl_type::int_type,
+                  ir_var_out, FRAG_RESULT_STENCIL);
+
+   if (warn)
+      fd->warn_extension = "GL_AMD_shader_stencil_export";
+}
+
 static void
 generate_120_fs_variables(exec_list *instructions,
                          struct _mesa_glsl_parse_state *state)
@@ -786,9 +824,22 @@ generate_130_fs_variables(exec_list *instructions,
 {
    generate_120_fs_variables(instructions, state);
 
+   generate_130_uniforms(instructions, state);
+
+   /* From the GLSL 1.30 spec, section 7.2 (Fragment Shader Special
+    * Variables):
+    *
+    *   The built-in input variable gl_ClipDistance array contains linearly
+    *   interpolated values for the vertex values written by the vertex shader
+    *   to the gl_ClipDistance vertex output variable. This array must be
+    *   sized in the fragment shader either implicitly or explicitly to be the
+    *   same size as it was sized in the vertex shader.
+    *
+    * In other words, the array must be pre-declared as implicitly sized.  We
+    * represent this in Mesa by initially declaring the array as size 0.
+    */
    const glsl_type *const clip_distance_array_type =
-      glsl_type::get_array_instance(glsl_type::float_type,
-                                   state->Const.MaxClipPlanes);
+      glsl_type::get_array_instance(glsl_type::float_type, 0);
 
    /* FINISHME: gl_ClipDistance needs a real location assigned. */
    add_variable(instructions, state->symbols,
@@ -818,6 +869,10 @@ initialize_fs_variables(exec_list *instructions,
    if (state->ARB_shader_stencil_export_enable)
       generate_ARB_shader_stencil_export_variables(instructions, state,
                                                   state->ARB_shader_stencil_export_warn);
+
+   if (state->AMD_shader_stencil_export_enable)
+      generate_AMD_shader_stencil_export_variables(instructions, state,
+                                                  state->AMD_shader_stencil_export_warn);
 }
 
 void