summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl/linker: Use constant_initializer instead of constant_value to ↵Ian Romanick2015-10-121-2/+2
| | | | | | | | initialize uniforms Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Cc: "10.6 11.0" <[email protected]>
* glsl: Allow built-in functions as constant expressions in OpenGL ES 1.00Ian Romanick2015-10-121-5/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | In d4a24745 (August 2012), Paul made functions calls not be constant expressions in GLSL ES 1.00. Since this feature was added in desktop GLSL 1.20, we believed that it was added in GLSL ES 3.00. That turns out to be completely wrong. Built-in functions have always been allowed as constant expressions in GLSL ES, and the patch adds the (many) spec quotations to prove it. While we never previously encountered this, a later patch enforces a GLSL ES 1.00 rule that global variable initializers must be constant expressions. Without this fix, several dEQP tests fail. Fixes: tests/spec/glsl-es-1.00/compiler/const-initializer/from-function.frag tests/spec/glsl-es-1.00/compiler/const-initializer/from-function.vert tests/spec/glsl-es-1.00/compiler/const-initializer/from-sequence-in-function.frag tests/spec/glsl-es-1.00/compiler/const-initializer/from-sequence-in-function.vert Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Cc: "10.0 10.1 10.2 10.3 10.4 10.5 10.6 11.0" <[email protected]> Yes, I know we don't maintain stable branches that far back, but that *is* how far back this bug goes!
* glsl: include variable name in error messages about initializersIago Toral Quiroga2015-10-121-12/+17
| | | | | | | | Also fix style / wrong indentation along the way and make the messages more uniform. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: shader outputs cannot have initializersIago Toral Quiroga2015-10-121-0/+6
| | | | | | | | | | | | | | GLSL Spec 4.20.8, 4.3 Storage Qualifiers: "Initializers in global declarations may only be used in declarations of global variables with no storage qualifier, with a const qualifier or with a uniform qualifier." We do this for input variables, but not for output variables. AMD and NVIDIA proprietary drivers don't allow this either. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: move shader_enums into nirRob Clark2015-10-094-5/+6
| | | | | | | | | | | | | | | | | | | | First step towards inverting the dependency between glsl and nir (so nir can be used without glsl). Also solves this issue with 'make distclean' Making distclean in mesa make[2]: Entering directory '/mnt/sdb1/Src64/Mesa-git/mesa/src/mesa' Makefile:2486: ../glsl/.deps/shader_enums.Plo: No such file or directory make[2]: *** No rule to make target '../glsl/.deps/shader_enums.Plo'. Stop. make[2]: Leaving directory '/mnt/sdb1/Src64/Mesa-git/mesa/src/mesa' Makefile:684: recipe for target 'distclean-recursive' failed make[1]: *** [distclean-recursive] Error 1 make[1]: Leaving directory '/mnt/sdb1/Src64/Mesa-git/mesa/src' Makefile:615: recipe for target 'distclean-recursive' failed make: *** [distclean-recursive] Error 1 Reported-by: Andy Furniss <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Signed-off-by: Rob Clark <[email protected]>
* nir/instr_set: remove unnecessary check in nir_instrs_equal()Connor Abbott2015-10-091-2/+1
| | | | | | | | | | | | | This was originally added to nir_instrs_equal() instead of nir_instr_can_cse() incorrectly, but this was fixed when moving to the instruction set API (as it had to be, otherwise hashing wouldn't work). Now, this is dead code since instr_can_rewrite() will only return true for texture instructions that use an index, so we can turn the check into an assert. This also means that now nir_instrs_equal(instr, instr) will always return true unless it assert-fails. Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* nir: make nir_instrs_equal() staticConnor Abbott2015-10-092-3/+1
| | | | | | | | | | This was previously tied to CSE, since it would only work for instructions where nir_can_cse() (now instr_can_rewrite()) returned true. Now that CSE uses the instruction set abstraction which only uses this internally, we can make it local to nir_instr_set.c. Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* nir/cse: use the instruction set APIConnor Abbott2015-10-091-115/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | This replaces an O(n^2) algorithm with an O(n) one, while allowing us to import most of the infrastructure required for GVN. The idea is to walk the dominance tree depth-first, similar when converting to SSA, and remove the instructions from the set when we're done visiting the sub-tree of the dominance tree so that the only instructions in the set are the instructions that dominate the current block. No piglit regressions. No shader-db changes. Compilation time for full shader-db: Difference at 95.0% confidence -35.826 +/- 2.16018 -6.2852% +/- 0.378975% (Student's t, pooled s = 3.37504) v2: - rebase on start_block removal - remove useless state struct - change commit message Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* nir: add an instruction set APIConnor Abbott2015-10-092-0/+349
| | | | | | | | | | | | | | | | | | | | | | | This will replace direct usage of nir_instrs_equal() in the CSE pass, which reduces an O(n^2) algorithm with an effectively O(n) one. It'll also be useful for implementing GVN on top of GCM. v2: - Add texture support. - Add more comments. - Rename instr_can_hash() to instr_can_rewrite() since it's really more about whether its uses can be rewritten, and it's implicitly used by nir_instrs_equal() as well. - Rename nir_instr_set_add() to nir_instr_set_add_or_rewrite() (Jason). - Make the HASH() macro less magical (Topi). - Rewrite the commit message. v3: - For sorting phi sources, use a VLA, store pointers to the sources, and compare the predecessor pointer directly (Jason). Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* nir: constify instruction comparison functionsConnor Abbott2015-10-092-4/+4
| | | | | | | | v2: rebase, don't constify nir_srcs_equal() as it's pass-by-value anyways Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* nir: constify nir_ssa_alu_instr_src_components()Connor Abbott2015-10-091-1/+1
| | | | | Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* nir: split out instruction comparison functionsConnor Abbott2015-10-095-181/+237
| | | | | | | | | | | | Right now nir_instrs_equal() is tied pretty tightly to CSE, but we're going to introduce the idea of an instruction set and tie it to that instead. In anticipation of that, move this into its own file where we'll add the rest of the instruction set implementation later. v2: Rebase on texture support. Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* nir: Add a function to determine if a source is dynamically uniformNeil Roberts2015-10-092-0/+30
| | | | | | | | | | | | Adds nir_src_is_dynamically_uniform which returns true if the source is known to be dynamically uniform. This will be used in a later patch to add a workaround for cases that only work with dynamically uniform sources. Note that the function is not definitive, it can return false negatives (but not false positives). Currently it only detects constants and uniform accesses. It could easily be extended to include more cases. Reviewed-by: Matt Turner <[email protected]>
* nir/sweep: Reparent the shader nameJason Ekstrand2015-10-081-0/+2
| | | | | | | | | | Previously the name of the nir shader was being freed prematurely during nir_sweep. Since 756613ed35d the name was later being used to generate filenames for the optimiser debug output and these would end up with garbage from the dangling pointer. Co-authored-by: Neil Roberts <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: add varyings to resource list only with SSOTapani Pälli2015-10-081-4/+7
| | | | | | | | | | | | | | | | | | | | Varyings can be considered inputs or outputs of a program only when SSO is in use. With multi-stage programs, inputs contain only inputs for first stage and outputs contains outputs of the final shader stage. I've tested that fix works for Assault Android Cactus (demo version) and does not cause Piglit or CTS regressions in glGetProgramiv tests. Following ES 3.1 CTS separate shader tests that do query properties of varyings in SSO shader programs pass: ES31-CTS.program_interface_query.separate-programs-vertex ES31-CTS.program_interface_query.separate-programs-fragment Signed-off-by: Tapani Pälli <[email protected]> Tested-by: Dieter Nützel <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92122
* glsl: whitespace/formatting/typo fixes in link_uniforms.cppBrian Paul2015-10-061-6/+9
|
* glsl: add std430 layout support for AoASamuel Iglesias Gonsalvez2015-10-061-5/+7
| | | | | Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Remove CSE pass.Matt Turner2015-10-054-475/+0
| | | | | | | | | | | | | | | | With NIR, it actually hurts things. total instructions in shared programs: 6529329 -> 6528888 (-0.01%) instructions in affected programs: 14833 -> 14392 (-2.97%) helped: 299 HURT: 1 In all affected programs I inspected (including the single hurt one) the pass CSE'd some multiplies and caused some reassociation (e.g., caused (A * B) * C to be A * (B * C)) when the original intermediate result was reused elsewhere. Acked-by: Kenneth Graunke <[email protected]>
* glsl: set glsl error if binding qualifier used on global scopeTapani Pälli2015-10-051-0/+11
| | | | | | | | Fixes following Piglit test: global-scope-binding-qualifier.frag Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: reduce memory footprint of uniform_storage structTimothy Arceri2015-10-056-41/+32
| | | | | | | | The uniform will only be of a single type so store the data for opaque types in a single array. Cc: Francisco Jerez <[email protected]> Cc: Ilia Mirkin <[email protected]>
* nir: Add a nir_shader_info::has_transform_feedback_varyings flag.Kenneth Graunke2015-10-042-0/+5
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* nir: Introduce new nir_intrinsic_load_per_vertex_input intrinsics.Kenneth Graunke2015-10-043-6/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | Geometry and tessellation shaders process multiple vertices; their inputs are arrays indexed by the vertex number. While GLSL makes this look like a normal array, it can be very different behind the scenes. On Intel hardware, all inputs for a particular vertex are stored together - as if they were grouped into a single struct. This means that consecutive elements of these top-level arrays are not contiguous. In fact, they may sometimes be in completely disjoint memory segments. NIR's existing load_input intrinsics are awkward for this case, as they distill everything down to a single offset. We'd much rather keep the vertex ID separate, but build up an offset as normal beyond that. This patch introduces new nir_intrinsic_load_per_vertex_input intrinsics to handle this case. They work like ordinary load_input intrinsics, but have an extra source (src[0]) which represents the outermost array index. v2: Rebase on earlier refactors. v3: Use ssa defs instead of nir_srcs, rebase on earlier refactors. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir/lower_io: Make get_io_offset() return a nir_ssa_def * for indirects.Kenneth Graunke2015-10-041-42/+20
| | | | | | | | | | | | | | | get_io_offset() already walks the dereference chain and discovers whether or not we have an indirect; we can just return that rather than computing it a second time via deref_has_indirect(). This means moving the call a bit earlier. By returning a nir_ssa_def *, we can pass back both an existence flag (via NULL checking the pointer) and the value in one parameter. It also simplifies the code somewhat. nir_lower_samplers works in a similar fashion. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: fix whitespaceTimothy Arceri2015-10-041-1/+1
| | | | Reviewed-by: Iago Toral Quiroga <[email protected]>
* mesa: remove Driver.DeleteShaderMarek Olšák2015-10-033-4/+15
| | | | | | | Nothing overrides it. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* nir: Add a nir_foreach_variable macroJason Ekstrand2015-10-027-18/+21
| | | | | | | This is a common enough operation that it's nice to not have to think about the arguments to foreach_list_typed every time. Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Move GS data to nir_shader_infoJason Ekstrand2015-10-024-14/+11
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Add a a nir_shader_info structJason Ekstrand2015-10-023-0/+53
| | | | | | This commit also adds code to glsl_to_nir and prog_to_nir to fill it out. Reviewed-by: Kenneth Graunke <[email protected]>
* nir/glsl: Take a gl_shader_program and a stage rather than a gl_shaderJason Ekstrand2015-10-022-3/+8
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/types: Make subroutine types have a single matrix columnJason Ekstrand2015-10-021-2/+1
| | | | | | | | | | | | That way, if we do the usual thing of multiplying vector_elements by matrix_columns we get the actual number of components in the type as per component_slots(). While we're at it, we also switch to using the actual C++ field initializers for vector_elements and matrix_columns. Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl: avoid leaking hiddenUniforms map when there are no uniformsIlia Mirkin2015-10-021-4/+4
| | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir: Fix uninitialized 'progress' variable in nir_lower_system_values.Chris Wilson2015-10-021-1/+1
| | | | | | | | | | | | | | | | | | Commit 0a1adaf11d051b71b4c46aabee2e5342f2d6aef3 (nir: Report progress from nir_lower_system_values().) introduced a bug caught by Valgrind: ==823== Conditional jump or move depends on uninitialised value(s) ==823== at 0xB09020C: convert_block (nir_lower_system_values.c:68) ==823== by 0xB079FB8: foreach_cf_node (nir.c:1310) ==823== by 0xB07A0AF: nir_foreach_block (nir.c:1336) ==823== by 0xB09026B: convert_impl (nir_lower_system_values.c:79) ... ==823== Uninitialised value was created by a stack allocation ==823== at 0xB090249: convert_impl (nir_lower_system_values.c:76) which is trivially fixed by initializing progress. Reviewed-by: Kenneth Graunke <[email protected]>
* nir/remove_phis: handle trivial back-edgesConnor Abbott2015-10-021-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some loops may have phi nodes that look like: foo = ... loop { bar = phi(foo, bar) ... } in which case we can remove the phi node and replace all uses of 'bar' with 'foo'. In particular, there are some L4D2 vertex shaders with loops that, after optimization, look like: /* succs: block_1 */ loop { block block_1: /* preds: block_0 block_4 */ vec1 ssa_2195 = phi block_0: ssa_2136, block_4: ssa_994 vec1 ssa_7321 = phi block_0: ssa_8195, block_4: ssa_7321 vec1 ssa_7324 = phi block_0: ssa_8198, block_4: ssa_7324 vec1 ssa_7327 = phi block_0: ssa_8174, block_4: ssa_7327 vec1 ssa_8139 = intrinsic load_uniform () () (232) vec1 ssa_588 = ige ssa_2195, ssa_8139 /* succs: block_2 block_3 */ if ssa_588 { block block_2: /* preds: block_1 */ break /* succs: block_5 */ } else { block block_3: /* preds: block_1 */ /* succs: block_4 */ } block block_4: /* preds: block_3 */ vec1 ssa_994 = iadd ssa_2195, ssa_2150 /* succs: block_1 */ } where after removing the second, third, and fourth phi nodes, the loop becomes entirely dead, and this patch will cause the loop to be deleted entirely. No piglit regressions. Shader-db results on bdw: instructions in affected programs: 5824 -> 5664 (-2.75%) total loops in shared programs: 2234 -> 2202 (-1.43%) helped: 32 Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* glsl: validate binding qualifier on block membersTapani Pälli2015-10-021-0/+4
| | | | | | | | Fixes following Piglit test: member-invalid-binding-qualifier.frag Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: emit row_major matrix's SSBO stores only for components in writemaskSamuel Iglesias Gonsalvez2015-10-021-0/+6
| | | | | | | | | | | | | When writing to a column of a row-major matrix, each component of the vector is stored to non-consecutive memory addresses, so we generate one instruction per component. This patch skips the disabled components in the writemask, saving some store instructions plus avoid storing wrong data on each disabled component. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl: error out if non-constant indexing of SSBO arrays with GLSL ESTapani Pälli2015-10-021-6/+8
| | | | | | | | Fixes a failing subtest in: ES31-CTS.shader_storage_buffer_object.negative-glsl-compileTime Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir: Allow nir_lower_io() to only lower one type of variable.Kenneth Graunke2015-10-012-4/+18
| | | | | | | | | We may want to use different type_size functions for (e.g.) inputs vs. uniforms. Passing in -1 for mode ignores this, handling all modes as before. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: assert base_alignment > 0 for recordsSamuel Iglesias Gonsalvez2015-09-301-0/+1
| | | | | | | | | | | From GLSL 1.50 spec, section 4.1.8 "Structures": "Structures must have at least one member declaration." So the base_alignment should be higher than zero. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: apply shader storage block member rules when adding program resourcesSamuel Iglesias Gonsalvez2015-09-301-0/+58
| | | | | | | | | | | | | | | | From ARB_program_interface_query: "For an active shader storage block member declared as an array, an entry will be generated only for the first array element, regardless of its type. For arrays of aggregate types, the enumeration rules are applied recursively for the single enumerated array element." v2: - Simplify 'if' conditions and return true if it is not a buffer variable, because these rules only apply to buffer variables (Timothy). Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir: Don't set dest in SSBO store glsl_to_nir conversionJordan Justen2015-09-291-1/+0
| | | | | | | | | This matches the function signature created in lower_ubo_reference_visitor::ssbo_store which has a void return. Suggested-by: Jason Ekstrand <[email protected]> Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir: Use a system value for gl_PrimitiveIDIn.Kenneth Graunke2015-09-294-2/+11
| | | | | | | | | | | | | | | | At least on Intel hardware, gl_PrimitiveIDIn comes in as a special part of the payload rather than a normal input. This is typically what we use system values for. Dave and Ilia also agree that a system value would be nicer. At some point, we should change it at the GLSL IR level as well. But that requires changing most of the drivers. For now, let's at least make NIR do the right thing, which is easy. v2: Add a comment about not creating a temporary (suggested by Iago). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir: Convert SYSTEM_VALUE_NUM_WORK_GROUPS to a nir intrinsicJordan Justen2015-09-292-0/+5
| | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl/cs: Add gl_NumWorkGroups as a system valueJordan Justen2015-09-292-1/+2
| | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Fix forward NULL dereference coverity warningIago Toral Quiroga2015-09-291-7/+6
| | | | | | | | | | | | The comment says that it should be impossible for decl_type to be NULL here, so don't try to handle the case where it is, simply add an assert. >>> CID 1324977: Null pointer dereferences (FORWARD_NULL) >>> Comparing "decl_type" to null implies that "decl_type" might be null. No piglit regressions observed. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Fix null return coverity warningIago Toral Quiroga2015-09-291-4/+6
| | | | | | | | | | | | | | Add an assert on the result of as_dereference() not being NULL: >>> CID 1324978: Null pointer dereferences (NULL_RETURNS) >>> Dereferencing a null pointer "deref_record->record->as_dereference()". Since we are introducing a new variable to hold the result of as_dereference(), take the opportunity to rename deref_record_type to interface_type and just name the new variable interface_deref, which is less confusing. Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Fix unused value warning reported by CoverityIago Toral Quiroga2015-09-291-2/+0
| | | | | | | | | | We don't use param in this part of the code, so no point in advancing the pointer forward: >>> CID 1324983: Code maintainability issues (UNUSED_VALUE) >>> Assigning value from "param->get_next()" to "param" here, but that stored value is overwritten before it can be used. Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: use correct number of uniform blocks in error messageSamuel Iglesias Gonsalvez2015-09-291-1/+1
| | | | | Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* mesa: rename gl_shader_program's NumUniformBlocks to NumBufferInterfaceBlocksSamuel Iglesias Gonsalvez2015-09-294-9/+9
| | | | | | | | | | | Because it counts shader storage blocks too. v2: - Use NumBufferInterfaceBlocks instead (Jordan). Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: revert "glsl: atomic counters can be declared as buffer-qualified ↵Iago Toral Quiroga2015-09-281-3/+3
| | | | | | | | | | | | | | | | | | | | | | variables" This reverts commit 586142658e2927a68c. The specs are not explicit about any restrictions related to the types allowed on buffer variables, however, the description of opaque types (like atomic counters) is in conclict with the purpose of buffer variables: "The opaque types declare variables that are effectively opaque handles to other objects. These objects are accessed through built-in functions, not through direct reading or writing of the declared variable. (...) Opaque variables cannot be treated as l-values;(...)" Also, Mesa is already disallowing opaque types in interface blocks anyway, so that commit was not really achieving anything. Reviewed-by: Francisco Jerez <[email protected]>
* glsl: fix component size calculation for tessellation and geom shadersTimothy Arceri2015-09-281-1/+1
| | | | | | Broken in commit abdab88b30ab when adding arrays of arrays support Reviewed-by: Dave Airlie <[email protected]>