platform/upstream/mesa.git
2 years agozink: ci updates
Mike Blumenkrantz [Tue, 15 Feb 2022 02:11:24 +0000 (21:11 -0500)]
zink: ci updates

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15020>

2 years agozink: always invalidate streamout counter buffer if not resuming
Mike Blumenkrantz [Thu, 10 Feb 2022 19:30:25 +0000 (14:30 -0500)]
zink: always invalidate streamout counter buffer if not resuming

this otherwise treates begin/end/begin the same as begin/pause/resume

cc: mesa-stable

fixes:
KHR-GL46.texture_view.view_classes
KHR-GL46.transform_feedback.capture_geometry_separate_test
KHR-GL46.transform_feedback.capture_vertex_separate_test
KHR-GL46.transform_feedback.query_geometry_separate_test
KHR-GL46.transform_feedback.query_vertex_separate_test

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15020>

2 years agozink: export PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR
Mike Blumenkrantz [Fri, 11 Feb 2022 01:35:26 +0000 (20:35 -0500)]
zink: export PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15020>

2 years agozink: map R8G8B8X8_SRGB -> R8G8B8A8_SRGB
Mike Blumenkrantz [Thu, 10 Feb 2022 20:48:34 +0000 (15:48 -0500)]
zink: map R8G8B8X8_SRGB -> R8G8B8A8_SRGB

this fixes a weird texstore bug that seems specific to this format

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15020>

2 years agozink: ci updates
Mike Blumenkrantz [Tue, 15 Feb 2022 01:57:51 +0000 (20:57 -0500)]
zink: ci updates

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15018>

2 years agozink: activate conditional render for compute dispatch when necessary
Mike Blumenkrantz [Thu, 3 Feb 2022 22:18:58 +0000 (17:18 -0500)]
zink: activate conditional render for compute dispatch when necessary

fixes:
KHR-GL46.compute_shader.conditional-dispatching

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15018>

2 years agozink: restart conditional render when crossing batch boundary
Mike Blumenkrantz [Thu, 3 Feb 2022 22:18:12 +0000 (17:18 -0500)]
zink: restart conditional render when crossing batch boundary

this will only happen when conditional render was being used outside
of a renderpass

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15018>

2 years agozink: always terminate conditional render when flushing a batch
Mike Blumenkrantz [Thu, 3 Feb 2022 22:15:56 +0000 (17:15 -0500)]
zink: always terminate conditional render when flushing a batch

we might not know whether conditional render is active,
so forcibly disable when necessary

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15018>

2 years agozink: track internal conditional render state
Mike Blumenkrantz [Thu, 3 Feb 2022 22:15:38 +0000 (17:15 -0500)]
zink: track internal conditional render state

this allows no-oping redundant calls

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15018>

2 years agointel/compiler: remove what looks like a bad rebase
Iván Briano [Mon, 14 Feb 2022 23:57:26 +0000 (15:57 -0800)]
intel/compiler: remove what looks like a bad rebase

This bit in the compiler looks like it was added by accident on one of
the latest versions of the original commit, but it clearly doesn't
belong there.

Fixes: 03e1e19246d ("anv: Refactor descriptor copy")

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15016>

2 years agogallivm/st/lvp: add flags arg to get_query_result_resource api.
Dave Airlie [Sat, 12 Feb 2022 00:48:51 +0000 (10:48 +1000)]
gallivm/st/lvp: add flags arg to get_query_result_resource api.

Currently this just has wait, but in order to get the right answer
for vulkan partial, lavapipe/llvmpipe need to pass a partial flag
through here in the future.

This just changes the API so that's possible.

v2: use an enum (zmike)

Acked-by: Ilia Mirkin <imirkin@alum.mit.edu>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15009>

2 years agonir_to_tgsi: Add support for FBFETCH.
Emma Anholt [Wed, 5 Jan 2022 19:40:32 +0000 (11:40 -0800)]
nir_to_tgsi: Add support for FBFETCH.

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15014>

2 years agonir_to_tgsi: Don't vectorize 64-bit instructions, to keep virgl happy.
Emma Anholt [Fri, 8 Oct 2021 18:51:48 +0000 (11:51 -0700)]
nir_to_tgsi: Don't vectorize 64-bit instructions, to keep virgl happy.

virglrenderer makes invalid shaders when faced with vector 64-bit
instructions, which GLSL-to-TGSI never produced.  While this doesn't fix
everything, it does get more tests running, and virgl probably the primary
consumer of 64-bit TGSI.  virgl may be deprecating its host 64-bit
support, at which point we can drop this workaround.

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15014>

2 years agovirgl: Move double operands to a temp to avoid double-swizzling bugs.
Emma Anholt [Mon, 10 Jan 2022 19:34:01 +0000 (11:34 -0800)]
virgl: Move double operands to a temp to avoid double-swizzling bugs.

virglrenderer applies the swizzle when packing doubles.  Since we use scan
now, we can just use the file count for texture detection.

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15014>

2 years agovirgl: Move tex immediate operands to a temp to avoid virglrenderer bug.
Emma Anholt [Fri, 8 Oct 2021 18:00:26 +0000 (11:00 -0700)]
virgl: Move tex immediate operands to a temp to avoid virglrenderer bug.

Prior to the noted MR, virglrenderer encoded the tex operands in a
limited-size temp buffer which we could easily overflow with TGSI
immediates.  GLSL-to-TGSI always emitted an extra MOV, so keep that
behavior when nir-to-tgsi feeds us more optimized TGSI.

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15014>

2 years agovirgl: Add workarounds for virglrenderer input/sv signedness bugs.
Emma Anholt [Thu, 16 Sep 2021 00:00:11 +0000 (17:00 -0700)]
virgl: Add workarounds for virglrenderer input/sv signedness bugs.

GLSL-to-TGSI would emit some MOVs that made things OK, but NTT
successfully copy-propagates the inputs and sysvals more, triggering bugs
in virglrenderer when the signedness of the input is different from that
of the ALU op.

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15014>

2 years agovirgl: Apply TGSI transforms to compute shaders, too.
Emma Anholt [Wed, 5 Jan 2022 18:59:16 +0000 (10:59 -0800)]
virgl: Apply TGSI transforms to compute shaders, too.

We need to do this for the upcoming virglrenderer workarounds.

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15014>

2 years agovirgl: Add a workaround for virglrenderer output writemask bugs.
Emma Anholt [Wed, 15 Sep 2021 23:03:36 +0000 (16:03 -0700)]
virgl: Add a workaround for virglrenderer output writemask bugs.

Various workaround paths in virglrenderer assume that outputs are written
with a full writemask, which is not required by TGSI.  To work around
that, store affected outputs in a temp and do a full write after each
writemasked write.

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15014>

2 years agovirgl: Work around old virglrenderer's BARRIER counting bug.
Emma Anholt [Fri, 8 Oct 2021 17:10:43 +0000 (10:10 -0700)]
virgl: Work around old virglrenderer's BARRIER counting bug.

One less regression from doing nir-to-tgsi on CI's virglrenderer.

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15014>

2 years agotgsi_translate: Make the procType public when translating.
Emma Anholt [Tue, 26 Oct 2021 20:13:34 +0000 (13:13 -0700)]
tgsi_translate: Make the procType public when translating.

This means that tgsi_translate users can check the PIPE_SHADER stage
without having to separately tgsi_scan().

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15014>

2 years agovenus: Exposes VK_EXT_4444_formats extension
Igor Torrente [Thu, 27 Jan 2022 09:33:55 +0000 (06:33 -0300)]
venus: Exposes VK_EXT_4444_formats extension

Allows venus to passthrough the VK_EXT_4444_formats extension to
the vulkan client.

And add code to the device initialization and feature query
functions.

Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Signed-off-by: Igor Torrente <igor.torrente@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14954>

2 years agoturnip: advertise VK_EXT_queue_family_foreign
Yiwei Zhang [Wed, 2 Feb 2022 20:10:50 +0000 (20:10 +0000)]
turnip: advertise VK_EXT_queue_family_foreign

Both Venus and Android AHB requires this extension.

Turnip ignores VK_SHARING_MODE_EXCLUSIVE so this is a no-op.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Acked-by: Rob Clark <robdclark@chromium.org>
Acked-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14836>

2 years agoir3: Limit the maximum imm offset in nir_opt_offset for shared vars
Danylo Piliaiev [Thu, 10 Feb 2022 12:07:12 +0000 (14:07 +0200)]
ir3: Limit the maximum imm offset in nir_opt_offset for shared vars

STL/LDL have 13 bits to store imm offset.

Fixes crash in CS compilation in Monster Hunter World.

Fixes: b024102d7c2959451bfef323432beaa4dca4dd88
("freedreno/ir3: Use nir_opt_offset for removing constant adds for shared vars.")

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14968>

2 years agointel/compiler: fix array & struct IO lowering in mesh shaders
Marcin Ślusarz [Fri, 11 Feb 2022 16:28:35 +0000 (17:28 +0100)]
intel/compiler: fix array & struct IO lowering in mesh shaders

We really need offsets to be in dwords, not in vec4s.

The bug manifests as random failure of func.mesh.clipdistance.5 crucible
test, where stores to gl_MeshVerticesNV[x].gl_ClipDistance[4+n] actually write to
gl_MeshVerticesNV[x].gl_ClipDistance[1+n].

Fixes: 1f438eb0337 ("intel/compiler: Implement Mesh Output")
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14997>

2 years agospirv: Create PRIMITIVE_INDICES for NV_mesh_shader on-demand.
Timur Kristóf [Thu, 10 Feb 2022 22:52:04 +0000 (23:52 +0100)]
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>

2 years agocompiler: Extract num_mesh_vertices_per_primitive function.
Timur Kristóf [Mon, 14 Feb 2022 09:44:28 +0000 (10:44 +0100)]
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>

2 years agoradv: remove set but unused radv_buffer::shareable
Samuel Pitoiset [Wed, 29 Dec 2021 09:24:49 +0000 (10:24 +0100)]
radv: remove set but unused radv_buffer::shareable

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14937>

2 years agoradv: remove useless NULL checks in vkBind{Buffer,Image}Memory2()
Samuel Pitoiset [Wed, 29 Dec 2021 09:10:01 +0000 (10:10 +0100)]
radv: remove useless NULL checks in vkBind{Buffer,Image}Memory2()

The memory object must be a valid vkDeviceMemory handle.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14937>

2 years agoradv: fix finding shaders by PC
Samuel Pitoiset [Wed, 9 Feb 2022 13:29:11 +0000 (14:29 +0100)]
radv: fix finding shaders by PC

Shaders are allocated contiguously in memory for a pipeline and
the freelist.next pointer is a pointer to the pipeline now.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14950>

2 years agoradv: make the trap handler shader BO resident
Samuel Pitoiset [Wed, 9 Feb 2022 13:49:33 +0000 (14:49 +0100)]
radv: make the trap handler shader BO resident

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14950>

2 years agoradv: fix allocating/uploading the trap handler shader
Samuel Pitoiset [Wed, 9 Feb 2022 13:48:07 +0000 (14:48 +0100)]
radv: fix allocating/uploading the trap handler shader

Since shaders are allocated per pipeline, the trap handler shader
was not uploaded at all.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14950>

2 years agodocs/features: Mark VK_KHR_ray_query in progress
Shmerl [Fri, 11 Feb 2022 19:18:32 +0000 (14:18 -0500)]
docs/features: Mark VK_KHR_ray_query in progress

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15000>

2 years agofreedreno/ir3: split up load/store/atomic by generation
Ilia Mirkin [Sun, 14 Nov 2021 18:06:18 +0000 (13:06 -0500)]
freedreno/ir3: split up load/store/atomic by generation

Some bits are slightly different on a4xx. Use the encodings that work.
Perhaps these can be combined at some point if we get a proper
understanding of what they mean.

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>

2 years agoisaspec: add gen-based leaf bitset separation
Ilia Mirkin [Sat, 29 Jan 2022 06:40:16 +0000 (01:40 -0500)]
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>

2 years agoisaspec: fix gen_max to be 2^32-1
Ilia Mirkin [Tue, 25 Jan 2022 06:01:17 +0000 (01:01 -0500)]
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>

2 years agopanfrost: Flesh out the Shader Program Descriptor
Alyssa Rosenzweig [Thu, 3 Feb 2022 00:10:47 +0000 (19:10 -0500)]
panfrost: Flesh out the Shader Program Descriptor

Only breaking change since Bifrost is that the shader contains barrier? flag is
now fragment-only, meaning it is just a spawn helper threads flag. This affects
compute shaders slightly.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15003>

2 years agopanfrost: Simplify Valhall preload descriptor
Alyssa Rosenzweig [Thu, 3 Feb 2022 00:02:27 +0000 (19:02 -0500)]
panfrost: Simplify Valhall preload descriptor

Honestly, we could stand to do the same to Bifrost...

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15003>

2 years agopanfrost: Clarify unknowns in z/stencil descriptor
Alyssa Rosenzweig [Wed, 2 Feb 2022 23:56:33 +0000 (18:56 -0500)]
panfrost: Clarify unknowns in z/stencil descriptor

Depth culling and clamping.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15003>

2 years agopanfrost: Add more fields to Attribute Descriptor
Alyssa Rosenzweig [Wed, 2 Feb 2022 23:41:46 +0000 (18:41 -0500)]
panfrost: Add more fields to Attribute Descriptor

More XML

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15003>

2 years agopanfrost: Update primitive descriptor for Valhall
Alyssa Rosenzweig [Wed, 2 Feb 2022 22:48:24 +0000 (17:48 -0500)]
panfrost: Update primitive descriptor for Valhall

Contains stuff needed for layered rendering. Unfortunately, there's no more
provoking vertex per draw -- ugh! That's fine for Vulkan (just don't set
provokingVertexModePerPipeline), but requires inserting extra flushes on desktop
OpenGL.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15003>

2 years agoradv: Only wait on CS/PS to finish if we wait on a semaphore.
Bas Nieuwenhuizen [Sat, 5 Feb 2022 21:40:07 +0000 (22:40 +0100)]
radv: Only wait on CS/PS to finish if we wait on a semaphore.

I think plain submission doesn't need it.

Reviewed-By: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14574>

2 years agoradv: Fix preamble argument order.
Bas Nieuwenhuizen [Sat, 15 Jan 2022 13:43:15 +0000 (14:43 +0100)]
radv: Fix preamble argument order.

Used the wrong cmdbuffer in the wrong situation. Oops.

Fixes: 915e9178faf ("radv: Split out commandbuffer submission.")
Reviewed-By: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14574>

2 years agoradv: Use larger arena sizes.
Bas Nieuwenhuizen [Tue, 18 Jan 2022 10:42:28 +0000 (11:42 +0100)]
radv: Use larger arena sizes.

For some games that take like 400 MiB of shader binaries, the
number of shader arenas ends up going >1500. Cut that down a bit
by using larger arenas.

8 MiB should still be decent with small BAR and should still cut
things down from ~1500 to ~50 buffers.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14591>

2 years agolima/ppir: refactor bitcopy to use unsigned char
Erico Nunes [Sat, 5 Feb 2022 10:14:36 +0000 (11:14 +0100)]
lima/ppir: refactor bitcopy to use unsigned char

This code does not work as expected when built with clang and
-fstrict-aliasing.
Redefine it in unsigned char operations so that it does not
violate strict aliasing rules.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Cc: 22.0 <mesa-stable>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14894>

2 years agolima/ppir: initialize slots array for dummy/undef
Erico Nunes [Wed, 2 Feb 2022 11:30:56 +0000 (12:30 +0100)]
lima/ppir: initialize slots array for dummy/undef

Some functions in ppir iterate the ppir_op_info slots arrays looking
for the PPIR_INSTR_SLOT_END token. The dummy/undef internal ops may
appear in the scheduling code and their slots arrays did not contain
that token, which could result in invalid array reads.
Reported by gcc -fsanitize=address.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Cc: 22.0 <mesa-stable>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14894>

2 years agolima/gpir: avoid invalid write in regalloc
Erico Nunes [Wed, 2 Feb 2022 11:27:08 +0000 (12:27 +0100)]
lima/gpir: avoid invalid write in regalloc

Reported by gcc -fsanitize=address, sometimes gpir regalloc attempts to
handle an uninitialized node->value_reg (containing the value -1), which
results in an invalid array access.
Avoid it for now to prevent crashes, but more investigation may be
required later on.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Cc: 22.0 <mesa-stable>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14894>

2 years agolima: remove an unneeded lima_job_get assignment
Erico Nunes [Fri, 4 Feb 2022 19:38:11 +0000 (20:38 +0100)]
lima: remove an unneeded lima_job_get assignment

Reported by scan-build.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14894>

2 years agolima: add some checks for potential null pointer dereference
Erico Nunes [Fri, 4 Feb 2022 19:22:17 +0000 (20:22 +0100)]
lima: add some checks for potential null pointer dereference

scan-build complains about a potential null pointer dereference in
some places around the lima code.
None of those seem to be a real issue as of now, but let's add some
asserts to cover for that and clean up the warning list.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14894>

2 years agolima: fix warning of garbage value access
Erico Nunes [Fri, 4 Feb 2022 19:17:26 +0000 (20:17 +0100)]
lima: fix warning of garbage value access

scan-build complains that an access of reg[j+1] in this code might
return garbage.
Let's take the chance to clean this open coded sorting code up and
just use qsort.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14894>

2 years agolima/ppir: initialize spill_costs array in regalloc
Erico Nunes [Fri, 4 Feb 2022 19:36:20 +0000 (20:36 +0100)]
lima/ppir: initialize spill_costs array in regalloc

Static analysis complains that spill_costs might be accessed in
non-initialized positions.
It does not seem to be an issue with the current code which initializes
it for every relevant register index, but we can also just initialize it
to not have to worry about that.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14894>

2 years agolima/ppir: avoid ppir_codegen_outmod implicit conversion
Erico Nunes [Sat, 5 Feb 2022 18:37:49 +0000 (19:37 +0100)]
lima/ppir: avoid ppir_codegen_outmod implicit conversion

Fix some clang -Wenum-conversion warnings like:

  warning: implicit conversion from enumeration type 'ppir_outmod' to
  different enumeration type 'ppir_codegen_outmod' [-Wenum-conversion]

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14894>

2 years agolima/ppir: clean up override-init warnings
Erico Nunes [Sun, 30 Jan 2022 09:50:42 +0000 (10:50 +0100)]
lima/ppir: clean up override-init warnings

Define ppir_op_unsupported as 0 so that we don't have to do the
initialization to -1.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14894>

2 years agolima/gpir: clean up override-init warnings
Erico Nunes [Sun, 30 Jan 2022 08:48:00 +0000 (09:48 +0100)]
lima/gpir: clean up override-init warnings

Define gpir_op_unsupported as 0 so that we don't have to do the
initialization to -1.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14894>

2 years agovenus: use 64KB alignment for suballocations
Chia-I Wu [Fri, 11 Feb 2022 20:53:44 +0000 (12:53 -0800)]
venus: use 64KB alignment for suballocations

TGL CCS surface addresses must be aligned to 64KB.

Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15001>

2 years agovenus: no roundtrip needed for shmem backed by BLOB_MEM_HOST3D
Yiwei Zhang [Sat, 29 Jan 2022 06:09:36 +0000 (06:09 +0000)]
venus: no roundtrip needed for shmem backed by BLOB_MEM_HOST3D

A successful DRM_IOCTL_VIRTGPU_MAP on BLOB_MEM_HOST3D implies a
roundtrip.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14658>

2 years agovenus: init renderer_info at renderer creation (part 2)
Yiwei Zhang [Sat, 29 Jan 2022 00:09:14 +0000 (00:09 +0000)]
venus: init renderer_info at renderer creation (part 2)

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14658>

2 years agovenus: init renderer_info at renderer creation (part 1)
Yiwei Zhang [Sat, 29 Jan 2022 00:03:41 +0000 (00:03 +0000)]
venus: init renderer_info at renderer creation (part 1)

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14658>

2 years agoaco/insert_exec_mask: refactor and remove some unnecessary WQM handling code
Daniel Schürmann [Mon, 7 Feb 2022 17:56:11 +0000 (18:56 +0100)]
aco/insert_exec_mask: refactor and remove some unnecessary WQM handling code

Some cases cannot happen and don't need to be handled anymore.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14951>

2 years agoaco/insert_exec_mask: refactor and simplify get_block_needs()
Daniel Schürmann [Thu, 27 Jan 2022 12:25:55 +0000 (13:25 +0100)]
aco/insert_exec_mask: refactor and simplify get_block_needs()

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14951>

2 years agoaco/insert_exec_mask: remove ever_again_needs and Exact_Branch
Daniel Schürmann [Wed, 26 Jan 2022 15:45:04 +0000 (16:45 +0100)]
aco/insert_exec_mask: remove ever_again_needs and Exact_Branch

This information is not required anymore.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14951>

2 years agoaco/insert_exec_mask: remove some unnecessary WQM loop handling code
Daniel Schürmann [Wed, 26 Jan 2022 10:08:42 +0000 (11:08 +0100)]
aco/insert_exec_mask: remove some unnecessary WQM loop handling code

These workarounds are were necessary to prevent infinite loops
with helper lane registers containing wrong data.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14951>

2 years agoaco/insert_exec_mask: remove Preserve_WQM flag
Daniel Schürmann [Wed, 26 Jan 2022 16:11:36 +0000 (17:11 +0100)]
aco/insert_exec_mask: remove Preserve_WQM flag

If WQM is needed anywhere after discard_if(), it will also
be flagged as WQM. We can rely on that to preserve the WQM mask.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14951>

2 years agoaco: don't emit WQM for bool_to_scalar_condition
Daniel Schürmann [Sun, 6 Feb 2022 12:37:37 +0000 (13:37 +0100)]
aco: don't emit WQM for bool_to_scalar_condition

This was only necessary to ensure that the source is computed in WQM
if the current exec mask is in WQM.

Totals from 23170 (17.17% of 134913) affected shaders: (GFX10.3)
VGPRs: 1384464 -> 1383400 (-0.08%); split: -0.08%, +0.01%
SpillSGPRs: 7575 -> 7574 (-0.01%)
CodeSize: 146444752 -> 146317104 (-0.09%); split: -0.13%, +0.04%
MaxWaves: 429870 -> 429868 (-0.00%)
Instrs: 27202586 -> 27170316 (-0.12%); split: -0.17%, +0.05%
Latency: 379488313 -> 379335412 (-0.04%); split: -0.07%, +0.03%
InvThroughput: 69500561 -> 69487704 (-0.02%); split: -0.03%, +0.01%
VClause: 473080 -> 473038 (-0.01%); split: -0.02%, +0.01%
SClause: 1080576 -> 1080571 (-0.00%); split: -0.06%, +0.06%
Copies: 1492865 -> 1504604 (+0.79%); split: -0.40%, +1.19%
Branches: 711295 -> 716849 (+0.78%); split: -0.01%, +0.79%
PreSGPRs: 1331362 -> 1328402 (-0.22%)

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14951>

2 years agoaco: don't propagate WQM for p_as_uniform
Daniel Schürmann [Tue, 25 Jan 2022 12:12:40 +0000 (13:12 +0100)]
aco: don't propagate WQM for p_as_uniform

This was needed, so that in case of active helper lanes,
these contain the correct value. It is now handled implicitly.

Totals from 1004 (0.74% of 134913) affected shaders: (GFX10.3)
CodeSize: 7581020 -> 7580892 (-0.00%); split: -0.00%, +0.00%
Instrs: 1454940 -> 1454908 (-0.00%); split: -0.00%, +0.00%
Latency: 12984953 -> 12984894 (-0.00%); split: -0.00%, +0.00%
InvThroughput: 3173037 -> 3173049 (+0.00%); split: -0.00%, +0.00%
PreSGPRs: 47498 -> 47273 (-0.47%)

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14951>

2 years agoaco/insert_exec_mask: stay in WQM while helper lanes are still needed
Daniel Schürmann [Mon, 24 Jan 2022 18:43:49 +0000 (19:43 +0100)]
aco/insert_exec_mask: stay in WQM while helper lanes are still needed

This patch flags all instructions WQM which don't require
Exact mode, but depend on the exec mask as long as WQM
is needed on any control flow path afterwards.
This will mostly prevent accidental copies of WQM values
within Exact mode, and also makes a lot of other workarounds
unnecessary.

Totals from 17374 (12.88% of 134913) affected shaders: (GFX10.3)
VGPRs: 526952 -> 527384 (+0.08%); split: -0.01%, +0.09%
CodeSize: 33740512 -> 33766636 (+0.08%); split: -0.06%, +0.14%
MaxWaves: 488166 -> 488108 (-0.01%); split: +0.00%, -0.02%
Instrs: 6254240 -> 6260557 (+0.10%); split: -0.08%, +0.18%
Latency: 66497580 -> 66463472 (-0.05%); split: -0.15%, +0.10%
InvThroughput: 13265741 -> 13264036 (-0.01%); split: -0.03%, +0.01%
VClause: 122962 -> 122975 (+0.01%); split: -0.01%, +0.02%
SClause: 334805 -> 334405 (-0.12%); split: -0.51%, +0.39%
Copies: 275728 -> 282341 (+2.40%); split: -0.91%, +3.31%
Branches: 92546 -> 90990 (-1.68%); split: -1.68%, +0.00%
PreSGPRs: 504119 -> 504352 (+0.05%); split: -0.00%, +0.05%

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14951>

2 years agoRe-indentation after the previous commit
Ian Romanick [Sat, 15 Jan 2022 03:12:24 +0000 (19:12 -0800)]
Re-indentation after the previous commit

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>

2 years agoglsl: Eliminate ir_assignment::condition
Ian Romanick [Sat, 15 Jan 2022 03:10:04 +0000 (19:10 -0800)]
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>

2 years agoglsl: Make ir_assignment::condition private
Ian Romanick [Sat, 15 Jan 2022 02:56:41 +0000 (18:56 -0800)]
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>

2 years agoglsl: Don't visit rvalues in the condition of an assignment
Ian Romanick [Sat, 15 Jan 2022 02:55:28 +0000 (18:55 -0800)]
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>

2 years agoglsl: Don't lower vector indexing in the condition of an assignment
Ian Romanick [Sat, 15 Jan 2022 02:53:59 +0000 (18:53 -0800)]
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>

2 years agoglsl: Don't split structures in the condition of an assignment
Ian Romanick [Sat, 15 Jan 2022 02:51:19 +0000 (18:51 -0800)]
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>

2 years agoglsl: Don't split arrays in the condition of an assignment
Ian Romanick [Sat, 15 Jan 2022 02:39:15 +0000 (18:39 -0800)]
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>

2 years agoglsl: Don't tree graft in the condition of an assignment
Ian Romanick [Sat, 15 Jan 2022 02:36:50 +0000 (18:36 -0800)]
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>

2 years agoglsl: Don't dead-built-in varying eliminate in the condition of an assignment
Ian Romanick [Sat, 15 Jan 2022 02:35:11 +0000 (18:35 -0800)]
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>

2 years agoglsl: Remove unused condition parameter from ir_assignment constructor
Ian Romanick [Sat, 15 Jan 2022 02:20:41 +0000 (18:20 -0800)]
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>

2 years agoglsl: Don't constant-fold the condition of an assignment
Ian Romanick [Sat, 15 Jan 2022 02:17:42 +0000 (18:17 -0800)]
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>

2 years agoglsl: Don't clone assignment conditions
Ian Romanick [Sat, 15 Jan 2022 02:11:14 +0000 (18:11 -0800)]
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>

2 years agoglsl: Eliminate unused conditional assignment constructor
Ian Romanick [Sat, 15 Jan 2022 01:57:53 +0000 (17:57 -0800)]
glsl: Eliminate unused conditional assignment constructor

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>

2 years agoglsl: Remove the ability to read text IR with conditional assignments
Ian Romanick [Sat, 15 Jan 2022 01:55:21 +0000 (17:55 -0800)]
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>

2 years agoglsl: Add ir_assignment constructor that takes just a write mask
Ian Romanick [Sat, 15 Jan 2022 01:38:05 +0000 (17:38 -0800)]
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>

2 years agoglsl: Lower if to conditional select instead of conditional assignment
Ian Romanick [Sat, 15 Jan 2022 02:48:50 +0000 (18:48 -0800)]
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>

2 years agoglsl/ir_builder: Eliminate unused conditional assignment builders
Ian Romanick [Sat, 15 Jan 2022 01:20:00 +0000 (17:20 -0800)]
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>

2 years agoglsl: Don't try to emit the "linear sequence" in lower_variable_index_to_cond_assign
Ian Romanick [Sat, 15 Jan 2022 01:12:35 +0000 (17:12 -0800)]
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>

2 years agoglsl: Use csel in do_vec_index_to_cond_assign
Ian Romanick [Fri, 14 Jan 2022 23:37:50 +0000 (15:37 -0800)]
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>

2 years agoglsl/lower_vector_derefs: Don't emit conditional assignments
Ian Romanick [Fri, 14 Jan 2022 23:07:53 +0000 (15:07 -0800)]
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>

2 years agor300: transform fs sin and cos input to [0,1) range in NIR
Pavel Ondračka [Wed, 9 Feb 2022 15:11:29 +0000 (16:11 +0100)]
r300: transform fs sin and cos input to [0,1) range in NIR

shader-db stats with RV530 (together with the vs commit):
total instructions in shared programs: 65194 -> 64721 (-0.73%)
instructions in affected programs: 6718 -> 6245 (-7.04%)
total consts in shared programs: 45363 -> 45353 (-0.02%)
consts in affected programs: 466 -> 456 (-2.15%)

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5982
Reviewed-by: Emma Anholt <emma@anholt.net>
Signed-off-by: Pavel Ondračka <pavel.ondracka@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14957>

2 years agor300: transform vs sin and cos input to [-PI,PI] range in NIR
Pavel Ondračka [Wed, 9 Feb 2022 14:48:04 +0000 (15:48 +0100)]
r300: transform vs sin and cos input to [-PI,PI] range in NIR

The python generator is mostly copy-pasted from lima.

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Signed-off-by: Pavel Ondračka <pavel.ondracka@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14957>

2 years agor300: use nir lowering for sin and cos on R300 and R400
Pavel Ondračka [Wed, 9 Feb 2022 09:36:08 +0000 (10:36 +0100)]
r300: use nir lowering for sin and cos on R300 and R400

The nir approximation is a bit more precise so there is one more
instruction for the scalar version but if the shader actually uses
vector one or some other stuff like sin(x) followed by cos(x) we
save more.

This nir approximation importantly seems to have better precision
so this should also fix some piglits/dEQPs.

With my shader-db and faked R300:
total instructions in shared programs: 67751 -> 65978 (-2.62%)
instructions in affected programs: 8637 -> 6864 (-20.53%)
total temps in shared programs: 9191 -> 9137 (-0.59%)
temps in affected programs: 486 -> 432 (-11.11%)
total consts in shared programs: 45427 -> 45412 (-0.03%)
consts in affected programs: 856 -> 841 (-1.75%)
total lits in shared programs: 2317 -> 2346 (1.25%)
lits in affected programs: 69 -> 98 (42.03%)

Reviewed-by: Emma Anholt <emma@anholt.net>
Signed-off-by: Pavel Ondračka <pavel.ondracka@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14957>

2 years agoradv/winsys: fix initializing debug/perftest options if multiple instances
Samuel Pitoiset [Fri, 11 Feb 2022 10:17:49 +0000 (11:17 +0100)]
radv/winsys: fix initializing debug/perftest options if multiple instances

Since the winsys uses refcount, options like RADV_DEBUG_ZERO_VRAM might
have not been initialized if the first instance wasn't created with
application info.

This fixes missing zerovram for vkd3d-proton.

Cc: 21.3 22.0 mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14978>

2 years agoanv: Handle VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE for descriptor sets
Rohan Garg [Mon, 24 Jan 2022 14:54:35 +0000 (15:54 +0100)]
anv: Handle VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE for descriptor sets

Ensure that surface state does not get created for
VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE and we don't bind to the
binding table for descriptor sets created with this pool.

Signed-off-by: Rohan Garg <rohan.garg@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14683>

2 years agoradv: move nir_opt_shrink_stores from radv_optimize_nir()
Daniel Schürmann [Mon, 10 Jan 2022 16:16:16 +0000 (16:16 +0000)]
radv: move nir_opt_shrink_stores from radv_optimize_nir()

No need to call this pass in a loop.

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14480>

2 years agonir/opt_shrink_vectors: Remove shrinking of store intrinsics data source
Daniel Schürmann [Mon, 10 Jan 2022 12:56:32 +0000 (12:56 +0000)]
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>

2 years agonir: split nir_opt_shrink_stores from nir_opt_shrink_vectors
Daniel Schürmann [Mon, 10 Jan 2022 13:34:20 +0000 (13:34 +0000)]
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>

2 years agoRevert "nir: make tgsi_varying_semantic_to_slot(..) public"
Christian Gmeiner [Thu, 16 Sep 2021 05:32:28 +0000 (07:32 +0200)]
Revert "nir: make tgsi_varying_semantic_to_slot(..) public"

This reverts commit edbdd977232f0cfe8f26a44ddbda792780168f4a.

As etnaviv's TGSI compiler is gone we make that function
private again.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12889>

2 years agoetnaviv: drop TGSI based backend compiler
Christian Gmeiner [Thu, 16 Sep 2021 05:08:18 +0000 (07:08 +0200)]
etnaviv: drop TGSI based backend compiler

I think it is time to switch to NIR per default and forget
about the past. There might be stuff that will explode in
different ways now but thats all fixable.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12889>

2 years agov3dv: Use the common command pool implementation
Jason Ekstrand [Mon, 7 Feb 2022 22:02:20 +0000 (16:02 -0600)]
v3dv: Use the common command pool implementation

The only interesting information stored in v3dv_cmd_pool is the list of
command buffers and that's already tracked by vk_command_pool.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14917>

2 years agov3dv: Don't use vk_alloc/free2 for command buffers
Jason Ekstrand [Mon, 7 Feb 2022 21:51:22 +0000 (15:51 -0600)]
v3dv: Don't use vk_alloc/free2 for command buffers

The pool will always have a valid allocator.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14917>

2 years agoanv: Use the common vk_command_pool
Jason Ekstrand [Mon, 7 Feb 2022 21:24:34 +0000 (15:24 -0600)]
anv: Use the common vk_command_pool

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14917>

2 years agoanv: Don't call DestroyCommandBuffers in AllocateCommandBuffers
Jason Ekstrand [Mon, 7 Feb 2022 21:19:25 +0000 (15:19 -0600)]
anv: Don't call DestroyCommandBuffers in AllocateCommandBuffers

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14917>

2 years agoanv: Drop anv_cmd_buffer::pool
Jason Ekstrand [Mon, 7 Feb 2022 21:22:54 +0000 (15:22 -0600)]
anv: Drop anv_cmd_buffer::pool

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14917>