Commit Graph

7169 Commits

Author SHA1 Message Date
Georg Lehmann bc5c68fc08 nir/opt_algebraic: Optimize Doom Eternal's word extract by LSB.
Foz-db GFX10_3:
Totals from 419 (0.31% of 134913) affected shaders:
CodeSize: 4126032 -> 4121756 (-0.10%)
Instrs: 783608 -> 782541 (-0.14%)
Latency: 7889664 -> 7888521 (-0.01%); split: -0.02%, +0.00%
InvThroughput: 1315690 -> 1314863 (-0.06%); split: -0.06%, +0.00%
VClause: 11826 -> 11830 (+0.03%)
SClause: 27736 -> 27734 (-0.01%)
Copies: 50493 -> 50428 (-0.13%); split: -0.13%, +0.01%
PreSGPRs: 23264 -> 23265 (+0.00%)

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16436>
2022-05-12 17:10:41 +00:00
Konstantin Seurer 938c9d9615 nir: Add a ray launch size addr intrinsic
Signed-off-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15712>
2022-05-12 15:04:31 +00:00
Timothy Arceri 0f98ed4afe nir: remove unreachable loop terminators
Remove the conditional break statements associated with all
terminators that are associated with a fixed iteration count,
except for the one associated with the limiting terminator.

This logic matches similiar functionality that exists in the
old GLSL IR unrolling code.

This change helps a piglit test pass on the r300 driver once
we switch off the old GLSL IR unrolling code.

Shader-db results IRIS (BDW):

total instructions in shared programs: 17538619 -> 17538595 (<.01%)
instructions in affected programs: 216 -> 192 (-11.11%)
helped: 3
HURT: 0
helped stats (abs) min: 7 max: 10 x̄: 8.00 x̃: 7
helped stats (rel) min: 10.00% max: 12.07% x̄: 11.38% x̃: 12.07%

total cycles in shared programs: 858674910 -> 858672810 (<.01%)
cycles in affected programs: 79540 -> 77440 (-2.64%)
helped: 3
HURT: 0
helped stats (abs) min: 620 max: 800 x̄: 700.00 x̃: 680
helped stats (rel) min: 2.45% max: 2.83% x̄: 2.63% x̃: 2.62%

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16399>
2022-05-12 02:06:31 +00:00
Timothy Arceri 4c3d138e5d nir: always set the exact_trip_count_unknown loop terminator property
Previously we only cared if this was set for the limiting
terminator. However in the following patch we will make use of this
information on other terminators to decide if we can eliminate them.

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16399>
2022-05-12 02:06:31 +00:00
Timur Kristóf 7de3034897 ac/nir: Add I/O lowering for task and mesh shaders.
Task shaders store their output payload to VRAM where mesh
shaders read from. There are two ring buffers:

1. Draw ring: this is where mesh dispatch sizes and
the ready bit are stored.

2. Payload ring: this is where the optional payload
is stored (up to 16K per task workgroup).

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14929>
2022-05-12 00:29:51 +00:00
Jason Ekstrand df1876f615 nir: Mark negative re-distribution on fadd as imprecise
Otherwise, it would mutate `fneg(fadd(-0, 0))` into `fadd(0, -0)` which
isn't correct since -0 + (+0) = +0 + (-0) = +0.

This fixes the OpenCL contraction tests on Iris.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16041>
2022-05-12 00:05:10 +00:00
Jason Ekstrand 25249e8be2 nir/lower_blend: Expand or shrink output variables as needed
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16309>
2022-05-11 14:47:33 +00:00
Jason Ekstrand 1d22465362 nir/builder: Add a nir_resize_vector helper
We're about to use this a couple of places.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16309>
2022-05-11 14:47:33 +00:00
Jason Ekstrand 352e32e5ba nir/builder: Add a nir_trim_vector helper
This pattern pops up a bunch and the semantics of nir_channels() aren't
very convenient much of the time.  Let's add a nir_trim_vector() which
matches nir_pad_vector().

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16309>
2022-05-11 14:47:33 +00:00
Jason Ekstrand 244b654de6 nir/lower_blend: Support SNORM and integer formats for logic ops
This fixes 158 of the dEQP-VK.pipeline.logic_op.* tests, once we turn
the feature on.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16309>
2022-05-11 14:47:33 +00:00
Jason Ekstrand 730d2b7660 nir/lower_blend: Stop passing the whole options object around
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16309>
2022-05-11 14:47:33 +00:00
Jason Ekstrand dcfffdcad1 nir/lower_blend: Be more explicit about deref assumptions
Because we pull the RT from the variable location and use that to look
up formats, we need a constant RT index.  To deal with arrays (possibly
of arrays), we would either need to handle array derefs (we don't today)
or we need to require the variables to be split into one variable per
RT.  Given that we have to lower indirect derefs anyway (to get constant
indices), we may as well require the client to split output variables by
calling nir_lower_io_arrays_to_elements_no_indirect().

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16309>
2022-05-11 14:47:33 +00:00
Michael Skorokhodov fd75be7986 glsl: Fix ir_quadop_vector validation
Some glcts tests have failed due to incorrect processing of `ir_quadop_vector` in
`ir_validation`. e.g:
`GLES31.functional.shaders.builtin_functions.integer.imulextended.int_highp_geometry`

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6461
Fixes: 23cde71b ("glsl: Stop lowering ir_quadop_vector.")

Reviewed-by: Emma Anholt <emma@anholt.net>
Signed-off-by: Mykhailo Skorokhodov <mykhailo.skorokhodov@globallogic.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16420>
2022-05-10 23:53:33 +00:00
Georg Lehmann 60c9a45562 nir/opt_algebraic: Simple xor/ishr optimizations.
The first pattern here removes the xor-swap pattern.

Foz-DB GFX10_3:
Totals from 305 (0.23% of 134913) affected shaders:
CodeSize: 1589040 -> 1585164 (-0.24%)
Instrs: 284344 -> 283375 (-0.34%)
Latency: 4205148 -> 4198472 (-0.16%); split: -0.16%, +0.00%
InvThroughput: 708745 -> 708739 (-0.00%)

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16411>
2022-05-10 19:29:31 +00:00
Georg Lehmann 66e917fff6 nir/opt_algebraic: Fix mask in shift by constant combining.
The comment above is correct, but the code to calculate the mask was broken.

No Foz-db changes outside of noise.

Fixes: 0e6581b87d ("nir/algebraic: Reassociate shift-by-constant of shift-by-constant")
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15990>
2022-05-10 18:47:21 +00:00
Timur Kristóf 7f189e3467 nir: Add upper bound for AMD shader arg intrinsics.
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13155>
2022-05-10 17:16:03 +00:00
Jason Ekstrand aea935264a shader_info: Bump the number of images and textures supported
OpenCL requires up to 128 read-only images and up to 64 write images.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15988>
2022-05-10 11:23:15 -05:00
Jason Ekstrand b37831c606 nir: Gather samplers_used separately from textures
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15988>
2022-05-10 11:23:12 -05:00
Jason Ekstrand 3c07c3e16d shader_info: Make images_used a bitset
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15988>
2022-05-10 11:23:11 -05:00
Jason Ekstrand 28f534350c nir: Stop assuming shader_info::textures_used is 32-bit
This isn't a hot path.  We don't need to be manually using the
INSIDE_WORD version which will assert if we ever get a bigger texture
index.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15988>
2022-05-10 11:23:07 -05:00
Jason Ekstrand 625b352f14 nir: Set image_buffers and msaa_images in lower_samplers_as_deref
This is where we set images_used so it's less likely that things will
accidentally get out-of-sync.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15988>
2022-05-10 11:21:39 -05:00
Jordan Justen 1c3e584dfa nir/divergence: handle more *_intel intrinsics
v2: fix topo/btd (Lionel)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16421>
2022-05-10 08:49:58 +00:00
Emma Anholt f3df3d4c80 glsl: Make all drivers take the GLSLOptimizeConservatively path.
Now that all consumers of GLSL use NIR, make the remaining drivers take
the path that relies on NIR to really do optimization.

nouveau steam shader-db runtime -6.69631% +/- 1.29235% (n=12).
No change on shader-db there.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16364>
2022-05-10 05:03:34 +00:00
Karol Herbst 9c5fd100cc nir: add a nir_remove_non_entrypoints helper
This code just got duplicated a lot. There is still more, but the
remaining instances do a bit more than just removing other functions.

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16348>
2022-05-10 03:37:44 +00:00
Jason Ekstrand 4b67d70d22 nir: Fix constant folding for non-32-bit ifind_msb and clz
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16348>
2022-05-10 03:37:44 +00:00
Emma Anholt 23cde71bb9 glsl: Stop lowering ir_quadop_vector.
Now that everybody goes through NIR, glsl_to_nir is happy to handle the
instruction and turn it into nir_op_vec4 instead of going to a temp
variable and back.

No changes on freedreno shader-db.

Reviewed-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16363>
2022-05-09 22:13:31 +00:00
Lionel Landwerlin 35d82ecf1e nir/lower_shader_calls: put inserted instructions into a dummy block
When moving code into the main block or loop blocks, put the code into
its own :

    if(true) { ... }

block so that we avoid break/continue/return issues.

v2: Also take care of the main block with return instructions

v3: Make deletion more obvious with dummy if blocks (Jason)

v4: Fixup assert for loops (Lionel)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 8dfb240b1f ("nir: Add raytracing shader call lowering pass.")
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16036>
2022-05-09 08:43:40 +00:00
Lionel Landwerlin 9cf986dcff nir/lower_shader_calls: don't insert code after break/continue
When moving code from below to the insertion cursor point, if the
cursor points to a jump instruction, don't bother inserting the code.
It would break the break/continue assumptions of NIR and would not be
executed anyway.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 8dfb240b1f ("nir: Add raytracing shader call lowering pass.")
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16036>
2022-05-09 08:43:40 +00:00
Lionel Landwerlin 51dea59eb4 nir/lower_shader_calls: don't use nop instructions as cursors
Stop using nop instructions which are causing issues with
break/continue, instead use a nir_cursor (which brings its share of
pain).

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 8dfb240b1f ("nir: Add raytracing shader call lowering pass.")
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16036>
2022-05-09 08:43:40 +00:00
Jason Ekstrand 25661ea028 nir/cf: Return a cursor from nir_cf_extract as well
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16036>
2022-05-09 08:43:40 +00:00
Lionel Landwerlin d65cf403f3 nir/cf: return cursor after insertion of cf_list
This will be useful to cut code from one location and paste it at
another place and later keep pasting after the previous insertions.

v2: update comment (Jason)
    deal with stiching 2 empty blocks (Jason)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16036>
2022-05-09 08:43:40 +00:00
Icecream95 ad864a7c15 nir/lower_tex: Copy more fields in lower_tex_to_txd and friends
Fixes NIR validation errors for OpenMW on Panfrost.

Fixes: 1f97819fbe ("panfrost: Emulate GL_CLAMP on Bifrost")
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15939>
2022-05-07 10:51:10 +00:00
Mike Blumenkrantz 5c24eb721a nir/gather_info: flag fbfetch on subpass image loads
might not be able to determine which output is being read, but these
are definitely fbfetch uses (from lavapipe)

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16346>
2022-05-06 17:04:34 +00:00
Emma Anholt dd3179aff0 glsl: Remove unused lower_variable_index_to_cond_assign.
It's been replaced by nir_lower_indirect_derefs().

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8044>
2022-05-05 22:25:03 +00:00
Emma Anholt 2529690ee3 glsl: Remove EmitNoLoops and the associated lower_jumps(lower_break=true) code.
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8044>
2022-05-05 22:25:03 +00:00
Emma Anholt c03cc83ef1 compiler/glsl: Remove the dead parts of build_program_resource_list().
These have all moved to NIR linking.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8044>
2022-05-05 22:25:03 +00:00
Emma Anholt 3a42e92a4f glsl: Drop the dead MOD_TO_FLOOR path.
It's now called lower_fmod in NIR.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8044>
2022-05-05 22:25:03 +00:00
Emma Anholt 7f13763690 glsl: Remove the unused lower_if_to_cond_assign.
Now that everything goes through NIR, nir_opt_peephole_select has replaced
it.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8044>
2022-05-05 22:25:03 +00:00
Emma Anholt 9617184bc2 glsl: Retire the non-NIR GLSL linking paths.
Now that we have only GLSL->NIR as a path in the frontend, we can rely on
the NIR linking support.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8044>
2022-05-05 22:25:03 +00:00
Eric Anholt e566b54a59 glsl: Remove UBO reference lowering.
All UBO-supporting drivers now go through the NIR path, which does a
better job of it.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8044>
2022-05-05 22:25:03 +00:00
Georg Lehmann 5833fab766 nir/lower_mediump: Add a new pass to fold 16bit image load/store.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15179>
2022-05-04 09:58:03 +00:00
Emma Anholt 695587413b nir: Don't assert on tg4 offset range.
From the GL 4.6 spec: "If the value of any non-ignored component of the
offset vector operand is outside implementation-dependent limits, the
results of the texture lookup are undefined."  We shouldn't assertion
fail, then.

GLSL-to-NIR shouldn't be enforcing limits on TG4 offsets, since it doesn't
for non-TG4 tex_src_offset either.  Leave it up to the driver to handle
it.

Fixes a crash in a piglit test on nouveau that supplies a negative random
number up to 10,000 as the first coordinate for some reason.  Other NIR
drivers lowered TG4 explicit offsets to tex_src_offset, so they weren't
affected.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16261>
2022-05-03 21:45:49 +00:00
Alyssa Rosenzweig ca280b2283 nir: Don't set writes_memory for reading XFB
That's a read, not a write. Fixes optimizations getting disabled for fragment
shaders when linked with a shader producing transform feedback varyings.

Fixes: 85a723975b ("nir: add and gather shader_info::writes_memory")
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16285>
2022-05-03 19:02:17 +00:00
Emma Anholt e3607e96bb nir: Eliminate out-of-bounds read/writes in local lowering.
Avoids nir validation assertion failures, and it's not like backend
drivers would want to see definitely-out-of-bounds read/writes either.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16066>
2022-05-03 18:32:47 +00:00
Timothy Arceri 180398f785 nir: fix sorting before assigning varying driver locations
We need to make sure we also properly sort varyings sharing a single
slot otherwise we can end up assigning earlier components to the next
slot if we have already processed later components.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6392

Fixes: 1e93b0caa1 ("mesa/st: add support for NIR as possible driver IR")

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16208>
2022-05-03 00:04:30 +00:00
Karol Herbst 93144175fa vtn: clamp SpvOpImageQuerySize dest to 32 bit
CL image arrays slice is 64 bit for whatever reason...

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16205>
2022-04-29 00:01:20 +00:00
Jason Ekstrand c31db58f65 nir/deref: Add an alu-of-cast optimization
Casts shouldn't change the bit pattern of the deref and you have to cast
again after you're done with the ALU anyway so we can ignore casts on
ALU sources.  This means we can actually start constant folding NULL
checks even if there are annoying casts in the way.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15673>
2022-04-28 23:05:48 +00:00
Emma Anholt 536c8ee96d nir/lower_tex: Make the adding a 0 LOD to nir_op_tex in the VS optional.
This controls the whole lowering of "make tex ops with implicit
derivatives on non-implicit-derivative stages be tex ops with an explicit
lod of 0 instead", but it's really hard to describe that in a git commit
summary.

All existing callers get it added except:
- nir_to_tgsi which didn't want it.
- nouveau, which didn't want it (fixes regressions in shadowcube and
  shadow2darray with NIR, since the shading languages don't expose txl of
  those sampler types and thus it's not supported in HW)
- optional lowering passes in mesa/st (lower_rect, YUV lowering, etc)

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16156>
2022-04-28 21:26:08 +00:00
Karol Herbst a2c9e1cb50 nir: add 16 and 64 bit fisnormal lowering
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16206>
2022-04-28 18:36:52 +00:00
Gert Wollny 47d3f7c69f nir: Don't optimize to 64 bit fsub if the driver doesn't support it
Fixes: a4840e15ab
  r600: Use nir-to-tgsi instead of TGSI when the NIR debug opt is disabled.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16130>
2022-04-27 00:01:20 +00:00
Jason Ekstrand e24d8760e9 nir: Constant fold sampler/texture offsets
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16171>
2022-04-26 22:34:39 +00:00
Jason Ekstrand 9332598b26 nir/constant_folding: Break TXB folding into a helper function
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16171>
2022-04-26 22:34:39 +00:00
Yevhenii Kolesnikov 65caf46b3b nir: Remove single-source phis before opt_if_loop_last_continue
We might have some single-source phis leftover after prior optimizations. We
want to get rid of them before merging the blocks.

Fixes: 5921a19d4b ("nir: add if opt opt_if_loop_last_continue()")

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6312

Signed-off-by: Yevhenii Kolesnikov <yevhenii.kolesnikov@globallogic.com>
Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16095>
2022-04-26 17:06:07 +00:00
Jason Ekstrand ef9d97ec1f spirv: Handle Op*MulExtended for non-32-bit types
Fixes: 58bcebd987 ("spirv: Allow [i/u]mulExtended to use new nir opcode")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6306
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16060>
2022-04-26 15:16:11 +00:00
Alyssa Rosenzweig 94b01ddcdd nir: Use u_worklist to back nir_block_worklist
u_worklist is nir_block_worklist, suitably generalized. All we need to do is
define the macros to translate between the APIs.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16046>
2022-04-25 23:50:57 +00:00
Jason Ekstrand 1755730362 nir: Lower all bit sizes of usub_borrow
It's not clear why this is restricted to 32-bit besides that being the
only bit size where GLSL has an intrinsic for this.  All drivers that
set this probably want it lowered for all bit sizes as far as I can
tell.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6353
Fixes: 8a3e344180 ("nir/opt_algebraic: Fix some expressions with ambiguous bit sizes")
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16146>
2022-04-25 21:27:09 +00:00
Samuel Pitoiset 4ebb5391ac nir: mark XFB varyings as unmoveable to prevent them to be remapped
XFB varyings are considered as always active IO to prevent them to
be removed or compacted. Though, if the NIR linker doesn't mark XFB
varyings as unmoveable it still possible to remap other varyings to
the same location/component.

Fixes KHR-Single-GL46.enhanced_layouts.xfb_override_qualifiers_with_api
with Zink and a bunch of other dEQP XFB tests.

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6301
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timothy Arceri  <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16092>
2022-04-25 07:56:27 +00:00
Samuel Pitoiset 26f74f17d9 nir: fix marking XFB varyings as always active IO
Components need to be handled, otherwise if a shader has two XFB
varyings at the same location, only one will be marked as always active.

Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timothy Arceri  <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16092>
2022-04-25 07:56:27 +00:00
Mike Blumenkrantz a6a4bf0f1e glsl/nir: set new_style_shadow for sparse tex ops as necessary
this needs the sparse result type, which is not the ir type

Fixes: f4a972b748 ("glsl/nir: convert sparse ir_texture to nir")

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16097>
2022-04-24 15:56:05 +00:00
Marek Olšák f7a77ff900 nir: fix an uninitialized variable valgrind warning in nir_group_loads
pass_flags is only initialized for grouped loads, so change the order

Fixes: 33b4eb149e - nir: add new SSA instruction scheduler grouping loads into indirection groups

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16090>
2022-04-22 18:18:09 +00:00
Lionel Landwerlin 9f44a26462 nir/divergence: handle load_global_block_intel
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: dd39e311b3 ("nir: Add nir_intrinsic_{load,store}_deref_block_intel")
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16075>
2022-04-21 17:41:04 +00:00
Gert Wollny 496fd59d71 nir: Add pass to split 64 bit vec3 and vec4 variable access and phis
NTT can't convert local 64 variables of type vec3 or vec4, therefore,
they need to be split into vec2 + double or vec2 + vec2.

At the same time deal splitting the phi nodes.

The pass goes into the global namespace because it is also useful
for r600.

v2: only lower function_temps (Emma) and handle array of arrays (Jason)

v3: - remove bool parameter in function to merge
      vec3 and vec4
    - simplify load/store_deref_(array|var)
    - use a pointer hash table
    - simplify PHI splitting (all Emma)

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15945>
2022-04-21 16:57:11 +00:00
Erik Faye-Lund 30aab0af07 nir/lower_int64: do not try to clamp floats to int-range
The clamping isn't correct, because the exact values ended up getting
rounded off a bit when converting back to floats.

But, converting floats to integers have undefined results when the
float value doesn't fit in the integer. So let's not try to clamp the
value here.

This was caught by digging at a Clang warning, see this thread for
details:

https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15547#note_1329769

Acked-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16022>
2022-04-21 14:12:34 +00:00
Alexey Bozhenko 25acf1d869 spirv: fix OpBranchConditional when both branches are the same
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6246

Signed-off-by: Bozhenko Alexey <oleksii.bozhenko@globallogic.com>

Fixes: 64cb143b92 ("spirv: Fix handling of OpBranchConditional with same THEN and ELSE")
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15929>
2022-04-21 13:41:24 +00:00
Rhys Perry dab745f3b4 nir/copy_prop_vars: fix non-vector shader call payloads
Fixes RADV+Q2RTX.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Fixes: ff05137c2d ("nir: introduce and use nir_component_mask")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16029>
2022-04-20 21:03:03 +00:00
Jason Ekstrand 1b8a43a0ba util: Remove util_cpu_detect
util_cpu_detect is an anti-pattern: it relies on callers high up in the call
chain initializing a local implementation detail. As a real example, I added:

...a Mali compiler unit test
...that called bi_imm_f16() to construct an FP16 immediate
...that calls _mesa_float_to_half internally
...that calls util_get_cpu_caps internally, but only on x86_64!
...that relies on util_cpu_detect having been called before.

As a consequence, this unit test:

...crashes on x86_64 with USE_X86_64_ASM set
...passes on every other architecture
...works on my local arm64 workstation and on my test board
...failed CI which runs on x86_64
...needed to have a random util_cpu_detect() call sprinkled in.

This is a bad design decision. It pollutes the tree with magic, it causes
mysterious CI failures especially for non-x86_64 developers, and it is not
justified by a micro-optimization.

Instead, let's call util_cpu_detect directly from util_get_cpu_caps, avoiding
the footgun where it fails to be called.  This cleans up Mesa's design,
simplifies the tree, and avoids a class of a (possibly platform-specific)
failures. To mitigate the added overhead, wrap it all in a (fast) atomic
load check and declare the whole thing as ATTRIBUTE_CONST so the
compiler will CSE calls to util_cpu_detect.

Co-authored-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15580>
2022-04-20 18:44:35 +00:00
Daniel Schürmann 90a0675989 nir/lower_alu_to_scalar: don't set the nir_builder cursor
This ensures recursive lowering in a single pass.

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15977>
2022-04-20 17:53:48 +00:00
Mike Blumenkrantz 27a43b531b nir/fold_16bit_sampler_conversions: add a mask for supported sampler dims
AMD might not support cubes, but that doesn't mean cubes can't be used
on other drivers

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15852>
2022-04-20 12:12:36 +00:00
Erik Faye-Lund ff05137c2d nir: introduce and use nir_component_mask
The BITFIELD_MASK() macro is intended for using with actual bitfields,
not with nir_component_mask_t. This means we do some extra work to
handle values that are invalid for nir_component_mask_t in the first
place.

This eliminates some warnings on Clang, where the compiler complains
about casting UINT32_MAX to UINT16_MAX.

Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15547>
2022-04-19 06:54:47 +00:00
Timothy Arceri 4b4bb46af4 nir: fix setting varying from uniform as flat
Here we just make sure we match the interpolation type on both
sides of the shader interface. Drivers like d3d12 are expecting
this.

Fixes: 9401990e6f ("nir/linker: set varying from uniform as flat")

Reviewed-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16003>
2022-04-18 11:45:56 +00:00
Emma Anholt 66a0f318fd nir: Avoid generating extra ftruncs for array handling.
It's quite likely that the source of the f2i32 was already an integer, in
which case we can skip the ftrunc (particularly useful on the int-to-float
class of hardware that's unlikely to just have a native trunc opcode!).

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15870>
2022-04-16 13:07:09 -07:00
Emma Anholt e4aa5f7889 nir: Skip fround_even on already-integral values.
Just like the other make-the-float-an-integer opcodes.  Noticed in a
gallium nine shader run through TGSI-to-NIR, where the array index had
been floored by the user, but got implicitly rounded by DX9 array
indexing.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15870>
2022-04-16 13:07:09 -07:00
Emma Anholt 6947016b46 nir: Add lowering for fround_even on r300.
When we put NIR in the compiler stack for r300, indirect addressing broke
for gallium nine.  DX's array indirects round the float value, so the DX
shader gets mapped to a TGSI "ARR ADDR[0] src.x" instruction.  Translating
that to NIR maps to r0[f2i32(fround(src.x))].  While we might hope that in
translation back using nir-to-tgsi after optimization we would recognize
the construct and emit ARR again, that's going to be error prone (think
"what if src.x is in a NIR register?") so we need a fallback plan.  r300
will be able to handle this lowering, so get it in place first to fix the
regression.

Fixes: #6297
Fixes: 7d2ea9b0ed ("r300: Request NIR shaders from mesa/st and use NIR-to-TGSI.")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15870>
2022-04-16 13:07:09 -07:00
Jason Ekstrand 5c9e4d400a nir/opcodes: fisfinite32 should return bool32
Otherwise constant-folding will fold it to 0/1 instead of 0/~0.

Fixes: 330e28155f ("nir: add 32-bit bool of fisfinite")
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15984>
2022-04-16 02:46:12 +00:00
Jason Ekstrand 319d87846c nir,microsoft: Move scale_fdiv into a common NIR pass
While we're at it, convert to nir_shader_instructions_pass() to get rid
of some boilerplate and get metadata correct.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15983>
2022-04-16 02:10:25 +00:00
Rhys Perry 46d14abeae nir/builder: add nir_{ine,ibfe,ubfe}_imm() helper
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15854>
2022-04-15 23:56:11 +00:00
Rhys Perry 9baa45c189 nir/gather_info: fix system_value_read for rt/mesh system values
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Fixes: c7eaf03068 ("radv: use shader_info::system_values_read")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15952>
2022-04-15 11:10:22 +00:00
Mike Blumenkrantz 5b0634d735 nir/lower_tex: fix rect queries with lower_rect set
queries still need the sampler_dim changed

Fixes: 682e14d3ea ("nir: lower_tex: Don't normalize coordinates for TXF with RECT")

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15895>
2022-04-14 22:57:23 +00:00
Jason Ekstrand 46d9b0e431 clc: Declare LLVMContexts on the stack
This prevents more use-after-free errors.  Passing them around using
std::unique_ptr ensures that the LLVMContext gets destroyed but doesn't
ensure destruction order.  Declaring it on the stack ensures that the
context doesn't get destroyed until right before the the function
returns which is after any other LLVM stuff is destroyed.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Icecream95 <ixn@disroot.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15937>
2022-04-14 21:19:56 +00:00
Jason Ekstrand 6099e6ce9a clc: Rework logging a bit
First, separate out the LLVM context logging to make it take a
clc_logger instead of passing in a string stream.  Currently, the LLVM
context may outlive the string stream which we assign which may lead to
use-after-free errors.  Second, use a separate string stream for clang
diagnosticl logging which we intentionally declare before the compiler
so the compiler can't outlive it.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Icecream95 <ixn@disroot.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15937>
2022-04-14 21:19:56 +00:00
Jason Ekstrand 6e3b9b1b1d clc: Only initialize LLVM once
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Icecream95 <ixn@disroot.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15937>
2022-04-14 21:19:56 +00:00
Dave Airlie fdab872224 clc: initialise one more llvm stage
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Icecream95 <ixn@disroot.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15937>
2022-04-14 21:19:56 +00:00
Dave Airlie b518020f64 clc: add simple llvm initialise API
This just calls some of the LLVM init functions in a common place

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Icecream95 <ixn@disroot.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15937>
2022-04-14 21:19:56 +00:00
Icecream95 f226222846 clc: Use stringstream for printing spirv errors
The type of the spv_position_t components can differ across platforms,
it's simpler to just let C++ overloading handle it.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15437>
2022-04-14 00:14:43 +00:00
Rhys Perry 778fc176b1 nir/opt_load_store_vectorize: create load_shared2_amd/store_shared2_amd
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13778>
2022-04-13 23:08:07 +00:00
Rhys Perry dc835626b3 nir/opt_load_store_vectorize: fix broken indentation
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13778>
2022-04-13 23:08:07 +00:00
Rhys Perry 8ff122f8b8 nir: add load_shared2_amd and store_shared2_amd
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13778>
2022-04-13 23:08:07 +00:00
Rhys Perry 5c038b3f02 nir: add _amd global access intrinsics
These are the same as the normal ones, but they take an unsigned 32-bit
offset in BASE and another unsigned 32-bit offset in the last source.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14124>
2022-04-13 16:23:35 +00:00
Timur Kristóf a7147ef1e8 nir: Handle out of bounds access in nir_vectorize_tess_levels.
Replace out of bounds loads with undef.
Then, delete instructions with out of bounds access.

Fixes: f5adf27fb9 "nir,radv: add and use nir_vectorize_tess_levels()"
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6264
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15775>
2022-04-13 13:25:10 +00:00
Lionel Landwerlin 3394680368 nir/lower_shader_calls: name resume shaders
Helpful when lost in a sea of NIR :)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15887>
2022-04-13 06:59:29 +00:00
Jason Ekstrand d0ace28790 nir/lower_int64: Fix [iu]mul_high handling
e551040c60, which added a new mechanism for 64-bit imul which is more
efficient on BDW and later Intel hardware also introduced a bug where we
weren't properly walking both X and Y.  No idea how testing didn't find
this.

Fixes: e551040c60 ("nir/glsl: Add another way of doing lower_imul64 for gen8+"
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6306
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15829>
2022-04-12 23:19:38 +00:00
Marcin Ślusarz 9b23aaf3cf nir: remove gl_PrimitiveID output from MS when it's not used in FS
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15340>
2022-04-12 09:35:26 +00:00
Mike Blumenkrantz 9c212e117d nir/lower_point_size_mov: handle case where gl_Position isn't written
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15821>
2022-04-10 16:45:15 +00:00
Mike Blumenkrantz 310903d096 nir/lower_point_size_mov: fix check for overwriting existing pointsize
this should match the comment and allow overwriting injected pointsize
variables regardless of whether xfb is flagged

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15699>
2022-04-07 21:56:09 -04:00
Timothy Arceri 7d216f296a glsl: fix needs_lowering() call in varying packing pass
Here we remove the outer arrays on geom and tess shaders where
needed. Without this the pass can sometimes attempt to pack a
varying on only one side of the shader interface where it is not
actually needed. The result can be mismatching varying types.

Fixes: d6b9202873 ("glsl: disable varying packing when its not safe")

Tested-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15761>
2022-04-07 23:57:40 +00:00
Mike Blumenkrantz 6cfcf891c1 nir/lower_tex: avoid adding invalid LOD to RECT textures
this is illegal

Fixes: 74ec2b12be ("nir/lower_tex: Rework invalid implicit LOD lowering")

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15804>
2022-04-07 21:37:58 +00:00
Jason Ekstrand 4cd260590c nir: Dont set coord_components on txs
Fixes: e1fc23265f ("nir: Add a pass for lowering CL-style image ops to texture ops")
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15758>
2022-04-07 21:13:35 +00:00
Emma Anholt 03549f3bf3 spirv: Silence "Decoration not allowed on struct members: SpvDecorationRestrict"
VK-GL-CTS causes tons of these due to a bug in glslang, to the point where
it's hard to find actual issues in test logs.  Disable the warning for
now, with a link to the issue we're waiting on being resolved.

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15332>
2022-04-05 21:37:46 +00:00
Erik Faye-Lund ed399a179e nir/tests: do not use designated initializers in c++ code
Designated initializers require C++20, which is a bit easier said than
done to support well across meson versions. Let's avoid using them
for now instead.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15706>
2022-04-05 16:58:56 +00:00
Ian Romanick 7fd1955412 nir: intel/compiler: Lower TXD on array surfaces on DG2+
DG2 can only do sample_d and sample_d_c on 1D and 2D surfaces.  Cube
maps and 3D surfaces were already handled, but 1D array and 2D array
surfaces were not.

Fixes the following Vulkan CTS failures on DG2:

    dEQP-VK.glsl.texture_functions.texturegradclamp.isampler1darray_fragment
    dEQP-VK.glsl.texture_functions.texturegradclamp.isampler2darray_fragment
    dEQP-VK.glsl.texture_functions.texturegradclamp.sampler1darray_fixed_fragment
    dEQP-VK.glsl.texture_functions.texturegradclamp.sampler1darray_float_fragment
    dEQP-VK.glsl.texture_functions.texturegradclamp.sampler2darray_fixed_fragment
    dEQP-VK.glsl.texture_functions.texturegradclamp.sampler2darray_float_fragment
    dEQP-VK.glsl.texture_functions.texturegradclamp.usampler1darray_fragment
    dEQP-VK.glsl.texture_functions.texturegradclamp.usampler2darray_fragment

The Fixes: tag below is a bit misleading. This commit adds another
lowering, similar to the one in the Fixes: commit, that probably should
have been added at the same time.  I just want to make sure this commit
gets applied everywhere that commit was also applied.

Fixes: 635ed58e52 ("intel/compiler: Lower txd for 3D samplers on XeHP.")
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15681>
2022-03-31 12:59:18 -07:00
Emma Anholt 97f17d4b38 glsl: Delete dont_lower_swz path of lower_quadop_vector.
This was last used with Mesa classic, in _mesa_ir_link_shader().

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15623>
2022-03-30 22:26:15 +00:00
Emma Anholt 761eb7e539 glsl: Delete unused EmitNoPow path.
This was last used with i915c, now lower_fpow covers this class of
lowering.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15623>
2022-03-30 22:26:15 +00:00
Yonggang Luo a1814067cd nir: Move the define of snprintf to header nir.h
The define of snprintf in nir_lower_atomics_to_ssbo.c is duplicated,
so remove it from this file

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14014>
2022-03-30 00:45:11 +08:00
Yonggang Luo 153cb830c4 vtn: Fixes compiling error for mingw/ucrt by using setjmp/longjmp function instead compiler builtin
The compiling error are:
```
[369/1463] Compiling C object src/compiler/nir/libnir.a.p/.._spirv_gl_spirv.c.obj
FAILED: src/compiler/nir/libnir.a.p/.._spirv_gl_spirv.c.obj
"cc" "-Isrc/compiler/nir/libnir.a.p" "-Isrc/compiler/nir" "-I../../src/compiler/nir" "-Iinclude" "-I../../include" "-Isrc" "-I../../src" "-Isrc/mapi" "-I../../src/mapi" "-Isrc/mesa" "-I../../src/mesa" "-I../../src/gallium/include" "-Isrc/gallium/auxiliary" "-I../../src/gallium/auxiliary" "-Isrc/compiler"
"-I../../src/compiler" "-Isrc/compiler/spirv" "-I../../src/compiler/spirv" "-fvisibility=hidden" "-fcolor-diagnostics" "-D_FILE_OFFSET_BITS=64" "-Wall" "-Winvalid-pch" "-std=c11" "-O2" "-g" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-DPACKAGE_VERSION=\"22.1.0-devel\"" "-DPACKAGE_BUGREPORT=\"https://gitlab.freedesktop.org/mesa/mesa/-/issues\"" "-DHAVE_WINDOWS_PLATFORM" "-DHAVE_SURFACELESS_PLATFORM" "-DUSE_ELF_TLS" "-DUSE_TLS_BEHIND_FUNCTIONS" "-DENABLE_ST_OMX_BELLAGIO=0" "-DENABLE_ST_OMX_TIZONIA=0" "-DEGL_NO_X11" "-DHAVE___BUILTIN_BSWAP32" "-DHAVE___BUILTIN_BSWAP64" "-DHAVE___BUILTIN_CLZ" "-DHAVE___BUILTIN_CLZLL" "-DHAVE___BUILTIN_CTZ" "-DHAVE___BUILTIN_EXPECT" "-DHAVE___BUILTIN_FFS" "-DHAVE___BUILTIN_FFSLL" "-DHAVE___BUILTIN_POPCOUNT" "-DHAVE___BUILTIN_POPCOUNTLL" "-DHAVE___BUILTIN_UNREACHABLE" "-DHAVE___BUILTIN_TYPES_COMPATIBLE_P" "-DHAVE_FUNC_ATTRIBUTE_CONST" "-DHAVE_FUNC_ATTRIBUTE_FLATTEN" "-DHAVE_FUNC_ATTRIBUTE_MALLOC" "-DHAVE_FUNC_ATTRIBUTE_PURE" "-DHAVE_FUNC_ATTRIBUTE_UNUSED" "-DHAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT" "-DHAVE_FUNC_ATTRIBUTE_WEAK" "-DHAVE_FUNC_ATTRIBUTE_FORMAT" "-DHAVE_FUNC_ATTRIBUTE_PACKED" "-DHAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL" "-DHAVE_FUNC_ATTRIBUTE_ALIAS" "-DHAVE_FUNC_ATTRIBUTE_NORETURN" "-DHAVE_FUNC_ATTRIBUTE_VISIBILITY" "-DHAVE_UINT128" "-D_WINDOWS" "-D_WIN32_WINNT=0x0A00" "-DWINVER=0x0A00" "-DPIPE_SUBSYSTEM_WINDOWS_USER" "-D_USE_MATH_DEFINES" "-DUSE_SSE41" "-DUSE_GCC_ATOMIC_BUILTINS" "-DHAS_SCHED_H" "-DHAVE_CET_H" "-DHAVE_STRTOF" "-DHAVE_TIMESPEC_GET" "-DHAVE_STRTOK_R" "-DHAVE_QSORT_S" "-DHAVE_ZLIB" "-DHAVE_ZSTD" "-DHAVE_COMPRESSION" "-DLLVM_AVAILABLE" "-DMESA_LLVM_VERSION_STRING=\"13.0.1\"" "-DLLVM_IS_SHARED=1" "-DDRAW_LLVM_AVAILABLE" "-DMESA_EXECMEM" "-DVK_USE_PLATFORM_WIN32_KHR" "-Werror=implicit-function-declaration" "-Werror=missing-prototypes" "-Werror=return-type" "-Werror=empty-body" "-Werror=incompatible-pointer-types" "-Werror=int-conversion" "-Wimplicit-fallthrough" "-Wno-missing-field-initializers" "-fno-math-errno" "-fno-trapping-math" "-Qunused-arguments" "-fno-common" "-Wno-microsoft-enum-value" "-Werror=format" "-Wformat-security" "-Werror=thread-safety" "-ffunction-sections" "-fdata-sections" "-Werror=pointer-arith" "-Werror=gnu-empty-initializer" "-Wno-override-init" "-Wno-initializer-overrides" -MD -MQ src/compiler/nir/libnir.a.p/.._spirv_gl_spirv.c.obj -MF "src/compiler/nir/libnir.a.p/.._spirv_gl_spirv.c.obj.d" -o src/compiler/nir/libnir.a.p/.._spirv_gl_spirv.c.obj "-c" ../../src/compiler/spirv/gl_spirv.c
../../src/compiler/spirv/gl_spirv.c:241:19: error: incompatible pointer types passing 'jmp_buf' (aka '_JBTYPE [16]') to parameter of type 'void **' [-Werror,-Wincompatible-pointer-types]
   if (vtn_setjmp(b->fail_jump)) {
                  ^~~~~~~~~~~~
1 error generated.
[376/1463] Compiling C object src/compiler/nir/libnir.a.p/.._spirv_spirv_to_nir.c.obj
FAILED: src/compiler/nir/libnir.a.p/.._spirv_spirv_to_nir.c.obj
"cc" "-Isrc/compiler/nir/libnir.a.p" "-Isrc/compiler/nir" "-I../../src/compiler/nir" "-Iinclude" "-I../../include" "-Isrc" "-I../../src" "-Isrc/mapi" "-I../../src/mapi" "-Isrc/mesa" "-I../../src/mesa" "-I../../src/gallium/include" "-Isrc/gallium/auxiliary" "-I../../src/gallium/auxiliary" "-Isrc/compiler"
"-I../../src/compiler" "-Isrc/compiler/spirv" "-I../../src/compiler/spirv" "-fvisibility=hidden" "-fcolor-diagnostics" "-D_FILE_OFFSET_BITS=64" "-Wall" "-Winvalid-pch" "-std=c11" "-O2" "-g" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-DPACKAGE_VERSION=\"22.1.0-devel\"" "-DPACKAGE_BUGREPORT=\"https://gitlab.freedesktop.org/mesa/mesa/-/issues\"" "-DHAVE_WINDOWS_PLATFORM" "-DHAVE_SURFACELESS_PLATFORM" "-DUSE_ELF_TLS" "-DUSE_TLS_BEHIND_FUNCTIONS" "-DENABLE_ST_OMX_BELLAGIO=0" "-DENABLE_ST_OMX_TIZONIA=0" "-DEGL_NO_X11" "-DHAVE___BUILTIN_BSWAP32" "-DHAVE___BUILTIN_BSWAP64" "-DHAVE___BUILTIN_CLZ" "-DHAVE___BUILTIN_CLZLL" "-DHAVE___BUILTIN_CTZ" "-DHAVE___BUILTIN_EXPECT" "-DHAVE___BUILTIN_FFS" "-DHAVE___BUILTIN_FFSLL" "-DHAVE___BUILTIN_POPCOUNT" "-DHAVE___BUILTIN_POPCOUNTLL" "-DHAVE___BUILTIN_UNREACHABLE" "-DHAVE___BUILTIN_TYPES_COMPATIBLE_P" "-DHAVE_FUNC_ATTRIBUTE_CONST" "-DHAVE_FUNC_ATTRIBUTE_FLATTEN" "-DHAVE_FUNC_ATTRIBUTE_MALLOC" "-DHAVE_FUNC_ATTRIBUTE_PURE" "-DHAVE_FUNC_ATTRIBUTE_UNUSED" "-DHAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT" "-DHAVE_FUNC_ATTRIBUTE_WEAK" "-DHAVE_FUNC_ATTRIBUTE_FORMAT" "-DHAVE_FUNC_ATTRIBUTE_PACKED" "-DHAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL" "-DHAVE_FUNC_ATTRIBUTE_ALIAS" "-DHAVE_FUNC_ATTRIBUTE_NORETURN" "-DHAVE_FUNC_ATTRIBUTE_VISIBILITY" "-DHAVE_UINT128" "-D_WINDOWS" "-D_WIN32_WINNT=0x0A00" "-DWINVER=0x0A00" "-DPIPE_SUBSYSTEM_WINDOWS_USER" "-D_USE_MATH_DEFINES" "-DUSE_SSE41" "-DUSE_GCC_ATOMIC_BUILTINS" "-DHAS_SCHED_H" "-DHAVE_CET_H" "-DHAVE_STRTOF" "-DHAVE_TIMESPEC_GET" "-DHAVE_STRTOK_R" "-DHAVE_QSORT_S" "-DHAVE_ZLIB" "-DHAVE_ZSTD" "-DHAVE_COMPRESSION" "-DLLVM_AVAILABLE" "-DMESA_LLVM_VERSION_STRING=\"13.0.1\"" "-DLLVM_IS_SHARED=1" "-DDRAW_LLVM_AVAILABLE" "-DMESA_EXECMEM" "-DVK_USE_PLATFORM_WIN32_KHR" "-Werror=implicit-function-declaration" "-Werror=missing-prototypes" "-Werror=return-type" "-Werror=empty-body" "-Werror=incompatible-pointer-types" "-Werror=int-conversion" "-Wimplicit-fallthrough" "-Wno-missing-field-initializers" "-fno-math-errno" "-fno-trapping-math" "-Qunused-arguments" "-fno-common" "-Wno-microsoft-enum-value" "-Werror=format" "-Wformat-security" "-Werror=thread-safety" "-ffunction-sections" "-fdata-sections" "-Werror=pointer-arith" "-Werror=gnu-empty-initializer" "-Wno-override-init" "-Wno-initializer-overrides" -MD -MQ src/compiler/nir/libnir.a.p/.._spirv_spirv_to_nir.c.obj -MF "src/compiler/nir/libnir.a.p/.._spirv_spirv_to_nir.c.obj.d" -o
src/compiler/nir/libnir.a.p/.._spirv_spirv_to_nir.c.obj "-c" ../../src/compiler/spirv/spirv_to_nir.c
../../src/compiler/spirv/spirv_to_nir.c:196:16: error: incompatible pointer types passing 'jmp_buf' (aka '_JBTYPE [16]') to parameter of type 'void **' [-Werror,-Wincompatible-pointer-types]
   vtn_longjmp(b->fail_jump, 1);
               ^~~~~~~~~~~~
```

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14014>
2022-03-30 00:45:08 +08:00
Jason Ekstrand 4a08ee7ecf spirv/libclc: Add generic versions of arithmetic functions
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15622>
2022-03-29 15:02:07 +00:00
Georg Lehmann 16be909936 nir: Add an option to lower 64bit iadd_sat.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15421>
2022-03-28 20:02:52 +00:00
Georg Lehmann 922916bf64 nir: Move lower_usub_sat64 to nir_lower_int64_options.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15421>
2022-03-28 20:02:52 +00:00
Pierre-Eric Pelloux-Prayer 2bc933f7d5 glsl/nir/linker: fix shader_storage_blocks_write_access
shader_storage_blocks_write_access was computed using the buffer indices
in the program but ShaderStorageBlocksWriteAccess is used with the shader
buffers.

So if a VS had 3 SSBOs and a FS had 4, the mask for VS was 0x3 (correct) but
the mask for the FS was 0x78 instead of 0x15.

Fix this by substracting the index of the first shader buffer in the program's
buffers.

Fixes: 79127f8d5b ("glsl: set ShaderStorageBlocksWriteAccess in the nir linker")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6184
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15552>
2022-03-28 11:06:31 +02:00
Pierre-Eric Pelloux-Prayer 61ee560bc5 glsl/nir/linker: update shader_storage_blocks_write_access for SPIR-V
Most of the code inside the "!prog->data->spirv" blocks shouldn't be
executed for SPIR-V except the part updating the writable mask.

See https://gitlab.freedesktop.org/mesa/mesa/-/issues/6184

Cc: mesa-stable
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15552>
2022-03-28 10:37:45 +02:00
Kenneth Graunke af529b545a nir: Teach nir_divergence_analysis about Intel-specific intrinsics
- load_reloc_const is just an immediate constant load, it's convergent.

- nir_intrinsic_load_global_const_block_intel should be convergent,
  it says the address must be uniform, and we uniformize the predicate

- Lowered image intrinsics: image_deref_load_param_intel just reads
  information about an image, as long as the image variable is
  convergent it should be too.  load_raw_intel...if the address we
  come up with is convergent, it ought to be as well.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15484>
2022-03-26 00:28:19 +00:00
Christian Gmeiner 2648ccb341 nir: Use const for nir_shader_get_entrypoint(..)
nir_shader_get_entrypoint(..) should not modify the passed nir_shader
object. Enforce this by marking shader paramenter as const.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Mihai Preda <mhpreda@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15362>
2022-03-25 07:25:37 +00:00
Mike Blumenkrantz 4e35ed8c67 nir/lower_tex: add txp lowering option for arrays
this is illegal in vulkan, so zink needs to be able to lower these

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15510>
2022-03-23 23:18:47 +00:00
Georg Lehmann 81b2008af9 nir/legalize_16bit_sampler_srcs: Don't guess source type.
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14895>
2022-03-23 20:55:39 +00:00
Georg Lehmann b5fe1187ec nir/fold_16bit_sampler_conversions: Fix src type mismatches.
Gitlab: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5996
Fixes: fb29cef8 ("nir: add many passes that lower and optimize 16-bit input/outputs and samplers")
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14895>
2022-03-23 20:55:39 +00:00
Georg Lehmann 88ec73e5e8 nir/fold_16bit_sampler_conversions: Fix dest type mismatches.
Gitlab: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5996
Fixes: fb29cef8dd ("nir: add many passes that lower and optimize 16-bit input/outputs and samplers")
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14895>
2022-03-23 20:55:39 +00:00
Georg Lehmann 798e47be51 nir/fold_16bit_sampler_conversions: Don't fold dest upcasts.
This is not a valid optimization.

Fixes: fb29cef8dd ("nir: add many passes that lower and optimize 16-bit input/outputs and samplers")
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14895>
2022-03-23 20:55:39 +00:00
Daniel Schürmann 832d67e99d nir: rename nir_src_is_dynamically_uniform to nir_src_is_always_uniform
As this function doesn't check for any control-flow
dependence, it only returns true for statically
(or globally) uniform values.
The same holds true for is_binding_dynamically_uniform()
in nir_opt_gcm().
Rename to better reflect that property.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14994>
2022-03-23 14:02:08 +00:00
Jason Ekstrand 4b2c78c08a spirv: Implement the function portion of the Linkage capability
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15486>
2022-03-23 10:24:31 +00:00
Jason Ekstrand 80a076382d nir: Allow nir_var_mem_global variables
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15486>
2022-03-23 10:24:31 +00:00
Rhys Perry e82aba88dc nir: allow bindless image/texture/sampler handles to be vectors
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12773>
2022-03-22 16:33:27 +00:00
Rhys Perry ff52a724d4 nir: add load_{scalar,vector}_arg_amd and load_smem_amd intrinsics
load_smem_gcn is similar to load_global/load_global_constant, but it's
guaranteed to use SMEM and it's much easier to utilize the format's 32-bit
offset source.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12773>
2022-03-22 16:33:27 +00:00
Kenneth Graunke 85d30846db nir: Print divergence status of SSA values if analysis was ever run.
After running divergence analysis, we include "div" or "con" for each
SSA def's divergence/convergence status:

	vec1 32 div ssa_35 = fddy ssa_34
	vec1 32 con ssa_36 = fddy ssa_6.x

We omit this before the first time divergence analysis has been run.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15445>
2022-03-21 22:46:34 -07:00
Qiang Yu 9401990e6f nir/linker: set varying from uniform as flat
Flat varying can save some rasterization compute cost
and register needed by shader.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15341>
2022-03-22 01:33:23 +00:00
Qiang Yu 2617e6c028 nir/linker: disable varying from uniform lowering by default
This fixes performance regression for Specviewperf/Energy
on AMD GPU. Other GPUs passing varying by memory may choose
to re-enable it as need.

Fixes: 2604625043 ("nir/linker: support uniform when optimizing varying")
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15341>
2022-03-22 01:33:23 +00:00
Karol Herbst 43c3f4386b nir: fix nir_sweep for printf
I hit a memory corruption trying to implement printf for Rusticl

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15474>
2022-03-21 13:23:04 +00:00
Jason Ekstrand e9ff6f4f06 nir/print: Add support for generic pointers
The way they're handled is that deref->modes is treated as a bitfield of
possible modes.  Variables are required to have a specific mode and
derefs with deref_type_var are as well.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13171>
2022-03-21 11:26:44 +00:00
Mike Blumenkrantz cdcfcb7916 nir/lower_is_helper_invocation: create load_helper_invocation instr with bitsize=1
the specification stipulates that this is a bool value, so don't load it as an int
or else nir_validate explodes

Fixes: f17b41ab4f ("nir: add lowering pass for helperInvocationEXT()")

Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15402>
2022-03-21 03:20:33 +00:00
Jason Ekstrand 7030d14e0d spirv: Properly mangle generic pointers
Fixes: a8e53a772f ("spirv: Add generic pointer support")
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15470>
2022-03-18 21:52:05 +00:00
Connor Abbott acba08b58f ir3: Implement and document ldc.k
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13148>
2022-03-17 12:15:45 +00:00
Connor Abbott ccc64b7e00 ir3: Plumb through store_uniform_ir3 intrinsic
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13148>
2022-03-17 12:15:45 +00:00
Connor Abbott 3244e659e0 ir3: Implement basic shader preamble intrinsics
These will be used to implement the ir3-specific shader preamble
lowering in NIR. shps is conceptually similar to getone (although it
technically can't be duplicated) and shpe is similar to other barriers,
since it has to happen after any stores to the constant file in the
preamble. Add NIR intrinsics and plumbs them through ir3.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13148>
2022-03-17 12:15:45 +00:00
Connor Abbott 3b96ad70ee nir: Add a preamble optimization pass
This pass tries to move computations that are uniform for the entire
draw to the preamble. There's also an API for backends to insert their
own instructions into the preamble, for porting existing UBO pushing
passes.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13148>
2022-03-17 12:15:45 +00:00
Connor Abbott 31221ee556 nir: Add a "deep" instruction clone
For the shader preamble, we need to add support for cloning one
instruction at a time into the preamble, but we also need to rewrite
sources.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13148>
2022-03-17 12:15:45 +00:00
Connor Abbott d1b017d479 nir: Add preamble functions
These are functions that run before the entrypoint at least once per
draw and write their results via store_preamble, and then are loaded in
the rest of the shader via load_preamble.

We will add users in the following commits.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13148>
2022-03-17 12:15:45 +00:00
Konstantin Seurer 357bd1829f nir,spirv: Preserve ray_query_value
Signed-off-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14565>
2022-03-13 12:02:05 +01:00
Iago Toral Quiroga fed51585c4 nir/schedule: allow drivers to decide about instruction latency
On V3D reading UBOs from uniform addresses uses a more efficient
mechanism with lower latency. On other platforms there may be
simular scenarios.

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15276>
2022-03-09 15:53:04 +00:00
Iago Toral Quiroga e7a4e97076 nir/schedule: use larger delay for non-filtered memory reads
This has been pending for a long time. It is not very consistent to
add a significant delay for textures and not do it for UBOs, etc
The reason we have not been doing this so far is the accumulated effect
on register pressure for V3D as shown by shader-db results below, but
from the point of view of a generic scheduler it makes sense to do this.

Later patches will address V3D specific issues with register pressure
derived from this by letting the driver control its instruction delay
settings.

total instructions in shared programs: 12662138 -> 13126587 (3.67%)
instructions in affected programs: 1813091 -> 2277540 (25.62%)
helped: 2410
HURT: 10499

total threads in shared programs: 415858 -> 407208 (-2.08%)
threads in affected programs: 17348 -> 8698 (-49.86%)
helped: 8
HURT: 4333

total uniforms in shared programs: 3711483 -> 3812698 (2.73%)
uniforms in affected programs: 128012 -> 229227 (79.07%)
helped: 3474
HURT: 2143

total max-temps in shared programs: 2138763 -> 2318430 (8.40%)
max-temps in affected programs: 318780 -> 498447 (56.36%)
helped: 588
HURT: 11997

total spills in shared programs: 3860 -> 49086 (1171.66%)
spills in affected programs: 709 -> 45935 (6378.84%)
helped: 23
HURT: 1595

total fills in shared programs: 5573 -> 55810 (901.44%)
fills in affected programs: 1067 -> 51304 (4708.25%)
helped: 23
HURT: 1595

LOST:   3
GAINED: 0

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15276>
2022-03-09 15:53:04 +00:00
Iago Toral Quiroga 3bd041e2fb nir/schedule: handle nir_intrinsic_group_memory_barrier
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15276>
2022-03-09 15:53:04 +00:00
Iago Toral Quiroga 46e330c07e nir/schedule: fix handling of generic memory barrier
We can get a generic nir_intrinsic_memory_barrier to represent a
barrier involving multiple semantics (instead of getting individual
specific barriers for each semantic). This means that we need to
consider these as potentially affecting shared memory access as well.

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15276>
2022-03-09 15:53:04 +00:00
Mike Blumenkrantz 0d80aed363 nir/gather_info: check copy_deref instrs for writing outputs
this is a valid way to write an output even though it usually gets rewritten
to some other instruction later on

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15228>
2022-03-09 05:10:21 +00:00
Mike Blumenkrantz 53cbba83eb glsl: store OES/EXT point_size extension enablement to shader struct
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15228>
2022-03-09 05:10:21 +00:00
Timur Kristóf 4b99b528f5 nir: Introduce workgroup_index and ability to lower workgroup_id to it.
The workgroup_index is intended for situations when a 3 dimensional
workgroup_id is not available on the HW, but a 1 dimensional index is.
In this case, we can use lower the 3D ID to use this.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15103>
2022-03-08 17:36:31 +00:00
Timur Kristóf 6a4c01f3ef nir: Extract lower_id_to_index into a separate function.
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15103>
2022-03-08 17:36:31 +00:00
Timur Kristóf 64acec0ef9 nir: Fix lowering terminology of compute system values: "from"->"to".
This is to match other NIR terminology.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15103>
2022-03-08 17:36:31 +00:00
Timur Kristóf 5b9bf3434f nir: Fix handling of NV_mesh_shader PRIMITIVE_INDICES output.
PRIMITIVE_INDICES is a flat array in NV_mesh_shader,
not a proper arrayed output, as opposed to D3D-style
mesh shaders where it's addressed by the primitive index.

Prevent assigning several slots to primitive indices,
to avoid issues.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Acked-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15160>
2022-03-08 13:44:10 +00:00
Georg Lehmann 6731460194 nir: Fix source type for fragment_fetch_amd.
Like txf_ms, these take integers not floats.

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15242>
2022-03-07 12:21:12 +00:00
Samuel Pitoiset 6532307555 nir: introduce nir_pack_{sint,uint}_2x16 instructions
These instructions have AMD hardware equivalent and they will be used
to lower fragment shader outputs in NIR.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15231>
2022-03-04 08:06:56 +00:00
Daniel Schürmann ca4595e01a nir/opt_shrink_vectors: update docstring
in order to reflect the various recent improvements.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12468>
2022-03-04 00:18:58 +00:00
Daniel Schürmann 405829cd85 nir/opt_shrink_vectors: remove duplicate components from vecN
vecN instructions which are only used by other ALU
will now get duplicate channels removed.

i915g:
total instructions in shared programs: 396309 -> 396294 (<.01%)
instructions in affected programs: 186 -> 171 (-8.06%)

r300:
total instructions in shared programs: 1165059 -> 1164354 (-0.06%)
instructions in affected programs: 35884 -> 35179 (-1.96%)
total temps in shared programs: 165497 -> 165326 (-0.10%)
temps in affected programs: 2990 -> 2819 (-5.72%)

softpipe:
total instructions in shared programs: 2860028 -> 2859084 (-0.03%)
instructions in affected programs: 55539 -> 54595 (-1.70%)
total temps in shared programs: 516939 -> 516546 (-0.08%)
temps in affected programs: 6623 -> 6230 (-5.93%)

Acked-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12468>
2022-03-04 00:18:58 +00:00
Daniel Schürmann e5963478c2 nir/opt_shrink_vectors: shrink load_const properly
This patch enables removal of arbitrary channels in
load_const instructions, if they are either unused or
duplicates of other channels and only used by ALU.

Totals from 692 (0.51% of 134913) affected shaders: (GFX10.3)
VGPRs: 21832 -> 21544 (-1.32%)
CodeSize: 1322016 -> 1313080 (-0.68%); split: -0.68%, +0.01%
Instrs: 243635 -> 242231 (-0.58%); split: -0.58%, +0.00%
Latency: 1856138 -> 1857237 (+0.06%); split: -0.09%, +0.15%
InvThroughput: 424298 -> 421671 (-0.62%); split: -0.62%, +0.01%
VClause: 4580 -> 4583 (+0.07%); split: -0.02%, +0.09%
SClause: 14336 -> 14354 (+0.13%); split: -0.04%, +0.17%
Copies: 8897 -> 8859 (-0.43%); split: -0.45%, +0.02%
PreSGPRs: 20439 -> 20437 (-0.01%)
PreVGPRs: 16011 -> 15907 (-0.65%); split: -0.97%, +0.32%

i915g:
total instructions in shared programs: 396471 -> 396309 (-0.04%)
instructions in affected programs: 6408 -> 6246 (-2.53%)
total const in shared programs: 56458 -> 56422 (-0.06%)
const in affected programs: 407 -> 371 (-8.85%)
LOST:   shaders/closed/steam/trine-2/fp-3.shader_test FS

r300:
total instructions in shared programs: 1164421 -> 1165059 (0.05%)
instructions in affected programs: 143981 -> 144619 (0.44%)
total temps in shared programs: 165488 -> 165497 (<.01%)
temps in affected programs: 318 -> 327 (2.83%)
total consts in shared programs: 922140 -> 921952 (-0.02%)
consts in affected programs: 12438 -> 12250 (-1.51%)

softpipe:
total instructions in shared programs: 2859978 -> 2860028 (<.01%)
instructions in affected programs: 183355 -> 183405 (0.03%)
total temps in shared programs: 517071 -> 516939 (-0.03%)
temps in affected programs: 1416 -> 1284 (-9.32%)
total imm in shared programs: 103601 -> 102767 (-0.81%)
imm in affected programs: 3928 -> 3094 (-21.23%)

Acked-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12468>
2022-03-04 00:18:58 +00:00
Ilia Mirkin 8ed07c0da9 nir: remove bogus logic to allow cube + offset to work
This was done for an a4xx hack which is now removed. No API allows cube
texturing to have offsets.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14670>
2022-03-03 18:26:43 +00:00
Andrii Simiklit ddf2778269 glsl: add member's location layout qualifier rules for `arrayed` in/out blocks
From Section 4.4.1 (Input Layout Qualifiers) of the GLSL 4.50 spec:

     "For some blocks declared as arrays, the location can only be applied
     at the block level: When a block is declared as an array where
     additional locations are needed for each member for each block array
     element, it is a compile-time error to specify locations on the block
     members. That is, when locations would be under specified by applying
     them on block members, they are not allowed on block members. For
     arrayed interfaces (those generally having an extra level of
     arrayness due to interface expansion), the outer array is stripped
     before applying this rule"

From Section 1.2.1 (Changes from Revision 6 of GLSL Version) of the GLSL 4.50 spec:

     "Private Bug 15678: Don’t allow location = on block members where
      the block needs an array of locations"

From Section 4.4.1 (Input Layout Qualifiers) of the GLSL ES 3.20 spec

     "If an input is declared as an array of blocks, excluding per-vertex-arrays
      as required for tessellation, it is an error to declare a member of
      the block with a location qualifier"

From Section 1.1.3 (Changes from GLSL ES 3.2 revision 3) of the GLSL ES 3.20 spec:

     "Arrayed blocks cannot have layout location qualifiers on members"

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Signed-off-by: Andrii Simiklit <andrii.simiklit@globallogic.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11522>
2022-03-03 05:42:45 +00:00
Ian Romanick 06eb9fb125 nir/algebraic: Optimize some cases of (sXX(a, b) != 0.0)
I noticed the SGE case while looking at the output of
shaders/closed/steam/trine-2/fp-3.shader_test on i915g.  These are
especially bad on i915 that needs two instructions to implement SNE.

An alternative would be to duplicate the sne(sXX(a, b), 0.0) rules in an
algebraic pass that occurs after bool_to_float.  Doing the work earlier
seems preferable.

i915
total instructions in shared programs: 788274 -> 788223 (<.01%)
instructions in affected programs: 666 -> 615 (-7.66%)
helped: 5
HURT: 0
helped stats (abs) min: 9 max: 12 x̄: 10.20 x̃: 9
helped stats (rel) min: 5.00% max: 11.11% x̄: 8.12% x̃: 8.16%
95% mean confidence interval for instructions value: -12.24 -8.16
95% mean confidence interval for instructions %-change: -10.81% -5.43%
Instructions are helped.

LOST:   0
GAINED: 2

The two gained shaders are assembly fragment programs in Euro Truck
Simulator 2.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15210>
2022-03-03 00:07:58 +00:00
Emma Anholt d506d910e4 nir: Switch to using nir_vec_scalars() for things that used nir_channel().
This should reduce follow-on optimization work to copy-propagate and
dead-code away the movs generated in construction of vectors.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14865>
2022-03-02 22:28:58 +00:00
Emma Anholt 16c064dfaf nir: Add a helper for setting up a nir_ssa_scalar struct.
Trivial, but will help users avoid some struct constructions that can be
awkward in C.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14865>
2022-03-02 22:28:58 +00:00
Emma Anholt d95f9d189a nir: Introduce a nir_vec_scalars() helper using nir_ssa_scalar.
Many users of nir_vec() do so by nir_channel()-ing a new ssa defs as movs
from other vectors to put the new vector together, which then just have to
get copy-propagated into the ALU srcs and DCEed away the temporary movs.
If they instead take nir_ssa_scalar, we can avoid that extra work.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14865>
2022-03-02 22:28:58 +00:00
Marek Olšák 1dcd1eac6a nir: pass nir_shader into nir_recompute_io_bases instead of func_impl
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14388>
2022-03-01 21:59:55 +00:00
Marek Olšák 606811bded nir: add nir_print_xfb_info
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14388>
2022-03-01 21:59:55 +00:00
Marek Olšák ad68a1ee5a nir: add nir_gather_xfb_info_from_intrinsics for lowered IO
Drivers will use this.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14388>
2022-03-01 21:59:55 +00:00
Marek Olšák d4c051b047 nir: add nir_lower_io_passes() with new transform feedback
moved from radeonsi without the vectorization, which won't be needed for
now. We will lower IO in st/mesa instead of radeonsi to get the transform
feedback info into store instructions.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14388>
2022-03-01 21:59:55 +00:00
Marek Olšák 3528dcdfa1 nir: add nir_io_semantics::no_varying, no_sysval_output, and helpers
This is for drivers that have separate store instructions for varyings,
system value outputs (such as clip distances), and transform feedback.
The flags tell the driver not to store the output to those locations.

This will be used by radeonsi initially, and then maybe by a new linker.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14388>
2022-03-01 21:59:55 +00:00
Marek Olšák 548b2d47b2 nir: scalarize transform feedback info in nir_lower_io_to_scalar
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14388>
2022-03-01 21:59:55 +00:00
Marek Olšák cc5505088b nir: add shader_info::xfb_strides
NIR now fully contains pipe_stream_output_info in shader_info and IO
intrinsics if lower_io_variables is true. radeonsi will not use
pipe_stream_output_info after this, and other drivers are free to follow
that.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14388>
2022-03-01 21:59:55 +00:00
Marek Olšák 4636fa7f38 nir: add transform feedback info into nir_intrinsic_store_output
This will allow compaction of transform feedback varyings because they
are no longer tied to varying slots with this information.
It will also make transform feedback info available to all NIR passes
after IO is lowered. It's meant to replace pipe_stream_output_info.

Other intrinsics are not used with transform feedback.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14388>
2022-03-01 21:59:55 +00:00
Marek Olšák 2c6e41bfe1 nir: fix nir_io_semantics::gs_streams in nir_lower_io_to_scalar
gs_streams is relative to the component. Also clear the high bits.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14388>
2022-03-01 21:59:55 +00:00
Marek Olšák 73ef225fc2 nir: validate write_mask for all intrinsics that have it
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14388>
2022-03-01 21:59:55 +00:00
Mike Blumenkrantz b28cff9f4a nir/lower_psiz_mov: stop clobbering existing exports
for this pass to work with xfb, the original value in the shader must be
preserved when xfb is active, and the driver must export only the newly
created output

Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15184>
2022-02-28 15:42:19 +00:00
Mike Blumenkrantz 3267417c22 nir/lower_psiz: create the store instruction more accurately
creating this at the start of the shader means it will get optimized out
when the pass is used to overwrite existing psiz values, and creating it
at the end means it will get optimized out in geometry shaders, so instead
just walk the instructions and create another store right after the existing one

Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15184>
2022-02-28 15:42:19 +00:00
Emma Anholt b1f349dff4 nir: Allow the _replicates opcodes to have num_components != 4.
This required relaxing a core NIR assertion which I don't think is doing
any important validation.

The shader-db effects here are small, but they're important for avoiding a
regression when we start doing per-component DCE in opt_shrink_vectors
(https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12468)

softpipe shader-db:
total instructions in shared programs: 2859777 -> 2859454 (-0.01%)
instructions in affected programs: 18881 -> 18558 (-1.71%)
total temps in shared programs: 293994 -> 293914 (-0.03%)
temps in affected programs: 418 -> 338 (-19.14%)

i915g:
total instructions in shared programs: 407562 -> 407544 (<.01%)
instructions in affected programs: 570 -> 552 (-3.16%)

r300:
total instructions in shared programs: 1414450 -> 1414459 (<.01%)
instructions in affected programs: 44494 -> 44503 (0.02%)
total vinst in shared programs: 473782 -> 473727 (-0.01%)
vinst in affected programs: 1102 -> 1047 (-4.99%)
total sinst in shared programs: 231224 -> 231216 (<.01%)
sinst in affected programs: 432 -> 424 (-1.85%)
total temps in shared programs: 197605 -> 197607 (<.01%)
temps in affected programs: 103 -> 105 (1.94%)

crocus hsw:
total instructions in shared programs: 8158185 -> 8158134 (<.01%)
instructions in affected programs: 10927 -> 10876 (-0.47%)

Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15178>
2022-02-25 12:31:48 -08:00
Timur Kristóf 962b2fe214 spirv: Use task_payload mode for generic task outputs and mesh inputs.
This new mode will be only used for the actual payload variables and
not the number of launched mesh shader workgroups, which will still
be treated as an output.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14930>
2022-02-25 06:52:07 +00:00
Timur Kristóf f629fbd778 nir: Add new variable mode for task/mesh payload.
Task shader outputs work differently than other shaders, so they
need special consideration. Essentially, they have two kinds of
outputs:

1. Number of mesh shader workgroups to launch.
Will be still represented by a shader output.

2. Optional payload of up to (at least) 16K bytes.
These payload variables behave similarly to shared memory, but
the spec doesn't actually define them as shared memory (also, they
may be implemented differently by each backend), so we need to add
a new NIR variable mode for them.

These payload variables can't be represented by shader outputs
because the 16K bytes don't fit the 32x vec4 model that NIR uses
for its output variables.

This patch adds a new NIR variable mode: nir_var_mem_task_payload
and corresponding explicit I/O intrinsics, as well as support for
this new mode in nir_lower_io.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14930>
2022-02-25 06:52:07 +00:00
Iago Toral Quiroga f1d20ec67c nir/nir_opt_move: handle non-SSA defs
We just skip register defs and avoid moving register reads across them.
This allows us to run this pass in non-SSA form.

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15056>
2022-02-24 11:36:00 +00:00
Iago Toral Quiroga fe2249eac5 nir: add a nir_instr_def_is_register helper
This returns true if the instruction has a dest that is not an SSA value.

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15056>
2022-02-24 11:36:00 +00:00
Iago Toral Quiroga 0a04468704 nir/nir_opt_move: allow to move uniform loads
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15056>
2022-02-24 11:36:00 +00:00
Timothy Arceri 6eec8fcbfa glsl/nir: free GLSL IR right after we convert to NIR
Gives us memory back faster which is useful for pathalogical CTS
tests.

The GLSL IR was previously used after converting to NIR for things
like building the GL resource list but we have had a NIR version
for this for some time and I don't believe there are any other
use cases left for keeping the old IR hanging around this long.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15127>
2022-02-24 01:10:49 +00:00
Erik Faye-Lund 2cd0779f83 nir/spirv: guard macros in case of redefinition
On some systems, these macros are already defined, and being defined
slightly differently causes them to emit redefinition-warnings.

Let's wrap them in ifdefs to avoid the warnings.

Acked-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15084>
2022-02-21 19:47:17 +00:00
Rhys Perry a9ac270c5f nir/validate: don't add instrs not present in shader to shader_gc_list
This makes the set smaller and GC list validation faster.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13547>
2022-02-21 11:57:22 +00:00
Rhys Perry 925c5f817d nir/validate: don't validate the GC list by default
This seems really slow.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13547>
2022-02-21 11:57:18 +00:00
Connor Abbott 7e8d885919 spirv: Rewrite determinant calculation
The old calculation for mat3 was clever, but it turns out that a
straightforward application of subdeterminants similar to how mat4 is
handled is more efficient: on a scalar architecture with some sort of
combined multiply+add instruction with a negate modifier (both fairly
common), the new determinant is 9 instructions vs. 15 for the old one,
and without the multiply-add it's 14 instructions vs. 18 for the old
one.  When used as a routine for inverse() the savings are compounded,
because we now use the same method as used to compute the adjucate
matrix and so CSE can combine most of the calculations with the adjucate
matrix ones.

Once mat3 and mat4 use the same method for computing determinants, we
can combine them into a single recursive function. I also pulled up the
mat_subdet() function because it was doing basically what we need, so
it's now shared between determinant and inverse. This shrinks the
implementation significantly, as can be seen from the diffstat.

The real reason I want to change this, though, is that it fixes
dEQP-VK.glsl.builtin.precision_fp16_storage16b.inverse.compute.mat3 with
turnip. Qualcomm uses round-to-zero for 16-bit frcp, which combined with
some inaccuracy in the old method of calculating the determinant led us
to fail. Qualcomm's driver uses something like the new method to
calculate the determinant in the inverse. We could argue that Mesa's
method should be allowed, because round-to-zero for floating-point
division is within spec and there are no precision guarantees given for
determinant() or inverse(). However we might as well use the more
efficient method.

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14652>
2022-02-19 02:03:25 +00:00
Connor Abbott 6761550357 nir/serialize: Don't access blob->data directly
It won't work if the blob is fixed-size and we overrun the size, which
will be the case with the Vulkan pipeline cache.

This gets a bit tricky for the repeated-header optimization, because we
can't read the header from the blob. Instead we have to store the header
itself.

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15028>
2022-02-19 01:25:46 +00:00
Alyssa Rosenzweig 2d6233d04f nir: Check all sizes in nir_alu_instr_is_comparison
nir_alu_instr_is_comparison needs to consider all comparison opcodes regardless
of size. Otherwise, they will be missed by nir_opt_move/sink.

Without this change, lowering booleans to integers regresses register
pressure (and spills/fills) significantly in certain shaders on Panfrost,
like android/com.miHoYo.GenshinImpact/1420.shader_test.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15073>
2022-02-18 19:22:01 +00:00
Jose Maria Casanova Crespo 90f966e05f v3dv/v3d: Fix copyright holder to Raspberry Pi Ltd
Acked-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15057>
2022-02-18 11:50:07 +01:00
Alyssa Rosenzweig 7ec1d96e5e nir: Set internal=true in nir_builder_init_simple_shader
Matches the expected use by callers. We do need to fix up a few callers which
use this call for external shaders.

v2: Fix up a radv call site (Rhys).

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net> [v1]
Acked-by: Rhys Perry <pendingchaos02@gmail.com>
Acked-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14936>
2022-02-17 23:30:46 +00:00
Ian Romanick a01b262990 nir: Add missing dependency on nir_opcodes.py
Commit 38800b38 changed nir_opcodes.py, but that doesn't seem to have
triggered nir_opt_algebraic.py.  The change in 75ef5991 depends on
opt_algebraic lowering 16-bit versions of slt, but if opt_algebraic is
not rebuilt, this may not happen.  This resulted in some people seeing
assertion failures in, for example,
dEQP-VK.spirv_assembly.instruction.compute.float16.arithmetic_3.step,
due to the backend seeing nir_op_slt that it didn't know how to handle.

v2: Add nir_opcodes.py to nir_algebraic_py so that all the per-driver
algebraic passes pick up the dependency too.  Rename it to
nir_algebraic_depends.  Suggested by Emma.

Closes: #6047
Fixes: d1992255bb ("meson: Add build Intel "anv" vulkan driver")
Reviewed-by: Emma Anholt <emma@anholt.net>
Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15050>
2022-02-17 22:57:33 +00:00
Lionel Landwerlin 768930a73a nir: fix lower_memcpy
memcpy is divided into chunks that are vec4 sized max. The problem
here happens with a structure of 24 bytes :

  struct {
    float3 a;
    float3 b;
  }

If you memcpy that struct, the lowering will emit 2 load/store, one of
sized 8, next one sized 16. But both end up located at offset 0, so we
effectively drop 2 floats.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: a3177cca99 ("nir: Add a lowering pass to lower memcpy")
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15049>
2022-02-17 15:12:45 +00:00
Emma Anholt 3f4bfecee6 nir: Add some notes about const/uniform array access rules in GL.
I was doing some RE on freedreno and we had some questions about when the
hardware might need non-uniform or non-constant array access for various
descriptor types, so let's leave some notes for the next person.

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13621>
2022-02-16 20:06:21 +00:00
Samuel Pitoiset 74b932f8d3 nir: add nir_intrinsic_load_vrs_rates_amd
This intrinsic specific to RADV will be used to load VRS rates from
an user SGPR when RADV_FORCE_VRS is enabled by the application.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14713>
2022-02-16 08:11:12 +01:00
Timur Kristóf e6cfd1ed64 spirv: Create PRIMITIVE_INDICES for NV_mesh_shader on-demand.
The shader can have SpvOpWritePackedPrimitiveIndices4x8NV while the
output variable may not exist. This seems to be a defect in the
NV_mesh_shader SPIR-V spec, let's work around it by creating the
variable on-demand.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15005>
2022-02-14 11:13:45 +01:00
Timur Kristóf 0445802ab2 compiler: Extract num_mesh_vertices_per_primitive function.
Prevent code duplication.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15005>
2022-02-14 11:13:42 +01:00
Ilia Mirkin b91b036322 isaspec: add gen-based leaf bitset separation
This is necessary for some ops which have slightly different encoding on
a4xx/a5xx, but are otherwise identical. This helps keeping the compiler
from having to worry about these details and creating separate ops.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14789>
2022-02-12 13:46:07 -05:00
Ilia Mirkin 40468430a4 isaspec: fix gen_max to be 2^32-1
The minus sign has higher preference than shift:

>>> 1 << 32 - 1
2147483648
>>> (1 << 32) - 1
4294967295

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14789>
2022-02-12 13:45:57 -05:00
Ian Romanick 59889eb3ae Re-indentation after the previous commit
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:34 +00:00
Ian Romanick 912299cb39 glsl: Eliminate ir_assignment::condition
Reformatting is left for the next commit.

v2: Remove assignments from the contructors. :face_palm:

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick fb630cd783 glsl: Make ir_assignment::condition private
And add get_condition().

This proof that nothing remains that could possibly set ::condition to
anything other than NULL.

v2: Fix bad rebase.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick 5208c116f2 glsl: Don't visit rvalues in the condition of an assignment
At this point, this should always be NULL.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick 1c22f06970 glsl: Don't lower vector indexing in the condition of an assignment
At this point, this should always be NULL.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick 2652b9a83d glsl: Don't split structures in the condition of an assignment
At this point, this should always be NULL.

v2: Fix bad rebase.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick d07551ad4e glsl: Don't split arrays in the condition of an assignment
At this point, this should always be NULL.

v2: Fix bad rebase.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick 41f6b42b08 glsl: Don't tree graft in the condition of an assignment
At this point, this should always be NULL.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick 97ffca80a8 glsl: Don't dead-built-in varying eliminate in the condition of an assignment
At this point, this should always be NULL.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick 231459ad26 glsl: Remove unused condition parameter from ir_assignment constructor
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick ec5c9649ba glsl: Don't constant-fold the condition of an assignment
At this point, this should always be NULL.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick 697a460e49 glsl: Don't clone assignment conditions
At this point, this should always be NULL.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick d27e3c6adc glsl: Eliminate unused conditional assignment constructor
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick 50a0d0d875 glsl: Remove the ability to read text IR with conditional assignments
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick 710adf2e60 glsl: Add ir_assignment constructor that takes just a write mask
The other constructor that takes a write mask and a condition will be
removed shortly.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick afee5dc63f glsl: Lower if to conditional select instead of conditional assignment
Platforms that don't have flow control also don't have anything that
could be written that has a side effect.  It should be safe to implement
these condition writes as

    foo = csel(condition, bar, foo);

This should eliminate the last thing in the GLSL compiler that can
create new conditions on assignments.  Everything else that can store
something in ir_assignment::condition derives it from a pre-existing
condition.

v2: Fix bad rebase.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick c3626e1580 glsl/ir_builder: Eliminate unused conditional assignment builders
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick 46a9df6aac glsl: Don't try to emit the "linear sequence" in lower_variable_index_to_cond_assign
When there are four or fewer elements left in the array partition, the
strategy changes from a binary search of nested flow control to sequence
of conditional assignments like

    (assign, dest, src[constant_i+0], index == constant_i+0)
    (assign, dest, src[constant_i+1], index == constant_i+1)
    (assign, dest, src[constant_i+2], index == constant_i+2)
    (assign, dest, src[constant_i+3], index == constant_i+3)

or

    (assign, dest[constant_i+0], src, index == constant_i+0)
    (assign, dest[constant_i+1], src, index == constant_i+1)
    (assign, dest[constant_i+2], src, index == constant_i+2)
    (assign, dest[constant_i+3], src, index == constant_i+3)

Realistically, the first case should use ir_triop_csel instead.

The second case will either get turned back into flow control like

    if (index == constant_i+0)
        (assign, dest[constant_i+0], src)

    if (index == constant_i+1)
        (assign, dest[constant_i+1], src)

    if (index == constant_i+2)
        (assign, dest[constant_i+2], src)

    if (index == constant_i+3)
        (assign, dest[constant_i+3], src)

or a sequence of conditional selects like

    (assign, dest[constant_i+0], (csel, index == constant_i+0, src, dest[constant_i+0]))
    (assign, dest[constant_i+1], (csel, index == constant_i+1, src, dest[constant_i+1]))
    (assign, dest[constant_i+2], (csel, index == constant_i+2, src, dest[constant_i+2]))
    (assign, dest[constant_i+3], (csel, index == constant_i+3, src, dest[constant_i+3]))

The former case should continue to use the binary search.  The later
case could be generated from the binary search by other lowering passes.

At the end of the day, conditional assignments don't really help
anything here, so stop using them.

Radeon R430
total instructions in shared programs: 2398683 -> 2398419 (-0.01%)
instructions in affected programs: 5143 -> 4879 (-5.13%)
helped: 9
HURT: 8

total vinst in shared programs: 616292 -> 616010 (-0.05%)
vinst in affected programs: 4467 -> 4185 (-6.31%)
helped: 9
HURT: 8

total sinst in shared programs: 315417 -> 315667 (0.08%)
sinst in affected programs: 2568 -> 2818 (9.74%)
helped: 2
HURT: 15

total flowcontrol in shared programs: 1049 -> 1048 (-0.10%)
flowcontrol in affected programs: 7 -> 6 (-14.29%)
helped: 1
HURT: 0

total presub in shared programs: 47027 -> 47027 (0.00%)
presub in affected programs: 127 -> 127 (0.00%)
helped: 1
HURT: 1

total omod in shared programs: 3618 -> 3615 (-0.08%)
omod in affected programs: 8 -> 5 (-37.50%)
helped: 3
HURT: 0

total temps in shared programs: 450757 -> 451312 (0.12%)
temps in affected programs: 837 -> 1392 (66.31%)
helped: 8
HURT: 6

total consts in shared programs: 1031928 -> 1031920 (<.01%)
consts in affected programs: 1211 -> 1203 (-0.66%)
helped: 6
HURT: 7

The shaders that were hurt for temps... are all lies.  None of those
shaders should have compiled as all 6 had more than 32 temps to begin
with.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick 05703a49f9 glsl: Use csel in do_vec_index_to_cond_assign
This matches what NIR does.  See nir_vector_extract.

This improves code generation for several reasons.  First, it only
requires 3 comparisons instead of 4 (vec3(i > 0, i > 1, i > 2) vs
vec4(i == 0, i == 1, i == 2, i == 3)).

Secondly, it shortens the liverange of some values, possibly quite
dramatically.  Consider a loop in the old version (after lowering
if-statements to selects):

    loop {
        ...
	x = csel(i == 0, a[0], x);
	x = csel(i == 1, a[1], x);
	x = csel(i == 2, a[2], x);
	x = csel(i == 3, a[3], x);
        ...
    }

x is live for the whole loop across iterations.  In the new version, x
is only live while its value is needed:

    loop {
        ...
	t0 = csel(i > 0 , a[1], a[0]);
	t1 = csel(i > 2 , a[3], a[2]);
	x = csel(i > 1, t1, t0);
        ...
    }

Outside a loop, this also means more values of the array may have their
liveness reduced sooner (by consuming two values at once).

All Intel platforms had similar results. (Tigerlake shown)
total instructions in shared programs: 21171336 -> 21163615 (-0.04%)
instructions in affected programs: 89680 -> 81959 (-8.61%)
helped: 40
HURT: 4
helped stats (abs) min: 1 max: 450 x̄: 193.68 x̃: 196
helped stats (rel) min: 0.41% max: 13.32% x̄: 6.01% x̃: 6.22%
HURT stats (abs)   min: 1 max: 12 x̄: 6.50 x̃: 6
HURT stats (rel)   min: 0.50% max: 0.66% x̄: 0.58% x̃: 0.58%
95% mean confidence interval for instructions value: -229.68 -121.28
95% mean confidence interval for instructions %-change: -6.93% -3.89%
Instructions are helped.

total cycles in shared programs: 832879641 -> 829513122 (-0.40%)
cycles in affected programs: 44738430 -> 41371911 (-7.52%)
helped: 35
HURT: 2
helped stats (abs) min: 2 max: 189948 x̄: 96186.49 x̃: 116154
helped stats (rel) min: 0.37% max: 11.08% x̄: 5.88% x̃: 6.47%
HURT stats (abs)   min: 4 max: 4 x̄: 4.00 x̃: 4
HURT stats (rel)   min: 0.69% max: 0.69% x̄: 0.69% x̃: 0.69%
95% mean confidence interval for cycles value: -112881.94 -69092.06
95% mean confidence interval for cycles %-change: -6.77% -4.27%
Cycles are helped.

total spills in shared programs: 8061 -> 7338 (-8.97%)
spills in affected programs: 873 -> 150 (-82.82%)
helped: 24
HURT: 0

total fills in shared programs: 7501 -> 6388 (-14.84%)
fills in affected programs: 1389 -> 276 (-80.13%)
helped: 24
HURT: 0

Radeon R430
total instructions in shared programs: 2449852 -> 2449136 (-0.03%)
instructions in affected programs: 6285 -> 5569 (-11.39%)
helped: 64
HURT: 0
helped stats (abs) min: 4 max: 12 x̄: 11.19 x̃: 12
helped stats (rel) min: 8.16% max: 21.62% x̄: 12.09% x̃: 10.91%

total consts in shared programs: 1032517 -> 1032482 (<.01%)
consts in affected programs: 966 -> 931 (-3.62%)
helped: 35
HURT: 0
helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1
helped stats (rel) min: 2.94% max: 10.00% x̄: 4.26% x̃: 3.57%

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Ian Romanick ed66d7c385 glsl/lower_vector_derefs: Don't emit conditional assignments
Use if-statements instead.  Any hardware that supports this sort of
tessellation has flow control, so it will probably emit the conditional
assignment using an if-statement anyway.  This is definitely what
st_glsl_to_nir does.

v2: Fix copy-and-paste bug in the ir_type_swizzle handling.  This bug
caused segfaults in tests/spec/arb_tessellation_shader/execution/variable-indexing/tcs-patch-vec4-swiz-index-wr.shader_test.

Reviewed-by: Matt Turner <mattst88@gmail.com> [v1]
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
2022-02-11 17:25:33 +00:00
Daniel Schürmann 2a92452a0e nir/opt_shrink_vectors: Remove shrinking of store intrinsics data source
This is done via nir_opt_shrink_stores.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14480>
2022-02-11 11:50:47 +01:00
Daniel Schürmann 2dba7e6056 nir: split nir_opt_shrink_stores from nir_opt_shrink_vectors
This patch moves the shrinking of store sources into
a separate pass.
The reasoning behind this is that this pass usually only
needs to be called once while nir_shrink_vectors might
better be called several times. This allows to move
the pass(es) out of the optimization loops.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14480>
2022-02-11 11:34:01 +01:00
Ian Romanick 1cb3d1a6ae nir: Produce correct results for atan with NaN
Properly handling NaN adversely affects several hundred shaders in
shader-db (lots of Skia and a few others from various synthetic
benchmarks) and fossil-db (mostly Talos and some Doom 2016).  Only apply
the NaN handling work-around when the shader demands it.

v2: Add comment explaining the 1.0*y_over_x.  Suggested by Caio.

Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Fixes: 2098ae16c8 ("nir/builder: Move nir_atan and nir_atan2 from SPIR-V translator")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13999>
2022-02-10 18:15:39 +00:00
Ian Romanick 7d0d9b9fbc nir: Properly handle various exceptional values in frexp
frexp_sig of ±0, ±Inf, or NaN should just return the input unmodified.

frexp_exp of ±Inf or NaN is undefined, and frexp_exp of ±0 should return
the input unmodified.  This seems to already work.

No shader-db or fossil-db changes on any Intel platform.

Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Fixes: 23d30f4099 ("spirv,nir: lower frexp_exp/frexp_sig inside a new NIR pass")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13999>
2022-02-10 18:15:39 +00:00
Ian Romanick 93ed87af28 spirv: Produce correct result for GLSLstd450Tanh with NaN
No shader-db or fossil-db changes on any Intel platform.

Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Fixes: 9f9432d56c ("Revert "spirv: Use a simpler and more correct implementaiton of tanh()"")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13999>
2022-02-10 18:15:39 +00:00
Ian Romanick e442b9d792 spirv: Produce correct result for GLSLstd450Modf with Inf
GLSLstd450ModfStruct too.

No shader-db or fossil-db changes on any Intel platform.

v2: Fix handling 16-bit (and presumably 64-bit) values.

Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Fixes: f92a35d831 ("vtn: Fix Modf.")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13999>
2022-02-10 18:15:39 +00:00
Ian Romanick 75ef5991f5 spriv: Produce correct result for GLSLstd450Step with NaN
NOTE: This commit needs "nir: All set-on-comparison opcodes can take all
float types" or regressions will occur in other Vulkan SPIR-V tests.

No shader-db changes on any Intel platform.

NOTE: This commit depends on "nir: All set-on-comparison opcodes can
take all float types".

v2: Fix handling 16-bit (and presumably 64-bit) values.

About 280 shaders in Talos are hurt by a few instructions, and a couple
shaders in Doom 2016 are hurt by a few instructions.

Tiger Lake
Instructions in all programs: 159893290 -> 159895026 (+0.0%)
SENDs in all programs: 6936431 -> 6936431 (+0.0%)
Loops in all programs: 38385 -> 38385 (+0.0%)
Cycles in all programs: 7019260087 -> 7019254134 (-0.0%)
Spills in all programs: 101389 -> 101389 (+0.0%)
Fills in all programs: 131532 -> 131532 (+0.0%)

Ice Lake
Instructions in all programs: 143624235 -> 143625691 (+0.0%)
SENDs in all programs: 6980289 -> 6980289 (+0.0%)
Loops in all programs: 38383 -> 38383 (+0.0%)
Cycles in all programs: 8440083238 -> 8440090702 (+0.0%)
Spills in all programs: 102246 -> 102246 (+0.0%)
Fills in all programs: 131908 -> 131908 (+0.0%)

Skylake
Instructions in all programs: 134185495 -> 134186618 (+0.0%)
SENDs in all programs: 6938790 -> 6938790 (+0.0%)
Loops in all programs: 38356 -> 38356 (+0.0%)
Cycles in all programs: 8222366923 -> 8222365826 (-0.0%)
Spills in all programs: 98821 -> 98821 (+0.0%)
Fills in all programs: 125218 -> 125218 (+0.0%)

Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Fixes: 1feeee9cf4 ("nir/spirv: Add initial support for GLSL 4.50 builtins")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13999>
2022-02-10 18:15:39 +00:00
Ian Romanick 38800b385c nir: All set-on-comparison opcodes can take all float types
Extend 4195a9450b so that the next poor fool doesn't come along and
say, "sge does the right thing for 16-bit sources, but slt gives a NIR
validation failure. What the deuce?"

NOTE: This commit is necessary to prevent regressions in GLSLstd450Step
tests of 16-bit sources at "spriv: Produce correct result for
GLSLstd450Step with NaN".

Fixes: 4195a9450b ("nir: sge operation is defined for floating-point types")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13999>
2022-02-10 18:15:39 +00:00
Ian Romanick 97ce3a56bd nir/search: Constify instr parameter to nir_search_expression::cond
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13999>
2022-02-10 18:15:39 +00:00
Ian Romanick 4dd4135551 nir: Constify def parameter to nir_ssa_def_bits_used
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13999>
2022-02-10 18:15:39 +00:00
Otavio Pontes 510d248299 nir: Use proper macro to set bits of variable correctly
When slots is 64 only the first bit was being set, instead of setting
all 64 bits of the variable, so for that case the function
get_variable_io_mask() always returned 0.

This behaviour caused variables that are being used both on producer and
consumer to be considered unused and thus being removed on
nir_remove_unused_io_vars().

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14955>
2022-02-10 17:19:54 +00:00
Georg Lehmann c2168f845e nir/lower_mediump: Treat u2u16 like i2i16.
There is a comment in nir_fold_16bit_sampler_conversions saying that these
are the same, but the code only checks for i2i16.

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14893>
2022-02-10 16:13:54 +00:00
Emma Anholt 20469009c7 nir: Delete the per-instr SSA liveness impl.
It was introduced for nir-to-tgsi, and I found that it was the wrong
approach.  There's a reason nobody else does RA this way.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14404>
2022-02-10 00:36:57 +00:00
Ilia Mirkin 13c6f401cc glsl: only validate xfb_buffer values when we have enhanced layouts
XFB might not be supported, and the shader wouldn't be setting this
flag. But validation would still fail, since the number of xfb buffers
would be 0. So only validate if an xfb_buffer is set in the qualifiers.

See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5415
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14869>
2022-02-09 03:31:16 +00:00
Ilia Mirkin c17a3392c4 glsl: simplify conditions for setting various allowed flags
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14869>
2022-02-09 03:31:16 +00:00
Emma Anholt f4ee7146f9 nir: Split the flag for lowering of fabs and fneg to source modifiers.
i915 and r300 have fneg source modifier but not fabs, and doing it in NIR
can save us some backend pain.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14938>
2022-02-08 18:50:01 -08:00
Lionel Landwerlin c78be5da30 intel/fs: lower ray query intrinsics
v2: Add helper for acceleration->root_node computation (Caio)

v3: Update comment on "done" bit (Caio)
    Remove progress bool value for impl function (Caio)
    Don't use nir_shader_instructions_pass to search the shader (Caio)

v4: Rename variable for if/else block (Caio)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13719>
2022-02-08 12:55:25 +00:00
Lionel Landwerlin e06f9d49bc nir/lower_shader_calls: consider relocated constants as rematerializable
After all they're constants.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13719>
2022-02-08 12:55:25 +00:00
Lionel Landwerlin 6d9ae6ec1e intel: add a new intrinsic to get the shader stage from bindless shaders
We'll use this to apply ray tracing operations in our trivial return
shader based on the stage we're in.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13719>
2022-02-08 12:55:25 +00:00
Lionel Landwerlin b8f087b0e6 nir/builder: add nir_ior_imm() helper
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13719>
2022-02-08 12:55:25 +00:00
Lionel Landwerlin bb40e999d1 intel/nir: use a single intel intrinsic to deal with ray traversal
In the future we'll want to reuse this intrinsic to deal with ray
queries. Ray queries will use a different global pointer and
programmatically change the control/level arguments of the trace send
instruction.

v2: Comment on barrier after sync trace instruction (Caio)
    Generalize lsc helper (Caio)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13719>
2022-02-08 12:55:25 +00:00
Lionel Landwerlin 4deb8e86df nir: change intel dss_id intrinsic to topology_id
This will allow to reuse the same intrinsic for various topology based
ID.

v2: fix intrinsic comment (Caio)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13719>
2022-02-08 12:55:24 +00:00
Alyssa Rosenzweig aaf00a1b4d nir,zink: Make lower_discard_if a common pass
This pass (lowering discard_if to control flow and unconditional
discard) was originally written for Zink, but is useful for hardware
that lacks conditional discard instructions like AGX. In theory AGX
could implement a conditional discard with CSEL, but the vendor
compiler uses a lowering like this one. Since I like not writing code,
I'd like to use the pass that's already in tree.

v2: Don't preserve dominance (Jason). Assert we don't see demotes or
terminates (Jason). Add Mike's ack.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14217>
2022-02-04 19:09:23 +00:00
Emma Anholt 3d5ee08c15 freedreno/isaspec: Add missing dep of encode.py/decode.py calls on isa.py
Fixes: #5921
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14725>
2022-02-02 11:21:56 -08:00
Lionel Landwerlin cebf284ac1 intel/compiler: add a new pass to lower shading rate into HW format
Rework:
 * Jason: Modernize brw_nir_lower_shading_rate_output:
   1. Use nir_shader_instructions_pass()
   2. Use *_imm builder helpers.
   3. Use nir_intrinsic_base() instead of ->const_index[0]

v2: Also lower loads (Caio)

v3: Update stage check to trigger lowering (Caio)

v4: Assert on != MESH (Caio)

v5: Fixup instruction insertion (Caio)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13739>
2022-02-02 17:09:46 +00:00
Lionel Landwerlin e227bb9fd5 nir/builder: add ishl_imm helper
v2: add (y >= x->bit_size) condition (Caio)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13739>
2022-02-02 17:09:46 +00:00
Lionel Landwerlin 7d8884800e compiler: add VARYING bit for primitive shading rate
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13739>
2022-02-02 17:09:46 +00:00
Caio Oliveira 8bab8f6422 compiler, intel: Add gl_shader_stage_is_mesh()
And replace the previous Intel-specific function.

Reviewed-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14823>
2022-02-01 17:41:25 +00:00
Connor Abbott 503a5bae59 nir: Add support for lowering shuffle to a waterfall loop
Qualcomm doesn't natively support shuffle, but it does natively support
relative shuffles where the delta is a constant. Therefore we'll expose
emulated support for both. Add support for this emulation of
subgroupShuffle() to NIR.

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14412>
2022-02-01 16:27:45 +00:00
Connor Abbott 913bec10c4 nir/lower_subgroups: Rename lower_shuffle to lower_relative_shuffle
This option only applies to relative shuffles (up/down/xor), and in a
moment we're going to add an option to lower normal shuffles, so rename
it.

While we're here, rename lower_shuffle() to lower_to_shuffle() for
similar reasons.

Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14412>
2022-02-01 16:27:45 +00:00
Qiang Yu 95d3617909 glsl/nir: convert ir_texture->clamp to nir
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14488>
2022-02-01 10:28:05 +00:00
Qiang Yu 10a71c6106 glsl: add ARB_sparse_texture_clamp builtin functions
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14488>
2022-02-01 10:28:05 +00:00
Qiang Yu 391f2dffaa glsl: _textureCubeArrayShadow support clamp
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14488>
2022-02-01 10:28:05 +00:00
Qiang Yu de37146c71 glsl: _texture support clamp parameter
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14488>
2022-02-01 10:28:05 +00:00
Qiang Yu 92d6b2735b glsl: ir_texture add clamp field
For ARB_sparse_texture_clamp to hold the lodClamp parameter.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14488>
2022-02-01 10:28:05 +00:00
Qiang Yu 13ffd46a0f glsl: add ARB_sparse_texture_clamp extension
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14488>
2022-02-01 10:28:05 +00:00
Timothy Arceri bfa096a0b9 glsl/st: move st_nir_opts() into gl compiler common code
This will allow us to use this in future NIR linker work. It also makes
more sense to move it here as the classic drivers are gone, tgsi is
going away and we are merging more of the st into the gl common code.

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14785>
2022-01-31 11:49:21 +00:00
Marcin Ślusarz 24fef8f33d intel/compiler: Use Task/Mesh InlineData for the first few push constants
Replace load_mesh_global_arg_addr_intel with a more general intrinsic
load_mesh_inline_data_intel, since inline data now hold both
a pointer descriptor information and the first few push constants.

Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14788>
2022-01-29 06:32:19 +00:00
Christian Gmeiner e5f9cdac1f nir/nir_lower_tex_shadow: support tex_instr without deref src
Use texture_index if there is no deref src.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14308>
2022-01-28 18:40:53 +00:00