From a7966f693b9f3d2e11edad7dfeb690fc24ee89ad Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Sat, 30 Aug 2025 17:51:45 +0200 Subject: [PATCH] rusticl/device: add DeviceCaps::has_create_fence_fd and use it Device::is_gl_sharing_supported was calling helper_ctx() but that can block randomly for any reason, so let's not do that. Part-of: --- src/gallium/frontends/rusticl/core/device.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/gallium/frontends/rusticl/core/device.rs b/src/gallium/frontends/rusticl/core/device.rs index 0bc15728161..77ddb5faad7 100644 --- a/src/gallium/frontends/rusticl/core/device.rs +++ b/src/gallium/frontends/rusticl/core/device.rs @@ -75,6 +75,7 @@ impl Deref for Device { #[derive(Default)] pub struct DeviceCaps { pub has_3d_image_writes: bool, + has_create_fence_fd: bool, pub has_depth_images: bool, pub has_image_unorm_int_2_101010: bool, pub has_images: bool, @@ -87,7 +88,7 @@ pub struct DeviceCaps { } impl DeviceCaps { - fn new(screen: &PipeScreen) -> Self { + fn new(screen: &PipeScreen, ctx: &PipeContext) -> Self { let cap_timestamp = screen.caps().query_timestamp; let timer_resolution = screen.caps().timer_resolution; @@ -111,6 +112,7 @@ impl DeviceCaps { max_read_images: has_images.then_some(max_read_images).unwrap_or_default(), max_write_images: has_images.then_some(max_write_images).unwrap_or_default(), timer_resolution: timer_resolution, + has_create_fence_fd: ctx.is_create_fence_fd_supported(), ..Default::default() } } @@ -153,7 +155,6 @@ pub trait HelperContextWrapper { rw: RWFlags, ) -> Option>; - fn is_create_fence_fd_supported(&self) -> bool; fn import_fence(&self, fence_fd: &FenceFd, fence_type: pipe_fd_type) -> CLResult; } @@ -245,10 +246,6 @@ impl HelperContextWrapper for HelperContext<'_> { .texture_map_flags(res, bx, pipe_map_flags::PIPE_MAP_UNSYNCHRONIZED | rw.into()) } - fn is_create_fence_fd_supported(&self) -> bool { - self.lock.is_create_fence_fd_supported() - } - fn import_fence(&self, fd: &FenceFd, fence_type: pipe_fd_type) -> CLResult { self.lock .import_fence(fd, fence_type) @@ -887,7 +884,7 @@ impl DeviceBase { && !self.is_device_software() && self.screen.is_res_handle_supported() && self.screen.device_uuid().is_some() - && self.helper_ctx().is_create_fence_fd_supported() + && self.caps.has_create_fence_fd } pub fn is_device_software(&self) -> bool { @@ -1269,7 +1266,7 @@ impl Device { // context being created. let helper_ctx = screen.create_context(PipeContextPrio::Med)?; let mut dev_base = DeviceBase { - caps: DeviceCaps::new(&screen), + caps: DeviceCaps::new(&screen, &helper_ctx), helper_ctx: Mutex::new(helper_ctx), screen: screen, cl_version: CLVersion::Cl3_0,