Commit graph

31 commits

Author SHA1 Message Date
Karol Herbst
301afbc313 rusticl: remove unecessary transmutes around uuids
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38807>
2025-12-20 00:13:19 +01:00
Karol Herbst
5fe097a844 rusticl: add SPDX tags
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Using MIT as mesa is MIT by default.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36856>
2025-08-23 11:19:57 +00:00
Seán de Búrca
543b07bee8 rusticl: write CLInfoValues from iterators instead of collecting
All of the current instances of writing info values from `Vec`s involve
building an iterator and then collecting it specifically for writing.
By using an `ExactSizeIterator`, we can avoid the need for allocating in
these cases.

v2: use existing `CLInfoValue::write_iter()` instead of custom type

Reviewed-by: @LingMan
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34389>
2025-05-16 19:58:31 +00:00
Seán de Búrca
2c202eb787 rusticl: verify validity of property names and values
v2: separate from using type aliases based on signature and reorder
v3: verify validity in two additional locations

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: @LingMan
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34167>
2025-04-24 14:23:05 +00:00
Karol Herbst
12752228db rusticl/util: rename Properties::from_ptr to new
Reviewed-by: @LingMan
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32268>
2024-12-04 16:20:08 +00:00
Karol Herbst
825936b3f8 rusticl/util: make Properties::from_ptr unsafe
Reviewed-by: @LingMan
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32268>
2024-12-04 16:20:07 +00:00
Karol Herbst
b4b01498a6 rusticl/util: add Properties::iter()
Reviewed-by: @LingMan
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32268>
2024-12-04 16:20:07 +00:00
Karol Herbst
ef9910df4f rusticl/api: mark get_info and get_info_obj as unsafe
Reviewed-by: @LingMan
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32268>
2024-12-04 16:20:07 +00:00
Karol Herbst
3a155a4591 rusticl/context: use write_iter for CL_DEVICES_FOR_GL_CONTEXT_KHR
Reviewed-by: @LingMan
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32268>
2024-12-04 16:20:07 +00:00
Karol Herbst
008caff86d rusticl: rework query APIs
The old way was quite annoying as it required to create a Vec to even get
the size of the result causing needless computations.

This also meant that copying into the result buffer always required to go
through a byte Vec even though we could just do the copy directly.

The main idea here is that instead of returning the result, we simply call
into a write function giving us more flexibility here.

Potentially this will also allow us to add overloads for Iterators or to
even use closures in case the size calculation is cheaper than creating
the value just to get the size.

Reviewed-by: @LingMan
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32268>
2024-12-04 16:20:07 +00:00
Karol Herbst
cdd604583f rusticl/icd: rename all entry points to the actual correct name
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29855>
2024-06-22 23:40:15 +00:00
Karol Herbst
57e5d377da rusticl/icd: move from_arc() and rename it
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27376>
2024-02-14 14:15:38 +00:00
Karol Herbst
51afd7a00c rusticl/device: deduplicate devices with sorting
a HashSet was kinda overkill here to begin with.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27376>
2024-02-14 14:15:38 +00:00
Karol Herbst
e63e21ac74 rusticl/icd: move get_ref()
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27376>
2024-02-14 14:15:38 +00:00
Karol Herbst
9b5bcbb60f rusticl/icd: move retain() and release()
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27376>
2024-02-14 14:15:38 +00:00
Karol Herbst
45b9fdb4e5 rusticl/icd: move refcnt() and get rid of needless atomic ops
The old impl used `get_arc` which internally calls into
`Arc::increment_strong_count` in order to protect against Arc::drop
deallocating our objects. We could also just not do that :)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27376>
2024-02-14 14:15:38 +00:00
Karol Herbst
98df65a875 rusticl: only support the matching device for gl_sharing
Cross vendor is bogus because of modifier screw ups. We could allow it on
all devices from the same vendor, but for that we have to check if the
supported modifiers match.

Also verify the device in questions actually supports gl_sharing.

Fixes: 57dfc013a6 ("rusticl: Add functions to create CL ctxs from GL, and also to query them")
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Antonio Gomes <antoniospg100@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26051>
2023-11-06 23:47:18 +00:00
Antonio Gomes
57dfc013a6 rusticl: Add functions to create CL ctxs from GL, and also to query them
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21305>
2023-11-04 01:28:42 +00:00
LingMan
250f6e9b2e rusticl: use DeleteContextCB
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25669>
2023-10-15 00:17:10 +00:00
LingMan
f34ff1daa5 rusticl: use CreateContextCB
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25669>
2023-10-15 00:17:10 +00:00
LingMan
157c743a27 rusticl: Rename XyzCB aliases to FuncXyzCB
This happens so the XyzCB names can be used for structs containing both the function pointer and
the provided user data. Since these aliases represent raw unsafe function pointers the `Func`
prefix was chosen over `Fn`, which is generally used for safe functions.

Unfortunately it is not possible to concatinate identifiers to create new ones without a proc macro.
Thus, specify the new alias manually instead of generating them from the existing XyzCB names.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25669>
2023-10-15 00:17:10 +00:00
Karol Herbst
d653eb8a9a rusticl/device: make it &'static
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24061>
2023-07-12 15:18:22 +00:00
Karol Herbst
afe95b613c rusticl: Replace &Arc<Device> with &Device
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24061>
2023-07-12 15:18:22 +00:00
LingMan
0535948535 rusticl: fix UB in CLProp machinery
Viewing structs as a collection of u8 is not generally sound. Any padding bytes might be
uninitialized and creating an integer from uninitialized memory constitutes producing an invalid
value, which is instant UB.

Since we only copy these bytes around, the fix is to simply work with MaybeUninit<u8>, which can handle uninitialized memory just fine, instead.

See: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23652>
2023-06-15 02:31:19 +00:00
Karol Herbst
948970c1eb rusticl/icd: use new proc macros
This drops quite a lot of boilerplate code as this is now all generated
via our proc macros.

Signed-off-by: Karol Herbst <git@karolherbst.de>
Reviewed by Nora Allen <blackcatgames@protonmail.com>

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23413>
2023-06-09 10:35:24 +00:00
Karol Herbst
11250d7a9e rusticl: split platform into core and api parts
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22280>
2023-04-13 02:54:20 +00:00
Karol Herbst
7f80350d55 rusticl: port to Rust 2018
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15439>
2022-09-12 05:58:13 +00:00
Karol Herbst
c0af2f5d76 rusticl/mem: implement clCreateSamplerWithProperties
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15439>
2022-09-12 05:58:13 +00:00
Karol Herbst
e1fefd5372 rusticl/context: implement clSetContextDestructorCallback
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15439>
2022-09-12 05:58:12 +00:00
Karol Herbst
84d16045d0 rusticl/api: add param to query which contains application provided values
this is required for e.g. CL_PROGRAM_BINARIES

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15439>
2022-09-12 05:58:12 +00:00
Karol Herbst
20c90fed5a rusticl: added
Initial code drop for Rusticl :)

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15439>
2022-09-12 05:58:12 +00:00