Commit Graph

2151 Commits

Author SHA1 Message Date
Danylo Piliaiev c0f623e62f glsl: Prohibit implicit conversion of mem parameter in atomicOP functions
Per OpenGL Shading Language, section 8.11. "Atomic Memory Functions"
first argument "mem" of all atomicOP functions is inout.
The same is true for ARB_shader_storage_buffer_object and
GL_INTEL_shader_atomic_float_minmax

For implicit conversion of inout parameters it is required for type
to support bi-directional conversion, since there is no such types
in glsl - implicit conversion is effectively prohibited.

Alternatively we could have marked atomic_var parameter of built-in
atomicOP functions as inout, however it opens another can of worms
during NIR lowerings.

Fixes: ea0a1f5beb
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2837
Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4887>
2021-07-05 18:29:51 +03:00
Timothy Arceri a73e7305e9 util/driconf: add new ignore_write_to_readonly_var workaround
This forces the GLSL compiler to ignore writes to readonly vars
rather than throwing an error.

Cc: mesa-stable

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11602>
2021-06-29 02:59:28 +00:00
Timothy Arceri e607205af0 glsl: force_glsl_version to shaders with no defined version
If a shader has no defined version force_glsl_version was
previous ignored and the shader would default to 110. This updates
the code so that those shaders are forced to a new level also.

We reused the existing code to make sure a sensible value is set
for the version.

Cc: mesa-stable

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11602>
2021-06-29 02:59:28 +00:00
Martin Krastev eb272f6571 compiler/glsl: Use mutex lock while freeing up mem_ctx
builtin_builder::~builtin_builder() and builtin_builder::release()
are running into race condition. This leads lightsmark to crash at
the end because both calls ralloc_free which mutates the arguments state

This patch fixes lightsmark2008 crash

Fixes: e4da8b9c33 ("mesa/compiler: rework tear down of builtin/types")

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Reviewed-by: Neha Bhende <bhenden@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Tested-by: Neha Bhende <bhenden@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11385>
2021-06-16 23:14:23 +00:00
Caio Marcelo de Oliveira Filho 8af6766062 nir: Move workgroup_size and workgroup_variable_size into common shader_info
Move it out the "cs" sub-struct, since these will be used for other
shader stages in the future.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11225>
2021-06-08 09:23:55 -07:00
Caio Marcelo de Oliveira Filho c8a7bd0dc8 nir: Rename WORK_GROUP (and similar) to WORKGROUP
Be consistent with other usages in Vulkan and SPIR-V, and the recently
added workgroup_size field.

Acked-by: Emma Anholt <emma@anholt.net>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11190>
2021-06-07 22:34:42 +00:00
Caio Marcelo de Oliveira Filho 43a6a2151b compiler: Rename SYSTEM_VALUE_LOCAL_GROUP_SIZE to SYSTEM_VALUE_WORKGROUP_SIZE
Acked-by: Emma Anholt <emma@anholt.net>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11190>
2021-06-07 22:34:42 +00:00
Caio Marcelo de Oliveira Filho 430d2206da compiler: Rename local_size to workgroup_size
Acked-by: Emma Anholt <emma@anholt.net>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11190>
2021-06-07 22:34:42 +00:00
Alyssa Rosenzweig 4d44d4179e glsl: Fix packing of matrices for XFB
The CAP for packed transform feedback concerns packing of unrelated
variables into the same varying slot. (On Mali, transform feedback is
implemented on a per-slot basis, so different variables need different
slots to be written to different buffers.) However, this requirement is
tangential to the packing of arrays, matrices, and structures inherent
to GLSL. These array-like values need to be packed /within/ their slot,
even though drivers using the CAP (just Panfrost) cannot pack
independent values in the slot. Transform feedback of individual
elements is not independent, after all.

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10778>
2021-05-20 10:05:39 +00:00
Alyssa Rosenzweig 538ab8c571 glsl: Fix subscripted arrays with no XFB packing
We need to duplicate the subscripted members even if they happen to be
aligned, since the other elements may be passed into the consumer
shader. Fixes on Panfrost:

dEQP-GLES3.functional.transform_feedback.array_element.interleaved.lines.highp_float

Note: the test did pass on main previously due to an elaborate set of
driver hacks. I don't believe the old behaviour was correct regardless.

Only Panfrost is affected by this change and the next, as every other
driver sets PIPE_CAP_PACKED_STREAM_OUTPUT.

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10778>
2021-05-20 10:05:39 +00:00
Timothy Arceri 5aabc91273 glsl: add missing support for explicit components in interface blocks
From the ARB_enhanced_layouts spec:

   "As with input layout qualifiers, all shaders except compute shaders
   allow *location* layout qualifiers on output variable declarations,
   output block declarations, and output block member declarations.  Of
   these, variables and block members (but not blocks) additionally
   allow the *component* layout qualifier."

We previously had compile tests in piglit to make sure this was not a
compile error but no execution tests.

Fixes: d99a040bbf ("i965: enable ARB_enhanced_layouts for gen8+")

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10763>
2021-05-13 08:07:53 +00:00
Timothy Arceri 1a71d6aa6e glsl: create validate_component_layout_for_type() helper
This will be used in the following patch.

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10763>
2021-05-13 08:07:53 +00:00
Tapani Pälli d93153a564 glsl: ignore interface precision qualifier on desktop GL
This fixes linking failures with new GL45 linkage tests, no
regressions spotted on existing tests.

v2: add spec reference (Samuel)

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10373>
2021-04-27 08:25:41 +00:00
Mike Blumenkrantz c8dfed0c12 nir/gl_lower_buffers: set access for ssbo load/store instrs
this is the last place where the information is available, so set the info before
it gets lost

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10074>
2021-04-26 21:31:44 +00:00
Matt Turner 7f8c5844ef compiler/glsl: Always propagate_invariance() last
Suggested-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10292>
2021-04-20 18:54:57 +00:00
Matt Turner d35f8604c7 compiler/glsl: Propagate invariant/precise when splitting arrays
This fixes the
dEQP-GLES3.functional.shaders.invariance.{low,medium,high}p.loop_4 tests when
run in a VM with virgl on a host with iris. virgl mangles the GLSL shaders and
emits shader code for the host driver that contains vec4 arrays. As such, the
test did not fail when running directly on the host.

The test also did not fail if the host was using i965. Disabling
PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY in iris was sufficient to work around it,
so I believe that i965 didn't show the problem because after arrays were split
by optimize_split_arrays(), even though the invariant/precise qualifiers were
lost, do_common_optimization() would be called again and thus
propagate_invariance() would propagate the qualifiers to the new variables
produced by optimize_split_arrays().

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10292>
2021-04-20 18:54:57 +00:00
Matt Turner 5ef4296cb6 compiler/glsl: Return progress from propagate_invariance()
Doing so allow you to easily tell what the pass did using the existing
infrastructure in the OPT macro.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10292>
2021-04-20 18:54:57 +00:00
Michel Dänzer 2928c21eb7 Convert most remaining free-form fall-through comments to FALLTHROUGH
One exception is src/amd/addrlib/, for which -Wimplicit-fallthrough is
explicitly disabled.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10220>
2021-04-15 16:01:22 +00:00
James Park 75d8998f7c meson: Fix winflexbison warnings
Undefine __STDC_VERSION__ for C files to avoid mismatch with C11/C17.

Define __STDC_VERSION__ for C++ files to use <inttypes.h> path.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10196>
2021-04-14 19:17:27 +00:00
Ella-0 a18ac347cf glsl: build without bison
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8739>
2021-04-13 19:12:48 +00:00
Erik Faye-Lund 437ed05708 compiler/glsl: do not cast struct to string
When formatting the error here, we're currently casting an
ast_type_qualifier as a string.

But we don't need to use a string here at all, because we know from
context exactly what qualifier we're talking about, because the
if-statements explicitly check for the uniform-qualifier.

So let's just hard-code the format-string to reference the right
qualifier instead of the string-shenanigans. The latter cannot do the
right thing.

Fixes: 2d03f48a65 ("glsl: Add parsing for GLSL uniform blocks.")
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9911>
2021-04-13 06:16:41 +00:00
Erik Faye-Lund 2a984da18e compiler/glsl: drop rogue argument to _mesa_glsl_error
This arugment is not present int the format-string, so we shouldn't pass
it to _mesa_glsl_error either.

Noticed by Coverity.

Fixes: 02dc74fbd7 ("glsl: parse invocations layout qualifier for ARB_gpu_shader5")
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9911>
2021-04-13 06:16:41 +00:00
Marek Olšák b19a836413 glsl: lower mediump uniforms to FP16 based on an option
Everything else is done - just allow it.

v2: update lower_precision_test.py

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> (v1)
Reviewed-by: Eric Anholt <eric@anholt.net> (v1)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9050>
2021-04-13 05:07:42 +00:00
Marek Olšák 6604aa2606 glsl: pack 16-bit uniforms in the NIR linker
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9050>
2021-04-13 05:07:42 +00:00
Mauro Rossi 492c8f1709 compiler/glsl: fix include for Android build
Sources outside of src/util path should include "util/string_buffer.h"

Fixes the following building error in Android:

external/mesa/src/compiler/glsl/ast_type.cpp:25:10: fatal error: 'string_buffer.h' file not found
         ^~~~~~~~~~~~~~~~~
1 error generated.

Fixes: eeec9d56ad ("compiler/glsl: clean up output")
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10156>
2021-04-10 20:33:52 +02:00
Erik Faye-Lund a161cccd9b glsl: tolerate int16 loop counters
When lowering precision on integers from GLSL ES, we can end up with
16 bit integer loop counters. So let's tolerate this as well.

This was probably not caught earlier because most NIR drivers disable
GLSL-level loop-unrolling, and no non-NIR driver sets LowerPrecisionInt16
to true. This was discovered while trying to wire up int16 support for
Zink, which doesn't currently disable GLSL loop-unrolling.

Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10125>
2021-04-10 09:01:54 +00:00
Erik Faye-Lund c64e2bf2c3 glsl: fix int16 type
This shouldn't be unsigned, or else we'll trigger asserts.

Fixes: 7f00d4dac8 ("glsl: Handle 16-bit types in loop analysis")
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10125>
2021-04-10 09:01:54 +00:00
Erik Faye-Lund eeec9d56ad compiler/glsl: clean up output
It's really hard to make sure we have the right amount of %s in the
format string, so let's change how we generate this string.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9896>
2021-04-09 03:57:51 +00:00
Erik Faye-Lund d5e0be9342 compiler/glsl: fix volatile string
The reason the member has a leading underscore is because volatile is a
keyword in C. We don't want to carry that detail into the error-string,
so let's drop the underscore.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9896>
2021-04-09 03:57:51 +00:00
Erik Faye-Lund 01e012dab8 compiler/glsl: correct the number of string-arguments
This format-string seems to have been incorrect since it's inception.
But there's also been commits that have both forgotten to add and remove
flags as appropriate as well.

Let's correct the format-list. This was done by counting by hand. A
better solution for the long-term is coming in a future commit.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9896>
2021-04-09 03:57:50 +00:00
Andrii Simiklit 7661320815 glsl/linker: Fix xfb stride alignment for buffers containing 64bit types
Per OpenGL 4.6 spec:
"If no xfb_stride qualifier is specified for a
 binding point, the stride is derived by identifying the variable associated with the
 binding point having the largest offset, and then adding the offset and the size of
 the variable, in basic machine units. If any variable associated with the binding
 point contains double-precision floating-point components, the derived stride is
 aligned to the next multiple of eight basic machine units. If a binding point has no
 xfb_stride qualifier and no associated output variables, its stride is zero."

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Signed-off-by: Andrii Simiklit <andrii.simiklit@globallogic.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2333>
2021-04-01 17:16:33 +00:00
Danylo Piliaiev 67e33db4a6 glsl/linker: Fix xfb with explicit locations and 64bit types
1) Per GL_ARB_enhanced_layouts if explicit location is set for varying,
each struct member, array element and matrix row will take
separate location. With GL_ARB_gpu_shader_fp64/GL_ARB_gpu_shader_int64
they may take two locations.

Examples:

| layout(location=0) dvec3[2] a; | layout(location=4) vec2[4] b; |
|                                |                               |
|   32b 32b 32b 32b              |   32b 32b 32b 32b             |
| 0  X   X   Y   Y               | 4  X   Y   0   0              |
| 1  Z   Z   0   0               | 5  X   Y   0   0              |
| 2  X   X   Y   Y               | 6  X   Y   0   0              |
| 3  Z   Z   0   0               | 7  X   Y   0   0              |

Previously it wasn't taken into account.

2) Captured double-precision variables should be aligned to
8 bytes per GL_ARB_gpu_shader_fp64:
 "If any variable captured in transform feedback has double-precision
 components, the practical requirements for defined behavior are:
     ...
 (c) each double-precision variable captured must be aligned to a
     multiple of eight bytes relative to the beginning of a vertex."

v2: fix `output_size` calculations
         ( Andrii Simiklit <andrii.simiklit@globallogic.com> )

Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/1667
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2333>
2021-04-01 17:16:33 +00:00
Danylo Piliaiev c432cb672a glsl/linker: Fix attempts to split up 64bit varyings between slots
When packing varyings when there is only 32bit of space
left in slot 64bit type is attempted to be divided between
current and next slot. However there is neither code for
splitting the 64bit type nor for assembling it back.
Instead we add 32bit padding.

The above happens only in structs because their
members aren't sorted by packing order.

Example of the issue:

struct S {
 vec3 a;
 double d;
};
out flat S s;

Before, the packing went as:

slot 32b  32b  32b  32b
 0   a.x  a.y  a.z   d
 1    d    0    0    0

After:

slot 32b  32b  32b  32b
 0   a.x  a.y  a.z   0
 1    d    d    0    0

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2333>
2021-04-01 17:16:33 +00:00
Timothy Arceri 3d1022382c glsl: enforce restrictions on builtin functions moved to compat
Section 8.9.4 (Compatibility Profile Texture Functions) of the
GLSL 4.20 spec outlines a number of builtin texture functions that
have been moved to compatibility shaders.

This change enforces those restrictions. Note we don't worry about
enforcing restrictions on the EXT_gpu_shader4 extensions of these
functions because EXT_gpu_shader4 should only be enabled for compat
already.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9887>
2021-04-01 02:41:40 +00:00
Vinson Lee cd222e4a9c glsl: Initialize parcel_out_uniform_storage members.
Fix defects reported by Coverity Scan.

uninit_member: Non-static class member buffer_block_index is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member ubo_byte_offset is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member shader_type is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member next_sampler is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member next_bindless_sampler is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member next_image is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member next_bindless_image is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member next_subroutine is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member field_counter is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member current_var is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member explicit_location is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member record_array_count is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member record_next_sampler is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member record_next_image is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member record_next_bindless_sampler is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member record_next_bindless_image is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member targets is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member shader_samplers_used is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member shader_shadow_samplers is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member num_bindless_samplers is not initialized in this constructor nor in any functions that it calls.
uninit_member: Non-static class member num_bindless_images is not initialized in this constructor nor in any functions that it calls.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7910>
2021-03-30 21:26:04 -07:00
Erik Faye-Lund 89a04a54c4 compiler/glsl: avoid null-pointer deref
When we encounter a bindless image here, lower_deref returns a
NULL-pointer, and calling record_images_used will try to dereference
that NULL-pointer.

So let's dig out the var from the source instruction instead of the
result of the lowering.

Fixes: 5910c938a2 ("nir/glsl: gather bitmask of images used by program")
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9895>
2021-03-30 15:22:17 +00:00
Jesse Schwartzentruber 02492bea5f glcpp: Fix undefined behaviour in glcpp
Specifically, fix this error (which is covered in existing tests):

    ../src/compiler/glsl/glcpp/pp.c:198:28: runtime error: applying non-zero offset 1 to null pointer
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/compiler/glsl/glcpp/pp.c:198:28 in

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9669>
2021-03-25 00:23:43 +00:00
Michel Dänzer 5057f14cba Revert "glsl/test: Don't run whitespace tests in parallel"
This reverts commit c60cea0daa.

Didn't have the intended effect, and slowed down the meson test run.

Reviewed-by: Dylan Baker <dylan.c.baker@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9528>
2021-03-19 08:50:38 +00:00
Michel Dänzer d8911a0ae8 Revert "meson: add enable-glcpp-tests option"
This reverts commit f9ae947e72.

Not needed anymore.

Reviewed-by: Dylan Baker <dylan.c.baker@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9528>
2021-03-19 08:50:38 +00:00
Michel Dänzer 7fedf51b95 glsl/tests: Use exit code 126 to detect valgrind errors
valgrind returns exit code 126 if it can't write to the file passed to
--log-file. Hopefully it'll be the same for any other invalid valgrind
command line parameters or internal errors as well.

Using a different exit code (31) for this was hiding the fact that the
valgrind test wasn't actually working.

v2:
* Use exit code 126; can't treat any non-0 exit code as failure because
  glcpp is expected to exit with non-0 for some of the input we feed it

Reviewed-by: Dylan Baker <dylan.c.baker@intel.com> # v1
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9528>
2021-03-19 08:50:38 +00:00
Michel Dänzer 4cc8c25d56 glsl/tests: Don't use tempfiles
Use pipes for direct communication between child & parent process.

Using tempfiles sometimes resulted in hitting the meson timeout if there
was high filesystem pressure (I saw a single unlink system call take as
long as 4 seconds; attempts to re-use a single tempfile just shifted the
delays to truncate/close systems calls).

As a bonus, this gets the valgrind test actually working as intended.
It wasn't working because the tempfile passed to --log-file didn't exist
(due to the earlier os.close(fd)?).

v2:
* Wrap .read() in "with open()" (Dylan Baker)

Reviewed-by: Dylan Baker <dylan.c.baker@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9528>
2021-03-19 08:50:37 +00:00
Michel Dänzer deb654cdd0 glsl/tests: Bump glcpp valgrind test timeout to 240 seconds
Once it's actually working as intended again, it may need that much
time.

v2:
* Bump to 240 seconds, still hit timeouts with 180.
* Don't change test priority.

Reviewed-by: Dylan Baker <dylan.c.baker@intel.com> # v1
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9528>
2021-03-19 08:50:37 +00:00
Michel Dänzer 37855fd59d glcpp: Fully initialize struct gl_context
valgrind flagged members of gl_ctx->Extensions being used uninitialized:

==23417== Conditional jump or move depends on uninitialised value(s)
==23417==    at 0x112642: _glcpp_parser_handle_version_declaration.part.0 (glcpp-parse.y:2493)
==23417==    by 0x11A515: glcpp_lex_update_state_per_token (glcpp-lex.l:132)
==23417==    by 0x11A515: glcpp_lex (glcpp-lex.l:547)
==23417==    by 0x114D46: glcpp_parser_lex (glcpp-parse.y:2302)
==23417==    by 0x114D46: glcpp_parser_parse (glcpp-parse.c:1871)
==23417==    by 0x11ADC6: glcpp_preprocess (pp.c:238)
==23417==    by 0x111384: main (glcpp.c:174)
==23417==  Uninitialised value was created by a stack allocation
==23417==    at 0x111295: main (glcpp.c:136)

Reviewed-by: Dylan Baker <dylan.c.baker@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9528>
2021-03-19 08:50:37 +00:00
Timothy Arceri 4feb26f647 glsl: add compilation errors for attribute and varying qualifiers
These qualifiers were removed in GLSL 4.20 and GLSL ES 3.00. For
desktop GL they are now only allowed if the shader is declared as
a compatibility shader.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9552>
2021-03-19 01:13:17 +00:00
Iago Toral Quiroga f29de817eb compiler/glsl: call util_cpu_detect from glsl_type_singleton_init_or_ref
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Closes: #4393
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9457>
2021-03-17 08:15:36 +01:00
Timothy Arceri 684f97de80 glsl: fix declarations of gl_MaxVaryingFloats
gl_MaxVaryingFloats was not removed from core until 4.20 and is still
available in compat shaders. Found while writing some new CTS to test
the correct declarations of this constant.

Fixes: 0ebf4257a385i ("glsl: define some GLES3 constants in GLSL 4.1")

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9514>
2021-03-12 04:30:32 +00:00
Timothy Arceri 1772569449 Revert "glsl: default to compat shaders in compat profile"
This reverts commit 6c8cc9be12.

A spec bug was resolved confirming the original behaviour. Also it
seems the game Foundation no longer depends on the incorrect
behaviour.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9486>
2021-03-11 04:09:49 +00:00
Dave Airlie 8027a7ba8a shader_info: convert textures_used to a bitset.
For now keep it a bitset of 1 32-bit dword.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9456>
2021-03-10 06:16:09 +10:00
Dave Airlie 0e1afe7c70 util/panfrost/glsl: rename BITSET_LAST_BIT to BITSET_LAST_BIT_SIZED
The current users all pass in the number of dwords, but I'd like
to provide an interface that doess ARRAY_SIZE implicitly.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9456>
2021-03-10 06:15:50 +10:00
Jason Ekstrand e20e85f01e nir: Make nir_ssa_def_rewrite_uses_after take an SSA value
This replaces the new_src parameter of nir_ssa_def_rewrite_uses_after()
with an SSA def, and rewrites all the users as needed.

Acked-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9383>
2021-03-08 16:59:55 +00:00