Skip to content

Commit 18ceb51

Browse files
authored
[spv-out] Move request_type_capabilities outside of LocalType lookup
1 parent a364e56 commit 18ceb51

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

naga/src/back/spv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ impl LocalImageType {
248248
/// this, by converting everything possible to a `LocalType` before inspecting
249249
/// it.
250250
///
251-
/// ## `Localtype` equality and SPIR-V `OpType` uniqueness
251+
/// ## `LocalType` equality and SPIR-V `OpType` uniqueness
252252
///
253253
/// The definition of `Eq` on `LocalType` is carefully chosen to help us follow
254254
/// certain SPIR-V rules. SPIR-V §2.8 requires some classes of `OpType...`

naga/src/back/spv/writer.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,11 @@ impl Writer {
970970
handle: Handle<crate::Type>,
971971
) -> Result<Word, Error> {
972972
let ty = &arena[handle];
973+
// If it's a type that needs SPIR-V capabilities, request them now.
974+
// This needs to happen regardless of the LocalType lookup succeeding,
975+
// because some types which map to the same LocalType have different
976+
// capability requirements. See https://github.com/gfx-rs/wgpu/issues/5569
977+
self.request_type_capabilities(&ty.inner)?;
973978
let id = if let Some(local) = make_local(&ty.inner) {
974979
// This type can be represented as a `LocalType`, so check if we've
975980
// already written an instruction for it. If not, do so now, with
@@ -985,10 +990,6 @@ impl Writer {
985990

986991
self.write_type_declaration_local(id, local);
987992

988-
// If it's a type that needs SPIR-V capabilities, request them now,
989-
// so write_type_declaration_local can stay infallible.
990-
self.request_type_capabilities(&ty.inner)?;
991-
992993
id
993994
}
994995
}

0 commit comments

Comments
 (0)