glsl: move some uniform linking code to new link_assign_uniform_storage()
[mesa.git] / src / compiler / glsl / glsl_parser_extras.h
index 4dacc2ac62beb8f86ac63de9e05fe710e9db8981..f4050e37de1196ca3572b2b0006e961b0bc21d94 100644 (file)
@@ -265,9 +265,64 @@ struct _mesa_glsl_parse_state {
       return ARB_compute_shader_enable || is_version(430, 310);
    }
 
+   bool has_shader_io_blocks() const
+   {
+      /* The OES_geometry_shader_specification says:
+       *
+       *    "If the OES_geometry_shader extension is enabled, the
+       *     OES_shader_io_blocks extension is also implicitly enabled."
+       *
+       * The OES_tessellation_shader extension has similar wording.
+       */
+      return OES_shader_io_blocks_enable ||
+             EXT_shader_io_blocks_enable ||
+             OES_geometry_shader_enable ||
+             EXT_geometry_shader_enable ||
+             OES_tessellation_shader_enable ||
+             EXT_tessellation_shader_enable ||
+
+             is_version(150, 320);
+   }
+
    bool has_geometry_shader() const
    {
-      return OES_geometry_shader_enable || is_version(150, 320);
+      return OES_geometry_shader_enable || EXT_geometry_shader_enable ||
+             is_version(150, 320);
+   }
+
+   bool has_tessellation_shader() const
+   {
+      return ARB_tessellation_shader_enable ||
+             OES_tessellation_shader_enable ||
+             EXT_tessellation_shader_enable ||
+             is_version(400, 320);
+   }
+
+   bool has_clip_distance() const
+   {
+      return EXT_clip_cull_distance_enable || is_version(130, 0);
+   }
+
+   bool has_cull_distance() const
+   {
+      return EXT_clip_cull_distance_enable ||
+             ARB_cull_distance_enable ||
+             is_version(450, 0);
+   }
+
+   bool has_framebuffer_fetch() const
+   {
+      return EXT_shader_framebuffer_fetch_enable ||
+             MESA_shader_framebuffer_fetch_enable ||
+             MESA_shader_framebuffer_fetch_non_coherent_enable;
+   }
+
+   bool has_texture_cube_map_array() const
+   {
+      return ARB_texture_cube_map_array_enable ||
+             EXT_texture_cube_map_array_enable ||
+             OES_texture_cube_map_array_enable ||
+             is_version(400, 320);
    }
 
    void process_version_directive(YYLTYPE *locp, int version,
@@ -281,12 +336,15 @@ struct _mesa_glsl_parse_state {
    unsigned num_supported_versions;
    struct {
       unsigned ver;
+      uint8_t gl_ver;
       bool es;
-   } supported_versions[15];
+   } supported_versions[16];
 
    bool es_shader;
    unsigned language_version;
    unsigned forced_language_version;
+   bool zero_init;
+   unsigned gl_version;
    gl_shader_stage stage;
 
    /**
@@ -383,6 +441,10 @@ struct _mesa_glsl_parse_state {
       /* ARB_draw_buffers */
       unsigned MaxDrawBuffers;
 
+      /* ARB_enhanced_layouts */
+      unsigned MaxTransformFeedbackBuffers;
+      unsigned MaxTransformFeedbackInterleavedComponents;
+
       /* ARB_blend_func_extended */
       unsigned MaxDualSourceDrawBuffers;
 
@@ -422,6 +484,11 @@ struct _mesa_glsl_parse_state {
       unsigned MaxAtomicCounterBufferSize;
 
       /* ARB_compute_shader */
+      unsigned MaxComputeAtomicCounterBuffers;
+      unsigned MaxComputeAtomicCounters;
+      unsigned MaxComputeImageUniforms;
+      unsigned MaxComputeTextureImageUnits;
+      unsigned MaxComputeUniformComponents;
       unsigned MaxComputeWorkGroupCount[3];
       unsigned MaxComputeWorkGroupSize[3];
 
@@ -452,6 +519,9 @@ struct _mesa_glsl_parse_state {
       unsigned MaxTessControlTotalOutputComponents;
       unsigned MaxTessControlUniformComponents;
       unsigned MaxTessEvaluationUniformComponents;
+
+      /* GL 4.5 / OES_sample_variables */
+      unsigned MaxSamples;
    } Const;
 
    /**
@@ -498,12 +568,18 @@ struct _mesa_glsl_parse_state {
    /*@{*/
    /* ARB extensions go here, sorted alphabetically.
     */
+   bool ARB_ES3_1_compatibility_enable;
+   bool ARB_ES3_1_compatibility_warn;
+   bool ARB_ES3_2_compatibility_enable;
+   bool ARB_ES3_2_compatibility_warn;
    bool ARB_arrays_of_arrays_enable;
    bool ARB_arrays_of_arrays_warn;
    bool ARB_compute_shader_enable;
    bool ARB_compute_shader_warn;
    bool ARB_conservative_depth_enable;
    bool ARB_conservative_depth_warn;
+   bool ARB_cull_distance_enable;
+   bool ARB_cull_distance_warn;
    bool ARB_derivative_control_enable;
    bool ARB_derivative_control_warn;
    bool ARB_draw_buffers_enable;
@@ -528,6 +604,8 @@ struct _mesa_glsl_parse_state {
    bool ARB_sample_shading_warn;
    bool ARB_separate_shader_objects_enable;
    bool ARB_separate_shader_objects_warn;
+   bool ARB_shader_atomic_counter_ops_enable;
+   bool ARB_shader_atomic_counter_ops_warn;
    bool ARB_shader_atomic_counters_enable;
    bool ARB_shader_atomic_counters_warn;
    bool ARB_shader_bit_encoding_enable;
@@ -536,6 +614,8 @@ struct _mesa_glsl_parse_state {
    bool ARB_shader_clock_warn;
    bool ARB_shader_draw_parameters_enable;
    bool ARB_shader_draw_parameters_warn;
+   bool ARB_shader_group_vote_enable;
+   bool ARB_shader_group_vote_warn;
    bool ARB_shader_image_load_store_enable;
    bool ARB_shader_image_load_store_warn;
    bool ARB_shader_image_size_enable;
@@ -552,6 +632,8 @@ struct _mesa_glsl_parse_state {
    bool ARB_shader_texture_image_samples_warn;
    bool ARB_shader_texture_lod_enable;
    bool ARB_shader_texture_lod_warn;
+   bool ARB_shader_viewport_layer_array_enable;
+   bool ARB_shader_viewport_layer_array_warn;
    bool ARB_shading_language_420pack_enable;
    bool ARB_shading_language_420pack_warn;
    bool ARB_shading_language_packing_enable;
@@ -579,6 +661,8 @@ struct _mesa_glsl_parse_state {
 
    /* KHR extensions go here, sorted alphabetically.
     */
+   bool KHR_blend_equation_advanced_enable;
+   bool KHR_blend_equation_advanced_warn;
 
    /* OES extensions go here, sorted alphabetically.
     */
@@ -588,12 +672,34 @@ struct _mesa_glsl_parse_state {
    bool OES_geometry_point_size_warn;
    bool OES_geometry_shader_enable;
    bool OES_geometry_shader_warn;
+   bool OES_gpu_shader5_enable;
+   bool OES_gpu_shader5_warn;
+   bool OES_primitive_bounding_box_enable;
+   bool OES_primitive_bounding_box_warn;
+   bool OES_sample_variables_enable;
+   bool OES_sample_variables_warn;
+   bool OES_shader_image_atomic_enable;
+   bool OES_shader_image_atomic_warn;
+   bool OES_shader_io_blocks_enable;
+   bool OES_shader_io_blocks_warn;
+   bool OES_shader_multisample_interpolation_enable;
+   bool OES_shader_multisample_interpolation_warn;
    bool OES_standard_derivatives_enable;
    bool OES_standard_derivatives_warn;
+   bool OES_tessellation_point_size_enable;
+   bool OES_tessellation_point_size_warn;
+   bool OES_tessellation_shader_enable;
+   bool OES_tessellation_shader_warn;
    bool OES_texture_3D_enable;
    bool OES_texture_3D_warn;
+   bool OES_texture_buffer_enable;
+   bool OES_texture_buffer_warn;
+   bool OES_texture_cube_map_array_enable;
+   bool OES_texture_cube_map_array_warn;
    bool OES_texture_storage_multisample_2d_array_enable;
    bool OES_texture_storage_multisample_2d_array_warn;
+   bool OES_viewport_array_enable;
+   bool OES_viewport_array_warn;
 
    /* All other extensions go here, sorted alphabetically.
     */
@@ -607,18 +713,48 @@ struct _mesa_glsl_parse_state {
    bool AMD_vertex_shader_layer_warn;
    bool AMD_vertex_shader_viewport_index_enable;
    bool AMD_vertex_shader_viewport_index_warn;
+   bool ANDROID_extension_pack_es31a_enable;
+   bool ANDROID_extension_pack_es31a_warn;
    bool EXT_blend_func_extended_enable;
    bool EXT_blend_func_extended_warn;
+   bool EXT_clip_cull_distance_enable;
+   bool EXT_clip_cull_distance_warn;
    bool EXT_draw_buffers_enable;
    bool EXT_draw_buffers_warn;
+   bool EXT_geometry_point_size_enable;
+   bool EXT_geometry_point_size_warn;
+   bool EXT_geometry_shader_enable;
+   bool EXT_geometry_shader_warn;
+   bool EXT_gpu_shader5_enable;
+   bool EXT_gpu_shader5_warn;
+   bool EXT_primitive_bounding_box_enable;
+   bool EXT_primitive_bounding_box_warn;
    bool EXT_separate_shader_objects_enable;
    bool EXT_separate_shader_objects_warn;
+   bool EXT_shader_framebuffer_fetch_enable;
+   bool EXT_shader_framebuffer_fetch_warn;
    bool EXT_shader_integer_mix_enable;
    bool EXT_shader_integer_mix_warn;
+   bool EXT_shader_io_blocks_enable;
+   bool EXT_shader_io_blocks_warn;
    bool EXT_shader_samples_identical_enable;
    bool EXT_shader_samples_identical_warn;
+   bool EXT_tessellation_point_size_enable;
+   bool EXT_tessellation_point_size_warn;
+   bool EXT_tessellation_shader_enable;
+   bool EXT_tessellation_shader_warn;
    bool EXT_texture_array_enable;
    bool EXT_texture_array_warn;
+   bool EXT_texture_buffer_enable;
+   bool EXT_texture_buffer_warn;
+   bool EXT_texture_cube_map_array_enable;
+   bool EXT_texture_cube_map_array_warn;
+   bool MESA_shader_framebuffer_fetch_enable;
+   bool MESA_shader_framebuffer_fetch_warn;
+   bool MESA_shader_framebuffer_fetch_non_coherent_enable;
+   bool MESA_shader_framebuffer_fetch_non_coherent_warn;
+   bool MESA_shader_integer_functions_enable;
+   bool MESA_shader_integer_functions_warn;
    /*@}*/
 
    /** Extensions supported by the OpenGL implementation. */
@@ -638,6 +774,8 @@ struct _mesa_glsl_parse_state {
 
    bool fs_early_fragment_tests;
 
+   unsigned fs_blend_support;
+
    /**
     * For tessellation control shaders, size of the most recently seen output
     * declaration that was a sized array, or 0 if no sized output array
@@ -670,6 +808,12 @@ struct _mesa_glsl_parse_state {
     * did the parser just parse a dot.
     */
    bool is_field;
+
+   /**
+    * seen values for clip/cull distance sizes
+    * so we can check totals aren't too large.
+    */
+   unsigned clip_dist_size, cull_dist_size;
 };
 
 # define YYLLOC_DEFAULT(Current, Rhs, N)                       \
@@ -733,8 +877,19 @@ extern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
 extern "C" {
 #endif
 
+struct glcpp_parser;
+
+typedef void (*glcpp_extension_iterator)(
+               struct _mesa_glsl_parse_state *state,
+               void (*add_builtin_define)(struct glcpp_parser *, const char *, int),
+               struct glcpp_parser *data,
+               unsigned version,
+               bool es);
+
 extern int glcpp_preprocess(void *ctx, const char **shader, char **info_log,
-                      const struct gl_extensions *extensions, struct gl_context *gl_ctx);
+                            glcpp_extension_iterator extensions,
+                            struct _mesa_glsl_parse_state *state,
+                            struct gl_context *gl_ctx);
 
 extern void _mesa_destroy_shader_compiler(void);
 extern void _mesa_destroy_shader_compiler_caches(void);