From cc636273dad2d84c8d5a929d0276097f447437d2 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 10 Oct 2022 11:37:57 +0000 Subject: [PATCH] tint: Validate no f16 sampled textures Bug: chromium:1370417 Change-Id: Id78178ab61cd882ff8fcbbe96aa8123de512f9aa Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105120 Reviewed-by: Corentin Wallez Auto-Submit: Ben Clayton Kokoro: Kokoro Commit-Queue: Corentin Wallez --- src/tint/resolver/type_validation_test.cc | 6 ++++++ src/tint/resolver/validator.cc | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/tint/resolver/type_validation_test.cc b/src/tint/resolver/type_validation_test.cc index 4d75155846..7cc5cef557 100644 --- a/src/tint/resolver/type_validation_test.cc +++ b/src/tint/resolver/type_validation_test.cc @@ -1000,22 +1000,27 @@ static constexpr TypeParams type_cases[] = { TypeParamsFor(true), TypeParamsFor(true), TypeParamsFor(true), + TypeParamsFor(false), TypeParamsFor>(false), TypeParamsFor>(true), TypeParamsFor>(true), TypeParamsFor>(true), + TypeParamsFor>(false), TypeParamsFor>(false), TypeParamsFor>(false), + TypeParamsFor>(false), TypeParamsFor>>(false), TypeParamsFor>>(false), + TypeParamsFor>>(false), }; using SampledTextureTypeTest = ResolverTestWithParam; TEST_P(SampledTextureTypeTest, All) { auto& params = GetParam(); + Enable(ast::Extension::kF16); GlobalVar( "a", ty.sampled_texture(Source{{12, 34}}, ast::TextureDimension::k2d, params.type_func(*this)), @@ -1035,6 +1040,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest, using MultisampledTextureTypeTest = ResolverTestWithParam; TEST_P(MultisampledTextureTypeTest, All) { auto& params = GetParam(); + Enable(ast::Extension::kF16); GlobalVar("a", ty.multisampled_texture(Source{{12, 34}}, ast::TextureDimension::k2d, params.type_func(*this)), diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc index 36ac610365..687d17df29 100644 --- a/src/tint/resolver/validator.cc +++ b/src/tint/resolver/validator.cc @@ -287,7 +287,7 @@ bool Validator::StorageTexture(const ast::StorageTexture* t) const { } bool Validator::SampledTexture(const sem::SampledTexture* t, const Source& source) const { - if (!t->type()->UnwrapRef()->is_numeric_scalar()) { + if (!t->type()->UnwrapRef()->IsAnyOf()) { AddError("texture_2d: type must be f32, i32 or u32", source); return false; } @@ -301,7 +301,7 @@ bool Validator::MultisampledTexture(const sem::MultisampledTexture* t, const Sou return false; } - if (!t->type()->UnwrapRef()->is_numeric_scalar()) { + if (!t->type()->UnwrapRef()->IsAnyOf()) { AddError("texture_multisampled_2d: type must be f32, i32 or u32", source); return false; }