summaryrefslogtreecommitdiffstats
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* glsl: pass the ir_variable object to set_opaque_binding()Samuel Pitoiset2017-06-141-3/+4
| | | | | | | | In order to set the explicit binding value for bindless samplers/images. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: process uniform images declared bindlessSamuel Pitoiset2017-06-142-9/+85
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: process uniform samplers declared bindlessSamuel Pitoiset2017-06-142-11/+95
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* mesa: add support for glUniformHandleui64*ARB()Samuel Pitoiset2017-06-143-0/+9
| | | | | | | | | | | | | | Bindless sampler/image handles are represented using 64-bit unsigned integers. The ARB_bindless_texture spec says: "The error INVALID_OPERATION is generated by UniformHandleui64{v}ARB if the sampler or image uniform being updated has the "bound_sampler" or "bound_image" layout qualifier"." Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: simplify an assertion in lower_ubo_referenceNicolai Hähnle2017-06-131-1/+1
| | | | | | Struct types are now equal when they're structurally equal. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: simplify validate_intrastage_arraysNicolai Hähnle2017-06-131-8/+0
| | | | | | Struct types are now equal when they are structurally equal. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: simplify varying matchingNicolai Hähnle2017-06-131-32/+9
| | | | | | Unnamed struct types are now equal if they have the same field. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: remove redundant record_compare check when linking globalsNicolai Hähnle2017-06-131-22/+17
| | | | | | | | | | | | | Unnamed struct types are now equal across stages based on the fields they contain, so overriding the type to make sure names match has become unnecessary. The check was originally introduced in commit 955c93dc089f ("glsl: Match unnamed record types across stages.") v2: clarify the commit message Reviewed-by: Timothy Arceri <[email protected]>
* glsl: stop considering unnamed and named structures equalNicolai Hähnle2017-06-131-6/+2
| | | | | | | | | | | | Previously, if an unnamed and a named struct contained the same fields, they were considered the same type during linking of globals. The discussion around commit e018ea81bf58 ("glsl: Structures must have same name to be considered same type.") doesn't seem to have considered this thoroughly, and I see no evidence that an unnamed struct should ever be considered to be the same type as a named struct. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: give all unnamed structs the same nameNicolai Hähnle2017-06-131-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As a result, unnamed structs defined in different places of the program are considered the same types if they have the same fields in the same order. This will simplify matching of global variables whose type is an unnamed struct. It also fixes a memory leak when the same shader containing unnamed structs is compiled over and over again: instead of creating a new type each time, the existing type is re-used. Finally, this does have the effect that some previously rejected programs are now accepted, such as: struct { float a; } s1; struct { float a; } s2; s2 = s1; C/C++ do not allow that, but GLSL does seem to want to treat unnamed structs with the same fields as the same type at least during linking (and apparently, some applications require it), so it seems odd to treat them as different types elsewhere. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: do not add unnamed struct types to the symbol tableNicolai Hähnle2017-06-131-1/+1
| | | | | | | We removed the need for lookups, and we will assign them all the same name in the future. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: do not lookup struct types by typenameNicolai Hähnle2017-06-133-6/+10
| | | | | | | | | | | | | | | | | | | | | This changes the logic during the conversion of the declaration list struct S { ... } v; from AST to IR, but should not change the end result. When assigning the type of v, instead of looking `S' up in the symbol table, we read the type from the member variable of ast_struct_specifier. This change is necessary for the subsequent change to how anonymous types are handled. v2: remove a type override when redefining a structure; should be the same type in that case anyway Reviewed-by: Timothy Arceri <[email protected]>
* glsl: fix a race condition when inserting new typesNicolai Hähnle2017-06-132-40/+32
| | | | | | | | | | | | By splitting glsl_type::mutex into two, we can avoid dropping the hash mutex while creating the new type instance (e.g. struct/record, interface). This fixes a time-of-check/time-of-use race where two threads would simultaneously attempt to create the same type but end up with different instances of glsl_type. Reviewed-by: Timothy Arceri <[email protected]>
* glsl/lower_distance: only set max_array_access for 1D clip dist arraysDave Airlie2017-06-121-1/+1
| | | | | | | | | | | | | | The max_array_access field applies to the first dimension, which means we only want to set it for the 1D clip dist arrays. This fixes an ir_validate assert seen with KHR-GL44.cull_distance.functional on nouveau and radeon with debug builds. Fixes: a08c4ebbe (glsl: rewrite clip/cull distance lowering pass) Reviewed-by: Timothy Arceri <[email protected]> Tested-by: Tobias Klausmann <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* nir: make various getters take const pointersGrazvydas Ignotas2017-06-102-13/+14
| | | | | | | | This will allow to constify other things. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* glsl: Fix gl_shader_stage enum unsigned comparisonRob Herring2017-06-084-4/+14
| | | | | | | | | | | Replace -1 with MESA_SHADER_NONE enum value to fix sign related warning: external/mesa3d/src/compiler/glsl/link_varyings.cpp:1415:25: warning: comparison of constant -1 with expression of type 'gl_shader_stage' is always true [-Wtautological-constant-out-of-range-compare] (consumer_stage != -1 && consumer_stage != MESA_SHADER_FRAGMENT))) { ~~~~~~~~~~~~~~ ^ ~~ Reviewed-by: Nicolai Hähnle <[email protected]> Signed-off-by: Rob Herring <[email protected]>
* Fix glcpp test expectationsIago Toral Quiroga2017-06-082-3/+6
| | | | | | | | | | With commit f7741985be0234 we have changed some preprocessor error messages and warnings. Adapt related glcpp tests expectations accordingly. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101336 Tested-by: Vinson Lee <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: fix bounds check in blob_overwrite_bytesRob Herring2017-06-071-1/+1
| | | | | | | | | | | | | | | | | clang gives a warning in blob_overwrite_bytes because offset type is size_t which is unsigned: src/compiler/glsl/blob.c:110:15: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare] if (offset < 0 || blob->size - offset < to_write) ~~~~~~ ^ ~ Remove the less than 0 check to fix this. Additionally, if offset is greater than blob->size, the 2nd check would be false due to unsigned math. Rewrite the check to avoid subtraction. Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Rob Herring <[email protected]>
* nir: Delete nir_array.hThomas Helland2017-06-072-100/+0
| | | | | Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* nir: Port to u_dynarrayThomas Helland2017-06-072-5/+5
| | | | | Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* nir: Remove unused includeThomas Helland2017-06-071-1/+0
| | | | | Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* glcpp: fix #undef to match latest spec update and GLSLang implementationIago Toral Quiroga2017-06-071-14/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLSL ES spec includes the following: "It is an error to undefine or to redefine a built-in (pre-defined) macro name." But desktop GLSL doesn't. This has sparked some discussion in Khronos, and the final conclusion was to update the GLSL 4.50 spec to include the following: "By convention, all macro names containing two consecutive underscores ( __ ) are reserved for use by underlying software layers. Defining or undefining such a name in a shader does not itself result in an error, but may result in unintended behaviors that stem from having multiple definitions of the same name. All macro names prefixed with “GL_” (“GL” followed by a single underscore) are also reserved, and defining or undefining such a name results in a compile-time error." In other words, undefining GL_* names should be an error, but undefining other names with a double underscore in them is not strictly prohibited in desktop GLSL. This patch fixes the preprocessor to apply these rules, following exactly the implementation already present in GLSLang. This fixes some tests in CTS. Khronos bug: https://cvs.khronos.org/bugzilla/show_bug.cgi?id=16003 Fixes: KHR-GL45.shaders.preprocessor.definitions.undefine_core_profile_vertex KHR-GL45.shaders.preprocessor.definitions.undefine_core_profile_fragment Reviewed-by: Samuel Pitoiset <[email protected]>
* tree-wide: remove trailing backslashEric Engestrom2017-06-071-1/+1
| | | | | | | | | Simple search for a backslash followed by two newlines. If one of the newlines were to be removed, this would cause issues, so let's just remove these trailing backslashes. Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* 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]>