Replace TextureType::(Is|As)Depth with Castable

Change-Id: I2f1785cec1880f728fbbf0c75762bc957e34ca0a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34276
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2020-11-30 23:30:58 +00:00
parent 16ec1bb626
commit 09b8829d8e
15 changed files with 39 additions and 52 deletions

View File

@@ -53,6 +53,7 @@
#include "src/ast/storage_class.h"
#include "src/ast/switch_statement.h"
#include "src/ast/type/bool_type.h"
#include "src/ast/type/depth_texture_type.h"
#include "src/ast/type/f32_type.h"
#include "src/ast/type/pointer_type.h"
#include "src/ast/type/texture_type.h"
@@ -3714,7 +3715,7 @@ bool FunctionEmitter::EmitSampledImageAccess(
parser_impl_.GetTypeForHandleVar(*image)) {
if (ast::type::TextureType* texture_type =
type->type()->As<ast::type::TextureType>()) {
if (texture_type->IsDepth()) {
if (texture_type->Is<ast::type::DepthTextureType>()) {
// Convert it to an unsigned integer type.
lod_operand = ast_module_.create<ast::TypeConstructorExpression>(
ast_module_.create<ast::type::U32Type>(),

View File

@@ -37,7 +37,8 @@ TEST_F(ParserImplTest, DepthTextureType_2d) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsDepth());
ASSERT_TRUE(
t->As<ast::type::TextureType>()->Is<ast::type::DepthTextureType>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ast::type::TextureDimension::k2d);
EXPECT_FALSE(p->has_error());
@@ -50,7 +51,8 @@ TEST_F(ParserImplTest, DepthTextureType_2dArray) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsDepth());
ASSERT_TRUE(
t->As<ast::type::TextureType>()->Is<ast::type::DepthTextureType>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ast::type::TextureDimension::k2dArray);
EXPECT_FALSE(p->has_error());
@@ -63,7 +65,8 @@ TEST_F(ParserImplTest, DepthTextureType_Cube) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsDepth());
ASSERT_TRUE(
t->As<ast::type::TextureType>()->Is<ast::type::DepthTextureType>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ast::type::TextureDimension::kCube);
EXPECT_FALSE(p->has_error());
@@ -76,7 +79,8 @@ TEST_F(ParserImplTest, DepthTextureType_CubeArray) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsDepth());
ASSERT_TRUE(
t->As<ast::type::TextureType>()->Is<ast::type::DepthTextureType>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ast::type::TextureDimension::kCubeArray);
EXPECT_FALSE(p->has_error());

View File

@@ -13,6 +13,7 @@
// limitations under the License.
#include "gtest/gtest.h"
#include "src/ast/type/depth_texture_type.h"
#include "src/ast/type/f32_type.h"
#include "src/ast/type/i32_type.h"
#include "src/ast/type/multisampled_texture_type.h"
@@ -66,7 +67,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
ASSERT_TRUE(t->Is<ast::type::TextureType>());
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsDepth());
ASSERT_TRUE(t->Is<ast::type::DepthTextureType>());
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
ast::type::TextureDimension::k2d);
}