mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 22:41:07 +01:00
Add check to ensure vulkan::CommandEncoder::discard_encoding is not called multiple times in a row (#5557)
Document that `wgpu_hal::CommandEncoder::discard_encoding` must not be called multiple times. Assert in `wgpu_hal::vulkan::CommandEncoder::discard_encoding` that encoding is actually in progress. Fixes #5255.
This commit is contained in:
3 files changed
+11
-1
No files matched your search
@@ -183,6 +183,7 @@ Bottom level categories:
|
||||
#### Vulkan
|
||||
|
||||
- Set object labels when the DEBUG flag is set, even if the VALIDATION flag is disabled. By @DJMcNab in [#5345](https://github.com/gfx-rs/wgpu/pull/5345).
|
||||
- Add safety check to `wgpu_hal::vulkan::CommandEncoder` to make sure `discard_encoding` is not called in the closed state. By @villuna in [#5557](https://github.com/gfx-rs/wgpu/pull/5557)
|
||||
|
||||
#### Metal
|
||||
|
||||
|
||||
+5
-1
@@ -645,7 +645,7 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug {
|
||||
/// This `CommandEncoder` must be in the "closed" state.
|
||||
unsafe fn begin_encoding(&mut self, label: Label) -> Result<(), DeviceError>;
|
||||
|
||||
/// Discard the command list under construction, if any.
|
||||
/// Discard the command list under construction.
|
||||
///
|
||||
/// If an error has occurred while recording commands, this
|
||||
/// is the only safe thing to do with the encoder.
|
||||
@@ -655,6 +655,10 @@ pub trait CommandEncoder: WasmNotSendSync + fmt::Debug {
|
||||
/// # Safety
|
||||
///
|
||||
/// This `CommandEncoder` must be in the "recording" state.
|
||||
///
|
||||
/// Callers must not assume that implementations of this
|
||||
/// function are idempotent, and thus should not call it
|
||||
/// multiple times in a row.
|
||||
unsafe fn discard_encoding(&mut self);
|
||||
|
||||
/// Return a fresh [`CommandBuffer`] holding the recorded commands.
|
||||
|
||||
@@ -104,6 +104,11 @@ impl crate::CommandEncoder for super::CommandEncoder {
|
||||
}
|
||||
|
||||
unsafe fn discard_encoding(&mut self) {
|
||||
// Safe use requires this is not called in the "closed" state, so the buffer
|
||||
// shouldn't be null. Assert this to make sure we're not pushing null
|
||||
// buffers to the discard pile.
|
||||
assert_ne!(self.active, vk::CommandBuffer::null());
|
||||
|
||||
self.discarded.push(self.active);
|
||||
self.active = vk::CommandBuffer::null();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user