trait Access {
type Output: MergeTuple + Copy + Clone;
// Required methods
fn generate(
&self,
id_gen: &mut IdGenerator,
coordinates_id: Word,
level_id: Option<Word>,
sample_id: Option<Word>,
block: &mut Block,
) -> Self::Output;
fn result_type(&self) -> Self::Output;
fn out_of_bounds_value(&self, ctx: &mut BlockContext<'_>) -> Self::Output;
}
Expand description
A trait for image access (load or store) code generators.
Types implementing this trait hold information about an ImageStore
or
ImageLoad
operation that is not affected by the bounds check policy. The
generate
method emits code for the access, given the results of bounds
checking.
The image
bounds checks policy affects access coordinates, level of
detail, and sample index, but never the image id, result type (if any), or
the specific SPIR-V instruction used. Types that implement this trait gather
together the latter category, so we don’t have to plumb them through the
bounds-checking code.
Required Associated Types§
sourcetype Output: MergeTuple + Copy + Clone
type Output: MergeTuple + Copy + Clone
The Rust type that represents SPIR-V values and types for this access.
For operations like loads, this is Word
. For operations like stores,
this is ()
.
For ReadZeroSkipWrite
, this will be the type of the selection
construct that performs the bounds checks, so it must implement
MergeTuple
.
Required Methods§
sourcefn generate(
&self,
id_gen: &mut IdGenerator,
coordinates_id: Word,
level_id: Option<Word>,
sample_id: Option<Word>,
block: &mut Block,
) -> Self::Output
fn generate( &self, id_gen: &mut IdGenerator, coordinates_id: Word, level_id: Option<Word>, sample_id: Option<Word>, block: &mut Block, ) -> Self::Output
Write an image access to block
.
Access the texel at coordinates_id
. The optional level_id
indicates
the level of detail, and sample_id
is the index of the sample to
access in a multisampled texel.
This method assumes that coordinates_id
has already had the image array
index, if any, folded in, as done by write_image_coordinates
.
Return the value id produced by the instruction, if any.
Use id_gen
to generate SPIR-V ids as necessary.
sourcefn result_type(&self) -> Self::Output
fn result_type(&self) -> Self::Output
Return the SPIR-V type of the value produced by the code written by
generate
. If the access does not produce a value, Self::Output
should be ()
.
sourcefn out_of_bounds_value(&self, ctx: &mut BlockContext<'_>) -> Self::Output
fn out_of_bounds_value(&self, ctx: &mut BlockContext<'_>) -> Self::Output
Construct the SPIR-V ‘zero’ value to be returned for an out-of-bounds
access under the ReadZeroSkipWrite
policy. If the access does not
produce a value, Self::Output
should be ()
.