Commit graph

166191 commits

Author SHA1 Message Date
Rhys Perry
477b310dfd util: skip zero-sized SHA1Update
Fixes UBSan error:
src/util/sha1/sha1.c:140:8: runtime error: null pointer passed as argument 2, which is declared to never be null

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25853>
2023-10-25 17:27:47 +00:00
Rhys Perry
1afd0878e9 nir/lower_shader_calls: skip zero-sized qsort
Fixes UBSan:
src/compiler/nir/nir_lower_shader_calls.c:1681:7: runtime error: null pointer passed as argument 1, which is declared to never be null

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25853>
2023-10-25 17:27:47 +00:00
Rhys Perry
f9289dfd02 nir/serialize: fix signed integer overflow
Fixes UBSan error:
src/compiler/nir/nir_serialize.c:1277:70: runtime error: left shift of 524287 by 13 places cannot be represented in type 'int'

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25853>
2023-10-25 17:27:47 +00:00
Alyssa Rosenzweig
9a6c20e64f nir/trivialize_registers: Handle obscure load hazard
Somebody less tired than me would add a unit test for this. Offending snippet:

        32    %58 = @load_reg (%55) (base=0, legacy_fabs=0, legacy_fneg=0)
        32    %57 = @load_reg (%55) (base=0, legacy_fabs=0, legacy_fneg=0)
        32    %21 = iadd %57, %15 (0x1)
                    @store_reg (%21, %55) (base=0, wrmask=x, legacy_fsat=0)
        32    %56 = @load_reg (%55) (base=0, legacy_fabs=0, legacy_fneg=0)
        32    %22 = i2f32 %56
        32    %23 = load_const (0x41000000 = 8.000000)
        32    %24 = fdiv %22, %23 (8.000000)
        32    %90 = mov %24
                    @store_reg_indirect (%90, %78, %58) (base=0, wrmask=x, legacy_fsat=0)

Closes: #10031
Fixes: d313eba94e ("nir: Add pass for trivializing register access")
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reported-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25865>
2023-10-25 16:34:47 +00:00
Samuel Pitoiset
1febb6f762 radv: report the last GPUVM fault when a device lost is detected
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23238>
2023-10-25 15:29:23 +00:00
Samuel Pitoiset
5a6208ad72 radv: query and report the last GPUVM fault with RADV_DEBUG=hang
Tested with a small use-after-free Vulkan test. It's pretty basic
for now but I think I will add status decoding support to report
more useful information.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23238>
2023-10-25 15:29:22 +00:00
Samuel Pitoiset
5eb8b3e9b1 radv/amdgpu: add support quering the last GPUVM fault
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23238>
2023-10-25 15:29:22 +00:00
Samuel Pitoiset
bdc62108be amd: add has_gpuvm_fault_query
Whether the kernel allows to query the last GPUVM fault.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23238>
2023-10-25 15:29:22 +00:00
Samuel Pitoiset
1b0fbcbe1c radv: remove outdated RADV_DEBUG=vmfaults support
It's been a very long time since this was useless because dmesg
required sudo access for a while.

This will be replaced by the new GPUVM fault interface which allows
to query from the kernel directly instead of trying to parse dmesg.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23238>
2023-10-25 15:29:22 +00:00
Seppo Yli-Olli
6bbbdd5ceb zink: Fix SyntaxWarning in zink_extensions script
Fix regex pattern in zink_extensions to use proper escaping. While the original
code works, it relies on Python ignoring incorrect syntax and fallbacking to
passing through the escape. Current behaviour results in SyntaxWarning
whenever the code is used.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25881>
2023-10-25 15:03:43 +00:00
Louis-Francis Ratté-Boulianne
5a928f7563 panfrost: Add env variable for max AFBC packing ratio
Add `PAN_MAX_AFBC_PACKING_RATIO` variable. If the ratio (size of the
packed resource) / (size of the sparse resource) * 100 is above that
value, we don't care about packing it.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
2023-10-25 14:25:31 +00:00
Louis-Francis Ratté-Boulianne
888d7c8ee6 panfrost: Add some debug utility methods for resources
Add a method to dump a specific superblock given its index (header
and few first bytes from the body) and a method to dump a resource
to a ppm file.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
2023-10-25 14:25:31 +00:00
Louis-Francis Ratté-Boulianne
33b48a5585 panfrost: Add debug flag to force packing of AFBC textures on upload
Add `forcepack` flag that will force conversion to AFBC-packed right
after a texture is uploaded when possible. We only pack 2D resources
larger than 32x32 as of now.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
2023-10-25 14:25:31 +00:00
Louis-Francis Ratté-Boulianne
bc91af8021 panfrost: Don't force constant modifier after converting
After converting a texture from one modifier to another, there is
no reason to force the modifier to stay constant afterwards. Set
back `modifier_constant` to false because it is changed by
`resource_setup` as it is causing issues when implementing AFBC
packing.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
2023-10-25 14:25:31 +00:00
Louis-Francis Ratté-Boulianne
e9d523bb92 panfrost: Legalize resource when attaching to a batch
Make sure we don't convert the texture for nothing by only
legalizing when creating a batch instead of on surface creation.
Also, to avoid recursive blit, we need to legalize the destination
resource before blitting.

Finally, make sure the resource has a sparse memory layout if
AFBC compressed. The GPU doesn't support rendering to a AFBC-packed
texture.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
2023-10-25 14:25:31 +00:00
Louis-Francis Ratté-Boulianne
bc55d150a9 panfrost: Add support for AFBC packing
When the GPU is converting a texture from linear/tiled to compressed
AFBC, it uses a sparse memory layout. That means that the
superblocks are stored starting at intervals equal to the size of an
uncompressed superblock. When memory usage needs to be optimized, it
is possible to pack the resource by trimming each superblock as much
as possible. The GPU will still be able to read from these packed
textures, but won't be able to write directly to them. If the
layout is AFBC-tiled, the packing process will also de-tile as
tiled+packed is not supported by Mali GPUs.

No new modifier flag has been added as the absence of the
`AFBC_FORMAT_MOD_SPARSE` flag means the resource will be packed.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
2023-10-25 14:25:31 +00:00
Louis-Francis Ratté-Boulianne
32fbd38889 panfrost: Add method to get size of AFBC superblocks valid data
The compute shader is going through all the AFBC header blocks and
calculating the size of valid data by summing up the subblock
sizes (and taking into account solid color, uncompressed mode and
copy blocks). The result is written into the given buffer (array
of `pan_afbc_block_info`).

The size is rounded up to the alignment parameter directly in the
shader.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
2023-10-25 14:25:31 +00:00
Louis-Francis Ratté-Boulianne
ae3fb3089f panfrost: Add infrastructure for internal AFBC compute shaders
A few compute shaders are needed to support AFBC-packing. Here is
just the boilerplate to create, compile and retrieve the shaders.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
2023-10-25 14:25:31 +00:00
Louis-Francis Ratté-Boulianne
c1429a3120 panfrost: Split out internal of panfrost_launch_grid
For an upcoming feature (AFBC packing), we're gonna run internal
compute shaders on resources. This commit just split the internal
of `panfrost_launch_grid` so we can run the shader on a given
batch.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
2023-10-25 14:25:31 +00:00
Louis-Francis Ratté-Boulianne
91514e7091 panfrost: Make panfrost_resource_create_with_modifier public
It allows creating a resource when we already know which modifier
we're gonna use.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
2023-10-25 14:25:31 +00:00
Louis-Francis Ratté-Boulianne
542c44ffde panfrost: Add panfrost_batch_write_bo
Needed when writing to a BO from a compute shader when the BO isn't
assigned to a resource yet.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
2023-10-25 14:25:31 +00:00
Louis-Francis Ratté-Boulianne
113d88f94d panfrost: Precalculate stride and nr of blocks for AFBC layouts
For AFBC packing, we will need to have the stride of the resource
in terms of superblocks and the total number of blocks. It is
easier to pre-calculate once when initializing the resource layout.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
2023-10-25 14:25:31 +00:00
Louis-Francis Ratté-Boulianne
9f3a79a6a3 panfrost: Add method to get size of AFBC subblocks
Each AFBC superblock is subdivised into subblocks that are
compressed individually. For all formats that we currently support,
the subblocks are 4x4 pixels.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
2023-10-25 14:25:30 +00:00
Louis-Francis Ratté-Boulianne
39efd7c245 panfrost: Add methods to determine slice and body alignment
Those methods are needed to have the same alignment everywhere
without hard-coding the values

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
2023-10-25 14:25:30 +00:00
Louis-Francis Ratté-Boulianne
6012bde0fc panfrost: Fix error in comment
"linear" -> "tiled"

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
2023-10-25 14:25:30 +00:00
Tapani Pälli
c7e522a9f3 egl: fix leaking drmDevicePtr in _eglFindDevice
Fixes: 3a9e1014e1 ("egl: Rename _eglAddDevice() to _eglFindDevice()")
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25524>
2023-10-25 12:37:30 +00:00
Lionel Landwerlin
3de5da7a5d anv: fixup 32bit build of internal shaders
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 11b4c23d19 ("anv: add ring buffer mode to generated draw optimization")
Fixes: db335d9b73 ("anv: factor out host/gpu internal shaders interfaces")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10037
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25870>
2023-10-25 11:47:40 +00:00
Christian Gmeiner
471942e06b etnaviv: Don't leak disk_cache
Fixes: 77af1ca690 ("etnaviv: add disk cache")
Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Reviewed-by: Tomeu Vizoso <tomeu@tomeuvizoso.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25877>
2023-10-25 09:46:37 +00:00
Tapani Pälli
d52c39a6cd intel/dev: expand existing fix for all gfx12 with small EU count
Commit 7db1b94e07 added a fix for ADL-N but this issue has been
reproduced also on RPL-S and is likely common with all gfx12 variants
with a small EU count.

cc: mesa-stable

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25861>
2023-10-25 05:15:47 +00:00
Caio Oliveira
67450674c0 compiler/types: Move comments and reorganize declarations
Move comments from C++ member functions to the C functions.  In
some cases just delete comments or consolidate them together.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
dfcca13800 compiler/types: Remove warnings about potential fallthrough
None of those cases are expected to fallthrough, but should be unreachable.
Just break them so they get to the unreachable entry at the end.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
9e32cc3d0b compiler/types: Rename glsl_types.cpp to glsl_types.c
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
c45276c665 compiler/types: Annotate extern "C" only once in glsl_types.cpp
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
cecdc686e4 compiler/types: Remove usages of C++ members in glsl_types.cpp
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
94bdf351dc compiler/types: Use C instead of C++ constants for builtin types
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
07ee4bd69f compiler/types: Add remaining type extraction functions and use them in C++
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
ada6183d60 compiler/types: Add glsl_simple_explicit_type() and simplify glsl_simple_type()
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
e17adf51db compiler/types: Implement glsl_type::field_type() in terms of existing functions
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
9e514b89a0 compiler/types: Add glsl_get_explicit_*() functions and use them in C++
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
d2a804a25b compiler/types: Add glsl_get_std430_array_stride() and use it in C++
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
7b42fe62a1 compiler/types: Add glsl_type_uniform_locations() and use it in C++
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
e98ba3b53f compiler/types: Add glsl_type_compare_no_precision() and use it in C++
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
3ce4d5e033 compiler/types: Add glsl_get_mul_type() and use it in C++
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
795bf4244c compiler/types: Add more glsl_contains_*() functions and use them in C++
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
2d4a250d21 rusticl: Add bindings for glsl_vector_type()
This is going to become inline functions, so add the corresponding
Rust bindings for it first.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
68f80e6fc1 compiler/types: Move remaining code from nir_types to glsl_types
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
b2407d7859 compiler/types: Flip wrapping of numeric type conversion functions
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
8bebd40d5c compiler/types: Flip wrapping of remaining small data getters
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
922fe24739 compiler/types: Flip wrapping of remaining non-trivial type getters
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00
Caio Oliveira
a5e6e5b6d3 compiler/types: Flip wrapping of get row/column type helpers
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
2023-10-25 01:51:12 +00:00