Skip to content

Commit

Permalink
[error] render bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Nov 22, 2020
1 parent 8e745eb commit 928d739
Show file tree
Hide file tree
Showing 11 changed files with 542 additions and 487 deletions.
4 changes: 3 additions & 1 deletion player/src/bin/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ fn main() {
None,
id
));
assert_eq!(error, None);
if let Some(e) = error {
panic!("{:?}", e);
}
id
}
_ => panic!("Expected Action::Init"),
Expand Down
71 changes: 49 additions & 22 deletions player/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ impl GlobalPlay for wgc::hub::Global<IdentityPassThroughFactory> {
}
}
}
self.command_encoder_finish::<B>(encoder, &wgt::CommandBufferDescriptor { label: None })
.unwrap()
let (cmd_buf, error) = self
.command_encoder_finish::<B>(encoder, &wgt::CommandBufferDescriptor { label: None });
if let Some(e) = error {
panic!("{:?}", e);
}
cmd_buf
}

fn process<B: wgc::hub::GfxBackend>(
Expand All @@ -138,7 +142,9 @@ impl GlobalPlay for wgc::hub::Global<IdentityPassThroughFactory> {
A::CreateBuffer(id, desc) => {
self.device_maintain_ids::<B>(device).unwrap();
let (_, error) = self.device_create_buffer::<B>(device, &desc, id);
assert_eq!(error, None);
if let Some(e) = error {
panic!("{:?}", e);
}
}
A::FreeBuffer(id) => {
self.buffer_destroy::<B>(id).unwrap();
Expand All @@ -149,7 +155,9 @@ impl GlobalPlay for wgc::hub::Global<IdentityPassThroughFactory> {
A::CreateTexture(id, desc) => {
self.device_maintain_ids::<B>(device).unwrap();
let (_, error) = self.device_create_texture::<B>(device, &desc, id);
assert_eq!(error, None);
if let Some(e) = error {
panic!("{:?}", e);
}
}
A::FreeTexture(id) => {
self.texture_destroy::<B>(id).unwrap();
Expand All @@ -164,15 +172,19 @@ impl GlobalPlay for wgc::hub::Global<IdentityPassThroughFactory> {
} => {
self.device_maintain_ids::<B>(device).unwrap();
let (_, error) = self.texture_create_view::<B>(parent_id, &desc, id);
assert_eq!(error, None);
if let Some(e) = error {
panic!("{:?}", e);
}
}
A::DestroyTextureView(id) => {
self.texture_view_drop::<B>(id).unwrap();
}
A::CreateSampler(id, desc) => {
self.device_maintain_ids::<B>(device).unwrap();
let (_, error) = self.device_create_sampler::<B>(device, &desc, id);
assert_eq!(error, None);
if let Some(e) = error {
panic!("{:?}", e);
}
}
A::DestroySampler(id) => {
self.sampler_drop::<B>(id);
Expand All @@ -187,23 +199,29 @@ impl GlobalPlay for wgc::hub::Global<IdentityPassThroughFactory> {
}
A::CreateBindGroupLayout(id, desc) => {
let (_, error) = self.device_create_bind_group_layout::<B>(device, &desc, id);
assert_eq!(error, None);
if let Some(e) = error {
panic!("{:?}", e);
}
}
A::DestroyBindGroupLayout(id) => {
self.bind_group_layout_drop::<B>(id);
}
A::CreatePipelineLayout(id, desc) => {
self.device_maintain_ids::<B>(device).unwrap();
let (_, error) = self.device_create_pipeline_layout::<B>(device, &desc, id);
assert_eq!(error, None);
if let Some(e) = error {
panic!("{:?}", e);
}
}
A::DestroyPipelineLayout(id) => {
self.pipeline_layout_drop::<B>(id);
}
A::CreateBindGroup(id, desc) => {
self.device_maintain_ids::<B>(device).unwrap();
let (_, error) = self.device_create_bind_group::<B>(device, &desc, id);
assert_eq!(error, None);
if let Some(e) = error {
panic!("{:?}", e);
}
}
A::DestroyBindGroup(id) => {
self.bind_group_drop::<B>(id);
Expand All @@ -224,7 +242,9 @@ impl GlobalPlay for wgc::hub::Global<IdentityPassThroughFactory> {
label,
};
let (_, error) = self.device_create_shader_module::<B>(device, &desc, id);
assert_eq!(error, None);
if let Some(e) = error {
panic!("{:?}", e);
}
}
A::DestroyShaderModule(id) => {
self.shader_module_drop::<B>(id);
Expand All @@ -233,7 +253,9 @@ impl GlobalPlay for wgc::hub::Global<IdentityPassThroughFactory> {
self.device_maintain_ids::<B>(device).unwrap();
let (_, _, error) =
self.device_create_compute_pipeline::<B>(device, &desc, id, None);
assert_eq!(error, None);
if let Some(e) = error {
panic!("{:?}", e);
}
}
A::DestroyComputePipeline(id) => {
self.compute_pipeline_drop::<B>(id);
Expand All @@ -242,20 +264,24 @@ impl GlobalPlay for wgc::hub::Global<IdentityPassThroughFactory> {
self.device_maintain_ids::<B>(device).unwrap();
let (_, _, error) =
self.device_create_render_pipeline::<B>(device, &desc, id, None);
assert_eq!(error, None);
if let Some(e) = error {
panic!("{:?}", e);
}
}
A::DestroyRenderPipeline(id) => {
self.render_pipeline_drop::<B>(id);
}
A::CreateRenderBundle { id, desc, base } => {
let bundle =
wgc::command::RenderBundleEncoder::new(&desc, device, Some(base)).unwrap();
self.render_bundle_encoder_finish::<B>(
let (_, error) = self.render_bundle_encoder_finish::<B>(
bundle,
&wgt::RenderBundleDescriptor { label: desc.label },
id,
)
.unwrap();
);
if let Some(e) = error {
panic!("{:?}", e);
}
}
A::DestroyRenderBundle(id) => {
self.render_bundle_drop::<B>(id);
Expand Down Expand Up @@ -288,13 +314,14 @@ impl GlobalPlay for wgc::hub::Global<IdentityPassThroughFactory> {
.unwrap();
}
A::Submit(_index, commands) => {
let encoder = self
.device_create_command_encoder::<B>(
device,
&wgt::CommandEncoderDescriptor { label: None },
comb_manager.alloc(device.backend()),
)
.unwrap();
let (encoder, error) = self.device_create_command_encoder::<B>(
device,
&wgt::CommandEncoderDescriptor { label: None },
comb_manager.alloc(device.backend()),
);
if let Some(e) = error {
panic!("{:?}", e);
}
let cmdbuf = self.encode_commands::<B>(encoder, commands);
self.queue_submit::<B>(device, &[cmdbuf]).unwrap();
}
Expand Down
4 changes: 3 additions & 1 deletion player/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ impl Test<'_> {
None,
device
));
assert_eq!(error, None);
if let Some(e) = error {
panic!("{:?}", e);
}

let mut command_buffer_id_manager = wgc::hub::IdentityManager::default();
println!("\t\t\tRunning...");
Expand Down
12 changes: 6 additions & 6 deletions wgpu-core/src/binding_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use std::{

use thiserror::Error;

#[derive(Clone, Debug, Error, PartialEq)]
#[derive(Clone, Debug, Error)]
pub enum CreateBindGroupLayoutError {
#[error(transparent)]
Device(#[from] DeviceError),
Expand All @@ -40,7 +40,7 @@ pub enum CreateBindGroupLayoutError {
TooManyBindings(BindingTypeMaxCountError),
}

#[derive(Clone, Debug, Error, PartialEq)]
#[derive(Clone, Debug, Error)]
pub enum CreateBindGroupError {
#[error(transparent)]
Device(#[from] DeviceError),
Expand Down Expand Up @@ -96,23 +96,23 @@ pub enum CreateBindGroupError {
DepthStencilAspect,
}

#[derive(Clone, Debug, Error, PartialEq)]
#[derive(Clone, Debug, Error)]
pub enum BindingZone {
#[error("stage {0:?}")]
Stage(wgt::ShaderStage),
#[error("whole pipeline")]
Pipeline,
}

#[derive(Clone, Debug, Error, PartialEq)]
#[derive(Clone, Debug, Error)]
#[error("too many bindings of type {kind:?} in {zone}, limit is {count}")]
pub struct BindingTypeMaxCountError {
pub kind: BindingTypeMaxCountErrorKind,
pub zone: BindingZone,
pub count: u32,
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug)]
pub enum BindingTypeMaxCountErrorKind {
DynamicUniformBuffers,
DynamicStorageBuffers,
Expand Down Expand Up @@ -336,7 +336,7 @@ impl<B: hal::Backend> Resource for BindGroupLayout<B> {
}
}

#[derive(Clone, Debug, Error, PartialEq)]
#[derive(Clone, Debug, Error)]
pub enum CreatePipelineLayoutError {
#[error(transparent)]
Device(#[from] DeviceError),
Expand Down
Loading

0 comments on commit 928d739

Please sign in to comment.