Skip to main content

RenderQueue

Struct RenderQueue 

Source
pub struct RenderQueue(/* private fields */);
Expand description

This queue is used to enqueue tasks for the GPU to execute asynchronously.

Implementations§

Source§

impl RenderQueue

Source

pub fn new(t: Queue) -> RenderQueue

Constructs a new instance of WgpuWrapper which will wrap the specified value.

Source

pub fn into_inner(self) -> Queue

Unwraps the value.

Methods from Deref<Target = Queue>§

Source

pub fn write_buffer(&self, buffer: &Buffer, offset: u64, data: &[u8])

Copies the bytes of data into buffer starting at offset.

The data must be written fully in-bounds, that is, offset + data.len() <= buffer.len().

§Performance considerations
  • Calls to write_buffer() do not submit the transfer to the GPU immediately. They begin GPU execution only on the next call to Queue::submit(), just before the explicitly submitted commands. To get a set of scheduled transfers started immediately, it’s fine to call submit with no command buffers at all:

    queue.write_buffer(&buffer, 0, &data);
    queue.submit([]);

    However, data will be immediately copied into staging memory, so the caller may discard it any time after this call completes.

  • Consider using Queue::write_buffer_with() instead. That method allows you to prepare your data directly within the staging memory, rather than first placing it in a separate [u8] to be copied. That is, queue.write_buffer(b, offset, data) is approximately equivalent to queue.write_buffer_with(b, offset, data.len()).copy_from_slice(data), so use write_buffer_with() if you can do something smarter than that copy_from_slice(). However, for small values (e.g. a typical uniform buffer whose contents come from a struct), there will likely be no difference, since the compiler will be able to optimize out unnecessary copies regardless.

  • Currently on native platforms, for both of these methods, the staging memory will be a new allocation. This will then be released after the next submission finishes. To entirely avoid short-lived allocations, you might be able to use StagingBelt, or buffers you explicitly create, map, and unmap yourself.

Source

pub fn write_buffer_with( &self, buffer: &Buffer, offset: u64, size: NonZero<u64>, ) -> Option<QueueWriteBufferView>

Prepares to write data to a buffer via a mapped staging buffer.

This operation allocates a temporary buffer and then returns a QueueWriteBufferView, which

  • dereferences to a [u8] of length size, and
  • when dropped, schedules a copy of its contents into buffer at offset.

Therefore, this obtains the same result as Queue::write_buffer(), but may allow you to skip one allocation and one copy of your data, if you are able to assemble your data directly into the returned QueueWriteBufferView instead of into a separate allocation like a Vec first.

The data must be written fully in-bounds, that is, offset + size <= buffer.len().

§Performance considerations
  • For small data not separately heap-allocated, there is no advantage of this over Queue::write_buffer().

  • Reading from the returned view may be slow, and will not yield the current contents of buffer. You should treat it as “write-only”.

  • Dropping the QueueWriteBufferView does not submit the transfer to the GPU immediately. The transfer begins only on the next call to Queue::submit() after the view is dropped, just before the explicitly submitted commands. To get a set of scheduled transfers started immediately, it’s fine to call queue.submit([]) with no command buffers at all.

  • Currently on native platforms, the staging memory will be a new allocation, which will then be released after the next submission finishes. To entirely avoid short-lived allocations, you might be able to use StagingBelt, or buffers you explicitly create, map, and unmap yourself.

Source

pub fn write_texture( &self, texture: TexelCopyTextureInfo<&Texture>, data: &[u8], data_layout: TexelCopyBufferLayout, size: Extent3d, )

Copies the bytes of data into a texture.

  • data contains the texels to be written, which must be in the same format as the texture.
  • data_layout describes the memory layout of data, which does not necessarily have to have tightly packed rows.
  • texture specifies the texture to write into, and the location within the texture (coordinate offset, mip level) that will be overwritten.
  • size is the size, in texels, of the region to be written.

This method fails if size overruns the size of texture, or if data is too short.

§Performance considerations

This operation has the same performance considerations as Queue::write_buffer(); see its documentation for details.

However, since there is no “mapped texture” like a mapped buffer, alternate techniques for writing to textures will generally consist of first copying the data to a buffer, then using CommandEncoder::copy_buffer_to_texture(), or in some cases a compute shader, to copy texels from that buffer to the texture.

Source

pub fn submit<I>(&self, command_buffers: I) -> SubmissionIndex
where I: IntoIterator<Item = CommandBuffer>,

Submits a series of finished command buffers for execution.

Source

pub fn get_timestamp_period(&self) -> f32

Gets the amount of nanoseconds each tick of a timestamp query represents.

Returns zero if timestamp queries are unsupported.

Timestamp values are represented in nanosecond values on WebGPU, see https://gpuweb.github.io/gpuweb/#timestamp Therefore, this is always 1.0 on the web, but on wgpu-core a manual conversion is required.

Source

pub fn on_submitted_work_done(&self, callback: impl FnOnce() + Send + 'static)

Registers a callback that is invoked when the previous Queue::submit finishes executing on the GPU. When this callback runs, all mapped-buffer callbacks registered for the same submission are guaranteed to have been called.

For the callback to run, either queue.submit(..), instance.poll_all(..), or device.poll(..) must be called elsewhere in the runtime, possibly integrated into an event loop or run on a separate thread.

The callback runs on the thread that first calls one of the above functions after the GPU work completes. There are no restrictions on the code you can run in the callback; however, on native the polling call will not return until the callback finishes, so keep callbacks short (set flags, send messages, etc.).

Source

pub unsafe fn as_hal<A>( &self, ) -> Option<impl Deref<Target = <A as Api>::Queue> + WasmNotSendSync>
where A: Api,

Get the wgpu_hal device from this Queue.

Find the Api struct corresponding to the active backend in wgpu_hal::api, and pass that struct to the to the A type parameter.

Returns a guard that dereferences to the type of the hal backend which implements A::Queue.

§Types

The returned type depends on the backend:

§Errors

This method will return None if:

  • The queue is not from the backend specified by A.
  • The queue is from the webgpu or custom backend.

On the webgpu backend, use as_webgpu instead.

§Safety
  • The returned resource must not be destroyed unless the guard is the last reference to it and it is not in use by the GPU. The guard and handle may be dropped at any time however.
  • All the safety requirements of wgpu-hal must be upheld.
Source

pub fn present(&self, surface_texture: SurfaceTexture)

Schedule a surface texture to be presented on the owning surface.

Should be called after any work on the texture is submitted via Queue::submit. If no work was submitted, the texture will be cleared automatically before presenting.

§Platform dependent behavior

On Wayland, present will attach a wl_buffer to the underlying wl_surface and commit the new surface state. If it is desired to do things such as request a frame callback, scale the surface using the viewporter or synchronize other double buffered state, then these operations should be done before the call to present.

Source

pub fn compact_blas(&self, blas: &Blas) -> Blas

Compact a BLAS, it must have had Blas::prepare_compaction_async called on it and had the callback provided called.

The returned BLAS is more restricted than a normal BLAS because it may not be rebuilt or compacted.

Trait Implementations§

Source§

impl Clone for RenderQueue

Source§

fn clone(&self) -> RenderQueue

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Component for RenderQueue
where RenderQueue: Send + Sync + 'static,

Source§

const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::SparseSet

A constant indicating the storage type used for this component.
Source§

type Mutability = Mutable

A marker type to assist Bevy with determining if this component is mutable, or immutable. Mutable components will have Component<Mutability = Mutable>, while immutable components will instead have Component<Mutability = Immutable>. Read more
Source§

fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )

Registers required components. Read more
Source§

fn clone_behavior() -> ComponentCloneBehavior

Called when registering this component, allowing to override clone function (or disable cloning altogether) for this component. Read more
Source§

fn relationship_accessor() -> Option<ComponentRelationshipAccessor<RenderQueue>>

Returns ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read more
Source§

fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_add ComponentHook for this Component if one is defined.
Source§

fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_insert ComponentHook for this Component if one is defined.
Source§

fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_discard ComponentHook for this Component if one is defined.
Source§

fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_remove ComponentHook for this Component if one is defined.
Source§

fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_despawn ComponentHook for this Component if one is defined.
Source§

fn map_entities<E>(_this: &mut Self, _mapper: &mut E)
where E: EntityMapper,

Maps the entities on this component using the given EntityMapper. This is used to remap entities in contexts like scenes and entity cloning. When deriving Component, this is populated by annotating fields containing entities with #[entities] Read more
Source§

const HAS_SUMMARY_TICK: bool = false

Set this constant to true if the component should track a summary tick. Read more
Source§

impl Deref for RenderQueue

Source§

type Target = Queue

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<RenderQueue as Deref>::Target

Dereferences the value.
Source§

impl DerefMut for RenderQueue

Source§

fn deref_mut(&mut self) -> &mut <RenderQueue as Deref>::Target

Mutably dereferences the value.
Source§

impl Resource for RenderQueue
where RenderQueue: Send + Sync + 'static,

Source§

impl Send for RenderQueue

Source§

impl Sync for RenderQueue

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

Source§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<C> Bundle for C
where C: Component,

Source§

fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>

Source§

fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>

Returns an iterator over this Bundle’s component ids. This will be None if the component has not been registered.
Source§

impl<C> BundleFromComponents for C
where C: Component,

Source§

unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
where F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a>, C: Sized,

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &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)

Converts &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> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<C> DynamicBundle for C
where C: Component,

Source§

type Effect = ()

An operation on the entity that happens after inserting this bundle.
Source§

unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect

Moves the components out of the bundle. Read more
Source§

unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )

Applies the after-effects of spawning this bundle. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Settings for T
where T: 'static + Send + Sync,

Source§

impl<T> Template for T
where T: Clone + Unpin,

Source§

type Output = T

The type of value produced by this Template.
Source§

fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>

Uses this template and the given entity context to produce a Template::Output.
Source§

fn clone_template(&self) -> T

Clones this template. See Clone.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

fn clone_type_data(&self) -> Box<dyn TypeData>

Creates a type-erased clone of self.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more