Skip to main content

Sampler

Trait Sampler 

Source
pub trait Sampler {
    // Required method
    fn sample(&mut self, request: Sample) -> Result<[f32; 4], String>;

    // Provided methods
    fn load(&mut self, request: Load) -> Result<[u32; 4], String> { ... }
    fn store(&mut self, request: Store) -> Result<(), String> { ... }
    fn atomic_add(&mut self, request: AtomicAdd) -> Result<u32, String> { ... }
    fn structured(
        &mut self,
        slot: u32,
        element: u32,
        offset: u32,
    ) -> Result<u32, String> { ... }
    fn buffer_elements(&mut self, slot: u32) -> Option<u32> { ... }
    fn sample_image(
        &mut self,
        request: ImageSample<u32>,
    ) -> Result<[f32; 4], String> { ... }
    fn load_image(
        &mut self,
        request: ImageLoad<u32>,
    ) -> Result<[u32; 4], String> { ... }
    fn query_image(
        &mut self,
        request: ImageQuery<u32>,
    ) -> Result<[u32; 4], String> { ... }
    fn atomic_image(&mut self, request: ImageAtomic<u32>) -> Result<u32, String> { ... }
    fn store_image(&mut self, request: ImageStore<u32>) -> Result<(), String> { ... }
}
Expand description

Answers sample, load, store and structured-buffer requests; an error stops the evaluation. A closure answers samples only.

Required Methods§

Source

fn sample(&mut self, request: Sample) -> Result<[f32; 4], String>

Answer a 2D Sample with the texel’s four lanes as floats, or an error that stops the evaluation.

Provided Methods§

Source

fn load(&mut self, request: Load) -> Result<[u32; 4], String>

The texel’s four lanes as its view returns them: f32 bits for a float view, the integers for a uint or sint one.

Source

fn store(&mut self, request: Store) -> Result<(), String>

A store to an unordered-access view (Store): the lanes mask marks of value, at the address the program gives (a structured view’s lanes the consecutive words from the byte offset). Its effect is the caller’s: it reaches none of this evaluation’s outputs.

Source

fn atomic_add(&mut self, request: AtomicAdd) -> Result<u32, String>

An atomic add (AtomicAdd); its result the word as it was before. The add itself is the caller’s effect.

Source

fn structured( &mut self, slot: u32, element: u32, offset: u32, ) -> Result<u32, String>

The 32-bit word at byte offset of element element of the structured buffer at t<slot>.

Source

fn buffer_elements(&mut self, slot: u32) -> Option<u32>

How many elements the buffer view at bind slot slot has, where the sampler knows. A program that reads past the end gets zeros (D3D’s rule) when this is stated; when it is not, no read is taken for out of range.

Source

fn sample_image( &mut self, request: ImageSample<u32>, ) -> Result<[f32; 4], String>

A sample of any texture: 1D, 3D or cube, with a texel offset, a gather or a comparison. A plain 2D sample (or a 2D array’s layer) goes to Sampler::sample; anything else is refused unless the sampler answers it.

Source

fn load_image(&mut self, request: ImageLoad<u32>) -> Result<[u32; 4], String>

A texel load of any texture. A 2D or 3D one (or a 2D array’s layer) goes to Sampler::load.

Source

fn query_image(&mut self, request: ImageQuery<u32>) -> Result<[u32; 4], String>

A texture’s size, level count, layer count or sample count.

Source

fn atomic_image(&mut self, request: ImageAtomic<u32>) -> Result<u32, String>

An atomic operation on a texel of a single-channel 32-bit unordered-access texture; its result is the word as it was before.

Source

fn store_image(&mut self, request: ImageStore<u32>) -> Result<(), String>

A write to an unordered-access texture; the plain form is Sampler::store.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§