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:
Karol Herbst
2022-03-17 12:18:39 +01:00
committed by Marge Bot
parent 9dd56ff2e7
commit 84d16045d0
9 changed files with 18 additions and 12 deletions

View File

@@ -17,7 +17,7 @@ use std::slice;
use std::sync::Arc;
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()?;
Ok(match q {
CL_CONTEXT_DEVICES => {

View File

@@ -16,7 +16,7 @@ use std::sync::Arc;
use std::sync::Once;
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()?;
Ok(match q {
CL_DEVICE_ADDRESS_BITS => cl_prop::<cl_uint>(dev.address_bits()),

View File

@@ -13,7 +13,7 @@ use std::ptr;
use std::sync::Arc;
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()?;
Ok(match q {
CL_EVENT_COMMAND_EXECUTION_STATUS => cl_prop::<cl_int>(event.status()),

View File

@@ -19,7 +19,7 @@ use std::slice;
use std::sync::Arc;
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()?;
Ok(match q {
CL_KERNEL_CONTEXT => {

View File

@@ -171,7 +171,7 @@ fn validate_matching_buffer_flags(mem: &Mem, flags: cl_mem_flags) -> CLResult<()
}
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()?;
Ok(match *q {
CL_MEM_ASSOCIATED_MEMOBJECT => {
@@ -629,7 +629,7 @@ fn validate_buffer(
}
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()?;
Ok(match *q {
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 {
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()?;
Ok(match q {
CL_SAMPLER_ADDRESSING_MODE => cl_prop::<cl_addressing_mode>(sampler.addressing_mode),

View File

@@ -18,7 +18,7 @@ pub struct _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()?;
Ok(match q {
CL_PLATFORM_EXTENSIONS => cl_prop("cl_khr_icd"),

View File

@@ -20,7 +20,7 @@ use std::slice;
use std::sync::Arc;
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()?;
Ok(match q {
CL_PROGRAM_CONTEXT => {

View File

@@ -11,7 +11,7 @@ use self::rusticl_opencl_gen::*;
use std::sync::Arc;
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()?;
Ok(match q {
CL_QUEUE_CONTEXT => {

View File

@@ -20,7 +20,7 @@ use std::slice;
use std::sync::Arc;
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(
&self,
@@ -29,7 +29,13 @@ pub trait CLInfo<I> {
param_value: *mut ::std::os::raw::c_void,
param_value_size_ret: *mut usize,
) -> 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();
// CL_INVALID_VALUE [...] if size in bytes specified by param_value_size is < size of return