Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dxc error message formatting #3632

Merged
merged 4 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,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