aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
Commit message (Collapse)AuthorAgeFilesLines
* meson: drop duplicate inc_nir from libglslEric Engestrom2019-10-071-1/+1
| | | | | Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
* glsl: Add helperInvocationEXT() builtinCaio Marcelo de Oliveira Filho2019-09-303-0/+47
| | | | | | | | | | | From EXT_demote_to_helper_invocation, implemented with the existing nir_intrinsic_is_helper_invocation. Such builtin is necessary when using `demote` because we can't redefine the value of gl_HelperInvocation (since it is an input variable). Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Parse `demote` statementCaio Marcelo de Oliveira Filho2019-09-305-1/+49
| | | | | | | When the EXT_demote_to_helper_invocation extension is enabled, `demote` is treated as a keyword, and produces an ir_demote. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add ir_demoteCaio Marcelo de Oliveira Filho2019-09-309-0/+81
| | | | | | | | | | | | | | | To represent the new `demote` keyword when using EXT_demote_to_helper_invocation extension. Most of the changes are to include it in the visitors. Demote is not considered a control flow, so also include an empty visit member function in ir_control_flow_visitor. Only NIR actually supports `demote`, so assert the translations for TGSI and Mesa's gl_program -- since the demote is not expected to appear for those. Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Extension boilerplate for EXT_demote_to_helper_invocationCaio Marcelo de Oliveira Filho2019-09-302-0/+3
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* 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]>
* Move blob from compiler/ to util/Jason Ekstrand2019-09-192-340/+0
| | | | | | | | There's nothing whatsoever compiler-specific about it other than that's currently where it's used. Reviewed-by: Kristian H. Kristensen <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]>
* glsl/nir: Add and use a gl_nir_link() functionCaio Marcelo de Oliveira Filho2019-09-102-0/+24
| | | | | | | | | Perform all the NIR linking steps in order. Change iris and i965 to use it. Suggested by Alejandro. v2: Add gl_nir_linker_options struct. Reviewed-by: Alejandro Piñeiro <[email protected]> [v1]
* glsl/nir: Fill in the Parameters in NIR linkerCaio Marcelo de Oliveira Filho2019-09-103-2/+76
| | | | | | | | | | | | | | | | | | | | | The parameter lists were not being created nor filled since i965 doesn't use them. In Gallium they are used for uniform handling, so add a way to fill them. The gl_uniform_storage struct got two new fields that let us go - from a Parameter to the matching UniformStorage and, - from the variable to the *first* UniformStorage without relying on names -- since they are optional for ARB_gl_spirv. Later patches will make use of them. v2: Do not fill parameters for i965. (Timothy) Use uint32_t for the new attributes. (Marek) v3: Serialize the new fields. (Timothy) Reviewed-by: Timothy Arceri <[email protected]>
* glsl/nir: Avoid overflow when setting max_uniform_locationCaio Marcelo de Oliveira Filho2019-09-101-1/+2
| | | | | | | | | Don't use the UNMAPPED_UNIFORM_LOC (-1) to set the unsigned max_uniform_location. Those unmapped uniforms don't have to be accounted at this point. Fixes: 7a9e5cdfbb9 ("nir/linker: Add gl_nir_link_uniforms()") Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl/tests: Handle windows \r\n new linesDylan Baker2019-09-101-1/+1
| | | | | | | | | Currently the praser for s expressions assumes that newlines will be \n, resulting in incorrect parsing on windows, where the newline is \r\n. This patch just adds \r? to the regular expression used to parse the s expressions, which fixes at 1 test on windows. Reviewed-by: Eric Engestrom <[email protected]>
* glsl: Fix unroll of do{} while(false) like loopsDanylo Piliaiev2019-09-062-17/+41
| | | | | | | | | | | | | | | For loops which condition is false on the first iteration iteration count was falsely calculated under the assumption that loop's condition is true until it becomes false, meaning it's true at least one time. Now such loops are reported as having 0 iteration. Similar to the fix e71fc7f2 done in NIR. Fixes tests/shaders/glsl-fs-loop-while-false-02.shader_test Signed-off-by: Danylo Piliaiev <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir: Carve out nir_lower_samplers from GLSL code.Timur Kristóf2019-09-061-127/+1
| | | | | | | | | | | | Lowering samplers is needed to produce NIR that can actually be consumed by some gallium drivers, so it doesn't make sense to to keep it only in the GLSL code. This commit introduces nir_lower_samplers to compiler/nir, while maintains the GL-specific function too. Signed-off-by: Timur Kristóf <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* gallium: Plumb through a way to disable GLSL const loweringConnor Abbott2019-09-051-1/+2
| | | | | | | | | | For radeonsi, we will prefer the NIR pass as it'll generate better code (some index calculation and a single load vs. a load, then index calculation, then another load) and oftentimes NIR optimization can kick in and make all the access indices constant. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Store the precision for a function return typeNeil Roberts2019-09-043-1/+30
| | | | | | | | | The precision for a function return type is now stored in ir_function_signature. This will later be useful to implement mediump to float16 lowering. In the meantime it is also useful to catch errors where a function is redeclared with a different precision. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: replace 'x + (-x)' with constant 0Pierre-Eric Pelloux-Prayer2019-08-291-0/+12
| | | | | | | | | | | | | This fixes a hang in shadertoy for radeonsi where a buffer was initialized with: value -= value with value being undefined. In this case LLVM replace the operation with an assignment to NaN. Cc: 19.1 19.2 <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111241 Reviewed-by: Marek Olšák <[email protected]>
* compiler/glsl: Fix warning about unused functionCaio Marcelo de Oliveira Filho2019-08-231-1/+3
| | | | | | | | | | The helper check_node_type() is only used when DEBUG is set (in the function below), but ASSERTED macro uses NDEBUG. So just guard the helper with #ifdef. If we see more such cases we might consider a ASSERTED-like macro for the DEBUG case. Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Add explicit signs to image min/max intrinsicsJason Ekstrand2019-08-214-12/+32
| | | | | | | | | | | This better matches all the other atomic intrinsics such as those for SSBOs and shared variables where the sign is part of the intrinsic opcode. Both generators (GLSL and SPIR-V) know the sign from the type of the image variable or handle. In SPIR-V, signed min/max are separate opcodes from unsigned. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* mesa/compiler: rework tear down of builtin/typesLionel Landwerlin2019-08-217-67/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | The issue we're running into when running CTS is that glsl types are deleted while builtins depending on them are not. This happens because on one hand we have glsl types ref counted, but builtins are not. Instead builtins are destroyed when unloading libGL or explicitly calling glReleaseShaderCompiler(). This change removes almost entirely any dealing with glsl types ref/unref by letting the builtins deal with it instead. In turn we introduce a builtin ref count mechanism. Each GL context takes a reference on the builtins when compiling a shader for the first time. It releases the reference when the context is destroyed. It can also explicitly release those when glReleaseShaderCompiler() is called. Finally we also take a reference on the glsl types when loading libGL to avoid recreating glsl types too often. v2: Ensure we take a reference if we don't have one in link step (Lionel) Signed-off-by: Lionel Landwerlin <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110796 Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl/tests: take refs on glsl typesLionel Landwerlin2019-08-219-18/+64
| | | | | | | | | Much like each driver, tests as standalone entities must take references on the glsl types. Signed-off-by: Lionel Landwerlin <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl/standalone: init shader stage in init_gl_program()Vasily Khoruzhick2019-08-171-2/+4
| | | | | | | | | | | Otherwise lima standalone compiler fails when trying to compile fragment shader with: lima_compiler: ../src/compiler/nir/nir.c:55: nir_shader_create: Assertion `si->stage == stage' failed Reviewed-by: Qiang Yu <[email protected]> Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Vasily Khoruzhick <[email protected]>
* win32: unify strcasecmp definitionsErik Faye-Lund2019-08-151-0/+1
| | | | | | | | | There was two incompatible definitions of strcasecmp, which lead to a compiler warning. Let's clean this up by only leaving one of them, and using that one all the time. Signed-off-by: Erik Faye-Lund <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: fixup u64-warningErik Faye-Lund2019-08-151-1/+1
| | | | | | | | | Similarly to the unsigned-version, we need to first cast the result to a suiting integer before negating the number, otherwise we'll trigger a warning. Signed-off-by: Erik Faye-Lund <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Optimize the SoftFP64 shader when first creating it.Kenneth Graunke2019-08-121-0/+13
| | | | | | | | | | | | | By optimizing the shader before inlining, we avoid having to redo this work for each inlined copy of a function. It should also reduce the memory consumption a bit. This cuts the KHR-GL46.arrays_of_arrays_gl.SubroutineFunctionCalls2 runtime by 25% on my Icelake. That test compiles many shaders, which contain large types (dmat4) and division (expensive operations). Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* nir: add atomic_inc_wrap/atomic_dec_wrap image intrinsicsPierre-Eric Pelloux-Prayer2019-08-061-1/+9
| | | | Reviewed-by: Marek Olšák <[email protected]>
* glsl: add EXT_shader_image_load_store new image functionsPierre-Eric Pelloux-Prayer2019-08-062-0/+14
| | | | | | | | This extension has 2 functions that are missing from the ARB versions: - imageAtomicIncWrap - imageAtomicDecWrap Reviewed-by: Marek Olšák <[email protected]>
* glsl: add EXT_shader_image_load_store keywords to lexerPierre-Eric Pelloux-Prayer2019-08-061-36/+36
| | | | | | All of them already existed for ARB_shader_image_load_store. Reviewed-by: Marek Olšák <[email protected]>
* glsl: add size qualifiers from EXT_shader_image_load_storePierre-Eric Pelloux-Prayer2019-08-062-39/+93
| | | | Reviewed-by: Marek Olšák <[email protected]>
* glsl: handle differences between ARB/EXT versions of shader_image_load_storePierre-Eric Pelloux-Prayer2019-08-064-3/+21
| | | | Reviewed-by: Marek Olšák <[email protected]>
* glcpp: use pre-expansion line number for __LINE__Jonathan Marek2019-08-061-4/+7
| | | | | | | | | | | Fixes the following deqp tests: dEQP-GLES2.functional.shaders.preprocessor.predefined_macros.line_2_* It don't see the spec requiring this, but it seems to be better, as the clang preprocessor for example has this behavior. Signed-off-by: Jonathan Marek <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* meson: drop unused dep_{thread,dl}Eric Engestrom2019-08-031-1/+1
| | | | | | | | Unused as of last commit. Signed-off-by: Eric Engestrom <[email protected]> Acked-by: Eric Anholt <[email protected]> Tested-by: Vinson Lee <[email protected]>
* meson: replace libmesa_util with idep_mesautilEric Engestrom2019-08-032-3/+3
| | | | | | | | | | | This automates the include_directories and dependencies tracking so that all users of libmesa_util don't need to add them manually. Next commit will remove the ones that were only added for that reason. Signed-off-by: Eric Engestrom <[email protected]> Acked-by: Eric Anholt <[email protected]> Tested-by: Vinson Lee <[email protected]>
* nir: Stop whacking gl_FrontFacing to a system valueJason Ekstrand2019-08-011-7/+2
| | | | | | | | | | We have a cap bit for gallium and a GLSL compiler flag to control this. Just trust what GLSL gives us and stop forcing it. In order for this to be safe, we have to advertise another cap in some of the gallium drivers. Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* autotools: delete leftover script wrapperEric Engestrom2019-07-311-16/+0
| | | | | | | | Randomly came across this file, which was likely only used by autotools to pass arguments to the test. Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* tree-wide: replace MAYBE_UNUSED with ASSERTEDEric Engestrom2019-07-313-4/+4
| | | | | | Suggested-by: Jason Ekstrand <[email protected]> Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* compiler: replace MAYBE_UNUSED with UNUSEDEric Engestrom2019-07-311-1/+1
| | | | | | | | MAYBE_UNUSED is going away, so let's replace legitimate uses of it with UNUSED, which the former aliased to so far anyway. Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add builtin functions for EXT_texture_shadow_lodPaulo Zanoni2019-07-301-0/+26
| | | | | | | | | | | | | With the help of Sagar, Ian and Ivan. v2: Fix dependencies (Ian Romanick) v3: 1) fix function name (Marek Olsak) 2) Add check for extension enable (Marek Olsak) Signed-off-by: Paulo Zanoni <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Allow _textureCubeArrayShadow function to accept ir_texture_opcodePaulo Zanoni2019-07-301-4/+19
| | | | | | | | | | | This will be used to support one of the function from Ext_texture_shadow_lod specification. With the help of Sagar, Ian and Ivan. Signed-off-by: Paulo Zanoni <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: extension boilerplate for EXT_texture_shadow_lodPaulo Zanoni2019-07-302-0/+3
| | | | | | | | With the help of Sagar, Ian and Ivan. Signed-off-by: Paulo Zanoni <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Treat gl_FragCoord as a varying even when it's a system valueJason Ekstrand2019-07-291-1/+3
| | | | | | | This fixes glsl-fcoord-invariant-pass.shader_test on drivers that set GLSLFragCoordIsSysVal which includes radeonsi among others. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: report no function instead of empty candidate listErik Faye-Lund2019-07-251-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When generating the error message for a missing function error where all available overloads were missing due to a too low GLSL version, we used to report something like this: ---8<--- 0:224(14): error: no matching function for call to `textureCubeLod(samplerCube, vec3, float)'; candidates are: 0:224(14): error: type mismatch ---8<--- This is a pretty confusing error message, and can throw people off when debugging. So let's instead check if any overload is available before we decide what to print. This allow us to report something like this instead: ---8<--- 0:224(14): error: no function with name 'textureCubeLod' 0:224(14): error: type mismatch ---8<--- This is arguably easier to understand for programmers, and doesn't send you on a wild goose chase to figure out what argument is wrong just because you stopped reading the message prematurely. I'm of course referring to a friend, not me. For sure. I would never do that. Signed-off-by: Erik Faye-Lund <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* util: use standard name for snprintf()Eric Engestrom2019-07-195-20/+19
| | | | | | | Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Optionally declare gl_PointCoord as a system valueAndreas Baierl2019-07-181-2/+6
| | | | | | Signed-off-by: Andreas Baierl <[email protected]> Reviewed-by: Qiang Yu <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl/shader_cache: handle SPIR-V shadersAlejandro Piñeiro2019-07-121-5/+5
| | | | | | | | | Right now we don't have cache support for SPIR-V shaders (from ARB_gl_spirv). Right now they are properly skipped because they fall on the ff shader code path (no key, no name), but it would be better to update current comments, and add some guards. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
* nir/linker: Initialize UniformDataDefaults when using SPIR-VArcady Goldmints-Orlov2019-07-122-0/+7
| | | | | | | | | | | | | Allocate UniformDataDefaults and fill in the data defaults when linking a SPIR-V program. Among other things, this allows program serialization to work. It allows the following piglit test (when run on SPIR-V mode) to pass: spec/arb_get_program_binary/execution/uniform-after-restore.shader_test v2: use memcpy to initialize UniformDataDefaults Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
* glsl/serialize: Update write_program_resource_data() to handle NULL input ↵Arcady Goldmints-Orlov2019-07-121-1/+5
| | | | | | and output variable names Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
* glsl/serialize: Handle NULL uniform name in write_uniforms()Arcady Goldmints-Orlov2019-07-121-1/+5
| | | | Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
* nir/linker: Fill TOP_LEVEL_ARRAY_SIZE and STRIDEAntia Puentes2019-07-121-3/+25
| | | | | | | | | | | | | | | | | | | | | | | | From the ARB_program_interface_query specification: "For the property TOP_LEVEL_ARRAY_SIZE, a single integer identifying the number of active array elements of the top-level shader storage block member containing to the active variable is written to <params>. If the top-level block member is not declared as an array, the value one is written to <params>. If the top-level block member is an array with no declared size, the value zero is written to <params>." "For the property TOP_LEVEL_ARRAY_STRIDE, a single integer identifying the stride between array elements of the top-level shader storage block member containing the active variable is written to <params>. For top-level block members declared as arrays, the value written is the difference, in basic machine units, between the offsets of the active variable for consecutive elements in the top-level array. For top-level block members not declared as an array, zero is written to <params>." v2: move top_level_array_size and stride into nir_link_uniforms_state Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
* nir/linker: Compute the offset for non-trivial uniform types.Antia Puentes2019-07-121-10/+23
| | | | | | | | | | | | | | | | | | | | ARB_gl_spirv points that the offset must be explicit, however this is true for 'root' types. For complex types, like struct members or arrays of arraya, it needs to be computed. We are not using the offset stored in the gl_buffer_variables during the uniform blocks linking because currently we do not have a way to relate a gl_buffer_variable with its corresponding gl_uniform_storage. The GLSL path uses the name for that, but we can not rely on that because names are optional in SPIR-V. Notice that uniforms non-backed by a buffer object will have an offset equal to -1, like in the GLSL path. v2: add offset and var_is_in_block as per-variable state in nir_link_uniforms_state (Arcady) Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>