Check if source is empty when constructing hal::DebugSource (0.18 backport) (#4693)

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
This commit is contained in:
Daniel JacobsandTeodor Tanasoaia authored and Connor Fitzgerald committed 2023-11-15 14:34:24 -05:00
1 parent 957e2849dd
commit ca96cb428c
1 file changed
+13 -12
+13 -12
View File
@@ -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)