summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* build: fix make-check after a6a6a71Rob Clark2015-10-171-0/+5
| | | | | | | | | | | | | commit a6a6a71092ba912803ae2b47eb56e3afdf36feb5 Author: Rob Clark <[email protected]> AuthorDate: Sat Oct 10 14:13:50 2015 -0400 glsl: (mostly) remove libglsl_util Was a bit too ambitious on removal of libglsl_util.. it is still needed by some of the tests. Signed-off-by: Rob Clark <[email protected]>
* glsl: (mostly) remove libglsl_utilRob Clark2015-10-161-6/+0
| | | | | | | | | | | Now that NIR does not depend on glsl, we can (mostly[*]) get rid of the libglsl_util hack. [*] glsl_compiler is the one remaining user of libglsl_util Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Signed-off-by: Rob Clark <[email protected]>
* nir: remove dependency on glslRob Clark2015-10-167-6/+5
| | | | | | | | | | | | | | | Move glsl_types into NIR, now that the dependency on glsl_symbol_table has been split out. Possibly makes sense to rename things at this point, but if we do that I'd like to keep it split out into a separate patch to make git history easier to follow (IMHO). v2: fix android build v3: I f***ing hate scons.. but at least it builds Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Rob Clark <[email protected]>
* glsl: move half<->float convertion to utilRob Clark2015-10-163-0/+3
| | | | | | | | Needed in NIR too, so move out of mesa/main/imports.c Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Signed-off-by: Rob Clark <[email protected]>
* glsl: move builtin vector types to glsl_types.cppRob Clark2015-10-162-3/+15
| | | | | | | | | | | First step at untangling NIR's dependency on glsl_types without bringing in the dependency on glsl_symbol_table. The builtin types are now in glsl_types (which will end up in NIR), but adding them to the symbol- table stays in builtin_types.cpp (which will not be part of NIR). Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Signed-off-by: Rob Clark <[email protected]>
* glsl: couple shader_enums cleanupsRob Clark2015-10-162-0/+15
| | | | | | | | | | | | Add missing enum to gl_system_value_name() and move VARYING_SLOT_MAX / FRAG_RESULT_MAX / etc into shader_enums.h as suggested by Emil. v2: add STATIC_ASSERT()'s Reported-by: Emil Velikov <[email protected]> Acked-by: Emil Velikov <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Rob Clark <[email protected]>
* glsl: initialise record array count to 1Timothy Arceri2015-10-171-0/+1
| | | | | | | | | This was only being done in one of the two process methods. Fixes an issue with samplers using the array size of a previous record. Tested-by: Marek Olšák <[email protected]> Cc: Jason Ekstrand <[email protected]>
* nir: add atomic lowering support for AoATimothy Arceri2015-10-171-10/+12
| | | | | Cc: Francisco Jerez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: wrapper for glsl_type arrays_of_arrays_size()Timothy Arceri2015-10-172-0/+8
| | | | | Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: silence warning about unhandled ast_unsized_array_dim case in switchBrian Paul2015-10-161-0/+3
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* glsl: fix check SSBOs support for builtin functionsSamuel Iglesias Gonsalvez2015-10-161-1/+1
| | | | | | | | | | | | | | | | has_shader_storage_buffer_objects() returns true also if the OpenGL context is 4.30 or ES 3.1. Previously, we were saying that all atomic*() GLSL builtin functions for SSBOs were not available when OpenGL ES 3.1 context was in use. Fixes 48 dEQP-GLES31 tests: dEQP-GLES31.functional.ssbo.atomic.* Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir: Get the number of SSBOs and UBOs rightIago Toral Quiroga2015-10-161-2/+2
| | | | | | | | | | | Before d31f98a272e429d and 56e2bdbca36a20 we had a sigle index space for UBOs and SSBOs, so NumBufferInterfaceBlocks would contain the combined number of blocks, not just one kind. This means that for shader programs using both UBOs and SSBOs, we were setting num_ssbos and num_ubos to a larger number than we should. Since the above commits we have separate index spaces for each so we can just get the right numbers. Reviewed-by: Jason Ekstrand <[email protected]>
* nir/glsl: Use shader_prog->Name for naming the NIR shaderJason Ekstrand2015-10-151-1/+1
| | | | | | | This has the better name to use. Aparently, sh->Name is usually 0. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Neil Roberts <[email protected]>
* nir: Add helpers for creating variables and adding them to listsJason Ekstrand2015-10-153-34/+92
| | | | Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir: include nir_instr_set.h in the tarballEmil Velikov2015-10-151-0/+1
| | | | Signed-off-by: Emil Velikov <[email protected]>
* glsl: Allow arrays of arrays in GLSL ES 3.10 and GLSL 4.30Timothy Arceri2015-10-153-18/+20
| | | | | | | | | | V3: use a check_*_allowed style function for requirements checking rather than has_* which doesn't encapsulate the error message V2: add missing 's' to the extension name in error messages and add decimal place in version string Reviewed-by: Marta Lofstedt <[email protected]>
* glsl: allow for AoA in calculating offset to ubo start regionTimothy Arceri2015-10-151-2/+1
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: build ubo name and indexing offset for AoATimothy Arceri2015-10-151-30/+86
| | | | | | V2: split out unrelated change as suggested by Samuel Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: link uniform block arrays of arraysTimothy Arceri2015-10-153-112/+229
| | | | | | | This adds support for setting up the UniformBlock structures for AoA and also adds support for resizing AoA blocks with a packed layout. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: Add AoA support when checking for non-const indexTimothy Arceri2015-10-151-1/+1
| | | | | | | When checking for non-const indexing of interfaces take into account arrays of arrays Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: Add support for lowering interface block arrays of arraysTimothy Arceri2015-10-151-14/+38
| | | | | | V2: make array processing functions static Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: add AoA support for an inteface with unsized array membersTimothy Arceri2015-10-151-4/+12
| | | | | | | | | Add support for setting the max access of an unsized member of an interface array of arrays. For example ifc[j][k].foo[i] where foo is unsized. Reviewed-by: Ian Romanick <[email protected]>
* glsl: add AoA support for linking interface blocks with unsized membersTimothy Arceri2015-10-152-6/+7
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: avoid hitting assert for arrays of arraysTimothy Arceri2015-10-151-0/+6
| | | | | | | Also add TODO comment about adding proper support Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: add AoA support for atomic countersTimothy Arceri2015-10-151-23/+54
| | | | | | | | | | | | | | This marks all counters in an AoA as active. For AoA all but the innermost array are treated as separate counters/uniforms. The Nvidia binary also goes further and finds inactive counters in the AoA, in future we should do this too, however this gets things working for the time being. This change also removes the use of UniformHash for atomic counters, this avoids having to generate name strings used as hash keys. Reviewed-by: Ian Romanick <[email protected]>
* glsl: add std140 layout support for AoATimothy Arceri2015-10-151-7/+8
| | | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: calculate AoA uniform offset correctly for structsTimothy Arceri2015-10-151-1/+16
| | | | | | | This allows the correct offset to be calculated for use in indirect indexing of samplers. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: remove dead code in a single passTimothy Arceri2015-10-154-17/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently only one ir assignment is removed for each var in a single dead code optimisation pass. This means if a var has more than one assignment, then it requires all the glsl optimisations to be run again for each additional assignment to be removed. Another pass is also required to remove the variable itself. With this change all assignments and the variable are removed in a single pass. Some of the arrays of arrays conformance tests that were looping through 8 dimensions ended up with a var with hundreds of assignments. This change helps ES31-CTS.arrays_of_arrays.InteractionFunctionCalls1 go from around 3 min 20 sec -> 2 min ES31-CTS.arrays_of_arrays.InteractionFunctionCalls2 went from around 9 min 20 sec to 7 min 30 sec I had difficulty getting the public shader-db to give a consistent result with or without this change but the results seemed unchanged at between 15-20 seconds. Thomas Helland measured change with shader-db on his machine from approx 117 secs to 112 secs. V3: Simplify freeing of list as suggested by Ian, and spelling fixes. V2: Add assert to be sure references are counted before assignments. Reviewed-by: Ian Romanick <[email protected]> Tested-By: Thomas Helland <[email protected]> Tested-by: Ian Romanick <[email protected]>
* glsl: dont allow gl_PerVertex to be redeclared as an array of arraysTimothy Arceri2015-10-152-1/+8
| | | | | | | | | | V3: move patch after fixes to ast for AoA and add const to helper as suggested by Ian V2: move single dimensional array detection into a helper Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: check that only the outermost array is unsizedTimothy Arceri2015-10-151-0/+22
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: allow AoA to be sized by initializer or constructorTimothy Arceri2015-10-155-41/+82
| | | | | | | V2: Split out unsized array validation to its own patch as suggested by Samuel. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: add support for initialising sampler AoATimothy Arceri2015-10-151-34/+49
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add support for linking uniform arrays of arraysTimothy Arceri2015-10-152-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | V3: Fix setting of data.location for struct AoA UBO members V2: Handle arrays of arrays in the same way structures are handled The ARB_arrays_of_arrays spec doesn't give very many details on how AoA uniforms are intended to be implemented. However in the ARB_program_interface_query spec there are details that show AoA are intended to be handled in a similar way to structs. Issues 7 from the ARB_program_interface_query spec: We define rules consistent with our enumeration rules for other complex types. For existing one-dimensional arrays, we enumerate a single entry if the array is an array of basic types, or separate entries for each array element if the array is an array of structures. We follow similar rules here. For a uniform array such as: uniform vec4 a[5][4][3]; we enumerate twenty different entries ("a[0][0][0]" through "a[4][3][0]"), each of which is treated as an array with three elements. This is morally equivalent to what you'd get if you worked around the limitation in current GLSL via: struct ArrayBottom { vec4 c[3]; }; struct ArrayMid { ArrayBottom b[3]; }; uniform ArrayMid a[5]; which would enumerate "a[0].b[0].c[0]" through "a[4].b[3].c[0]". Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Support uint index in lower_vector_insertJordan Justen2015-10-141-1/+5
| | | | | | | | | The ES31-CTS.compute_shader.pipeline-compute-chain test case generates an unsigned index by using gl_LocalInvocationID.x and gl_LocalInvocationID.y as array indices. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Support uint index in do_vec_index_to_cond_assignJordan Justen2015-10-141-1/+3
| | | | | | | | | The ES31-CTS.compute_shader.pipeline-compute-chain test case generates an unsigned index by using gl_LocalInvocationID.x and gl_LocalInvocationID.y as array indices. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Enable split of lower UBOs and SSBO also for compute shadersMarta Lofstedt2015-10-141-1/+1
| | | | | | | | | | | | | The split of Uniform blocks and shader storage block only loops up to MESA_SHADER_FRAGMENT and igonres compute shaders. This cause segfault when running the OpenGL ES 3.1 CTS tests with GL_ARB_compute_shader enabled. V2: Changed to use MESA_SHADER_STAGES instead of MESA_SHADER_COMPUTE Reviewed-by: Francisco Jerez <[email protected]> Signed-off-by: Marta Lofstedt <[email protected]>
* glsl: Include util/strndup.h.Jose Fonseca2015-10-141-0/+1
| | | | | | Fixes Windows builds. Trivial.
* glsl: calculate TOP_LEVEL_ARRAY_SIZE and STRIDE when adding resourcesTapani Pälli2015-10-141-0/+241
| | | | | | | | | | Patch moves existing calculation code from shader_query.cpp to happen during program resource list creation. No Piglit or CTS regressions were observed during testing. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: add top level array size and stride to gl_uniform_storageTapani Pälli2015-10-141-10/+22
| | | | | | | | | | | | Patch adds 2 new fields to gl_uniform_storage so that we don't need to calculate these values during runtime shader queries. This is required by upcoming changes to free GLSL IR after linking. Patch moves 3 booleans inside structure so that structure size stays the same after this change. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl/lower_ubo_reference: lower UBOs and SSBOs to separate index spacesIago Toral Quiroga2015-10-141-8/+14
| | | | Reviewed-by: Kristian Høgsberg <[email protected]>
* mesa: Add {Num}UniformBlocks and {Num}ShaderStorageBlocks to gl_shader{_program}Iago Toral Quiroga2015-10-142-0/+70
| | | | | | These arrays provide backends with separate index spaces for UBOS and SSBOs. Reviewed-by: Kristian Høgsberg <[email protected]>
* mesa: Rename {Num}UniformBlocks to {Num}BufferInterfaceBlocksIago Toral Quiroga2015-10-146-42/+42
| | | | | | | | | | | | | | Currently, these arrays in gl_shader and gl_shader_program hold both UBOs and SSBOs, so this looks like a better name. We were already using NumBufferInterfaceBlocks in gl_shader_program, so this makes things more consistent as well. In a later patch we will add {Num}UniformBlocks and {Num}ShaderStorageBlocks which will contain only references to UBOs and SSBOs respectively that will provide backends with a separate index space for both types of objects. Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Fix variable_referenced() for vector_{extract,insert} expressionsIago Toral Quiroga2015-10-142-0/+18
| | | | | | | | | | | | | | We get these when we operate on vector variables with array accessors (i.e. things like a[0] where 'a' is a vec4). When we call variable_referenced() on these expressions we want to return a reference to 'a' instead of NULL. This fixes a problem where we pass a[0] as the first argument to an atomic SSBO function that expects a buffer variable. In order to check this, we use variable_referenced(), but that is currently returning NULL in this case, since the underlying rvalue is a vector_extract expression. Tested-by: Markus Wick <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* nir: split SSBO min/max atomic instrinsics into signed/unsigned versionsIago Toral Quiroga2015-10-142-6/+22
| | | | | | | | | | | | | NIR is typeless so this is the only way to keep track of the type to select the proper atomic to use. v2: - Use imin,imax,umin,umax for the intrinsic names (Connor Abbott) - Change message for unreachable paths (Michael Schellenberger) Tested-by: Markus Wick <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: fix matrix stride calculation for std430's row_major matrices with two ↵Samuel Iglesias Gonsalvez2015-10-131-1/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | columns This is the result of applying several rules: From OpenGL 4.3 spec, section 7.6.2.2 "Standard Uniform Block Layout": "2. If the member is a two- or four-component vector with components consuming N basic machine units, the base alignment is 2N or 4N, respectively." [...] "4. If the member is an array of scalars or vectors, the base alignment and array stride are set to match the base alignment of a single array element, according to rules (1), (2), and (3), and rounded up to the base alignment of a vec4." [...] "7. If the member is a row-major matrix with C columns and R rows, the matrix is stored identically to an array of R row vectors with C components each, according to rule (4)." [...] "When using the std430 storage layout, shader storage blocks will be laid out in buffer storage identically to uniform and shader storage blocks using the std140 layout, except that the base alignment and stride of arrays of scalars and vectors in rule 4 and of structures in rule 9 are not rounded up a multiple of the base alignment of a vec4." In summary: vec2 has a base alignment of 2*N, a row-major mat2xY is stored like an array of Y row vectors with 2 components each. Because of std430 storage layout, the base alignment of the array of vectors is not rounded up to vec4, so it is still 2*N. Fixes 15 dEQP tests: dEQP-GLES31.functional.ssbo.layout.single_basic_type.std430.row_major_lowp_mat2 dEQP-GLES31.functional.ssbo.layout.single_basic_type.std430.row_major_mediump_mat2 dEQP-GLES31.functional.ssbo.layout.single_basic_type.std430.row_major_highp_mat2 dEQP-GLES31.functional.ssbo.layout.single_basic_type.std430.row_major_lowp_mat2x3 dEQP-GLES31.functional.ssbo.layout.single_basic_type.std430.row_major_mediump_mat2x3 dEQP-GLES31.functional.ssbo.layout.single_basic_type.std430.row_major_highp_mat2x3 dEQP-GLES31.functional.ssbo.layout.single_basic_type.std430.row_major_lowp_mat2x4 dEQP-GLES31.functional.ssbo.layout.single_basic_type.std430.row_major_mediump_mat2x4 dEQP-GLES31.functional.ssbo.layout.single_basic_type.std430.row_major_highp_mat2x4 dEQP-GLES31.functional.ssbo.layout.single_basic_array.std430.row_major_mat2 dEQP-GLES31.functional.ssbo.layout.single_basic_array.std430.row_major_mat2x3 dEQP-GLES31.functional.ssbo.layout.single_basic_array.std430.row_major_mat2x4 dEQP-GLES31.functional.ssbo.layout.instance_array_basic_type.std430.row_major_mat2 dEQP-GLES31.functional.ssbo.layout.instance_array_basic_type.std430.row_major_mat2x3 dEQP-GLES31.functional.ssbo.layout.instance_array_basic_type.std430.row_major_mat2x4 v2: - Add spec quote in both commit log and code (Timothy) Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Marta Lofstedt <[email protected]>
* glsl: Never allow the sequence operator anywhere in an array sizeIan Romanick2015-10-121-1/+1
| | | | | | | | | | | Fixes: spec/glsl-1.20/compiler/structure-and-array-operations/array-size-sequence-in-parenthesis.vert spec/glsl-es-1.00/compiler/array-sized-by-sequence-in-parenthesis.vert spec/glsl-es-3.00/compiler/array-sized-by-sequence-in-parenthesis.vert Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: In later GLSL versions, sequence operator is cannot be a constant ↵Ian Romanick2015-10-121-1/+42
| | | | | | | | | | | | | | | | | expression Fixes: ES3-CTS.shaders.negative.constant_sequence spec/glsl-es-3.00/compiler/global-initializer/from-sequence.vert spec/glsl-es-3.00/compiler/global-initializer/from-sequence.frag v2: Fix a couple copy-and-paste mistake in the spec quotations. Suggested by Matt. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Cc: "10.6 11.0" <[email protected]>
* glsl: Add method to determine whether an expression contains the sequence ↵Ian Romanick2015-10-123-0/+97
| | | | | | | | | | | | | | | | | operator This will be used in the next patch to enforce some language sematics. v2: Fix inverted logic in ast_function_expression::has_sequence_subexpression. The method originally had a different name and a different meaning. I fixed the logic in ast_to_hir.cpp, but I only changed the names in ast_function.cpp. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Marta Lofstedt <[email protected]> [v1] Reviewed-by: Matt Turner <[email protected]> Cc: "10.6 11.0" <[email protected]>
* glsl: Restrict initializers for global variables to constant expression in ESIan Romanick2015-10-121-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | v2: Combine this check with the existing const and uniform checks. This change depends on the previous patch (glsl: Only set ir_variable::constant_value for const-decorated variables). Fixes: ES2-CTS.shaders.negative.initialize ES3-CTS.shaders.negative.initialize spec/glsl-es-1.00/compiler/global-initializer/from-attribute.vert spec/glsl-es-1.00/compiler/global-initializer/from-uniform.vert spec/glsl-es-1.00/compiler/global-initializer/from-uniform.frag spec/glsl-es-1.00/compiler/global-initializer/from-global.vert spec/glsl-es-1.00/compiler/global-initializer/from-global.frag spec/glsl-es-1.00/compiler/global-initializer/from-varying.frag spec/glsl-es-3.00/compiler/global-initializer/from-uniform.vert spec/glsl-es-3.00/compiler/global-initializer/from-uniform.frag spec/glsl-es-3.00/compiler/global-initializer/from-in.vert spec/glsl-es-3.00/compiler/global-initializer/from-in.frag spec/glsl-es-3.00/compiler/global-initializer/from-global.vert spec/glsl-es-3.00/compiler/global-initializer/from-global.frag Note: spec/glsl-es-3.00/compiler/global-initializer/from-sequence.* still fail because the result of a sequence operator is still considered to be a constant expression. Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92304 Reviewed-by: Tapani Pälli <[email protected]> [v1] Reviewed-by: Iago Toral Quiroga <[email protected]> [v1] Reviewed-by: Matt Turner <[email protected]> Cc: "10.6 11.0" <[email protected]>
* glsl: Only set ir_variable::constant_value for const-decorated variablesIan Romanick2015-10-121-3/+6
| | | | | | | | | | Right now we're also setting for uniforms, and that doesn't seem to hurt things. The next patch will make general global variables in GLSL ES, and those definitely should not have constant_value set! Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Cc: "10.6 11.0" <[email protected]>