Esempio n. 1
0
static bool ep_compile_pass_shaderparams(struct effect_parser *ep,
		struct darray *pass_params, struct darray *used_params,
		gs_shader_t *shader)
{
	size_t i;
	darray_resize(sizeof(struct pass_shaderparam), pass_params,
			used_params->num);

	for (i = 0; i < pass_params->num; i++) {
		struct dstr *param_name;
		struct pass_shaderparam *param;

		param_name = darray_item(sizeof(struct dstr), used_params, i);
		param = darray_item(sizeof(struct pass_shaderparam),
				pass_params, i);

		param->eparam = gs_effect_get_param_by_name(ep->effect,
				param_name->array);
		param->sparam = gs_shader_get_param_by_name(shader,
				param_name->array);

		if (!param->sparam) {
			blog(LOG_ERROR, "Effect shader parameter not found");
			return false;
		}
	}

	return true;
}
/*
    @description:
        Initializes the darray pointed to by p to the requested capacity.
*/
extern void darray_init(darray *p, size_t item_size, size_t capacity)
{
    p->item_size = item_size;
    p->capacity = 0;
    p->data = NULL;
    if (capacity > 0)
        darray_resize(p, capacity);
}
void darray_push(DArray *array, void *value) {

  array->last++;

  if (array->last == array->size) {
    darray_resize(array, array->size * 2);
  }
  array->data[array->last] = value;
}
Esempio n. 4
0
int darray_expand(darray_t *array)
{
    size_t old_max = array->max;
    check(darray_resize(array, array->max + array->expand_rate) == 0,
            "Failed to expand array to new size: %d",
            array->max + (int)array->expand_rate);

    memset(array->contents + old_max, 0, array->expand_rate + 1);
    return 0;

error:
    return -1;
}
void darray_set(DArray *array, int index, void *value) {

  int new_size = array->size;

  while (index > (new_size - 1)) {
    new_size *= 2;
  }

  if (new_size != array->size) {
    darray_resize(array, new_size);
  }

  array->data[index] = value;

  if (index > array->last) {
    array->last = index;
  }
}
Esempio n. 6
0
static void ep_compile_annotations(struct darray *ep_annotations,
	struct darray *gsp_annotations, struct effect_parser *ep)
{
	darray_resize(sizeof(struct gs_effect_param),
		gsp_annotations, ep_annotations->num);

	size_t i;
	for (i = 0; i < ep_annotations->num; i++) {
		struct gs_effect_param *param = ((struct gs_effect_param *)
				gsp_annotations->array)+i;
		struct ep_param *param_in = ((struct ep_param *)
				ep_annotations->array)+i;

		param->name = bstrdup(param_in->name);
		param->section = EFFECT_ANNOTATION;
		param->effect = ep->effect;
		da_move(param->default_val, param_in->default_val);

		param->type = get_effect_param_type(param_in->type);
	}
}
Esempio n. 7
0
int darray_contract(darray_t *array)
{
    int new_size = array->end < (int)array->expand_rate ? (int)array->expand_rate : array->end;

    return darray_resize(array, new_size + 1);
}