Replace Type::(Is|As)Sampler with Castable
Change-Id: Iaa43e607199e25308ecb121c61bb7a37abff197c Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34270 Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
c52f4214ad
commit
351128a41e
|
@ -281,8 +281,8 @@ Function::ReferencedSamplerVariablesImpl(type::SamplerKind kind) const {
|
||||||
|
|
||||||
for (auto* var : referenced_module_variables()) {
|
for (auto* var : referenced_module_variables()) {
|
||||||
auto* unwrapped_type = var->type()->UnwrapIfNeeded();
|
auto* unwrapped_type = var->type()->UnwrapIfNeeded();
|
||||||
if (!var->IsDecorated() || !unwrapped_type->IsSampler() ||
|
if (!var->IsDecorated() || !unwrapped_type->Is<ast::type::SamplerType>() ||
|
||||||
unwrapped_type->AsSampler()->kind() != kind) {
|
unwrapped_type->As<ast::type::SamplerType>()->kind() != kind) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ TEST_F(AccessControlTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<I32Type>());
|
EXPECT_FALSE(ty->Is<I32Type>());
|
||||||
EXPECT_FALSE(ty->Is<MatrixType>());
|
EXPECT_FALSE(ty->Is<MatrixType>());
|
||||||
EXPECT_FALSE(ty->Is<PointerType>());
|
EXPECT_FALSE(ty->Is<PointerType>());
|
||||||
EXPECT_FALSE(ty->IsSampler());
|
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||||
EXPECT_FALSE(ty->IsStruct());
|
EXPECT_FALSE(ty->IsStruct());
|
||||||
EXPECT_FALSE(ty->IsTexture());
|
EXPECT_FALSE(ty->IsTexture());
|
||||||
EXPECT_FALSE(ty->IsU32());
|
EXPECT_FALSE(ty->IsU32());
|
||||||
|
|
|
@ -60,7 +60,7 @@ TEST_F(AliasTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<I32Type>());
|
EXPECT_FALSE(ty->Is<I32Type>());
|
||||||
EXPECT_FALSE(ty->Is<MatrixType>());
|
EXPECT_FALSE(ty->Is<MatrixType>());
|
||||||
EXPECT_FALSE(ty->Is<PointerType>());
|
EXPECT_FALSE(ty->Is<PointerType>());
|
||||||
EXPECT_FALSE(ty->IsSampler());
|
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||||
EXPECT_FALSE(ty->IsStruct());
|
EXPECT_FALSE(ty->IsStruct());
|
||||||
EXPECT_FALSE(ty->IsTexture());
|
EXPECT_FALSE(ty->IsTexture());
|
||||||
EXPECT_FALSE(ty->IsU32());
|
EXPECT_FALSE(ty->IsU32());
|
||||||
|
|
|
@ -65,7 +65,7 @@ TEST_F(ArrayTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<I32Type>());
|
EXPECT_FALSE(ty->Is<I32Type>());
|
||||||
EXPECT_FALSE(ty->Is<MatrixType>());
|
EXPECT_FALSE(ty->Is<MatrixType>());
|
||||||
EXPECT_FALSE(ty->Is<PointerType>());
|
EXPECT_FALSE(ty->Is<PointerType>());
|
||||||
EXPECT_FALSE(ty->IsSampler());
|
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||||
EXPECT_FALSE(ty->IsStruct());
|
EXPECT_FALSE(ty->IsStruct());
|
||||||
EXPECT_FALSE(ty->IsTexture());
|
EXPECT_FALSE(ty->IsTexture());
|
||||||
EXPECT_FALSE(ty->IsU32());
|
EXPECT_FALSE(ty->IsU32());
|
||||||
|
|
|
@ -40,7 +40,7 @@ TEST_F(BoolTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<I32Type>());
|
EXPECT_FALSE(ty->Is<I32Type>());
|
||||||
EXPECT_FALSE(ty->Is<MatrixType>());
|
EXPECT_FALSE(ty->Is<MatrixType>());
|
||||||
EXPECT_FALSE(ty->Is<PointerType>());
|
EXPECT_FALSE(ty->Is<PointerType>());
|
||||||
EXPECT_FALSE(ty->IsSampler());
|
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||||
EXPECT_FALSE(ty->IsStruct());
|
EXPECT_FALSE(ty->IsStruct());
|
||||||
EXPECT_FALSE(ty->IsTexture());
|
EXPECT_FALSE(ty->IsTexture());
|
||||||
EXPECT_FALSE(ty->IsU32());
|
EXPECT_FALSE(ty->IsU32());
|
||||||
|
|
|
@ -42,7 +42,7 @@ TEST_F(DepthTextureTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<I32Type>());
|
EXPECT_FALSE(ty->Is<I32Type>());
|
||||||
EXPECT_FALSE(ty->Is<MatrixType>());
|
EXPECT_FALSE(ty->Is<MatrixType>());
|
||||||
EXPECT_FALSE(ty->Is<PointerType>());
|
EXPECT_FALSE(ty->Is<PointerType>());
|
||||||
EXPECT_FALSE(ty->IsSampler());
|
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||||
EXPECT_FALSE(ty->IsStruct());
|
EXPECT_FALSE(ty->IsStruct());
|
||||||
EXPECT_TRUE(ty->IsTexture());
|
EXPECT_TRUE(ty->IsTexture());
|
||||||
EXPECT_FALSE(ty->IsU32());
|
EXPECT_FALSE(ty->IsU32());
|
||||||
|
|
|
@ -40,7 +40,7 @@ TEST_F(F32TypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<I32Type>());
|
EXPECT_FALSE(ty->Is<I32Type>());
|
||||||
EXPECT_FALSE(ty->Is<MatrixType>());
|
EXPECT_FALSE(ty->Is<MatrixType>());
|
||||||
EXPECT_FALSE(ty->Is<PointerType>());
|
EXPECT_FALSE(ty->Is<PointerType>());
|
||||||
EXPECT_FALSE(ty->IsSampler());
|
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||||
EXPECT_FALSE(ty->IsStruct());
|
EXPECT_FALSE(ty->IsStruct());
|
||||||
EXPECT_FALSE(ty->IsTexture());
|
EXPECT_FALSE(ty->IsTexture());
|
||||||
EXPECT_FALSE(ty->IsU32());
|
EXPECT_FALSE(ty->IsU32());
|
||||||
|
|
|
@ -40,7 +40,7 @@ TEST_F(I32TypeTest, Is) {
|
||||||
EXPECT_TRUE(ty->Is<I32Type>());
|
EXPECT_TRUE(ty->Is<I32Type>());
|
||||||
EXPECT_FALSE(ty->Is<MatrixType>());
|
EXPECT_FALSE(ty->Is<MatrixType>());
|
||||||
EXPECT_FALSE(ty->Is<PointerType>());
|
EXPECT_FALSE(ty->Is<PointerType>());
|
||||||
EXPECT_FALSE(ty->IsSampler());
|
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||||
EXPECT_FALSE(ty->IsStruct());
|
EXPECT_FALSE(ty->IsStruct());
|
||||||
EXPECT_FALSE(ty->IsTexture());
|
EXPECT_FALSE(ty->IsTexture());
|
||||||
EXPECT_FALSE(ty->IsU32());
|
EXPECT_FALSE(ty->IsU32());
|
||||||
|
|
|
@ -49,7 +49,7 @@ TEST_F(MatrixTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<I32Type>());
|
EXPECT_FALSE(ty->Is<I32Type>());
|
||||||
EXPECT_TRUE(ty->Is<MatrixType>());
|
EXPECT_TRUE(ty->Is<MatrixType>());
|
||||||
EXPECT_FALSE(ty->Is<PointerType>());
|
EXPECT_FALSE(ty->Is<PointerType>());
|
||||||
EXPECT_FALSE(ty->IsSampler());
|
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||||
EXPECT_FALSE(ty->IsStruct());
|
EXPECT_FALSE(ty->IsStruct());
|
||||||
EXPECT_FALSE(ty->IsTexture());
|
EXPECT_FALSE(ty->IsTexture());
|
||||||
EXPECT_FALSE(ty->IsU32());
|
EXPECT_FALSE(ty->IsU32());
|
||||||
|
|
|
@ -42,7 +42,7 @@ TEST_F(MultisampledTextureTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<I32Type>());
|
EXPECT_FALSE(ty->Is<I32Type>());
|
||||||
EXPECT_FALSE(ty->Is<MatrixType>());
|
EXPECT_FALSE(ty->Is<MatrixType>());
|
||||||
EXPECT_FALSE(ty->Is<PointerType>());
|
EXPECT_FALSE(ty->Is<PointerType>());
|
||||||
EXPECT_FALSE(ty->IsSampler());
|
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||||
EXPECT_FALSE(ty->IsStruct());
|
EXPECT_FALSE(ty->IsStruct());
|
||||||
EXPECT_TRUE(ty->IsTexture());
|
EXPECT_TRUE(ty->IsTexture());
|
||||||
EXPECT_FALSE(ty->IsU32());
|
EXPECT_FALSE(ty->IsU32());
|
||||||
|
|
|
@ -48,7 +48,7 @@ TEST_F(PointerTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<I32Type>());
|
EXPECT_FALSE(ty->Is<I32Type>());
|
||||||
EXPECT_FALSE(ty->Is<MatrixType>());
|
EXPECT_FALSE(ty->Is<MatrixType>());
|
||||||
EXPECT_TRUE(ty->Is<PointerType>());
|
EXPECT_TRUE(ty->Is<PointerType>());
|
||||||
EXPECT_FALSE(ty->IsSampler());
|
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||||
EXPECT_FALSE(ty->IsStruct());
|
EXPECT_FALSE(ty->IsStruct());
|
||||||
EXPECT_FALSE(ty->IsTexture());
|
EXPECT_FALSE(ty->IsTexture());
|
||||||
EXPECT_FALSE(ty->IsU32());
|
EXPECT_FALSE(ty->IsU32());
|
||||||
|
|
|
@ -42,7 +42,7 @@ TEST_F(SampledTextureTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<I32Type>());
|
EXPECT_FALSE(ty->Is<I32Type>());
|
||||||
EXPECT_FALSE(ty->Is<MatrixType>());
|
EXPECT_FALSE(ty->Is<MatrixType>());
|
||||||
EXPECT_FALSE(ty->Is<PointerType>());
|
EXPECT_FALSE(ty->Is<PointerType>());
|
||||||
EXPECT_FALSE(ty->IsSampler());
|
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||||
EXPECT_FALSE(ty->IsStruct());
|
EXPECT_FALSE(ty->IsStruct());
|
||||||
EXPECT_TRUE(ty->IsTexture());
|
EXPECT_TRUE(ty->IsTexture());
|
||||||
EXPECT_FALSE(ty->IsU32());
|
EXPECT_FALSE(ty->IsU32());
|
||||||
|
|
|
@ -36,10 +36,6 @@ SamplerType::SamplerType(SamplerType&&) = default;
|
||||||
|
|
||||||
SamplerType::~SamplerType() = default;
|
SamplerType::~SamplerType() = default;
|
||||||
|
|
||||||
bool SamplerType::IsSampler() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string SamplerType::type_name() const {
|
std::string SamplerType::type_name() const {
|
||||||
return std::string("__sampler_") +
|
return std::string("__sampler_") +
|
||||||
(kind_ == SamplerKind::kSampler ? "sampler" : "comparison");
|
(kind_ == SamplerKind::kSampler ? "sampler" : "comparison");
|
||||||
|
|
|
@ -43,9 +43,6 @@ class SamplerType : public Castable<SamplerType, Type> {
|
||||||
SamplerType(SamplerType&&);
|
SamplerType(SamplerType&&);
|
||||||
~SamplerType() override;
|
~SamplerType() override;
|
||||||
|
|
||||||
/// @returns true if the type is a sampler type
|
|
||||||
bool IsSampler() const override;
|
|
||||||
|
|
||||||
/// @returns the sampler type
|
/// @returns the sampler type
|
||||||
SamplerKind kind() const { return kind_; }
|
SamplerKind kind() const { return kind_; }
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ TEST_F(SamplerTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<I32Type>());
|
EXPECT_FALSE(ty->Is<I32Type>());
|
||||||
EXPECT_FALSE(ty->Is<MatrixType>());
|
EXPECT_FALSE(ty->Is<MatrixType>());
|
||||||
EXPECT_FALSE(ty->Is<PointerType>());
|
EXPECT_FALSE(ty->Is<PointerType>());
|
||||||
EXPECT_TRUE(ty->IsSampler());
|
EXPECT_TRUE(ty->Is<SamplerType>());
|
||||||
EXPECT_FALSE(ty->IsStruct());
|
EXPECT_FALSE(ty->IsStruct());
|
||||||
EXPECT_FALSE(ty->IsTexture());
|
EXPECT_FALSE(ty->IsTexture());
|
||||||
EXPECT_FALSE(ty->IsU32());
|
EXPECT_FALSE(ty->IsU32());
|
||||||
|
|
|
@ -46,7 +46,7 @@ TEST_F(StorageTextureTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<I32Type>());
|
EXPECT_FALSE(ty->Is<I32Type>());
|
||||||
EXPECT_FALSE(ty->Is<MatrixType>());
|
EXPECT_FALSE(ty->Is<MatrixType>());
|
||||||
EXPECT_FALSE(ty->Is<PointerType>());
|
EXPECT_FALSE(ty->Is<PointerType>());
|
||||||
EXPECT_FALSE(ty->IsSampler());
|
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||||
EXPECT_FALSE(ty->IsStruct());
|
EXPECT_FALSE(ty->IsStruct());
|
||||||
EXPECT_TRUE(ty->IsTexture());
|
EXPECT_TRUE(ty->IsTexture());
|
||||||
EXPECT_FALSE(ty->IsU32());
|
EXPECT_FALSE(ty->IsU32());
|
||||||
|
|
|
@ -57,7 +57,7 @@ TEST_F(StructTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<I32Type>());
|
EXPECT_FALSE(ty->Is<I32Type>());
|
||||||
EXPECT_FALSE(ty->Is<MatrixType>());
|
EXPECT_FALSE(ty->Is<MatrixType>());
|
||||||
EXPECT_FALSE(ty->Is<PointerType>());
|
EXPECT_FALSE(ty->Is<PointerType>());
|
||||||
EXPECT_FALSE(ty->IsSampler());
|
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||||
EXPECT_TRUE(ty->IsStruct());
|
EXPECT_TRUE(ty->IsStruct());
|
||||||
EXPECT_FALSE(ty->IsTexture());
|
EXPECT_FALSE(ty->IsTexture());
|
||||||
EXPECT_FALSE(ty->IsU32());
|
EXPECT_FALSE(ty->IsU32());
|
||||||
|
|
|
@ -66,10 +66,6 @@ Type* Type::UnwrapAll() {
|
||||||
return UnwrapIfNeeded()->UnwrapPtrIfNeeded()->UnwrapIfNeeded();
|
return UnwrapIfNeeded()->UnwrapPtrIfNeeded()->UnwrapIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::IsSampler() const {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Type::IsStruct() const {
|
bool Type::IsStruct() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -142,11 +138,6 @@ bool Type::is_integer_scalar_or_vector() {
|
||||||
return is_unsigned_scalar_or_vector() || is_signed_scalar_or_vector();
|
return is_unsigned_scalar_or_vector() || is_signed_scalar_or_vector();
|
||||||
}
|
}
|
||||||
|
|
||||||
const SamplerType* Type::AsSampler() const {
|
|
||||||
assert(IsSampler());
|
|
||||||
return static_cast<const SamplerType*>(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
const StructType* Type::AsStruct() const {
|
const StructType* Type::AsStruct() const {
|
||||||
assert(IsStruct());
|
assert(IsStruct());
|
||||||
return static_cast<const StructType*>(this);
|
return static_cast<const StructType*>(this);
|
||||||
|
@ -172,11 +163,6 @@ const VoidType* Type::AsVoid() const {
|
||||||
return static_cast<const VoidType*>(this);
|
return static_cast<const VoidType*>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SamplerType* Type::AsSampler() {
|
|
||||||
assert(IsSampler());
|
|
||||||
return static_cast<SamplerType*>(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
StructType* Type::AsStruct() {
|
StructType* Type::AsStruct() {
|
||||||
assert(IsStruct());
|
assert(IsStruct());
|
||||||
return static_cast<StructType*>(this);
|
return static_cast<StructType*>(this);
|
||||||
|
|
|
@ -23,7 +23,6 @@ namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
class SamplerType;
|
|
||||||
class StructType;
|
class StructType;
|
||||||
class TextureType;
|
class TextureType;
|
||||||
class U32Type;
|
class U32Type;
|
||||||
|
@ -40,8 +39,6 @@ class Type : public Castable<Type> {
|
||||||
Type(Type&&);
|
Type(Type&&);
|
||||||
~Type() override;
|
~Type() override;
|
||||||
|
|
||||||
/// @returns true if the type is a sampler
|
|
||||||
virtual bool IsSampler() const;
|
|
||||||
/// @returns true if the type is a struct type
|
/// @returns true if the type is a struct type
|
||||||
virtual bool IsStruct() const;
|
virtual bool IsStruct() const;
|
||||||
/// @returns true if the type is a texture type
|
/// @returns true if the type is a texture type
|
||||||
|
@ -107,8 +104,6 @@ class Type : public Castable<Type> {
|
||||||
/// @returns true if this type is an integer scalar or vector
|
/// @returns true if this type is an integer scalar or vector
|
||||||
bool is_integer_scalar_or_vector();
|
bool is_integer_scalar_or_vector();
|
||||||
|
|
||||||
/// @returns the type as a sampler type
|
|
||||||
const SamplerType* AsSampler() const;
|
|
||||||
/// @returns the type as a struct type
|
/// @returns the type as a struct type
|
||||||
const StructType* AsStruct() const;
|
const StructType* AsStruct() const;
|
||||||
/// @returns the type as a texture type
|
/// @returns the type as a texture type
|
||||||
|
@ -120,8 +115,6 @@ class Type : public Castable<Type> {
|
||||||
/// @returns the type as a void type
|
/// @returns the type as a void type
|
||||||
const VoidType* AsVoid() const;
|
const VoidType* AsVoid() const;
|
||||||
|
|
||||||
/// @returns the type as a sampler type
|
|
||||||
SamplerType* AsSampler();
|
|
||||||
/// @returns the type as a struct type
|
/// @returns the type as a struct type
|
||||||
StructType* AsStruct();
|
StructType* AsStruct();
|
||||||
/// @returns the type as a texture type
|
/// @returns the type as a texture type
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/ast/type/i32_type.h"
|
||||||
#include "src/ast/type/matrix_type.h"
|
#include "src/ast/type/matrix_type.h"
|
||||||
#include "src/ast/type/pointer_type.h"
|
#include "src/ast/type/pointer_type.h"
|
||||||
|
#include "src/ast/type/sampler_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
@ -41,7 +42,7 @@ TEST_F(U32TypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<I32Type>());
|
EXPECT_FALSE(ty->Is<I32Type>());
|
||||||
EXPECT_FALSE(ty->Is<MatrixType>());
|
EXPECT_FALSE(ty->Is<MatrixType>());
|
||||||
EXPECT_FALSE(ty->Is<PointerType>());
|
EXPECT_FALSE(ty->Is<PointerType>());
|
||||||
EXPECT_FALSE(ty->IsSampler());
|
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||||
EXPECT_FALSE(ty->IsStruct());
|
EXPECT_FALSE(ty->IsStruct());
|
||||||
EXPECT_FALSE(ty->IsTexture());
|
EXPECT_FALSE(ty->IsTexture());
|
||||||
EXPECT_TRUE(ty->IsU32());
|
EXPECT_TRUE(ty->IsU32());
|
||||||
|
|
|
@ -49,7 +49,7 @@ TEST_F(VectorTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<I32Type>());
|
EXPECT_FALSE(ty->Is<I32Type>());
|
||||||
EXPECT_FALSE(ty->Is<MatrixType>());
|
EXPECT_FALSE(ty->Is<MatrixType>());
|
||||||
EXPECT_FALSE(ty->Is<PointerType>());
|
EXPECT_FALSE(ty->Is<PointerType>());
|
||||||
EXPECT_FALSE(ty->IsSampler());
|
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||||
EXPECT_FALSE(ty->IsStruct());
|
EXPECT_FALSE(ty->IsStruct());
|
||||||
EXPECT_FALSE(ty->IsTexture());
|
EXPECT_FALSE(ty->IsTexture());
|
||||||
EXPECT_FALSE(ty->IsU32());
|
EXPECT_FALSE(ty->IsU32());
|
||||||
|
|
|
@ -37,8 +37,8 @@ TEST_F(ParserImplTest, SamplerType_Sampler) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->IsSampler());
|
ASSERT_TRUE(t->Is<ast::type::SamplerType>());
|
||||||
EXPECT_FALSE(t->AsSampler()->IsComparison());
|
EXPECT_FALSE(t->As<ast::type::SamplerType>()->IsComparison());
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ TEST_F(ParserImplTest, SamplerType_ComparisonSampler) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->IsSampler());
|
ASSERT_TRUE(t->Is<ast::type::SamplerType>());
|
||||||
EXPECT_TRUE(t->AsSampler()->IsComparison());
|
EXPECT_TRUE(t->As<ast::type::SamplerType>()->IsComparison());
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_Sampler) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->IsSampler());
|
ASSERT_TRUE(t->Is<ast::type::SamplerType>());
|
||||||
ASSERT_FALSE(t->AsSampler()->IsComparison());
|
ASSERT_FALSE(t->As<ast::type::SamplerType>()->IsComparison());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) {
|
||||||
|
@ -53,8 +53,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) {
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr);
|
ASSERT_NE(t.value, nullptr);
|
||||||
ASSERT_TRUE(t->IsSampler());
|
ASSERT_TRUE(t->Is<ast::type::SamplerType>());
|
||||||
ASSERT_TRUE(t->AsSampler()->IsComparison());
|
ASSERT_TRUE(t->As<ast::type::SamplerType>()->IsComparison());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
|
TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
|
||||||
|
|
|
@ -747,8 +747,8 @@ TEST_F(ParserImplTest, TypeDecl_Sampler) {
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
EXPECT_EQ(t.value, type);
|
EXPECT_EQ(t.value, type);
|
||||||
ASSERT_TRUE(t->IsSampler());
|
ASSERT_TRUE(t->Is<ast::type::SamplerType>());
|
||||||
ASSERT_FALSE(t->AsSampler()->IsComparison());
|
ASSERT_FALSE(t->As<ast::type::SamplerType>()->IsComparison());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TypeDecl_Texture_Old) {
|
TEST_F(ParserImplTest, TypeDecl_Texture_Old) {
|
||||||
|
|
|
@ -2079,8 +2079,8 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
||||||
// https://bugs.chromium.org/p/tint/issues/detail?id=183
|
// https://bugs.chromium.org/p/tint/issues/detail?id=183
|
||||||
error_ = "pointers not supported in HLSL";
|
error_ = "pointers not supported in HLSL";
|
||||||
return false;
|
return false;
|
||||||
} else if (type->IsSampler()) {
|
} else if (type->Is<ast::type::SamplerType>()) {
|
||||||
auto* sampler = type->AsSampler();
|
auto* sampler = type->As<ast::type::SamplerType>();
|
||||||
out << "Sampler";
|
out << "Sampler";
|
||||||
if (sampler->IsComparison()) {
|
if (sampler->IsComparison()) {
|
||||||
out << "Comparison";
|
out << "Comparison";
|
||||||
|
|
|
@ -1832,7 +1832,7 @@ bool GeneratorImpl::EmitType(ast::type::Type* type, const std::string& name) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out_ << "*";
|
out_ << "*";
|
||||||
} else if (type->IsSampler()) {
|
} else if (type->Is<ast::type::SamplerType>()) {
|
||||||
out_ << "sampler";
|
out_ << "sampler";
|
||||||
} else if (type->IsStruct()) {
|
} else if (type->IsStruct()) {
|
||||||
// The struct type emits as just the name. The declaration would be emitted
|
// The struct type emits as just the name. The declaration would be emitted
|
||||||
|
|
|
@ -734,7 +734,7 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (!type->IsSampler()) {
|
} else if (!type->Is<ast::type::SamplerType>()) {
|
||||||
// Certain cases require us to generate a constructor value.
|
// Certain cases require us to generate a constructor value.
|
||||||
//
|
//
|
||||||
// 1- ConstantId's must be attached to the OpConstant, if we have a
|
// 1- ConstantId's must be attached to the OpConstant, if we have a
|
||||||
|
@ -2452,7 +2452,7 @@ uint32_t Builder::GenerateTypeIfNeeded(ast::type::Type* type) {
|
||||||
if (!GenerateTextureType(type->AsTexture(), result)) {
|
if (!GenerateTextureType(type->AsTexture(), result)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else if (type->IsSampler()) {
|
} else if (type->Is<ast::type::SamplerType>()) {
|
||||||
push_type(spv::Op::OpTypeSampler, {result});
|
push_type(spv::Op::OpTypeSampler, {result});
|
||||||
|
|
||||||
// Register both of the sampler type names. In SPIR-V they're the same
|
// Register both of the sampler type names. In SPIR-V they're the same
|
||||||
|
|
|
@ -453,8 +453,8 @@ bool GeneratorImpl::EmitType(ast::type::Type* type) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out_ << ">";
|
out_ << ">";
|
||||||
} else if (type->IsSampler()) {
|
} else if (type->Is<ast::type::SamplerType>()) {
|
||||||
auto* sampler = type->AsSampler();
|
auto* sampler = type->As<ast::type::SamplerType>();
|
||||||
out_ << "sampler";
|
out_ << "sampler";
|
||||||
|
|
||||||
if (sampler->IsComparison()) {
|
if (sampler->IsComparison()) {
|
||||||
|
|
Loading…
Reference in New Issue