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
Rhys Perry
389c95a889
spirv: set ACCESS_COHERENT for ssbo/global/image atomic load/store
...
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com >
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6063 >
2020-08-05 09:45:54 +00:00
Iago Toral Quiroga
71572ebb32
nir/lower_tex: skip lower_tex_packing for the texture samples query
...
Similar to other skips for texture queries that don't actually sample
the texture and which results are not packed.
We can't use nir_tex_instr_is_query() here to skip the lowering for all
queries since that causes regressions in Piglit. Apparently, we do want
to lower some of the query results. In particularly, the LOD query.
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6169 >
2020-08-05 08:39:52 +02:00
Eric Anholt
13b3c401a4
nir: Print the constant data size associated with a shader.
...
We should probably dump the constants, too, but this is useful to me for
now.
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com >
Reviewed-by: Rob Clark <robdclark@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6179 >
2020-08-05 04:35:05 +00:00
Eric Anholt
041bae28c6
nir: Add a little more docs about NIR's constant_data.
...
I think everyone trips over "how does this relate to nir_const", and I was
curious if I could redefine the units of the constant_data_size / indirect
offsets.
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com >
Reviewed-by: Rob Clark <robdclark@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6179 >
2020-08-05 04:35:05 +00:00
Eric Anholt
2e833b16bc
nir/lower_amul: Use num_ubos/ssbos instead of recomputing it.
...
Now that num_ubos is correctly maintained, we can just trust it. Fixes an
assertion failure in freedreno I triggered on
dEQP-GLES31.functional.ubo.random.all_per_block_buffers.1 for reasons I
don't really understand.
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com >
Reviewed-by: Rob Clark <robdclark@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6179 >
2020-08-05 04:35:05 +00:00
Caio Marcelo de Oliveira Filho
b98dd70489
spirv: Propagate explicit layout only in types that need it
...
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5511 >
2020-08-04 07:53:37 -07:00
Jason Ekstrand
4816f6f8d8
spirv: Do more complex unwrapping in get_nir_type
...
The OpenGL flavor of SPIR-V allows for samplers inside structs. This
means that our simple array-of-array handling isn't sufficient and we
need something substantially more complex for generating NIR types.
Fixes: 14a12b771d "spirv: Rework our handling of images and samplers"
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6065 >
2020-08-04 03:05:34 +00:00
Jason Ekstrand
140a5492e0
compiler/types: Add a struct_type_is_packed wrapper
...
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6065 >
2020-08-04 03:05:34 +00:00
Jason Ekstrand
611f654fcf
nir/deref: Don't try to compare derefs containing casts
...
One day, we may want copy_prop_vars or other passes to be able to see
through certain types of casts such as when someone casts a uint64_t to
a uvec2. However, for now we should just avoid casts all together.
Fixes: d8e3edb784 "nir/deref: Support casts and ptr_as_array in..."
Tested-by: Jesse Natalie <jenatali@microsoft.com >
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6072 >
2020-08-03 21:49:25 +00:00
Eric Anholt
ee2f21b10d
nir: Remove the old nir_opt_shrink_load.
...
The old pass only handled intrinsic load_constant, while the new
nir_opt_shrink_vectors handles ALU ops, nir load_consts, along with all
the load intrinsics.
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com >
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6050 >
2020-08-03 21:26:45 +00:00
Eric Anholt
1c9906d5ff
nir: Add a pass to cut the trailing ends of vectors.
...
Ideally we'd also handle unused middles of vectors and reswizzle ALU-only
uses of it so we could write fewer channels, but that's future work/
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com >
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6050 >
2020-08-03 21:26:45 +00:00
David Stevens
d8fdb8dab4
nir: Add colorspace support to YUV lowering pass
...
This change adds support for BT709 and BT2020 colorspace to the YUV
lowering pass. The default remains BT601.
This change also fixes minor imprecision in the last digits of the BT601
offsets due to computation from rounded values when the math was
simplified.
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com >
Reviewed-by: Rob Clark <robdclark@chromium.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6122 >
2020-07-31 07:27:03 +00:00
Boris Brezillon
e1b114868a
nir: Get rid of __[u]int64_to_fp32() and __fp32_to_[u]int64()
...
Those are now handled by nir_lower_int64() which has native NIR
implementations.
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com >
Reviewed-by: Matt Turner <mattst88@gmail.com >
Acked-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5588 >
2020-07-30 16:54:24 +00:00
Boris Brezillon
936c58c8fc
nir: Extend nir_lower_int64() to support i2f/f2i lowering
...
That's an attempt at replacing the complex __int64_to_float() and
__float_to_int64() implementations found in float64.glsl by a simpler
native NIR equivalent.
Thanks to that, we can have lower those conversion without having to
compile a GLSL shader, which would be quite annoying for OpenCL
kernels.
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com >
Reviewed-by: Matt Turner <mattst88@gmail.com >
Acked-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5588 >
2020-07-30 16:54:24 +00:00
Boris Brezillon
bfee35b45c
nir: Stop passing an options arg to nir_lower_int64()
...
This information is exposed through shader->options->lower_int64_options.
Removing the extra arg forces drivers to initialize this field correctly.
This also allows us to check the int64 lowering options from each int64
lowering helper and decide if we should lower the instructions we
introduce.
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com >
Reviewed-by: Matt Turner <mattst88@gmail.com >
Reviewed-by: Rob Clark <robdclark@chromium.org >
Acked-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5588 >
2020-07-30 16:54:24 +00:00
Boris Brezillon
dd155aef44
nir: Allow casts in nir_deref_instr_get[_const]_offset()
...
Allow casts in a deref chain so we can calculate an offset from
a base pointer dereference or have pointer type casts in the
middle of the chain (both are pretty common in CL).
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5682 >
2020-07-30 17:11:43 +02:00
Boris Brezillon
6a1382399c
nir: Use a switch in build_deref_offset()/deref_instr_get_const_offset()
...
We are about to add support for casts when calculating offset, but let's
first turn the if()/else if()/else block into a switch() statement to
ease addition of new cases.
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5682 >
2020-07-30 17:11:35 +02:00
Marcin Ślusarz
59bb0ff945
glsl: catch out of bounds access in the debug version
...
Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6067 >
2020-07-30 10:41:00 +00:00