mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 19:00:13 +01:00
rusticl/icd: move retain() and release()
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27376>
This commit is contained in:
parent
45b9fdb4e5
commit
9b5bcbb60f
7 changed files with 28 additions and 29 deletions
|
|
@ -234,12 +234,12 @@ fn create_context_from_type(
|
|||
|
||||
#[cl_entrypoint]
|
||||
fn retain_context(context: cl_context) -> CLResult<()> {
|
||||
context.retain()
|
||||
Context::retain(context)
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
fn release_context(context: cl_context) -> CLResult<()> {
|
||||
context.release()
|
||||
Context::release(context)
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
|
|
|
|||
|
|
@ -68,12 +68,12 @@ fn create_user_event(context: cl_context) -> CLResult<cl_event> {
|
|||
|
||||
#[cl_entrypoint]
|
||||
fn retain_event(event: cl_event) -> CLResult<()> {
|
||||
event.retain()
|
||||
Event::retain(event)
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
fn release_event(event: cl_event) -> CLResult<()> {
|
||||
event.release()
|
||||
Event::release(event)
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
|
|
|
|||
|
|
@ -285,20 +285,6 @@ pub trait ReferenceCountedAPIPointer<T, const ERR: i32> {
|
|||
}
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
fn retain(&self) -> CLResult<()> {
|
||||
unsafe {
|
||||
Arc::increment_strong_count(self.get_ptr()?);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn release(&self) -> CLResult<()> {
|
||||
unsafe {
|
||||
Arc::from_raw(self.get_ptr()?);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait CLObject<'a, const ERR: i32, CL: ReferenceCountedAPIPointer<Self, ERR> + 'a>:
|
||||
|
|
@ -332,6 +318,20 @@ pub trait CLObject<'a, const ERR: i32, CL: ReferenceCountedAPIPointer<Self, ERR>
|
|||
}
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
fn release(ptr: CL) -> CLResult<()> {
|
||||
let ptr = ptr.get_ptr()?;
|
||||
// SAFETY: `get_ptr` already checks if it's one of our pointers.
|
||||
unsafe { Arc::decrement_strong_count(ptr) };
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn retain(ptr: CL) -> CLResult<()> {
|
||||
let ptr = ptr.get_ptr()?;
|
||||
// SAFETY: `get_ptr` already checks if it's one of our pointers.
|
||||
unsafe { Arc::increment_strong_count(ptr) };
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
|
|
|
|||
|
|
@ -267,12 +267,12 @@ fn create_kernel(
|
|||
|
||||
#[cl_entrypoint]
|
||||
fn retain_kernel(kernel: cl_kernel) -> CLResult<()> {
|
||||
kernel.retain()
|
||||
Kernel::retain(kernel)
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
fn release_kernel(kernel: cl_kernel) -> CLResult<()> {
|
||||
kernel.release()
|
||||
Kernel::release(kernel)
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
|
|
|
|||
|
|
@ -1004,12 +1004,12 @@ fn create_sampler_with_properties(
|
|||
|
||||
#[cl_entrypoint]
|
||||
fn retain_sampler(sampler: cl_sampler) -> CLResult<()> {
|
||||
sampler.retain()
|
||||
Sampler::retain(sampler)
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
fn release_sampler(sampler: cl_sampler) -> CLResult<()> {
|
||||
sampler.release()
|
||||
Sampler::release(sampler)
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
|
|
@ -2169,12 +2169,12 @@ fn enqueue_map_image(
|
|||
|
||||
#[cl_entrypoint]
|
||||
fn retain_mem_object(mem: cl_mem) -> CLResult<()> {
|
||||
mem.retain()
|
||||
Mem::retain(mem)
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
fn release_mem_object(mem: cl_mem) -> CLResult<()> {
|
||||
mem.release()
|
||||
Mem::release(mem)
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
|
|
|
|||
|
|
@ -252,12 +252,12 @@ fn create_program_with_il(
|
|||
|
||||
#[cl_entrypoint]
|
||||
fn retain_program(program: cl_program) -> CLResult<()> {
|
||||
program.retain()
|
||||
Program::retain(program)
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
fn release_program(program: cl_program) -> CLResult<()> {
|
||||
program.release()
|
||||
Program::release(program)
|
||||
}
|
||||
|
||||
fn debug_logging(p: &Program, devs: &[&Device]) {
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ fn finish(command_queue: cl_command_queue) -> CLResult<()> {
|
|||
|
||||
#[cl_entrypoint]
|
||||
fn retain_command_queue(command_queue: cl_command_queue) -> CLResult<()> {
|
||||
command_queue.retain()
|
||||
Queue::retain(command_queue)
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
|
|
@ -225,6 +225,5 @@ fn release_command_queue(command_queue: cl_command_queue) -> CLResult<()> {
|
|||
// clReleaseCommandQueue performs an implicit flush to issue any previously queued OpenCL
|
||||
// commands in command_queue.
|
||||
flush(command_queue)?;
|
||||
command_queue.release()?;
|
||||
Ok(())
|
||||
Queue::release(command_queue)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue