summaryrefslogtreecommitdiffstats
path: root/src/glsl/lower_ubo_reference.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Strip arrayness from ir_type_dereference_variable tooIan Romanick2014-09-261-1/+1
| | | | | | | | | | | | If the thing being dereferenced is a record or an array of records, it should be treated as row-major. The ir_type_derference_record path already does this, and I think I intended to do the same for this path in b17a4d5d. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83741 Cc: [email protected]
* glsl: Make sure row-major array-of-structure get correct layoutIan Romanick2014-09-261-1/+8
| | | | | | | | | | | Whether or not the field is row-major (because it might be a bvec2 or something) does not affect the array itself. We need to know whether an array element in its entirety is row-major. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83506 Cc: [email protected]
* glsl: Make sure fields after small structs have correct paddingIan Romanick2014-09-261-0/+22
| | | | | | | | | | | Previously the linker would correctly calculate the layout, but the lower_ubo_reference pass would not apply correct alignment to fields following small (less than 16-byte) nested structures. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83533 Cc: [email protected]
* glsl: Do not add extra padding to structuresIan Romanick2014-08-041-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This code was attemping to align the base of the structure to the required alignment of the structure. However, it had two problems: 1. It was aligning the target structure member, not the base of the structure. 2. It was calculating the alignment based on the members previous to the target member instead of all the members of the structure. Fixes gles3conform failures in: ES3-CTS.shaders.uniform_block.random.nested_structs.6 ES3-CTS.shaders.uniform_block.random.nested_structs_arrays_instance_arrays.2 ES3-CTS.shaders.uniform_block.random.nested_structs_arrays_instance_arrays.6 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.5 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.19 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.0 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.2 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.6 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.12 v2: Fix rebase failure noticed by Matt. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Correctly determine when the field of a UBO is row-majorIan Romanick2014-08-041-15/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously if a field of an block with an instance name was marked row-major (but block itself was not), we would think the field (and it's sub-fields) were column-major. Fixes gles3conform failures in: ES3-CTS.shaders.uniform_block.random.basic_types.7 ES3-CTS.shaders.uniform_block.random.basic_types.9 ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.1 ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.3 ES3-CTS.shaders.uniform_block.random.nested_structs.3 ES3-CTS.shaders.uniform_block.random.nested_structs.5 ES3-CTS.shaders.uniform_block.random.nested_structs.8 ES3-CTS.shaders.uniform_block.random.nested_structs_arrays.3 ES3-CTS.shaders.uniform_block.random.nested_structs_arrays.6 ES3-CTS.shaders.uniform_block.random.nested_structs_arrays.7 ES3-CTS.shaders.uniform_block.random.nested_structs_arrays.8 ES3-CTS.shaders.uniform_block.random.nested_structs_arrays.9 ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.0 ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.1 ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.2 ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.3 ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.4 ES3-CTS.shaders.uniform_block.random.nested_structs_instance_arrays.6 ES3-CTS.shaders.uniform_block.random.nested_structs_arrays_instance_arrays.0 ES3-CTS.shaders.uniform_block.random.nested_structs_arrays_instance_arrays.1 ES3-CTS.shaders.uniform_block.random.nested_structs_arrays_instance_arrays.5 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.0 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.4 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.7 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.8 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.12 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.14 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.15 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.16 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.1 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.8 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.9 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.10 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.11 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.13 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.14 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.15 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.16 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.17 Fixes gles3conform failures (caused by previous commits) in: ES3-CTS.shaders.uniform_block.random.basic_types.8 ES3-CTS.shaders.uniform_block.random.basic_arrays.3 ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.0 ES3-CTS.shaders.uniform_block.random.basic_instance_arrays.2 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.9 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.13 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.18 ES3-CTS.shaders.uniform_block.random.all_shared_buffer.4 v2: Fix rebase failure noticed by Matt. v3: Use without_array() instead of older predicates. v4: s/GLSL_MATRIX_LAYOUT_DEFAULT/GLSL_MATRIX_LAYOUT_INHERITED/g Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> [v2]
* glsl: Correctly load columns of a row-major matrixIan Romanick2014-08-041-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For a row-major matrix, the next column starts at the next element. Fixes gles3conform failures in: ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat2 ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat3 ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat4 ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat2x3 ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat2x4 ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat3x2 ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat3x4 ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat4x2 ES3-CTS.shaders.uniform_block.single_basic_array.shared.row_major_mat4x3 ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat2 ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat3 ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat4 ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat2x3 ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat2x4 ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat3x2 ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat3x4 ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat4x2 ES3-CTS.shaders.uniform_block.single_basic_array.packed.row_major_mat4x3 ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat2 ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat3 ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat4 ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat2x3 ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat2x4 ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat3x2 ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat3x4 ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat4x2 ES3-CTS.shaders.uniform_block.single_basic_array.std140.row_major_mat4x3 ES3-CTS.shaders.uniform_block.random.all_per_block_buffers.9 Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Use constant_expression_value instead of as_constantIan Romanick2014-08-041-1/+2
| | | | | | | | | Just a few lines earlier we may have wrapped the index expression with ir_unop_i2u expression. Whenever that happens, as_constant will return NULL, and that almost always happens. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* glsl: Accept nonconstant array references in lower_ubo_referenceChris Forbes2014-07-261-11/+32
| | | | | | | | | | | | Instead of falling back to just the block name (which we won't find), look for the first element of the block array. We'll deal with the rest in the backend by arranging for the blocks to be laid out contiguously. V2: Squashed together patches 3, 5 of V1, plus a naming tweak. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Convert uniform_block in lower_ubo_reference to ir_rvalue.Chris Forbes2014-07-261-7/+8
| | | | | | | | | | Previously this was a block index with special semantics for -1. With ARB_gpu_shader5, this need not be a compile-time constant, so allow any rvalue here and convert the -1 to a NULL pointer. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fix lack of i2u in lower_ubo_reference.Kenneth Graunke2014-04-081-3/+7
| | | | | | | | | | | | | | | | | ir_binop_ubo_load takes unsigned integer operands. However, the array index used to compute these offsets may be a signed integer. (For example, see Piglit's spec/glsl-1.40/uniform_buffer/fs-bvec-array). For some reason, we were missing an ir_binop_i2u cast, and ir_validator was failing to catch that. Without this change, ir_builder's type inference code broke for me when writing a new optimization pass. Cc: [email protected] Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: move variables in to ir_variable::data, part IITapani Pälli2013-12-121-1/+1
| | | | | | | | | | | | | This patch moves following bitfields and variables to the data structure: explicit_location, explicit_index, explicit_binding, has_initializer, is_unmatched_generic_inout, location_frac, from_named_ifc_block_nonarray, from_named_ifc_block_array, depth_layout, location, index, binding, max_array_access, atomic Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Make accessor functions for ir_variable::interface_type.Paul Berry2013-10-091-1/+2
| | | | | | | In a future patch, this will allow us to enforce invariants when the interface type is updated. Reviewed-by: Jordan Justen <[email protected]>
* glsl: Generated masked write instead of vector array index for UBO loweringIan Romanick2013-03-291-7/+3
| | | | | | | | | | | | | | | When reading a column from a row-major matrix, we would slot the single value read into the vector using an ir_dereference_array of the vector with a constant index. This will (eventually) get optimized to a masked-write, so just generate the masked write in the first place. v2: Remove unused variable 'chan'. Suggested by Ken. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Cc: Eric Anholt <[email protected]>
* glsl: Lower UBO references using link-time data instead of compile-time dataIan Romanick2013-01-251-3/+86
| | | | | | | | Pretty much all of the compile-time, per-compilation unit block data is about to get the axe. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: Make the align function available elsewhere in the linkerIan Romanick2013-01-251-12/+7
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Carl Worth <[email protected]>
* glsl: Add ir_variable::is_in_uniform_block predicateIan Romanick2013-01-251-1/+1
| | | | | | | | | The way a variable is tested for this property is about to change, and this makes the code easier to modify. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add a lowering pass to turn complicated UBO references to vector loads.Eric Anholt2012-08-071-0/+313
v2: Reduce the impenetrable code in emit_ubo_loads() by 23 lines by keeping the ir_variable as the variable part of the offset from handle_rvalue(), and track the constant offsets from that with a plain old integer value, avoiding a bunch of temporary variables in the array and struct handling. Also, fix file description doxygen. v3: Fix a row vs col typo, and fix spelling in a comment. Reviewed-by: Eric Anholt <[email protected]>