summaryrefslogtreecommitdiffstats
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* nir: Add a bool to float32 lowering passJason Ekstrand2019-01-144-0/+181
| | | | | | | | | | | From @jekstrand's nir-1-bit-bool branch, with improved ior/inot lowering. ior: fmax instead of fadd allows removing the fsat. inot: seq(x, 0) can be better than fsub(1, x). On a2xx, it works better with the scalar instruction set. Reviewed-by: Jonathan Marek <[email protected]>
* src/compiler: use new hash table and set creation helpersCaio Marcelo de Oliveira Filho2019-01-1442-160/+72
| | | | | | | | | Replace calls to create hash tables and sets that use _mesa_hash_pointer/_mesa_key_pointer_equal with the helpers _mesa_pointer_hash_table_create() and _mesa_pointer_set_create(). Reviewed-by: Jason Ekstrand <[email protected]> Acked-by: Eric Engestrom <[email protected]>
* glsl: Fix copying function's out to temp if dereferenced by arrayDanylo Piliaiev2019-01-141-24/+22
| | | | | | | | | | | | | | | Function's out variable could be an array dereferenced by an array: func(v[w[i]]); or something more complicated. Copy index in any case. Fixes: 76c27e47b906 ("glsl: Copy function out to temp if we don't directly ref a variable") Signed-off-by: Danylo Piliaiev <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* spirv: Emit switch conditions on-the-flyJason Ekstrand2019-01-121-36/+26
| | | | | | | | | | | | | Instead of emitting all of the conditions for the cases of a switch statement up-front, emit them on-the-fly as we emit the code for each case. The original justification for this was that we were going to have to build a default case anyway which would need them all. However, we can just trust CSE to clean up the mess in that case. Emitting each condition right before the if statement that uses it reduces register pressure and, in one customer benchmark, reduces spilling and improves performance by about 2x. Reviewed-by: Lionel Landwerlin <[email protected]>
* nir/gcm: Support deref instructionsJason Ekstrand2019-01-121-0/+4
| | | | | | | Even though no one's been brave enough to ever use this pass, I like to keep it functionally working. Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Contain the GLSLang issue #179 workaround to old GLSLangJason Ekstrand2019-01-123-18/+38
| | | | | | | | | | | Instead of applying the workaround universally, detect semi-old GLSLang via the generator ID and only enable the workaround on old GLSLang. This isn't nearly as precise as one would like it to be because the first GLSLang generator id version bump was on October 7, 2017 which is about 1.5 years after the bug was fixed. However, it at least lets us disable it for non-GLSLang and for more modern versions. Reviewed-by: Lionel Landwerlin <[email protected]>
* spirv: Whack sampler/image pointers to uniformJason Ekstrand2019-01-121-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | A long time in a galaxy far far away, there was a GLSLang bug with how it handled samplers passed in as function parameters. (The bug can be found here: https://github.com/KhronosGroup/glslang/issues/179.) Unfortunately, that version was shipped in several apps and has been causing heartburn for our SPIR-V parser ever since. Recent changes to NIR uncovered a moderately old bug in how we work around this issue. In particular, we ended up with a deref_cast from uniform to local which is not a no-op cast so nir_opt_deref wasn't getting rid of the cast. The only reason why it worked before was because someone just happened to call nir_fixup_deref_modes which "fixed" the cast (that shouldn't be happening) and then a later round of copy-prop would get rid of it. The fact that the deref_cast survived that long without causing trouble for other parts of NIR is a bit surprising. Just whacking the mode of the pointer seems to fix it fairly unobtrusively. Currently, only apps with this bug will have a local variable containing an image or sampler. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109304 Reviewed-by: Lionel Landwerlin <[email protected]>
* glsl/nir: keep bool types when native_integers=falseJonathan Marek2019-01-111-98/+63
| | | | | | | | With the new handling of bool types, the conversion to float in glsl_to_nir should not apply to bool types anymore. Signed-off-by: Jonathan Marek <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl/nir: ftrunc for native_integers=false float to int castJonathan Marek2019-01-111-0/+4
| | | | | | | | out_type in the default cast case is always GLSL_TYPE_FLOAT, so we get a mov otherwise. Signed-off-by: Jonathan Marek <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl/nir: int constants as float for native_integers=falseJonathan Marek2019-01-111-4/+12
| | | | | | | | | | | | All alu instructions emitted with native_integers=false expect float (or bool in some cases) constants, so this change is necessary. This will cause changes with some intrinsics which had integer sources, such as nir_intrinsic_load_uniform. Apparently it might cause issues with some opt passes, but perhaps those don't apply in OpenGL ES 2.0 cases? Signed-off-by: Jonathan Marek <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Allow a non-existent sampler deref in nir_lower_samplers_as_derefKenneth Graunke2019-01-111-19/+21
| | | | | | | | | | | | | | GL_ARB_gl_spirv does not provide a sampler deref for e.g. texelFetch(), so we can't assume that both are present and identical. Simply lower each if it is present. Fixes regressions in GL_ARB_gl_spirv tests since I switched everyone to using this pass. Thanks to Alejandro Piñeiro for catching these. Fixes: f003859f97c nir: Make gl_nir_lower_samplers use gl_nir_lower_samplers_as_deref Reviewed-by: Jason Ekstrand <[email protected]> Tested-by: Alejandro Piñeiro <[email protected]>
* glsl: Make invariant outputs in ES fragment shader not to cause errorDanylo Piliaiev2019-01-111-1/+1
| | | | | | | | | | | | | | | | | In all GLSL ES versions output variables in fragment shader are allowed to be invariant. From Section 4.6.1 ("The Invariant Qualifier") GLSL ES 1.00 spec: "Only the following variables may be declared as invariant: ... - Built-in special variables output from the fragment shader." From Section 4.6.1 ("The Invariant Qualifier") GLSL ES 3.00 spec: "Only variables output from a shader can be candidates for invariance." Signed-off-by: Danylo Piliaiev <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107842
* compiler/types: Serialize/deserialize subpass input types correctlyJason Ekstrand2019-01-101-2/+2
| | | | | | | They have glsl_sampler_dim enum values of 8 and 9 which don't work when you & them with 0x7. Fortunately, we have plenty of bits. Reviewed-by: Lionel Landwerlin <[email protected]>
* nir: fix copy-paste error in nir_lower_constant_initializersRhys Perry2019-01-101-2/+2
| | | | | | | | Fixes: 393b59e0772e7bf0426bdf61c740752c4e09dde1 ('nir: Rework nir_lower_constant_initializers() to handle functions') Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Erik Faye-Lund <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl/linker: specify proper direction in location aliasing errorAndres Gomez2019-01-101-5/+10
| | | | | | | | | | | The check for location aliasing was always asuming output variables but this validation is also called for input variables. Fixes: e2abb75b0e4 ("glsl/linker: validate explicit locations for SSO programs") Cc: Iago Toral Quiroga <[email protected]> Signed-off-by: Andres Gomez <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir: Unset metadata debug bit if no progress madeMatt Turner2019-01-0922-12/+115
| | | | | | | | | | | | | | | | | | | | | NIR metadata validation verifies that the debug bit was unset (by a call to nir_metadata_preserve) if a NIR optimization pass made progress on the shader. With the expectation that the NIR shader consists of only a single main function, it has been safe to call nir_metadata_preserve() iff progress was made. However, most optimization passes calculate progress per-function and then return the union of those calculations. In the case that an optimization pass makes progress only on a subset of the functions in the shader metadata validation will detect the debug bit is still set on any unchanged functions resulting in a failed assertion. This patch offers a quick solution (short of a larger scale refactoring which I do not wish to undertake as part of this series) that simply unsets the debug bit on unchanged functions. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Add lowering support for 64-bit operations to softwareMatt Turner2019-01-092-2/+178
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Create nir_builder in nir_lower_doubles_impl()Matt Turner2019-01-091-17/+19
| | | | | | | We're going to use it more in a future patch, and this avoids a lot of gross code. Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Add and set info::uses_64bitMatt Turner2019-01-092-0/+10
| | | | | | | | Will be used to communicate that a shader uses 64-bit operations to the concerned lowering passes. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Implement lowering of 64-bit shift operationsMatt Turner2019-01-092-0/+143
| | | | | Reviewed-by: Elie Tournier <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Wire up int64 lowering functionsMatt Turner2019-01-092-3/+127
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Add some more int64 lowering helpersJason Ekstrand2019-01-091-0/+227
| | | | | | | | | | | [mattst88]: Found in an old branch of Jason's. Jason implemented: inot, iand, ior, iadd, isub, ineg, iabs, compare, imin, imax, umin, umax Matt implemented: ixor, bcsel, b2i, i2b, i2i8, i2i16, i2i32, i2i64, u2u8, u2u16, u2u32, u2u64, and fixed ilt Reviewed-by: Elie Tournier <[email protected]>
* nir: Tag entrypoint for easy recognition by nir_shader_get_entrypoint()Matt Turner2019-01-097-6/+30
| | | | | | | | We're going to have multiple functions, so nir_shader_get_entrypoint() needs to do something a little smarter. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Rework nir_lower_constant_initializers() to handle functionsMatt Turner2019-01-091-34/+25
| | | | | | Previously it assumed that only a single function (the entrypoint) existed and attempted to lower constant initializers of shader outputs for each function, for instance.
* glsl: Add "built-in" functions to do fp32_to_int64(fp32)Sagar Ghuge2019-01-091-0/+31
| | | | | Reviewed-by: Elie Tournier <[email protected]> Signed-off-by: Sagar Ghuge <[email protected]>
* glsl: Add "built-in" functions to do fp32_to_uint64(fp32)Sagar Ghuge2019-01-091-0/+29
| | | | | Reviewed-by: Elie Tournier <[email protected]> Signed-off-by: Sagar Ghuge <[email protected]>
* glsl: Add "built-in" functions to do fp64_to_int64(fp64)Sagar Ghuge2019-01-091-0/+29
| | | | | Reviewed-by: Elie Tournier <[email protected]> Signed-off-by: Sagar Ghuge <[email protected]>
* glsl: Add utility function to round and pack int64_t valueSagar Ghuge2019-01-091-0/+36
| | | | | Reviewed-by: Elie Tournier <[email protected]> Signed-off-by: Sagar Ghuge <[email protected]>
* glsl: Add "built-in" functions to do fp64_to_uint64(fp64)Sagar Ghuge2019-01-091-0/+27
| | | | | Reviewed-by: Elie Tournier <[email protected]> Signed-off-by: Sagar Ghuge <[email protected]>
* glsl: Add utility function to round and pack uint64_t valueSagar Ghuge2019-01-091-0/+32
| | | | | Reviewed-by: Elie Tournier <[email protected]> Signed-off-by: Sagar Ghuge <[email protected]>
* glsl: Add "built-in" functions to do int64_to_fp32(int64_t)Sagar Ghuge2019-01-091-0/+22
| | | | | Reviewed-by: Elie Tournier <[email protected]> Signed-off-by: Sagar Ghuge <[email protected]>
* glsl: Add "built-in" functions to do uint64_to_fp32(uint64_t)Sagar Ghuge2019-01-091-0/+20
| | | | | Reviewed-by: Elie Tournier <[email protected]> Signed-off-by: Sagar Ghuge <[email protected]>
* glsl: Add "built-in" functions to do int64_to_fp64(int64_t)Sagar Ghuge2019-01-091-0/+18
| | | | | Reviewed-by: Elie Tournier <[email protected]> Signed-off-by: Sagar Ghuge <[email protected]>
* glsl: Add "built-in" functions to do uint64_to_fp64(uint64_t)Sagar Ghuge2019-01-091-0/+18
| | | | | Reviewed-by: Elie Tournier <[email protected]> Signed-off-by: Sagar Ghuge <[email protected]>
* glsl: Add "built-in" functions to convert bool to doubleMatt Turner2019-01-091-0/+12
| | | | | | And vice versa. Reviewed-by: Elie Tournier <[email protected]>
* glsl: Add "built-in" functions to do ffract(fp64)Matt Turner2019-01-091-0/+6
| | | | Reviewed-by: Elie Tournier <[email protected]>
* glsl: Add "built-in" function to do ffloor(fp64)Matt Turner2019-01-091-0/+13
| | | | Reviewed-by: Elie Tournier <[email protected]>
* glsl: Add "built-in" functions to do fmin/fmax(fp64)Matt Turner2019-01-091-0/+20
| | | | Reviewed-by: Elie Tournier <[email protected]>
* glsl: Add "built-in" functions to do ffma(fp64)Matt Turner2019-01-091-0/+6
| | | | | | Definitely not actually a fused-multiply add. Reviewed-by: Elie Tournier <[email protected]>
* glsl: Add "built-in" functions to do round(fp64)Elie Tournier2019-01-091-0/+42
| | | | Signed-off-by: Elie Tournier <[email protected]>
* glsl: Add "built-in" functions to do trunc(fp64)Elie Tournier2019-01-091-0/+22
| | | | | | v2: use mix. Signed-off-by: Elie Tournier <[email protected]>
* glsl: Add "built-in" functions to do sqrt(fp64)Elie Tournier2019-01-091-0/+272
| | | | Signed-off-by: Elie Tournier <[email protected]>
* glsl: Add "built-in" functions to do fp32_to_fp64(fp32)Elie Tournier2019-01-091-0/+38
| | | | Signed-off-by: Elie Tournier <[email protected]>
* glsl: Add "built-in" functions to do fp64_to_fp32(fp64)Elie Tournier2019-01-091-0/+101
| | | | Signed-off-by: Elie Tournier <[email protected]>
* glsl: Add "built-in" functions to do int_to_fp64(int)Elie Tournier2019-01-091-0/+23
| | | | | v2: use mix Signed-off-by: Elie Tournier <[email protected]>
* glsl: Add "built-in" functions to do fp64_to_int(fp64)Elie Tournier2019-01-091-0/+41
| | | | | | v2: use mix Signed-off-by: Elie Tournier <[email protected]>
* glsl: Add "built-in" functions to do uint_to_fp64(uint)Elie Tournier2019-01-091-0/+22
| | | | Signed-off-by: Elie Tournier <[email protected]>
* glsl: Add "built-in" functions to do fp64_to_uint(fp64)Elie Tournier2019-01-091-0/+61
| | | | Signed-off-by: Elie Tournier <[email protected]>
* glsl: Add "built-in" functions to do mul(fp64, fp64)Elie Tournier2019-01-091-0/+148
| | | | | v2: use mix Signed-off-by: Elie Tournier <[email protected]>
* glsl: Add "built-in" functions to do add(fp64, fp64)Elie Tournier2019-01-091-0/+433
| | | | | | | v2: use mix and findMSB to optimise. v3: [Sagar] Fix zFrac0 == 0u case in __normalizeRoundAndPackFloat64 Signed-off-by: Elie Tournier <[email protected]>