use std::ffi::c_void;
use std::fmt;
use super::CUdeviceptr;
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct CUarray(pub *mut c_void);
unsafe impl Send for CUarray {}
unsafe impl Sync for CUarray {}
impl fmt::Debug for CUarray {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "CUarray({:p})", self.0)
}
}
impl Default for CUarray {
fn default() -> Self {
Self(std::ptr::null_mut())
}
}
impl CUarray {
#[inline]
pub fn is_null(self) -> bool {
self.0.is_null()
}
}
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct CUmipmappedArray(pub *mut c_void);
unsafe impl Send for CUmipmappedArray {}
unsafe impl Sync for CUmipmappedArray {}
impl fmt::Debug for CUmipmappedArray {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "CUmipmappedArray({:p})", self.0)
}
}
impl Default for CUmipmappedArray {
fn default() -> Self {
Self(std::ptr::null_mut())
}
}
impl CUmipmappedArray {
#[inline]
pub fn is_null(self) -> bool {
self.0.is_null()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u32)]
#[non_exhaustive]
#[allow(non_camel_case_types)]
pub enum CUarray_format {
UnsignedInt8 = 0x01,
UnsignedInt16 = 0x02,
UnsignedInt32 = 0x03,
SignedInt8 = 0x08,
SignedInt16 = 0x09,
SignedInt32 = 0x0a,
Half = 0x10,
Float = 0x20,
Nv12 = 0xb0,
UnormInt8X1 = 0xc0,
UnormInt8X2 = 0xc1,
UnormInt8X4 = 0xc2,
UnormInt16X1 = 0xc3,
UnormInt16X2 = 0xc4,
UnormInt16X4 = 0xc5,
SnormInt8X1 = 0xc6,
SnormInt8X2 = 0xc7,
SnormInt8X4 = 0xc8,
SnormInt16X1 = 0xc9,
SnormInt16X2 = 0xca,
SnormInt16X4 = 0xcb,
Bc1Unorm = 0x91,
Bc1UnormSrgb = 0x92,
Bc2Unorm = 0x93,
Bc2UnormSrgb = 0x94,
Bc3Unorm = 0x95,
Bc3UnormSrgb = 0x96,
Bc4Unorm = 0x97,
Bc4Snorm = 0x98,
Bc5Unorm = 0x99,
Bc5Snorm = 0x9a,
Bc6hUf16 = 0x9b,
Bc6hSf16 = 0x9c,
Bc7Unorm = 0x9d,
Bc7UnormSrgb = 0x9e,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u32)]
#[non_exhaustive]
pub enum CUresourcetype {
Array = 0x00,
MipmappedArray = 0x01,
Linear = 0x02,
Pitch2d = 0x03,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u32)]
#[allow(non_camel_case_types)]
pub enum CUaddress_mode {
Wrap = 0,
Clamp = 1,
Mirror = 2,
Border = 3,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u32)]
#[allow(non_camel_case_types)]
pub enum CUfilter_mode {
Point = 0,
Linear = 1,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u32)]
#[non_exhaustive]
pub enum CUresourceViewFormat {
None = 0x00,
Uint1x8 = 0x01,
Uint2x8 = 0x02,
Uint4x8 = 0x03,
Sint1x8 = 0x04,
Sint2x8 = 0x05,
Sint4x8 = 0x06,
Uint1x16 = 0x07,
Uint2x16 = 0x08,
Uint4x16 = 0x09,
Sint1x16 = 0x0a,
Sint2x16 = 0x0b,
Sint4x16 = 0x0c,
Uint1x32 = 0x0d,
Uint2x32 = 0x0e,
Uint4x32 = 0x0f,
Sint1x32 = 0x10,
Sint2x32 = 0x11,
Sint4x32 = 0x12,
Float1x16 = 0x13,
Float2x16 = 0x14,
Float4x16 = 0x15,
Float1x32 = 0x16,
Float2x32 = 0x17,
Float4x32 = 0x18,
UnsignedBc1 = 0x19,
UnsignedBc2 = 0x1a,
UnsignedBc3 = 0x1b,
UnsignedBc4 = 0x1c,
SignedBc4 = 0x1d,
UnsignedBc5 = 0x1e,
SignedBc5 = 0x1f,
UnsignedBc6h = 0x20,
SignedBc6h = 0x21,
UnsignedBc7 = 0x22,
Nv12 = 0x23,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(C)]
pub struct CUDA_ARRAY_DESCRIPTOR {
pub width: usize,
pub height: usize,
pub format: CUarray_format,
pub num_channels: u32,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(C)]
pub struct CUDA_ARRAY3D_DESCRIPTOR {
pub width: usize,
pub height: usize,
pub depth: usize,
pub format: CUarray_format,
pub num_channels: u32,
pub flags: u32,
}
pub const CUDA_ARRAY3D_LAYERED: u32 = 0x01;
pub const CUDA_ARRAY3D_SURFACE_LDST: u32 = 0x02;
pub const CUDA_ARRAY3D_CUBEMAP: u32 = 0x04;
pub const CUDA_ARRAY3D_TEXTURE_GATHER: u32 = 0x08;
#[derive(Clone, Copy)]
#[repr(C)]
pub struct CudaResourceDescArray {
pub h_array: CUarray,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct CudaResourceDescMipmap {
pub h_mipmapped_array: CUmipmappedArray,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct CudaResourceDescLinear {
pub dev_ptr: CUdeviceptr,
pub format: CUarray_format,
pub num_channels: u32,
pub size_in_bytes: usize,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct CudaResourceDescPitch2d {
pub dev_ptr: CUdeviceptr,
pub format: CUarray_format,
pub num_channels: u32,
pub width_in_elements: usize,
pub height: usize,
pub pitch_in_bytes: usize,
}
#[repr(C)]
pub union CudaResourceDescRes {
pub array: CudaResourceDescArray,
pub mipmap: CudaResourceDescMipmap,
pub linear: CudaResourceDescLinear,
pub pitch2d: CudaResourceDescPitch2d,
pub reserved: [i32; 32],
}
#[repr(C)]
pub struct CUDA_RESOURCE_DESC {
pub res_type: CUresourcetype,
pub res: CudaResourceDescRes,
pub flags: u32,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct CUDA_TEXTURE_DESC {
pub address_mode: [CUaddress_mode; 3],
pub filter_mode: CUfilter_mode,
pub flags: u32,
pub max_anisotropy: u32,
pub mipmap_filter_mode: CUfilter_mode,
pub mipmap_level_bias: f32,
pub min_mipmap_level_clamp: f32,
pub max_mipmap_level_clamp: f32,
pub border_color: [f32; 4],
pub reserved: [i32; 12],
}
pub const CU_TRSF_READ_AS_INTEGER: u32 = 0x01;
pub const CU_TRSF_NORMALIZED_COORDINATES: u32 = 0x02;
pub const CU_TRSF_SRGB: u32 = 0x10;
pub const CU_TRSF_DISABLE_TRILINEAR_OPTIMIZATION: u32 = 0x20;
#[derive(Clone, Copy)]
#[repr(C)]
pub struct CUDA_RESOURCE_VIEW_DESC {
pub format: CUresourceViewFormat,
pub width: usize,
pub height: usize,
pub depth: usize,
pub first_mipmap_level: u32,
pub last_mipmap_level: u32,
pub first_layer: u32,
pub last_layer: u32,
pub reserved: [u32; 16],
}