Skip to content

Commit

Permalink
add dxc error message formatting (#3632)
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidster authored Apr 10, 2023
1 parent 2c37608 commit 4d15567
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ By @cwfitzgerald in [#3610](https://github.com/gfx-rs/wgpu/pull/3610).
- Improve attachment related errors. By @cwfitzgerald in [#3549](https://github.com/gfx-rs/wgpu/pull/3549)
- Make error descriptions all upper case. By @cwfitzgerald in [#3549](https://github.com/gfx-rs/wgpu/pull/3549)
- Don't include ANSI terminal color escape sequences in shader module validation error messages. By @jimblandy in [#3591](https://github.com/gfx-rs/wgpu/pull/3591)
- Report error messages from DXC compile. By @Davidster in [#3632](https://github.com/gfx-rs/wgpu/pull/3632)

#### WebGPU

Expand Down
22 changes: 20 additions & 2 deletions wgpu-hal/src/dx12/shader_compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ mod dxc {
Err(e) => (
Err(crate::PipelineError::Linkage(
stage_bit,
format!("DXC validation error: {:?}\n{:?}", e.0, e.1),
format!(
"DXC validation error: {:?}\n{:?}",
get_error_string_from_dxc_result(&dxc_container.library, &e.0)
.unwrap_or_default(),
e.1
),
)),
log::Level::Error,
),
Expand All @@ -205,7 +210,11 @@ mod dxc {
Err(e) => (
Err(crate::PipelineError::Linkage(
stage_bit,
format!("DXC compile error: {e:?}"),
format!(
"DXC compile error: {:?}",
get_error_string_from_dxc_result(&dxc_container.library, &e.0)
.unwrap_or_default()
),
)),
log::Level::Error,
),
Expand Down Expand Up @@ -240,6 +249,15 @@ mod dxc {
}
}
}

fn get_error_string_from_dxc_result(
library: &hassle_rs::DxcLibrary,
error: &hassle_rs::DxcOperationResult,
) -> Result<String, hassle_rs::HassleError> {
error
.get_error_buffer()
.and_then(|error| library.get_blob_as_string(&hassle_rs::DxcBlob::from(error)))
}
}

// These are stubs for when the `dxc_shader_compiler` feature is disabled.
Expand Down

0 comments on commit 4d15567

Please sign in to comment.