platform/upstream/mesa.git
11 months agoci: disable Collabora's LAVA lab for maintance
Sergi Blanch Torne [Tue, 1 Aug 2023 09:22:27 +0000 (11:22 +0200)]
ci: disable Collabora's LAVA lab for maintance

This is to inform you of some planned downtime in the LAVA lab as follows:

* Start: 2023-08-14 08:00 BST (UTC+1)
* End: 2023-08-14 12:00 BST (UTC+1)

Signed-off-by: Sergi Blanch Torne <sergi.blanch.torne@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24424>

11 months agogallium: move vertex stride to CSO
Mike Blumenkrantz [Fri, 30 Jun 2023 21:15:09 +0000 (17:15 -0400)]
gallium: move vertex stride to CSO

this simplifies code in most place and enables some optimizations in
frontends

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24117>

11 months agonouveau: calloc vertex csos
Mike Blumenkrantz [Mon, 10 Jul 2023 18:37:34 +0000 (14:37 -0400)]
nouveau: calloc vertex csos

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24117>

11 months agovirgl: fix some indentation
Mike Blumenkrantz [Wed, 5 Jul 2023 13:43:08 +0000 (09:43 -0400)]
virgl: fix some indentation

no functional changes

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24117>

11 months agovirgl: move virgl_vertex_elements_state to header
Mike Blumenkrantz [Tue, 4 Jul 2023 14:55:37 +0000 (10:55 -0400)]
virgl: move virgl_vertex_elements_state to header

no functional changes

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24117>

11 months agod3d10umd: use cso_context to set vertex buffers and elements
Mike Blumenkrantz [Fri, 30 Jun 2023 21:13:38 +0000 (17:13 -0400)]
d3d10umd: use cso_context to set vertex buffers and elements

should be no functional changes

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24117>

11 months agonir: Drop nir_foreach_dest()
Faith Ekstrand [Sun, 13 Aug 2023 00:24:01 +0000 (19:24 -0500)]
nir: Drop nir_foreach_dest()

This requires an annoying bit of shuffling into nir_inline_helpers.h but
it's not horrible.

Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24658>

11 months agonir/from_ssa: Use nir_foreach_def() instead of nir_foreach_dest()
Faith Ekstrand [Sun, 13 Aug 2023 00:23:23 +0000 (19:23 -0500)]
nir/from_ssa: Use nir_foreach_def() instead of nir_foreach_dest()

Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24658>

11 months agodxil: Use nir_foreach_def() instead of nir_foreach_dest()
Faith Ekstrand [Sun, 13 Aug 2023 00:19:21 +0000 (19:19 -0500)]
dxil: Use nir_foreach_def() instead of nir_foreach_dest()

Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24658>

11 months agost,zink,sfn: Use nir_foreach_def instead of nir_foreach_dest
Faith Ekstrand [Sun, 13 Aug 2023 00:18:51 +0000 (19:18 -0500)]
st,zink,sfn: Use nir_foreach_def instead of nir_foreach_dest

It's basically the same code in all three.

Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24658>

11 months agonir: nir_foreach_ssa_def() -> nir_foreach_def()
Faith Ekstrand [Sun, 13 Aug 2023 00:10:24 +0000 (19:10 -0500)]
nir: nir_foreach_ssa_def() -> nir_foreach_def()

    s/nir_foreach_ssa_def/nir_foreach_def/g

followed by

    ninja -C _build clang-format

and a little hand clean-up in nir.c.

Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24658>

11 months agonir: Drop nir_ssa_dest_init_for_type()
Faith Ekstrand [Sat, 12 Aug 2023 23:59:27 +0000 (18:59 -0500)]
nir: Drop nir_ssa_dest_init_for_type()

Replace it with a new nir_def_init_for_type()

Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24658>

11 months agonir: Drop nir_ssa_dest_init()
Faith Ekstrand [Sat, 12 Aug 2023 23:55:58 +0000 (18:55 -0500)]
nir: Drop nir_ssa_dest_init()

Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24658>

11 months agonir/serialize: [De]serialize nir_def nor nir_dest
Faith Ekstrand [Sat, 12 Aug 2023 23:53:42 +0000 (18:53 -0500)]
nir/serialize: [De]serialize nir_def nor nir_dest

This both gets rid of its use of nir_ssa_dest_init() but also will make
it easier to mechanically remove nir_dest entirely later.

Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24658>

11 months agonir/clone: Clone nir_def nor nir_dest
Faith Ekstrand [Sat, 12 Aug 2023 23:53:12 +0000 (18:53 -0500)]
nir/clone: Clone nir_def nor nir_dest

This both gets rid of its use of nir_ssa_dest_init() but also will make
it easier to mechanically remove nir_dest entirely later.

Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24658>

11 months agonir: Drop more instances of nir_ssa_dest_init()
Faith Ekstrand [Sun, 13 Aug 2023 00:01:17 +0000 (19:01 -0500)]
nir: Drop more instances of nir_ssa_dest_init()

Catching the cases that Coccinelle missed.  Mostly in C++ files using
gtest which causes Coccinelle to just give up and walk away.

Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24658>

11 months agonir: Drop most instances of nir_ssa_dest_init()
Faith Ekstrand [Sat, 12 Aug 2023 23:31:52 +0000 (18:31 -0500)]
nir: Drop most instances of nir_ssa_dest_init()

Generated using the following two semantic patches:

    @@
    expression I, J, NC, BS;
    @@

    -nir_ssa_dest_init(I, &J->dest, NC, BS);
    +nir_def_init(I, &J->dest.ssa, NC, BS);

    @@
    expression I, J, NC, BS;
    @@

    -nir_ssa_dest_init(I, &J->dest.dest, NC, BS);
    +nir_def_init(I, &J->dest.dest.ssa, NC, BS);

Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24658>

11 months agofrontends/va: Ignore requested size when creating VAEncCodedBufferType
David Rosca [Sun, 30 Jul 2023 15:36:06 +0000 (17:36 +0200)]
frontends/va: Ignore requested size when creating VAEncCodedBufferType

The buffer data is not directly accessible to application and it's
internally used to only store VACodedBufferSegment struct.
Ignore the size requested by application and instead allocate
sizeof(VACodedBufferSegment). Use calloc to zero out the struct.

This can save significant amount of memory, for example FFmpeg
will request up to tens of MB for single buffer.

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6462

Reviewed-by: Thong Thai <thong.thai@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24410>

11 months agolavapipe: Use common physical device properties
Konstantin Seurer [Fri, 11 Aug 2023 10:55:05 +0000 (12:55 +0200)]
lavapipe: Use common physical device properties

Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24629>

11 months agoclang-format: Disable formatting by default
Konstantin Seurer [Sat, 12 Aug 2023 08:53:39 +0000 (10:53 +0200)]
clang-format: Disable formatting by default

This should make `git clang-format` usable for patches that modify
clang formatted and manually formatted code.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9492
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24645>

11 months agonvk: Remove reference to genUserClip
M Henning [Sat, 12 Aug 2023 23:34:32 +0000 (19:34 -0400)]
nvk: Remove reference to genUserClip

GL uses this for adding clip distances to shaders that are missing them,
but the vulkan spec guarantees "A shader must write a single clip distance
for each enabled clip half-space"

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24657>

11 months agonvk: Don't use nir_ssa_for_src()
Faith Ekstrand [Sat, 12 Aug 2023 20:42:21 +0000 (15:42 -0500)]
nvk: Don't use nir_ssa_for_src()

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24655>

11 months agonir: Drop "SSA" from NIR language
Alyssa Rosenzweig [Sat, 12 Aug 2023 20:17:15 +0000 (16:17 -0400)]
nir: Drop "SSA" from NIR language

Everything is SSA now.

   sed -e 's/nir_ssa_def/nir_def/g' \
       -e 's/nir_ssa_undef/nir_undef/g' \
       -e 's/nir_ssa_scalar/nir_scalar/g' \
       -e 's/nir_src_rewrite_ssa/nir_src_rewrite/g' \
       -e 's/nir_gather_ssa_types/nir_gather_types/g' \
       -i $(git grep -l nir | grep -v relnotes)

   git mv src/compiler/nir/nir_gather_ssa_types.c \
          src/compiler/nir/nir_gather_types.c

   ninja -C build/ clang-format
   cd src/compiler/nir && find *.c *.h -type f -exec clang-format -i \{} \;

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Acked-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24585>

11 months agonir: clang-format src/compiler/nir/*.[ch]
Faith Ekstrand [Tue, 8 Aug 2023 17:00:35 +0000 (12:00 -0500)]
nir: clang-format src/compiler/nir/*.[ch]

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24382>

11 months agonir: Add a .clang-format file
Faith Ekstrand [Sat, 29 Jul 2023 16:37:48 +0000 (11:37 -0500)]
nir: Add a .clang-format file

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24382>

11 months agonir: Add a do to the do/while in nir_const_value_t_array()
Faith Ekstrand [Wed, 9 Aug 2023 18:03:21 +0000 (13:03 -0500)]
nir: Add a do to the do/while in nir_const_value_t_array()

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24382>

11 months agonir: Wrap pass macros in braces
Faith Ekstrand [Tue, 8 Aug 2023 16:53:39 +0000 (11:53 -0500)]
nir: Wrap pass macros in braces

This makes clang-format not mess them up so bad.  It's also probably a
good idea to make sure anything we declare in the macro is properly
scoped.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24382>

11 months agonir: Pretty format type mapping helpers
Faith Ekstrand [Tue, 8 Aug 2023 16:25:17 +0000 (11:25 -0500)]
nir: Pretty format type mapping helpers

One of them was even breaking after every return statement. Classy...

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24382>

11 months agonir: More manual formatting
Faith Ekstrand [Tue, 8 Aug 2023 16:23:19 +0000 (11:23 -0500)]
nir: More manual formatting

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24382>

11 months agonir: Don't clang-format debug print setup
Faith Ekstrand [Tue, 8 Aug 2023 16:11:56 +0000 (11:11 -0500)]
nir: Don't clang-format debug print setup

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24382>

11 months agonir: Don't clang-format a couple typedefs
Faith Ekstrand [Sat, 29 Jul 2023 16:37:16 +0000 (11:37 -0500)]
nir: Don't clang-format a couple typedefs

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24382>

11 months agonir: Don't clang-format const_value helpers
Faith Ekstrand [Sat, 29 Jul 2023 16:19:40 +0000 (11:19 -0500)]
nir: Don't clang-format const_value helpers

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24382>

11 months agonir: Re-align a couple enums and add clang-format comments
Faith Ekstrand [Sat, 29 Jul 2023 15:53:09 +0000 (10:53 -0500)]
nir: Re-align a couple enums and add clang-format comments

I actually kinda care about the human-readable formatting of these
enums.  Keep clang-format from messing them up.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24382>

11 months agoclang-format: Set the default ColumnLimit to 0
Faith Ekstrand [Sat, 12 Aug 2023 19:07:42 +0000 (14:07 -0500)]
clang-format: Set the default ColumnLimit to 0

This is a better default than any actual limit because it causes
clang-format to mostly leave line wrapping alone.

Suggested-by: Marek Olšák <maraeo@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24382>

11 months agoclang-format: nir_foreach_src is not a foreach macro
Faith Ekstrand [Tue, 8 Aug 2023 16:15:45 +0000 (11:15 -0500)]
clang-format: nir_foreach_src is not a foreach macro

Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24382>

11 months agoclang-format: Add nir_foreach_reg_*
Faith Ekstrand [Sat, 29 Jul 2023 16:13:31 +0000 (11:13 -0500)]
clang-format: Add nir_foreach_reg_*

Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24382>

11 months agoandroid: Introduce the Android buffer info abstraction
Roman Stratiienko [Tue, 23 Aug 2022 17:08:22 +0000 (20:08 +0300)]
android: Introduce the Android buffer info abstraction

Both EGL and Vulkan implementations require obtaining buffer metadata,
e.g., format, modifier, offsets, strides, etc.

Currently, mesa3d doesn't have a generic solution, and every Vulkan
implementation uses its getters. Most of the getters rely on
kernel metadata storage that is available for x86-based GPU drivers.

ARM-based Vulkan drivers rely on userspace metadata sharing, making it
important to use advanced metadata API. Otherwise, the driver will work
with limited functionality (no YUV, lack of support for modifiers, etc.)

Current EGL buffer getter implementation is advanced enough and used as
a base for a common Android buffer-getter logic.

Use example:

    void
    android_buffer_test(android_handle_type *a_handle)
    {
       // First, get the gralloc object. It will be created if it doesn't
       // exist. Use U_GRALLOC_TYPE_AUTO to let the implementation choose
       // the best gralloc
       struct u_gralloc *gralloc = u_gralloc_create(U_GRALLOC_TYPE_AUTO);

       // Prepare the internal handle structure (hal_format and
       // pixel_stride are required for the fallback implementation).
       // Both Vulkan and EGL clients expose HAL format / pixel stride
       // in their structures.
       u_gralloc_buffer_handle hnd = {
          .handle = a_handle->native_handle,
          .hal_format = a_handle->hal_format,
          .pixel_stride = a_handle->pixel_stride,
       };

       // Get the basic buffer info
       u_gralloc_buffer_basic_info basic_info;
       int ret = u_gralloc_get_buffer_basic_info(gralloc, &hnd, &basic_info);
       if (ret) {
          // Handle the error
       }

       // Get the color info
       u_gralloc_buffer_color_info color_info;
       ret = u_gralloc_get_buffer_color_info(gralloc, &hnd, &color_info);
       if (ret) {
          // Handle the error
       }

       // unref the gralloc object
       u_gralloc_destroy(&gralloc);
    }

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18215>

11 months agoutil: Add NONNULL macro
Roman Stratiienko [Thu, 10 Aug 2023 13:14:02 +0000 (16:14 +0300)]
util: Add NONNULL macro

Macro leverages __attribute__((__nonnull__)) to help users mark
the function parameter that isn't allowed to be NULL.

Suggested-by: Eric Engestrom <eric@igalia.com>
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18215>

11 months agoci/deqp: really remove the uncompressed results.csv file
David Heidelberg [Sat, 12 Aug 2023 16:24:44 +0000 (18:24 +0200)]
ci/deqp: really remove the uncompressed results.csv file

Arguments are parsed in order, so the `-c` here causes that first `--rm`
won't get applied and then it gets overriden by `-o` which writes the file.

Sadly zstd won't report this as a issue, but that's being reported in [1],
so maybe in future versions zstd will warn about it.

[1] https://github.com/facebook/zstd/issues/3719

Fixes: d110299d77c9 ("ci/deqp-runner: compress results.csv before uploading it to GitLab")

Signed-off-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24651>

11 months agoanv: move genX(rasterization_mode) to gfx8_cmd_buffer.c
Lionel Landwerlin [Sun, 4 Jun 2023 23:53:25 +0000 (02:53 +0300)]
anv: move genX(rasterization_mode) to gfx8_cmd_buffer.c

Only used there.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24632>

11 months agoanv: get rid of genX(emit_multisample)
Lionel Landwerlin [Tue, 1 Aug 2023 09:18:53 +0000 (12:18 +0300)]
anv: get rid of genX(emit_multisample)

The initialization can be simplified and the real programming moved
over to genX_pipeline.c

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24632>

11 months agointel/decoder: add options to decode surfaces/samplers
Lionel Landwerlin [Tue, 1 Aug 2023 20:16:43 +0000 (23:16 +0300)]
intel/decoder: add options to decode surfaces/samplers

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24632>

11 months agoanv: emit 3DSTATE_GS only once per pipeline
Lionel Landwerlin [Wed, 2 Aug 2023 06:30:05 +0000 (09:30 +0300)]
anv: emit 3DSTATE_GS only once per pipeline

Following 71ebd9b9d7, 3DSTATE_GS can be emitted as part of the
pipeline batch and as a dynamic state. Just do the latter.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 71ebd9b9d7 ("anv,hasvk: respect provoking vertex setting on geometry shaders")
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24632>

11 months agoblorp: drop programming of 3DSTATE_(MESH|TASK)_SHADER
Lionel Landwerlin [Tue, 1 Aug 2023 08:51:36 +0000 (11:51 +0300)]
blorp: drop programming of 3DSTATE_(MESH|TASK)_SHADER

We can disable the MESH/TASK stages by just using the CONTROL
instruction and keep the rest of the HW programmed as before.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24632>

11 months agointel/decoder: constify some input parameters
Lionel Landwerlin [Fri, 4 Aug 2023 08:14:27 +0000 (11:14 +0300)]
intel/decoder: constify some input parameters

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24632>

11 months agoci/farms: enabled Microsoft job only when conditions are met
David Heidelberg [Thu, 10 Aug 2023 09:06:14 +0000 (11:06 +0200)]
ci/farms: enabled Microsoft job only when conditions are met

Otherwise it gets run by default on newly pushed fork branch.

In general, this is copy-paste of `.container-rules`.

Signed-off-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24604>

11 months agozink/nir: add a zink specific intrinsic for push constants
antonino [Mon, 31 Jul 2023 15:54:52 +0000 (17:54 +0200)]
zink/nir: add a zink specific intrinsic for push constants

Push costants in Zink are not flat indexed like in vulkan drivers which
makes the `nir_intrinsic_load_push_constant` intrinsic inappropiate.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24401>

11 months agozink: remove unused indices from `nir_load_push_constant` calls
antonino [Mon, 31 Jul 2023 16:45:15 +0000 (18:45 +0200)]
zink: remove unused indices from `nir_load_push_constant` calls

Zink passes `base` and `range` indices to this intrinsic despite those
being ignored by nir_to_spirv. This change removes them completely.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24401>

11 months agoci/freedreno: document vs-nested-return-sibling-loop2 flake on Adreno 530
David Heidelberg [Fri, 11 Aug 2023 13:12:18 +0000 (15:12 +0200)]
ci/freedreno: document vs-nested-return-sibling-loop2 flake on Adreno 530

Signed-off-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24607>

11 months agoci/amd: add glx@glx-visuals-depth flake to raven
David Heidelberg [Fri, 11 Aug 2023 12:03:09 +0000 (14:03 +0200)]
ci/amd: add glx@glx-visuals-depth flake to raven

Signed-off-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24607>

11 months agoci/build: limit debian-build-testing to 30 minutes
David Heidelberg [Thu, 10 Aug 2023 10:04:39 +0000 (12:04 +0200)]
ci/build: limit debian-build-testing to 30 minutes

Previous 45 minutes is too much.

 - 5 - 15 minutes mesa LTO build
 - 5 - 15 minutes shader-db run

Should be safe, in case something fails, we still can make another run.

Signed-off-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24607>

11 months agonir/opt_if: also rewrite uniform uses for read_invocation
Georg Lehmann [Thu, 10 Aug 2023 19:05:32 +0000 (21:05 +0200)]
nir/opt_if: also rewrite uniform uses for read_invocation

No Foz-DB changes, but maybe it matters in the future because dxil-spirv
will use read_invocation for WaveReadLaneFirst in fragment shaders.

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

11 months agovulkan: ignore VkPipelineColorWriteCreateInfoEXT if the state is dynamic
Samuel Pitoiset [Thu, 10 Aug 2023 07:16:34 +0000 (09:16 +0200)]
vulkan: ignore VkPipelineColorWriteCreateInfoEXT if the state is dynamic

Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24601>

11 months agoegl/drm: fix EGL_EXT_buffer_age with gbm contexts
Erico Nunes [Fri, 11 Aug 2023 10:50:49 +0000 (12:50 +0200)]
egl/drm: fix EGL_EXT_buffer_age with gbm contexts

Fix remaining dri2 check from 3d59f4cfcbc, which caused gbm contexts to
not expose EGL_EXT_buffer_age anymore.

Fixes: 3d59f4cfcbc ("egl/drm: Use IMAGE_DRIVER instead of DRI2_LOADER")

Reviewed-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24630>

11 months agoasahi: Legalize compression before blitting
Alyssa Rosenzweig [Wed, 9 Aug 2023 18:15:35 +0000 (14:15 -0400)]
asahi: Legalize compression before blitting

Fixes invalid recursive blitting.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Do not allow creating vec8
Alyssa Rosenzweig [Thu, 10 Aug 2023 21:20:34 +0000 (17:20 -0400)]
agx: Do not allow creating vec8

mem_access_bit_size needs to split up 64x4 into 2 loads. Fixes:

dEQP-VK.spirv_assembly.instruction.compute.64bit_compare.int64.comp_opiequal_vector

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Handle <32-bit local memory access
Alyssa Rosenzweig [Thu, 10 Aug 2023 21:09:14 +0000 (17:09 -0400)]
agx: Handle <32-bit local memory access

I don't know if this is possible to hit with GL, but it is with Vulkan. Fixes:

dEQP-VK.spirv_assembly.instruction.compute.workgroup_memory.*

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Handle f2f16_rtne like f2f16
Alyssa Rosenzweig [Thu, 10 Aug 2023 18:28:55 +0000 (14:28 -0400)]
agx: Handle f2f16_rtne like f2f16

TBD whether we can control round modes later on.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Lower f2f16_rtz
Alyssa Rosenzweig [Thu, 10 Aug 2023 20:35:43 +0000 (16:35 -0400)]
agx: Lower f2f16_rtz

Based on what VIR does.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Fix 64-bit immediate moves
Alyssa Rosenzweig [Fri, 11 Aug 2023 14:11:44 +0000 (10:11 -0400)]
agx: Fix 64-bit immediate moves

Don't truncate them in the builder. Fixes:

dEQP-VK.spirv_assembly.instruction.compute.convertutof.uint64_to_float32_4294967296

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Fix uadd_sat packing
Alyssa Rosenzweig [Thu, 10 Aug 2023 20:21:19 +0000 (16:21 -0400)]
agx: Fix uadd_sat packing

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Handle conversions to 8-bit
Alyssa Rosenzweig [Thu, 10 Aug 2023 18:57:03 +0000 (14:57 -0400)]
agx: Handle conversions to 8-bit

These can't be lowered by nir_lower_bit_sizes but it doesn't actually matter.
Fixes SPIR-V conversions tests.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Lower f2u8/f2i8
Alyssa Rosenzweig [Fri, 11 Aug 2023 13:58:33 +0000 (09:58 -0400)]
agx: Lower f2u8/f2i8

The less 8-bit we need to emulate in the backend the better.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Handle blocks with no predecessors
Alyssa Rosenzweig [Thu, 10 Aug 2023 17:36:55 +0000 (13:36 -0400)]
agx: Handle blocks with no predecessors

This can come up with loops with SPIR-V. Fixes:

dEQP-VK.spirv_assembly.instruction.compute.loop_control.none

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoasahi: Fix incorrect BO bitmap reallocations
Asahi Lina [Fri, 11 Aug 2023 08:04:00 +0000 (17:04 +0900)]
asahi: Fix incorrect BO bitmap reallocations

If the BO handle is greater than 2x what fits inside the current bitmap
size, then we end up overflowing. Make sure to always reallocate to a
large enough bitmap, not just 2x the previous size.

Found while replaying firefox apitraces with looping (which apparently
leaks a ton of objects, but that might just be apitrace).

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoasahi: Handle non-written RTs correctly
Asahi Lina [Fri, 11 Aug 2023 04:41:02 +0000 (13:41 +0900)]
asahi: Handle non-written RTs correctly

When a bound RT is not written to, we need to force the pass type to
translucent to ensure that this draw does not cull draws that do write
to that RT.

Fixes Inochi2D regression after c24b753378.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Move nir_lower_fragcolor out of agx_preprocess_nir
Mary [Fri, 11 Aug 2023 10:18:47 +0000 (12:18 +0200)]
agx: Move nir_lower_fragcolor out of agx_preprocess_nir

Do not apply "nir_lower_fragcolor" in the common code.

This fix a crash on agxv side when a frag shader have SSBO writes.

This is caused by "nir_lower_frag_color" assuming that every
"store_deref" will have a variable backing the
output.

Signed-off-by: Mary <mary@mary.zone>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Stop setting forwarding bit
Alyssa Rosenzweig [Tue, 1 Aug 2023 01:42:10 +0000 (21:42 -0400)]
agx: Stop setting forwarding bit

We need actual analysis to set it properly, and improperly setting it can cause
random data dependency hazards it turns out. Stop setting it. Fixes some flaky
tests with shuffle code inserted.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Remove unused allocation
Alyssa Rosenzweig [Tue, 1 Aug 2023 13:29:40 +0000 (09:29 -0400)]
agx: Remove unused allocation

Relic from early RA attempts.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Don't reuse ssa_to_reg across blocks
Alyssa Rosenzweig [Tue, 1 Aug 2023 13:16:27 +0000 (09:16 -0400)]
agx: Don't reuse ssa_to_reg across blocks

This avoids an entire class of bugs with live range splitting. Fixes with
AGX_MESA_DEBUG=demand:

   dEQP-GLES31.functional.separate_shader.random.8

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Don't use ssa_to_reg across blocks
Alyssa Rosenzweig [Tue, 1 Aug 2023 13:13:02 +0000 (09:13 -0400)]
agx: Don't use ssa_to_reg across blocks

This is a footgun with live range spltiting.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Assert invariant stated in the comment
Alyssa Rosenzweig [Tue, 1 Aug 2023 13:07:31 +0000 (09:07 -0400)]
agx: Assert invariant stated in the comment

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Use agx_replace_src
Alyssa Rosenzweig [Tue, 1 Aug 2023 12:33:13 +0000 (08:33 -0400)]
agx: Use agx_replace_src

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Stop setting registers after the shader
Alyssa Rosenzweig [Tue, 1 Aug 2023 12:30:33 +0000 (08:30 -0400)]
agx: Stop setting registers after the shader

Leftover from before live range splitting. Should be a no-op.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Set phi sources in predecessors
Alyssa Rosenzweig [Tue, 1 Aug 2023 12:15:13 +0000 (08:15 -0400)]
agx: Set phi sources in predecessors

This ensures correctness with live range splits. Now agx_set_sources is only for
non-phis where it makes sense.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Fix accounting for phis
Alyssa Rosenzweig [Tue, 1 Aug 2023 11:26:51 +0000 (07:26 -0400)]
agx: Fix accounting for phis

All affected shaders are in pubg. Presumably, with the new demand calculation,
RA is hitting a higher target thread count at the expense of a little more live
range splitting.

   total instructions in shared programs: 1773295 -> 1773310 (<.01%)
   instructions in affected programs: 6058 -> 6073 (0.25%)
   helped: 0
   HURT: 15
   Instructions are HURT.

   total bytes in shared programs: 11695360 -> 11695450 (<.01%)
   bytes in affected programs: 40496 -> 40586 (0.22%)
   helped: 0
   HURT: 15
   Bytes are HURT.

   total halfregs in shared programs: 530844 -> 530724 (-0.02%)
   halfregs in affected programs: 1785 -> 1665 (-6.72%)
   helped: 15
   HURT: 0
   Halfregs are helped.

   total threads in shared programs: 18909440 -> 18910400 (<.01%)
   threads in affected programs: 12480 -> 13440 (7.69%)
   helped: 15
   HURT: 0
   Threads are helped.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Allow 64-bit memory regs
Alyssa Rosenzweig [Tue, 1 Aug 2023 11:26:03 +0000 (07:26 -0400)]
agx: Allow 64-bit memory regs

The mask is based on the format, which can be at most 32-bits per channel. So if
we have 64-bit loads/stores we're still using a 32-bit format with double the
bits set in the mask. This will fix validation fails with spilling.

No shader-db changes.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Maintain ctx->max_reg while assigning regs
Alyssa Rosenzweig [Mon, 31 Jul 2023 21:42:58 +0000 (17:42 -0400)]
agx: Maintain ctx->max_reg while assigning regs

We can't calculate after since ssa_to_reg[] gets overwritten during live range
splits. Theoretical issue only, but let's fix it while squashing live range
splitting bugs.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Fix AGX_MESA_DEBUG=demand
Alyssa Rosenzweig [Sun, 30 Jul 2023 20:08:35 +0000 (16:08 -0400)]
agx: Fix AGX_MESA_DEBUG=demand

No wonder it seemed like it wasn't doing anything!

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Optimize logical_end removal
Alyssa Rosenzweig [Mon, 31 Jul 2023 20:40:48 +0000 (16:40 -0400)]
agx: Optimize logical_end removal

We know logical_end instructions are only at the end of the block (validated),
so by changing how we iterate the pass goes from O(instructions) to O(blocks)
which is strictly better.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Optimize swaps of 2x16 channels
Alyssa Rosenzweig [Mon, 31 Jul 2023 21:19:56 +0000 (17:19 -0400)]
agx: Optimize swaps of 2x16 channels

We can use extr to swap the low and high halves of a 32-bit register in one
instruction.

No shader-db changes, but it reduces xor's on a deqp I'm looking at. Yes, I'm
procrastinating on debugging deqps, how'd you guess?

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Use compressed fadd/fmul encodings
Alyssa Rosenzweig [Mon, 31 Jul 2023 02:44:28 +0000 (22:44 -0400)]
agx: Use compressed fadd/fmul encodings

See applegpu commit b9b3582 ("FBinaryInstructions have compressed encodings")

   total bytes in shared programs: 11717310 -> 11716524 (<.01%)
   bytes in affected programs: 317504 -> 316718 (-0.25%)
   helped: 196
   HURT: 0
   Bytes are helped.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Require an immediate for `nest`
Alyssa Rosenzweig [Sun, 30 Jul 2023 01:46:52 +0000 (21:46 -0400)]
agx: Require an immediate for `nest`

There's no good reason to allow non-immediate nesting values, and this lets us
use the (smaller) mov_imm instruction without special casing. This matches what
Metal produces, so it seems like a good preference.

   total bytes in shared programs: 11720338 -> 11717310 (-0.03%)
   bytes in affected programs: 2341580 -> 2338552 (-0.13%)
   helped: 1385
   HURT: 0
   Bytes are helped.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Fix length bit confusion
Alyssa Rosenzweig [Sun, 30 Jul 2023 01:54:58 +0000 (21:54 -0400)]
agx: Fix length bit confusion

Man, this expression was wrong. First of all, raw is 64-bit so our mask needs to
be too. Second, length is in bytes -- not bits -- so we need to multiply by 8 to
get something sensible. In effect, the old wrong expression would always use the
long encoding for ALU instructions... whoops. This particular bug probably goes
back to the very first version of agx_pack...

Massive improvement in code density. Noticed while comparing assembly with the
blob. It's my Saturday, I can pointless optimize if I want to.

   total bytes in shared programs: 12175112 -> 11720338 (-3.74%)
   bytes in affected programs: 11963800 -> 11509026 (-3.80%)
   helped: 16624
   HURT: 0
   Bytes are helped.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Optimize out pointless else instructions
Alyssa Rosenzweig [Sun, 30 Jul 2023 01:36:07 +0000 (21:36 -0400)]
agx: Optimize out pointless else instructions

Now that they're in the right blocks, this is easy. Includes an informal proof
and the implementation itself is built around a finite state machine, which
together meant this code worked on its first try :~)

And hey, it's a pointless little instruction saving optimization I've wanted to
do for a while~

Major note is that this HAS to be done after register allocation, since it
doesn't update the control flow graph and would introduce critical edges
if it tried to actually deleted the else block. The intuitive reason for this is
simple: sometimes RA needs to insert instructions into the else block, even if
it was empty in the original NIR, so we always need an else block even if we can
delete it with this pass after RA.

   total instructions in shared programs: 1778390 -> 1776725 (-0.09%)
   instructions in affected programs: 268459 -> 266794 (-0.62%)
   helped: 1013
   HURT: 0
   Instructions are helped.

   total bytes in shared programs: 12185102 -> 12175112 (-0.08%)
   bytes in affected programs: 1927524 -> 1917534 (-0.52%)
   helped: 1013
   HURT: 0
   Bytes are helped.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Use unconditional else instruction
Alyssa Rosenzweig [Sun, 30 Jul 2023 00:58:53 +0000 (20:58 -0400)]
agx: Use unconditional else instruction

Rather than duplicating the condition. This matches the blob, so is presumably
the most energy-efficient way of expressing the logic.

No shader-db changes.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Put else instructions in the right block
Alyssa Rosenzweig [Sun, 30 Jul 2023 00:08:43 +0000 (20:08 -0400)]
agx: Put else instructions in the right block

According to Dougall's pseudocode, else_icmp operates as:

  if r0l == 0:
    r0l = n
  elif r0l == 1:
    if cc.compare(A[thread], B[thread]):
      r0l = 0
    else:
      r0l = 1

  exec_mask[thread] = (r0l == 0)

Notice that the comparison only happens when r0l == 1, that is, for threads that
are about to enter the else block. Threads that just executed the if body are
still active (r0l = 0) and skip the comparison. As such, the sources of
else_icmp are only read in the else block, and hence the whole instruction
should be placed in the else block for correctness with respect to live range
splitting.

shader-db is a wash, but shows some improvements due to correctly modelling the
liveness of the condition variable.

   total instructions in shared programs: 1778376 -> 1778390 (<.01%)
   instructions in affected programs: 14753 -> 14767 (0.09%)
   helped: 35
   HURT: 39
   Inconclusive result (value mean confidence interval includes 0).

   total bytes in shared programs: 12185018 -> 12185102 (<.01%)
   bytes in affected programs: 101522 -> 101606 (0.08%)
   helped: 35
   HURT: 39
   Inconclusive result (value mean confidence interval includes 0).

   total halfregs in shared programs: 531174 -> 531032 (-0.03%)
   halfregs in affected programs: 2320 -> 2178 (-6.12%)
   helped: 40
   HURT: 1
   Halfregs are helped.

   total threads in shared programs: 18909184 -> 18909440 (<.01%)
   threads in affected programs: 1792 -> 2048 (14.29%)
   helped: 2
   HURT: 0

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Do not move bindless handles
Alyssa Rosenzweig [Fri, 4 Aug 2023 15:25:00 +0000 (11:25 -0400)]
agx: Do not move bindless handles

NIR->AGX translation relies on bindless handles being vec2 instructions with a
constant first index. Moving the entire vec2 into the preamble would mess this
up, so tell nir_opt_preamble to never do this. It's still allowed to move the
offset calculation into the preamble, if it thinks that's beneficial.

Fixes dEQP-GLES31.functional.shaders.opaque_type_indexing.sampler.*

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Fix shader info with sample mask writes
Alyssa Rosenzweig [Thu, 3 Aug 2023 17:28:27 +0000 (13:28 -0400)]
agx: Fix shader info with sample mask writes

Otherwise the discard_agx isn't lowered.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoasahi: Enable explicit coherency for G14D (multi-die)
Asahi Lina [Wed, 9 Aug 2023 11:13:39 +0000 (11:13 +0000)]
asahi: Enable explicit coherency for G14D (multi-die)

It turns out we do need this explicit coherency dance for G14,
but only on G14D.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoasahi,agx: Upload constant buffers immediately
Janne Grunau [Sun, 30 Jul 2023 16:26:45 +0000 (18:26 +0200)]
asahi,agx: Upload constant buffers immediately

The lifetime of the constant buffer's user_buffer is not guaranteed
to last until agx_upload_uniforms.
Fixes the same ASAN issue mesa/mesa!21685 is trying to address.

Fixes: 080b05e29e1 ("asahi: Add Gallium driver")
Signed-off-by: Janne Grunau <j@jannau.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Fix atomics with no destination
Alyssa Rosenzweig [Thu, 27 Jul 2023 18:06:00 +0000 (14:06 -0400)]
agx: Fix atomics with no destination

We need to:

* properly null out the dest in DCE.
* not assert out when packing with null dest

Fixes potential reg pressure blow up with atomics that don't use their
destinations, though I don't see shader-db changes.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx/dce: Use the helper
Alyssa Rosenzweig [Thu, 27 Jul 2023 18:05:54 +0000 (14:05 -0400)]
agx/dce: Use the helper

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoagx: Don't lower load_local_invocation_index
Alyssa Rosenzweig [Sat, 29 Jul 2023 01:24:20 +0000 (21:24 -0400)]
agx: Don't lower load_local_invocation_index

We have an SR for it, which can save a bit of math. This came up while working
on the spiller.

   total instructions in shared programs: 1778396 -> 1778376 (<.01%)
   instructions in affected programs: 3036 -> 3016 (-0.66%)
   helped: 10
   HURT: 3
   Instructions are helped.

   total bytes in shared programs: 12185182 -> 12185018 (<.01%)
   bytes in affected programs: 38640 -> 38476 (-0.42%)
   helped: 18
   HURT: 2
   Bytes are helped.

   total halfregs in shared programs: 531218 -> 531174 (<.01%)
   halfregs in affected programs: 471 -> 427 (-9.34%)
   helped: 6
   HURT: 0
   Halfregs are helped.

   total threads in shared programs: 18909056 -> 18909184 (<.01%)
   threads in affected programs: 1280 -> 1408 (10.00%)
   helped: 2
   HURT: 0

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoasahi,agx: Fix stack buffer overflow in agx_link_varyings_vs_fs
Janne Grunau [Sat, 29 Jul 2023 17:12:09 +0000 (19:12 +0200)]
asahi,agx: Fix stack buffer overflow in agx_link_varyings_vs_fs

Discovered while running dEQP-EGL under address sanitizer.

Fixes: f3877f56ba7 ("asahi,agx: Rewrite varying linking")
Signed-off-by: Janne Grunau <j@jannau.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoasahi: Force linear for SHARED buffers with no/implicit modifier
Asahi Lina [Sat, 29 Jul 2023 11:05:35 +0000 (20:05 +0900)]
asahi: Force linear for SHARED buffers with no/implicit modifier

Consumers might not pass through the modifier information in this case.

Fixes XWayland/mutter using dma-buf v4 feedback (though the fact they
try to use implicit modifiers is likely a bug on their end, and will
decrease performance).

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoasahi,agx: Respect no16 even for I/O
Alyssa Rosenzweig [Tue, 25 Jul 2023 13:50:48 +0000 (09:50 -0400)]
asahi,agx: Respect no16 even for I/O

Don't call lower_mediump_io for no16. This is helpful for debugging and soon
driconf-shaming apps with broken precision qualifiers.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoasahi: Impose limits on resource shadowing
Asahi Lina [Sat, 22 Jul 2023 09:37:40 +0000 (18:37 +0900)]
asahi: Impose limits on resource shadowing

Apps can have pathological use cases where huge resources are shadowed
repeatedly. An app that alternately writes to a resource and then uses
it to draw can create an unbounded amount of shadow BOs.

To fix this, introduce both a maximum resource size for shadowing, and a
maximum cumulative size that resource may be shadowed before we start
flushing readers. The flush path then clears the counter, as does the
happy path where there are no readers left after flushing writers.

Fixes massive memory bloating in Firefox and probably others.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoasahi: Print info about shadowed resources
Asahi Lina [Sat, 22 Jul 2023 09:36:54 +0000 (18:36 +0900)]
asahi: Print info about shadowed resources

If resource and perf debugging are both enabled, this prints resource
info for shadowed resources.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

11 months agoasahi: Always use resource size, not BO size
Asahi Lina [Sat, 22 Jul 2023 09:35:42 +0000 (18:35 +0900)]
asahi: Always use resource size, not BO size

BOs can be oversized, as they can come from the BO cache. Make sure to
always use the resource layout size, not the BO size, when we need this
for some reason.

This fixes BO shadowing creating overlarge BOs, and also the attachment
size for submissions (probably doesn't matter, but it's more correct now).

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>