811: Error type for `command_encoder_finish` r=kvark a=GabrielMajeri

**Connections**
Part of #638 

**Description**
Makes `command_encoder_finish` return an error type.

**Testing**
Checked with core.

Co-authored-by: Gabriel Majeri <gabriel.majeri6@gmail.com>
This commit is contained in:
bors[bot]
2020-07-18 16:55:31 +00:00
committed by GitHub
2 changed files with 13 additions and 3 deletions

View File

@@ -136,6 +136,7 @@ impl GlobalPlay for wgc::hub::Global<IdentityPassThroughFactory> {
}
}
self.command_encoder_finish::<B>(encoder, &wgt::CommandBufferDescriptor { todo: 0 })
.unwrap()
}
fn process<B: wgc::hub::GfxBackend>(

View File

@@ -26,6 +26,7 @@ use crate::{
};
use hal::command::CommandBuffer as _;
use thiserror::Error;
use std::thread::ThreadId;
@@ -141,12 +142,18 @@ impl<C: Clone> BasePass<C> {
}
}
#[derive(Clone, Debug, Error)]
pub enum CommandEncoderFinishError {
#[error("command buffer must be recording")]
NotRecording,
}
impl<G: GlobalIdentityHandlerFactory> Global<G> {
pub fn command_encoder_finish<B: GfxBackend>(
&self,
encoder_id: id::CommandEncoderId,
_desc: &wgt::CommandBufferDescriptor,
) -> id::CommandBufferId {
) -> Result<id::CommandBufferId, CommandEncoderFinishError> {
span!(_guard, INFO, "CommandEncoder::finish");
let hub = B::hub(self);
@@ -155,7 +162,9 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
//TODO: actually close the last recorded command buffer
let (mut comb_guard, _) = hub.command_buffers.write(&mut token);
let comb = &mut comb_guard[encoder_id];
assert!(comb.is_recording, "Command buffer must be recording");
if !comb.is_recording {
return Err(CommandEncoderFinishError::NotRecording);
}
comb.is_recording = false;
// stop tracking the swapchain image, if used
if let Some((ref sc_id, _)) = comb.used_swap_chain {
@@ -166,7 +175,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
comb.trackers.views.remove(view_id.value);
}
log::trace!("Command buffer {:?} {:#?}", encoder_id, comb.trackers);
encoder_id
Ok(encoder_id)
}
pub fn command_encoder_push_debug_group<B: GfxBackend>(