Skip to content

Commit

Permalink
Print errors in a more readable format in the player. (#4137)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicolas Silva <[email protected]>
  • Loading branch information
nical and Nicolas Silva authored Sep 14, 2023
1 parent 7fea9e9 commit 90b022d
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions player/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
let (cmd_buf, error) = self
.command_encoder_finish::<A>(encoder, &wgt::CommandBufferDescriptor { label: None });
if let Some(e) = error {
panic!("{:?}", e);
panic!("{e}");
}
cmd_buf
}
Expand Down Expand Up @@ -186,7 +186,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
self.device_maintain_ids::<A>(device).unwrap();
let (_, error) = self.device_create_buffer::<A>(device, &desc, id);
if let Some(e) = error {
panic!("{:?}", e);
panic!("{e}");
}
}
Action::FreeBuffer(id) => {
Expand All @@ -199,7 +199,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
self.device_maintain_ids::<A>(device).unwrap();
let (_, error) = self.device_create_texture::<A>(device, &desc, id);
if let Some(e) = error {
panic!("{:?}", e);
panic!("{e}");
}
}
Action::FreeTexture(id) => {
Expand All @@ -216,7 +216,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
self.device_maintain_ids::<A>(device).unwrap();
let (_, error) = self.texture_create_view::<A>(parent_id, &desc, id);
if let Some(e) = error {
panic!("{:?}", e);
panic!("{e}");
}
}
Action::DestroyTextureView(id) => {
Expand All @@ -226,7 +226,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
self.device_maintain_ids::<A>(device).unwrap();
let (_, error) = self.device_create_sampler::<A>(device, &desc, id);
if let Some(e) = error {
panic!("{:?}", e);
panic!("{e}");
}
}
Action::DestroySampler(id) => {
Expand All @@ -242,7 +242,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
Action::CreateBindGroupLayout(id, desc) => {
let (_, error) = self.device_create_bind_group_layout::<A>(device, &desc, id);
if let Some(e) = error {
panic!("{:?}", e);
panic!("{e}");
}
}
Action::DestroyBindGroupLayout(id) => {
Expand All @@ -252,7 +252,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
self.device_maintain_ids::<A>(device).unwrap();
let (_, error) = self.device_create_pipeline_layout::<A>(device, &desc, id);
if let Some(e) = error {
panic!("{:?}", e);
panic!("{e}");
}
}
Action::DestroyPipelineLayout(id) => {
Expand All @@ -262,7 +262,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
self.device_maintain_ids::<A>(device).unwrap();
let (_, error) = self.device_create_bind_group::<A>(device, &desc, id);
if let Some(e) = error {
panic!("{:?}", e);
panic!("{e}");
}
}
Action::DestroyBindGroup(id) => {
Expand All @@ -272,7 +272,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
log::info!("Creating shader from {}", data);
let code = fs::read_to_string(dir.join(&data)).unwrap();
let source = if data.ends_with(".wgsl") {
wgc::pipeline::ShaderModuleSource::Wgsl(Cow::Owned(code))
wgc::pipeline::ShaderModuleSource::Wgsl(Cow::Owned(code.clone()))
} else if data.ends_with(".ron") {
let module = ron::de::from_str(&code).unwrap();
wgc::pipeline::ShaderModuleSource::Naga(module)
Expand All @@ -281,7 +281,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
};
let (_, error) = self.device_create_shader_module::<A>(device, &desc, source, id);
if let Some(e) = error {
panic!("{:?}", e);
println!("shader compilation error:\n---{code}\n---\n{e}");
}
}
Action::DestroyShaderModule(id) => {
Expand All @@ -303,7 +303,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
let (_, error) =
self.device_create_compute_pipeline::<A>(device, &desc, id, implicit_ids);
if let Some(e) = error {
panic!("{:?}", e);
panic!("{e}");
}
}
Action::DestroyComputePipeline(id) => {
Expand All @@ -325,7 +325,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
let (_, error) =
self.device_create_render_pipeline::<A>(device, &desc, id, implicit_ids);
if let Some(e) = error {
panic!("{:?}", e);
panic!("{e}");
}
}
Action::DestroyRenderPipeline(id) => {
Expand All @@ -340,7 +340,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
id,
);
if let Some(e) = error {
panic!("{:?}", e);
panic!("{e}");
}
}
Action::DestroyRenderBundle(id) => {
Expand All @@ -350,7 +350,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
self.device_maintain_ids::<A>(device).unwrap();
let (_, error) = self.device_create_query_set::<A>(device, &desc, id);
if let Some(e) = error {
panic!("{:?}", e);
panic!("{e}");
}
}
Action::DestroyQuerySet(id) => {
Expand Down Expand Up @@ -393,7 +393,7 @@ impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
comb_manager.alloc(device.backend()),
);
if let Some(e) = error {
panic!("{:?}", e);
panic!("{e}");
}
let cmdbuf = self.encode_commands::<A>(encoder, commands);
self.queue_submit::<A>(device, &[cmdbuf]).unwrap();
Expand Down

0 comments on commit 90b022d

Please sign in to comment.