pub struct GpuContext { /* private fields */ }Expand description
GPU context for compute operations
This is the main entry point for GPU-accelerated operations. It manages device selection, resource allocation, and command submission.
Implementations§
Source§impl GpuContext
impl GpuContext
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new GPU context with automatic device selection
This will select the most suitable GPU device available on the system. If no GPU is available, an error is returned.
§Errors
Returns an error if no suitable GPU device is found or if device initialization fails.
Sourcepub fn with_device(device_index: usize) -> Result<Self>
pub fn with_device(device_index: usize) -> Result<Self>
Sourcepub fn list_devices() -> Result<Vec<GpuDeviceInfo>>
pub fn list_devices() -> Result<Vec<GpuDeviceInfo>>
List available GPU devices
Returns information about all GPU devices available on the system.
Sourcepub fn device_info(&self) -> &GpuDeviceInfo
pub fn device_info(&self) -> &GpuDeviceInfo
Get information about the current device
Sourcepub fn scale_bilinear(
&self,
input: &[u8],
src_width: u32,
src_height: u32,
output: &mut [u8],
dst_width: u32,
dst_height: u32,
) -> Result<()>
pub fn scale_bilinear( &self, input: &[u8], src_width: u32, src_height: u32, output: &mut [u8], dst_width: u32, dst_height: u32, ) -> Result<()>
Scale an image using bilinear interpolation
§Arguments
input- Input image buffer (packed RGBA format)src_width- Source image widthsrc_height- Source image heightoutput- Output image buffer (packed RGBA format)dst_width- Destination image widthdst_height- Destination image height
§Errors
Returns an error if buffer sizes are invalid or if the GPU operation fails.
Sourcepub fn scale_bicubic(
&self,
input: &[u8],
src_width: u32,
src_height: u32,
output: &mut [u8],
dst_width: u32,
dst_height: u32,
) -> Result<()>
pub fn scale_bicubic( &self, input: &[u8], src_width: u32, src_height: u32, output: &mut [u8], dst_width: u32, dst_height: u32, ) -> Result<()>
Scale an image using bicubic interpolation
§Arguments
input- Input image buffer (packed RGBA format)src_width- Source image widthsrc_height- Source image heightoutput- Output image buffer (packed RGBA format)dst_width- Destination image widthdst_height- Destination image height
§Errors
Returns an error if buffer sizes are invalid or if the GPU operation fails.
Sourcepub fn scale_lanczos(
&self,
input: &[u8],
src_width: u32,
src_height: u32,
output: &mut [u8],
dst_width: u32,
dst_height: u32,
) -> Result<()>
pub fn scale_lanczos( &self, input: &[u8], src_width: u32, src_height: u32, output: &mut [u8], dst_width: u32, dst_height: u32, ) -> Result<()>
Scale an image using Lanczos-3 interpolation (highest quality)
§Arguments
input- Input image buffer (packed RGBA format)src_width- Source image widthsrc_height- Source image heightoutput- Output image buffer (packed RGBA format)dst_width- Destination image widthdst_height- Destination image height
§Errors
Returns an error if buffer sizes are invalid or if the GPU operation fails.
Sourcepub fn gaussian_blur(
&self,
input: &[u8],
output: &mut [u8],
width: u32,
height: u32,
sigma: f32,
) -> Result<()>
pub fn gaussian_blur( &self, input: &[u8], output: &mut [u8], width: u32, height: u32, sigma: f32, ) -> Result<()>
Sourcepub fn sharpen(
&self,
input: &[u8],
output: &mut [u8],
width: u32,
height: u32,
amount: f32,
) -> Result<()>
pub fn sharpen( &self, input: &[u8], output: &mut [u8], width: u32, height: u32, amount: f32, ) -> Result<()>
Sourcepub fn edge_detect(
&self,
input: &[u8],
output: &mut [u8],
width: u32,
height: u32,
) -> Result<()>
pub fn edge_detect( &self, input: &[u8], output: &mut [u8], width: u32, height: u32, ) -> Result<()>
Sourcepub fn dct_2d(
&self,
input: &[f32],
output: &mut [f32],
width: u32,
height: u32,
) -> Result<()>
pub fn dct_2d( &self, input: &[f32], output: &mut [f32], width: u32, height: u32, ) -> Result<()>
Auto Trait Implementations§
impl !RefUnwindSafe for GpuContext
impl !UnwindSafe for GpuContext
impl Freeze for GpuContext
impl Send for GpuContext
impl Sync for GpuContext
impl Unpin for GpuContext
impl UnsafeUnpin for GpuContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more