summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl_to_nir: zero-initialize var->data.descriptor_setNicolai Hähnle2017-07-051-0/+1
| | | | | | | This is convenient for backends that support both Vulkan and OpenGL while lowering samplers to derefs with nir_lower_samplers_as_deref. Reviewed-by: Timothy Arceri <[email protected]>
* glsl/blob: add valgrind checks that written data is definedNicolai Hähnle2017-07-051-0/+12
| | | | | | | | | | | | | Undefined data will eventually trigger a valgrind error while computing its CRC32 while writing it into the disk cache, but at that point, it is basically impossible to track down where the undefined data came from. With this change, finding the origin of undefined data becomes easy. v2: remove duplicate VALGRIND_CFLAGS (Emil) Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* glsl: explicitly zero out padding to gl_shader_variable bitfieldNicolai Hähnle2017-07-051-1/+4
| | | | | | | | | | Otherwise, the padding bits remain undefined, which leads to valgrind errors when storing the gl_shader_variable in the disk cache. v2: use rzalloc instead of an explicit padding member variable Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: look for multiple variables simultaneously with find_assignment_visitorNicolai Hähnle2017-07-051-41/+81
| | | | | | | | | | | | Save some passes over the IR. v2: redesign to make the users of find_assignments more readable v3: - fix missing ! - add some comments and make the num_found check more explicit (Timothy) Reviewed-by: Ian Romanick <[email protected]> (v1) Reviewed-by: Timothy Arceri <[email protected]>
* glsl: simplify disable_varying_optimizations_for_ssoNicolai Hähnle2017-07-031-18/+11
| | | | | | | | | We always have stage == first and stage == last when first == last, so drop the special case. Also rephrase the comment to make the logic clearer. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: always print non-zero var->data.location_fracNicolai Hähnle2017-07-031-1/+1
| | | | | | | This is helpful in debugging varying assignments. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: do not call link_xfb_stride_layout_qualifiers() for fragment shadersJuan A. Suarez Romero2017-06-261-2/+5
| | | | | | | | | | | | | | | | | xfb only applies to the latest stage before the fragment shader, so there is no need to invoke it in the fragment shader. Fixes: KHR-GL45.enhanced_layouts.xfb_stride_of_empty_list KHR-GL45.enhanced_layouts.xfb_stride_of_empty_list_and_api v2: do reset only if shaders provide an explicit stride v3: do not call link_xfb_stride_layout_qualifiers() for fragment shaders (Timothy) Reviewed-by: Timothy Arceri <[email protected]> Signed-off-by: Juan A. Suarez Romero <[email protected]>
* glsl: tidy up int declarationTimothy Arceri2017-06-221-2/+1
| | | | | | Reviewed-by: Lionel Landwerlin <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: fix typo in commentTimothy Arceri2017-06-221-1/+1
| | | | | | Reviewed-by: Lionel Landwerlin <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: Track whether uniforms are active per stageKenneth Graunke2017-06-223-0/+9
| | | | | | | | | | for finer granularity state flagging v2: Marek - use a bitmask, add shader cache support Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Update build instructions for int64.glslIan Romanick2017-06-201-2/+2
| | | | | | Trivial Signed-off-by: Ian Romanick <[email protected]>
* glsl: Fix indent in dump codeElie Tournier2017-06-201-7/+7
| | | | | Signed-off-by: Elie Tournier <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: gl_Max{Vertex,Fragment}UniformComponents exist in all desktop GL versionsIago Toral Quiroga2017-06-191-7/+9
| | | | | | | | | | The current implementation assumed that these were replaced in GLSL >= 4.10 by gl_Max{Vertex,Fragment}UniformVectors, however this is not true: both built-ins should be produced from GLSL 4.10 onwards. This was raised by new CTS tests that are in development. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: add ir_variable::contains_bindless()Samuel Pitoiset2017-06-141-0/+11
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: set the explicit binding value for bindless samplers/imagesSamuel Pitoiset2017-06-141-6/+29
| | | | | | | | | This handles a situation like: layout (bindless_sampler, binding = 7) uniform sampler2D; Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* 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: 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/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]>
* glsl: Fix gl_shader_stage enum unsigned comparisonRob Herring2017-06-083-4/+13
| | | | | | | | | | | 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]>
* 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]>
* 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]>
* 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]>