rusticl/queue: properly implement clCreateCommandQueueWithProperties
authorKarol Herbst <git@karolherbst.de>
Fri, 1 Sep 2023 09:10:28 +0000 (11:10 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 1 Sep 2023 13:51:22 +0000 (13:51 +0000)
It didn't do any of the error checking, but it was supposed to be. Also
the error checking was slightly wrong and we should return
CL_INVALID_QUEUE_PROPERTIES instead of CL_INVALID_VALUE for unsupported
properties.

Signed-off-by: Karol Herbst <git@karolherbst.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24991>

src/gallium/frontends/rusticl/api/queue.rs

index d3a734a..01e8e11 100644 (file)
@@ -41,8 +41,12 @@ impl CLInfo<cl_command_queue_info> for cl_command_queue {
 }
 
 fn valid_command_queue_properties(properties: cl_command_queue_properties) -> bool {
-    let valid_flags =
-        cl_bitfield::from(CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_PROFILING_ENABLE);
+    let valid_flags = cl_bitfield::from(
+        CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
+            | CL_QUEUE_PROFILING_ENABLE
+            | CL_QUEUE_ON_DEVICE
+            | CL_QUEUE_ON_DEVICE_DEFAULT,
+    );
     properties & !valid_flags == 0
 }
 
@@ -110,9 +114,6 @@ fn create_command_queue_with_properties(
     device: cl_device_id,
     properties: *const cl_queue_properties,
 ) -> CLResult<cl_command_queue> {
-    let c = context.get_arc()?;
-    let d = device.get_ref()?.to_static().ok_or(CL_INVALID_DEVICE)?;
-
     let mut queue_properties = cl_command_queue_properties::default();
     let properties = if properties.is_null() {
         None
@@ -132,12 +133,7 @@ fn create_command_queue_with_properties(
         Some(properties)
     };
 
-    Ok(cl_command_queue::from_arc(Queue::new(
-        c,
-        d,
-        queue_properties,
-        properties,
-    )?))
+    create_command_queue_impl(context, device, queue_properties, properties)
 }
 
 #[cl_entrypoint]