summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/ir.cpp
Commit message (Collapse)AuthorAgeFilesLines
* mesa: include mtypes.h lessMarek Olšák2018-04-121-1/+0
| | | | | | | | | | - 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: 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: silence signed/unsigned comparison warningBrian Paul2017-09-211-1/+1
| | | | Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: Unify ir_constant::const_elements and ::componentsIan Romanick2017-09-191-73/+19
| | | | | | | | | | There was no reason to treat array types and record types differently. Unifying them saves a bunch of code and saves a few bytes in every ir_constant. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Alejandro Piñeiro <[email protected]> Reviewed-by: Elie Tournier <[email protected]>
* glsl: Rename ir_constant::array_elements to ::const_elementsIan Romanick2017-09-191-12/+12
| | | | | | | | | | | The next patch will unify ::array_elements and ::components, so the name ::array_elements wouldn't be appropriate. A lot of things use the names array_elements and components, so grepping for either is pretty useless. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Alejandro Piñeiro <[email protected]> Reviewed-by: Elie Tournier <[email protected]>
* glsl: stop copying struct and interface member namesTimothy Arceri2017-08-111-5/+3
| | | | | | | | | | | 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: tidy up get_num_operands()Timothy Arceri2017-08-111-3/+6
| | | | | | | | | | | Also add a comment that this should only be used by the ir_reader interface for testing purposes. v2: - fix grammar in comment - use unreachable rather than assert Reviewed-by: Thomas Helland <[email protected]>
* glsl: calculate number of operands in an expression onceTimothy Arceri2017-08-111-2/+20
| | | | | | | | | | | | | | | | | | | 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: Fix g++ initializer order warningBrian Paul2017-05-251-1/+1
| | | | | | | | | | | | | | | | | Fixes this warning: In file included from ../../../src/compiler/glsl/ir.cpp:25:0: ../../../src/compiler/glsl/ir.h: In constructor 'ir_swizzle::ir_swizzle(ir_rvalue*, ir_swizzle_mask)': ../../../src/compiler/glsl/ir.h:1955:20: warning: 'ir_swizzle::mask' will be initialized after [-Wreorder] ir_swizzle_mask mask; ^ ../../../src/compiler/glsl/ir.h:1954:15: warning: 'ir_rvalue* ir_swizzle::val' [-Wreorder] ir_rvalue *val; ^ ../../../src/compiler/glsl/ir.cpp:1592:1: warning: when initialized here [-Wreorder] ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask) ^ Reviewed-by: Matt Turner <[email protected]>
* glsl: set mask via initialisation list rather than in constructor bodyTimothy Arceri2017-05-221-3/+1
| | | | | | | | | Potentially more efficient as it may avoid the struct being initialised twice. Also add var to the initialisation list while we are here. Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: implement ARB_bindless_texture conversionsSamuel Pitoiset2017-05-061-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | From section 5.4.1 of the ARB_bindless_texture spec: "In the following four constructors, the low 32 bits of the sampler type correspond to the .x component of the uvec2 and the high 32 bits correspond to the .y component." uvec2(any sampler type) // Converts a sampler type to a // pair of 32-bit unsigned integers any sampler type(uvec2) // Converts a pair of 32-bit unsigned integers to // a sampler type uvec2(any image type) // Converts an image type to a // pair of 32-bit unsigned integers any image type(uvec2) // Converts a pair of 32-bit unsigned integers to // an image type v4: - fix up comment style v3: - rebase (and remove (sampler) ? 1 : vector_elements) Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: allow bindless samplers/images to be l-valuesSamuel Pitoiset2017-05-061-0/+14
| | | | | | | | | | | | | | | | | | | From section 4.1.7 of the ARB_bindless_texture spec: "Samplers can be used as l-values, so can be assigned into and used as "out" and "inout" function parameters." From section 4.1.X of the ARB_bindless_texture spec: "Images can be used as l-values, so can be assigned into and used as "out" and "inout" function parameters." v4: - invert the logic v3: - update spec comment formatting - keep the read_only check Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: add _mesa_glsl_parse_state object to is_lvalue()Samuel Pitoiset2017-05-061-1/+3
| | | | | | | | | | | | | | | Yes, this is a bit hacky but we don't really have the choice. Plain GLSL doesn't accept bindless samplers/images as l-values while it's allowed when ARB_bindless_texture is enabled. The default NULL parameter is because we can't access the _mesa_glsl_parse_state object in few places in the compiler. One is_lvalue(NULL) call is for IR validation but other checks happen elsewhere, should be safe. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: process bindless/bound layout qualifiersSamuel Pitoiset2017-05-061-0/+2
| | | | | | | | | | | | This adds bindless_sampler and bound_sampler (and respectively bindless_image and bound_image) to the parser. v3: - add an extra space in apply_bindless_qualifier_to_variable() - fix indentation in merge_qualifier() Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: do not make sampler/image types readonly variablesSamuel Pitoiset2017-05-061-3/+0
| | | | | | | | | | | | | | | | | In plain GLSL, sampler and image types can only be declared uniform-qualified global variables or 'in' function parameters. Setting the read_only flag seems quite useless because other checks will prevent sampler/image variables to be assigned and also because the flag is not set for atomic_uint types which are opaque types. This will also help for ARB_bindless_texture because samplers and images can be assigned when they are considered bindless. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: rename image_* qualifiers to memory_*Samuel Pitoiset2017-05-041-10/+10
| | | | | | | | | It doesn't make sense to prefix them with 'image' because they are called "Memory Qualifiers" and they can be applied to members of storage buffer blocks. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Andres Gomez <[email protected]>
* glsl: remove the shader_group_vote and shader_ballot expression opsNicolai Hähnle2017-04-281-18/+0
| | | | They are now no longer used.
* glsl: make use of glsl_type::is_float()Samuel Pitoiset2017-04-211-4/+3
| | | | | | 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-1/+1
| | | | | | 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_record()Samuel Pitoiset2017-04-211-1/+1
| | | | | | 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/+12
| | | | Reviewed-by: Marek Olšák <[email protected]>
* glsl: use is_sampler() anywhere it's possibleSamuel Pitoiset2017-02-271-2/+2
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl/ir: Add support for 64-bit integer conversions.Dave Airlie2017-01-201-0/+55
| | | | | | | | | | | | | | | | | | | | | | 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/ast/ir: Add 64-bit integer constant supportDave Airlie2017-01-201-0/+117
| | | | | | | | | | | | | | | | | This adds support for 64-bit integer constants to the parser, ast and ir. v2: fix a few issues found in testing. v3: Add missing ir_constant copy contructor support. v4: Use PRIu64 and PRId64 in printfs in glsl_parser_extras.cpp. Suggested by Nicolai. Rebase on Marek's linalloc changes. Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ian Romanick <[email protected]> [v2] Reviewed-by: Matt Turner <[email protected]> [v3] Reviewed-by: Nicolai Hähnle <[email protected]>
* Revert recent GLSL slot counting fiasco.Kenneth Graunke2017-01-071-25/+0
| | | | | | | | | | | | | | | | | | | | | | | | I apparently broke mark_whole_variable in ir_set_program_inouts. It was passing a type that wasn't var->type, so the wrapper didn't work out. It's all broken, revert it and start over. Fixes all kinds of things on other drivers. Revert "glsl: Make is_fixed_function_array actually check for varyings." This reverts commit 42699e12711668a142b7acf11c168cf4301c1295. Revert "glsl: Mark whole variable used for ClipDistance and TessLevel*." This reverts commit 5c580e64cc206ab160e1767c42e4d6c81f67da4d. Revert "glsl: Override the # of varying slots for ClipDistance and TessLevel*." This reverts commit 8b5749f65ac434961308ccb579fb8a816e4f29d5. Revert "glsl: Create and use a new ir_variable::count_attribute_slots() wrapper." This reverts commit 6aa5cb34d03765b7be8611aa516bc201bd337f73.
* glsl: Override the # of varying slots for ClipDistance and TessLevel*.Kenneth Graunke2017-01-061-0/+18
| | | | | | | | | | | | | Right now, this shouldn't have any effect, as all drivers use LowerClipDist and LowerTessFactors to turn the float[] arrays into vectors. However, it should help make it possible for drivers to avoid that lowering. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Create and use a new ir_variable::count_attribute_slots() wrapper.Kenneth Graunke2017-01-061-0/+7
| | | | | | | | | This wraps glsl_type::count_attribute_slots(), but will soon contain a couple of overrides for a couple of GLSL built-ins variables. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: use a non-malloc'd storage for short ir_variable namesMarek Olšák2016-10-311-0/+4
| | | | | Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: Remove ir_function_signature::_is_intrinsic fieldIan Romanick2016-10-041-1/+1
| | | | | | | | | text data bss dec hex filename 6036491 283160 28608 6348259 60dde3 lib64/i965_dri.so before 6036395 283160 28608 6348163 60dd83 lib64/i965_dri.so after Signed-off-by: Ian Romanick <[email protected]> Acked-by: Ilia Mirkin <[email protected]>
* glsl: Add ir_function_signature::is_intrinsic() methodIan Romanick2016-10-041-1/+1
| | | | | | | | | | | | This necessetated renaming the is_intrinsic field to _is_intrinsic. The next commit will remove the field. text data bss dec hex filename 6036507 283160 28608 6348275 60ddf3 lib64/i965_dri.so before 6036491 283160 28608 6348259 60dde3 lib64/i965_dri.so after Signed-off-by: Ian Romanick <[email protected]> Acked-by: Ilia Mirkin <[email protected]>
* glsl: Track a unique intrinsic ID with each intrinsic functionIan Romanick2016-10-041-1/+1
| | | | | | | | | text data bss dec hex filename 6037483 283160 28608 6349251 60e1c3 lib64/i965_dri.so before 6038043 283160 28608 6349811 60e3f3 lib64/i965_dri.so after Signed-off-by: Ian Romanick <[email protected]> Acked-by: Ilia Mirkin <[email protected]>
* glsl: Just access the ir_expression_operation strings table directlyIan Romanick2016-08-301-15/+2
| | | | | | | | | | | | | | The operator_string functions gave us some protection against a malformed table. Now that the table is generated from the same data that generates the enum, this is not a concern. Just cut out the middle man. text data bss dec hex filename 7531892 273992 28584 7834468 778b64 i965_dri-64bit-before.so 7531828 273992 28584 7834404 778b24 i965_dri-64bit-after.so Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Pull operator_strs out to its own fileIan Romanick2016-08-301-115/+1
| | | | | | | | | | No change except to the copyright symbol. The next patch will generate this file with Python, and Unicode + Python = pure rage. v2: Massive rebase. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add support for representing framebuffer fetch in the GLSL IR.Francisco Jerez2016-08-241-0/+1
| | | | | | | | | | The GLSL IR representation of framebuffer fetch amounts to a single bit in the ir_variable object applicable to fragment shader outputs. The flag indicates that the variable will be implicitly initialized to the previous contents of the render buffer at the same fragment coordinates and sample index. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Separate overlapping sentinel nodes in exec_list.Matt Turner2016-07-261-4/+4
| | | | | | | | | | | 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]>
* compiler: Rename INTERP_QUALIFIER_* to INTERP_MODE_*.Kenneth Graunke2016-07-171-5/+5
| | | | | | | | | | | | | | | | | Likewise, rename the enum type to glsl_interp_mode. Beyond the GLSL front-end, talking about "interpolation modes" seems more natural than "interpolation qualifiers" - in the IR, we're removed from how exactly the source language specifies how to interpolate an input. Also, SPIR-V calls these "decorations" rather than "qualifiers". Generated by: $ find . -regextype egrep -regex '.*\.(c|cpp|h)' -type f -exec sed -i \ -e 's/INTERP_QUALIFIER_/INTERP_MODE_/g' \ -e 's/glsl_interp_qualifier/glsl_interp_mode/g' {} \; Signed-off-by: Kenneth Graunke <[email protected]> Acked-by: Dave Airlie <[email protected]>
* mesa: hook up core bits of GL_ARB_shader_group_voteIlia Mirkin2016-06-061-0/+9
| | | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* Revert "glsl: fix xfb_offset unsized array validation"Timothy Arceri2016-06-011-23/+0
| | | | | | | | | | | This reverts commit aac90ba2920cf5ceb4df6dba776dd3952780e456. The commit caused a regression in: piglit.spec.glsl-1_50.compiler.gs-input-nonarray-named-block.geom Also the CTS test it was meant to fix seems like it may be bogus. Cc: "12.0" <[email protected]>
* glsl: fix xfb_offset unsized array validationTimothy Arceri2016-05-301-0/+23
| | | | | | | | | | | | | | | | This partially fixes CTS test: GL44-CTS.enhanced_layouts.xfb_get_program_resource_api The test now fails at a tes evaluation shader with unsized output arrays. The ARB_enhanced_layouts spec says: "It is a compile-time error to apply xfb_offset to the declaration of an unsized array." So this seems like a bug in the CTS. Reviewed-by: Dave Airlie <[email protected]>
* glsl: make max array trackers ints and use -1 as base. (v2)Dave Airlie2016-05-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: fixed uninitialized pointerJakob Sinclair2016-05-121-0/+5
| | | | | | | | | | | | | Class "ir_constant" had a bunch of constructors where the pointer member "array_elements" had not been initialized. This could have lead to unsafe code if something had tried to write anything to it. This patch fixes this issue by initializing the pointer to NULL in all the constructors. This issue was discovered by Coverity. CID: 401603, 401604, 401605, 401610 Signed-off-by: Jakob Sinclair <[email protected]> Reviewed-by: Alejandro Piñeiro <[email protected]>
* compiler/glsl: do not downcast list sentinelNicolai Hähnle2016-05-071-1/+4
| | | | | | This crashes gcc's undefined behaviour sanitizer. Reviewed-by: Marek Olšák <[email protected]>
* glsl: remove unused helperTimothy Arceri2016-02-171-15/+0
| | | | | | Seems to have become unused when i965 moved to NIR. Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl/types: Rename sampler_type to sampled_typeJason Ekstrand2016-02-131-1/+1
| | | | | | | | It's a bit more descriptive since it is the base type that you get when you sample from it. Also, the next commit adds a bare "sampler" type and we need glsl_type::sampler_type available for a public static member. Reviewed-by: Jordan Justen <[email protected]>
* glsl: Remove 2x16 half-precision pack/unpack opcodes.Matt Turner2016-02-011-9/+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/+2039
Signed-off-by: Emil Velikov <[email protected]> Acked-by: Matt Turner <[email protected]> Acked-by: Jose Fonseca <[email protected]>