mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 05:08:08 +02:00
rusticl/api: remove Option around Properties
It already has the right semantics we are looking for. Reviewed-by: @LingMan Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32268>
This commit is contained in:
parent
825936b3f8
commit
d791135df1
4 changed files with 32 additions and 45 deletions
|
|
@ -948,9 +948,7 @@ unsafe impl CLInfo<cl_sampler_info> for cl_sampler {
|
|||
CL_SAMPLER_FILTER_MODE => v.write::<cl_filter_mode>(sampler.filter_mode),
|
||||
CL_SAMPLER_NORMALIZED_COORDS => v.write::<bool>(sampler.normalized_coords),
|
||||
CL_SAMPLER_REFERENCE_COUNT => v.write::<cl_uint>(Sampler::refcnt(*self)?),
|
||||
CL_SAMPLER_PROPERTIES => {
|
||||
v.write::<Option<&Properties<cl_sampler_properties>>>(sampler.props.as_ref())
|
||||
}
|
||||
CL_SAMPLER_PROPERTIES => v.write::<&Properties<cl_sampler_properties>>(&sampler.props),
|
||||
// CL_INVALID_VALUE if param_name is not one of the supported values
|
||||
_ => Err(CL_INVALID_VALUE),
|
||||
}
|
||||
|
|
@ -962,7 +960,7 @@ fn create_sampler_impl(
|
|||
normalized_coords: cl_bool,
|
||||
addressing_mode: cl_addressing_mode,
|
||||
filter_mode: cl_filter_mode,
|
||||
props: Option<Properties<cl_sampler_properties>>,
|
||||
props: Properties<cl_sampler_properties>,
|
||||
) -> CLResult<cl_sampler> {
|
||||
let c = Context::arc_from_raw(context)?;
|
||||
|
||||
|
|
@ -1000,7 +998,7 @@ fn create_sampler(
|
|||
normalized_coords,
|
||||
addressing_mode,
|
||||
filter_mode,
|
||||
None,
|
||||
Properties::default(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -1014,24 +1012,19 @@ fn create_sampler_with_properties(
|
|||
let mut filter_mode = CL_FILTER_NEAREST;
|
||||
|
||||
// CL_INVALID_VALUE if the same property name is specified more than once.
|
||||
let sampler_properties = if sampler_properties.is_null() {
|
||||
None
|
||||
} else {
|
||||
// SAFETY: sampler_properties is a 0 terminated array by spec.
|
||||
let sampler_properties =
|
||||
unsafe { Properties::from_ptr(sampler_properties) }.ok_or(CL_INVALID_VALUE)?;
|
||||
for (&key, &val) in sampler_properties.iter() {
|
||||
match key as u32 {
|
||||
CL_SAMPLER_ADDRESSING_MODE => addressing_mode = val as u32,
|
||||
CL_SAMPLER_FILTER_MODE => filter_mode = val as u32,
|
||||
CL_SAMPLER_NORMALIZED_COORDS => normalized_coords = val as u32,
|
||||
// CL_INVALID_VALUE if the property name in sampler_properties is not a supported
|
||||
// property name
|
||||
_ => return Err(CL_INVALID_VALUE),
|
||||
}
|
||||
// SAFETY: sampler_properties is a 0 terminated array by spec.
|
||||
let sampler_properties =
|
||||
unsafe { Properties::from_ptr(sampler_properties) }.ok_or(CL_INVALID_VALUE)?;
|
||||
for (&key, &val) in sampler_properties.iter() {
|
||||
match key as u32 {
|
||||
CL_SAMPLER_ADDRESSING_MODE => addressing_mode = val as u32,
|
||||
CL_SAMPLER_FILTER_MODE => filter_mode = val as u32,
|
||||
CL_SAMPLER_NORMALIZED_COORDS => normalized_coords = val as u32,
|
||||
// CL_INVALID_VALUE if the property name in sampler_properties is not a supported
|
||||
// property name
|
||||
_ => return Err(CL_INVALID_VALUE),
|
||||
}
|
||||
Some(sampler_properties)
|
||||
};
|
||||
}
|
||||
|
||||
create_sampler_impl(
|
||||
context,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ unsafe impl CLInfo<cl_command_queue_info> for cl_command_queue {
|
|||
CL_QUEUE_DEVICE_DEFAULT => v.write::<cl_command_queue>(ptr::null_mut()),
|
||||
CL_QUEUE_PROPERTIES => v.write::<cl_command_queue_properties>(queue.props),
|
||||
CL_QUEUE_PROPERTIES_ARRAY => {
|
||||
v.write::<Option<&Properties<cl_queue_properties>>>(queue.props_v2.as_ref())
|
||||
v.write::<&Properties<cl_queue_properties>>(&queue.props_v2)
|
||||
}
|
||||
CL_QUEUE_REFERENCE_COUNT => v.write::<cl_uint>(Queue::refcnt(*self)?),
|
||||
// clGetCommandQueueInfo, passing CL_QUEUE_SIZE Returns CL_INVALID_COMMAND_QUEUE since
|
||||
|
|
@ -88,7 +88,7 @@ pub fn create_command_queue_impl(
|
|||
context: cl_context,
|
||||
device: cl_device_id,
|
||||
properties: cl_command_queue_properties,
|
||||
properties_v2: Option<Properties<cl_queue_properties>>,
|
||||
properties_v2: Properties<cl_queue_properties>,
|
||||
) -> CLResult<cl_command_queue> {
|
||||
let c = Context::arc_from_raw(context)?;
|
||||
let d = Device::ref_from_raw(device)?
|
||||
|
|
@ -119,7 +119,7 @@ fn create_command_queue(
|
|||
device: cl_device_id,
|
||||
properties: cl_command_queue_properties,
|
||||
) -> CLResult<cl_command_queue> {
|
||||
create_command_queue_impl(context, device, properties, None)
|
||||
create_command_queue_impl(context, device, properties, Properties::default())
|
||||
}
|
||||
|
||||
#[cl_entrypoint(clCreateCommandQueueWithProperties)]
|
||||
|
|
@ -129,24 +129,18 @@ fn create_command_queue_with_properties(
|
|||
properties: *const cl_queue_properties,
|
||||
) -> CLResult<cl_command_queue> {
|
||||
let mut queue_properties = cl_command_queue_properties::default();
|
||||
let properties = if properties.is_null() {
|
||||
None
|
||||
} else {
|
||||
// SAFETY: properties is a 0 terminated array by spec.
|
||||
let properties = unsafe { Properties::from_ptr(properties) }.ok_or(CL_INVALID_PROPERTY)?;
|
||||
|
||||
for (k, v) in properties.iter() {
|
||||
match *k as cl_uint {
|
||||
CL_QUEUE_PROPERTIES => queue_properties = *v,
|
||||
// CL_INVALID_QUEUE_PROPERTIES if values specified in properties are valid but are not
|
||||
// supported by the device.
|
||||
CL_QUEUE_SIZE => return Err(CL_INVALID_QUEUE_PROPERTIES),
|
||||
_ => return Err(CL_INVALID_PROPERTY),
|
||||
}
|
||||
// SAFETY: properties is a 0 terminated array by spec.
|
||||
let properties = unsafe { Properties::from_ptr(properties) }.ok_or(CL_INVALID_PROPERTY)?;
|
||||
for (k, v) in properties.iter() {
|
||||
match *k as cl_uint {
|
||||
CL_QUEUE_PROPERTIES => queue_properties = *v,
|
||||
// CL_INVALID_QUEUE_PROPERTIES if values specified in properties are valid but are not
|
||||
// supported by the device.
|
||||
CL_QUEUE_SIZE => return Err(CL_INVALID_QUEUE_PROPERTIES),
|
||||
_ => return Err(CL_INVALID_PROPERTY),
|
||||
}
|
||||
|
||||
Some(properties)
|
||||
};
|
||||
}
|
||||
|
||||
create_command_queue_impl(context, device, queue_properties, properties)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1615,7 +1615,7 @@ pub struct Sampler {
|
|||
pub normalized_coords: bool,
|
||||
pub addressing_mode: cl_addressing_mode,
|
||||
pub filter_mode: cl_filter_mode,
|
||||
pub props: Option<Properties<cl_sampler_properties>>,
|
||||
pub props: Properties<cl_sampler_properties>,
|
||||
}
|
||||
|
||||
impl_cl_type_trait!(cl_sampler, Sampler, CL_INVALID_SAMPLER);
|
||||
|
|
@ -1626,7 +1626,7 @@ impl Sampler {
|
|||
normalized_coords: bool,
|
||||
addressing_mode: cl_addressing_mode,
|
||||
filter_mode: cl_filter_mode,
|
||||
props: Option<Properties<cl_sampler_properties>>,
|
||||
props: Properties<cl_sampler_properties>,
|
||||
) -> Arc<Sampler> {
|
||||
Arc::new(Self {
|
||||
base: CLObjectBase::new(RusticlTypes::Sampler),
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ pub struct Queue {
|
|||
pub context: Arc<Context>,
|
||||
pub device: &'static Device,
|
||||
pub props: cl_command_queue_properties,
|
||||
pub props_v2: Option<Properties<cl_queue_properties>>,
|
||||
pub props_v2: Properties<cl_queue_properties>,
|
||||
state: Mutex<QueueState>,
|
||||
_thrd: JoinHandle<()>,
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ impl Queue {
|
|||
context: Arc<Context>,
|
||||
device: &'static Device,
|
||||
props: cl_command_queue_properties,
|
||||
props_v2: Option<Properties<cl_queue_properties>>,
|
||||
props_v2: Properties<cl_queue_properties>,
|
||||
) -> CLResult<Arc<Queue>> {
|
||||
// we assume that memory allocation is the only possible failure. Any other failure reason
|
||||
// should be detected earlier (e.g.: checking for CAPs).
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue