Boris Brezillon
199bea0fd8
nir: Fix i64tof32 lowering
...
The round-to-nearest-even implementation found in lower_2f() is incorrect
for any value having a significand that is not directly representable
and whose non-representable part lies between 1 and half the minimum
representable value. In this case, the significand is rounded up instead
of being rounded down.
Fixes: 936c58c8fc ("nir: Extend nir_lower_int64() to support i2f/f2i lowering")
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com >
Tested-by: Jesse Natalie <jenatali@microsoft.com >
Acked-by: Matt Turner <mattst88@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6290 >
2020-08-17 20:31:31 +00:00
Boris Brezillon
18e464cfc0
compiler/nir: Add new flags to lower pack/unpack split instructions
...
And add new rules to do this lowering in nir_opt_algebraic.py.
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com >
Reviewed-by: Eric Anholt <eric@anholt.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6309 >
2020-08-17 19:46:10 +00:00
Daniel Stone
c60cea0daa
glsl/test: Don't run whitespace tests in parallel
...
For some unfathomable reason, three out of these four tests often time
out when running within CI. On the assumption that there is some
parallelisation badness happening rather than the non-UNIX tests
entering infinite loops, try just marking them as serial-only.
This should have a negligible impact on runtime since they are quick to
execute.
Signed-off-by: Daniel Stone <daniels@collabora.com >
Reviewed-by: Eric Engestrom <eric@engestrom.ch >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6301 >
2020-08-17 17:44:26 +00:00
Jesse Natalie
ee905aa3a0
nir/vtn: CL SPIR-V callers should specify address modes
...
Instead of inferring the address mode from the environment, allows
callers to override to suit their needs.
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6330 >
2020-08-17 14:36:18 +00:00
Jason Ekstrand
a097bf160a
nir/builder: Make nir_get_ptr_bitsize take a nir_shader
...
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6330 >
2020-08-17 14:36:18 +00:00
Jesse Natalie
627c8e1640
nir: Add nir_address_format_32bit_index_offset_pack64
...
This new address mode is supported by nir_lower_explicit_io
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6330 >
2020-08-17 14:36:18 +00:00
Jesse Natalie
113458d372
nir: Add nir_address_format_32bit_offset_as_64bit
...
This new address mode is supported by nir_lower_explicit_io
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6330 >
2020-08-17 14:36:18 +00:00
Jesse Natalie
a1ed83fddd
nir: Optimize mask+downcast to just downcast
...
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6330 >
2020-08-17 14:36:18 +00:00
Jesse Natalie
fd9b33d516
nir: Fix serialize/deserialize of void samplers/images
...
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6222 >
2020-08-17 13:10:19 +00:00
Jesse Natalie
c17b58a9e6
glsl: Add 'bare' shadow sampler type
...
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6222 >
2020-08-17 13:10:19 +00:00
Gert Wollny
418c4c0d7d
compiler/nir: extend lower_fragcoord_wtrans to support VARYING_SLOT_POS
...
Signed-off-by: Gert Wollny <gert.wollny@collabora.com >
Reviewed-by: Andreas Baierl <ichgeh@imkreisrum.de >
Reviewed-by: Eric Anholt <eric@anholt.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6220 >
2020-08-17 12:38:05 +00:00
Gert Wollny
7aaddf1a34
compiler/nir: rewrite lower_fragcoord_wtrans to use nir_lower_instructions
...
This compacts the code and makes it easier to extend.
Signed-off-by: Gert Wollny <gert.wollny@collabora.com >
Reviewed-by: Andreas Baierl <ichgeh@imkreisrum.de >
Reviewed-by: Eric Anholt <eric@anholt.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6220 >
2020-08-17 12:38:05 +00:00
Marek Olšák
8a012f429d
nir: handle load_input_vertex in nir_get_io_offset_src
...
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6328 >
2020-08-17 11:06:49 +00:00
Marek Olšák
83953f9d4d
nir: remove nir_strip stub declaration
...
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6328 >
2020-08-17 11:06:49 +00:00
Marek Olšák
f3a9781ee1
compiler: add glsl_print_type
...
Move it from the glsl compiler. For debugging.
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6328 >
2020-08-17 11:06:49 +00:00
BillKristiansen
ff4c991fd1
compiler/glsl: Initialize local variable to zero to fix MSVC RTC error
...
Without this, we get a run-time error about using an uninitialized
variable.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6221 >
2020-08-17 09:31:37 +00:00
orbea
a76423e481
spirv/vtn_cfg.c: Include util/debug.h for env_var_as_boolean.
...
Fixes https://gitlab.freedesktop.org/mesa/mesa/-/issues/3414
Reviewed-by: Dave Airlie <airlied@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6331 >
2020-08-16 06:27:34 +00:00
Jason Ekstrand
b41e74ae4a
spirv: Add a MESA_SPIRV_FORCE_UNSTRUCTURED environment variable
...
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:37 +00:00
Karol Herbst
217def3ac6
spirv: parse unstructured CFG
...
v2 (Boris Brezillon): handle functions with return values
v3: call structurizer
v4: entire rewrite
v5: fix handling of already visited default branches
v2 (Jason Ekstrand): Stop walking hash tables
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Tested-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:37 +00:00
Karol Herbst
467b90fcc4
spirv: extract switch parsing into its own function
...
v2 (Jason Ekstrand):
- Construct a list of vtn_case objects
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:37 +00:00
Boris Brezillon
96dff31bc8
spirv: Move the emit a 'return value' store logic into own function
...
Right now, only the structured CF path emits 'return value' stores when
an SpvOpReturnValue opcode is found. Move the emit 'return value' logic
in a separate function so we can use it from the unstructured path as well.
v2 (Karol): rephrased and removed unstructured changes
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:37 +00:00
Jason Ekstrand
4638de8b1b
nir/lower_goto_if: Add some debug prints
...
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:37 +00:00
Jason Ekstrand
d57573dcd4
nir/lower_goto_if: Add a route::outside set
...
Acked-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:37 +00:00
Jason Ekstrand
d2bf850672
nir/lower_goto_if: Replace a tripple loop with a double loop
...
If there's some reason why this needs to be a tripple loop, I'm not
seeing it. As far as I can tell, all the inner-most loop does is look
for the next remaining block not already in cur_level->blocks. There's
no reason to re-walk the whole set every time just to do that.
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:37 +00:00
Jason Ekstrand
b892d473b4
nir/lower_goto_if: Add a block_for_singular_set helper
...
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:37 +00:00
Jason Ekstrand
193765e26b
nir/lower_goto_if: Sort blocks in select_fork
...
Hash set ordering is non-deterministic so any time we make a decision
that may affect the final structure or order of instructions, we want to
use a sorted list of blocks.
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:37 +00:00
Jason Ekstrand
0fad20f21b
nir/lower_goto_if: Rework some set union logic
...
I find the ternary a bit hard to read. The optimization is fairly
obvious but the way it's coded makes things more dense than they
probably need to be.
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:37 +00:00
Jason Ekstrand
d161798589
nir/lower_goto_if: Rework handling of skip targets
...
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:37 +00:00
Jason Ekstrand
2455d03c31
nir/lower_goto_if: Use util/list instead of exec_list
...
I'm trying to reduce exec_list usage in NIR. Also, util_list has some
better helpers for a bunch of the operations this pass needs.
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:37 +00:00
Jason Ekstrand
f69d732fca
nir/lower_goto_if: Clean up ralloc usage
...
It's really hard to track in this pass which sets are getting ralloc'd
off which other sets. To avoid leaks, just pass a mem_ctx around
everywhere and ralloc almost everything off the one context. We do keep
using recursion a few places where it's crystal clear what the parent
relationship is.
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:37 +00:00
Jason Ekstrand
202b4df4ae
nir/lower_goto_if: Document some data structures
...
Reviewed-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:37 +00:00
Julian Winkler
b273611bb1
nir: Add a structurizer
...
v2 (Karol):
renamed pathes to paths
use more bool
use _mesa_set_intersects
deduplicated some code
fixed some typos
v3 (Karol):
don't enable structurizer as we do this in vtn now
v4 (Jason):
A few clean-ups due to unstructured NIR changes
v5 (Jason):
Misc whitespace and style cleanups
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Tested-by: Erik Faye-Lund <erik.faye-lund@collabora.com >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:36 +00:00
Karol Herbst
025bdbac3e
nir: Add goto_if jump instruction
...
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:36 +00:00
Jason Ekstrand
92db942fc6
nir: Add and use nir_foreach_block_unstructured helpers
...
These are safe to call on either structured or unstructured NIR but
don't provide the nice ordering guarantees of nir_foreach_block and
friends. While we're here, we use them for a very small selection of
passes which are known to be safe for unstructured control-flow. The
most important such pass is nir_dominance which is required for
structurizing.
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:36 +00:00
Karol Herbst
4768ea1a77
nir: Add a structured flag to nir_shader
...
v2 (Jason Ekstrand):
- Make "structured" a property of nir_function_impl not nir_shader
- More validation and asserts
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:36 +00:00
Karol Herbst
19f35735a0
spirv: rename vtn_emit_cf_list to vtn_emit_cf_list_structured
...
Signed-off-by: Karol Herbst <kherbst@redhat.com >
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2401 >
2020-08-14 20:35:36 +00:00
Tony Wasserka
8277334f39
nir/lower_idiv: Port recent LLVM fixes to emit_udiv
...
This change fixes off-by-one results in corner cases such as
0xffffffff / 0x11111111. For details refer to LLVM bug 46212.
Fixes: 8b98d0954e ('nir/lower_idiv: add new llvm-based path')
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6281 >
2020-08-13 10:11:57 +00:00
Jesse Natalie
678cb6d248
nir: nir_range_analysis needs to be updated for vec16
...
Reviewed-by: Daniel Stone <daniels@collabora.com >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6275 >
2020-08-11 14:38:34 +00:00
Alyssa Rosenzweig
5cf7eec6b1
nir/lower_ssbo: Don't set align_* for atomics
...
Fixes crashes when lowering atomic SSBOs:
run: ../src/compiler/nir/nir.h:1875: nir_intrinsic_align_mul: Assertion `info->index_map[NIR_INTRINSIC_ALIGN_MUL] > 0' failed.
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Reviewed-by: Eric Anholt <eric@anholt.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6204 >
2020-08-11 09:00:11 +00:00
Rob Clark
5e922fbc16
glsl_to_nir: fix bitfield_extract with 16-bit operands
...
These are defined to explicitly take 32b values.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Reviewed-by: Rob Clark <robdclark@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6073 >
2020-08-05 22:04:47 +00:00
Marek Olšák
92f5e94a93
glsl: improve precision determination for calls
...
Don't leave the precision as NONE for non-lowerable calls. Set it to HIGH
if a function really returns highp.
Reviewed-by: Rob Clark <robdclark@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6073 >
2020-08-05 22:04:47 +00:00
Marek Olšák
282a1e6288
glsl: don't lower to mediump for desktop OpenGL
...
Desktop OpenGL ignores all precision qualifiers.
Also, the lowering pass doesn't work if precision qualifiers are not set,
which is only possible with desktop OpenGL, causing random behavior.
Reviewed-by: Rob Clark <robdclark@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6073 >
2020-08-05 22:04:47 +00:00
Marek Olšák
01e0085637
glsl: don't create conversion opcodes for array types
...
Instead, convert all elements one by one.
This fixes piglit shaders@glsl-bug-110796.
Reviewed-by: Rob Clark <robdclark@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6073 >
2020-08-05 22:04:47 +00:00
Marek Olšák
5020403c70
glsl: don't lower atomic functions to mediump
...
Reviewed-by: Rob Clark <robdclark@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6073 >
2020-08-05 22:04:47 +00:00
Rob Clark
93076f60d3
glsl: don't inline intrinsics for mediump
...
They have an empty fxn body, trying to handle them results in the
intrinsic call being expanded into a no-op.
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Reviewed-by: Rob Clark <robdclark@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6073 >
2020-08-05 22:04:47 +00:00
Marek Olšák
48a6255186
glsl: fix constant expression evaluation for 16-bit types
...
Reviewed-by: Rob Clark <robdclark@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6073 >
2020-08-05 22:04:47 +00:00
Marek Olšák
f2d5f4851a
glsl: lower_precision - fix assertion failure with dereferences of constants
...
Reviewed-by: Rob Clark <robdclark@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6073 >
2020-08-05 22:04:47 +00:00
Rob Clark
a4c4e0103a
glsl: remove LowerPrecisionTemporaries
...
Signed-off-by: Rob Clark <robdclark@chromium.org >
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Reviewed-by: Eric Anholt <eric@anholt.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6189 >
2020-08-05 21:00:44 +00:00
Rob Clark
0a763c0c86
glsl/lower_precision: split out const lowering
...
Some hw can narrow 32b const/uniform to 16b on load.. and in particular
lowering constants to 16b would break const->uniform lowering. Allow
them to lower temps to 16b, while skipping consts.
Initially it is set to the same value as LowerPrecisionTemporaries, to
preserve the current behavior.
Signed-off-by: Rob Clark <robdclark@chromium.org >
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Reviewed-by: Eric Anholt <eric@anholt.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6189 >
2020-08-05 21:00:44 +00:00
Alejandro Piñeiro
7f25f1f106
nir/lower_tex: handle query lod with nir_lower_tex_packing_16 at lower_tex_packing
...
packing_16 with floats assumed 1 (shadow) or 4 components. But query
lod operations return 2.
Fixes the following test with v3dv:
dEQP-VK.ycbcr.query.lod.fragment.r8g8b8a8_unorm
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com >
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5863 >
2020-08-05 10:10:12 +00:00