glsl/mesa: split gl_shader in two
authorTimothy Arceri <timothy.arceri@collabora.com>
Thu, 30 Jun 2016 04:55:40 +0000 (14:55 +1000)
committerTimothy Arceri <timothy.arceri@collabora.com>
Thu, 30 Jun 2016 06:51:25 +0000 (16:51 +1000)
There are two distinctly different uses of this struct. The first
is to store GL shader objects. The second is to store information
about a shader stage thats been linked.

The two uses actually share few fields and there is clearly confusion
about their use. For example the linked shaders map one to one with
a program so can simply be destroyed along with the program. However
previously we were calling reference counting on the linked shaders.

We were also creating linked shaders with a name even though it
is always 0 and called the driver version of the _mesa_new_shader()
function unnecessarily for GL shader objects.

Acked-by: Iago Toral Quiroga <itoral@igalia.com>
58 files changed:
src/compiler/glsl/glsl_to_nir.cpp
src/compiler/glsl/ir_optimization.h
src/compiler/glsl/link_atomics.cpp
src/compiler/glsl/link_functions.cpp
src/compiler/glsl/link_interface_blocks.cpp
src/compiler/glsl/link_uniform_blocks.cpp
src/compiler/glsl/link_uniform_initializers.cpp
src/compiler/glsl/link_uniforms.cpp
src/compiler/glsl/link_varyings.cpp
src/compiler/glsl/link_varyings.h
src/compiler/glsl/linker.cpp
src/compiler/glsl/linker.h
src/compiler/glsl/lower_distance.cpp
src/compiler/glsl/lower_named_interface_blocks.cpp
src/compiler/glsl/lower_packed_varyings.cpp
src/compiler/glsl/lower_shared_reference.cpp
src/compiler/glsl/lower_tess_level.cpp
src/compiler/glsl/lower_ubo_reference.cpp
src/compiler/glsl/lower_vector_derefs.cpp
src/compiler/glsl/lower_vertex_id.cpp
src/compiler/glsl/opt_dead_builtin_varyings.cpp
src/compiler/glsl/standalone.cpp
src/compiler/glsl/standalone_scaffolding.cpp
src/compiler/glsl/standalone_scaffolding.h
src/compiler/glsl/test_optpass.cpp
src/mesa/drivers/common/meta.c
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_gs.c
src/mesa/drivers/dri/i965/brw_link.cpp
src/mesa/drivers/dri/i965/brw_program.c
src/mesa/drivers/dri/i965/brw_program.h
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/drivers/dri/i965/brw_shader.h
src/mesa/drivers/dri/i965/brw_tcs.c
src/mesa/drivers/dri/i965/brw_tes.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/main/api_validate.c
src/mesa/main/dd.h
src/mesa/main/ff_fragment_shader.cpp
src/mesa/main/mtypes.h
src/mesa/main/shader_query.cpp
src/mesa/main/shaderapi.c
src/mesa/main/shaderobj.c
src/mesa/main/shaderobj.h
src/mesa/main/uniform_query.cpp
src/mesa/main/uniforms.c
src/mesa/program/ir_to_mesa.cpp
src/mesa/program/ir_to_mesa.h
src/mesa/program/prog_print.c
src/mesa/program/prog_print.h
src/mesa/state_tracker/st_atom_constbuf.c
src/mesa/state_tracker/st_atom_image.c
src/mesa/state_tracker/st_atom_storagebuf.c
src/mesa/state_tracker/st_glsl_to_nir.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp
src/mesa/state_tracker/st_nir.h
src/mesa/state_tracker/st_program.c

index a22fd5b3e0871a25c93d0f1d3956f6c0c551fd3d..0ad3be107607b3c9bceda23e837610f8892ad18e 100644 (file)
@@ -134,7 +134,7 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
             gl_shader_stage stage,
             const nir_shader_compiler_options *options)
 {
-   struct gl_shader *sh = shader_prog->_LinkedShaders[stage];
+   struct gl_linked_shader *sh = shader_prog->_LinkedShaders[stage];
 
    nir_shader *shader = nir_shader_create(NULL, stage, options);
 
index ba14e34b71e0f3df16c20823d2980ff1d186e04b..ba790762a622b6f06c9685eb7a1eadfca3fed48b 100644 (file)
@@ -86,7 +86,8 @@ bool do_copy_propagation(exec_list *instructions);
 bool do_copy_propagation_elements(exec_list *instructions);
 bool do_constant_propagation(exec_list *instructions);
 void do_dead_builtin_varyings(struct gl_context *ctx,
-                              gl_shader *producer, gl_shader *consumer,
+                              gl_linked_shader *producer,
+                              gl_linked_shader *consumer,
                               unsigned num_tfeedback_decls,
                               class tfeedback_decl *tfeedback_decls);
 bool do_dead_code(exec_list *instructions, bool uniform_locations_assigned);
@@ -119,26 +120,30 @@ bool lower_variable_index_to_cond_assign(gl_shader_stage stage,
     bool lower_temp, bool lower_uniform);
 bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
 bool lower_const_arrays_to_uniforms(exec_list *instructions);
-bool lower_clip_cull_distance(struct gl_shader_program *prog, gl_shader *shader);
+bool lower_clip_cull_distance(struct gl_shader_program *prog,
+                              gl_linked_shader *shader);
 void lower_output_reads(unsigned stage, exec_list *instructions);
 bool lower_packing_builtins(exec_list *instructions, int op_mask);
-void lower_shared_reference(struct gl_shader *shader, unsigned *shared_size);
-void lower_ubo_reference(struct gl_shader *shader, bool clamp_block_indices);
+void lower_shared_reference(struct gl_linked_shader *shader,
+                            unsigned *shared_size);
+void lower_ubo_reference(struct gl_linked_shader *shader,
+                         bool clamp_block_indices);
 void lower_packed_varyings(void *mem_ctx,
                            unsigned locations_used, ir_variable_mode mode,
-                           unsigned gs_input_vertices, gl_shader *shader,
+                           unsigned gs_input_vertices,
+                           gl_linked_shader *shader,
                            bool disable_varying_packing, bool xfb_enabled);
 bool lower_vector_insert(exec_list *instructions, bool lower_nonconstant_index);
-bool lower_vector_derefs(gl_shader *shader);
-void lower_named_interface_blocks(void *mem_ctx, gl_shader *shader);
+bool lower_vector_derefs(gl_linked_shader *shader);
+void lower_named_interface_blocks(void *mem_ctx, gl_linked_shader *shader);
 bool optimize_redundant_jumps(exec_list *instructions);
 bool optimize_split_arrays(exec_list *instructions, bool linked);
 bool lower_offset_arrays(exec_list *instructions);
 void optimize_dead_builtin_variables(exec_list *instructions,
                                      enum ir_variable_mode other);
-bool lower_tess_level(gl_shader *shader);
+bool lower_tess_level(gl_linked_shader *shader);
 
-bool lower_vertex_id(gl_shader *shader);
+bool lower_vertex_id(gl_linked_shader *shader);
 
 bool lower_subroutine(exec_list *instructions, struct _mesa_glsl_parse_state *state);
 void propagate_invariance(exec_list *instructions);
index 277d4737ab748a2de5f735116dceeee2b7bcd7c7..fa845e9d1eb4c42096eb843283119e4b0bfe2c7b 100644 (file)
@@ -150,7 +150,7 @@ namespace {
       *num_buffers = 0;
 
       for (unsigned i = 0; i < MESA_SHADER_STAGES; ++i) {
-         struct gl_shader *sh = prog->_LinkedShaders[i];
+         struct gl_linked_shader *sh = prog->_LinkedShaders[i];
          if (sh == NULL)
             continue;
 
index de194c324510fe348a3dcb3951842c30e0045024..079f3b959efaa94d1a267d185cfecb310b2f717a 100644 (file)
@@ -37,7 +37,7 @@ namespace {
 
 class call_link_visitor : public ir_hierarchical_visitor {
 public:
-   call_link_visitor(gl_shader_program *prog, gl_shader *linked,
+   call_link_visitor(gl_shader_program *prog, gl_linked_shader *linked,
                     gl_shader **shader_list, unsigned num_shaders)
    {
       this->prog = prog;
@@ -297,7 +297,7 @@ private:
     * linked shader that are accessed by the function.  It is also used to add
     * global variables from the shader where the function originated.
     */
-   gl_shader *linked;
+   gl_linked_shader *linked;
 
    /**
     * Table of variables local to the function.
@@ -335,7 +335,7 @@ find_matching_signature(const char *name, const exec_list *actual_parameters,
 
 
 bool
-link_function_calls(gl_shader_program *prog, gl_shader *main,
+link_function_calls(gl_shader_program *prog, gl_linked_shader *main,
                    gl_shader **shader_list, unsigned num_shaders)
 {
    call_link_visitor v(prog, main, shader_list, num_shaders);
index 5858eeedc2dd373991c2cdadd23eaa481eeb108d..447d9a45c6321926e0815616622ea21caa41bdc2 100644 (file)
@@ -343,8 +343,8 @@ validate_intrastage_interface_blocks(struct gl_shader_program *prog,
 
 void
 validate_interstage_inout_blocks(struct gl_shader_program *prog,
-                                 const gl_shader *producer,
-                                 const gl_shader *consumer)
+                                 const gl_linked_shader *producer,
+                                 const gl_linked_shader *consumer)
 {
    interface_block_definitions definitions;
    /* VS -> GS, VS -> TCS, VS -> TES, TES -> GS */
@@ -384,15 +384,15 @@ validate_interstage_inout_blocks(struct gl_shader_program *prog,
 
 void
 validate_interstage_uniform_blocks(struct gl_shader_program *prog,
-                                   gl_shader **stages, int num_stages)
+                                   gl_linked_shader **stages)
 {
    interface_block_definitions definitions;
 
-   for (int i = 0; i < num_stages; i++) {
+   for (int i = 0; i < MESA_SHADER_STAGES; i++) {
       if (stages[i] == NULL)
          continue;
 
-      const gl_shader *stage = stages[i];
+      const gl_linked_shader *stage = stages[i];
       foreach_in_list(ir_instruction, node, stage->ir) {
          ir_variable *var = node->as_variable();
          if (!var || !var->get_interface_type() ||
index b816dab9cb7d4202f920ad1f97280f347978e2a8..4b51d40c14b3b195a20398d89f9269ce6c06e36d 100644 (file)
@@ -391,7 +391,7 @@ void
 link_uniform_blocks(void *mem_ctx,
                     struct gl_context *ctx,
                     struct gl_shader_program *prog,
-                    struct gl_shader **shader_list,
+                    struct gl_linked_shader **shader_list,
                     unsigned num_shaders,
                     struct gl_uniform_block **ubo_blocks,
                     unsigned *num_ubo_blocks,
index acf8222079a73fb6f0ed6b8a7d63a995a0254e0a..effbb6aea0c959c6432ca5decaf8076356dce277 100644 (file)
@@ -131,7 +131,7 @@ set_opaque_binding(void *mem_ctx, gl_shader_program *prog,
       }
 
       for (int sh = 0; sh < MESA_SHADER_STAGES; sh++) {
-        gl_shader *shader = prog->_LinkedShaders[sh];
+        gl_linked_shader *shader = prog->_LinkedShaders[sh];
 
          if (shader) {
             if (storage->type->base_type == GLSL_TYPE_SAMPLER &&
@@ -243,7 +243,7 @@ set_uniform_initializer(void *mem_ctx, gl_shader_program *prog,
 
       if (storage->type->is_sampler()) {
          for (int sh = 0; sh < MESA_SHADER_STAGES; sh++) {
-            gl_shader *shader = prog->_LinkedShaders[sh];
+            gl_linked_shader *shader = prog->_LinkedShaders[sh];
 
             if (shader && storage->opaque[sh].active) {
                unsigned index = storage->opaque[sh].index;
@@ -263,7 +263,7 @@ link_set_uniform_initializers(struct gl_shader_program *prog,
    void *mem_ctx = NULL;
 
    for (unsigned int i = 0; i < MESA_SHADER_STAGES; i++) {
-      struct gl_shader *shader = prog->_LinkedShaders[i];
+      struct gl_linked_shader *shader = prog->_LinkedShaders[i];
 
       if (shader == NULL)
         continue;
index 98ae3ad53718e37513cd91a9321e44462a24a027..807a8f3bd04624d5c6bb62befbe1466832c04c1b 100644 (file)
@@ -886,7 +886,7 @@ public:
  * shaders).
  */
 static void
-link_update_uniform_buffer_variables(struct gl_shader *shader)
+link_update_uniform_buffer_variables(struct gl_linked_shader *shader)
 {
    foreach_in_list(ir_instruction, node, shader->ir) {
       ir_variable *const var = node->as_variable();
@@ -1022,7 +1022,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
    struct string_to_uint_map *hiddenUniforms = new string_to_uint_map;
    count_uniform_size uniform_size(prog->UniformHash, hiddenUniforms);
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
-      struct gl_shader *sh = prog->_LinkedShaders[i];
+      struct gl_linked_shader *sh = prog->_LinkedShaders[i];
 
       if (sh == NULL)
          continue;
@@ -1204,7 +1204,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
          continue;
 
       for (unsigned j = 0; j < MESA_SHADER_STAGES; j++) {
-         struct gl_shader *sh = prog->_LinkedShaders[j];
+         struct gl_linked_shader *sh = prog->_LinkedShaders[j];
          if (!sh)
             continue;
 
@@ -1234,7 +1234,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
       if (uniforms[i].remap_location != UNMAPPED_UNIFORM_LOC)
          continue;
       for (unsigned j = 0; j < MESA_SHADER_STAGES; j++) {
-         struct gl_shader *sh = prog->_LinkedShaders[j];
+         struct gl_linked_shader *sh = prog->_LinkedShaders[j];
          if (!sh)
             continue;
 
index ef8bdbe3ade8015bad6135bc54fa542e13042f8f..db42bb1b714d1405ca8f004245b4850222681cdb 100644 (file)
@@ -107,7 +107,7 @@ create_xfb_varying_names(void *mem_ctx, const glsl_type *t, char **name,
 }
 
 bool
-process_xfb_layout_qualifiers(void *mem_ctx, const gl_shader *sh,
+process_xfb_layout_qualifiers(void *mem_ctx, const gl_linked_shader *sh,
                               unsigned *num_tfeedback_decls,
                               char ***varying_names)
 {
@@ -370,7 +370,8 @@ cross_validate_front_and_back_color(struct gl_shader_program *prog,
  */
 void
 cross_validate_outputs_to_inputs(struct gl_shader_program *prog,
-                                 gl_shader *producer, gl_shader *consumer)
+                                 gl_linked_shader *producer,
+                                 gl_linked_shader *consumer)
 {
    glsl_symbol_table parameters;
    ir_variable *explicit_locations[MAX_VARYINGS_INCL_PATCH][4] =
@@ -556,7 +557,7 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog,
  */
 void
 remove_unused_shader_inputs_and_outputs(bool is_separate_shader_object,
-                                        gl_shader *sh,
+                                        gl_linked_shader *sh,
                                         enum ir_variable_mode mode)
 {
    if (is_separate_shader_object)
@@ -1938,7 +1939,8 @@ canonicalize_shader_io(exec_list *ir, enum ir_variable_mode io_mode)
  * with a max of MAX_VARYING.
  */
 uint64_t
-reserved_varying_slot(struct gl_shader *stage, ir_variable_mode io_mode)
+reserved_varying_slot(struct gl_linked_shader *stage,
+                      ir_variable_mode io_mode)
 {
    assert(io_mode == ir_var_shader_in || io_mode == ir_var_shader_out);
    /* Avoid an overflow of the returned value */
@@ -1997,7 +1999,8 @@ bool
 assign_varying_locations(struct gl_context *ctx,
                          void *mem_ctx,
                          struct gl_shader_program *prog,
-                         gl_shader *producer, gl_shader *consumer,
+                         gl_linked_shader *producer,
+                         gl_linked_shader *consumer,
                          unsigned num_tfeedback_decls,
                          tfeedback_decl *tfeedback_decls,
                          const uint64_t reserved_slots)
@@ -2260,7 +2263,7 @@ assign_varying_locations(struct gl_context *ctx,
 bool
 check_against_output_limit(struct gl_context *ctx,
                            struct gl_shader_program *prog,
-                           gl_shader *producer,
+                           gl_linked_shader *producer,
                            unsigned num_explicit_locations)
 {
    unsigned output_vectors = num_explicit_locations;
@@ -2304,7 +2307,7 @@ check_against_output_limit(struct gl_context *ctx,
 bool
 check_against_input_limit(struct gl_context *ctx,
                           struct gl_shader_program *prog,
-                          gl_shader *consumer,
+                          gl_linked_shader *consumer,
                           unsigned num_explicit_locations)
 {
    unsigned input_vectors = num_explicit_locations;
index 39e907039a6c55b798ef81b2de108be095251643..afce56e52213b9d1d4f580fc3a16c52114083bb7 100644 (file)
@@ -291,7 +291,8 @@ private:
 
 void
 cross_validate_outputs_to_inputs(struct gl_shader_program *prog,
-                                gl_shader *producer, gl_shader *consumer);
+                                 gl_linked_shader *producer,
+                                 gl_linked_shader *consumer);
 
 bool
 parse_tfeedback_decls(struct gl_context *ctx, struct gl_shader_program *prog,
@@ -299,13 +300,13 @@ parse_tfeedback_decls(struct gl_context *ctx, struct gl_shader_program *prog,
                       char **varying_names, tfeedback_decl *decls);
 
 bool
-process_xfb_layout_qualifiers(void *mem_ctx, const gl_shader *sh,
+process_xfb_layout_qualifiers(void *mem_ctx, const gl_linked_shader *sh,
                               unsigned *num_tfeedback_decls,
                               char ***varying_names);
 
 void
 remove_unused_shader_inputs_and_outputs(bool is_separate_shader_object,
-                                        gl_shader *sh,
+                                        gl_linked_shader *sh,
                                         enum ir_variable_mode mode);
 
 bool
@@ -318,24 +319,26 @@ bool
 assign_varying_locations(struct gl_context *ctx,
                         void *mem_ctx,
                         struct gl_shader_program *prog,
-                        gl_shader *producer, gl_shader *consumer,
+                         gl_linked_shader *producer,
+                         gl_linked_shader *consumer,
                          unsigned num_tfeedback_decls,
                          tfeedback_decl *tfeedback_decls,
                          const uint64_t reserved_slots);
 
 uint64_t
-reserved_varying_slot(struct gl_shader *stage, ir_variable_mode io_mode);
+reserved_varying_slot(struct gl_linked_shader *stage,
+                      ir_variable_mode io_mode);
 
 bool
 check_against_output_limit(struct gl_context *ctx,
                            struct gl_shader_program *prog,
-                           gl_shader *producer,
+                           gl_linked_shader *producer,
                            unsigned num_explicit_locations);
 
 bool
 check_against_input_limit(struct gl_context *ctx,
                           struct gl_shader_program *prog,
-                          gl_shader *consumer,
+                          gl_linked_shader *consumer,
                           unsigned num_explicit_locations);
 
 #endif /* GLSL_LINK_VARYINGS_H */
index 411d2feec74d49115e6d6776e8f6a1f800ed9bfe..926520eb1b8e08270f15003eee2c8cf9f833d28a 100644 (file)
@@ -655,7 +655,7 @@ link_invalidate_variable_locations(exec_list *ir)
  */
 static void
 analyze_clip_cull_usage(struct gl_shader_program *prog,
-                        struct gl_shader *shader,
+                        struct gl_linked_shader *shader,
                         struct gl_context *ctx,
                         GLuint *clip_distance_array_size,
                         GLuint *cull_distance_array_size)
@@ -750,7 +750,7 @@ analyze_clip_cull_usage(struct gl_shader_program *prog,
  */
 void
 validate_vertex_shader_executable(struct gl_shader_program *prog,
-                                  struct gl_shader *shader,
+                                  struct gl_linked_shader *shader,
                                   struct gl_context *ctx)
 {
    if (shader == NULL)
@@ -805,7 +805,7 @@ validate_vertex_shader_executable(struct gl_shader_program *prog,
 
 void
 validate_tess_eval_shader_executable(struct gl_shader_program *prog,
-                                     struct gl_shader *shader,
+                                     struct gl_linked_shader *shader,
                                      struct gl_context *ctx)
 {
    if (shader == NULL)
@@ -824,7 +824,7 @@ validate_tess_eval_shader_executable(struct gl_shader_program *prog,
  */
 void
 validate_fragment_shader_executable(struct gl_shader_program *prog,
-                                    struct gl_shader *shader)
+                                    struct gl_linked_shader *shader)
 {
    if (shader == NULL)
       return;
@@ -851,7 +851,7 @@ validate_fragment_shader_executable(struct gl_shader_program *prog,
  */
 void
 validate_geometry_shader_executable(struct gl_shader_program *prog,
-                                    struct gl_shader *shader,
+                                    struct gl_linked_shader *shader,
                                     struct gl_context *ctx)
 {
    if (shader == NULL)
@@ -873,7 +873,7 @@ static void
 validate_geometry_shader_emissions(struct gl_context *ctx,
                                    struct gl_shader_program *prog)
 {
-   struct gl_shader *sh = prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
+   struct gl_linked_shader *sh = prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
 
    if (sh != NULL) {
       find_emit_vertex_visitor emit_vertex(ctx->Const.MaxVertexStreams - 1);
@@ -1240,7 +1240,7 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog,
    }
 
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
-      struct gl_shader *sh = prog->_LinkedShaders[i];
+      struct gl_linked_shader *sh = prog->_LinkedShaders[i];
 
       InterfaceBlockStageIndex[i] = new int[max_num_buffer_blocks];
       for (unsigned int j = 0; j < max_num_buffer_blocks; j++)
@@ -1285,7 +1285,7 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog,
          int stage_index = InterfaceBlockStageIndex[i][j];
 
         if (stage_index != -1) {
-           struct gl_shader *sh = prog->_LinkedShaders[i];
+           struct gl_linked_shader *sh = prog->_LinkedShaders[i];
 
             blks[j].stageref |= (1 << i);
 
@@ -1314,7 +1314,7 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog,
  * Populates a shaders symbol table with all global declarations
  */
 static void
-populate_symbol_table(gl_shader *sh)
+populate_symbol_table(gl_linked_shader *sh)
 {
    sh->symbols = new(sh) glsl_symbol_table;
 
@@ -1352,12 +1352,12 @@ populate_symbol_table(gl_shader *sh)
  *                     should be added.
  */
 void
-remap_variables(ir_instruction *inst, struct gl_shader *target,
+remap_variables(ir_instruction *inst, struct gl_linked_shader *target,
                hash_table *temps)
 {
    class remap_visitor : public ir_hierarchical_visitor {
    public:
-        remap_visitor(struct gl_shader *target,
+        remap_visitor(struct gl_linked_shader *target,
                    hash_table *temps)
       {
         this->target = target;
@@ -1392,7 +1392,7 @@ remap_variables(ir_instruction *inst, struct gl_shader *target,
       }
 
    private:
-      struct gl_shader *target;
+      struct gl_linked_shader *target;
       glsl_symbol_table *symbols;
       exec_list *instructions;
       hash_table *temps;
@@ -1427,7 +1427,7 @@ remap_variables(ir_instruction *inst, struct gl_shader *target,
  */
 exec_node *
 move_non_declarations(exec_list *instructions, exec_node *last,
-                     bool make_copies, gl_shader *target)
+                     bool make_copies, gl_linked_shader *target)
 {
    hash_table *temps = NULL;
 
@@ -1682,7 +1682,7 @@ private:
 static void
 link_xfb_stride_layout_qualifiers(struct gl_context *ctx,
                                   struct gl_shader_program *prog,
-                                 struct gl_shader *linked_shader,
+                                 struct gl_linked_shader *linked_shader,
                                  struct gl_shader **shader_list,
                                  unsigned num_shaders)
 {
@@ -1746,7 +1746,7 @@ link_xfb_stride_layout_qualifiers(struct gl_context *ctx,
  */
 static void
 link_tcs_out_layout_qualifiers(struct gl_shader_program *prog,
-                             struct gl_shader *linked_shader,
+                             struct gl_linked_shader *linked_shader,
                              struct gl_shader **shader_list,
                              unsigned num_shaders)
 {
@@ -1801,7 +1801,7 @@ link_tcs_out_layout_qualifiers(struct gl_shader_program *prog,
  */
 static void
 link_tes_in_layout_qualifiers(struct gl_shader_program *prog,
-                               struct gl_shader *linked_shader,
+                               struct gl_linked_shader *linked_shader,
                                struct gl_shader **shader_list,
                                unsigned num_shaders)
 {
@@ -1901,7 +1901,7 @@ link_tes_in_layout_qualifiers(struct gl_shader_program *prog,
  */
 static void
 link_fs_input_layout_qualifiers(struct gl_shader_program *prog,
-                               struct gl_shader *linked_shader,
+                               struct gl_linked_shader *linked_shader,
                                struct gl_shader **shader_list,
                                unsigned num_shaders)
 {
@@ -1969,7 +1969,7 @@ link_fs_input_layout_qualifiers(struct gl_shader_program *prog,
  */
 static void
 link_gs_inout_layout_qualifiers(struct gl_shader_program *prog,
-                               struct gl_shader *linked_shader,
+                               struct gl_linked_shader *linked_shader,
                                struct gl_shader **shader_list,
                                unsigned num_shaders)
 {
@@ -2076,7 +2076,7 @@ link_gs_inout_layout_qualifiers(struct gl_shader_program *prog,
  */
 static void
 link_cs_input_layout_qualifiers(struct gl_shader_program *prog,
-                                struct gl_shader *linked_shader,
+                                struct gl_linked_shader *linked_shader,
                                 struct gl_shader **shader_list,
                                 unsigned num_shaders)
 {
@@ -2138,7 +2138,7 @@ link_cs_input_layout_qualifiers(struct gl_shader_program *prog,
  * If this function is supplied a single shader, it is cloned, and the new
  * shader is returned.
  */
-static struct gl_shader *
+static struct gl_linked_shader *
 link_intrastage_shaders(void *mem_ctx,
                        struct gl_context *ctx,
                        struct gl_shader_program *prog,
@@ -2216,7 +2216,7 @@ link_intrastage_shaders(void *mem_ctx,
     */
    gl_shader *main = NULL;
    for (unsigned i = 0; i < num_shaders; i++) {
-      if (!_mesa_get_main_function_signature(shader_list[i]->symbols)) {
+      if (_mesa_get_main_function_signature(shader_list[i]->symbols)) {
         main = shader_list[i];
         break;
       }
@@ -2228,7 +2228,7 @@ link_intrastage_shaders(void *mem_ctx,
       return NULL;
    }
 
-   gl_shader *linked = ctx->Driver.NewShader(NULL, 0, shader_list[0]->Stage);
+   gl_linked_shader *linked = ctx->Driver.NewShader(shader_list[0]->Stage);
    linked->ir = new(linked) exec_list;
    clone_ir_list(mem_ctx, linked->ir, main->ir);
 
@@ -2299,7 +2299,7 @@ link_intrastage_shaders(void *mem_ctx,
 
 
    if (!ok) {
-      _mesa_delete_shader(ctx, linked);
+      _mesa_delete_linked_shader(ctx, linked);
       return NULL;
    }
 
@@ -2317,7 +2317,7 @@ link_intrastage_shaders(void *mem_ctx,
                        &num_ssbo_blocks);
 
    if (!prog->LinkStatus) {
-      _mesa_delete_shader(ctx, linked);
+      _mesa_delete_linked_shader(ctx, linked);
       return NULL;
    }
 
@@ -2463,8 +2463,8 @@ resize_tes_inputs(struct gl_context *ctx,
    if (prog->_LinkedShaders[MESA_SHADER_TESS_EVAL] == NULL)
       return;
 
-   gl_shader *const tcs = prog->_LinkedShaders[MESA_SHADER_TESS_CTRL];
-   gl_shader *const tes = prog->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+   gl_linked_shader *const tcs = prog->_LinkedShaders[MESA_SHADER_TESS_CTRL];
+   gl_linked_shader *const tes = prog->_LinkedShaders[MESA_SHADER_TESS_EVAL];
 
    /* If no control shader is present, then the TES inputs are statically
     * sized to MaxPatchVertices; the actual size of the arrays won't be
@@ -2576,7 +2576,7 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
    assert((target_index == MESA_SHADER_VERTEX)
          || (target_index == MESA_SHADER_FRAGMENT));
 
-   gl_shader *const sh = prog->_LinkedShaders[target_index];
+   gl_linked_shader *const sh = prog->_LinkedShaders[target_index];
    if (sh == NULL)
       return true;
 
@@ -2976,8 +2976,8 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
  * unmatch flag if found so we don't optimise them away.
  */
 static void
-match_explicit_outputs_to_inputs(gl_shader *producer,
-                                 gl_shader *consumer)
+match_explicit_outputs_to_inputs(gl_linked_shader *producer,
+                                 gl_linked_shader *consumer)
 {
    glsl_symbol_table parameters;
    ir_variable *explicit_locations[MAX_VARYINGS_INCL_PATCH][4] =
@@ -3081,7 +3081,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
    unsigned total_shader_storage_blocks = 0;
 
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
-      struct gl_shader *sh = prog->_LinkedShaders[i];
+      struct gl_linked_shader *sh = prog->_LinkedShaders[i];
 
       if (sh == NULL)
         continue;
@@ -3175,7 +3175,7 @@ static void
 link_calculate_subroutine_compat(struct gl_shader_program *prog)
 {
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
-      struct gl_shader *sh = prog->_LinkedShaders[i];
+      struct gl_linked_shader *sh = prog->_LinkedShaders[i];
       int count;
       if (!sh)
          continue;
@@ -3213,7 +3213,7 @@ static void
 check_subroutine_resources(struct gl_shader_program *prog)
 {
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
-      struct gl_shader *sh = prog->_LinkedShaders[i];
+      struct gl_linked_shader *sh = prog->_LinkedShaders[i];
 
       if (sh) {
          if (sh->NumSubroutineUniformRemapTable > MAX_SUBROUTINE_UNIFORM_LOCATIONS)
@@ -3236,7 +3236,7 @@ check_image_resources(struct gl_context *ctx, struct gl_shader_program *prog)
       return;
 
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
-      struct gl_shader *sh = prog->_LinkedShaders[i];
+      struct gl_linked_shader *sh = prog->_LinkedShaders[i];
 
       if (sh) {
          if (sh->NumImages > ctx->Const.Program[i].MaxImageUniforms)
@@ -3340,7 +3340,7 @@ reserve_explicit_locations(struct gl_shader_program *prog,
 
 static bool
 reserve_subroutine_explicit_locations(struct gl_shader_program *prog,
-                                      struct gl_shader *sh,
+                                      struct gl_linked_shader *sh,
                                       ir_variable *var)
 {
    unsigned slots = var->type->uniform_locations();
@@ -3415,7 +3415,7 @@ check_explicit_uniform_locations(struct gl_context *ctx,
 
    unsigned entries_total = 0;
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
-      struct gl_shader *sh = prog->_LinkedShaders[i];
+      struct gl_linked_shader *sh = prog->_LinkedShaders[i];
 
       if (!sh)
          continue;
@@ -3620,7 +3620,7 @@ build_stageref(struct gl_shader_program *shProg, const char *name,
    assert(MESA_SHADER_STAGES < 8);
 
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
-      struct gl_shader *sh = shProg->_LinkedShaders[i];
+      struct gl_linked_shader *sh = shProg->_LinkedShaders[i];
       if (!sh)
          continue;
 
@@ -3859,7 +3859,7 @@ add_interface_variables(struct gl_shader_program *shProg,
 static bool
 add_packed_varyings(struct gl_shader_program *shProg, int stage, GLenum type)
 {
-   struct gl_shader *sh = shProg->_LinkedShaders[stage];
+   struct gl_linked_shader *sh = shProg->_LinkedShaders[stage];
    GLenum iface;
 
    if (!sh || !sh->packed_varyings)
@@ -3895,7 +3895,7 @@ add_packed_varyings(struct gl_shader_program *shProg, int stage, GLenum type)
 static bool
 add_fragdata_arrays(struct gl_shader_program *shProg)
 {
-   struct gl_shader *sh = shProg->_LinkedShaders[MESA_SHADER_FRAGMENT];
+   struct gl_linked_shader *sh = shProg->_LinkedShaders[MESA_SHADER_FRAGMENT];
 
    if (!sh || !sh->fragdata_arrays)
       return true;
@@ -4270,7 +4270,7 @@ build_program_resource_list(struct gl_context *ctx,
    }
 
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
-      struct gl_shader *sh = shProg->_LinkedShaders[i];
+      struct gl_linked_shader *sh = shProg->_LinkedShaders[i];
       GLuint type;
 
       if (!sh)
@@ -4322,7 +4322,7 @@ static void
 link_assign_subroutine_types(struct gl_shader_program *prog)
 {
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
-      gl_shader *sh = prog->_LinkedShaders[i];
+      gl_linked_shader *sh = prog->_LinkedShaders[i];
 
       if (sh == NULL)
          continue;
@@ -4428,7 +4428,7 @@ disable_varying_optimizations_for_sso(struct gl_shader_program *prog)
       return;
 
    for (unsigned stage = 0; stage < MESA_SHADER_STAGES; stage++) {
-      gl_shader *sh = prog->_LinkedShaders[stage];
+      gl_linked_shader *sh = prog->_LinkedShaders[stage];
       if (!sh)
          continue;
 
@@ -4587,8 +4587,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
    }
 
    for (unsigned int i = 0; i < MESA_SHADER_STAGES; i++) {
-      if (prog->_LinkedShaders[i] != NULL)
-        _mesa_delete_shader(ctx, prog->_LinkedShaders[i]);
+      if (prog->_LinkedShaders[i] != NULL) {
+        _mesa_delete_linked_shader(ctx, prog->_LinkedShaders[i]);
+      }
 
       prog->_LinkedShaders[i] = NULL;
    }
@@ -4597,13 +4598,13 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
     */
    for (int stage = 0; stage < MESA_SHADER_STAGES; stage++) {
       if (num_shaders[stage] > 0) {
-         gl_shader *const sh =
+         gl_linked_shader *const sh =
             link_intrastage_shaders(mem_ctx, ctx, prog, shader_list[stage],
                                     num_shaders[stage]);
 
          if (!prog->LinkStatus) {
             if (sh)
-               _mesa_delete_shader(ctx, sh);
+               _mesa_delete_linked_shader(ctx, sh);
             goto done;
          }
 
@@ -4626,11 +4627,11 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
          }
          if (!prog->LinkStatus) {
             if (sh)
-               _mesa_delete_shader(ctx, sh);
+               _mesa_delete_linked_shader(ctx, sh);
             goto done;
          }
 
-         _mesa_reference_shader(ctx, &prog->_LinkedShaders[stage], sh);
+         prog->_LinkedShaders[stage] = sh;
       }
    }
 
@@ -4701,8 +4702,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
    }
 
    /* Cross-validate uniform blocks between shader stages */
-   validate_interstage_uniform_blocks(prog, prog->_LinkedShaders,
-                                      MESA_SHADER_STAGES);
+   validate_interstage_uniform_blocks(prog, prog->_LinkedShaders);
    if (!prog->LinkStatus)
       goto done;
 
@@ -4718,7 +4718,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
     * This rule also applies to GLSL ES 3.00.
     */
    if (max_version >= (prog->IsES ? 300 : 130)) {
-      struct gl_shader *sh = prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
+      struct gl_linked_shader *sh = prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
       if (sh) {
         lower_discard_flow(sh->ir);
       }
@@ -4879,7 +4879,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
       /* If the program is made up of only a single stage */
       if (first == last) {
 
-         gl_shader *const sh = prog->_LinkedShaders[last];
+         gl_linked_shader *const sh = prog->_LinkedShaders[last];
          if (prog->SeparateShader) {
             const uint64_t reserved_slots =
                reserved_varying_slot(sh, ir_var_shader_in);
@@ -4910,8 +4910,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
             if (prog->_LinkedShaders[i] == NULL && i != 0)
                continue;
 
-            gl_shader *const sh_i = prog->_LinkedShaders[i];
-            gl_shader *const sh_next = prog->_LinkedShaders[next];
+            gl_linked_shader *const sh_i = prog->_LinkedShaders[i];
+            gl_linked_shader *const sh_next = prog->_LinkedShaders[next];
 
             const uint64_t reserved_out_slots =
                reserved_varying_slot(sh_i, ir_var_shader_out);
index 045dc1fff02c0708f36bf600b19fdc0239926dd4..19b14d50696756dbd00ef7421f0bfe05acce46aa 100644 (file)
@@ -27,7 +27,7 @@
 #define GLSL_LINKER_H
 
 extern bool
-link_function_calls(gl_shader_program *prog, gl_shader *main,
+link_function_calls(gl_shader_program *prog, gl_linked_shader *main,
                    gl_shader **shader_list, unsigned num_shaders);
 
 extern void
@@ -57,7 +57,7 @@ extern void
 link_uniform_blocks(void *mem_ctx,
                     struct gl_context *ctx,
                     struct gl_shader_program *prog,
-                    struct gl_shader **shader_list,
+                    struct gl_linked_shader **shader_list,
                     unsigned num_shaders,
                     struct gl_uniform_block **ubo_blocks,
                     unsigned *num_ubo_blocks,
@@ -76,12 +76,12 @@ validate_intrastage_interface_blocks(struct gl_shader_program *prog,
 
 void
 validate_interstage_inout_blocks(struct gl_shader_program *prog,
-                                 const gl_shader *producer,
-                                 const gl_shader *consumer);
+                                 const gl_linked_shader *producer,
+                                 const gl_linked_shader *consumer);
 
 void
 validate_interstage_uniform_blocks(struct gl_shader_program *prog,
-                                   gl_shader **stages, int num_stages);
+                                   gl_linked_shader **stages);
 
 extern void
 link_assign_atomic_counter_resources(struct gl_context *ctx,
index c2158f24f3940d111106564a18ab2c59cc9f8e8e..e2d7e2a5886c7d160e33f5fdae7b13004de6d608 100644 (file)
@@ -654,7 +654,8 @@ lower_distance_visitor_counter::handle_rvalue(ir_rvalue **rv)
 }
 
 bool
-lower_clip_cull_distance(struct gl_shader_program *prog, gl_shader *shader)
+lower_clip_cull_distance(struct gl_shader_program *prog,
+                         struct gl_linked_shader *shader)
 {
    int clip_size, cull_size;
 
index f780ecacbd29b627270f729c69ac2d06aeb6f356..dbf0c639028f95c2b60fbaa9ca337e65b3efe9ce 100644 (file)
@@ -289,7 +289,7 @@ flatten_named_interface_blocks_declarations::handle_rvalue(ir_rvalue **rvalue)
 }
 
 void
-lower_named_interface_blocks(void *mem_ctx, gl_shader *shader)
+lower_named_interface_blocks(void *mem_ctx, gl_linked_shader *shader)
 {
    flatten_named_interface_blocks_declarations v_decl(mem_ctx);
    v_decl.run(shader->ir);
index 130b8f66ed698c411259649312ab96c5a45ab063..a897d2fb59b80cae59119e2d36a3dbf2cdc0995e 100644 (file)
@@ -172,7 +172,7 @@ public:
                                  bool disable_varying_packing,
                                  bool xfb_enabled);
 
-   void run(struct gl_shader *shader);
+   void run(struct gl_linked_shader *shader);
 
 private:
    void bitwise_assign_pack(ir_rvalue *lhs, ir_rvalue *rhs);
@@ -260,7 +260,7 @@ lower_packed_varyings_visitor::lower_packed_varyings_visitor(
 }
 
 void
-lower_packed_varyings_visitor::run(struct gl_shader *shader)
+lower_packed_varyings_visitor::run(struct gl_linked_shader *shader)
 {
    foreach_in_list(ir_instruction, node, shader->ir) {
       ir_variable *var = node->as_variable();
@@ -767,7 +767,7 @@ lower_packed_varyings_return_splicer::visit_leave(ir_return *ret)
 void
 lower_packed_varyings(void *mem_ctx, unsigned locations_used,
                       ir_variable_mode mode, unsigned gs_input_vertices,
-                      gl_shader *shader, bool disable_varying_packing,
+                      gl_linked_shader *shader, bool disable_varying_packing,
                       bool xfb_enabled)
 {
    exec_list *instructions = shader->ir;
index e63e7dd819301f12acab4154159c51b20e3edd7a..1702469fe656d355952393356b063a5c6b52e324 100644 (file)
@@ -51,7 +51,7 @@ class lower_shared_reference_visitor :
       public lower_buffer_access::lower_buffer_access {
 public:
 
-   lower_shared_reference_visitor(struct gl_shader *shader)
+   lower_shared_reference_visitor(struct gl_linked_shader *shader)
       : list_ctx(ralloc_context(NULL)), shader(shader), shared_size(0u)
    {
       list_inithead(&var_offsets);
@@ -88,7 +88,7 @@ public:
                          unsigned write_mask);
 
    void *list_ctx;
-   struct gl_shader *shader;
+   struct gl_linked_shader *shader;
    struct list_head var_offsets;
    unsigned shared_size;
    bool progress;
@@ -475,7 +475,7 @@ lower_shared_reference_visitor::visit_enter(ir_call *ir)
 } /* unnamed namespace */
 
 void
-lower_shared_reference(struct gl_shader *shader, unsigned *shared_size)
+lower_shared_reference(struct gl_linked_shader *shader, unsigned *shared_size)
 {
    if (shader->Stage != MESA_SHADER_COMPUTE)
       return;
index bed2553222f717f7052aed86b0710badbfb1def4..adca29ce424d7bd63c5a137c82d490c955380e1f 100644 (file)
@@ -440,7 +440,7 @@ lower_tess_level_visitor::visit_leave(ir_call *ir)
 
 
 bool
-lower_tess_level(gl_shader *shader)
+lower_tess_level(gl_linked_shader *shader)
 {
    if ((shader->Stage != MESA_SHADER_TESS_CTRL) &&
        (shader->Stage != MESA_SHADER_TESS_EVAL))
index c27de0b2565d4ae2a78a3083f19d4d5d26e524ce..083f43f93a39d37e4e620af74627be56c743a48d 100644 (file)
@@ -44,7 +44,7 @@ namespace {
 class lower_ubo_reference_visitor :
       public lower_buffer_access::lower_buffer_access {
 public:
-   lower_ubo_reference_visitor(struct gl_shader *shader,
+   lower_ubo_reference_visitor(struct gl_linked_shader *shader,
                                bool clamp_block_indices)
    : shader(shader), clamp_block_indices(clamp_block_indices),
      struct_field(NULL), variable(NULL)
@@ -105,7 +105,7 @@ public:
    ir_call *check_for_ssbo_atomic_intrinsic(ir_call *ir);
    ir_visitor_status visit_enter(ir_call *ir);
 
-   struct gl_shader *shader;
+   struct gl_linked_shader *shader;
    bool clamp_block_indices;
    struct gl_uniform_buffer_variable *ubo_var;
    const struct glsl_struct_field *struct_field;
@@ -1090,7 +1090,7 @@ lower_ubo_reference_visitor::visit_enter(ir_call *ir)
 } /* unnamed namespace */
 
 void
-lower_ubo_reference(struct gl_shader *shader, bool clamp_block_indices)
+lower_ubo_reference(struct gl_linked_shader *shader, bool clamp_block_indices)
 {
    lower_ubo_reference_visitor v(shader, clamp_block_indices);
 
index 4a5d6f0da4cd2527f5a0618676900daea2c12e42..f7bf68db3646be163d0ffd853c3b807f15576788 100644 (file)
@@ -94,7 +94,7 @@ vector_deref_visitor::handle_rvalue(ir_rvalue **rv)
 }
 
 bool
-lower_vector_derefs(gl_shader *shader)
+lower_vector_derefs(gl_linked_shader *shader)
 {
    vector_deref_visitor v;
 
index ee69d94038839a9f046bd70d9b83ba9d6aa87d06..412b97e527bf3bb738b8ca8d8d624ddd28ca9c20 100644 (file)
@@ -122,7 +122,7 @@ lower_vertex_id_visitor::visit(ir_dereference_variable *ir)
 }
 
 bool
-lower_vertex_id(gl_shader *shader)
+lower_vertex_id(gl_linked_shader *shader)
 {
    /* gl_VertexID only exists in the vertex shader.
     */
index 2e40b78d20bf7f5e368ec469c9df27268437c569..7feea3ba18b5c93076a68c45689e1182efdeb00c 100644 (file)
@@ -272,7 +272,7 @@ public:
  */
 class replace_varyings_visitor : public ir_rvalue_visitor {
 public:
-   replace_varyings_visitor(struct gl_shader *sha,
+   replace_varyings_visitor(struct gl_linked_shader *sha,
                             const varying_info_visitor *info,
                             unsigned external_texcoord_usage,
                             unsigned external_color_usage,
@@ -499,7 +499,7 @@ public:
    }
 
 private:
-   struct gl_shader *shader;
+   struct gl_linked_shader *shader;
    const varying_info_visitor *info;
    ir_variable *new_fragdata[MAX_DRAW_BUFFERS];
    ir_variable *new_texcoord[MAX_TEXTURE_COORD_UNITS];
@@ -511,7 +511,7 @@ private:
 } /* anonymous namespace */
 
 static void
-lower_texcoord_array(struct gl_shader *shader, const varying_info_visitor *info)
+lower_texcoord_array(struct gl_linked_shader *shader, const varying_info_visitor *info)
 {
    replace_varyings_visitor(shader, info,
                             (1 << MAX_TEXTURE_COORD_UNITS) - 1,
@@ -519,7 +519,7 @@ lower_texcoord_array(struct gl_shader *shader, const varying_info_visitor *info)
 }
 
 static void
-lower_fragdata_array(struct gl_shader *shader)
+lower_fragdata_array(struct gl_linked_shader *shader)
 {
    varying_info_visitor info(ir_var_shader_out, true);
    info.get(shader->ir, 0, NULL);
@@ -530,7 +530,8 @@ lower_fragdata_array(struct gl_shader *shader)
 
 void
 do_dead_builtin_varyings(struct gl_context *ctx,
-                         gl_shader *producer, gl_shader *consumer,
+                         gl_linked_shader *producer,
+                         gl_linked_shader *consumer,
                          unsigned num_tfeedback_decls,
                          tfeedback_decl *tfeedback_decls)
 {
index d0057df7f323d5f750fe627d12a181434f26b58b..760fe8f01b53bb51f3f3d4859c6bbfedb78cbcd2 100644 (file)
@@ -222,7 +222,7 @@ initialize_context(struct gl_context *ctx, gl_api api)
    ctx->Const.GenerateTemporaryNames = true;
    ctx->Const.MaxPatchVertices = 32;
 
-   ctx->Driver.NewShader = _mesa_new_shader;
+   ctx->Driver.NewShader = _mesa_new_linked_shader;
 }
 
 /* Returned string will have 'ctx' as its ralloc owner. */
@@ -412,7 +412,7 @@ standalone_compile_shader(const struct standalone_options *_options,
       }
 
       for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
-         struct gl_shader *shader = whole_program->_LinkedShaders[i];
+         struct gl_linked_shader *shader = whole_program->_LinkedShaders[i];
 
          if (!shader)
             continue;
index 396965af3b53c1ae7d4bbc863d99ffa09941b09f..b5dc5231ee845a2094145690f634938ad29f7b18 100644 (file)
@@ -84,6 +84,19 @@ _mesa_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage)
    return shader;
 }
 
+struct gl_linked_shader *
+_mesa_new_linked_shader(gl_shader_stage stage)
+{
+   struct gl_linked_shader *shader;
+
+   assert(stage == MESA_SHADER_FRAGMENT || stage == MESA_SHADER_VERTEX);
+   shader = rzalloc(NULL, struct gl_linked_shader);
+   if (shader) {
+      shader->Stage = stage;
+   }
+   return shader;
+}
+
 void
 _mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh)
 {
@@ -92,6 +105,13 @@ _mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh)
    ralloc_free(sh);
 }
 
+void
+_mesa_delete_linked_shader(struct gl_context *ctx,
+                           struct gl_linked_shader *sh)
+{
+   ralloc_free(sh);
+}
+
 void
 _mesa_clear_shader_program_data(struct gl_shader_program *shProg)
 {
index 15dc7028f64fbd29d54060c2a4cde4c5489f5ba0..c6666c9c73d7d5b865f2d8bd4e0237ced8fcc858 100644 (file)
@@ -44,9 +44,16 @@ _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
 extern "C" struct gl_shader *
 _mesa_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage);
 
+extern "C" struct gl_linked_shader *
+_mesa_new_linked_shader(gl_shader_stage stage);
+
 extern "C" void
 _mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh);
 
+extern "C" void
+_mesa_delete_linked_shader(struct gl_context *ctx,
+                           struct gl_linked_shader *sh);
+
 extern "C" void
 _mesa_clear_shader_program_data(struct gl_shader_program *);
 
index fed1fabf3019fa5f68e90c87942671df2be9838f..f19d7e6e6d53653833af7b6b90a16e610eace66e 100644 (file)
@@ -200,7 +200,7 @@ int test_optpass(int argc, char **argv)
    struct gl_context *ctx = &local_ctx;
    initialize_context_to_defaults(ctx, API_OPENGL_COMPAT);
 
-   ctx->Driver.NewShader = _mesa_new_shader;
+   ctx->Driver.NewShader = _mesa_new_linked_shader;
    ir_variable::temporaries_allocate_names = true;
 
    struct gl_shader *shader = rzalloc(NULL, struct gl_shader);
index be671b4b629c63e0fe268e24b3161cd6d650f374..df57c87fa3fb9bd7ca89603c0519fd117adfb23c 100644 (file)
@@ -129,7 +129,7 @@ meta_compile_shader_with_debug(struct gl_context *ctx, gl_shader_stage stage,
    const GLuint name = ~0;
    struct gl_shader *sh;
 
-   sh = ctx->Driver.NewShader(ctx, name, stage);
+   sh = _mesa_new_shader(ctx, name, stage);
    sh->Source = strdup(source);
    sh->CompileStatus = false;
    _mesa_compile_shader(ctx, sh);
index c7a66cb99911d427e4a130b5588ab6d48e48bd28..5e3c9d169b356e19e671fa8c806b9b2477820ccf 100644 (file)
@@ -239,8 +239,9 @@ intel_update_state(struct gl_context * ctx, GLuint new_state)
 
    /* Resolve color for each active shader image. */
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
-      const struct gl_shader *shader = ctx->_Shader->CurrentProgram[i] ?
-         ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i] : NULL;
+      const struct gl_linked_shader *shader =
+         ctx->_Shader->CurrentProgram[i] ?
+            ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i] : NULL;
 
       if (unlikely(shader && shader->NumImages)) {
          for (unsigned j = 0; j < shader->NumImages; j++) {
index 9d7a5b45c3643ff158507ab82b993aee1dbb3dab..cc0327876676ac6f9332c6654c18fedcf90a964f 100644 (file)
@@ -366,7 +366,7 @@ struct brw_compute_program {
 
 
 struct brw_shader {
-   struct gl_shader base;
+   struct gl_linked_shader base;
 
    bool compiled_once;
 };
@@ -1581,15 +1581,15 @@ brw_update_sol_surface(struct brw_context *brw,
                        uint32_t *out_offset, unsigned num_vector_components,
                        unsigned stride_dwords, unsigned offset_dwords);
 void brw_upload_ubo_surfaces(struct brw_context *brw,
-                            struct gl_shader *shader,
+                            struct gl_linked_shader *shader,
                              struct brw_stage_state *stage_state,
                              struct brw_stage_prog_data *prog_data);
 void brw_upload_abo_surfaces(struct brw_context *brw,
-                             struct gl_shader *shader,
+                             struct gl_linked_shader *shader,
                              struct brw_stage_state *stage_state,
                              struct brw_stage_prog_data *prog_data);
 void brw_upload_image_surfaces(struct brw_context *brw,
-                               struct gl_shader *shader,
+                               struct gl_linked_shader *shader,
                                struct brw_stage_state *stage_state,
                                struct brw_stage_prog_data *prog_data);
 
index 4ac1009447c4963e5a423de63845bd08bbbafbf4..1ce74d8b0ef963da3816e35e1415f2763a76ba0b 100644 (file)
@@ -98,7 +98,6 @@ brw_codegen_gs_prog(struct brw_context *brw,
                     struct brw_gs_prog_key *key)
 {
    struct brw_compiler *compiler = brw->intelScreen->compiler;
-   struct gl_shader *shader = prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
    struct brw_stage_state *stage_state = &brw->gs.base;
    struct brw_gs_prog_data prog_data;
    bool start_busy = false;
@@ -117,7 +116,7 @@ brw_codegen_gs_prog(struct brw_context *brw,
     * padding around uniform values below vec4 size, so the worst case is that
     * every uniform is a float which gets padded to the size of a vec4.
     */
-   struct gl_shader *gs = prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
+   struct gl_linked_shader *gs = prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
    struct brw_shader *bgs = (struct brw_shader *) gs;
    int param_count = gp->program.Base.nir->num_uniforms / 4;
 
@@ -161,7 +160,7 @@ brw_codegen_gs_prog(struct brw_context *brw,
    char *error_str;
    const unsigned *program =
       brw_compile_gs(brw->intelScreen->compiler, brw, mem_ctx, key,
-                     &prog_data, shader->Program->nir, prog,
+                     &prog_data, gs->Program->nir, prog,
                      st_index, &program_size, &error_str);
    if (program == NULL) {
       ralloc_free(mem_ctx);
index 76c580b4648802de018829dae0d4d389cc1af1b3..5374685325cdfb520fc26434e19c90a44ef5362e 100644 (file)
@@ -43,12 +43,12 @@ static bool
 brw_shader_precompile(struct gl_context *ctx,
                       struct gl_shader_program *sh_prog)
 {
-   struct gl_shader *vs = sh_prog->_LinkedShaders[MESA_SHADER_VERTEX];
-   struct gl_shader *tcs = sh_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL];
-   struct gl_shader *tes = sh_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL];
-   struct gl_shader *gs = sh_prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
-   struct gl_shader *fs = sh_prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
-   struct gl_shader *cs = sh_prog->_LinkedShaders[MESA_SHADER_COMPUTE];
+   struct gl_linked_shader *vs = sh_prog->_LinkedShaders[MESA_SHADER_VERTEX];
+   struct gl_linked_shader *tcs = sh_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL];
+   struct gl_linked_shader *tes = sh_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+   struct gl_linked_shader *gs = sh_prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
+   struct gl_linked_shader *fs = sh_prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
+   struct gl_linked_shader *cs = sh_prog->_LinkedShaders[MESA_SHADER_COMPUTE];
 
    if (fs && !brw_fs_precompile(ctx, sh_prog, fs->Program))
       return false;
@@ -89,7 +89,7 @@ static void
 process_glsl_ir(gl_shader_stage stage,
                 struct brw_context *brw,
                 struct gl_shader_program *shader_prog,
-                struct gl_shader *shader)
+                struct gl_linked_shader *shader)
 {
    struct gl_context *ctx = &brw->ctx;
    const struct brw_compiler *compiler = brw->intelScreen->compiler;
@@ -186,16 +186,14 @@ process_glsl_ir(gl_shader_stage stage,
    }
 }
 
-extern "C" struct gl_shader *
-brw_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage)
+extern "C" struct gl_linked_shader *
+brw_new_shader(gl_shader_stage stage)
 {
    struct brw_shader *shader;
 
    shader = rzalloc(NULL, struct brw_shader);
    if (shader) {
       shader->base.Stage = stage;
-      shader->base.Name = name;
-      _mesa_init_shader(ctx, &shader->base);
    }
 
    return &shader->base;
@@ -209,13 +207,13 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
    unsigned int stage;
 
    for (stage = 0; stage < ARRAY_SIZE(shProg->_LinkedShaders); stage++) {
-      struct gl_shader *shader = shProg->_LinkedShaders[stage];
+      struct gl_linked_shader *shader = shProg->_LinkedShaders[stage];
       if (!shader)
          continue;
 
       struct gl_program *prog =
          ctx->Driver.NewProgram(ctx, _mesa_shader_stage_to_program(stage),
-                                shader->Name);
+                                0);
       if (!prog)
         return false;
       prog->Parameters = _mesa_new_parameter_list();
index a1a81165ab14df877e53b7fac145ccfe932732f8..aee9467ddb70685d788a05428a0d38fc4c287d15 100644 (file)
@@ -651,7 +651,7 @@ brw_stage_prog_data_free(const void *p)
 
 void
 brw_dump_ir(const char *stage, struct gl_shader_program *shader_prog,
-            struct gl_shader *shader, struct gl_program *prog)
+            struct gl_linked_shader *shader, struct gl_program *prog)
 {
    if (shader_prog) {
       if (shader->ir) {
index 4d6299f0c31b2fa187f125711a8a81053b100782..5874d93162370f06e68c2605889263ba2be4b3cc 100644 (file)
@@ -60,7 +60,7 @@ brw_stage_prog_data_free(const void *prog_data);
 
 void
 brw_dump_ir(const char *stage, struct gl_shader_program *shader_prog,
-            struct gl_shader *shader, struct gl_program *prog);
+            struct gl_linked_shader *shader, struct gl_program *prog);
 
 void brw_upload_tcs_prog(struct brw_context *brw,
                          uint64_t per_vertex_slots, uint32_t per_patch_slots);
index 5ce7b82bf5bf7ce3d056d35c528e912118230c19..f3b54870de7538b35e9ce57ffd61f979ac220a83 100644 (file)
@@ -1158,7 +1158,7 @@ brw_assign_common_binding_table_offsets(gl_shader_stage stage,
                                         struct brw_stage_prog_data *stage_prog_data,
                                         uint32_t next_binding_table_offset)
 {
-   const struct gl_shader *shader = NULL;
+   const struct gl_linked_shader *shader = NULL;
    int num_textures = _mesa_fls(prog->SamplersUsed);
 
    if (shader_prog)
@@ -1320,7 +1320,7 @@ brw_compile_tes(const struct brw_compiler *compiler,
                 char **error_str)
 {
    const struct brw_device_info *devinfo = compiler->devinfo;
-   struct gl_shader *shader =
+   struct gl_linked_shader *shader =
       shader_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL];
    const bool is_scalar = compiler->scalar_stage[MESA_SHADER_TESS_EVAL];
 
index d74c6d6af9ab596de41ec602fc9fc8d1e2e9b160..dd9eb2d8867d8f7467e01f4777e1830df0b813b6 100644 (file)
@@ -289,8 +289,7 @@ bool brw_cs_precompile(struct gl_context *ctx,
                        struct gl_program *prog);
 
 GLboolean brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog);
-struct gl_shader *brw_new_shader(struct gl_context *ctx, GLuint name,
-                                 gl_shader_stage stage);
+struct gl_linked_shader *brw_new_shader(gl_shader_stage stage);
 
 int type_size_scalar(const struct glsl_type *type);
 int type_size_vec4(const struct glsl_type *type);
index d488715cac342d5ac3ee40fcf6bcbeda1010cb49..3ba9f2c7d7431ce84e00f2b491c76559096bbe80 100644 (file)
@@ -197,7 +197,7 @@ brw_codegen_tcs_prog(struct brw_context *brw,
     * padding around uniform values below vec4 size, so the worst case is that
     * every uniform is a float which gets padded to the size of a vec4.
     */
-   struct gl_shader *tcs = shader_prog ?
+   struct gl_linked_shader *tcs = shader_prog ?
       shader_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL] : NULL;
    int param_count = nir->num_uniforms / 4;
 
index d7b3e69a269e0d14a82b9ca8584fccf339323a82..001655df872b111614bf85d920cd0628dff0e59a 100644 (file)
@@ -150,7 +150,8 @@ brw_codegen_tes_prog(struct brw_context *brw,
     * padding around uniform values below vec4 size, so the worst case is that
     * every uniform is a float which gets padded to the size of a vec4.
     */
-   struct gl_shader *tes = shader_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+   struct gl_linked_shader *tes =
+      shader_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL];
    int param_count = nir->num_uniforms / 4;
 
    prog_data.base.base.param =
index eed16acf31c8631b6bfdcbc6576eac28d6b1816c..c101e0596475af45a1c631fe55ff91313e46fc34 100644 (file)
@@ -946,7 +946,7 @@ const struct brw_tracked_state brw_cs_texture_surfaces = {
 
 void
 brw_upload_ubo_surfaces(struct brw_context *brw,
-                       struct gl_shader *shader,
+                       struct gl_linked_shader *shader,
                         struct brw_stage_state *stage_state,
                         struct brw_stage_prog_data *prog_data)
 {
@@ -1064,7 +1064,7 @@ const struct brw_tracked_state brw_cs_ubo_surfaces = {
 
 void
 brw_upload_abo_surfaces(struct brw_context *brw,
-                        struct gl_shader *shader,
+                        struct gl_linked_shader *shader,
                         struct brw_stage_state *stage_state,
                         struct brw_stage_prog_data *prog_data)
 {
@@ -1350,7 +1350,7 @@ update_image_surface(struct brw_context *brw,
 
 void
 brw_upload_image_surfaces(struct brw_context *brw,
-                          struct gl_shader *shader,
+                          struct gl_linked_shader *shader,
                           struct brw_stage_state *stage_state,
                           struct brw_stage_prog_data *prog_data)
 {
index 8efbf50c09234943a37dd0e36159d87f367f4f40..c0962241f840aa561ac98e6563817db3480a130e 100644 (file)
@@ -207,7 +207,8 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
       GLenum mode_before_gs = mode;
 
       if (tes) {
-         struct gl_shader *tes_sh = tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+         struct gl_linked_shader *tes_sh =
+            tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
          if (tes_sh->TessEval.PointMode)
             mode_before_gs = GL_POINTS;
          else if (tes_sh->TessEval.PrimitiveMode == GL_ISOLINES)
@@ -324,7 +325,8 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
       else if (ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL]) {
          struct gl_shader_program *tes =
             ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
-         struct gl_shader *tes_sh = tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+         struct gl_linked_shader *tes_sh =
+            tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
          if (tes_sh->TessEval.PointMode)
             pass = ctx->TransformFeedback.Mode == GL_POINTS;
          else if (tes_sh->TessEval.PrimitiveMode == GL_ISOLINES)
index f918bb6f7170b57203635933c2938f11674bf4e8..4891e2a3728ef21a70f6727830a4a0ba1f55fe7e 100644 (file)
@@ -783,8 +783,7 @@ struct dd_function_table {
     * \name GLSL-related functions (ARB extensions and OpenGL 2.x)
     */
    /*@{*/
-   struct gl_shader *(*NewShader)(struct gl_context *ctx,
-                                  GLuint name, gl_shader_stage stage);
+   struct gl_linked_shader *(*NewShader)(gl_shader_stage stage);
    void (*UseProgram)(struct gl_context *ctx, struct gl_shader_program *shProg);
    /*@}*/
 
index d0def7c5f7068b0459d24afb3a5a49b541020d94..f90d31ae7e952cd3d2cd90140f1cf514cc28579b 100644 (file)
@@ -1203,7 +1203,7 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
    _mesa_glsl_parse_state *state;
 
    p.mem_ctx = ralloc_context(NULL);
-   p.shader = ctx->Driver.NewShader(ctx, 0, MESA_SHADER_FRAGMENT);
+   p.shader = _mesa_new_shader(ctx, 0, MESA_SHADER_FRAGMENT);
    p.shader->ir = new(p.shader) exec_list;
    state = new(p.shader) _mesa_glsl_parse_state(ctx, MESA_SHADER_FRAGMENT,
                                                p.shader);
index 73ae55d83ebed71b84f47a56f3709e2b72b5842f..fdd445f68578c7affc42dc8ca17c8b8a37683f57 100644 (file)
@@ -2235,30 +2235,13 @@ struct gl_subroutine_function
 };
 
 /**
- * A GLSL vertex or fragment shader object.
+ * A linked GLSL shader object.
  */
-struct gl_shader
+struct gl_linked_shader
 {
-   /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB ||
-    *  GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER.
-    * Must be the first field.
-    */
-   GLenum Type;
    gl_shader_stage Stage;
-   GLuint Name;  /**< AKA the handle */
-   GLint RefCount;  /**< Reference count */
-   GLchar *Label;   /**< GL_KHR_debug */
-   GLboolean DeletePending;
-   GLboolean CompileStatus;
-   bool IsES;              /**< True if this shader uses GLSL ES */
-
-   GLuint SourceChecksum;       /**< for debug/logging purposes */
-   const GLchar *Source;  /**< Source code string */
 
    struct gl_program *Program;  /**< Post-compile assembly code */
-   GLchar *InfoLog;
-
-   unsigned Version;       /**< GLSL version used for linking */
 
    /**
     * \name Sampler tracking
@@ -2450,6 +2433,126 @@ struct gl_shader
    struct gl_subroutine_function *SubroutineFunctions;
 };
 
+/**
+ * A GLSL shader object.
+ */
+struct gl_shader
+{
+   /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB ||
+    *  GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER.
+    * Must be the first field.
+    */
+   GLenum Type;
+   gl_shader_stage Stage;
+   GLuint Name;  /**< AKA the handle */
+   GLint RefCount;  /**< Reference count */
+   GLchar *Label;   /**< GL_KHR_debug */
+   GLboolean DeletePending;
+   GLboolean CompileStatus;
+   bool IsES;              /**< True if this shader uses GLSL ES */
+
+   GLuint SourceChecksum;       /**< for debug/logging purposes */
+   const GLchar *Source;  /**< Source code string */
+
+   GLchar *InfoLog;
+
+   unsigned Version;       /**< GLSL version used for linking */
+
+   struct exec_list *ir;
+   struct glsl_symbol_table *symbols;
+
+   bool uses_builtin_functions;
+   bool uses_gl_fragcoord;
+   bool redeclares_gl_fragcoord;
+   bool ARB_fragment_coord_conventions_enable;
+
+   /**
+    * Fragment shader state from GLSL 1.50 layout qualifiers.
+    */
+   bool origin_upper_left;
+   bool pixel_center_integer;
+
+   struct {
+      /** Global xfb_stride out qualifier if any */
+      GLuint BufferStride[MAX_FEEDBACK_BUFFERS];
+   } TransformFeedback;
+
+   /**
+    * Tessellation Control shader state from layout qualifiers.
+    */
+   struct {
+      /**
+       * 0 - vertices not declared in shader, or
+       * 1 .. GL_MAX_PATCH_VERTICES
+       */
+      GLint VerticesOut;
+   } TessCtrl;
+
+   /**
+    * Tessellation Evaluation shader state from layout qualifiers.
+    */
+   struct {
+      /**
+       * GL_TRIANGLES, GL_QUADS, GL_ISOLINES or PRIM_UNKNOWN if it's not set
+       * in this shader.
+       */
+      GLenum PrimitiveMode;
+      /**
+       * GL_EQUAL, GL_FRACTIONAL_ODD, GL_FRACTIONAL_EVEN, or 0 if it's not set
+       * in this shader.
+       */
+      GLenum Spacing;
+      /**
+       * GL_CW, GL_CCW, or 0 if it's not set in this shader.
+       */
+      GLenum VertexOrder;
+      /**
+       * 1, 0, or -1 if it's not set in this shader.
+       */
+      int PointMode;
+   } TessEval;
+
+   /**
+    * Geometry shader state from GLSL 1.50 layout qualifiers.
+    */
+   struct {
+      GLint VerticesOut;
+      /**
+       * 0 - Invocations count not declared in shader, or
+       * 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS
+       */
+      GLint Invocations;
+      /**
+       * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or
+       * GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this
+       * shader.
+       */
+      GLenum InputType;
+       /**
+        * GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP, or PRIM_UNKNOWN if
+        * it's not set in this shader.
+        */
+      GLenum OutputType;
+   } Geom;
+
+   /**
+    * Whether early fragment tests are enabled as defined by
+    * ARB_shader_image_load_store.
+    */
+   bool EarlyFragmentTests;
+
+   /**
+    * Compute shader state from ARB_compute_shader layout qualifiers.
+    */
+   struct {
+      /**
+       * Size specified using local_size_{x,y,z}, or all 0's to indicate that
+       * it's not set in this shader.
+       */
+      unsigned LocalSize[3];
+   } Comp;
+};
+
 
 struct gl_uniform_buffer_variable
 {
@@ -2834,7 +2937,7 @@ struct gl_shader_program
     * \c MESA_SHADER_* defines.  Entries for non-existent stages will be
     * \c NULL.
     */
-   struct gl_shader *_LinkedShaders[MESA_SHADER_STAGES];
+   struct gl_linked_shader *_LinkedShaders[MESA_SHADER_STAGES];
 
    /** List of all active resources after linking. */
    struct gl_program_resource *ProgramResourceList;
index 5956ce4976d9aa75d7af1be5398a1d24b62aad4c..b5e1a44417fdb729162d963045d200518c98c1f3 100644 (file)
@@ -1264,7 +1264,7 @@ _mesa_program_resource_prop(struct gl_shader_program *shProg,
       return 1;
    case GL_COMPATIBLE_SUBROUTINES: {
       const struct gl_uniform_storage *uni;
-      struct gl_shader *sh;
+      struct gl_linked_shader *sh;
       unsigned count, i;
       int j;
 
index 142e75089df90f6c1c88daaca3983563648c6e51..962b42e62ae3fa61bae88836b266597310d5f617 100644 (file)
@@ -2175,7 +2175,8 @@ _mesa_copy_linked_program_data(gl_shader_stage type,
    case MESA_SHADER_TESS_EVAL: {
       struct gl_tess_eval_program *dst_tep =
          (struct gl_tess_eval_program *) dst;
-      struct gl_shader *tes_sh = src->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+      struct gl_linked_shader *tes_sh =
+         src->_LinkedShaders[MESA_SHADER_TESS_EVAL];
 
       dst_tep->PrimitiveMode = tes_sh->TessEval.PrimitiveMode;
       dst_tep->Spacing = tes_sh->TessEval.Spacing;
@@ -2187,7 +2188,8 @@ _mesa_copy_linked_program_data(gl_shader_stage type,
    }
    case MESA_SHADER_GEOMETRY: {
       struct gl_geometry_program *dst_gp = (struct gl_geometry_program *) dst;
-      struct gl_shader *geom_sh = src->_LinkedShaders[MESA_SHADER_GEOMETRY];
+      struct gl_linked_shader *geom_sh =
+         src->_LinkedShaders[MESA_SHADER_GEOMETRY];
 
       dst_gp->VerticesIn = src->Geom.VerticesIn;
       dst_gp->VerticesOut = geom_sh->Geom.VerticesOut;
@@ -2420,7 +2422,7 @@ _mesa_GetActiveSubroutineUniformiv(GLuint program, GLenum shadertype,
    GET_CURRENT_CONTEXT(ctx);
    const char *api_name = "glGetActiveSubroutineUniformiv";
    struct gl_shader_program *shProg;
-   struct gl_shader *sh;
+   struct gl_linked_shader *sh;
    gl_shader_stage stage;
    struct gl_program_resource *res;
    const struct gl_uniform_storage *uni;
@@ -2585,7 +2587,7 @@ _mesa_UniformSubroutinesuiv(GLenum shadertype, GLsizei count,
    GET_CURRENT_CONTEXT(ctx);
    const char *api_name = "glUniformSubroutinesuiv";
    struct gl_shader_program *shProg;
-   struct gl_shader *sh;
+   struct gl_linked_shader *sh;
    gl_shader_stage stage;
    int i;
 
@@ -2683,7 +2685,7 @@ _mesa_GetUniformSubroutineuiv(GLenum shadertype, GLint location,
    GET_CURRENT_CONTEXT(ctx);
    const char *api_name = "glGetUniformSubroutineuiv";
    struct gl_shader_program *shProg;
-   struct gl_shader *sh;
+   struct gl_linked_shader *sh;
    gl_shader_stage stage;
 
    if (!_mesa_has_shader_subroutine(ctx)) {
@@ -2730,7 +2732,7 @@ _mesa_GetProgramStageiv(GLuint program, GLenum shadertype,
    GET_CURRENT_CONTEXT(ctx);
    const char *api_name = "glGetProgramStageiv";
    struct gl_shader_program *shProg;
-   struct gl_shader *sh;
+   struct gl_linked_shader *sh;
    gl_shader_stage stage;
 
    if (!_mesa_has_shader_subroutine(ctx)) {
@@ -2812,7 +2814,8 @@ _mesa_GetProgramStageiv(GLuint program, GLenum shadertype,
 }
 
 static int
-find_compat_subroutine(struct gl_shader *sh, const struct glsl_type *type)
+find_compat_subroutine(struct gl_linked_shader *sh,
+                       const struct glsl_type *type)
 {
    int i, j;
 
@@ -2827,7 +2830,7 @@ find_compat_subroutine(struct gl_shader *sh, const struct glsl_type *type)
 }
 
 static void
-_mesa_shader_init_subroutine_defaults(struct gl_shader *sh)
+_mesa_shader_init_subroutine_defaults(struct gl_linked_shader *sh)
 {
    int i, j;
 
index f3d5c2ee5badc1df2974137a4d0e0ac151005e18..93fdc669f2f6d0db9829806a03a41c31b9179f2a 100644 (file)
@@ -99,7 +99,6 @@ _mesa_init_shader(struct gl_context *ctx, struct gl_shader *shader)
 
 /**
  * Allocate a new gl_shader object, initialize it.
- * Called via ctx->Driver.NewShader()
  */
 struct gl_shader *
 _mesa_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage)
@@ -115,6 +114,22 @@ _mesa_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage)
 }
 
 
+/**
+ * Allocate a new gl_linked_shader object.
+ * Called via ctx->Driver.NewShader()
+ */
+struct gl_linked_shader *
+_mesa_new_linked_shader(gl_shader_stage stage)
+{
+   struct gl_linked_shader *shader;
+   shader = rzalloc(NULL, struct gl_linked_shader);
+   if (shader) {
+      shader->Stage = stage;
+   }
+   return shader;
+}
+
+
 /**
  * Delete a shader object.
  */
@@ -123,6 +138,17 @@ _mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh)
 {
    free((void *)sh->Source);
    free(sh->Label);
+   ralloc_free(sh);
+}
+
+
+/**
+ * Delete a shader object.
+ */
+void
+_mesa_delete_linked_shader(struct gl_context *ctx,
+                           struct gl_linked_shader *sh)
+{
    _mesa_reference_program(ctx, &sh->Program, NULL);
    ralloc_free(sh);
 }
@@ -360,7 +386,7 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
 
    for (sh = 0; sh < MESA_SHADER_STAGES; sh++) {
       if (shProg->_LinkedShaders[sh] != NULL) {
-        _mesa_delete_shader(ctx, shProg->_LinkedShaders[sh]);
+        _mesa_delete_linked_shader(ctx, shProg->_LinkedShaders[sh]);
         shProg->_LinkedShaders[sh] = NULL;
       }
    }
@@ -436,6 +462,6 @@ _mesa_lookup_shader_program_err(struct gl_context *ctx, GLuint name,
 void
 _mesa_init_shader_object_functions(struct dd_function_table *driver)
 {
-   driver->NewShader = _mesa_new_shader;
+   driver->NewShader = _mesa_new_linked_shader;
    driver->LinkShader = _mesa_ir_link_shader;
 }
index 3abd597a58c053f17760f0cc36e53ace256fc03f..f331db11664839f0e4d13496d05af76189715125 100644 (file)
@@ -82,9 +82,16 @@ _mesa_init_shader(struct gl_context *ctx, struct gl_shader *shader);
 extern struct gl_shader *
 _mesa_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage type);
 
+extern struct gl_linked_shader *
+_mesa_new_linked_shader(gl_shader_stage type);
+
 extern void
 _mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh);
 
+extern void
+_mesa_delete_linked_shader(struct gl_context *ctx,
+                           struct gl_linked_shader *sh);
+
 extern struct gl_shader_program *
 _mesa_lookup_shader_program(struct gl_context *ctx, GLuint name);
 
index 127f097fe1f45430a8823463ca802898411a1b51..67375a17f48f8e382ec3d4595a49e836dc2f315a 100644 (file)
@@ -824,7 +824,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
    if (uni->type->is_sampler()) {
       bool flushed = false;
       for (int i = 0; i < MESA_SHADER_STAGES; i++) {
-        struct gl_shader *const sh = shProg->_LinkedShaders[i];
+        struct gl_linked_shader *const sh = shProg->_LinkedShaders[i];
 
         /* If the shader stage doesn't use the sampler uniform, skip this.
          */
@@ -876,7 +876,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
    if (uni->type->is_image()) {
       for (int i = 0; i < MESA_SHADER_STAGES; i++) {
         if (uni->opaque[i].active) {
-            struct gl_shader *sh = shProg->_LinkedShaders[i];
+            struct gl_linked_shader *sh = shProg->_LinkedShaders[i];
 
             for (int j = 0; j < count; j++)
                sh->ImageUnits[uni->opaque[i].index + offset + j] =
index d02f92ee0a591d9420c78142f994c20b0727a066..3921644892c33aaf8c6ea51b816b25ec035d51ef 100644 (file)
@@ -68,7 +68,7 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg,
                                  struct gl_program *prog)
 {
    GLbitfield mask = prog->SamplersUsed;
-   struct gl_shader *shader =
+   struct gl_linked_shader *shader =
       shProg->_LinkedShaders[_mesa_program_enum_to_shader_stage(prog->Target)];
 
    assert(shader);
index cf47c0d9348077c699a800734d73079cdf27b721..e74d94f84f7a35baa3dbd889c43f2ee5776771b4 100644 (file)
@@ -2469,7 +2469,7 @@ add_uniform_to_shader::visit_field(const glsl_type *type, const char *name,
 void
 _mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
                                            *shader_program,
-                                           struct gl_shader *sh,
+                                           struct gl_linked_shader *sh,
                                            struct gl_program_parameter_list
                                            *params)
 {
@@ -2779,7 +2779,7 @@ ir_to_mesa_visitor::copy_propagate(void)
 static struct gl_program *
 get_mesa_program(struct gl_context *ctx,
                  struct gl_shader_program *shader_program,
-                struct gl_shader *shader)
+                struct gl_linked_shader *shader)
 {
    ir_to_mesa_visitor v;
    struct prog_instruction *mesa_instructions, *mesa_inst;
index a70f575bb5c4583251c58100d9ca97cf56ff531b..be45ba0ebca9be3171b6c96779780bbefb1bb9ca 100644 (file)
@@ -39,7 +39,7 @@ GLboolean _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program
 void
 _mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
                                            *shader_program,
-                                           struct gl_shader *sh,
+                                           struct gl_linked_shader *sh,
                                            struct gl_program_parameter_list
                                            *params);
 void
index 570b2f5800ad34177b3886304c4d6781421aa6d8..b8d7cca2f3b46066262b43f820515e905c688a47 100644 (file)
@@ -1005,7 +1005,7 @@ _mesa_write_shader_to_file(const struct gl_shader *shader)
  * _mesa_write_shader_to_file function.
  */
 void
-_mesa_append_uniforms_to_file(const struct gl_shader *shader)
+_mesa_append_uniforms_to_file(const struct gl_linked_shader *shader)
 {
    const struct gl_program *const prog = shader->Program;
    const char *type;
index 9058dfa7688645083f9f161e468fb19b9fa3b378..7b1e1fe3b18e696127a18aa954396c71fbea04be 100644 (file)
@@ -118,7 +118,7 @@ extern void
 _mesa_write_shader_to_file(const struct gl_shader *shader);
 
 extern void
-_mesa_append_uniforms_to_file(const struct gl_shader *shader);
+_mesa_append_uniforms_to_file(const struct gl_linked_shader *shader);
 
 
 #ifdef __cplusplus
index a980dbedac5264eac1f394866fa640379b294c95..594db1e9f12566468d470e75a3194935b686a693 100644 (file)
@@ -265,7 +265,7 @@ const struct st_tracked_state st_update_cs_constants = {
 };
 
 static void st_bind_ubos(struct st_context *st,
-                           struct gl_shader *shader,
+                           struct gl_linked_shader *shader,
                            unsigned shader_type)
 {
    unsigned i;
index f8a0044c24215f9d333c7f44b13d892de90f0353..bc9344e51b205c9e06e0923dfc35148cff457f71 100644 (file)
@@ -45,7 +45,7 @@
 #include "st_format.h"
 
 static void
-st_bind_images(struct st_context *st, struct gl_shader *shader,
+st_bind_images(struct st_context *st, struct gl_linked_shader *shader,
               unsigned shader_type)
 {
    unsigned i;
index 37b4c4d256d385d4a9a687984e1c44c0baabbb7e..0f96e6d79b30c6d5eb33acaa35c6d4a7118c1a5f 100644 (file)
@@ -41,7 +41,7 @@
 #include "st_program.h"
 
 static void
-st_bind_ssbos(struct st_context *st, struct gl_shader *shader,
+st_bind_ssbos(struct st_context *st, struct gl_linked_shader *shader,
               unsigned shader_type)
 {
    unsigned i;
index a8805645b6ee0c79b8bb9ad454edc66b5dd76122..52470a0021abdbd382c9d722646fd50f67c2bd7e 100644 (file)
@@ -347,7 +347,7 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog, nir_shader *nir)
 struct gl_program *
 st_nir_get_mesa_program(struct gl_context *ctx,
                         struct gl_shader_program *shader_program,
-                        struct gl_shader *shader)
+                        struct gl_linked_shader *shader)
 {
    struct gl_program *prog;
    GLenum target = _mesa_shader_stage_to_program(shader->Stage);
index 07ec91a7e4fe93e92c90221720b03339882bb64a..931515324a30feb4bd25a00dd5c89a5d906abfdd 100644 (file)
@@ -376,7 +376,7 @@ public:
    struct gl_context *ctx;
    struct gl_program *prog;
    struct gl_shader_program *shader_program;
-   struct gl_shader *shader;
+   struct gl_linked_shader *shader;
    struct gl_shader_compiler_options *options;
 
    int next_temp;
@@ -6452,7 +6452,7 @@ out:
 static struct gl_program *
 get_mesa_program_tgsi(struct gl_context *ctx,
                       struct gl_shader_program *shader_program,
-                      struct gl_shader *shader)
+                      struct gl_linked_shader *shader)
 {
    glsl_to_tgsi_visitor* v;
    struct gl_program *prog;
@@ -6663,7 +6663,7 @@ get_mesa_program_tgsi(struct gl_context *ctx,
 static struct gl_program *
 get_mesa_program(struct gl_context *ctx,
                  struct gl_shader_program *shader_program,
-                 struct gl_shader *shader)
+                 struct gl_linked_shader *shader)
 {
    struct pipe_screen *pscreen = ctx->st->pipe->screen;
    unsigned ptarget = st_shader_stage_to_ptarget(shader->Stage);
index 49ba573df2d94ee0b8d69339b629e496a546188a..19e2d2d97ff5cb7b0a3f1a9e8d9186a4229a5da3 100644 (file)
@@ -43,7 +43,7 @@ void st_finalize_nir(struct st_context *st, struct gl_program *prog, nir_shader
 struct gl_program *
 st_nir_get_mesa_program(struct gl_context *ctx,
                         struct gl_shader_program *shader_program,
-                        struct gl_shader *shader);
+                        struct gl_linked_shader *shader);
 
 #ifdef __cplusplus
 }
index f2b5537992306809da8208278a1e10548be772c7..57b093544871b8c2ce4737ee729a32d9e677f689 100644 (file)
@@ -1756,10 +1756,6 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData)
          struct gl_shader_program *shProg = (struct gl_shader_program *) data;
          GLuint i;
 
-         for (i = 0; i < shProg->NumShaders; i++) {
-            destroy_program_variants(st, shProg->Shaders[i]->Program);
-         }
-
         for (i = 0; i < ARRAY_SIZE(shProg->_LinkedShaders); i++) {
            if (shProg->_LinkedShaders[i])
                destroy_program_variants(st, shProg->_LinkedShaders[i]->Program);
@@ -1772,9 +1768,6 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData)
    case GL_TESS_CONTROL_SHADER:
    case GL_TESS_EVALUATION_SHADER:
    case GL_COMPUTE_SHADER:
-      {
-         destroy_program_variants(st, shader->Program);
-      }
       break;
    default:
       assert(0);