diff options
author | marha <marha@users.sourceforge.net> | 2014-07-28 21:23:36 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2014-07-28 21:32:18 +0200 |
commit | 777fcfa17aafab62719446e00068f5e61ec946d5 (patch) | |
tree | ca0ed3fea46b207daa6cd5bc05382e2d60a1e87f /mesalib/src/glsl | |
parent | 61c36feba19d918885022042ea62d068a698c83d (diff) | |
parent | b33b8d8ae86876b50df96881b96074b3fe177cce (diff) | |
download | vcxsrv-777fcfa17aafab62719446e00068f5e61ec946d5.tar.gz vcxsrv-777fcfa17aafab62719446e00068f5e61ec946d5.tar.bz2 vcxsrv-777fcfa17aafab62719446e00068f5e61ec946d5.zip |
Merge remote-tracking branch 'origin/released'
Conflicts:
xorg-server/include/servermd.h
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r-- | mesalib/src/glsl/ast_array_index.cpp | 3 | ||||
-rw-r--r-- | mesalib/src/glsl/ast_to_hir.cpp | 2 | ||||
-rw-r--r-- | mesalib/src/glsl/builtin_variables.cpp | 6 | ||||
-rw-r--r-- | mesalib/src/glsl/ir_validate.cpp | 1 | ||||
-rw-r--r-- | mesalib/src/glsl/link_uniform_block_active_visitor.cpp | 50 | ||||
-rw-r--r-- | mesalib/src/glsl/link_uniform_blocks.cpp | 6 | ||||
-rw-r--r-- | mesalib/src/glsl/lower_ubo_reference.cpp | 56 |
7 files changed, 82 insertions, 42 deletions
diff --git a/mesalib/src/glsl/ast_array_index.cpp b/mesalib/src/glsl/ast_array_index.cpp index f3b060ea6..50f9987c8 100644 --- a/mesalib/src/glsl/ast_array_index.cpp +++ b/mesalib/src/glsl/ast_array_index.cpp @@ -181,7 +181,8 @@ _mesa_ast_array_index_to_hir(void *mem_ctx, if (array->type->is_unsized_array()) { _mesa_glsl_error(&loc, state, "unsized array index must be constant"); } else if (array->type->fields.array->is_interface() - && array->variable_referenced()->data.mode == ir_var_uniform) { + && array->variable_referenced()->data.mode == ir_var_uniform + && !state->is_version(400, 0) && !state->ARB_gpu_shader5_enable) { /* Page 46 in section 4.3.7 of the OpenGL ES 3.00 spec says: * * "All indexes used to index a uniform block array must be diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp index 328cd1b1b..a15ee9c05 100644 --- a/mesalib/src/glsl/ast_to_hir.cpp +++ b/mesalib/src/glsl/ast_to_hir.cpp @@ -5212,7 +5212,7 @@ ast_process_structure_or_interface_block(exec_list *instructions, fields[i].row_major = false; } - i++; + i++; } } diff --git a/mesalib/src/glsl/builtin_variables.cpp b/mesalib/src/glsl/builtin_variables.cpp index 34973023f..4c5b9c070 100644 --- a/mesalib/src/glsl/builtin_variables.cpp +++ b/mesalib/src/glsl/builtin_variables.cpp @@ -672,6 +672,12 @@ builtin_variable_generator::generate_constants() } if (state->is_version(430, 0) || state->ARB_compute_shader_enable) { + add_const("gl_MaxComputeAtomicCounterBuffers", MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS); + add_const("gl_MaxComputeAtomicCounters", MAX_COMPUTE_ATOMIC_COUNTERS); + add_const("gl_MaxComputeImageUniforms", MAX_COMPUTE_IMAGE_UNIFORMS); + add_const("gl_MaxComputeTextureImageUnits", MAX_COMPUTE_TEXTURE_IMAGE_UNITS); + add_const("gl_MaxComputeUniformComponents", MAX_COMPUTE_UNIFORM_COMPONENTS); + add_const_ivec3("gl_MaxComputeWorkGroupCount", state->Const.MaxComputeWorkGroupCount[0], state->Const.MaxComputeWorkGroupCount[1], diff --git a/mesalib/src/glsl/ir_validate.cpp b/mesalib/src/glsl/ir_validate.cpp index 37e1ce33e..4f85b7db8 100644 --- a/mesalib/src/glsl/ir_validate.cpp +++ b/mesalib/src/glsl/ir_validate.cpp @@ -495,7 +495,6 @@ ir_validate::visit_leave(ir_expression *ir) break; case ir_binop_ubo_load: - assert(ir->operands[0]->as_constant()); assert(ir->operands[0]->type == glsl_type::uint_type); assert(ir->operands[1]->type == glsl_type::uint_type); diff --git a/mesalib/src/glsl/link_uniform_block_active_visitor.cpp b/mesalib/src/glsl/link_uniform_block_active_visitor.cpp index d19ce20c7..854309f9b 100644 --- a/mesalib/src/glsl/link_uniform_block_active_visitor.cpp +++ b/mesalib/src/glsl/link_uniform_block_active_visitor.cpp @@ -109,32 +109,44 @@ link_uniform_block_active_visitor::visit_enter(ir_dereference_array *ir) assert((b->num_array_elements == 0) == (b->array_elements == NULL)); assert(b->type != NULL); - /* Determine whether or not this array index has already been added to the - * list of active array indices. At this point all constant folding must - * have occured, and the array index must be a constant. - */ ir_constant *c = ir->array_index->as_constant(); - assert(c != NULL); - const unsigned idx = c->get_uint_component(0); + if (c) { + /* Index is a constant, so mark just that element used, if not already */ + const unsigned idx = c->get_uint_component(0); - unsigned i; - for (i = 0; i < b->num_array_elements; i++) { - if (b->array_elements[i] == idx) - break; - } + unsigned i; + for (i = 0; i < b->num_array_elements; i++) { + if (b->array_elements[i] == idx) + break; + } - assert(i <= b->num_array_elements); + assert(i <= b->num_array_elements); - if (i == b->num_array_elements) { - b->array_elements = reralloc(this->mem_ctx, - b->array_elements, - unsigned, - b->num_array_elements + 1); + if (i == b->num_array_elements) { + b->array_elements = reralloc(this->mem_ctx, + b->array_elements, + unsigned, + b->num_array_elements + 1); - b->array_elements[b->num_array_elements] = idx; + b->array_elements[b->num_array_elements] = idx; - b->num_array_elements++; + b->num_array_elements++; + } + } else { + /* The array index is not a constant, so mark the entire array used. */ + assert(b->type->is_array()); + if (b->num_array_elements < b->type->length) { + b->num_array_elements = b->type->length; + b->array_elements = reralloc(this->mem_ctx, + b->array_elements, + unsigned, + b->num_array_elements); + + for (unsigned i = 0; i < b->num_array_elements; i++) { + b->array_elements[i] = i; + } + } } return visit_continue_with_parent; diff --git a/mesalib/src/glsl/link_uniform_blocks.cpp b/mesalib/src/glsl/link_uniform_blocks.cpp index 53a18c934..fef3626bf 100644 --- a/mesalib/src/glsl/link_uniform_blocks.cpp +++ b/mesalib/src/glsl/link_uniform_blocks.cpp @@ -92,13 +92,13 @@ private: unsigned len = strlen(close_bracket + 1) + 1; memmove(open_bracket, close_bracket + 1, len); - } else { + } else { v->IndexName = v->Name; } const unsigned alignment = record_type - ? record_type->std140_base_alignment(v->RowMajor) - : type->std140_base_alignment(v->RowMajor); + ? 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); diff --git a/mesalib/src/glsl/lower_ubo_reference.cpp b/mesalib/src/glsl/lower_ubo_reference.cpp index 90e65bd0e..67b752d3d 100644 --- a/mesalib/src/glsl/lower_ubo_reference.cpp +++ b/mesalib/src/glsl/lower_ubo_reference.cpp @@ -57,7 +57,7 @@ public: void *mem_ctx; struct gl_shader *shader; struct gl_uniform_buffer_variable *ubo_var; - unsigned uniform_block; + ir_rvalue *uniform_block; bool progress; }; @@ -69,9 +69,11 @@ public: * \c UniformBlocks array. */ static const char * -interface_field_name(void *mem_ctx, char *base_name, ir_dereference *d) +interface_field_name(void *mem_ctx, char *base_name, ir_dereference *d, + ir_rvalue **nonconst_block_index) { - ir_constant *previous_index = NULL; + ir_rvalue *previous_index = NULL; + *nonconst_block_index = NULL; while (d != NULL) { switch (d->ir_type) { @@ -79,13 +81,21 @@ interface_field_name(void *mem_ctx, char *base_name, ir_dereference *d) ir_dereference_variable *v = (ir_dereference_variable *) d; if (previous_index && v->var->is_interface_instance() - && v->var->type->is_array()) - return ralloc_asprintf(mem_ctx, - "%s[%d]", - base_name, - previous_index->get_uint_component(0)); - else + && v->var->type->is_array()) { + + ir_constant *const_index = previous_index->as_constant(); + if (!const_index) { + *nonconst_block_index = previous_index; + return ralloc_asprintf(mem_ctx, "%s[0]", base_name); + } else { + return ralloc_asprintf(mem_ctx, + "%s[%d]", + base_name, + const_index->get_uint_component(0)); + } + } else { return base_name; + } break; } @@ -101,7 +111,8 @@ interface_field_name(void *mem_ctx, char *base_name, ir_dereference *d) ir_dereference_array *a = (ir_dereference_array *) d; d = a->array->as_dereference(); - previous_index = a->array_index->as_constant(); + previous_index = a->array_index; + break; } @@ -131,14 +142,24 @@ lower_ubo_reference_visitor::handle_rvalue(ir_rvalue **rvalue) mem_ctx = ralloc_parent(*rvalue); + ir_rvalue *nonconst_block_index; const char *const field_name = interface_field_name(mem_ctx, (char *) var->get_interface_type()->name, - deref); + deref, &nonconst_block_index); - this->uniform_block = -1; + this->uniform_block = NULL; for (unsigned i = 0; i < shader->NumUniformBlocks; i++) { if (strcmp(field_name, shader->UniformBlocks[i].Name) == 0) { - this->uniform_block = i; + + ir_constant *index = new(mem_ctx) ir_constant(i); + + if (nonconst_block_index) { + if (nonconst_block_index->type != glsl_type::uint_type) + nonconst_block_index = i2u(nonconst_block_index); + this->uniform_block = add(nonconst_block_index, index); + } else { + this->uniform_block = index; + } struct gl_uniform_block *block = &shader->UniformBlocks[i]; @@ -149,7 +170,7 @@ lower_ubo_reference_visitor::handle_rvalue(ir_rvalue **rvalue) } } - assert(this->uniform_block != (unsigned) -1); + assert(this->uniform_block); ir_rvalue *offset = new(mem_ctx) ir_constant(0u); unsigned const_offset = 0; @@ -267,11 +288,12 @@ ir_expression * lower_ubo_reference_visitor::ubo_load(const glsl_type *type, ir_rvalue *offset) { + ir_rvalue *block_ref = this->uniform_block->clone(mem_ctx, NULL); return new(mem_ctx) ir_expression(ir_binop_ubo_load, - type, - new(mem_ctx) ir_constant(this->uniform_block), - offset); + type, + block_ref, + offset); } |