pub struct TextureResampler { /* private fields */ }Expand description
A compiled compute kernel that resamples a sampleable source texture into a destination storage texture using a hardware sampler.
Constructed once per (method, dst_format) pair via TextureResampler::new
and reused across many dispatches.
Implementations§
Source§impl TextureResampler
impl TextureResampler
Sourcepub fn new(
ctx: &GpuContext,
method: TextureFilterMethod,
dst_format: TextureFormat,
) -> GpuResult<Self>
pub fn new( ctx: &GpuContext, method: TextureFilterMethod, dst_format: TextureFormat, ) -> GpuResult<Self>
Construct a new texture resampler.
§Parameters
ctx— the GPU context that owns the device and queue.method— the filter mode (Nearest or Linear) applied by the sampler.dst_format— the storage texture format the kernel will write to. Must be one ofRgba32Float,R32Float, orRgba8Unorm.
§Errors
Returns GpuError::UnsupportedFormat when dst_format is not one of
the supported destination formats.
Sourcepub fn method(&self) -> TextureFilterMethod
pub fn method(&self) -> TextureFilterMethod
The filter mode this resampler was constructed with.
Sourcepub fn dst_format(&self) -> TextureFormat
pub fn dst_format(&self) -> TextureFormat
The destination storage-texture format this resampler writes to.
Sourcepub fn dispatch(
&self,
ctx: &GpuContext,
src_texture: &Texture,
dst_texture: &StorageTextureBinding,
) -> GpuResult<()>
pub fn dispatch( &self, ctx: &GpuContext, src_texture: &Texture, dst_texture: &StorageTextureBinding, ) -> GpuResult<()>
Dispatch the compute kernel, reading from src_texture and writing to
dst_texture.
§Errors
- Returns
GpuError::UnsupportedFormatwhen the destination texture format does not match the resampler’sdst_format. - Returns the underlying error if the device has been lost.
Auto Trait Implementations§
impl !RefUnwindSafe for TextureResampler
impl !UnwindSafe for TextureResampler
impl Freeze for TextureResampler
impl Send for TextureResampler
impl Sync for TextureResampler
impl Unpin for TextureResampler
impl UnsafeUnpin for TextureResampler
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
Mutably borrows from an owned value. Read more