glsl: replace remaining tabs in link_uniforms.cpp

Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
This commit is contained in:
Timothy Arceri
2016-02-24 19:33:28 +11:00
parent 3322cb7b8d
commit e2415e8467

View File

@@ -188,8 +188,8 @@ program_resource_visitor::recursion(const glsl_type *t, char **name,
this->enter_record(t, *name, row_major, packing); this->enter_record(t, *name, row_major, packing);
for (unsigned i = 0; i < t->length; i++) { for (unsigned i = 0; i < t->length; i++) {
const char *field = t->fields.structure[i].name; const char *field = t->fields.structure[i].name;
size_t new_length = name_length; size_t new_length = name_length;
if (t->fields.structure[i].type->is_record()) if (t->fields.structure[i].type->is_record())
this->visit_field(&t->fields.structure[i]); this->visit_field(&t->fields.structure[i]);
@@ -250,10 +250,10 @@ program_resource_visitor::recursion(const glsl_type *t, char **name,
record_array_count *= length; record_array_count *= length;
for (unsigned i = 0; i < length; i++) { for (unsigned i = 0; i < length; i++) {
size_t new_length = name_length; size_t new_length = name_length;
/* Append the subscript to the current variable name */ /* Append the subscript to the current variable name */
ralloc_asprintf_rewrite_tail(name, &new_length, "[%u]", i); ralloc_asprintf_rewrite_tail(name, &new_length, "[%u]", i);
recursion(t->fields.array, name, new_length, row_major, recursion(t->fields.array, name, new_length, row_major,
record_type, record_type,
@@ -423,19 +423,19 @@ private:
if(!is_shader_storage) if(!is_shader_storage)
this->num_shader_uniform_components += values; this->num_shader_uniform_components += values;
} else { } else {
/* Accumulate the total number of uniform slots used by this shader. /* Accumulate the total number of uniform slots used by this shader.
* Note that samplers do not count against this limit because they * Note that samplers do not count against this limit because they
* don't use any storage on current hardware. * don't use any storage on current hardware.
*/ */
if (!is_ubo_var && !is_shader_storage) if (!is_ubo_var && !is_shader_storage)
this->num_shader_uniform_components += values; this->num_shader_uniform_components += values;
} }
/* If the uniform is already in the map, there's nothing more to do. /* If the uniform is already in the map, there's nothing more to do.
*/ */
unsigned id; unsigned id;
if (this->map->get(id, name)) if (this->map->get(id, name))
return; return;
if (this->current_var->data.how_declared == ir_var_hidden) { if (this->current_var->data.how_declared == ir_var_hidden) {
this->hidden_map->put(this->num_hidden_uniforms, name); this->hidden_map->put(this->num_hidden_uniforms, name);
@@ -481,8 +481,8 @@ class parcel_out_uniform_storage : public program_resource_visitor {
public: public:
parcel_out_uniform_storage(struct gl_shader_program *prog, parcel_out_uniform_storage(struct gl_shader_program *prog,
struct string_to_uint_map *map, struct string_to_uint_map *map,
struct gl_uniform_storage *uniforms, struct gl_uniform_storage *uniforms,
union gl_constant_value *values) union gl_constant_value *values)
: prog(prog), map(map), uniforms(uniforms), values(values) : prog(prog), map(map), uniforms(uniforms), values(values)
{ {
} }
@@ -528,9 +528,9 @@ public:
ubo_block_index = i; ubo_block_index = i;
break; break;
} }
} }
} }
assert(ubo_block_index != -1); assert(ubo_block_index != -1);
/* Uniform blocks that were specified with an instance name must be /* Uniform blocks that were specified with an instance name must be
* handled a little bit differently. The name of the variable is the * handled a little bit differently. The name of the variable is the
@@ -743,15 +743,15 @@ private:
assert(found); assert(found);
if (!found) if (!found)
return; return;
const glsl_type *base_type; const glsl_type *base_type;
if (type->is_array()) { if (type->is_array()) {
this->uniforms[id].array_elements = type->length; this->uniforms[id].array_elements = type->length;
base_type = type->fields.array; base_type = type->fields.array;
} else { } else {
this->uniforms[id].array_elements = 0; this->uniforms[id].array_elements = 0;
base_type = type; base_type = type;
} }
/* Initialise opaque data */ /* Initialise opaque data */
@@ -835,11 +835,11 @@ private:
this->uniforms[id].array_stride = this->uniforms[id].array_stride =
glsl_align(type->without_array()->std140_size(row_major), glsl_align(type->without_array()->std140_size(row_major),
16); 16);
} else { } else {
this->uniforms[id].array_stride = 0; this->uniforms[id].array_stride = 0;
} }
if (type->without_array()->is_matrix()) { if (type->without_array()->is_matrix()) {
const glsl_type *matrix = type->without_array(); const glsl_type *matrix = type->without_array();
const unsigned N = matrix->base_type == GLSL_TYPE_DOUBLE ? 8 : 4; const unsigned N = matrix->base_type == GLSL_TYPE_DOUBLE ? 8 : 4;
const unsigned items = const unsigned items =
@@ -851,17 +851,17 @@ private:
glsl_align(items * N, 16); glsl_align(items * N, 16);
else else
this->uniforms[id].matrix_stride = glsl_align(items * N, 16); this->uniforms[id].matrix_stride = glsl_align(items * N, 16);
this->uniforms[id].row_major = row_major; this->uniforms[id].row_major = row_major;
} else { } else {
this->uniforms[id].matrix_stride = 0; this->uniforms[id].matrix_stride = 0;
this->uniforms[id].row_major = false; this->uniforms[id].row_major = false;
} }
} else { } else {
this->uniforms[id].block_index = -1; this->uniforms[id].block_index = -1;
this->uniforms[id].offset = -1; this->uniforms[id].offset = -1;
this->uniforms[id].array_stride = -1; this->uniforms[id].array_stride = -1;
this->uniforms[id].matrix_stride = -1; this->uniforms[id].matrix_stride = -1;
this->uniforms[id].row_major = false; this->uniforms[id].row_major = false;
} }
this->values += values_for_type(type); this->values += values_for_type(type);
@@ -927,36 +927,36 @@ public:
*/ */
int int
link_cross_validate_uniform_block(void *mem_ctx, link_cross_validate_uniform_block(void *mem_ctx,
struct gl_uniform_block **linked_blocks, struct gl_uniform_block **linked_blocks,
unsigned int *num_linked_blocks, unsigned int *num_linked_blocks,
struct gl_uniform_block *new_block) struct gl_uniform_block *new_block)
{ {
for (unsigned int i = 0; i < *num_linked_blocks; i++) { for (unsigned int i = 0; i < *num_linked_blocks; i++) {
struct gl_uniform_block *old_block = &(*linked_blocks)[i]; struct gl_uniform_block *old_block = &(*linked_blocks)[i];
if (strcmp(old_block->Name, new_block->Name) == 0) if (strcmp(old_block->Name, new_block->Name) == 0)
return link_uniform_blocks_are_compatible(old_block, new_block) return link_uniform_blocks_are_compatible(old_block, new_block)
? i : -1; ? i : -1;
} }
*linked_blocks = reralloc(mem_ctx, *linked_blocks, *linked_blocks = reralloc(mem_ctx, *linked_blocks,
struct gl_uniform_block, struct gl_uniform_block,
*num_linked_blocks + 1); *num_linked_blocks + 1);
int linked_block_index = (*num_linked_blocks)++; int linked_block_index = (*num_linked_blocks)++;
struct gl_uniform_block *linked_block = &(*linked_blocks)[linked_block_index]; struct gl_uniform_block *linked_block = &(*linked_blocks)[linked_block_index];
memcpy(linked_block, new_block, sizeof(*new_block)); memcpy(linked_block, new_block, sizeof(*new_block));
linked_block->Uniforms = ralloc_array(*linked_blocks, linked_block->Uniforms = ralloc_array(*linked_blocks,
struct gl_uniform_buffer_variable, struct gl_uniform_buffer_variable,
linked_block->NumUniforms); linked_block->NumUniforms);
memcpy(linked_block->Uniforms, memcpy(linked_block->Uniforms,
new_block->Uniforms, new_block->Uniforms,
sizeof(*linked_block->Uniforms) * linked_block->NumUniforms); sizeof(*linked_block->Uniforms) * linked_block->NumUniforms);
for (unsigned int i = 0; i < linked_block->NumUniforms; i++) { for (unsigned int i = 0; i < linked_block->NumUniforms; i++) {
struct gl_uniform_buffer_variable *ubo_var = struct gl_uniform_buffer_variable *ubo_var =
&linked_block->Uniforms[i]; &linked_block->Uniforms[i];
if (ubo_var->Name == ubo_var->IndexName) { if (ubo_var->Name == ubo_var->IndexName) {
ubo_var->Name = ralloc_strdup(*linked_blocks, ubo_var->Name); ubo_var->Name = ralloc_strdup(*linked_blocks, ubo_var->Name);
@@ -983,7 +983,7 @@ link_update_uniform_buffer_variables(struct gl_shader *shader)
ir_variable *const var = node->as_variable(); ir_variable *const var = node->as_variable();
if ((var == NULL) || !var->is_in_buffer_block()) if ((var == NULL) || !var->is_in_buffer_block())
continue; continue;
assert(var->data.mode == ir_var_uniform || assert(var->data.mode == ir_var_uniform ||
var->data.mode == ir_var_shader_storage); var->data.mode == ir_var_shader_storage);
@@ -1005,7 +1005,7 @@ link_update_uniform_buffer_variables(struct gl_shader *shader)
const unsigned l = strlen(var->name); const unsigned l = strlen(var->name);
for (unsigned i = 0; i < shader->NumBufferInterfaceBlocks; i++) { for (unsigned i = 0; i < shader->NumBufferInterfaceBlocks; i++) {
for (unsigned j = 0; j < shader->BufferInterfaceBlocks[i].NumUniforms; j++) { for (unsigned j = 0; j < shader->BufferInterfaceBlocks[i].NumUniforms; j++) {
if (sentinel) { if (sentinel) {
const char *begin = shader->BufferInterfaceBlocks[i].Uniforms[j].Name; const char *begin = shader->BufferInterfaceBlocks[i].Uniforms[j].Name;
const char *end = strchr(begin, sentinel); const char *end = strchr(begin, sentinel);
@@ -1023,13 +1023,13 @@ link_update_uniform_buffer_variables(struct gl_shader *shader)
} }
} else if (!strcmp(var->name, } else if (!strcmp(var->name,
shader->BufferInterfaceBlocks[i].Uniforms[j].Name)) { shader->BufferInterfaceBlocks[i].Uniforms[j].Name)) {
found = true; found = true;
var->data.location = j; var->data.location = j;
break; break;
} }
} }
if (found) if (found)
break; break;
} }
assert(found); assert(found);
} }
@@ -1112,7 +1112,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
struct gl_shader *sh = prog->_LinkedShaders[i]; struct gl_shader *sh = prog->_LinkedShaders[i];
if (sh == NULL) if (sh == NULL)
continue; continue;
/* Uniforms that lack an initializer in the shader code have an initial /* Uniforms that lack an initializer in the shader code have an initial
* value of zero. This includes sampler uniforms. * value of zero. This includes sampler uniforms.
@@ -1133,13 +1133,13 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
uniform_size.start_shader(); uniform_size.start_shader();
foreach_in_list(ir_instruction, node, sh->ir) { foreach_in_list(ir_instruction, node, sh->ir) {
ir_variable *const var = node->as_variable(); ir_variable *const var = node->as_variable();
if ((var == NULL) || (var->data.mode != ir_var_uniform && if ((var == NULL) || (var->data.mode != ir_var_uniform &&
var->data.mode != ir_var_shader_storage)) var->data.mode != ir_var_shader_storage))
continue; continue;
uniform_size.process(var); uniform_size.process(var);
} }
sh->num_samplers = uniform_size.num_shader_samplers; sh->num_samplers = uniform_size.num_shader_samplers;
@@ -1149,8 +1149,8 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
for (unsigned i = 0; i < sh->NumBufferInterfaceBlocks; i++) { for (unsigned i = 0; i < sh->NumBufferInterfaceBlocks; i++) {
if (!sh->BufferInterfaceBlocks[i].IsShaderStorage) { if (!sh->BufferInterfaceBlocks[i].IsShaderStorage) {
sh->num_combined_uniform_components += sh->num_combined_uniform_components +=
sh->BufferInterfaceBlocks[i].UniformBufferSize / 4; sh->BufferInterfaceBlocks[i].UniformBufferSize / 4;
} }
} }
} }
@@ -1183,18 +1183,18 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
if (prog->_LinkedShaders[i] == NULL) if (prog->_LinkedShaders[i] == NULL)
continue; continue;
parcel.start_shader((gl_shader_stage)i); parcel.start_shader((gl_shader_stage)i);
foreach_in_list(ir_instruction, node, prog->_LinkedShaders[i]->ir) { foreach_in_list(ir_instruction, node, prog->_LinkedShaders[i]->ir) {
ir_variable *const var = node->as_variable(); ir_variable *const var = node->as_variable();
if ((var == NULL) || (var->data.mode != ir_var_uniform && if ((var == NULL) || (var->data.mode != ir_var_uniform &&
var->data.mode != ir_var_shader_storage)) var->data.mode != ir_var_shader_storage))
continue; continue;
parcel.set_and_process(var); parcel.set_and_process(var);
} }
prog->_LinkedShaders[i]->active_samplers = parcel.shader_samplers_used; prog->_LinkedShaders[i]->active_samplers = parcel.shader_samplers_used;