[spirv-reader] Drop NonWritable NonReadable for now
Pending WGSL issue https://github.com/gpuweb/gpuweb/issues/935
Bug: tint:3, tint:99
Change-Id: I90771e6e0c6a2f109fd6e361d79adea273ca7bc6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25261
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc
index 3cd3d7e..835508d 100644
--- a/src/reader/spirv/parser_impl.cc
+++ b/src/reader/spirv/parser_impl.cc
@@ -375,6 +375,11 @@
return nullptr;
}
return std::make_unique<ast::StructMemberOffsetDecoration>(decoration[1]);
+ case SpvDecorationNonReadable:
+ case SpvDecorationNonWritable:
+ // TODO(dneto): Drop these for now.
+ // https://github.com/gpuweb/gpuweb/issues/935
+ return nullptr;
default:
// TODO(dneto): Support the remaining member decorations.
break;
@@ -744,11 +749,12 @@
return nullptr;
} else {
auto ast_member_decoration = ConvertMemberDecoration(decoration);
- if (ast_member_decoration == nullptr) {
- // Already emitted diagnostics.
+ if (!success_) {
return nullptr;
}
- ast_member_decorations.push_back(std::move(ast_member_decoration));
+ if (ast_member_decoration) {
+ ast_member_decorations.push_back(std::move(ast_member_decoration));
+ }
}
}
const auto member_name = namer_.GetMemberName(type_id, member_index);
diff --git a/src/reader/spirv/parser_impl.h b/src/reader/spirv/parser_impl.h
index d304aad..623e1b2 100644
--- a/src/reader/spirv/parser_impl.h
+++ b/src/reader/spirv/parser_impl.h
@@ -182,8 +182,9 @@
DecorationList GetDecorationsForMember(uint32_t id,
uint32_t member_index) const;
- /// Converts a SPIR-V decoration. On failure, emits a diagnostic and returns
- /// nullptr.
+ /// Converts a SPIR-V decoration. If the decoration is recognized but
+ /// deliberately dropped, then returns nullptr without a diagnostic.
+ /// On failure, emits a diagnostic and returns nullptr.
/// @param decoration an encoded SPIR-V Decoration
/// @returns the corresponding ast::StructuMemberDecoration
std::unique_ptr<ast::StructMemberDecoration> ConvertMemberDecoration(
diff --git a/src/reader/spirv/parser_impl_module_var_test.cc b/src/reader/spirv/parser_impl_module_var_test.cc
index dac8467..564784c 100644
--- a/src/reader/spirv/parser_impl_module_var_test.cc
+++ b/src/reader/spirv/parser_impl_module_var_test.cc
@@ -1292,6 +1292,50 @@
"instruction, found '4'."));
}
+TEST_F(SpvParserTest, ModuleScopeVar_NonReadableDecoration_DroppedForNow) {
+ auto* p = parser(test::Assemble(R"(
+ OpName %myvar "myvar"
+ OpDecorate %strct Block
+ OpMemberDecorate %strct 0 NonReadable
+)" + CommonTypes() + R"(
+ %ptr_sb_strct = OpTypePointer StorageBuffer %strct
+ %myvar = OpVariable %ptr_sb_strct StorageBuffer
+ )"));
+ ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
+ EXPECT_TRUE(p->error().empty());
+ const auto module_str = p->module().to_str();
+ EXPECT_THAT(module_str, HasSubstr(R"(
+ Variable{
+ myvar
+ storage_buffer
+ __alias_S__struct_S
+ }
+S -> __struct_S
+})")) << module_str;
+}
+
+TEST_F(SpvParserTest, ModuleScopeVar_NonWritableDecoration_DroppedForNow) {
+ auto* p = parser(test::Assemble(R"(
+ OpName %myvar "myvar"
+ OpDecorate %strct Block
+ OpMemberDecorate %strct 0 NonWritable
+)" + CommonTypes() + R"(
+ %ptr_sb_strct = OpTypePointer StorageBuffer %strct
+ %myvar = OpVariable %ptr_sb_strct StorageBuffer
+ )"));
+ ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
+ EXPECT_TRUE(p->error().empty());
+ const auto module_str = p->module().to_str();
+ EXPECT_THAT(module_str, HasSubstr(R"(
+ Variable{
+ myvar
+ storage_buffer
+ __alias_S__struct_S
+ }
+S -> __struct_S
+})")) << module_str;
+}
+
} // namespace
} // namespace spirv
} // namespace reader