• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ralloc_strdup函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ralloc_strdup函数的典型用法代码示例。如果您正苦于以下问题:C++ ralloc_strdup函数的具体用法?C++ ralloc_strdup怎么用?C++ ralloc_strdup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ralloc_strdup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: gl_type

glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
		     const char *name) :
   gl_type(0),
   base_type(GLSL_TYPE_STRUCT),
   sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
   sampler_type(0), interface_packing(0),
   vector_elements(0), matrix_columns(0),
   length(num_fields)
{
   unsigned int i;

   init_ralloc_type_ctx();
   assert(name != NULL);
   this->name = ralloc_strdup(this->mem_ctx, name);
   this->fields.structure = ralloc_array(this->mem_ctx,
					 glsl_struct_field, length);
   for (i = 0; i < length; i++) {
      this->fields.structure[i].type = fields[i].type;
      this->fields.structure[i].name = ralloc_strdup(this->fields.structure,
						     fields[i].name);
      this->fields.structure[i].precision = fields[i].precision;
      this->fields.structure[i].location = fields[i].location;
      this->fields.structure[i].interpolation = fields[i].interpolation;
      this->fields.structure[i].centroid = fields[i].centroid;
      this->fields.structure[i].sample = fields[i].sample;
      this->fields.structure[i].matrix_layout = fields[i].matrix_layout;
   }
}
开发者ID:382309009,项目名称:minko,代码行数:28,代码来源:glsl_types.cpp


示例2: ralloc_strdup

void
program_resource_visitor::process(ir_variable *var)
{
   const glsl_type *t = var->type;

   /* false is always passed for the row_major parameter to the other
    * processing functions because no information is available to do
    * otherwise.  See the warning in linker.h.
    */

   /* Only strdup the name if we actually will need to modify it. */
   if (t->is_record() || (t->is_array() && t->fields.array->is_record())) {
      char *name = ralloc_strdup(NULL, var->name);
      recursion(var->type, &name, strlen(name), false);
      ralloc_free(name);
   } else if (t->is_interface()) {
      char *name = ralloc_strdup(NULL, var->type->name);
      recursion(var->type, &name, strlen(name), false);
      ralloc_free(name);
   } else if (t->is_array() && t->fields.array->is_interface()) {
      char *name = ralloc_strdup(NULL, var->type->fields.array->name);
      recursion(var->type, &name, strlen(name), false);
      ralloc_free(name);
   } else {
      this->visit_field(t, var->name, false);
   }
}
开发者ID:SfietKonstantin,项目名称:radeon-mesa-x86-radeon,代码行数:27,代码来源:link_uniforms.cpp


示例3: base_type

glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
                     const char *name) :
    base_type(GLSL_TYPE_STRUCT),
    sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
    sampler_ms(false), sampler_buffer(false), outputstream_type(GLSL_OUTPUTSTREAM_NONE),
    sample_count(1), inner_type(0), vector_elements(0),
    matrix_columns(0), HlslName(nullptr), length(num_fields), patch_length(0)
{
    unsigned int i;

    init_ralloc_type_ctx();
    this->name = ralloc_strdup(this->mem_ctx, name);
    this->fields.structure = ralloc_array(this->mem_ctx,
                                          glsl_struct_field, length);
    for (i = 0; i < length; i++)
    {
        this->fields.structure[i].type = fields[i].type;
        this->fields.structure[i].name = ralloc_strdup(this->mem_ctx, fields[i].name);
        this->fields.structure[i].semantic = ralloc_strdup(this->mem_ctx, fields[i].semantic);
        this->fields.structure[i].centroid = fields[i].centroid;
        this->fields.structure[i].interpolation = fields[i].interpolation;
        this->fields.structure[i].geometryinput = fields[i].geometryinput;
        this->fields.structure[i].patchconstant = fields[i].patchconstant;
    }
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:25,代码来源:glsl_types.cpp


示例4: while

ir_visitor_status
ir_array_decomposer_visitor::visit(ir_variable *ir)
{
   if(!basevar) basevar = ir;

   if(ir->type->is_array()) {   
      unsigned array_count = ir->type->array_size();
      void *ctx = ir;
      while(array_count-- > 0) {
         char nm[512];
         sprintf(&nm[0], "%s_%d", ir->name, array_count);
         ir_variable *newvar = new (ctx) ir_variable(ir->type->element_type(), ralloc_strdup(ctx, &nm[0]), (ir_variable_mode)ir->mode, (glsl_precision)ir->precision);
         newvar->parent = ir;
         newvar->location = array_count;
         base_ir->insert_after(newvar);
         hash_table_insert(varhash, newvar, ralloc_strdup(ctx, &nm[0]));
      }
   } else if(ir->type->is_matrix()) {
      unsigned n = ir->type->matrix_columns;
      void *ctx = ir;
      while(n-- > 0) {
         char nm[512];
         sprintf(&nm[0], "%s_%d", ir->name, n);
         ir_variable *newvar = new (ctx) ir_variable(glsl_type::vec4_type, ralloc_strdup(ctx, &nm[0]), (ir_variable_mode)ir->mode, (glsl_precision)ir->precision);
         newvar->parent = ir;
				 ir->child[n] = newvar;
				 newvar->usedAsAMatrixComponent = true;				 
         newvar->location = n;				 
         base_ir->insert_after(newvar);
         hash_table_insert(varhash, newvar, ralloc_strdup(ctx, &nm[0]));
      }
   }

   return visit_continue;
}
开发者ID:KTXSoftware,项目名称:glsl2agal,代码行数:35,代码来源:lower_arrays.cpp


示例5: if

void ir_remap_agalvars_visitor::handleDeref(ir_variable **varloc)
{
   ir_variable *glvar = *varloc;
   ir_variable *agalvar = (ir_variable*)hash_table_find(varhash, glvar->name);

   if(agalvar) {
      *varloc = agalvar;
      //fprintf(stderr, "remapping deref -- %s\n", glvar->name);
   } else if(glvar->name[0] == 'g' && glvar->name[1] == 'l' && glvar->name[2] == '_') {
      computeAgalName(glvar);
      agalvar = new (glvar) ir_variable(glvar->type, ralloc_strdup(glvar, &agalName[0]), (ir_variable_mode)glvar->mode, (glsl_precision)glvar->precision);
      hash_table_insert(varhash, agalvar, ralloc_strdup(agalvar, glvar->name));
      hash_table_insert(varhash, agalvar, ralloc_strdup(agalvar, &agalName[0]));
      hash_table_insert(renamedvars, glvar, glvar);
      varbase->insert_before(agalvar);
      *varloc = agalvar;
      //fprintf(stderr, "renaming: %s -> %s\n", glvar->name, &agalName[0]);
   } else if (hash_table_find(renamedvars, glvar)) {
      // already renamed
   } else {
      computeAgalName(glvar);
      glvar->name = ralloc_strdup(glvar, agalName);
      hash_table_insert(renamedvars, glvar, glvar);
   }
}
开发者ID:5432935,项目名称:crossbridge,代码行数:25,代码来源:remap_agalvars.cpp


示例6: check

void glsl_type::add_structure_member(const glsl_struct_field* field)
{
    check(this->is_record());

    unsigned int i;

    glsl_struct_field* new_fields = ralloc_array(this->mem_ctx, glsl_struct_field, this->length + 1);
    for (i = 0; i < this->length; i++)
    {
        new_fields[i].type = this->fields.structure[i].type;
        new_fields[i].name = this->fields.structure[i].name;
        new_fields[i].semantic = this->fields.structure[i].semantic;
        new_fields[i].centroid = this->fields.structure[i].centroid;
        new_fields[i].interpolation = this->fields.structure[i].interpolation;
        new_fields[i].geometryinput = this->fields.structure[i].geometryinput;
        new_fields[i].patchconstant = this->fields.structure[i].patchconstant;

    }

    new_fields[i].type = field->type;
    new_fields[i].name = ralloc_strdup(new_fields, field->name);
    new_fields[i].semantic = ralloc_strdup(new_fields, field->semantic);
    new_fields[i].centroid = field->centroid;
    new_fields[i].interpolation = field->interpolation;
    new_fields[i].geometryinput = field->geometryinput;
    new_fields[i].patchconstant = field->patchconstant;

    this->fields.structure = new_fields;
    ++this->length;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:30,代码来源:glsl_types.cpp


示例7: copyShVariableCtx

ShVariable* copyShVariableCtx(ShVariable *src, void* mem_ctx)
{
    if (!src)
        return NULL;

    ShVariable* ret = (ShVariable*) rzalloc(mem_ctx, ShVariable);
    assert(ret || !"not enough memory to copy ShVariable");

    ret->uniqueId = src->uniqueId;
    ret->builtin = src->builtin;
    if (src->name)
        ret->name = ralloc_strdup(ret, src->name);

    ret->type = src->type;
    ret->qualifier = src->qualifier;
    ret->size = src->size;
    ret->isMatrix = src->isMatrix;
    ret->matrixSize[0] = src->matrixSize[0];
    ret->matrixSize[1] = src->matrixSize[1];
    ret->isArray = src->isArray;
    for (int i = 0; i < MAX_ARRAYS; i++)
        ret->arraySize[i] = src->arraySize[i];

    if (src->structName)
        ret->structName = ralloc_strdup(ret, src->structName);

    ret->structSize = src->structSize;
    if (ret->structSize) {
        ret->structSpec = (ShVariable**) rzalloc_array(ret, ShVariable*, ret->structSize);
        assert(ret->structSpec || !"not enough memory to copy structSpec of ShVariable");
        for (int i = 0; i < ret->structSize; i++)
            ret->structSpec[i] = copyShVariableCtx(src->structSpec[i], ret->structSpec);
    }
开发者ID:zard17,项目名称:GLSL-Debugger,代码行数:33,代码来源:Variable.cpp


示例8: ralloc_strdup

void glsl_type::replace_structure_member(int memberIndex, const glsl_struct_field* new_field)
{
    this->fields.structure[memberIndex].type = new_field->type;
    this->fields.structure[memberIndex].name = ralloc_strdup(this->fields.structure, new_field->name);
    this->fields.structure[memberIndex].semantic = ralloc_strdup(this->fields.structure, new_field->semantic);
    this->fields.structure[memberIndex].centroid = new_field->centroid;
    this->fields.structure[memberIndex].interpolation = new_field->interpolation;
    this->fields.structure[memberIndex].geometryinput = new_field->geometryinput;
    this->fields.structure[memberIndex].patchconstant = new_field->patchconstant;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:10,代码来源:glsl_types.cpp


示例9: build_color_shaders

static void
build_color_shaders(struct nir_shader **out_vs,
                    struct nir_shader **out_fs,
                    uint32_t frag_output)
{
	nir_builder vs_b;
	nir_builder fs_b;

	nir_builder_init_simple_shader(&vs_b, NULL, MESA_SHADER_VERTEX, NULL);
	nir_builder_init_simple_shader(&fs_b, NULL, MESA_SHADER_FRAGMENT, NULL);

	vs_b.shader->info.name = ralloc_strdup(vs_b.shader, "meta_clear_color_vs");
	fs_b.shader->info.name = ralloc_strdup(fs_b.shader, "meta_clear_color_fs");

	const struct glsl_type *position_type = glsl_vec4_type();
	const struct glsl_type *color_type = glsl_vec4_type();

	nir_variable *vs_out_pos =
		nir_variable_create(vs_b.shader, nir_var_shader_out, position_type,
				    "gl_Position");
	vs_out_pos->data.location = VARYING_SLOT_POS;

	nir_intrinsic_instr *in_color_load = nir_intrinsic_instr_create(fs_b.shader, nir_intrinsic_load_push_constant);
	nir_intrinsic_set_base(in_color_load, 0);
	nir_intrinsic_set_range(in_color_load, 16);
	in_color_load->src[0] = nir_src_for_ssa(nir_imm_int(&fs_b, 0));
	in_color_load->num_components = 4;
	nir_ssa_dest_init(&in_color_load->instr, &in_color_load->dest, 4, 32, "clear color");
	nir_builder_instr_insert(&fs_b, &in_color_load->instr);

	nir_variable *fs_out_color =
		nir_variable_create(fs_b.shader, nir_var_shader_out, color_type,
				    "f_color");
	fs_out_color->data.location = FRAG_RESULT_DATA0 + frag_output;

	nir_store_var(&fs_b, fs_out_color, &in_color_load->dest.ssa, 0xf);

	nir_ssa_def *outvec = radv_meta_gen_rect_vertices(&vs_b);
	nir_store_var(&vs_b, vs_out_pos, outvec, 0xf);

	const struct glsl_type *layer_type = glsl_int_type();
	nir_variable *vs_out_layer =
		nir_variable_create(vs_b.shader, nir_var_shader_out, layer_type,
				    "v_layer");
	vs_out_layer->data.location = VARYING_SLOT_LAYER;
	vs_out_layer->data.interpolation = INTERP_MODE_FLAT;
	nir_ssa_def *inst_id = nir_load_system_value(&vs_b, nir_intrinsic_load_instance_id, 0);
	nir_ssa_def *base_instance = nir_load_system_value(&vs_b, nir_intrinsic_load_base_instance, 0);

	nir_ssa_def *layer_id = nir_iadd(&vs_b, inst_id, base_instance);
	nir_store_var(&vs_b, vs_out_layer, layer_id, 0x1);

	*out_vs = vs_b.shader;
	*out_fs = fs_b.shader;
}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:55,代码来源:radv_meta_clear.c


示例10: assert

/**
 * Replace any declaration of gl_TessLevel* as an array of floats with a
 * declaration of gl_TessLevel*MESA as a vec4.
 */
ir_visitor_status
lower_tess_level_visitor::visit(ir_variable *ir)
{
   if ((!ir->name) ||
       ((strcmp(ir->name, "gl_TessLevelInner") != 0) &&
        (strcmp(ir->name, "gl_TessLevelOuter") != 0)))
      return visit_continue;

   assert (ir->type->is_array());

   if (strcmp(ir->name, "gl_TessLevelOuter") == 0) {
      if (this->old_tess_level_outer_var)
         return visit_continue;

      old_tess_level_outer_var = ir;
      assert(ir->type->fields.array == glsl_type::float_type);

      /* Clone the old var so that we inherit all of its properties */
      new_tess_level_outer_var = ir->clone(ralloc_parent(ir), NULL);

      /* And change the properties that we need to change */
      new_tess_level_outer_var->name = ralloc_strdup(new_tess_level_outer_var,
                                                "gl_TessLevelOuterMESA");
      new_tess_level_outer_var->type = glsl_type::vec4_type;
      new_tess_level_outer_var->data.max_array_access = 0;

      ir->replace_with(new_tess_level_outer_var);
   } else if (strcmp(ir->name, "gl_TessLevelInner") == 0) {
      if (this->old_tess_level_inner_var)
         return visit_continue;

      old_tess_level_inner_var = ir;
      assert(ir->type->fields.array == glsl_type::float_type);

      /* Clone the old var so that we inherit all of its properties */
      new_tess_level_inner_var = ir->clone(ralloc_parent(ir), NULL);

      /* And change the properties that we need to change */
      new_tess_level_inner_var->name = ralloc_strdup(new_tess_level_inner_var,
                                                "gl_TessLevelInnerMESA");
      new_tess_level_inner_var->type = glsl_type::vec2_type;
      new_tess_level_inner_var->data.max_array_access = 0;

      ir->replace_with(new_tess_level_inner_var);
   } else {
      assert(0);
   }

   this->progress = true;

   return visit_continue;
}
开发者ID:chemecse,项目名称:mesa,代码行数:56,代码来源:lower_tess_level.cpp


示例11: sprintf

ir_visitor_status
ir_unique_agalvars_visitor::visit(ir_variable *ir)
{
   if(hash_table_find(varhash, ir->name)) {
      char nm[512];
      sprintf(&nm[0], "%s_%d", ir->name, tmpcount++);
      //fprintf(stderr, "uniquing %s --> %s\n", ir->name, &nm[0]);
      ir->name = (char*)ralloc_strdup(ir, &nm[0]);
   }

   hash_table_insert(varhash, (void*)0x1, ralloc_strdup(ir, ir->name));
   return visit_continue;
}
开发者ID:5432935,项目名称:crossbridge,代码行数:13,代码来源:unique_variables.cpp


示例12: visit_field

   virtual void visit_field(const glsl_type *type, const char *name,
                            bool row_major, const glsl_type *record_type)
   {
      assert(this->index < this->num_variables);

      gl_uniform_buffer_variable *v = &this->variables[this->index++];

      v->Name = ralloc_strdup(mem_ctx, name);
      v->Type = type;
      v->RowMajor = row_major;

      if (this->is_array_instance) {
         v->IndexName = ralloc_strdup(mem_ctx, name);

         char *open_bracket = strchr(v->IndexName, '[');
         assert(open_bracket != NULL);

         char *close_bracket = strchr(open_bracket, ']');
         assert(close_bracket != NULL);

         /* Length of the tail without the ']' but with the NUL.
          */
         unsigned len = strlen(close_bracket + 1) + 1;

         memmove(open_bracket, close_bracket + 1, len);
     } else {
         v->IndexName = v->Name;
      }

      const unsigned alignment = record_type
	 ? record_type->std140_base_alignment(!!v->RowMajor)
	 : type->std140_base_alignment(!!v->RowMajor);
      unsigned size = type->std140_size(!!v->RowMajor);

      this->offset = glsl_align(this->offset, alignment);
      v->Offset = this->offset;
      this->offset += size;

      /* From the GL_ARB_uniform_buffer_object spec:
       *
       *     "For uniform blocks laid out according to [std140] rules, the
       *      minimum buffer object size returned by the
       *      UNIFORM_BLOCK_DATA_SIZE query is derived by taking the offset of
       *      the last basic machine unit consumed by the last uniform of the
       *      uniform block (including any end-of-array or end-of-structure
       *      padding), adding one, and rounding up to the next multiple of
       *      the base alignment required for a vec4."
       */
      this->buffer_size = glsl_align(this->offset, 16);
   }
开发者ID:Chiur,项目名称:glsl-optimizer,代码行数:50,代码来源:link_uniform_blocks.cpp


示例13: ralloc_parent

ir_rvalue*
ir_array_decomposer_visitor::computeNewRValue(ir_rvalue *rval)
{
   ir_dereference_array *da = rval->as_dereference_array();
   if(da && (da->array->type->is_array() || da->array->type->is_matrix())) {
      ir_constant *ci = da->array_index->constant_expression_value();
      if(!ci) {
         return NULL;
      }

      ir_variable *src = da->variable_referenced();
      if(!src) {
         return NULL;
      }

      // make sure unsized arrays end up with a reasonable size
      if(src->max_array_access < ci->get_int_component(0)) {
         src->max_array_access = ci->get_int_component(0);
         //fprintf(stderr, "updating max access: %d\n", src->max_array_access);
      }

      void *ctx = ralloc_parent(base_ir);

      char nm[512] = {0};
      sprintf(&nm[0], "%s_%d", src->name, ci->get_int_component(0));

      ir_variable *v = (ir_variable*)hash_table_find(varhash, &nm[0]);
      if(!v) {
         v = new (ctx) ir_variable(src->type->element_type(), ralloc_strdup(ctx, &nm[0]), (ir_variable_mode)src->mode, (glsl_precision)src->precision);
         v->parent = src;
         v->location = ci->get_int_component(0);
         basevar->insert_before(v);
         hash_table_insert(varhash, v, ralloc_strdup(ctx, &nm[0]));
      }
      
      ir_dereference_variable *dv = new(ctx) ir_dereference_variable(v);

      int c = v->type->vector_elements;
      if(c == 4) {
         return dv;
      }

      char si[5] = "xyzw";
      si[c] = 0;
      ir_swizzle *sz = ir_swizzle::create(dv, si, c);
      return sz;
   }

   return NULL;
}
开发者ID:KTXSoftware,项目名称:glsl2agal,代码行数:50,代码来源:lower_arrays.cpp


示例14: _mesa_clear_shader_program_data

void
_mesa_clear_shader_program_data(struct gl_shader_program *shProg)
{
   unsigned i;

   shProg->NumUniformStorage = 0;
   shProg->UniformStorage = NULL;
   shProg->NumUniformRemapTable = 0;
   shProg->UniformRemapTable = NULL;
   shProg->UniformHash = NULL;

   ralloc_free(shProg->InfoLog);
   shProg->InfoLog = ralloc_strdup(shProg, "");

   ralloc_free(shProg->BufferInterfaceBlocks);
   shProg->BufferInterfaceBlocks = NULL;
   shProg->NumBufferInterfaceBlocks = 0;

   ralloc_free(shProg->UniformBlocks);
   shProg->UniformBlocks = NULL;
   shProg->NumUniformBlocks = 0;

   ralloc_free(shProg->ShaderStorageBlocks);
   shProg->ShaderStorageBlocks = NULL;
   shProg->NumShaderStorageBlocks = 0;

   for (i = 0; i < MESA_SHADER_STAGES; i++) {
      ralloc_free(shProg->InterfaceBlockStageIndex[i]);
      shProg->InterfaceBlockStageIndex[i] = NULL;
   }

   ralloc_free(shProg->AtomicBuffers);
   shProg->AtomicBuffers = NULL;
   shProg->NumAtomicBuffers = 0;
}
开发者ID:Distrotech,项目名称:Mesa,代码行数:35,代码来源:standalone_scaffolding.cpp


示例15: _mesa_clear_shader_program_data

/**
 * Clear (free) the shader program state that gets produced by linking.
 */
void
_mesa_clear_shader_program_data(struct gl_context *ctx,
                                struct gl_shader_program *shProg)
{
   if (shProg->UniformStorage) {
      unsigned i;
      for (i = 0; i < shProg->NumUserUniformStorage; ++i)
         _mesa_uniform_detach_all_driver_storage(&shProg->UniformStorage[i]);
      ralloc_free(shProg->UniformStorage);
      shProg->NumUserUniformStorage = 0;
      shProg->UniformStorage = NULL;
   }

   if (shProg->UniformRemapTable) {
      ralloc_free(shProg->UniformRemapTable);
      shProg->NumUniformRemapTable = 0;
      shProg->UniformRemapTable = NULL;
   }

   if (shProg->UniformHash) {
      string_to_uint_map_dtor(shProg->UniformHash);
      shProg->UniformHash = NULL;
   }

   assert(shProg->InfoLog != NULL);
   ralloc_free(shProg->InfoLog);
   shProg->InfoLog = ralloc_strdup(shProg, "");
}
开发者ID:cwabbott0,项目名称:mesa,代码行数:31,代码来源:shaderobj.c


示例16: main

int
main (int argc, char *argv[])
{
	char *filename = NULL;
	void *ctx = ralloc(NULL, void*);
	char *info_log = ralloc_strdup(ctx, "");
	const char *shader;
	int ret;

	if (argc) {
		filename = argv[1];
	}

	shader = load_text_file (ctx, filename);
	if (shader == NULL)
	   return 1;

	ret = glcpp_preprocess(ctx, &shader, &info_log, NULL, API_OPENGL);

	printf("%s", shader);
	fprintf(stderr, "%s", info_log);

	ralloc_free(ctx);

	return ret;
}
开发者ID:FASTCHIP,项目名称:kernel_3.4.67_lenovo_s939_mtk6592,代码行数:26,代码来源:glcpp.c


示例17: hash_table_ctor

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;
}
开发者ID:DanMacDonald,项目名称:LoomSDK,代码行数:30,代码来源:glsl_types.cpp


示例18: nir_variable_clone

/* NOTE: for cloning nir_variables, bypass nir_variable_create to avoid
 * having to deal with locals and globals separately:
 */
nir_variable *
nir_variable_clone(const nir_variable *var, nir_shader *shader)
{
   nir_variable *nvar = rzalloc(shader, nir_variable);

   nvar->type = var->type;
   nvar->name = ralloc_strdup(nvar, var->name);
   nvar->data = var->data;
   nvar->num_state_slots = var->num_state_slots;
   nvar->state_slots = ralloc_array(nvar, nir_state_slot, var->num_state_slots);
   memcpy(nvar->state_slots, var->state_slots,
          var->num_state_slots * sizeof(nir_state_slot));
   if (var->constant_initializer) {
      nvar->constant_initializer =
         nir_constant_clone(var->constant_initializer, nvar);
   }
   nvar->interface_type = var->interface_type;

   nvar->num_members = var->num_members;
   if (var->num_members) {
      nvar->members = ralloc_array(nvar, struct nir_variable_data,
                                   var->num_members);
      memcpy(nvar->members, var->members,
             var->num_members * sizeof(*var->members));
   }
开发者ID:freedreno,项目名称:mesa,代码行数:28,代码来源:nir_clone.c


示例19: assert

/**
 * Replace any declaration of gl_ClipDistance as an array of floats with a
 * declaration of gl_ClipDistanceMESA as an array of vec4's.
 */
ir_visitor_status
lower_clip_distance_visitor::visit(ir_variable *ir)
{
   /* No point in looking for the declaration of gl_ClipDistance if
    * we've already found it.
    */
   if (this->old_clip_distance_var)
      return visit_continue;

   if (ir->name && strcmp(ir->name, "gl_ClipDistance") == 0) {
      this->progress = true;
      this->old_clip_distance_var = ir;
      assert (ir->type->is_array());
      assert (ir->type->element_type() == glsl_type::float_type);
      unsigned new_size = (ir->type->array_size() + 3) / 4;

      /* Clone the old var so that we inherit all of its properties */
      this->new_clip_distance_var = ir->clone(ralloc_parent(ir), NULL);

      /* And change the properties that we need to change */
      this->new_clip_distance_var->name
         = ralloc_strdup(this->new_clip_distance_var, "gl_ClipDistanceMESA");
      this->new_clip_distance_var->type
         = glsl_type::get_array_instance(glsl_type::vec4_type, new_size);
      this->new_clip_distance_var->max_array_access = ir->max_array_access / 4;

      ir->replace_with(this->new_clip_distance_var);
   }
   return visit_continue;
}
开发者ID:VadimGirlin,项目名称:mesa,代码行数:34,代码来源:lower_clip_distance.cpp


示例20: process_block_array

static void
process_block_array(struct uniform_block_array_elements *ub_array, char **name,
                    size_t name_length, gl_uniform_block *blocks,
                    ubo_visitor *parcel, gl_uniform_buffer_variable *variables,
                    const struct link_uniform_block_active *const b,
                    unsigned *block_index, unsigned *binding_offset,
                    struct gl_context *ctx, struct gl_shader_program *prog)
{
   if (ub_array) {
      for (unsigned j = 0; j < ub_array->num_array_elements; j++) {
         size_t new_length = name_length;

         /* Append the subscript to the current variable name */
         ralloc_asprintf_rewrite_tail(name, &new_length, "[%u]",
                                      ub_array->array_elements[j]);

         process_block_array(ub_array->array, name, new_length, blocks,
                             parcel, variables, b, block_index,
                             binding_offset, ctx, prog);
      }
   } else {
      unsigned i = *block_index;
      const glsl_type *type =  b->type->without_array();

      blocks[i].Name = ralloc_strdup(blocks, *name);
      blocks[i].Uniforms = &variables[(*parcel).index];

      /* The GL_ARB_shading_language_420pack spec says:
       *
       *     "If the binding identifier is used with a uniform block
       *     instanced as an array then the first element of the array
       *     takes the specified block binding and each subsequent
       *     element takes the next consecutive uniform block binding
       *     point."
       */
      blocks[i].Binding = (b->has_binding) ? b->binding + *binding_offset : 0;

      blocks[i].UniformBufferSize = 0;
      blocks[i]._Packing = gl_uniform_block_packing(type->interface_packing);

      parcel->process(type, blocks[i].Name);

      blocks[i].UniformBufferSize = parcel->buffer_size;

      /* Check SSBO size is lower than maximum supported size for SSBO */
      if (b->is_shader_storage &&
          parcel->buffer_size > ctx->Const.MaxShaderStorageBlockSize) {
         linker_error(prog, "shader storage block `%s' has size %d, "
                      "which is larger than than the maximum allowed (%d)",
                      b->type->name,
                      parcel->buffer_size,
                      ctx->Const.MaxShaderStorageBlockSize);
      }
      blocks[i].NumUniforms =
         (unsigned)(ptrdiff_t)(&variables[parcel->index] - blocks[i].Uniforms);

      *block_index = *block_index + 1;
      *binding_offset = *binding_offset + 1;
   }
}
开发者ID:BNieuwenhuizen,项目名称:mesa,代码行数:60,代码来源:link_uniform_blocks.cpp



注:本文中的ralloc_strdup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ran1函数代码示例发布时间:2022-05-30
下一篇:
C++ ralloc_parent函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap