summaryrefslogtreecommitdiffstats
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* glsl: fix a crash in ir_print_visitor() for bindless samplers/imagesSamuel Pitoiset2017-06-011-1/+5
| | | | | | | | | Bindless samplers/images are represented with 64-bit unsigned integers and they can be assigned with explicit constructors. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: teach opt_array_splitting about bindless imagesSamuel Pitoiset2017-06-011-2/+13
| | | | | | | | Memory/format layout qualifiers shouldn't be lost when arrays of images are splitted by this pass. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: teach opt_structure_splitting about images in structuresSamuel Pitoiset2017-06-011-2/+21
| | | | | | | | | GL_ARB_bindless_texture allows images to be declared inside structures, but when memory/format qualifiers are used, they should be propagated when structures are splitted. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: fix broken indentation in do_structure_splitting()Samuel Pitoiset2017-06-011-16/+13
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: handle format layout qualifiers for struct with array of imagesSamuel Pitoiset2017-06-011-1/+2
| | | | | | | | | | | This handles a situation like: struct { layout (r32f) image2D imgs[6]; } s; Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: handle memory qualifiers for struct with array of imagesSamuel Pitoiset2017-06-011-3/+4
| | | | | | | | | | | This handles a situation like: struct { image2D imgs[6]; } s; Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl/lower_int64: only set progress when something is lowered.Dave Airlie2017-06-011-4/+1
| | | | | | | | Otherwise we'd get progress continually set if we had non 64-bit versions of these ops. Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Dave Airlie <[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]>
* nir/lower-atomics-to-ssbo: remove atomic_uint arrays tooRob Clark2017-05-231-1/+9
| | | | | | | | Maybe there is a better way to do this. But by the time we get to assigning uniform locs, we want the atomic_uint's to all be gone, otherwise we assert in st_glsl_attrib_type_size(). Signed-off-by: Rob Clark <[email protected]>
* nir/lower-atomics-to-ssbo: fix num_componentsRob Clark2017-05-231-0/+5
| | | | | | Fixes some piglits like arb_shader_atomic_counters-active-counters Signed-off-by: Rob Clark <[email protected]>
* util/disk_cache: add new driver_flags param to cache keysTimothy Arceri2017-05-231-10/+10
| | | | | | | | | This will be used for things such as adding driver specific environment variables to the key. Allowing us to set environment vars that change the shader and not have the driver ignore them if it finds existing shaders in the cache. Reviewed-by: Eduardo Lima Mitev <[email protected]>
* mesa: GL_ARB_shader_subroutine is not optional in core profileIan Romanick2017-05-221-1/+0
| | | | | | | | | | | text data bss dec hex filename 7038459 235248 37280 7310987 6f8e8b 32-bit i965_dri.so before 7038227 235248 37280 7310755 6f8da3 32-bit i965_dri.so after 6681438 303400 50608 7035446 6b5a36 64-bit i965_dri.so before 6681254 303400 50608 7035262 6b597e 64-bit i965_dri.so after Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Ilia Mirkin <[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]>
* glcpp: Skip unnecessary line continuations removalVladislav Egorov2017-05-221-2/+8
| | | | | | | | | | Overwhelming majority of shaders don't use line continuations. In my shader-db only shaders from the Talos Principle and Serious Sam used them, less than 1% out of all shaders. Optimize for this case, don't do any copying if no line continuation was found. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glcpp: Avoid unnecessary strcmp()Vladislav Egorov2017-05-221-5/+9
| | | | | | | | strcmp() is slow. Initiate comparison with "__LINE__" or "__FILE__" only if the identifier starts with '_', which is rare. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Conditionally allow redeclaration of built-in variablesJohn Brooks2017-05-203-0/+19
| | | | | | | | | | | | | Conditional on allow_glsl_builtin_variable_redeclaration driconf option. v2 (Samuel Pitoiset): - Rename allow_glsl_builtin_redeclaration -> allow_glsl_builtin_variable_redeclaration - style: put spaces after 'if' Signed-off-by: John Brooks <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]>
* st/mesa: don't mark the program as in cache_fallback when there is cache missTimothy Arceri2017-05-201-1/+1
| | | | | | | | | | | | | | | | | | When we fallback currently the gl_program objects are re-allocated. This is likely to change when the i965 cache lands, but for now this fixes a crash when using MESA_GLSL=cache_fb. This env var simulates the fallback path taken when a tgsi cache item doesn't exist due to being evicted previously or some kind of error. Unlike i965 we are always falling back at link time so it's safe to just re-allocate everything. We will be unnecessarily freeing and re-allocate a bunch of things here but it's probably not a huge deal, and can be changed when the i965 code lands. Fixes: 0e9991f957e2 ("glsl: don't reference shader prog data during cache fallback") Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: simplify link_assign_uniform_storage() a bitSamuel Pitoiset2017-05-161-8/+9
| | | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Elie Tournier <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: include image qualifiers when printing IRNicolai Hähnle2017-05-121-3/+17
| | | | | | | | v2: - fix copy&paste errors noted by Samuel - rebase Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: order indices for images inside a struct arraySamuel Pitoiset2017-05-121-11/+17
| | | | | | | | ARB_bindless_texture allows images to be declared inside structures. This is similar to samplers. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: add parcel_out_uniform_storage::set_opaque_indices() helperSamuel Pitoiset2017-05-121-54/+65
| | | | | | | | In order to sort indices for images inside a struct array we need to do something similar to samplers. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: simplify set_opaque_binding()Samuel Pitoiset2017-05-111-21/+20
| | | | | | | While we are at it, update the GLSL spec comment. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: add missing check for samplers in set_opaque_binding()Samuel Pitoiset2017-05-111-0/+2
| | | | | | | | | Like images, this prevents out-of-bound access when the explicit binding layout qualifier is used with an array which contains too much samplers. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* Android: amd/common: fix dependency on libmesa_nirRob Herring2017-05-111-0/+1
| | | | | | | | | | | | | | | | | | Building libmesa_amd_common fails with: external/mesa/src/amd/common/ac_shader_info.c:23:10: fatal error: 'nir/nir.h' file not found ^ external/mesa/src/compiler/nir/nir.h:48:10: fatal error: 'nir_opcodes.h' file not found ^ libmesa_amd_common now depends on libmesa_nir, so add it as a dependency and export the necessary directories. Fixes: 224cf29 "radv/ac: add initial pre-pass for shader info gathering" Signed-off-by: Rob Herring <[email protected]> Reviewed-by: Chih-Wei Huang <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* nir: Embed the shader_info in the nir_shader againJason Ekstrand2017-05-0914-96/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit e1af20f18a86f52a9640faf2d4ff8a71b0a4fa9b changed the shader_info from being embedded into being just a pointer. The idea was that sharing the shader_info between NIR and GLSL would be easier if it were a pointer pointing to the same shader_info struct. This, however, has caused a few problems: 1) There are many things which generate NIR without GLSL. This means we have to support both NIR shaders which come from GLSL and ones that don't and need to have an info elsewhere. 2) The solution to (1) raises all sorts of ownership issues which have to be resolved with ralloc_parent checks. 3) Ever since 00620782c92100d77c660f9783504c6d80fa1d58, we've been using nir_gather_info to fill out the final shader_info. Thanks to cloning and the above ownership issues, the nir_shader::info may not point back to the gl_shader anymore and so we have to do a copy of the shader_info from NIR back to GLSL anyway. All of these issues go away if we just embed the shader_info in the nir_shader. There's a little downside of having to copy it back after calling nir_gather_info but, as explained above, we have to do that anyway. Acked-by: Timothy Arceri <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Don't allow redefining builtin functions on GLSL 1.00.Eric Anholt2017-05-081-2/+13
| | | | | | | | | | The spec text cited above says you can't, but only the GLSL 3.00 (redefine or overload) case was implemented. Fixes dEQP scoping.invalid.redefine_builtin_fragment/vertex. Reviewed-by: Samuel Pitoiset <[email protected]> Tested-by: Matt Turner <[email protected]>
* glsl: Restrict func redeclarations (not just redefinitions) on GLSL 1.00.Eric Anholt2017-05-081-0/+10
| | | | | | | | | Fixes DEQP's scoping.invalid.redeclare_function_fragment/vertex. v2: Fix accidental rejection of prototype+decl. Reviewed-by: Samuel Pitoiset <[email protected]> (v1) Tested-by: Matt Turner <[email protected]>
* glsl: Ban #undefining __LINE__ and friends on GLES2.Eric Anholt2017-05-081-5/+2
| | | | | | | Fixes deqp_gles2 undefine_invalid_object_* failures. Reviewed-by: Samuel Pitoiset <[email protected]> Tested-by: Matt Turner <[email protected]>
* glsl: Restrict functions to not return arrays or SOAs in GLSL 1.00.Eric Anholt2017-05-083-0/+31
| | | | | | | | | | | | | | | From the spec, Arrays are allowed as arguments, but not as the return type. [...] The return type can also be a structure if the structure does not contain an array. Fixes DEQP shaders.functions.invalid.return_array_in_struct_fragment. v2: Spec cite wording change Reviewed-by: Samuel Pitoiset <[email protected]> Tested-by: Matt Turner <[email protected]>
* nir: fix (hopefully) windows buildRob Clark2017-05-082-4/+4
| | | | | Fixes: 53aa109b ("nir: add pass to lower atomic counters to SSBO") Signed-off-by: Rob Clark <[email protected]>
* glsl: apply the image format for members of structuresSamuel Pitoiset2017-05-081-8/+29
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: store the image format in glsl_struct_fieldSamuel Pitoiset2017-05-083-1/+11
| | | | | | | | ARB_bindless_texture allows to declare image types inside structures, which means we need to keep track of the format. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: destroy function and subroutine hash tablesGrazvydas Ignotas2017-05-081-0/+10
| | | | | | | | | Just like other type hash tables are destroyed in _mesa_glsl_release_types(), also destroy the ones for function and subroutine types. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir: Fix missing snprintf symbol on Windows.Jose Fonseca2017-05-071-0/+4
| | | | | | | | | | Copy nir_print.c's snprintf definition for now, to unbreak Windows builds. We can and should cleanup all snprintf definitions in a follow up change, but I rather not leave Windows build broken any further. Trivial.
* glsl: skip tree grafting for sampler and image typesNicolai Hähnle2017-05-061-0/+11
| | | | | | | v2: - use is_sampler()/is_image() instead (Samuel Pitoiset) Reviewed-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: teach lower_ubo_reference about samplers inside structuresSamuel Pitoiset2017-05-061-0/+15
| | | | | | | | | | | | | | In a situation like: (tex vec4 (record_ref (var_ref f) tex) (constant vec2 (0.000000 0.000000)) 0 1 () ) The sampler needs to be lowered, otherwise this ends up with "ir_dereference_variable @ 0x229a100 specifies undeclared variable `ubo_load_temp' @ 0x2290440" Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: link bindless layout qualifiersSamuel Pitoiset2017-05-061-0/+44
| | | | | | | | | | | | From section 4.4.6 of the ARB_bindless_texture spec: "If both bindless_sampler and bound_sampler, or bindless_image and bound_image, are declared at global scope in any compilation unit, a link- time error will be generated." Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: do not count bindless samplers/images when linking uniformsSamuel Pitoiset2017-05-061-2/+2
| | | | | | | | | | | | | From section 2.14.8 of the ARB_bindless_texture spec: "(modify second paragraph, p. 126) ... against the MAX_COMBINED_TEXTURE_IMAGE_UNITS limit. Samplers accessed using texture handles (section 3.9.X) are not counted against this limit." Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: lower bindless sampler/image packed varyingsSamuel Pitoiset2017-05-061-0/+14
| | | | | | | | 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: implement ARB_bindless_texture conversionsSamuel Pitoiset2017-05-063-10/+84
| | | | | | | | | | | | | | | | | | | | | | | | 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 used with constructorsSamuel Pitoiset2017-05-061-2/+14
| | | | | | | | | | | | | | | | | | | | | For the explicit conversions. From section 4.1.7 of the ARB_bindless_texture spec: "Samplers are represented using 64-bit integer handles, and may be converted to and from 64-bit integers using constructors." From section 4.1.X of the ARB_bindless_texture spec: "Images are represented using 64-bit integer handles, and may be converted to and from 64-bit integers using constructors." v3: - add spec comment - update the glsl error message Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> (v2) Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: add is_valid_constructor() helper functionSamuel Pitoiset2017-05-061-2/+8
| | | | | | | | | This will help for the explicit conversions for sampler and image types as specified by ARB_bindless_texture. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: add ARB_bindless_texture operationsSamuel Pitoiset2017-05-062-0/+26
| | | | | | | | 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: allow bindless samplers/images to be initializedSamuel Pitoiset2017-05-061-3/+14
| | | | | | | | | | | | | | | | | | | From section 4.1.7 of the ARB_bindless_texture spec: "Samplers may be declared as shader inputs and outputs, as uniform variables, as temporary variables, and as function parameters." From section 4.1.X of the ARB_bindless_texture spec: "Images may be declared as shader inputs and outputs, as uniform variables, as temporary variables, and as function parameters." v3: - add spec comment - update the glsl error message Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[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-064-7/+9
| | | | | | | | | | | | | | | 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: relax bindless sampler arrays indexingSamuel Pitoiset2017-05-061-1/+7
| | | | | | | | | | | | | From section 4.1.7 of the ARB_bindless_texture spec: "Samplers aggregated into arrays within a shader (using square brackets []) can be indexed with arbitrary integer expressions." v3: - update spec comment formatting Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: reject bindless samplers/images frag inputs without 'flat'Samuel Pitoiset2017-05-061-0/+20
| | | | | | | | | | | | | | | | | | | From section 4.3.4 of the ARB_bindless_texture spec "(modify last paragraph, p. 35, allowing samplers and images as fragment shader inputs) ... Fragment inputs can only be signed and unsigned integers and integer vectors, floating point scalars, floating-point vectors, matrices, sampler and image types, or arrays or structures of these. Fragment shader inputs that are signed or unsigned integers, integer vectors, or any double-precision floating- point type, or any sampler or image type must be qualified with the interpolation qualifier "flat"." v3: - update spec comment formatting Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: allow bindless samplers/images as vertex shader inputsSamuel Pitoiset2017-05-061-0/+14
| | | | | | | | | | | | | | | | From section 4.3.4 of the ARB_bindless_texture spec: "(modify third paragraph of the section to allow sampler and image types) ... Vertex shader inputs can only be float, single-precision floating-point scalars, single-precision floating-point vectors, matrices, signed and unsigned integers and integer vectors, sampler and image types." v3: - update spec comment formatting Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: allow bindless samplers/images as varying variablesSamuel Pitoiset2017-05-061-0/+20
| | | | | | | | | | | | | | | | | | | | | | | From section 4.3.4 of the ARB_bindless_texture spec: "(modify third paragraph of the section to allow sampler and image types) ... Vertex shader inputs can only be float, single-precision floating-point scalars, single-precision floating-point vectors, matrices, signed and unsigned integers and integer vectors, sampler and image types." From section 4.3.6 of the ARB_bindless_texture spec: "Output variables can only be floating-point scalars, floating-point vectors, matrices, signed or unsigned integers or integer vectors, sampler or image types, or arrays or structures of any these." v3: - add spec comment Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>