aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/ir_constant_expression.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: fix evaluating float16 constant expression matricesMarek Olšák2020-07-071-0/+6
| | | | | Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
* glsl: fix constant packing for 64-bit big endian.Dave Airlie2020-07-011-0/+15
| | | | | | | | | In a piglit run on s390 a lot of double tests fail, explicitly packing/shifting things rather than using memcpy seems to help Cc: <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5679>
* glsl: handle int16 and uint16 types and add instructions for mediumpMarek Olšák2020-06-021-8/+61
| | | | | | | | 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: Use SATURATEAlyssa Rosenzweig2020-05-261-2/+2
| | | | | | Signed-off-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5100>
* glsl: Remove integer matrix support from ↵Ian Romanick2020-05-211-9/+1
| | | | | | | | | | | ir_dereference_array::constant_expression_value It looks like this code has existed since day 1, but I have no idea why. There have never been integer matrices in GLSL. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Sagar Ghuge <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5135>
* glsl: Hard-code noise to zero in builtin_functions.cppJason Ekstrand2020-04-211-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Expand fp16 to float before constant expression evaluationKristian H. Kristensen2020-03-091-0/+26
| | | | | | | | | | | This way the generated constant folding code doesn't need to understand fp16. All operations have to be expanded to full float for evaulation on the CPU, so we might as well do it up front. As far as GLSL is concerned, fp16 isn't a separate type from float, so everything we're supposed to support for float we need to do for fp16. Reviewed-by: Ian Romanick <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3929>
* glsl: Add support for float16 types in the IR treeNeil Roberts2020-03-091-0/+1
| | | | | | | Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Ian Romanick <[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/+36
| | | | | | | | | | | | | | | | 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: turn runtime asserts of compile-time value into compile-time assertsEric Engestrom2019-09-251-6/+12
| | | | | Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Erik Faye-Lund <[email protected]>
* glsl: correct bitcast-helpersErik Faye-Lund2019-09-251-2/+2
| | | | | | | | | | | | Without this, we'll incorrectly round off huge values to the nearest representable double instead of keeping it at the exact value as we're supposed to. Found by inspecting compiler-warnings. Signed-off-by: Erik Faye-Lund <[email protected]> Fixes: 85faf5082f ("glsl: Add 64-bit integer support for constant expressions") Reviewed-by: Eric Engestrom <[email protected]>
* glsl/types: Rename is_integer to is_integer_32Jason Ekstrand2019-06-191-1/+2
| | | | | | | 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]>
* 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]>
* Replace uses of _mesa_bitcount with util_bitcountDylan Baker2018-09-071-1/+1
| | | | | | | | | | | | | and _mesa_bitcount_64 with util_bitcount_64. This fixes a build problem in nir for platforms that don't have popcount or popcountll, such as 32bit msvc. v2: - Fix additional uses of _mesa_bitcount added after this was originally written Acked-by: Eric Engestrom <[email protected]> (v1) Acked-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Avoid calling get_array_element for scalar constantsDanylo Piliaiev2018-08-151-1/+1
| | | | | | | | | | | | | Accessing scalar constant as an array in function call or initializer list triggered assert in get_array_element. Examples: func(0[0]); vec2 t = { 0[0], 0 }; Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107550 Signed-off-by: Danylo Piliaiev <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* mesa: include mtypes.h lessMarek Olšák2018-04-121-1/+1
| | | | | | | | | | - remove mtypes.h from most header files - add main/menums.h for often used definitions - remove main/core.h v2: fix radv build Reviewed-by: Brian Paul <[email protected]>
* glsl: Silence unused parameter warningsIan Romanick2017-09-191-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | glsl/ast_type.cpp: In function ‘void merge_bindless_qualifier(YYLTYPE*, _mesa_glsl_parse_state*, const ast_type_qualifier&, const ast_type_qualifier&)’: glsl/ast_type.cpp:189:35: warning: unused parameter ‘loc’ [-Wunused-parameter] merge_bindless_qualifier(YYLTYPE *loc, ^~~ glsl/ast_type.cpp:191:52: warning: unused parameter ‘qualifier’ [-Wunused-parameter] const ast_type_qualifier &qualifier, ^~~~~~~~~ glsl/ast_type.cpp:192:52: warning: unused parameter ‘new_qualifier’ [-Wunused-parameter] const ast_type_qualifier &new_qualifier) ^~~~~~~~~~~~~ glsl/ir_constant_expression.cpp: In member function ‘virtual ir_constant* ir_rvalue::constant_expression_value(void*, hash_table*)’: glsl/ir_constant_expression.cpp:512:44: warning: unused parameter ‘mem_ctx’ [-Wunused-parameter] ir_rvalue::constant_expression_value(void *mem_ctx, struct hash_table *) ^~~~~~~ glsl/ir_constant_expression.cpp: In member function ‘virtual ir_constant* ir_texture::constant_expression_value(void*, hash_table*)’: glsl/ir_constant_expression.cpp:705:45: warning: unused parameter ‘mem_ctx’ [-Wunused-parameter] ir_texture::constant_expression_value(void *mem_ctx, struct hash_table *) ^~~~~~~ glsl/ir_constant_expression.cpp: In member function ‘virtual ir_constant* ir_assignment::constant_expression_value(void*, hash_table*)’: glsl/ir_constant_expression.cpp:851:48: warning: unused parameter ‘mem_ctx’ [-Wunused-parameter] ir_assignment::constant_expression_value(void *mem_ctx, struct hash_table *) ^~~~~~~ glsl/ir_constant_expression.cpp: In member function ‘virtual ir_constant* ir_constant::constant_expression_value(void*, hash_table*)’: glsl/ir_constant_expression.cpp:859:46: warning: unused parameter ‘mem_ctx’ [-Wunused-parameter] ir_constant::constant_expression_value(void *mem_ctx, struct hash_table *) ^~~~~~~ glsl/linker.cpp: In function ‘void link_xfb_stride_layout_qualifiers(gl_context*, gl_shader_program*, gl_linked_shader*, gl_shader**, unsigned int)’: glsl/linker.cpp:1655:60: warning: unused parameter ‘linked_shader’ [-Wunused-parameter] struct gl_linked_shader *linked_shader, ^~~~~~~~~~~~~ glsl/linker.cpp: In function ‘void link_bindless_layout_qualifiers(gl_shader_program*, gl_program*, gl_shader**, unsigned int)’: glsl/linker.cpp:1693:52: warning: unused parameter ‘gl_prog’ [-Wunused-parameter] struct gl_program *gl_prog, ^~~~~~~ glsl/lower_distance.cpp: In member function ‘virtual void {anonymous}::lower_distance_visitor_counter::handle_rvalue(ir_rvalue**)’: glsl/lower_distance.cpp:652:59: warning: unused parameter ‘rv’ [-Wunused-parameter] lower_distance_visitor_counter::handle_rvalue(ir_rvalue **rv) ^~ glsl/opt_array_splitting.cpp: In member function ‘virtual ir_visitor_status {anonymous}::ir_array_reference_visitor::visit_leave(ir_assignment*)’: glsl/opt_array_splitting.cpp:198:56: warning: unused parameter ‘ir’ [-Wunused-parameter] ir_array_reference_visitor::visit_leave(ir_assignment *ir) ^~ glsl/glsl_parser_extras.cpp: In function ‘void assign_subroutine_indexes(gl_shader*, _mesa_glsl_parse_state*)’: glsl/glsl_parser_extras.cpp:1869:45: warning: unused parameter ‘sh’ [-Wunused-parameter] assign_subroutine_indexes(struct gl_shader *sh, ^~ Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Alejandro Piñeiro <[email protected]> Reviewed-by: Elie Tournier <[email protected]>
* glsl: add a few missing int64 constant propagation casesIlia Mirkin2017-08-181-0/+2
| | | | | | | | | | Fixes KHR-GL45.shader_ballot_tests.ShaderBallotAvailability, which causes some silly swizzles to appear, triggering this optimization to get hit. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Cc: [email protected]
* glsl: pass mem_ctx to constant_expression_value(...) and friendsTimothy Arceri2017-08-111-39/+75
| | | | | | | | | | | | | | | | | | | | The main motivation for this is that threaded compilation can fall over if we were to allocate IR inside constant_expression_value() when calling it on a builtin. This is because builtins are shared across the whole OpenGL context. f81ede469910d worked around the problem by cloning the entire builtin before constant_expression_value() could be called on it. However cloning the whole function each time we referenced it lead to a significant reduction in the GLSL IR compiler performance. This change along with the following patch helps fix that performance regression. Other advantages are that we reduce the number of calls to ralloc_parent(), and for loop unrolling we free constants after they are used rather than leaving them hanging around. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: stop copying struct and interface member namesTimothy Arceri2017-08-111-2/+2
| | | | | | | | | | | We are currently copying the name for each member dereference but we can just share a single instance of the string provided by the type. This change also stops us recalculating the field index repeatedly. Reviewed-by: Thomas Helland <[email protected]>
* glsl: calculate number of operands in an expression onceTimothy Arceri2017-08-111-1/+1
| | | | | | | | | | | | | | | | | | | 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 64-bit integer support for constant expressionsDave Airlie2017-01-201-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | This just adds the new operations and add 64-bit integer support to all the existing cases where it is needed. v2: fix some issues found in testing. v2.1: add unreachable (Ian), add missing int/uint pack/unpack (Dave). v3 (idr): Rebase on top of idr's series to generate ir_expression_operation_constant.h. In addition, this version: Adds missing support for ir_unop_bit_not, ir_binop_all_equal, ir_binop_any_nequal, ir_binop_vector_extract, ir_triop_vector_insert, and ir_quadop_vector. Removes support for uint64_t from ir_unop_abs and ir_unop_sign. 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: Convert constant_expression to the util hash tableThomas Helland2016-09-121-11/+14
| | | | | | | | | | V2: Fix incorrect ordering on hash table insert V3: null check value returned by _mesa_hash_table_search() (Timothy Arceri) Signed-off-by: Thomas Helland <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Use the generated constant expression codeIan Romanick2016-08-301-1108/+1
| | | | | | | | | | | | | | Immediately previous to this patch, diff -wud src/glsl/ir_constant_expression.cpp \ src/glsl/ir_expression_operation_constant.h should be "minimal." v3: With much help from José Fonseca, fix the SCons build. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Compact a bunch of things onto one lineIan Romanick2016-08-301-66/+20
| | | | | | | Even though they are much too long for that. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Sort constant expression handling by IR operand enum valueIan Romanick2016-08-301-318/+319
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Trivial whitespace and punctuation changesIan Romanick2016-08-301-66/+76
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Sort GLSL type enums in switch-statements in enum orderIan Romanick2016-08-301-28/+28
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Always use correct float types in constant expression handlingIan Romanick2016-08-301-5/+5
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Extract ir_quadop_bitfield_insert implementation to a separate functionIan Romanick2016-08-301-25/+23
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Extract ir_triop_bitfield_extract implementation to a separate functionIan Romanick2016-08-301-24/+42
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Extract ir_binop_ldexp implementation to a separate functionIan Romanick2016-08-301-11/+28
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Use find_msb_uint to implement ir_unop_find_lsbIan Romanick2016-08-301-10/+9
| | | | | | | | | | (X & -X) calculates a value with only the least significant bit of X set. Since there is only one bit set, the LSB is the MSB. v2: Remove extra int() cast. Suggested by Matt. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Extract ir_unop_find_msb implementation to a separate functionIan Romanick2016-08-301-15/+34
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Extract ir_unop_bitfield_reverse implementation to a separate functionIan Romanick2016-08-301-13/+27
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Use _mesa_bitcount to implement constant ir_unop_bit_countIan Romanick2016-08-301-9/+2
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add missing ir_quadop_vector constant evaluation for Boolean typesIan Romanick2016-08-171-0/+3
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Fix typo in ir_unop_f2u implementationIan Romanick2016-08-171-1/+1
| | | | | | | This won't affect the output, but it was, technically, wrong. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Fix typo in ir_unop_b2i implementationIan Romanick2016-08-171-1/+1
| | | | | | | This won't affect the output, but it was, technically, wrong. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Don't support integer types for operations that can't handle themIan Romanick2016-08-171-14/+0
| | | | | | | | 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-6/+0
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Avoid aliasing violations.Matt Turner2016-07-261-8/+3
| | | | | Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Separate overlapping sentinel nodes in exec_list.Matt Turner2016-07-261-1/+1
| | | | | | | | | | | 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]>
* glsl/ir: remove TABs in ir_constant_expression.cppDave Airlie2016-06-101-535/+535
| | | | | | | | Adding 64-bit integers support was going to make this file worse, just remove the tabs from it now. Acked-by: Timothy Arceri <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: move to compiler/Emil Velikov2016-01-261-0/+2092
Signed-off-by: Emil Velikov <[email protected]> Acked-by: Matt Turner <[email protected]> Acked-by: Jose Fonseca <[email protected]>