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>
This commit is contained in:
@@ -17,7 +17,7 @@ use std::slice;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
impl CLInfo<cl_context_info> for cl_context {
|
impl CLInfo<cl_context_info> for cl_context {
|
||||||
fn query(&self, q: cl_context_info) -> CLResult<Vec<u8>> {
|
fn query(&self, q: cl_context_info, _: &[u8]) -> CLResult<Vec<u8>> {
|
||||||
let ctx = self.get_ref()?;
|
let ctx = self.get_ref()?;
|
||||||
Ok(match q {
|
Ok(match q {
|
||||||
CL_CONTEXT_DEVICES => {
|
CL_CONTEXT_DEVICES => {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use std::sync::Arc;
|
|||||||
use std::sync::Once;
|
use std::sync::Once;
|
||||||
|
|
||||||
impl CLInfo<cl_device_info> for cl_device_id {
|
impl CLInfo<cl_device_info> for cl_device_id {
|
||||||
fn query(&self, q: cl_device_info) -> CLResult<Vec<u8>> {
|
fn query(&self, q: cl_device_info, _: &[u8]) -> CLResult<Vec<u8>> {
|
||||||
let dev = self.get_ref()?;
|
let dev = self.get_ref()?;
|
||||||
Ok(match q {
|
Ok(match q {
|
||||||
CL_DEVICE_ADDRESS_BITS => cl_prop::<cl_uint>(dev.address_bits()),
|
CL_DEVICE_ADDRESS_BITS => cl_prop::<cl_uint>(dev.address_bits()),
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use std::ptr;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
impl CLInfo<cl_event_info> for cl_event {
|
impl CLInfo<cl_event_info> for cl_event {
|
||||||
fn query(&self, q: cl_event_info) -> CLResult<Vec<u8>> {
|
fn query(&self, q: cl_event_info, _: &[u8]) -> CLResult<Vec<u8>> {
|
||||||
let event = self.get_ref()?;
|
let event = self.get_ref()?;
|
||||||
Ok(match q {
|
Ok(match q {
|
||||||
CL_EVENT_COMMAND_EXECUTION_STATUS => cl_prop::<cl_int>(event.status()),
|
CL_EVENT_COMMAND_EXECUTION_STATUS => cl_prop::<cl_int>(event.status()),
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use std::slice;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
impl CLInfo<cl_kernel_info> for cl_kernel {
|
impl CLInfo<cl_kernel_info> for cl_kernel {
|
||||||
fn query(&self, q: cl_kernel_info) -> CLResult<Vec<u8>> {
|
fn query(&self, q: cl_kernel_info, _: &[u8]) -> CLResult<Vec<u8>> {
|
||||||
let kernel = self.get_ref()?;
|
let kernel = self.get_ref()?;
|
||||||
Ok(match q {
|
Ok(match q {
|
||||||
CL_KERNEL_CONTEXT => {
|
CL_KERNEL_CONTEXT => {
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ fn validate_matching_buffer_flags(mem: &Mem, flags: cl_mem_flags) -> CLResult<()
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CLInfo<cl_mem_info> for cl_mem {
|
impl CLInfo<cl_mem_info> for cl_mem {
|
||||||
fn query(&self, q: cl_mem_info) -> CLResult<Vec<u8>> {
|
fn query(&self, q: cl_mem_info, _: &[u8]) -> CLResult<Vec<u8>> {
|
||||||
let mem = self.get_ref()?;
|
let mem = self.get_ref()?;
|
||||||
Ok(match *q {
|
Ok(match *q {
|
||||||
CL_MEM_ASSOCIATED_MEMOBJECT => {
|
CL_MEM_ASSOCIATED_MEMOBJECT => {
|
||||||
@@ -629,7 +629,7 @@ fn validate_buffer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CLInfo<cl_image_info> for cl_mem {
|
impl CLInfo<cl_image_info> for cl_mem {
|
||||||
fn query(&self, q: cl_image_info) -> CLResult<Vec<u8>> {
|
fn query(&self, q: cl_image_info, _: &[u8]) -> CLResult<Vec<u8>> {
|
||||||
let mem = self.get_ref()?;
|
let mem = self.get_ref()?;
|
||||||
Ok(match *q {
|
Ok(match *q {
|
||||||
CL_IMAGE_ARRAY_SIZE => cl_prop::<usize>(mem.image_desc.image_array_size),
|
CL_IMAGE_ARRAY_SIZE => cl_prop::<usize>(mem.image_desc.image_array_size),
|
||||||
@@ -742,7 +742,7 @@ pub fn get_supported_image_formats(
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CLInfo<cl_sampler_info> for cl_sampler {
|
impl CLInfo<cl_sampler_info> for cl_sampler {
|
||||||
fn query(&self, q: cl_sampler_info) -> CLResult<Vec<u8>> {
|
fn query(&self, q: cl_sampler_info, _: &[u8]) -> CLResult<Vec<u8>> {
|
||||||
let sampler = self.get_ref()?;
|
let sampler = self.get_ref()?;
|
||||||
Ok(match q {
|
Ok(match q {
|
||||||
CL_SAMPLER_ADDRESSING_MODE => cl_prop::<cl_addressing_mode>(sampler.addressing_mode),
|
CL_SAMPLER_ADDRESSING_MODE => cl_prop::<cl_addressing_mode>(sampler.addressing_mode),
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ pub struct _cl_platform_id {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CLInfo<cl_platform_info> for cl_platform_id {
|
impl CLInfo<cl_platform_info> for cl_platform_id {
|
||||||
fn query(&self, q: cl_platform_info) -> CLResult<Vec<u8>> {
|
fn query(&self, q: cl_platform_info, _: &[u8]) -> CLResult<Vec<u8>> {
|
||||||
let p = self.get_ref()?;
|
let p = self.get_ref()?;
|
||||||
Ok(match q {
|
Ok(match q {
|
||||||
CL_PLATFORM_EXTENSIONS => cl_prop("cl_khr_icd"),
|
CL_PLATFORM_EXTENSIONS => cl_prop("cl_khr_icd"),
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use std::slice;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
impl CLInfo<cl_program_info> for cl_program {
|
impl CLInfo<cl_program_info> for cl_program {
|
||||||
fn query(&self, q: cl_program_info) -> CLResult<Vec<u8>> {
|
fn query(&self, q: cl_program_info, _: &[u8]) -> CLResult<Vec<u8>> {
|
||||||
let prog = self.get_ref()?;
|
let prog = self.get_ref()?;
|
||||||
Ok(match q {
|
Ok(match q {
|
||||||
CL_PROGRAM_CONTEXT => {
|
CL_PROGRAM_CONTEXT => {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use self::rusticl_opencl_gen::*;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
impl CLInfo<cl_command_queue_info> for cl_command_queue {
|
impl CLInfo<cl_command_queue_info> for cl_command_queue {
|
||||||
fn query(&self, q: cl_command_queue_info) -> CLResult<Vec<u8>> {
|
fn query(&self, q: cl_command_queue_info, _: &[u8]) -> CLResult<Vec<u8>> {
|
||||||
let queue = self.get_ref()?;
|
let queue = self.get_ref()?;
|
||||||
Ok(match q {
|
Ok(match q {
|
||||||
CL_QUEUE_CONTEXT => {
|
CL_QUEUE_CONTEXT => {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use std::slice;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub trait CLInfo<I> {
|
pub trait CLInfo<I> {
|
||||||
fn query(&self, q: I) -> CLResult<Vec<u8>>;
|
fn query(&self, q: I, vals: &[u8]) -> CLResult<Vec<u8>>;
|
||||||
|
|
||||||
fn get_info(
|
fn get_info(
|
||||||
&self,
|
&self,
|
||||||
@@ -29,7 +29,13 @@ pub trait CLInfo<I> {
|
|||||||
param_value: *mut ::std::os::raw::c_void,
|
param_value: *mut ::std::os::raw::c_void,
|
||||||
param_value_size_ret: *mut usize,
|
param_value_size_ret: *mut usize,
|
||||||
) -> CLResult<()> {
|
) -> CLResult<()> {
|
||||||
let d = self.query(param_name)?;
|
let arr = if !param_value.is_null() {
|
||||||
|
unsafe { slice::from_raw_parts(param_value.cast(), param_value_size) }
|
||||||
|
} else {
|
||||||
|
&[]
|
||||||
|
};
|
||||||
|
|
||||||
|
let d = self.query(param_name, arr)?;
|
||||||
let size: usize = d.len();
|
let size: usize = d.len();
|
||||||
|
|
||||||
// CL_INVALID_VALUE [...] if size in bytes specified by param_value_size is < size of return
|
// CL_INVALID_VALUE [...] if size in bytes specified by param_value_size is < size of return
|
||||||
|
|||||||
Reference in New Issue
Block a user