Skip to content

Commit

Permalink
Check if source is empty when constructing hal::DebugSource (0.18…
Browse files Browse the repository at this point in the history
… backport) (gfx-rs#4693)

Co-authored-by: Teodor Tanasoaia <[email protected]>
  • Loading branch information
2 people authored and cwfitzgerald committed Nov 15, 2023
1 parent 957e284 commit ca96cb4
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions wgpu-core/src/device/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1317,18 +1317,19 @@ impl<A: HalApi> Device<A> {
.contains(wgt::DownlevelFlags::CUBE_ARRAY_TEXTURES),
);

let debug_source = if self.instance_flags.contains(wgt::InstanceFlags::DEBUG) {
Some(hal::DebugSource {
file_name: Cow::Owned(
desc.label
.as_ref()
.map_or("shader".to_string(), |l| l.to_string()),
),
source_code: Cow::Owned(source.clone()),
})
} else {
None
};
let debug_source =
if self.instance_flags.contains(wgt::InstanceFlags::DEBUG) && !source.is_empty() {
Some(hal::DebugSource {
file_name: Cow::Owned(
desc.label
.as_ref()
.map_or("shader".to_string(), |l| l.to_string()),
),
source_code: Cow::Owned(source.clone()),
})
} else {
None
};

let info = naga::valid::Validator::new(naga::valid::ValidationFlags::all(), caps)
.validate(&module)
Expand Down

0 comments on commit ca96cb4

Please sign in to comment.