#[repr(C)]pub struct IndirectParameters {
pub vertex_or_index_count: u32,
pub instance_count: u32,
pub first_vertex_or_first_index: u32,
pub base_vertex_or_first_instance: u32,
pub first_instance: u32,
}
Expand description
The wgpu
indirect parameters structure.
This is actually a union of the two following structures:
#[repr(C)]
struct ArrayIndirectParameters {
vertex_count: u32,
instance_count: u32,
first_vertex: u32,
first_instance: u32,
}
#[repr(C)]
struct ElementIndirectParameters {
index_count: u32,
instance_count: u32,
first_vertex: u32,
base_vertex: u32,
first_instance: u32,
}
We actually generally treat these two variants identically in code. To do that, we make the following two observations:
-
instance_count
is in the same place in both structures. So we can access it regardless of the structure we’re looking at. -
The second structure is one word larger than the first. Thus we need to pad out the first structure by one word in order to place both structures in an array. If we pad out
ArrayIndirectParameters
by copying thefirst_instance
field into the padding, then the resulting union structure will always have a read-only copy offirst_instance
in the final word. We take advantage of this in the shader to reduce branching.
Fields§
§vertex_or_index_count: u32
For ArrayIndirectParameters
, vertex_count
; for
ElementIndirectParameters
, index_count
.
instance_count: u32
The number of instances we’re going to draw.
This field is in the same place in both structures.
first_vertex_or_first_index: u32
For ArrayIndirectParameters
, first_vertex
; for
ElementIndirectParameters
, first_index
.
base_vertex_or_first_instance: u32
For ArrayIndirectParameters
, first_instance
; for
ElementIndirectParameters
, base_vertex
.
first_instance: u32
For ArrayIndirectParameters
, this is padding; for
ElementIndirectParameters
, this is first_instance
.
Conventionally, we copy first_instance
into this field when padding
out ArrayIndirectParameters
. That way, shader code can read this value
at the same place, regardless of the specific structure this represents.
Trait Implementations§
Source§impl Clone for IndirectParameters
impl Clone for IndirectParameters
Source§fn clone(&self) -> IndirectParameters
fn clone(&self) -> IndirectParameters
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl CreateFrom for IndirectParameterswhere
Self: ShaderType<ExtraMetadata = StructMetadata<5usize>>,
for<'__, '__, '__, '__, '__> u32: CreateFrom,
impl CreateFrom for IndirectParameterswhere
Self: ShaderType<ExtraMetadata = StructMetadata<5usize>>,
for<'__, '__, '__, '__, '__> u32: CreateFrom,
fn create_from<B: BufferRef>(reader: &mut Reader<B>) -> Self
Source§impl ReadFrom for IndirectParameterswhere
Self: ShaderType<ExtraMetadata = StructMetadata<5usize>>,
for<'__, '__, '__, '__, '__> u32: ReadFrom,
impl ReadFrom for IndirectParameterswhere
Self: ShaderType<ExtraMetadata = StructMetadata<5usize>>,
for<'__, '__, '__, '__, '__> u32: ReadFrom,
Source§impl ShaderSize for IndirectParameterswhere
u32: ShaderSize,
impl ShaderSize for IndirectParameterswhere
u32: ShaderSize,
Source§const SHADER_SIZE: NonZero<u64> = _
const SHADER_SIZE: NonZero<u64> = _
ShaderType::min_size
)Source§impl ShaderType for IndirectParameters
impl ShaderType for IndirectParameters
Source§fn size(&self) -> NonZeroU64
fn size(&self) -> NonZeroU64
Self
at runtime Read moreSource§fn assert_uniform_compat()
fn assert_uniform_compat()
Self
meets the requirements of the
uniform address space restrictions on stored values and the
uniform address space layout constraints Read moreSource§impl WriteInto for IndirectParameterswhere
Self: ShaderType<ExtraMetadata = StructMetadata<5usize>>,
for<'__, '__, '__, '__, '__> u32: WriteInto,
impl WriteInto for IndirectParameterswhere
Self: ShaderType<ExtraMetadata = StructMetadata<5usize>>,
for<'__, '__, '__, '__, '__> u32: WriteInto,
fn write_into<B: BufferMut>(&self, writer: &mut Writer<B>)
impl Copy for IndirectParameters
impl Pod for IndirectParameters
Auto Trait Implementations§
impl Freeze for IndirectParameters
impl RefUnwindSafe for IndirectParameters
impl Send for IndirectParameters
impl Sync for IndirectParameters
impl Unpin for IndirectParameters
impl UnwindSafe for IndirectParameters
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.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
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self
.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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