Dynamically adding to the list is not used anymore, so
just inline the calls in the atexit callback and remove
_eglAddAtExitCall().
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37518>
This ensure that the default handlers enumerated in
eglGlobal will be called. Historically the atexit() would
be set when adding a new handler, but as the code moved on
the handlers were included by default and the function
that added them is not being called anymore.
This fixes memory leaks like
```
==37635== 144 bytes in 1 blocks are still reachable in loss record 2,416 of 2,428
==37635== at 0x48463F3: calloc (vg_replace_malloc.c:1675)
==37635== by 0x7D13686: ??? (in /usr/lib64/libdrm.so.2.125.0)
==37635== by 0x7D13A13: ??? (in /usr/lib64/libdrm.so.2.125.0)
==37635== by 0x7D18310: drmGetDevices2 (in /usr/lib64/libdrm.so.2.125.0)
==37635== by 0x4FFC411: _eglDeviceRefreshList (egldevice.c:431)
==37635== by 0x4FF079A: eglInitialize (eglapi.c:672)
==37635== by 0x40078F: main (main.c:75)
```
and
```
==37664== 2,680 bytes in 1 blocks are still reachable in loss record 2,423 of 2,428
==37664== at 0x48463F3: calloc (vg_replace_malloc.c:1675)
==37664== by 0x4FFCDF3: _eglFindDisplay (egldisplay.c:270)
==37664== by 0x4FEED00: eglGetDisplay (eglapi.c:418)
==37664== by 0x501464E: __eglGLVNDGetPlatformDisplay (eglglvnd.c:67)
==37664== by 0x488170D: ??? (in /usr/lib64/libEGL.so.1.1.0)
==37664== by 0x40075C: main (main.c:68)
```
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37518>
If a client creates a semaphore, exports it, and then re-imports it back
into the device, this can trick our semaphore reset logic. When this
happens, we end up with two different vk_sync structs that have the same
underlying payload so if one is used as the signal and one is used as
the wait of the same submit, we'll end up resetting it because we think
they're different, causing us to lose the signal.
We already have the ability to handle this for the threaded case by
moving the semaphore payload into a new vk_sync which we then destroy
after we're done submitting to the driver. Use this path for shared
semaphores in the immediate case so we can just wait and signal without
worrying about the reset.
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13805
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37149>
srnd_edge_cases.lua is checking edge cases.
srnd_randomized.lua is shared by Caio and it serves as a good example for
understanding the randomness and probability of rounding.
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36529>
Adding zero has the effect of flushing to zero when ftz is set.
This fixes a regression in
dEQP-VK.spirv_assembly.instruction.compute.float_controls.fp32.input_args.reflect_denorm_flush_to_zero
An add.ftz changes one of its arguments to negative rather than positive
zero starting in 8d19ffef0a ("nir: Add more matches for `fmulz`") on
that test, which was then triggering copy-prop which brought this
issue to light.
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13961
Fixes: 29bfdcd7 ("nak: Add an ftz bit to a bunch of float ops")
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Reviewed-by: Mary Guillemard <mary@mary.zone>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37537>
Based on git history thhese appears to be a subset of
`anv_batch_emit_batch`, so I've structured the code similarly, if
`anv_batch_emit_dwords` returns `nullptr`, we just move on without
copying the memory.
CID: 1665339
CID: 1664814
Reviewed-by: Iván Briano <ivan.briano@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37534>
Commit 534a04d557 optimized agx_resource_from_handle() to lazily
defer assignment of a kms-ro renderonly_scanout object to an imported
resource until its kms winsys handle is actually queried by a caller
via agx_resource_get_handle(), to avoid unnecessary import into the
DCP display controller. Only resources with bind flag PIPE_BIND_SCANOUT
will get a renderonly_scanout object assigned during such queries.
Problem: This prevents Mesa GBM's gbm_bo_import() function from properly
importing dmabufs for direct scanout use by some Wayland compositors,
e.g., GNOME mutter.
gbm_bo_import() of dmabuf fd's (GBM_BO_IMPORT_FD / GBM_BO_IMPORT_FD_MODIFIER),
even with GBM_BO_USE_SCANOUT flag, will not mark an imported bo with the
PIPE_BIND_SCANOUT bind flag before internally assigning its KMS winsys
handle via screen->resource_get_handle() -> agx_resource_get_handle(),
causing silent failure of that query. Therefore gbm_bo_import() seems
to return a successfully created gbm_bo with all proper properties,
but gbm_bo_get_handle() and gbm_bo_get_handle_for_plane() will return
invalid handles. These invalid handles cause drmAddFbXXX ioctl calls to
fail, and therefore failure of direct scanout of wl_buffers.
Setting PIPE_BIND_SCANOUT for a resource in agx_resource_from_handle()
may retain the optimization and makes gbm_bo_get_handle[_for_plane]()
work. This fixes direct scanout of fullscreen wl_surface / wl_buffers
under at least GNOME mutter 48.
Fixes: 534a04d557 ("asahi: Flip kmsro around to allocate on the GPU")
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37538>
If bo->size = lseek(); would return a failure value of bo->size ==-1,
then current error handling would return while leaving the already
allocated and cached bo for the dmabuf fd in a half initialized "zombie"
state. On a successive call to agx_bo_import() for the same fd, the
assigned bo->size == -1 would mark the bo as "already initialized",
just bumping its reference count, and then returning a dysfunctional
bo to the caller, leasing to followup failures elsewhere.
Use goto error; instead, where "error:" handling will zero-out the bo,
marking it as effectively uninitialized, and hopefully causing proper
initialization on a successive call to agx_bo_import().
Fixes: df725d4f64 ("asahi: remove agx_bo::dev")
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37538>
This broke after divergence became metadata because the divergence
analysis pass does not support all instructions.
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35069>
This would unconditionally invalid all metadata except
nir_metadata_control_flow and then invalidate that if opt_if_safe_cf_list
and opt_if_regs_cf_list made no progress.
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35069>
Only create nir_load_rt_arg_scratch_offset_amd if needed.
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35069>
For 3-component RGB images with OPTIMAL tiling, we need to create the
surface as RGBX or RGBA. When a host image copy to/from this image
happens, we calculate sizes and offsets based on the 4-component surface
and blow past the end of the 3-component API provided buffer.
Hilarity^WSegfault ensues.
Ideally we'd calculate the right sizes and have the tiled copy functions
handle the conversion, but they are format unaware and expect to just
copy bytes in blocks of equal sizes from both sides.
Handle this case by making an intermediate copy to/from linear RGB
from/to linear RGBX, and pass that intermediate slice to the tiled copy
functions.
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36453>
Per VUID-VkCopyImageToImageInfo-srcImage-09069,
srcImage and dstImage must have been created with identical image
creation parameters, so we are not going to have copies from color <->
depth/stencil, but we can copy both D/S aspects of an image at the same
time.
Nothing says that we can't copy from one plane of a multiplanar image to
another, so handle that case too (though nothing is currently testing
it).
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36453>