summaryrefslogtreecommitdiff
path: root/src/compiler/glsl
AgeCommit message (Collapse)AuthorFilesLines
2019-03-05glsl: fix recording of variables for XFB in TCS shadersIlia Mirkin3-5/+44
This is purely for conformance, since it's not actually possible to do XFB on TCS output varyings. However we do have to make sure we record the names correctly, and this removes an extra level of array-ness from the names in question. Fixes KHR-GL45.tessellation_shader.single.xfb_captures_data_from_correct_stage v2: Add comment to the new program_resource_visitor::process function. (Ilia Mirkin) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108457 Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Cc: 19.0 <mesa-stable@lists.freedesktop.org> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> (cherry picked from commit 4eec3a2a3652317f8e0fa97e0730c297bde8241a)
2019-03-05glsl: TCS outputs can not be transform feedback candidates on GLESJose Maria Casanova Crespo1-1/+21
Avoids regression on: KHR-GLES*.core.tessellation_shader.single.xfb_captures_data_from_correct_stage that is uncovered by the following patch. "glsl: fix recording of variables for XFB in TCS shaders" v2: Rebased over glsl: fix recording of variables for XFB in TCS shaders v3: Move this patch before "glsl: fix recording of variables for XFB in TCS shaders" to avoid temporal regressions. (Illia Mirkin) Cc: 19.0 <mesa-stable@lists.freedesktop.org> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> (cherry picked from commit bf1f49482d677e562993543cd9a9367597ce3ccc)
2019-03-05glsl: fix shader cache for packed param listTimothy Arceri1-11/+4
Some types of params such as some builtins are always padded. We need to keep track of this so we can restore the list correctly. Here we also remove a couple of cache entries that are not actually required as they get rebuilt by the _mesa_add_parameter() calls. This patch fixes a bunch of arb_texture_multisample and arb_sample_shading piglit tests for the radeonsi NIR backend. Fixes: edded1237607 ("mesa: rework ParameterList to allow packing") Reviewed-by: Marek Olšák <marek.olsak@amd.com> (cherry picked from commit 7536af670b7501228628a8c90f9e8456b5aec9e1)
2019-02-26compiler: Mark clip/cull distance arrays as compact before lowering.Kenneth Graunke1-0/+12
nir_lower_clip_cull_distance_arrays() marks the combined clip/cull distance array as compact. However, when translating in from GLSL or SPIR-V, we were not marking the original float[] arrays as compact. We should do so. That way, we can detect these corner cases properly. Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> (cherry picked from commit ef99f4c8d176f4e854e12afa1545fa53f651d758) Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2019-01-29glsl: use remap location when serialising uniform program resource dataTimothy Arceri1-7/+26
This allows us to avoid expensive string compares since we already have a map to the pointers. These compares were taking ~30 seconds for a single shader compile in Godot due to it using 64,000+ uniforms. Fixes: c4cff5f40254 ("glsl: add basic support for resource list to shader cache") Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109229
2019-01-27glsl: fix block member alignment validation for vec3Niklas Haas1-4/+4
Section 7.6.2.2 (Standard Uniform Block Layout) of the GL spec says: The base offset of the first member of a structure is taken from the aligned offset of the structure itself. The base offset of all other structure members is derived by taking the offset of the last basic machine unit consumed by the previous member and adding one. The current code does not reflect this last sentence - it effectively instead aligns up the next offset up to the alignment of the previous member. This causes an issue in exactly one case: layout(std140) uniform block { layout(offset=0) vec3 var1; layout(offset=12) float var2; }; As per section 7.6.2.1 (Uniform Buffer Object Storage) and elsewhere, a vec3 consumes 3 floats, i.e. 12 basic machine units. Therefore, `var1` in the example above consumes units 0-11, with 12 being the first available offset afterwards. However, before this commit, mesa incorrectly assumes `var2` must start at offset=16 when using explicit offsets, which results in a compile-time error. Without explicit offsets, the shaders actually work fine, indicating that mesa is already correctly aligning these fields internally. (Just not in the code that handles explicit buffer offset parsing) This patch should fix piglit tests: ssbo-explicit-offset-vec3.vert ubo-explicit-offset-vec3.vert Signed-off-by: Niklas Haas <git@haasn.xyz> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
2019-01-21glsl/lower_output_reads: set invariant and precise flags on temporariesKarol Herbst1-0/+4
fixes a couple of deqp tests (on nvc0 and potential other drivers): dEQP-GLES3.functional.shaders.invariance.highp.common_subexpression_1 dEQP-GLES3.functional.shaders.invariance.highp.common_subexpression_2 dEQP-GLES3.functional.shaders.invariance.highp.common_subexpression_3 dEQP-GLES3.functional.shaders.invariance.mediump.common_subexpression_1 dEQP-GLES3.functional.shaders.invariance.mediump.common_subexpression_2 dEQP-GLES3.functional.shaders.invariance.mediump.common_subexpression_3 dEQP-GLES3.functional.shaders.invariance.lowp.common_subexpression_1 dEQP-GLES3.functional.shaders.invariance.lowp.common_subexpression_2 dEQP-GLES3.functional.shaders.invariance.lowp.common_subexpression_3 CC: <mesa-stable@lists.freedesktop.org> Signed-off-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
2019-01-19nir: rename nir_var_shared to nir_var_mem_sharedKarol Herbst1-1/+1
Signed-off-by: Karol Herbst <kherbst@redhat.com> Acked-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
2019-01-19nir: rename nir_var_ssbo to nir_var_mem_ssboKarol Herbst2-2/+2
Signed-off-by: Karol Herbst <kherbst@redhat.com> Acked-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
2019-01-19nir: rename nir_var_ubo to nir_var_mem_uboKarol Herbst1-1/+1
Signed-off-by: Karol Herbst <kherbst@redhat.com> Acked-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
2019-01-19nir: rename nir_var_function to nir_var_function_tempKarol Herbst1-5/+5
Signed-off-by: Karol Herbst <kherbst@redhat.com> Acked-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
2019-01-19nir: rename nir_var_private to nir_var_shader_tempKarol Herbst1-2/+2
Signed-off-by: Karol Herbst <kherbst@redhat.com> Acked-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
2019-01-19glsl: be much more aggressive when skipping shader compilationTimothy Arceri2-6/+10
Currently we only add a cache key for a shader once it is linked. However games like Team Fortress 2 compile a whole bunch of shaders which are never actually linked. These compiled shaders can take up a bunch of memory. This patch changes things so that we add the key for the shader to the cache as soon as it is compiled. This means on a warm cache we can avoid the wasted memory from these shaders. Worst case scenario is we need to compile the shaders at link time but this can happen anyway if the shader has been evicted from the cache. Reduces memory use in Team Fortress 2 from 1.3GB -> 770MB on a warm cache from start up to the game menu. V2: only add key to cache when compilation is successful. Acked-by: Marek Olšák <marek.olsak@amd.com>
2019-01-19Revert "glsl: be much more aggressive when skipping shader compilation"Timothy Arceri2-10/+6
This reverts commit 64b8c86d37ebb1e1d286c69d642d52b7bcf051d3. Reverting for now as it was causing some segfaults.
2019-01-19glsl: be much more aggressive when skipping shader compilationTimothy Arceri2-6/+10
Currently we only add a cache key for a shader once it is linked. However games like Team Fortress 2 compile a whole bunch of shaders which are never actually linked. These compiled shaders can take up a bunch of memory. This patch changes things so that we add the key for the shader to the cache as soon as it is compiled. This means on a warm cache we can avoid the wasted memory from these shaders. Worst case scenario is we need to compile the shaders at link time but this can happen anyway if the shader has been evicted from the cache. Reduces memory use in Team Fortress 2 from 1.3GB -> 770MB on a warm cache from start up to the game menu. Acked-by: Marek Olšák <marek.olsak@amd.com>
2019-01-19glsl: don't skip GLSL IR opts on first-time compilesTimothy Arceri2-32/+1
This basically reverts c2bc0aa7b188. By running the opts we reduce memory using in Team Fortress 2 from 1.5GB -> 1.3GB from start-up to game menu. This will likely increase Deus Ex start up times as per commit c2bc0aa7b188. However currently 32bit games like Team Fortress 2 can run out of memory on low memory systems, so that seems more important. Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2019-01-14src/compiler: use new hash table and set creation helpersCaio Marcelo de Oliveira Filho20-59/+28
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 <jason@jlekstrand.net> Acked-by: Eric Engestrom <eric@engestrom.ch>
2019-01-14glsl: Fix copying function's out to temp if dereferenced by arrayDanylo Piliaiev1-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 <danylo.piliaiev@globallogic.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2019-01-11glsl/nir: keep bool types when native_integers=falseJonathan Marek1-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 <jonathan@marek.ca> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2019-01-11glsl/nir: ftrunc for native_integers=false float to int castJonathan Marek1-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 <jonathan@marek.ca> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2019-01-11glsl/nir: int constants as float for native_integers=falseJonathan Marek1-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 <jonathan@marek.ca> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2019-01-11nir: Allow a non-existent sampler deref in nir_lower_samplers_as_derefKenneth Graunke1-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 <jason@jlekstrand.net> Tested-by: Alejandro Piñeiro <apinheiro@igalia.com>
2019-01-11glsl: Make invariant outputs in ES fragment shader not to cause errorDanylo Piliaiev1-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 <danylo.piliaiev@globallogic.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107842
2019-01-10glsl/linker: specify proper direction in location aliasing errorAndres Gomez1-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 <itoral@igalia.com> Signed-off-by: Andres Gomez <agomez@igalia.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
2019-01-09nir: Tag entrypoint for easy recognition by nir_shader_get_entrypoint()Matt Turner1-0/+2
We're going to have multiple functions, so nir_shader_get_entrypoint() needs to do something a little smarter. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2019-01-09glsl: Add "built-in" functions to do fp32_to_int64(fp32)Sagar Ghuge1-0/+31
Reviewed-by: Elie Tournier <tournier.elie@gmail.com> Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com>
2019-01-09glsl: Add "built-in" functions to do fp32_to_uint64(fp32)Sagar Ghuge1-0/+29
Reviewed-by: Elie Tournier <tournier.elie@gmail.com> Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com>
2019-01-09glsl: Add "built-in" functions to do fp64_to_int64(fp64)Sagar Ghuge1-0/+29
Reviewed-by: Elie Tournier <tournier.elie@gmail.com> Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com>
2019-01-09glsl: Add utility function to round and pack int64_t valueSagar Ghuge1-0/+36
Reviewed-by: Elie Tournier <tournier.elie@gmail.com> Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com>
2019-01-09glsl: Add "built-in" functions to do fp64_to_uint64(fp64)Sagar Ghuge1-0/+27
Reviewed-by: Elie Tournier <tournier.elie@gmail.com> Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com>
2019-01-09glsl: Add utility function to round and pack uint64_t valueSagar Ghuge1-0/+32
Reviewed-by: Elie Tournier <tournier.elie@gmail.com> Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com>
2019-01-09glsl: Add "built-in" functions to do int64_to_fp32(int64_t)Sagar Ghuge1-0/+22
Reviewed-by: Elie Tournier <tournier.elie@gmail.com> Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com>
2019-01-09glsl: Add "built-in" functions to do uint64_to_fp32(uint64_t)Sagar Ghuge1-0/+20
Reviewed-by: Elie Tournier <tournier.elie@gmail.com> Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com>
2019-01-09glsl: Add "built-in" functions to do int64_to_fp64(int64_t)Sagar Ghuge1-0/+18
Reviewed-by: Elie Tournier <tournier.elie@gmail.com> Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com>
2019-01-09glsl: Add "built-in" functions to do uint64_to_fp64(uint64_t)Sagar Ghuge1-0/+18
Reviewed-by: Elie Tournier <tournier.elie@gmail.com> Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com>
2019-01-09glsl: Add "built-in" functions to convert bool to doubleMatt Turner1-0/+12
And vice versa. Reviewed-by: Elie Tournier <tournier.elie@gmail.com>
2019-01-09glsl: Add "built-in" functions to do ffract(fp64)Matt Turner1-0/+6
Reviewed-by: Elie Tournier <tournier.elie@gmail.com>
2019-01-09glsl: Add "built-in" function to do ffloor(fp64)Matt Turner1-0/+13
Reviewed-by: Elie Tournier <tournier.elie@gmail.com>
2019-01-09glsl: Add "built-in" functions to do fmin/fmax(fp64)Matt Turner1-0/+20
Reviewed-by: Elie Tournier <tournier.elie@gmail.com>
2019-01-09glsl: Add "built-in" functions to do ffma(fp64)Matt Turner1-0/+6
Definitely not actually a fused-multiply add. Reviewed-by: Elie Tournier <tournier.elie@gmail.com>
2019-01-09glsl: Add "built-in" functions to do round(fp64)Elie Tournier1-0/+42
Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
2019-01-09glsl: Add "built-in" functions to do trunc(fp64)Elie Tournier1-0/+22
v2: use mix. Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
2019-01-09glsl: Add "built-in" functions to do sqrt(fp64)Elie Tournier1-0/+272
Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
2019-01-09glsl: Add "built-in" functions to do fp32_to_fp64(fp32)Elie Tournier1-0/+38
Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
2019-01-09glsl: Add "built-in" functions to do fp64_to_fp32(fp64)Elie Tournier1-0/+101
Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
2019-01-09glsl: Add "built-in" functions to do int_to_fp64(int)Elie Tournier1-0/+23
v2: use mix Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
2019-01-09glsl: Add "built-in" functions to do fp64_to_int(fp64)Elie Tournier1-0/+41
v2: use mix Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
2019-01-09glsl: Add "built-in" functions to do uint_to_fp64(uint)Elie Tournier1-0/+22
Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
2019-01-09glsl: Add "built-in" functions to do fp64_to_uint(fp64)Elie Tournier1-0/+61
Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
2019-01-09glsl: Add "built-in" functions to do mul(fp64, fp64)Elie Tournier1-0/+148
v2: use mix Signed-off-by: Elie Tournier <elie.tournier@collabora.com>