ir_remap_agalvars_visitor(PrintGlslMode _mode, hash_table *_oldnames) { oldnames = _oldnames; varhash = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare); renamedvars = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); varbase = 0; mode = _mode; nVA = nC = nT = nV = nFS = 0; useNewSyntax = false; memset(&agalName[0], 0, sizeof(agalName)); namesAreSorted = false; }
void link_varyings::SetUp() { this->mem_ctx = ralloc_context(NULL); this->ir.make_empty(); this->consumer_inputs = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare); this->consumer_interface_inputs = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare); }
loop_state::loop_state() { this->ht = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); this->mem_ctx = ralloc_context(NULL); this->loop_found = false; }
const glsl_type * glsl_type::get_interface_instance(const glsl_struct_field *fields, unsigned num_fields, enum glsl_interface_packing packing, const char *name) { const glsl_type key(fields, num_fields, packing, name); if (interface_types == NULL) { interface_types = hash_table_ctor(64, record_key_hash, record_key_compare); } const glsl_type *t = (glsl_type *) hash_table_find(interface_types, & key); if (t == NULL) { t = new glsl_type(fields, num_fields, packing, name); hash_table_insert(interface_types, (void *) t, t); } assert(t->base_type == GLSL_TYPE_INTERFACE); assert(t->length == num_fields); assert(strcmp(t->name, name) == 0); return t; }
has_recursion_visitor() : current(NULL) { this->mem_ctx = ralloc_context(NULL); this->function_hash = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); }
const glsl_type * glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) { if (array_types == NULL) { array_types = hash_table_ctor(64, hash_table_string_hash, hash_table_string_compare); } /* Generate a name using the base type pointer in the key. This is * done because the name of the base type may not be unique across * shaders. For example, two shaders may have different record types * named 'foo'. */ char key[128]; snprintf(key, sizeof(key), "%p[%u]", (void *) base, array_size); const glsl_type *t = (glsl_type *) hash_table_find(array_types, key); if (t == NULL) { t = new glsl_type(base, array_size); hash_table_insert(array_types, (void *) t, ralloc_strdup(mem_ctx, key)); } assert(t->base_type == GLSL_TYPE_ARRAY); assert(t->length == array_size); assert(t->fields.array == base); return t; }
ir_set_program_inouts_visitor(struct gl_program *prog, bool is_fragment_shader) { this->prog = prog; this->is_fragment_shader = is_fragment_shader; this->ht = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); }
ir_coalesce_floats_visitor() { basevar = NULL; newvar = NULL; firstUse = lastUse = NULL; tmpcount = 0; for(int i=0;i<4;i++) floatvars[i] = NULL; promotions = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); }
ir_if_to_cond_assign_visitor(unsigned max_depth) { this->progress = false; this->max_depth = max_depth; this->depth = 0; this->condition_variables = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); }
hash_table* do_remap_agalvars(exec_list *instructions, int mode) { hash_table *oldnames = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare); ir_remap_agalvars_visitor v((PrintGlslMode)mode, oldnames); v.run(instructions); return oldnames; }
struct _mesa_symbol_table * _mesa_symbol_table_ctor(void) { struct _mesa_symbol_table *table = calloc(1, sizeof(*table)); if (table != NULL) { table->ht = hash_table_ctor(32, hash_table_string_hash, hash_table_string_compare); _mesa_symbol_table_push_scope(table); } return table; }
const glsl_type * glsl_type::get_record_instance(const glsl_struct_field *fields, unsigned num_fields, const char *name) { const glsl_type key(fields, num_fields, name); if (record_types == NULL) { record_types = hash_table_ctor(64, record_key_hash, record_key_compare); } const glsl_type *t = (glsl_type *) hash_table_find(record_types, & key); if (t == NULL) { t = new glsl_type(fields, num_fields, name); hash_table_insert(record_types, (void *) t, t); } assert(t->base_type == GLSL_TYPE_STRUCT); assert(t->length == num_fields); assert(strcmp(t->name, name) == 0); return t; }
const glsl_type * glsl_type::get_templated_instance(const glsl_type *base, const char *name, int num_samples, int patch_size) { if (sampler_types == NULL) { sampler_types = hash_table_ctor(64, hash_table_string_hash, hash_table_string_compare); // Base sampler types. hash_table_insert(sampler_types, new glsl_type(GLSL_SAMPLER_DIM_1D, /*shadow=*/ false, /*array=*/ false, /*multisample=*/ false, /*samples=*/ 0, /*sampler_buffer=*/ true, /*type=*/ NULL, "samplerBuffer", "sampler"), "Buffer"); hash_table_insert(sampler_types, new glsl_type(GLSL_SAMPLER_DIM_1D, /*shadow=*/ false, /*array=*/ false, /*multisample=*/ false, /*samples=*/ 0, /*sampler_buffer=*/ false, /*type=*/ NULL, "sampler1D", "texture1d"), "Texture1D"); hash_table_insert(sampler_types, new glsl_type(GLSL_SAMPLER_DIM_1D, /*shadow=*/ false, /*array=*/ true, /*multisample=*/ false, /*samples=*/ 0, /*sampler_buffer=*/ false, /*type=*/ NULL, "sampler1DArray", nullptr), "Texture1DArray"); hash_table_insert(sampler_types, new glsl_type(GLSL_SAMPLER_DIM_2D, /*shadow=*/ false, /*array=*/ false, /*multisample=*/ false, /*samples=*/ 0, /*sampler_buffer=*/ false, /*type=*/ NULL, "sampler2D", "texture2d"), "Texture2D"); hash_table_insert(sampler_types, new glsl_type(GLSL_SAMPLER_DIM_2D, /*shadow=*/ false, /*array=*/ true, /*multisample=*/ false, /*samples=*/ 0, /*sampler_buffer=*/ false, /*type=*/ NULL, "sampler2DArray", nullptr), "Texture2DArray"); hash_table_insert(sampler_types, new glsl_type(GLSL_SAMPLER_DIM_2D, /*shadow=*/ false, /*array=*/ false, /*multisample=*/ true, /*samples=*/ 0, /*sampler_buffer=*/ false, /*type=*/ NULL, "sampler2DMS", nullptr), "Texture2DMS"); hash_table_insert(sampler_types, new glsl_type(GLSL_SAMPLER_DIM_2D, /*shadow=*/ false, /*array=*/ true, /*multisample=*/ true, /*samples=*/ 0, /*sampler_buffer=*/ false, /*type=*/ NULL, "sampler2DMSArray", nullptr), "Texture2DMSArray"); hash_table_insert(sampler_types, new glsl_type(GLSL_SAMPLER_DIM_3D, /*shadow=*/ false, /*array=*/ false, /*multisample=*/ false, /*samples=*/ 0, /*sampler_buffer=*/ false, /*type=*/ NULL, "sampler3D", "texture3d"), "Texture3D"); hash_table_insert(sampler_types, new glsl_type(GLSL_SAMPLER_DIM_CUBE, /*shadow=*/ false, /*array=*/ false, /*multisample=*/ false, /*samples=*/ 0, /*sampler_buffer=*/ false, /*type=*/ NULL, "samplerCube", "texturecube"), "TextureCube"); hash_table_insert(sampler_types, new glsl_type(GLSL_SAMPLER_DIM_CUBE, /*shadow=*/ false, /*array=*/ true, /*multisample=*/ false, /*samples=*/ 0, /*sampler_buffer=*/ false, /*type=*/ NULL, "samplerCubeArray", nullptr), "TextureCubeArray"); } if (outputstream_types == NULL) { outputstream_types = hash_table_ctor(64, hash_table_string_hash, hash_table_string_compare); // Base outputstream types. hash_table_insert(outputstream_types, new glsl_type(GLSL_OUTPUTSTREAM_POINTS, /*type=*/ NULL, "point_stream"), "PointStream"); hash_table_insert(outputstream_types, new glsl_type(GLSL_OUTPUTSTREAM_LINES, /*type=*/ NULL, "line_stream"), "LineStream"); hash_table_insert(outputstream_types, new glsl_type(GLSL_OUTPUTSTREAM_TRIANGLES, /*type=*/ NULL, "triangle_stream"), "TriangleStream"); } if (inputpatch_types == NULL) { inputpatch_types = hash_table_ctor(64, hash_table_string_hash, hash_table_string_compare); // Base input patch types. hash_table_insert(inputpatch_types, new glsl_type(GLSL_TYPE_INPUTPATCH, 0, (glsl_type*)NULL, "input_patch"), "InputPatch"); } if (outputpatch_types == NULL) { outputpatch_types = hash_table_ctor(64, hash_table_string_hash, hash_table_string_compare); // Base output patch types. hash_table_insert(outputpatch_types, new glsl_type(GLSL_TYPE_OUTPUTPATCH, 0, (glsl_type*)NULL, "output_patch"), "OutputPatch"); } if (image_types == NULL) { image_types = hash_table_ctor(64, hash_table_string_hash, hash_table_string_compare); // Base sampler types. hash_table_insert(image_types, new glsl_type(GLSL_SAMPLER_DIM_1D, /*array=*/ false, /*sampler_buffer=*/ true, /*type=*/ NULL, "imageBuffer"), "RWBuffer"); hash_table_insert(image_types, new glsl_type(GLSL_SAMPLER_DIM_1D, /*array=*/ false, /*sampler_buffer=*/ false, /*type=*/ NULL, "image1D"), "RWTexture1D"); hash_table_insert(image_types, new glsl_type(GLSL_SAMPLER_DIM_1D, /*array=*/ true, /*sampler_buffer=*/ false, /*type=*/ NULL, "image1DArray"), "RWTexture1DArray"); hash_table_insert(image_types, new glsl_type(GLSL_SAMPLER_DIM_2D, /*array=*/ false, /*sampler_buffer=*/ false, /*type=*/ NULL, "image2D"), "RWTexture2D"); hash_table_insert(image_types, new glsl_type(GLSL_SAMPLER_DIM_2D, /*array=*/ true, /*sampler_buffer=*/ false, /*type=*/ NULL, "image2DArray"), "RWTexture2DArray"); hash_table_insert(image_types, new glsl_type(GLSL_SAMPLER_DIM_3D, /*array=*/ false, /*sampler_buffer=*/ false, /*type=*/ NULL, "image3D"), "RWTexture3D"); hash_table_insert(image_types, new glsl_type(GLSL_SAMPLER_DIM_BUF, /*array=*/ false, /*sampler_buffer=*/ true, /*type=*/ NULL, "StructuredBuffer"), "RWStructuredBuffer"); hash_table_insert(image_types, new glsl_type(GLSL_SAMPLER_DIM_BUF, /*array=*/ false, /*sampler_buffer=*/ true, /*type=*/ NULL, "ByteAddressBuffer"), "RWByteAddressBuffer"); } if (base == NULL) { return NULL; } const glsl_type* outputstream_base_type = (const glsl_type*)hash_table_find(outputstream_types, name); if (outputstream_base_type != NULL) { /** Generate a key that is the combination of outputstream type and inner type. */ char key[128]; snprintf(key, sizeof(key), "%s<%s>", outputstream_base_type->name, base->name); const glsl_type *actual_type = (glsl_type *)hash_table_find(outputstream_types, key); if (actual_type == NULL) { actual_type = new glsl_type( (glsl_outputstream_type)(outputstream_base_type->outputstream_type), base, key); hash_table_insert(outputstream_types, (void *)actual_type, ralloc_strdup(mem_ctx, key)); } return actual_type; } const glsl_type* inputpatch_base_type = (const glsl_type*)hash_table_find(inputpatch_types, name); if (inputpatch_base_type != NULL) { /** Generate a key that is the combination of input patch type and inner type. */ char key[128]; snprintf(key, sizeof(key), "%s<%s>", inputpatch_base_type->name, base->name); const glsl_type *actual_type = (glsl_type *)hash_table_find(inputpatch_types, key); if (actual_type == NULL) { actual_type = new glsl_type(GLSL_TYPE_INPUTPATCH, patch_size, base, key); hash_table_insert(inputpatch_types, (void *)actual_type, ralloc_strdup(mem_ctx, key)); } return actual_type; } const glsl_type* outputpatch_base_type = (const glsl_type*)hash_table_find(outputpatch_types, name); if (outputpatch_base_type != NULL) { /** Generate a key that is the combination of input patch type and inner type. */ char key[128]; snprintf(key, sizeof(key), "%s<%s>", outputpatch_base_type->name, base->name); const glsl_type *actual_type = (glsl_type *)hash_table_find(outputpatch_types, key); if (actual_type == NULL) { actual_type = new glsl_type(GLSL_TYPE_OUTPUTPATCH, patch_size, base, key); hash_table_insert(outputpatch_types, (void *)actual_type, ralloc_strdup(mem_ctx, key)); } return actual_type; } if (!base->is_numeric()) { // Hack! //#todo-rco: Proper support! //if (strcmp(name, "RWStructuredBuffer") && strcmp(name, "RWByteAddressBuffer")) { return nullptr; } } const glsl_type* image_base_type = (const glsl_type*)hash_table_find(image_types, name); if (image_base_type != NULL) { /** Generate a key that is the combination of sampler type and inner type. */ char key[128]; snprintf(key, sizeof(key), "%s<%s>", image_base_type->name, base->name); const glsl_type *actual_type = (glsl_type *)hash_table_find(image_types, key); if (actual_type == NULL) { actual_type = new glsl_type( (glsl_sampler_dim)(image_base_type->sampler_dimensionality), image_base_type->sampler_array, image_base_type->sampler_buffer, base, ralloc_asprintf(mem_ctx, "%s%s", sampler_type_prefix[base->base_type], image_base_type->name)); hash_table_insert(image_types, (void *)actual_type, ralloc_strdup(mem_ctx, key)); } return actual_type; } const glsl_type* sampler_base_type = (const glsl_type*)hash_table_find(sampler_types, name); if (sampler_base_type == NULL) { return NULL; } /** Generate a key that is the combination of sampler type and inner type. */ char key[128]; if (num_samples>1) { snprintf(key, sizeof(key), "%s<%s,%d>", sampler_base_type->name, base->name, num_samples); } else { snprintf(key, sizeof(key), "%s<%s>", sampler_base_type->name, base->name); } const glsl_type *actual_type = (glsl_type *)hash_table_find(sampler_types, key); if (actual_type == NULL) { actual_type = new glsl_type( (glsl_sampler_dim)(sampler_base_type->sampler_dimensionality), sampler_base_type->sampler_shadow, sampler_base_type->sampler_array, sampler_base_type->sampler_ms, num_samples, sampler_base_type->sampler_buffer, base, ralloc_asprintf(mem_ctx, "%s%s", sampler_type_prefix[base->base_type], sampler_base_type->name), sampler_base_type->HlslName); hash_table_insert(sampler_types, (void *)actual_type, ralloc_strdup(mem_ctx, key)); } return actual_type; }
ir_array_decomposer_visitor() { basevar = NULL; varhash = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare); }
ir_lower_conditional_assigns_to_agal_visitor() { varbase = NULL; tmpcount = 0; assignedvars = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); }
ir_shorten_liveranges_visitor() { varhash = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); }
output_read_remover::output_read_remover() { mem_ctx = ralloc_context(NULL); replacements = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); }
void flatten_named_interface_blocks_declarations::run(exec_list *instructions) { interface_namespace = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare); /* First pass: adjust instance block variables with an instance name * to not have an instance name. * * The interface block variables are stored in the interface_namespace * hash table so they can be used in the second pass. */ foreach_list_safe(node, instructions) { ir_variable *var = ((ir_instruction *) node)->as_variable(); if (!var || !var->is_interface_instance()) continue; /* It should be possible to handle uniforms during this pass, * but, this will require changes to the other uniform block * support code. */ if (var->data.mode == ir_var_uniform) continue; const glsl_type * iface_t = var->type; const glsl_type * array_t = NULL; exec_node *insert_pos = var; if (iface_t->is_array()) { array_t = iface_t; iface_t = array_t->fields.array; } assert (iface_t->is_interface()); for (unsigned i = 0; i < iface_t->length; i++) { const char * field_name = iface_t->fields.structure[i].name; char *iface_field_name = ralloc_asprintf(mem_ctx, "%s.%s.%s", iface_t->name, var->name, field_name); ir_variable *found_var = (ir_variable *) hash_table_find(interface_namespace, iface_field_name); if (!found_var) { ir_variable *new_var; char *var_name = ralloc_strdup(mem_ctx, iface_t->fields.structure[i].name); if (array_t == NULL) { new_var = new(mem_ctx) ir_variable(iface_t->fields.structure[i].type, var_name, (ir_variable_mode) var->data.mode); new_var->data.from_named_ifc_block_nonarray = 1; } else { const glsl_type *new_array_type = glsl_type::get_array_instance( iface_t->fields.structure[i].type, array_t->length); new_var = new(mem_ctx) ir_variable(new_array_type, var_name, (ir_variable_mode) var->data.mode); new_var->data.from_named_ifc_block_array = 1; } new_var->data.location = iface_t->fields.structure[i].location; new_var->data.explicit_location = (new_var->data.location >= 0); new_var->data.interpolation = iface_t->fields.structure[i].interpolation; new_var->data.centroid = iface_t->fields.structure[i].centroid; new_var->data.sample = iface_t->fields.structure[i].sample; new_var->init_interface_type(iface_t); hash_table_insert(interface_namespace, new_var, iface_field_name); insert_pos->insert_after(new_var); insert_pos = new_var; } } var->remove(); }
ir_float_liverange_visitor() { firstUse = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); lastUse = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); }
ir_unique_agalvars_visitor() { tmpcount = 0; varhash = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare); }