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 3 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
16 changes: 14 additions & 2 deletions wgpu-hal/src/dx12/shader_compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ pub(super) fn compile_fxc(
mod dxc {
use std::path::PathBuf;

use hassle_rs::{DxcBlob, DxcOperationResult};

// Destructor order should be fine since _dxil and _dxc don't rely on each other.
pub(crate) struct DxcContainer {
compiler: hassle_rs::DxcCompiler,
Expand Down Expand Up @@ -176,6 +178,12 @@ mod dxc {
&[],
);

let format_error_message = |e: DxcOperationResult| {
Davidster marked this conversation as resolved.
Show resolved Hide resolved
e.get_error_buffer()
.and_then(|e| dxc_container.library.get_blob_as_string(&DxcBlob::from(e)))
.unwrap_or_default()
};

let (result, log_level) = match compiled {
Ok(dxc_result) => match dxc_result.get_result() {
Ok(dxc_blob) => {
Expand All @@ -188,7 +196,11 @@ mod dxc {
Err(e) => (
Err(crate::PipelineError::Linkage(
stage_bit,
format!("DXC validation error: {:?}\n{:?}", e.0, e.1),
format!(
"DXC validation error: {:?}\n{:?}",
format_error_message(e.0),
e.1
),
)),
log::Level::Error,
),
Expand All @@ -205,7 +217,7 @@ mod dxc {
Err(e) => (
Err(crate::PipelineError::Linkage(
stage_bit,
format!("DXC compile error: {e:?}"),
format!("DXC compile error: {:?}", format_error_message(e.0)),
)),
log::Level::Error,
),
Expand Down