Commit Graph

77 Commits

Author SHA1 Message Date
Yonggang Luo
1ac1c0843f treewide: Replace usage of macro DEBUG with MESA_DEBUG when possible
This is achieved by the following steps:

#ifndef DEBUG => #if !MESA_DEBUG
defined(DEBUG) => MESA_DEBUG
#ifdef DEBUG => #if MESA_DEBUG

This is done by replace in vscode

excludes
docs,*.rs,addrlib,src/imgui,*.sh,src/intel/vulkan/grl/gpu

These are safe because those files should keep DEBUG macro is already excluded;
and not directly replace DEBUG, as we have some symbols around it.

Use debug or NDEBUG instead of DEBUG in comments when proper

This for reduce the usage of DEBUG,
so it's easier migrating to MESA_DEBUG

These are found when migrating DEBUG to MESA_DEBUG,
these are all comment update, so it's safe

Replace comment /* DEBUG */ and /* !DEBUG */ with proper /* MESA_DEBUG */ or /* !MESA_DEBUG */ manually

DEBUG || !NDEBUG -> MESA_DEBUG || !NDEBUG
!DEBUG && NDEBUG -> !(MESA_DEBUG || !NDEBUG)

Replace the DEBUG present in comment with proper new MESA_DEBUG manually

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: David Heidelberg <david.heidelberg@collabora.com>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28092>
2024-03-22 18:22:34 +00:00
Marek Olšák
bfdbfd6ade gallium: use u_box_3d to initialize pipe_box instead of non-designated initializers
This is the original utility for initializing pipe_box.
It prevents breakage when pipe_box fields are reordered.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27953>
2024-03-21 03:33:39 +00:00
Yonggang Luo
680e707534 treewide: Replace the invalid usage #if DEBUG with #ifdef DEBUG
This is done by find&replace and exclude the following folders in vscode
docs,*.rs,addrlib,src/imgui,*.sh,src/intel/vulkan/grl/gpu

This is a prepare step for re-working https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21946

These issues are found when to try switch DEBUG to MESA_DEBUG=0|1 in MR

https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28092

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28083>
2024-03-15 16:08:18 +00:00
Sil Vilerino
830561c575 d3d12: Only check D3D12_FEATURE_DATA_PLACED_RESOURCE_SUPPORT_INFO for D3D_FEATURE_LEVEL_1_0_GENERIC
Fixes: 55e377e965 ("d3d12: Add partial media, compute, graphics support with CORE and GENERIC feature levels")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28074>
2024-03-08 18:02:03 +00:00
Sil Vilerino
1b6d7ab80b d3d12: Add GetDesc wrapper for ID3D12Heap
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10779
Fixes: 55e377e965 ("d3d12: Add partial media, compute, graphics support with CORE and GENERIC feature levels")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28074>
2024-03-08 18:02:03 +00:00
Sil Vilerino
2074da0c39 d3d12: Refactor graphics functions from context and blit to separate files
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27997>
2024-03-06 23:06:59 +00:00
Sil Vilerino
55e377e965 d3d12: Add partial media, compute, graphics support with CORE and GENERIC feature levels
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27997>
2024-03-06 23:06:59 +00:00
Jesse Natalie
5c85cdd378 d3d12: Support R16G16B16A16_FLOAT display targets
Since GDI doesn't support this format, we need a fallback path to
get contents on-screen if we're not using DXGI. For that scenario,
we allocate a proxy display target and blit during frontbuffer flush.

Once we have that fallback in place, we can override the sw winsys
format support check for that format.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27512>
2024-02-15 17:56:45 +00:00
Sil Vilerino
0233cdd00d d3d12: Detect imported resource buffer unknown format
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26456>
2023-12-06 03:58:53 +00:00
Jesse Natalie
e61287888d d3d12: GL4.3
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26108>
2023-11-07 23:56:23 +00:00
Jesse Natalie
438be4f9a0 d3d12: Support ARB_texture_view
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26104>
2023-11-07 22:31:20 +00:00
Sil Vilerino
c3cf7f3e35 d3d12: Fix Map/Unmap of YUV resources
Restore transfer box original size after temporal per plane
dimension calculation.

Currently the returned transfer object on Map will have the
size (usually downsampled) of the latest plane instead of
the overall resource size. Then on unmap, when flushing the
changes the received transfer box has the wrong dimensions
and only partial data is flushed.

Fixes: 12a4f2c132 ("frontends/va: Also map VAImageBufferType for reading")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24909>
2023-08-28 13:15:55 -04:00
Yonggang Luo
137aa8b2dc util: Replace all usage of PIPE_TIMEOUT_INFINITE with OS_TIMEOUT_INFINITE
They are exactly the same, so it's safe to do the replace
Also gen OS_TIMEOUT_INFINITE var with rusticl_mesa_bindings_rs by OS_ prefix and
include "util/os_time.h" in rusticl/rusticl_mesa_bindings.h

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23401>
2023-06-05 05:12:02 +00:00
Caleb Cornett
97061dd7ee d3d12: Add support for Xbox GDK.
The big items in this patch:
- New screen file, to support the Xbox "windowing" system
- Lots of small macros/changes to support the Xbox D3D12 API without messing with the Win32 path too much
- A few changes to avoid requiring COM interfaces (the big one was QueryInterface which is unsupported)

Co-authored-by: Ethan Lee <flibitijibibo@gmail.com>
Co-authored-by: David Jacewicz <david.jacewicz@protonmail.com>
Co-authored-by: tieuchanlong <tieuchanlong@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19022>
2023-01-19 03:25:55 +00:00
Jesse Natalie
b4f2b244fa d3d12: Advertise PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19396>
2022-10-31 18:17:41 +00:00
Jesse Natalie
7118b2136e d3d12: Don't multiply cube array sizes by 6
Gallium already does this for us.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19357>
2022-10-27 23:17:47 +00:00
Damian Korczowski
5b47e32474 d3d12: Fix placed footprint of subresources
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19220>
2022-10-21 18:57:54 +00:00
Sil Vilerino
7ba94036f3 d3d12: Create d3d12_resource objects for video usage keeping their DXGI_..._UNORM formats
Do not set D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS nor convert
new d3d12_resource objects to their DXGI typeless formats for video
usage flagged by the video driver with PIPE_BIND_CUSTOM

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19206>
2022-10-20 20:37:10 +00:00
Sil Vilerino
e08df85923 d3d12: resource_from_handle to validate importing resource ptr from same d3d12 device
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19063>
2022-10-19 00:45:48 +00:00
Sil Vilerino
59c45e1ed7 d3d12: Fix leak in d3d12_resource_from_resource and usage in d3d12 video dec, enc
Reviewed-by: Giancarlo Devich <gdevich@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18328>
2022-09-15 11:19:39 -04:00
Sil Vilerino
cdd83c6110 d3d12: Fix winsys displaytarget leak in d3d12_resource
Reviewed-by: Giancarlo Devich <gdevich@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18328>
2022-09-15 11:19:39 -04:00
Jesse Natalie
aa94e0b37c d3d12: Rename bind invalidate options to transition flags
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17688>
2022-07-22 14:42:56 +00:00
Jesse Natalie
f972a57b0b d3d12: Treat depth/stencil as planar for plane count helper
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17688>
2022-07-22 14:42:56 +00:00
Jesse Natalie
17c3f4f3e1 d3d12: Give bos a unique identifier to be used for state tracking
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17688>
2022-07-22 14:42:56 +00:00
Jesse Natalie
e14beaf05b d3d12: Add helpers to build with correct ABI for MinGW
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17548>
2022-07-15 16:27:11 +00:00
Jesse Natalie
333432310a d3d12: Fix up resource import validation
Format on buffers is irrelevant and bind flag validation needs to be disabled.

Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-by: Giancarlo Devich <gdevich@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17446>
2022-07-14 03:45:17 +00:00
Jesse Natalie
e3e22ce882 d3d12: Support opening resources and memobj by name
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-by: Giancarlo Devich <gdevich@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17446>
2022-07-14 03:45:17 +00:00
Jesse Natalie
d462325895 d3d12: Implement resource_from_memobj
If the memobj wraps a resource, then we only succeed the
mapping operation if the gallium desc matches the D3D12
resource desc.

If the memobj wraps a heap, then we can place whatever
gallium is describing on the heap.

Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-by: Giancarlo Devich <gdevich@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17446>
2022-07-14 03:45:17 +00:00
Jesse Natalie
bd0407a4a6 d3d12: Support creating memory objects
They can wrap either an opened heap or resource

Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-by: Giancarlo Devich <gdevich@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17446>
2022-07-14 03:45:17 +00:00
Jesse Natalie
c87d7cfaad d3d12: PIPE_BIND_SHARED doesn't mean linear and is always on opened resources
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-by: Giancarlo Devich <gdevich@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17446>
2022-07-14 03:45:17 +00:00
Yonggang Luo
d493e2ef7d d3d12: Move shared code that include d3d12 headers into d3d12_common.h
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16767>
2022-06-03 16:33:00 +00:00
Jesse Natalie
4b34869d9d d3d12: Don't use VLAs
Fixes: 739283da ("d3d12: Improve planar resource support to handle video requirements")
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16588>
2022-05-18 09:28:47 -07:00
Sil Vilerino
739283da13 d3d12: Improve planar resource support to handle video requirements
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16286>
2022-05-17 21:02:25 +00:00
Jesse Natalie
32c1b5fd05 d3d12: Fix leaks in map with do-not-wait
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16182>
2022-05-02 16:58:20 +00:00
Pierre-Eric Pelloux-Prayer
b83bbd6f7f d3d12: replace opencoded slab_zalloc
Acked-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15277>
2022-03-21 09:47:58 +01:00
Pierre-Eric Pelloux-Prayer
cd0ef9b3f4 gallium/u_threaded: late alloc cpu_storage
Instead of allocating cpu_storage in threaded_resource_init, defer the
allocation to first use (in tc_buffer_map).
This avoids needless memory allocation if tc_buffer_disable_cpu_storage is
called before tc_buffer_map.

map_buffer_alignment is stored and serves as a "can cpu_storage be used" flag.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15074>
2022-03-07 14:51:15 +01:00
Jesse Natalie
22fc534930 d3d12: Default newly-created resources to not-resident
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14959>
2022-02-10 20:06:15 +00:00
Jesse Natalie
671deb541e d3d12: Add residency info to d3d12_bo
This is all currently immutable, but will be used to manage the
residency of the underlying D3D objects in a future commit.

Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14959>
2022-02-10 20:06:15 +00:00
Jesse Natalie
5cbd7093af d3d12: When mapping a resource used in the current batch without blocking, at least flush
Also, resource_is_busy needs to opportunistically retire batches, so apps can
spin on non-blocking resource maps and eventually succeed.

Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14959>
2022-02-10 20:06:15 +00:00
Jesse Natalie
52766e020f d3d12: Use CPU storage in TC for buffers
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14933>
2022-02-08 20:36:29 +00:00
Jesse Natalie
9d6febad5d d3d12: Actually suballocate and cache buffers
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14933>
2022-02-08 20:36:29 +00:00
Jesse Natalie
d0f4f8efae d3d12: Fix offset for buf/image copies with suballocated buffers
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14933>
2022-02-08 20:36:29 +00:00
Jesse Natalie
fb08bc8d76 d3d12: Don't suballocate TBO buffers
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14933>
2022-02-08 20:36:29 +00:00
Jesse Natalie
c35f77aa84 d3d12: Delete make_resource_writeable
This never did anything useful AFAICT since we didn't actually
suballocate buffers, and when this ended up being invoked it breaks
the ability to read back XFB data.

Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14933>
2022-02-08 20:36:29 +00:00
Jesse Natalie
1d43e75228 d3d12: Add UAV barriers for UAVs that are being used by compute transforms
If an indirect arg buffer is being produced by a compute shader, then when
we go to consume it as an SSBO in a compute transform pass, we need to insert
a UAV barrier to prevent the two dispatches from overlapping. For app dispatches,
this is the app's responsibility via explicit barrier APIs, and if they don't,
then they're allowed to overlap.

Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14787>
2022-01-31 13:13:33 -08:00
Jesse Natalie
23918d933e d3d12: When mapping a non-directly-mappable resource for write, readback first
For non-discard writes, we need to make sure that the resource has valid contents
so they can be *updated*, not overwritten.

We have to skip this when doing asynchronous maps, but that should be okay, because
the threading context should only do asynchronous map-write when the resource is
known to be idle/empty.

Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14624>
2022-01-21 23:08:26 +00:00
Jesse Natalie
0f8213cb10 d3d12: Handle bitcasting of shader images
This is handled in 2 ways:
* For casts in the same "class," we can just do the cast. There's also
  limited support for 4x8 => 1x32 and 2x16 => 1x32.
* For casts that are just by size, use a lowering pass. This reads the
  data in the appropriate UINT format (except R11G11B10), retrieves
  the original bits, re-packs it into the dest, and returns it to the
  app for loads. For stores, the process is done in reverse - bits
  for the final format are computed and re-expanded to the format that
  should be used for the store.

Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14342>
2022-01-07 03:31:16 +00:00
Jesse Natalie
ef44b93914 d3d12: Create textures as UAV-capable when appropriate
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14342>
2022-01-07 03:31:16 +00:00
Jesse Natalie
664810ebb0 d3d12: Fix NV12 resource importing
Fixes: a6db8054 ("d3d12: Handle opening planar resources")
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14276>
2021-12-21 16:56:45 +00:00
Jesse Natalie
0312142d96 d3d12: Allow creating planar resources
Also handle opening planar resources with a single handle, instead
of per-plane handles.

Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14123>
2021-12-08 20:46:22 +00:00