MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / new

Method new

crates/cust/src/texture.rs:420–453  ·  view source on GitHub ↗
(
        resource_desc: ResourceDescriptor,
        texture_desc: TextureDescriptor,
        resource_view_desc: Option<ResourceViewDescriptor>,
    )

Source from the content-addressed store, hash-verified

418 }
419
420 pub fn new(
421 resource_desc: ResourceDescriptor,
422 texture_desc: TextureDescriptor,
423 resource_view_desc: Option<ResourceViewDescriptor>,
424 ) -> CudaResult<Self> {
425 let handle = unsafe {
426 let mut uninit = MaybeUninit::<CUtexObject>::uninit();
427 let resource_view_desc =
428 if let Some(x) = resource_view_desc.map(|x| Box::new(x.to_raw())) {
429 Box::into_raw(x)
430 } else {
431 ptr::null_mut()
432 };
433
434 let resource_desc = &resource_desc.into_raw();
435 let texture_desc = &texture_desc.to_raw();
436
437 cuTexObjectCreate(
438 uninit.as_mut_ptr(),
439 resource_desc as *const _,
440 texture_desc as *const _,
441 resource_view_desc as *const _,
442 )
443 .to_result()?;
444 if !resource_view_desc.is_null() {
445 let _ = Box::from_raw(resource_view_desc);
446 }
447 uninit.assume_init()
448 };
449 Ok(Self {
450 handle,
451 _destroy_array_on_destruct: true,
452 })
453 }
454
455 pub fn from_array(array: ArrayObject) -> CudaResult<Self> {
456 let resource_desc = ResourceDescriptor {

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
is_nullMethod · 0.80
to_rawMethod · 0.45
into_rawMethod · 0.45
to_resultMethod · 0.45
as_mut_ptrMethod · 0.45

Tested by

no test coverage detected