Struct bevy_render::batching::gpu_preprocessing::IndirectParameters
source · #[repr(C)]pub struct IndirectParameters {
pub vertex_or_index_count: u32,
pub instance_count: u32,
pub first_vertex: 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_countis 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
ArrayIndirectParametersby copying thefirst_instancefield into the padding, then the resulting union structure will always have a read-only copy offirst_instancein the final word. We take advantage of this in the shader to reduce branching.
Fields§
§vertex_or_index_count: u32For ArrayIndirectParameters, vertex_count; for
ElementIndirectParameters, index_count.
instance_count: u32The number of instances we’re going to draw.
This field is in the same place in both structures.
first_vertex: u32The index of the first vertex we’re to draw.
base_vertex_or_first_instance: u32For ArrayIndirectParameters, first_instance; for
ElementIndirectParameters, base_vertex.
first_instance: u32For 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,
§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> 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.