pub(crate) struct InnerCommandEncoder {
pub(crate) raw: ManuallyDrop<Box<dyn DynCommandEncoder>>,
pub(crate) list: Vec<Box<dyn DynCommandBuffer>>,
pub(crate) device: Arc<Device>,
pub(crate) is_open: bool,
pub(crate) api: EncodingApi,
pub(crate) label: String,
}Expand description
A raw CommandEncoder, and the raw CommandBuffers built from it.
Each wgpu-core CommandBuffer owns an instance of this type, which is
where the commands are actually stored.
This holds a Vec of raw CommandBuffers, not just one. We are not
always able to record commands in the order in which they must ultimately be
submitted to the queue, but raw command buffers don’t permit inserting new
commands into the middle of a recorded stream. However, hal queue submission
accepts a series of command buffers at once, so we can simply break the
stream up into multiple buffers, and then reorder the buffers. See
InnerCommandEncoder::close_and_swap for a specific example of this.
Fields§
§raw: ManuallyDrop<Box<dyn DynCommandEncoder>>The underlying wgpu_hal CommandEncoder.
Successfully executed command buffers’ encoders are saved in a
CommandAllocator for recycling.
list: Vec<Box<dyn DynCommandBuffer>>All the raw command buffers for our owning CommandBuffer, in
submission order.
These command buffers were all constructed with raw. The
wgpu_hal::CommandEncoder trait forbids these from outliving raw,
and requires that we provide all of these when we call
raw.reset_all(), so the encoder and its buffers travel
together.
device: Arc<Device>§is_open: boolTrue if raw is in the “recording” state.
See the documentation for wgpu_hal::CommandEncoder for
details on the states raw can be in.
api: EncodingApiTracks which API is being used to encode commands.
Mixing the wgpu encoding API with access to the raw hal encoder via
as_hal_mut is not supported. this field tracks which API is being used
in order to detect and reject invalid usage.
label: StringImplementations§
Source§impl InnerCommandEncoder
impl InnerCommandEncoder
Sourcefn close_and_swap(&mut self) -> Result<(), DeviceError>
fn close_and_swap(&mut self) -> Result<(), DeviceError>
Finish the current command buffer and insert it just before
the last element in self.list.
On return, the underlying hal encoder is closed.
What is this for?
The wgpu_hal contract requires that each render or compute pass’s
commands be preceded by calls to transition_buffers and
transition_textures, to put the resources the pass operates on in
the appropriate state. Unfortunately, we don’t know which transitions
are needed until we’re done recording the pass itself. Rather than
iterating over the pass twice, we note the necessary transitions as we
record its commands, finish the raw command buffer for the actual pass,
record a new raw command buffer for the transitions, and jam that buffer
in just before the pass’s. This is the function that jams in the
transitions’ command buffer.
§Panics
- If the encoder is not open.
Sourcepub(crate) fn close_and_push_front(&mut self) -> Result<(), DeviceError>
pub(crate) fn close_and_push_front(&mut self) -> Result<(), DeviceError>
Sourcepub(crate) fn close(&mut self) -> Result<(), DeviceError>
pub(crate) fn close(&mut self) -> Result<(), DeviceError>
Sourcefn close_if_open(&mut self) -> Result<(), DeviceError>
fn close_if_open(&mut self) -> Result<(), DeviceError>
Sourcefn open_if_closed(&mut self) -> Result<&mut dyn DynCommandEncoder, DeviceError>
fn open_if_closed(&mut self) -> Result<&mut dyn DynCommandEncoder, DeviceError>
If the command encoder is not open, begin recording a new command buffer.
If the command encoder was already open, does nothing.
In both cases, returns a reference to the raw encoder.
Sourcepub(crate) fn open(&mut self) -> Result<&mut dyn DynCommandEncoder, DeviceError>
pub(crate) fn open(&mut self) -> Result<&mut dyn DynCommandEncoder, DeviceError>
Begin recording a new command buffer, if we haven’t already.
The underlying hal encoder is put in the “recording” state.
Sourcepub(crate) fn open_pass(
&mut self,
label: Option<&str>,
) -> Result<&mut dyn DynCommandEncoder, DeviceError>
pub(crate) fn open_pass( &mut self, label: Option<&str>, ) -> Result<&mut dyn DynCommandEncoder, DeviceError>
Begin recording a new command buffer for a render or compute pass, with its own label.
The underlying hal encoder is put in the “recording” state.
§Panics
- If the encoder is already open.