aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/ir_validate.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: don't validate array types in ir_dereference_variableMarek Olšák2020-07-081-1/+4
| | | | | | | | Fixes: 8d62969cfe8 - glsl: validate more stuff Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3245 Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5813>
* glsl: don't lower builtins to mediump that don't allow itMarek Olšák2020-07-071-14/+14
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: validate more stuffMarek Olšák2020-07-071-0/+66
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: run validate_ir_tree if GLSL_VALIDATE=1 regardless of the build configMarek Olšák2020-07-071-4/+5
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: handle int16 and uint16 types and add instructions for mediumpMarek Olšák2020-06-021-65/+82
| | | | | | | | v2: add more changes to ir_validate.cpp Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Rob Clark <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5002>
* glsl: Hard-code noise to zero in builtin_functions.cppJason Ekstrand2020-04-211-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Version 4.4 of the GLSL spec changed the definition of noise*() to always return zero and earlier versions of the spec allowed zero as a valid implementation. All drivers, as far as I can tell, unconditionally call lower_noise() today which turns ir_unop_noise into zero. We've got a 10-year-old comment in there saying "In the future, ir_unop_noise may be replaced by a call to a function that implements noise." Well, it's the future now and we've not yet gotten around to that. In the mean time, the GLSL spec has made doing so illegal. To make things worse, we then pretend to handle the opcode in glsl_to_nir, ir_to_mesa, and st_glsl_to_tgsi even though it should never get there given the lowering. The lowering in st_glsl_to_tgsi defines noise*() to be 0.5 which is an illegal implementation of the noise functions according to pre-4.4 specs. We also have opcodes for this in NIR which are never used because, again, we always call lower_noise(). Let's just kill the whole opcode and make builtin_builder.cpp build a bunch of functions that just return zero. Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4624>
* glsl/validate: Allow float16 in the expression treeNeil Roberts2020-03-091-27/+18
| | | | | | | | | v2. [Hyunjun Ko ([email protected])] squashed 3 commits into one commit. Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl: Add ir_unop_f2fmpNeil Roberts2020-03-091-0/+1
| | | | | | | | | | | | This is the same as ir_unop_f2f16 except that it comes with a promise that it is safe to optimise it out if the result is immediately converted back to float32 again. Normally this would be a lossy operation but it is safe to do if the conversion was generated as part of the precision lowering pass. Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl: Add b2f16 and f162b conversion operationsNeil Roberts2020-03-091-0/+9
| | | | | | Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl: Add IR conversion ops for 16-bit float typesNeil Roberts2020-03-091-0/+8
| | | | | | | | | Adds ir_unop_f162f and ir_unop_f2f16. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl: Add new expressions for INTEL_shader_integer_functions2Ian Romanick2020-01-231-0/+24
| | | | | | | | | | | | | | | | v2: Re-write iadd64_saturate and isub64_saturate to avoid undefined overflow behavior. Also fix copy-and-paste bug in isub64_saturate. Suggested by Caio. v3: Avoid signed integer overflow for abs_sub(0, INT_MIN). Noticed by Caio. v4: Alternate fix for signed integer overflow for abs_sub(0, INT_MIN). I tried the previous methon in a small test program with -ftrapv, and it failed. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/767>
* glsl: Add opcodes for atan and atan2Neil Roberts2019-10-121-0/+13
| | | | | | | | Adds ir_binop_atan2 and ir_unop_atan. When converting to NIR these are expanded out using the appropriate builtin generator. If they are used with anything else then it will just hit an assert. Reviewed-by: Kristian H. Kristensen <[email protected]>
* compiler/glsl: Fix warning about unused functionCaio Marcelo de Oliveira Filho2019-08-231-1/+3
| | | | | | | | | | The helper check_node_type() is only used when DEBUG is set (in the function below), but ASSERTED macro uses NDEBUG. So just guard the helper with #ifdef. If we see more such cases we might consider a ASSERTED-like macro for the DEBUG case. Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* tree-wide: replace MAYBE_UNUSED with ASSERTEDEric Engestrom2019-07-311-1/+1
| | | | | | Suggested-by: Jason Ekstrand <[email protected]> Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl/types: Rename is_integer to is_integer_32Jason Ekstrand2019-06-191-9/+9
| | | | | | | It only accepts 32-bit integers so it should have a more descriptive name. This patch should not be a functional change. Reviewed-by: Karol Herbst <[email protected]>
* glsl: [u/i]mulExtended optimization for GLSLSagar Ghuge2019-03-041-0/+11
| | | | | | | | | | | | | | | Optimize mulExtended to use 32x32->64 multiplication. Drivers which are not based on NIR, they can set the MUL64_TO_MUL_AND_MUL_HIGH lowering flag in order to have same old behavior. v2: Add missing condition check (Jason Ekstrand) Signed-off-by: Sagar Ghuge <[email protected]> Suggested-by: Matt Turner <Matt Turner <[email protected]> Suggested-by: Jason Ekstrand <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* src/compiler: use new hash table and set creation helpersCaio Marcelo de Oliveira Filho2019-01-141-2/+1
| | | | | | | | | Replace calls to create hash tables and sets that use _mesa_hash_pointer/_mesa_key_pointer_equal with the helpers _mesa_pointer_hash_table_create() and _mesa_pointer_set_create(). Reviewed-by: Jason Ekstrand <[email protected]> Acked-by: Eric Engestrom <[email protected]>
* glsl: Remove ir_binop_greater and ir_binop_lequal expressionsIan Romanick2017-10-301-2/+0
| | | | | | | | | | | | | | | | | | | NIR does not have these instructions. TGSI and Mesa IR both implement them using < and >=, repsectively. Removing them deletes a bunch of code and means I don't have to add code to the SPIR-V generator for them. v2: Rebase on 2+ years of change... and fix a major bug added in the rebase. text data bss dec hex filename 8255291 268856 294072 8818219 868e2b 32-bit i965_dri.so before 8254235 268856 294072 8817163 868a0b 32-bit i965_dri.so after 7815339 345592 420592 8581523 82f193 64-bit i965_dri.so before 7813995 345560 420592 8580147 82ec33 64-bit i965_dri.so after Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: replace conditional compilation with MAYBE_UNUSEDEric Engestrom2017-09-191-3/+2
| | | | | | Suggested-by: Nicolai Hähnle <[email protected]> Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: compile unused function outEric Engestrom2017-09-131-0/+2
| | | | | | | | | The function is only called from one place, which is hidden behind the same `#ifdef DEBUG`. Fixes: ca73c3358c91434e68ab "glsl: Mark functions static" Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Mark functions staticMatt Turner2017-08-211-1/+1
| | | | | | Cuts 3224 bytes of .text Reviewed-by: Jordan Justen <[email protected]>
* glsl: calculate number of operands in an expression onceTimothy Arceri2017-08-111-0/+8
| | | | | | | | | | | | | | | | | | | Extra validation is added to ir_validate to make sure this is always updated to the correct numer of operands, as passes like lower_instructions modify the instructions directly rather then generating a new one. The reduction in time is so small that it is not really measurable. However callgrind was reporting this function as being called just under 34 million times while compiling the Deus Ex shaders (just pre-linking was profiled) with 0.20% spent in this function. v2: - make num_operands a unit8_t - fix unsigned/signed mismatches Reviewed-by: Thomas Helland <[email protected]>
* glsl: add ARB_bindless_texture operationsSamuel Pitoiset2017-05-061-0/+20
| | | | | | | | For the explicit pack/unpack conversions. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: remove the shader_group_vote and shader_ballot expression opsNicolai Hähnle2017-04-281-23/+0
| | | | They are now no longer used.
* glsl: make use of glsl_type::is_float()Samuel Pitoiset2017-04-211-27/+27
| | | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
* glsl: make use of glsl_type::is_double()Samuel Pitoiset2017-04-211-24/+24
| | | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
* glsl: make use of glsl_type::is_boolean()Samuel Pitoiset2017-04-211-14/+14
| | | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
* glsl: add ARB_shader_ballot operationsNicolai Hähnle2017-04-051-0/+16
| | | | Reviewed-by: Marek Olšák <[email protected]>
* glsl: Allow GLSL_TYPE_INT64 for ir_unop_abs and ir_unop_signIan Romanick2017-01-201-1/+2
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add 64-bit integer support to some operations.Dave Airlie2017-01-201-2/+2
| | | | | | | | This adds 64-bit integer support to some AST and IR operations where it is needed. Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl/ir: Add support for 64-bit integer conversions.Dave Airlie2017-01-201-0/+116
| | | | | | | | | | | | | | | | | | | | | | This adds all the conversions in the world, I'm not 100% sure of all of these are needed, but add all of them and we can cut them down later. v2: fix issue with packing output types. v3 (idr): Rebase on top of idr's series to generate ir_expression_operation_constant.h. Fix transposed ir_validate assertions for ir_unop_u642i64 and ir_unop_i642u64. Add missing automatic type setup for ir_unop_u642i64 and ir_unop_i642u64. v4 (idr): "cut them down later" => Remove ir_unop_b2u64 and ir_unop_u642b. Handle these with extra i2u or u2i casts just like uint(bool) and bool(uint) conversion is done. Signed-off-by: Dave Airlie <[email protected]> Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Ian Romanick <[email protected]> [v2] Reviewed-by: Matt Turner <[email protected]> [v3] Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: Don't support integer types for operations that can't handle themIan Romanick2016-08-171-0/+2
| | | | | | | | ir_unop_fract already forbade integer types in ir_validate. ir_unop_rcp, ir_unop_rsq, and ir_unop_sqrt should also forbid them in ir_validate. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Don't support ir_unop_abs or ir_unop_sign for unsigned integersIan Romanick2016-08-171-0/+9
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Separate overlapping sentinel nodes in exec_list.Matt Turner2016-07-261-2/+2
| | | | | | | | | | | I do appreciate the cleverness, but unfortunately it prevents a lot more cleverness in the form of additional compiler optimizations brought on by -fstrict-aliasing. No difference in OglBatch7 (n=20). Co-authored-by: Davin McCall <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: hook up core bits of GL_ARB_shader_group_voteIlia Mirkin2016-06-061-0/+8
| | | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: handle implicit sized arrays in ssboDave Airlie2016-05-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current code disallows unsized arrays except at the end of an SSBO but it is a bit overzealous in doing so. struct a { int b[]; int f[4]; }; is valid as long as b is implicitly sized within the shader, i.e. it is accessed only by integer indices. I've submitted some piglit tests to test for this. This also has no regressions on piglit on my Haswell. This fixes: GL45-CTS.shader_storage_buffer_object.basic-syntax GL45-CTS.shader_storage_buffer_object.basic-syntaxSSO This patch moves a chunk of the linker code down, so that we don't link the uniform blocks until after we've merged all the variables. The logic went something like: Removing the checks for last ssbo member unsized from the compiler and into the linker, meant doing the check in the link_uniform_blocks code. However to do that the array sizing had to happen first, so we knew that the only unsized arrays were in the last block. But array sizing required the variable to be merged, otherwise you'd get two different array sizes in different version of two variables, and one would get lost when merged. So the solution was to move array sizing up, after variable merging, but before uniform block visiting. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: make max array trackers ints and use -1 as base. (v2)Dave Airlie2016-05-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a bug that breaks cull distances. The problem is the max array accessors can't tell the difference between an never accessed unsized array and an accessed at location 0 unsized array. This leads to converting an undeclared unused gl_ClipDistance inside or outside gl_PerVertex to a size 1 array. However we need to the number of active clip distances to work out the starting point for the cull distances, and this offset by one when it's not being used isn't possible to distinguish from the case were only the first element is accessed. I tried to use ->used for this, but that doesn't work when gl_ClipDistance is part of an interface block. So this changes things so that max_array_access is an int and initialised to -1. This also allows unsized arrays to proceed further than that could before, but we really shouldn't mind as they will get eliminated if nothing uses them later. For initialised uniforms we no longer change their array size at runtime, if these are unused they will get eliminated eventually. v2: use ralloc_array (Ilia) Reviewed-by: Ilia Mirkin <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: Remove 2x16 half-precision pack/unpack opcodes.Matt Turner2016-02-011-12/+0
| | | | | | i965/fs was the only consumer, and we're now doing the lowering in NIR. Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl: move to compiler/Emil Velikov2016-01-261-0/+930
Signed-off-by: Emil Velikov <[email protected]> Acked-by: Matt Turner <[email protected]> Acked-by: Jose Fonseca <[email protected]>