diff options
Diffstat (limited to 'mesalib/src')
41 files changed, 198 insertions, 98 deletions
diff --git a/mesalib/src/glsl/builtin_functions.cpp b/mesalib/src/glsl/builtin_functions.cpp index 96358a737..72054e0fe 100644 --- a/mesalib/src/glsl/builtin_functions.cpp +++ b/mesalib/src/glsl/builtin_functions.cpp @@ -304,6 +304,8 @@ tex3d_lod(const _mesa_glsl_parse_state *state) /******************************************************************************/ +namespace { + /** * builtin_builder: A singleton object representing the core of the built-in * function module. @@ -521,6 +523,8 @@ private: /** @} */ }; +} /* anonymous namespace */ + /** * Core builtin_builder functionality: * @{ diff --git a/mesalib/src/glsl/ir_function_detect_recursion.cpp b/mesalib/src/glsl/ir_function_detect_recursion.cpp index b02c32518..5813315b6 100644 --- a/mesalib/src/glsl/ir_function_detect_recursion.cpp +++ b/mesalib/src/glsl/ir_function_detect_recursion.cpp @@ -127,6 +127,8 @@ #include "program/hash_table.h" #include "program.h" +namespace { + struct call_node : public exec_node { class function *func; }; @@ -222,6 +224,8 @@ public: bool progress; }; +} /* anonymous namespace */ + static void destroy_links(exec_list *list, function *f) { diff --git a/mesalib/src/glsl/ir_import_prototypes.cpp b/mesalib/src/glsl/ir_import_prototypes.cpp index 3585bf6b2..b0429fbc3 100644 --- a/mesalib/src/glsl/ir_import_prototypes.cpp +++ b/mesalib/src/glsl/ir_import_prototypes.cpp @@ -30,6 +30,8 @@ #include "ir.h" #include "glsl_symbol_table.h" +namespace { + /** * Visitor used to import function prototypes * @@ -99,6 +101,7 @@ private: void *mem_ctx; }; +} /* anonymous namespace */ /** * Import function prototypes from one IR tree into another diff --git a/mesalib/src/glsl/ir_reader.cpp b/mesalib/src/glsl/ir_reader.cpp index ec35b682e..f0318ea21 100644 --- a/mesalib/src/glsl/ir_reader.cpp +++ b/mesalib/src/glsl/ir_reader.cpp @@ -28,6 +28,8 @@ const static bool debug = false; +namespace { + class ir_reader { public: ir_reader(_mesa_glsl_parse_state *); @@ -66,6 +68,8 @@ private: ir_dereference_variable *read_var_ref(s_expression *); }; +} /* anonymous namespace */ + ir_reader::ir_reader(_mesa_glsl_parse_state *state) : state(state) { this->mem_ctx = state; diff --git a/mesalib/src/glsl/ir_set_program_inouts.cpp b/mesalib/src/glsl/ir_set_program_inouts.cpp index 6196d6a64..1267d6d71 100644 --- a/mesalib/src/glsl/ir_set_program_inouts.cpp +++ b/mesalib/src/glsl/ir_set_program_inouts.cpp @@ -42,6 +42,8 @@ #include "ir_visitor.h" #include "glsl_types.h" +namespace { + class ir_set_program_inouts_visitor : public ir_hierarchical_visitor { public: ir_set_program_inouts_visitor(struct gl_program *prog, GLenum shader_type) @@ -67,6 +69,8 @@ private: GLenum shader_type; }; +} /* anonymous namespace */ + static inline bool is_shader_inout(ir_variable *var) { diff --git a/mesalib/src/glsl/ir_validate.cpp b/mesalib/src/glsl/ir_validate.cpp index 2068de06a..2c64f4e58 100644 --- a/mesalib/src/glsl/ir_validate.cpp +++ b/mesalib/src/glsl/ir_validate.cpp @@ -38,6 +38,8 @@ #include "program/hash_table.h" #include "glsl_types.h" +namespace { + class ir_validate : public ir_hierarchical_visitor { public: ir_validate() @@ -81,6 +83,7 @@ public: struct hash_table *ht; }; +} /* anonymous namespace */ ir_visitor_status ir_validate::visit(ir_dereference_variable *ir) diff --git a/mesalib/src/glsl/link_functions.cpp b/mesalib/src/glsl/link_functions.cpp index 9e96365e6..b1a68fd55 100644 --- a/mesalib/src/glsl/link_functions.cpp +++ b/mesalib/src/glsl/link_functions.cpp @@ -34,6 +34,8 @@ find_matching_signature(const char *name, const exec_list *actual_parameters, gl_shader **shader_list, unsigned num_shaders, bool use_builtin); +namespace { + class call_link_visitor : public ir_hierarchical_visitor { public: call_link_visitor(gl_shader_program *prog, gl_shader *linked, @@ -273,6 +275,7 @@ private: hash_table *locals; }; +} /* anonymous namespace */ /** * Searches a list of shaders for a particular function definition diff --git a/mesalib/src/glsl/link_uniform_blocks.cpp b/mesalib/src/glsl/link_uniform_blocks.cpp index d96075849..72d6c5323 100644 --- a/mesalib/src/glsl/link_uniform_blocks.cpp +++ b/mesalib/src/glsl/link_uniform_blocks.cpp @@ -29,6 +29,8 @@ #include "main/hash_table.h" #include "program.h" +namespace { + class ubo_visitor : public program_resource_visitor { public: ubo_visitor(void *mem_ctx, gl_uniform_buffer_variable *variables, @@ -147,6 +149,8 @@ private: } }; +} /* anonymous namespace */ + struct block { const glsl_type *type; bool has_instance_name; diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp index 39e85ce61..a466348c4 100644 --- a/mesalib/src/glsl/link_uniforms.cpp +++ b/mesalib/src/glsl/link_uniforms.cpp @@ -168,6 +168,8 @@ program_resource_visitor::visit_field(const glsl_struct_field *field) /* empty */ } +namespace { + /** * Class to help calculate the storage requirements for a set of uniforms * @@ -272,6 +274,8 @@ private: struct string_to_uint_map *map; }; +} /* anonymous namespace */ + /** * Class to help parcel out pieces of backing storage to uniforms * diff --git a/mesalib/src/glsl/link_varyings.cpp b/mesalib/src/glsl/link_varyings.cpp index 081a51da5..905621daf 100644 --- a/mesalib/src/glsl/link_varyings.cpp +++ b/mesalib/src/glsl/link_varyings.cpp @@ -597,6 +597,7 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog, return true; } +namespace { /** * Data structure recording the relationship between outputs of one shader @@ -689,6 +690,7 @@ private: const bool consumer_is_fs; }; +} /* anonymous namespace */ varying_matches::varying_matches(bool disable_varying_packing, bool consumer_is_fs) diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp index 8a143fddf..c54b7049b 100644 --- a/mesalib/src/glsl/linker.cpp +++ b/mesalib/src/glsl/linker.cpp @@ -82,6 +82,8 @@ extern "C" { void linker_error(gl_shader_program *, const char *, ...); +namespace { + /** * Visitor that determines whether or not a variable is ever written. */ @@ -275,6 +277,7 @@ private: bool found; }; +} /* anonymous namespace */ void linker_error(gl_shader_program *prog, const char *fmt, ...) diff --git a/mesalib/src/glsl/loop_analysis.cpp b/mesalib/src/glsl/loop_analysis.cpp index 40897bb6f..b08241af5 100644 --- a/mesalib/src/glsl/loop_analysis.cpp +++ b/mesalib/src/glsl/loop_analysis.cpp @@ -102,6 +102,7 @@ loop_variable_state::insert(ir_if *if_stmt) return t; } +namespace { class loop_analysis : public ir_hierarchical_visitor { public: @@ -128,6 +129,7 @@ public: exec_list state; }; +} /* anonymous namespace */ loop_analysis::loop_analysis(loop_state *loops) : loops(loops), if_statement_depth(0), current_assignment(NULL) diff --git a/mesalib/src/glsl/loop_controls.cpp b/mesalib/src/glsl/loop_controls.cpp index 79c820436..26481930d 100644 --- a/mesalib/src/glsl/loop_controls.cpp +++ b/mesalib/src/glsl/loop_controls.cpp @@ -151,6 +151,7 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment, return (valid_loop) ? iter_value : -1; } +namespace { class loop_control_visitor : public ir_hierarchical_visitor { public: @@ -167,6 +168,7 @@ public: bool progress; }; +} /* anonymous namespace */ ir_visitor_status loop_control_visitor::visit_leave(ir_loop *ir) diff --git a/mesalib/src/glsl/loop_unroll.cpp b/mesalib/src/glsl/loop_unroll.cpp index 3434fde62..ff97766f1 100644 --- a/mesalib/src/glsl/loop_unroll.cpp +++ b/mesalib/src/glsl/loop_unroll.cpp @@ -25,6 +25,8 @@ #include "loop_analysis.h" #include "ir_hierarchical_visitor.h" +namespace { + class loop_unroll_visitor : public ir_hierarchical_visitor { public: loop_unroll_visitor(loop_state *state, unsigned max_iterations) @@ -42,6 +44,7 @@ public: unsigned max_iterations; }; +} /* anonymous namespace */ static bool is_break(ir_instruction *ir) diff --git a/mesalib/src/glsl/lower_clip_distance.cpp b/mesalib/src/glsl/lower_clip_distance.cpp index d6cf94438..9ddd64603 100644 --- a/mesalib/src/glsl/lower_clip_distance.cpp +++ b/mesalib/src/glsl/lower_clip_distance.cpp @@ -50,6 +50,8 @@ #include "ir.h" #include "program/prog_instruction.h" /* For WRITEMASK_* */ +namespace { + class lower_clip_distance_visitor : public ir_rvalue_visitor { public: lower_clip_distance_visitor() @@ -81,6 +83,7 @@ public: ir_variable *new_clip_distance_var; }; +} /* anonymous namespace */ /** * Replace any declaration of gl_ClipDistance as an array of floats with a diff --git a/mesalib/src/glsl/lower_discard.cpp b/mesalib/src/glsl/lower_discard.cpp index cafd2dd3b..f2757d120 100644 --- a/mesalib/src/glsl/lower_discard.cpp +++ b/mesalib/src/glsl/lower_discard.cpp @@ -108,6 +108,8 @@ #include "glsl_types.h" #include "ir.h" +namespace { + class lower_discard_visitor : public ir_hierarchical_visitor { public: lower_discard_visitor() @@ -120,6 +122,7 @@ public: bool progress; }; +} /* anonymous namespace */ bool lower_discard(exec_list *instructions) diff --git a/mesalib/src/glsl/lower_discard_flow.cpp b/mesalib/src/glsl/lower_discard_flow.cpp index d385c1435..1bc56d79e 100644 --- a/mesalib/src/glsl/lower_discard_flow.cpp +++ b/mesalib/src/glsl/lower_discard_flow.cpp @@ -48,6 +48,8 @@ #include "ir.h" #include "program/hash_table.h" +namespace { + class lower_discard_flow_visitor : public ir_hierarchical_visitor { public: lower_discard_flow_visitor(ir_variable *discarded) @@ -71,6 +73,8 @@ public: void *mem_ctx; }; +} /* anonymous namespace */ + ir_visitor_status lower_discard_flow_visitor::visit_enter(ir_loop_jump *ir) { diff --git a/mesalib/src/glsl/lower_if_to_cond_assign.cpp b/mesalib/src/glsl/lower_if_to_cond_assign.cpp index 2c5d5612d..1e7ce51c7 100644 --- a/mesalib/src/glsl/lower_if_to_cond_assign.cpp +++ b/mesalib/src/glsl/lower_if_to_cond_assign.cpp @@ -49,6 +49,8 @@ #include "ir.h" #include "program/hash_table.h" +namespace { + class ir_if_to_cond_assign_visitor : public ir_hierarchical_visitor { public: ir_if_to_cond_assign_visitor(unsigned max_depth) @@ -76,6 +78,8 @@ public: struct hash_table *condition_variables; }; +} /* anonymous namespace */ + bool lower_if_to_cond_assign(exec_list *instructions, unsigned max_depth) { diff --git a/mesalib/src/glsl/lower_instructions.cpp b/mesalib/src/glsl/lower_instructions.cpp index cb5304895..d01879cbd 100644 --- a/mesalib/src/glsl/lower_instructions.cpp +++ b/mesalib/src/glsl/lower_instructions.cpp @@ -109,6 +109,8 @@ using namespace ir_builder; +namespace { + class lower_instructions_visitor : public ir_hierarchical_visitor { public: lower_instructions_visitor(unsigned lower) @@ -133,6 +135,8 @@ private: void ldexp_to_arith(ir_expression *); }; +} /* anonymous namespace */ + /** * Determine if a particular type of lowering should occur */ diff --git a/mesalib/src/glsl/lower_jumps.cpp b/mesalib/src/glsl/lower_jumps.cpp index bfc8c013b..02f65f097 100644 --- a/mesalib/src/glsl/lower_jumps.cpp +++ b/mesalib/src/glsl/lower_jumps.cpp @@ -133,6 +133,8 @@ enum jump_strength strength_return }; +namespace { + struct block_record { /* minimum jump strength (of lowered IR, not pre-lowering IR) @@ -279,8 +281,13 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor { bool lower_main_return; ir_lower_jumps_visitor() + : progress(false), + pull_out_jumps(false), + lower_continue(false), + lower_break(false), + lower_sub_return(false), + lower_main_return(false) { - this->progress = false; } void truncate_after_instruction(exec_node *ir) @@ -992,6 +999,8 @@ lower_continue: } }; +} /* anonymous namespace */ + bool do_lower_jumps(exec_list *instructions, bool pull_out_jumps, bool lower_sub_return, bool lower_main_return, bool lower_continue, bool lower_break) { diff --git a/mesalib/src/glsl/lower_mat_op_to_vec.cpp b/mesalib/src/glsl/lower_mat_op_to_vec.cpp index 08cae29fa..105ee0d3f 100644 --- a/mesalib/src/glsl/lower_mat_op_to_vec.cpp +++ b/mesalib/src/glsl/lower_mat_op_to_vec.cpp @@ -35,6 +35,8 @@ #include "ir_expression_flattening.h" #include "glsl_types.h" +namespace { + class ir_mat_op_to_vec_visitor : public ir_hierarchical_visitor { public: ir_mat_op_to_vec_visitor() @@ -63,6 +65,8 @@ public: bool made_progress; }; +} /* anonymous namespace */ + static bool mat_op_to_vec_predicate(ir_instruction *ir) { diff --git a/mesalib/src/glsl/lower_named_interface_blocks.cpp b/mesalib/src/glsl/lower_named_interface_blocks.cpp index 20196a356..7019185a2 100644 --- a/mesalib/src/glsl/lower_named_interface_blocks.cpp +++ b/mesalib/src/glsl/lower_named_interface_blocks.cpp @@ -65,6 +65,8 @@ #include "ir_rvalue_visitor.h" #include "program/hash_table.h" +namespace { + class flatten_named_interface_blocks_declarations : public ir_rvalue_visitor { public: @@ -83,6 +85,8 @@ public: virtual void handle_rvalue(ir_rvalue **rvalue); }; +} /* anonymous namespace */ + void flatten_named_interface_blocks_declarations::run(exec_list *instructions) { diff --git a/mesalib/src/glsl/lower_output_reads.cpp b/mesalib/src/glsl/lower_output_reads.cpp index 5ba9720d0..128b0b8cd 100644 --- a/mesalib/src/glsl/lower_output_reads.cpp +++ b/mesalib/src/glsl/lower_output_reads.cpp @@ -37,6 +37,8 @@ * main() function to copy the final values to the actual shader outputs. */ +namespace { + class output_read_remover : public ir_hierarchical_visitor { protected: /** @@ -55,6 +57,8 @@ public: virtual ir_visitor_status visit_leave(class ir_function_signature *); }; +} /* anonymous namespace */ + /** * Hash function for the output variables - computes the hash of the name. * NOTE: We're using the name string to ensure that the hash doesn't depend diff --git a/mesalib/src/glsl/lower_packed_varyings.cpp b/mesalib/src/glsl/lower_packed_varyings.cpp index 4f617225c..2bcadfd55 100644 --- a/mesalib/src/glsl/lower_packed_varyings.cpp +++ b/mesalib/src/glsl/lower_packed_varyings.cpp @@ -148,6 +148,8 @@ #include "ir.h" #include "ir_optimization.h" +namespace { + /** * Visitor that performs varying packing. For each varying declared in the * shader, this visitor determines whether it needs to be packed. If so, it @@ -230,6 +232,8 @@ private: exec_list *out_instructions; }; +} /* anonymous namespace */ + lower_packed_varyings_visitor::lower_packed_varyings_visitor( void *mem_ctx, unsigned location_base, unsigned locations_used, ir_variable_mode mode, unsigned gs_input_vertices, diff --git a/mesalib/src/glsl/lower_texture_projection.cpp b/mesalib/src/glsl/lower_texture_projection.cpp index 6e3aaecce..16d637680 100644 --- a/mesalib/src/glsl/lower_texture_projection.cpp +++ b/mesalib/src/glsl/lower_texture_projection.cpp @@ -37,6 +37,8 @@ #include "ir.h" +namespace { + class lower_texture_projection_visitor : public ir_hierarchical_visitor { public: lower_texture_projection_visitor() @@ -49,6 +51,8 @@ public: bool progress; }; +} /* anonymous namespace */ + ir_visitor_status lower_texture_projection_visitor::visit_leave(ir_texture *ir) { diff --git a/mesalib/src/glsl/lower_variable_index_to_cond_assign.cpp b/mesalib/src/glsl/lower_variable_index_to_cond_assign.cpp index 0f5072793..699fb3903 100644 --- a/mesalib/src/glsl/lower_variable_index_to_cond_assign.cpp +++ b/mesalib/src/glsl/lower_variable_index_to_cond_assign.cpp @@ -122,6 +122,7 @@ is_array_or_matrix(const ir_rvalue *ir) return (ir->type->is_array() || ir->type->is_matrix()); } +namespace { /** * Replace a dereference of a variable with a specified r-value * @@ -191,6 +192,12 @@ struct assignment_generator ir_variable* var; assignment_generator() + : base_ir(NULL), + rvalue(NULL), + old_index(NULL), + is_write(false), + write_mask(0), + var(NULL) { } @@ -512,6 +519,8 @@ public: } }; +} /* anonymous namespace */ + bool lower_variable_index_to_cond_assign(exec_list *instructions, bool lower_input, diff --git a/mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp b/mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp index 880859688..8080006c1 100644 --- a/mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp +++ b/mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp @@ -41,6 +41,8 @@ #include "ir_optimization.h" #include "glsl_types.h" +namespace { + /** * Visitor class for replacing expressions with ir_constant values. */ @@ -69,6 +71,8 @@ public: bool progress; }; +} /* anonymous namespace */ + ir_rvalue * ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(void *mem_ctx, ir_rvalue *orig_vector, diff --git a/mesalib/src/glsl/lower_vec_index_to_swizzle.cpp b/mesalib/src/glsl/lower_vec_index_to_swizzle.cpp index d5ad692c2..46985791e 100644 --- a/mesalib/src/glsl/lower_vec_index_to_swizzle.cpp +++ b/mesalib/src/glsl/lower_vec_index_to_swizzle.cpp @@ -39,6 +39,8 @@ * Visitor class for replacing expressions with ir_constant values. */ +namespace { + class ir_vec_index_to_swizzle_visitor : public ir_hierarchical_visitor { public: ir_vec_index_to_swizzle_visitor() @@ -58,6 +60,8 @@ public: bool progress; }; +} /* anonymous namespace */ + ir_rvalue * ir_vec_index_to_swizzle_visitor::convert_vector_extract_to_swizzle(ir_rvalue *ir) { diff --git a/mesalib/src/glsl/lower_vector.cpp b/mesalib/src/glsl/lower_vector.cpp index 0cd6909db..a658410ae 100644 --- a/mesalib/src/glsl/lower_vector.cpp +++ b/mesalib/src/glsl/lower_vector.cpp @@ -31,9 +31,11 @@ #include "ir.h" #include "ir_rvalue_visitor.h" +namespace { + class lower_vector_visitor : public ir_rvalue_visitor { public: - lower_vector_visitor() : progress(false) + lower_vector_visitor() : dont_lower_swz(false), progress(false) { /* empty */ } @@ -48,6 +50,8 @@ public: bool progress; }; +} /* anonymous namespace */ + /** * Determine if an IR expression tree looks like an extended swizzle * diff --git a/mesalib/src/glsl/lower_vector_insert.cpp b/mesalib/src/glsl/lower_vector_insert.cpp index 0e640cc32..6d7cfa942 100644 --- a/mesalib/src/glsl/lower_vector_insert.cpp +++ b/mesalib/src/glsl/lower_vector_insert.cpp @@ -27,6 +27,8 @@ using namespace ir_builder; +namespace { + class vector_insert_visitor : public ir_rvalue_visitor { public: vector_insert_visitor(bool lower_nonconstant_index) @@ -48,6 +50,7 @@ public: bool lower_nonconstant_index; }; +} /* anonymous namespace */ void vector_insert_visitor::handle_rvalue(ir_rvalue **rv) diff --git a/mesalib/src/glsl/opt_array_splitting.cpp b/mesalib/src/glsl/opt_array_splitting.cpp index f4a7ef99b..34ac836ae 100644 --- a/mesalib/src/glsl/opt_array_splitting.cpp +++ b/mesalib/src/glsl/opt_array_splitting.cpp @@ -40,6 +40,8 @@ static bool debug = false; +namespace { + namespace opt_array_splitting { class variable_entry : public exec_node @@ -77,6 +79,7 @@ public: }; } /* namespace */ + using namespace opt_array_splitting; /** @@ -112,6 +115,8 @@ public: void *mem_ctx; }; +} /* namespace */ + variable_entry * ir_array_reference_visitor::get_variable_entry(ir_variable *var) { diff --git a/mesalib/src/glsl/opt_dead_builtin_varyings.cpp b/mesalib/src/glsl/opt_dead_builtin_varyings.cpp index 3cdd13038..7e8cd4372 100644 --- a/mesalib/src/glsl/opt_dead_builtin_varyings.cpp +++ b/mesalib/src/glsl/opt_dead_builtin_varyings.cpp @@ -52,6 +52,7 @@ #include "glsl_types.h" #include "link_varyings.h" +namespace { /** * This obtains detailed information about built-in varyings from shader code. @@ -397,6 +398,7 @@ private: ir_variable *new_fog; }; +} /* anonymous namespace */ static void lower_texcoord_array(exec_list *ir, const varying_info_visitor *info) diff --git a/mesalib/src/mapi/glapi/gen/gl_enums.py b/mesalib/src/mapi/glapi/gen/gl_enums.py index 6aa36c363..1ff03fbe1 100755 --- a/mesalib/src/mapi/glapi/gen/gl_enums.py +++ b/mesalib/src/mapi/glapi/gen/gl_enums.py @@ -47,8 +47,8 @@ class PrintGlEnums(gl_XML.gl_print_base): print '#include "main/imports.h"' print '#include "main/mtypes.h"' print '' - print 'typedef struct {' - print ' size_t offset;' + print 'typedef struct PACKED {' + print ' uint16_t offset;' print ' int n;' print '} enum_elt;' print '' @@ -59,33 +59,18 @@ class PrintGlEnums(gl_XML.gl_print_base): typedef int (*cfunc)(const void *, const void *); /** - * Compare a key name to an element in the \c all_enums array. + * Compare a key enum value to an element in the \c enum_string_table_offsets array. * * \c bsearch always passes the key as the first parameter and the pointer * to the array element as the second parameter. We can elimiate some * extra work by taking advantage of that fact. * * \param a Pointer to the desired enum name. - * \param b Pointer to an element of the \c all_enums array. + * \param b Pointer into the \c enum_string_table_offsets array. */ -static int compar_name( const char *a, const enum_elt *b ) +static int compar_nr( const int *a, enum_elt *b ) { - return strcmp( a, & enum_string_table[ b->offset ] ); -} - -/** - * Compare a key enum value to an element in the \c all_enums array. - * - * \c bsearch always passes the key as the first parameter and the pointer - * to the array element as the second parameter. We can elimiate some - * extra work by taking advantage of that fact. - * - * \param a Pointer to the desired enum name. - * \param b Pointer to an index into the \c all_enums array. - */ -static int compar_nr( const int *a, const unsigned *b ) -{ - return a[0] - all_enums[*b].n; + return a[0] - b->n; } @@ -93,15 +78,17 @@ static char token_tmp[20]; const char *_mesa_lookup_enum_by_nr( int nr ) { - unsigned * i; + enum_elt *elt; + + STATIC_ASSERT(sizeof(enum_string_table) < (1 << 16)); - i = (unsigned *) _mesa_bsearch(& nr, reduced_enums, - Elements(reduced_enums), - sizeof(reduced_enums[0]), - (cfunc) compar_nr); + elt = _mesa_bsearch(& nr, enum_string_table_offsets, + Elements(enum_string_table_offsets), + sizeof(enum_string_table_offsets[0]), + (cfunc) compar_nr); - if ( i != NULL ) { - return & enum_string_table[ all_enums[ *i ].offset ]; + if (elt != NULL) { + return &enum_string_table[elt->offset]; } else { /* this is not re-entrant safe, no big deal here */ @@ -147,20 +134,6 @@ _mesa_lookup_prim_by_nr(GLuint nr) } -int _mesa_lookup_enum_by_name( const char *symbol ) -{ - enum_elt * f = NULL; - - if ( symbol != NULL ) { - f = (enum_elt *) _mesa_bsearch(symbol, all_enums, - Elements(all_enums), - sizeof( enum_elt ), - (cfunc) compar_name); - } - - return (f != NULL) ? f->n : -1; -} - """ return @@ -170,56 +143,37 @@ int _mesa_lookup_enum_by_name( const char *symbol ) for api in api_list: self.process_enums( api ) - keys = self.enum_table.keys() - keys.sort() - - name_table = [] - enum_table = {} + enum_table = [] - for enum in keys: + for enum in sorted(self.enum_table.keys()): low_pri = 9 + best_name = '' for [name, pri] in self.enum_table[ enum ]: - name_table.append( [name, enum] ) - if pri < low_pri: low_pri = pri - enum_table[enum] = name - + best_name = name - name_table.sort() + enum_table.append((enum, best_name)) string_offsets = {} i = 0; print 'LONGSTRING static const char enum_string_table[] = ' - for [name, enum] in name_table: + for enum, name in enum_table: print ' "%s\\0"' % (name) - string_offsets[ name ] = i + string_offsets[ enum ] = i i += len(name) + 1 print ' ;' print '' - print 'static const enum_elt all_enums[%u] =' % (len(name_table)) + print 'static const enum_elt enum_string_table_offsets[%u] =' % (len(enum_table)) print '{' - for [name, enum] in name_table: - print ' { %5u, 0x%08X }, /* %s */' % (string_offsets[name], enum, name) + for enum, name in enum_table: + print ' { %5u, 0x%08X }, /* %s */' % (string_offsets[enum], enum, name) print '};' print '' - print 'static const unsigned reduced_enums[%u] =' % (len(keys)) - print '{' - for enum in keys: - name = enum_table[ enum ] - if [name, enum] not in name_table: - print ' /* Error! %s, 0x%04x */ 0,' % (name, enum) - else: - i = name_table.index( [name, enum] ) - - print ' %4u, /* %s */' % (i, name) - print '};' - - self.print_code() return diff --git a/mesalib/src/mesa/drivers/dri/swrast/Makefile.am b/mesalib/src/mesa/drivers/dri/swrast/Makefile.am index d3da19651..fb9b8a050 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/Makefile.am +++ b/mesalib/src/mesa/drivers/dri/swrast/Makefile.am @@ -42,7 +42,8 @@ endif swrast_dri_la_SOURCES = \ $(SWRAST_C_FILES) -swrast_dri_la_LDFLAGS = -module -avoid-version -shared +swrast_dri_la_LDFLAGS = $(DRI_DRIVER_LDFLAGS) + swrast_dri_la_LIBADD = \ $(DRI_LIB_DEPS) diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c index ab5bbbf6d..e5814e397 100644 --- a/mesalib/src/mesa/main/bufferobj.c +++ b/mesalib/src/mesa/main/bufferobj.c @@ -440,7 +440,6 @@ _mesa_buffer_data( struct gl_context *ctx, GLenum target, GLsizeiptrARB size, * Note that all GL error checking will have been done already. * * \param ctx GL context. - * \param target Buffer object target on which to operate. * \param offset Offset of the first byte to be modified. * \param size Size, in bytes, of the data range. * \param data Pointer to the data to store in the buffer object. diff --git a/mesalib/src/mesa/main/compiler.h b/mesalib/src/mesa/main/compiler.h index fb7baf84e..0f27d5a66 100644 --- a/mesalib/src/mesa/main/compiler.h +++ b/mesalib/src/mesa/main/compiler.h @@ -270,6 +270,15 @@ static INLINE GLuint CPU_TO_LE32(GLuint x) #define NULL 0 #endif +/* Used to optionally mark structures with misaligned elements or size as + * packed, to trade off performance for space. + */ +#if (__GNUC__ >= 3) +#define PACKED __attribute__((__packed__)) +#else +#define PACKED +#endif + /** * LONGSTRING macro diff --git a/mesalib/src/mesa/main/enums.h b/mesalib/src/mesa/main/enums.h index 556c1db99..36c053d4b 100644 --- a/mesalib/src/mesa/main/enums.h +++ b/mesalib/src/mesa/main/enums.h @@ -44,6 +44,4 @@ extern const char *_mesa_lookup_enum_by_nr( int nr ); */ const char *_mesa_lookup_prim_by_nr( unsigned nr ); -extern int _mesa_lookup_enum_by_name( const char *symbol ); - #endif diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index c88c1c67b..448946c03 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -3498,8 +3498,6 @@ struct gl_uniform_buffer_binding * OpenGL state is contained in this structure. * Think of this as a base class from which device drivers will derive * sub classes. - * - * The struct gl_context typedef names this structure. */ struct gl_context { diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index b719fc856..c1261138d 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -661,22 +661,29 @@ _mesa_delete_texture_image(struct gl_context *ctx, GLboolean _mesa_is_proxy_texture(GLenum target) { + unsigned i; + static const GLenum targets[] = { + GL_PROXY_TEXTURE_1D, + GL_PROXY_TEXTURE_2D, + GL_PROXY_TEXTURE_3D, + GL_PROXY_TEXTURE_CUBE_MAP, + GL_PROXY_TEXTURE_RECTANGLE, + GL_PROXY_TEXTURE_1D_ARRAY, + GL_PROXY_TEXTURE_2D_ARRAY, + GL_PROXY_TEXTURE_CUBE_MAP_ARRAY, + GL_PROXY_TEXTURE_2D_MULTISAMPLE, + GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY + }; /* - * NUM_TEXTURE_TARGETS should match number of terms below, except there's no + * NUM_TEXTURE_TARGETS should match number of terms above, except there's no * proxy for GL_TEXTURE_BUFFER and GL_TEXTURE_EXTERNAL_OES. */ - assert(NUM_TEXTURE_TARGETS == 10 + 2); - - return (target == GL_PROXY_TEXTURE_1D || - target == GL_PROXY_TEXTURE_2D || - target == GL_PROXY_TEXTURE_3D || - target == GL_PROXY_TEXTURE_CUBE_MAP_ARB || - target == GL_PROXY_TEXTURE_RECTANGLE_NV || - target == GL_PROXY_TEXTURE_1D_ARRAY_EXT || - target == GL_PROXY_TEXTURE_2D_ARRAY_EXT || - target == GL_PROXY_TEXTURE_CUBE_MAP_ARRAY || - target == GL_PROXY_TEXTURE_2D_MULTISAMPLE || - target == GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY); + STATIC_ASSERT(NUM_TEXTURE_TARGETS == Elements(targets) + 2); + + for (i = 0; i < Elements(targets); ++i) + if (target == targets[i]) + return GL_TRUE; + return GL_FALSE; } diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp index c46a3d005..8cd42dfd2 100644 --- a/mesalib/src/mesa/program/ir_to_mesa.cpp +++ b/mesalib/src/mesa/program/ir_to_mesa.cpp @@ -57,11 +57,13 @@ extern "C" { #include "program/sampler.h" } +static int swizzle_for_size(int size); + +namespace { + class src_reg; class dst_reg; -static int swizzle_for_size(int size); - /** * This struct is a corresponding struct to Mesa prog_src_register, with * wider fields. @@ -129,6 +131,8 @@ public: src_reg *reladdr; }; +} /* anonymous namespace */ + src_reg::src_reg(dst_reg reg) { this->file = reg.file; @@ -147,6 +151,8 @@ dst_reg::dst_reg(src_reg reg) this->reladdr = reg.reladdr; } +namespace { + class ir_to_mesa_instruction : public exec_node { public: DECLARE_RZALLOC_CXX_OPERATORS(ir_to_mesa_instruction) @@ -316,6 +322,8 @@ public: void *mem_ctx; }; +} /* anonymous namespace */ + static src_reg undef_src = src_reg(PROGRAM_UNDEFINED, 0, NULL); static dst_reg undef_dst = dst_reg(PROGRAM_UNDEFINED, SWIZZLE_NOOP); @@ -2244,7 +2252,7 @@ ir_to_mesa_visitor::visit(ir_if *ir) visit_exec_list(&ir->else_instructions, this); } - if_inst = emit(ir->condition, OPCODE_ENDIF); + emit(ir->condition, OPCODE_ENDIF); } void @@ -2407,6 +2415,8 @@ print_program(struct prog_instruction *mesa_instructions, } } +namespace { + class add_uniform_to_shader : public program_resource_visitor { public: add_uniform_to_shader(struct gl_shader_program *shader_program, @@ -2436,6 +2446,8 @@ private: gl_shader_type shader_type; }; +} /* anonymous namespace */ + void add_uniform_to_shader::visit_field(const glsl_type *type, const char *name, bool row_major) diff --git a/mesalib/src/mesa/program/program.c b/mesalib/src/mesa/program/program.c index 2529c1305..093d37297 100644 --- a/mesalib/src/mesa/program/program.c +++ b/mesalib/src/mesa/program/program.c @@ -72,10 +72,10 @@ _mesa_init_program(struct gl_context *ctx) ASSERT(ctx->Const.FragmentProgram.MaxAddressOffset <= (1 << INST_INDEX_BITS)); /* If this fails, increase prog_instruction::TexSrcUnit size */ - ASSERT(MAX_TEXTURE_UNITS <= (1 << 5)); + STATIC_ASSERT(MAX_TEXTURE_UNITS <= (1 << 5)); /* If this fails, increase prog_instruction::TexSrcTarget size */ - ASSERT(NUM_TEXTURE_TARGETS <= (1 << 4)); + STATIC_ASSERT(NUM_TEXTURE_TARGETS <= (1 << 4)); ctx->Program.ErrorPos = -1; ctx->Program.ErrorString = _mesa_strdup(""); @@ -477,7 +477,6 @@ _mesa_clone_program(struct gl_context *ctx, const struct gl_program *prog) if (prog->Parameters) clone->Parameters = _mesa_clone_parameter_list(prog->Parameters); memcpy(clone->LocalParams, prog->LocalParams, sizeof(clone->LocalParams)); - memcpy(clone->LocalParams, prog->LocalParams, sizeof(clone->LocalParams)); clone->IndirectRegisterFiles = prog->IndirectRegisterFiles; clone->NumInstructions = prog->NumInstructions; clone->NumTemporaries = prog->NumTemporaries; |