From 667375999c7ecaf018eff6fdaceaa6dfd847636f Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Tue, 29 Aug 2023 20:30:21 +0200 Subject: [PATCH] rusticl/event: disable profiling for devices without timestamps Timestamp queries are strictly required, but a bit odd to not expose CL for not supporting it... Part-of: --- src/gallium/frontends/rusticl/api/queue.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/gallium/frontends/rusticl/api/queue.rs b/src/gallium/frontends/rusticl/api/queue.rs index 2402178366b..d3a734a3d86 100644 --- a/src/gallium/frontends/rusticl/api/queue.rs +++ b/src/gallium/frontends/rusticl/api/queue.rs @@ -1,6 +1,7 @@ use crate::api::event::create_and_queue; use crate::api::icd::*; use crate::api::util::*; +use crate::core::device::*; use crate::core::event::*; use crate::core::queue::*; @@ -45,9 +46,21 @@ fn valid_command_queue_properties(properties: cl_command_queue_properties) -> bo properties & !valid_flags == 0 } -fn supported_command_queue_properties(properties: cl_command_queue_properties) -> bool { - let valid_flags = cl_bitfield::from(CL_QUEUE_PROFILING_ENABLE); - properties & !valid_flags == 0 +fn supported_command_queue_properties( + dev: &Device, + properties: cl_command_queue_properties, +) -> bool { + let profiling = cl_bitfield::from(CL_QUEUE_PROFILING_ENABLE); + let valid_flags = profiling; + if properties & !valid_flags != 0 { + return false; + } + + if properties & profiling != 0 && !dev.has_timestamp { + return false; + } + + true } pub fn create_command_queue_impl( @@ -70,7 +83,7 @@ pub fn create_command_queue_impl( } // CL_INVALID_QUEUE_PROPERTIES if values specified in properties are valid but are not supported by the device. - if !supported_command_queue_properties(properties) { + if !supported_command_queue_properties(d, properties) { return Err(CL_INVALID_QUEUE_PROPERTIES); }