Replace Type::(Is|As)Texture with Castable
Change-Id: I53bbccc3e1e7b88ad8c201997cf7e2e485ad9c81 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34272 Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
d734dd0c10
commit
38409c79dc
|
@ -310,12 +310,14 @@ Function::ReferencedSampledTextureVariablesImpl(bool multisampled) const {
|
|||
|
||||
for (auto* var : referenced_module_variables()) {
|
||||
auto* unwrapped_type = var->type()->UnwrapIfNeeded();
|
||||
if (!var->IsDecorated() || !unwrapped_type->IsTexture()) {
|
||||
if (!var->IsDecorated() || !unwrapped_type->Is<ast::type::TextureType>()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((multisampled && !unwrapped_type->AsTexture()->IsMultisampled()) ||
|
||||
(!multisampled && !unwrapped_type->AsTexture()->IsSampled())) {
|
||||
if ((multisampled &&
|
||||
!unwrapped_type->As<ast::type::TextureType>()->IsMultisampled()) ||
|
||||
(!multisampled &&
|
||||
!unwrapped_type->As<ast::type::TextureType>()->IsSampled())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "src/ast/type/matrix_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
|
||||
namespace tint {
|
||||
|
@ -61,7 +62,7 @@ TEST_F(AccessControlTypeTest, Is) {
|
|||
EXPECT_FALSE(ty->Is<PointerType>());
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->IsTexture());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "src/ast/type/matrix_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
|
||||
namespace tint {
|
||||
|
@ -62,7 +63,7 @@ TEST_F(AliasTypeTest, Is) {
|
|||
EXPECT_FALSE(ty->Is<PointerType>());
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->IsTexture());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "src/ast/type/matrix_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
|
||||
namespace tint {
|
||||
|
@ -68,7 +69,7 @@ TEST_F(ArrayTypeTest, Is) {
|
|||
EXPECT_FALSE(ty->Is<PointerType>());
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->IsTexture());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "src/ast/type/matrix_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
@ -43,7 +44,7 @@ TEST_F(BoolTypeTest, Is) {
|
|||
EXPECT_FALSE(ty->Is<PointerType>());
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->IsTexture());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ TEST_F(DepthTextureTypeTest, Is) {
|
|||
EXPECT_FALSE(ty->Is<PointerType>());
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_TRUE(ty->IsTexture());
|
||||
EXPECT_TRUE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "src/ast/type/matrix_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
@ -43,7 +44,7 @@ TEST_F(F32TypeTest, Is) {
|
|||
EXPECT_FALSE(ty->Is<PointerType>());
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->IsTexture());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "src/ast/type/matrix_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
@ -43,7 +44,7 @@ TEST_F(I32TypeTest, Is) {
|
|||
EXPECT_FALSE(ty->Is<PointerType>());
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->IsTexture());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "src/ast/type/i32_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
@ -52,7 +53,7 @@ TEST_F(MatrixTypeTest, Is) {
|
|||
EXPECT_FALSE(ty->Is<PointerType>());
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->IsTexture());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ TEST_F(MultisampledTextureTypeTest, Is) {
|
|||
EXPECT_FALSE(ty->Is<PointerType>());
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_TRUE(ty->IsTexture());
|
||||
EXPECT_TRUE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "src/ast/type/i32_type.h"
|
||||
#include "src/ast/type/matrix_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
@ -51,7 +52,7 @@ TEST_F(PointerTypeTest, Is) {
|
|||
EXPECT_TRUE(ty->Is<PointerType>());
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->IsTexture());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ TEST_F(SampledTextureTypeTest, Is) {
|
|||
EXPECT_FALSE(ty->Is<PointerType>());
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_TRUE(ty->IsTexture());
|
||||
EXPECT_TRUE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "src/ast/type/matrix_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
@ -55,7 +56,7 @@ TEST_F(SamplerTypeTest, Is) {
|
|||
EXPECT_FALSE(ty->Is<PointerType>());
|
||||
EXPECT_TRUE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->IsTexture());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ TEST_F(StorageTextureTypeTest, Is) {
|
|||
EXPECT_FALSE(ty->Is<PointerType>());
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_TRUE(ty->IsTexture());
|
||||
EXPECT_TRUE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
@ -95,9 +95,9 @@ TEST_F(StorageTextureTypeTest, F32Type) {
|
|||
TypeDeterminer td(&ctx, &mod);
|
||||
|
||||
ASSERT_TRUE(td.Determine()) << td.error();
|
||||
ASSERT_TRUE(s->IsTexture());
|
||||
ASSERT_TRUE(s->AsTexture()->IsStorage());
|
||||
EXPECT_TRUE(s->AsTexture()->AsStorage()->type()->Is<F32Type>());
|
||||
ASSERT_TRUE(s->Is<TextureType>());
|
||||
ASSERT_TRUE(s->As<TextureType>()->IsStorage());
|
||||
EXPECT_TRUE(s->As<TextureType>()->AsStorage()->type()->Is<F32Type>());
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTypeTest, U32Type) {
|
||||
|
@ -109,9 +109,9 @@ TEST_F(StorageTextureTypeTest, U32Type) {
|
|||
TypeDeterminer td(&ctx, &mod);
|
||||
|
||||
ASSERT_TRUE(td.Determine()) << td.error();
|
||||
ASSERT_TRUE(s->IsTexture());
|
||||
ASSERT_TRUE(s->AsTexture()->IsStorage());
|
||||
EXPECT_TRUE(s->AsTexture()->AsStorage()->type()->IsU32());
|
||||
ASSERT_TRUE(s->Is<TextureType>());
|
||||
ASSERT_TRUE(s->As<TextureType>()->IsStorage());
|
||||
EXPECT_TRUE(s->As<TextureType>()->AsStorage()->type()->IsU32());
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTypeTest, I32Type) {
|
||||
|
@ -123,9 +123,9 @@ TEST_F(StorageTextureTypeTest, I32Type) {
|
|||
TypeDeterminer td(&ctx, &mod);
|
||||
|
||||
ASSERT_TRUE(td.Determine()) << td.error();
|
||||
ASSERT_TRUE(s->IsTexture());
|
||||
ASSERT_TRUE(s->AsTexture()->IsStorage());
|
||||
EXPECT_TRUE(s->AsTexture()->AsStorage()->type()->Is<I32Type>());
|
||||
ASSERT_TRUE(s->Is<TextureType>());
|
||||
ASSERT_TRUE(s->As<TextureType>()->IsStorage());
|
||||
EXPECT_TRUE(s->As<TextureType>()->AsStorage()->type()->Is<I32Type>());
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTypeTest, MinBufferBindingSize) {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "src/ast/type/i32_type.h"
|
||||
#include "src/ast/type/matrix_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
#include "src/ast/type/vector_type.h"
|
||||
|
||||
|
@ -59,7 +60,7 @@ TEST_F(StructTypeTest, Is) {
|
|||
EXPECT_FALSE(ty->Is<PointerType>());
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_TRUE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->IsTexture());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
|
|
@ -61,10 +61,6 @@ TextureType::TextureType(TextureType&&) = default;
|
|||
|
||||
TextureType::~TextureType() = default;
|
||||
|
||||
bool TextureType::IsTexture() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TextureType::IsDepth() const {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -60,9 +60,6 @@ class TextureType : public Castable<TextureType, Type> {
|
|||
TextureType(TextureType&&);
|
||||
~TextureType() override;
|
||||
|
||||
/// @returns true if the type is a texture type
|
||||
bool IsTexture() const override;
|
||||
|
||||
/// @returns the texture dimension
|
||||
TextureDimension dim() const { return dim_; }
|
||||
|
||||
|
|
|
@ -66,10 +66,6 @@ Type* Type::UnwrapAll() {
|
|||
return UnwrapIfNeeded()->UnwrapPtrIfNeeded()->UnwrapIfNeeded();
|
||||
}
|
||||
|
||||
bool Type::IsTexture() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type::IsU32() const {
|
||||
return false;
|
||||
}
|
||||
|
@ -134,11 +130,6 @@ bool Type::is_integer_scalar_or_vector() {
|
|||
return is_unsigned_scalar_or_vector() || is_signed_scalar_or_vector();
|
||||
}
|
||||
|
||||
const TextureType* Type::AsTexture() const {
|
||||
assert(IsTexture());
|
||||
return static_cast<const TextureType*>(this);
|
||||
}
|
||||
|
||||
const U32Type* Type::AsU32() const {
|
||||
assert(IsU32());
|
||||
return static_cast<const U32Type*>(this);
|
||||
|
@ -154,11 +145,6 @@ const VoidType* Type::AsVoid() const {
|
|||
return static_cast<const VoidType*>(this);
|
||||
}
|
||||
|
||||
TextureType* Type::AsTexture() {
|
||||
assert(IsTexture());
|
||||
return static_cast<TextureType*>(this);
|
||||
}
|
||||
|
||||
U32Type* Type::AsU32() {
|
||||
assert(IsU32());
|
||||
return static_cast<U32Type*>(this);
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace tint {
|
|||
namespace ast {
|
||||
namespace type {
|
||||
|
||||
class TextureType;
|
||||
class U32Type;
|
||||
class VectorType;
|
||||
class VoidType;
|
||||
|
@ -38,8 +37,6 @@ class Type : public Castable<Type> {
|
|||
Type(Type&&);
|
||||
~Type() override;
|
||||
|
||||
/// @returns true if the type is a texture type
|
||||
virtual bool IsTexture() const;
|
||||
/// @returns true if the type is a u32 type
|
||||
virtual bool IsU32() const;
|
||||
/// @returns true if the type is a vec type
|
||||
|
@ -101,8 +98,6 @@ class Type : public Castable<Type> {
|
|||
/// @returns true if this type is an integer scalar or vector
|
||||
bool is_integer_scalar_or_vector();
|
||||
|
||||
/// @returns the type as a texture type
|
||||
const TextureType* AsTexture() const;
|
||||
/// @returns the type as a u32 type
|
||||
const U32Type* AsU32() const;
|
||||
/// @returns the type as a vector type
|
||||
|
@ -110,8 +105,6 @@ class Type : public Castable<Type> {
|
|||
/// @returns the type as a void type
|
||||
const VoidType* AsVoid() const;
|
||||
|
||||
/// @returns the type as a texture type
|
||||
TextureType* AsTexture();
|
||||
/// @returns the type as a u32 type
|
||||
U32Type* AsU32();
|
||||
/// @returns the type as a vector type
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/sampler_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
@ -45,7 +46,7 @@ TEST_F(U32TypeTest, Is) {
|
|||
EXPECT_FALSE(ty->Is<PointerType>());
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->IsTexture());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_TRUE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "src/ast/type/matrix_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
@ -52,7 +53,7 @@ TEST_F(VectorTypeTest, Is) {
|
|||
EXPECT_FALSE(ty->Is<PointerType>());
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->IsTexture());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_TRUE(ty->IsVector());
|
||||
}
|
||||
|
|
|
@ -350,7 +350,8 @@ std::vector<ResourceBinding> Inspector::GetSampledTextureResourceBindingsImpl(
|
|||
entry.bind_group = binding_info.set->value();
|
||||
entry.binding = binding_info.binding->value();
|
||||
|
||||
auto* texture_type = var->type()->UnwrapIfNeeded()->AsTexture();
|
||||
auto* texture_type =
|
||||
var->type()->UnwrapIfNeeded()->As<ast::type::TextureType>();
|
||||
switch (texture_type->dim()) {
|
||||
case ast::type::TextureDimension::k1d:
|
||||
entry.dim = ResourceBinding::TextureDimension::k1d;
|
||||
|
|
|
@ -3711,7 +3711,8 @@ bool FunctionEmitter::EmitSampledImageAccess(
|
|||
// integer.
|
||||
if (ast::type::PointerType* type =
|
||||
parser_impl_.GetTypeForHandleVar(*image)) {
|
||||
if (ast::type::TextureType* texture_type = type->type()->AsTexture()) {
|
||||
if (ast::type::TextureType* texture_type =
|
||||
type->type()->As<ast::type::TextureType>()) {
|
||||
if (texture_type->IsDepth()) {
|
||||
// Convert it to an unsigned integer type.
|
||||
lod_operand = ast_module_.create<ast::TypeConstructorExpression>(
|
||||
|
@ -3782,11 +3783,12 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess(
|
|||
Fail();
|
||||
return {};
|
||||
}
|
||||
if (!type || !type->type()->IsTexture()) {
|
||||
if (!type || !type->type()->Is<ast::type::TextureType>()) {
|
||||
Fail() << "invalid texture type for " << image->PrettyPrint();
|
||||
return {};
|
||||
}
|
||||
ast::type::TextureDimension dim = type->type()->AsTexture()->dim();
|
||||
ast::type::TextureDimension dim =
|
||||
type->type()->As<ast::type::TextureType>()->dim();
|
||||
// Number of regular coordinates.
|
||||
uint32_t num_axes = 0;
|
||||
bool is_arrayed = false;
|
||||
|
|
|
@ -36,9 +36,10 @@ TEST_F(ParserImplTest, DepthTextureType_2d) {
|
|||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsDepth());
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k2d);
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsDepth());
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
|
||||
ast::type::TextureDimension::k2d);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
@ -48,9 +49,10 @@ TEST_F(ParserImplTest, DepthTextureType_2dArray) {
|
|||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsDepth());
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k2dArray);
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsDepth());
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
|
||||
ast::type::TextureDimension::k2dArray);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
@ -60,9 +62,10 @@ TEST_F(ParserImplTest, DepthTextureType_Cube) {
|
|||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsDepth());
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::kCube);
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsDepth());
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
|
||||
ast::type::TextureDimension::kCube);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
@ -72,9 +75,10 @@ TEST_F(ParserImplTest, DepthTextureType_CubeArray) {
|
|||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsDepth());
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::kCubeArray);
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsDepth());
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
|
||||
ast::type::TextureDimension::kCubeArray);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
|
|
@ -64,9 +64,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
|
|||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsDepth());
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k2d);
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsDepth());
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
|
||||
ast::type::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32_Old) {
|
||||
|
@ -76,10 +77,14 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32_Old) {
|
|||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsSampled());
|
||||
ASSERT_TRUE(t->AsTexture()->AsSampled()->type()->Is<ast::type::F32Type>());
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k1d);
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsSampled());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()
|
||||
->AsSampled()
|
||||
->type()
|
||||
->Is<ast::type::F32Type>());
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
|
||||
ast::type::TextureDimension::k1d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32_Old) {
|
||||
|
@ -89,10 +94,14 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32_Old) {
|
|||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsSampled());
|
||||
ASSERT_TRUE(t->AsTexture()->AsSampled()->type()->Is<ast::type::I32Type>());
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k2d);
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsSampled());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()
|
||||
->AsSampled()
|
||||
->type()
|
||||
->Is<ast::type::I32Type>());
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
|
||||
ast::type::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32_Old) {
|
||||
|
@ -102,10 +111,11 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32_Old) {
|
|||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsSampled());
|
||||
ASSERT_TRUE(t->AsTexture()->AsSampled()->type()->IsU32());
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k3d);
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsSampled());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->AsSampled()->type()->IsU32());
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
|
||||
ast::type::TextureDimension::k3d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_Invalid_Old) {
|
||||
|
@ -156,10 +166,14 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32) {
|
|||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsSampled());
|
||||
ASSERT_TRUE(t->AsTexture()->AsSampled()->type()->Is<ast::type::F32Type>());
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k1d);
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsSampled());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()
|
||||
->AsSampled()
|
||||
->type()
|
||||
->Is<ast::type::F32Type>());
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
|
||||
ast::type::TextureDimension::k1d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) {
|
||||
|
@ -169,10 +183,14 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) {
|
|||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsSampled());
|
||||
ASSERT_TRUE(t->AsTexture()->AsSampled()->type()->Is<ast::type::I32Type>());
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k2d);
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsSampled());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()
|
||||
->AsSampled()
|
||||
->type()
|
||||
->Is<ast::type::I32Type>());
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
|
||||
ast::type::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) {
|
||||
|
@ -182,10 +200,11 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) {
|
|||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsSampled());
|
||||
ASSERT_TRUE(t->AsTexture()->AsSampled()->type()->IsU32());
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k3d);
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsSampled());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->AsSampled()->type()->IsU32());
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
|
||||
ast::type::TextureDimension::k3d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_Invalid) {
|
||||
|
@ -235,11 +254,14 @@ TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_I32) {
|
|||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsMultisampled());
|
||||
ASSERT_TRUE(
|
||||
t->AsTexture()->AsMultisampled()->type()->Is<ast::type::I32Type>());
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k2d);
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsMultisampled());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()
|
||||
->AsMultisampled()
|
||||
->type()
|
||||
->Is<ast::type::I32Type>());
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
|
||||
ast::type::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_Invalid) {
|
||||
|
@ -290,13 +312,14 @@ TEST_F(ParserImplTest,
|
|||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsStorage());
|
||||
EXPECT_EQ(t->AsTexture()->AsStorage()->image_format(),
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsStorage());
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->AsStorage()->image_format(),
|
||||
ast::type::ImageFormat::kR8Unorm);
|
||||
EXPECT_EQ(t->AsTexture()->AsStorage()->access(),
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->AsStorage()->access(),
|
||||
ast::AccessControl::kReadOnly);
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k1d);
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
|
||||
ast::type::TextureDimension::k1d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest,
|
||||
|
@ -307,13 +330,14 @@ TEST_F(ParserImplTest,
|
|||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsStorage());
|
||||
EXPECT_EQ(t->AsTexture()->AsStorage()->image_format(),
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsStorage());
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->AsStorage()->image_format(),
|
||||
ast::type::ImageFormat::kR16Float);
|
||||
EXPECT_EQ(t->AsTexture()->AsStorage()->access(),
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->AsStorage()->access(),
|
||||
ast::AccessControl::kWriteOnly);
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k2d);
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
|
||||
ast::type::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType_Old) {
|
||||
|
@ -360,13 +384,14 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dR8Unorm) {
|
|||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsStorage());
|
||||
EXPECT_EQ(t->AsTexture()->AsStorage()->image_format(),
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsStorage());
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->AsStorage()->image_format(),
|
||||
ast::type::ImageFormat::kR8Unorm);
|
||||
EXPECT_EQ(t->AsTexture()->AsStorage()->access(),
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->AsStorage()->access(),
|
||||
ast::AccessControl::kReadOnly);
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k1d);
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
|
||||
ast::type::TextureDimension::k1d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
|
||||
|
@ -376,13 +401,14 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
|
|||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsStorage());
|
||||
EXPECT_EQ(t->AsTexture()->AsStorage()->image_format(),
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsStorage());
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->AsStorage()->image_format(),
|
||||
ast::type::ImageFormat::kR16Float);
|
||||
EXPECT_EQ(t->AsTexture()->AsStorage()->access(),
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->AsStorage()->access(),
|
||||
ast::AccessControl::kWriteOnly);
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k2d);
|
||||
EXPECT_EQ(t->As<ast::type::TextureType>()->dim(),
|
||||
ast::type::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType) {
|
||||
|
|
|
@ -764,9 +764,12 @@ TEST_F(ParserImplTest, TypeDecl_Texture_Old) {
|
|||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
EXPECT_EQ(t.value, type);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsSampled());
|
||||
ASSERT_TRUE(t->AsTexture()->AsSampled()->type()->Is<ast::type::F32Type>());
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsSampled());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()
|
||||
->AsSampled()
|
||||
->type()
|
||||
->Is<ast::type::F32Type>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Texture) {
|
||||
|
@ -782,9 +785,12 @@ TEST_F(ParserImplTest, TypeDecl_Texture) {
|
|||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
EXPECT_EQ(t.value, type);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsSampled());
|
||||
ASSERT_TRUE(t->AsTexture()->AsSampled()->type()->Is<ast::type::F32Type>());
|
||||
ASSERT_TRUE(t->Is<ast::type::TextureType>());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()->IsSampled());
|
||||
ASSERT_TRUE(t->As<ast::type::TextureType>()
|
||||
->AsSampled()
|
||||
->type()
|
||||
->Is<ast::type::F32Type>());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -85,10 +85,12 @@ void TypeDeterminer::set_referenced_from_function_if_needed(
|
|||
bool TypeDeterminer::Determine() {
|
||||
for (auto& iter : mod_->types()) {
|
||||
auto& type = iter.second;
|
||||
if (!type->IsTexture() || !type->AsTexture()->IsStorage()) {
|
||||
if (!type->Is<ast::type::TextureType>() ||
|
||||
!type->As<ast::type::TextureType>()->IsStorage()) {
|
||||
continue;
|
||||
}
|
||||
if (!DetermineStorageTextureSubtype(type->AsTexture()->AsStorage())) {
|
||||
if (!DetermineStorageTextureSubtype(
|
||||
type->As<ast::type::TextureType>()->AsStorage())) {
|
||||
set_error(Source{}, "unable to determine storage texture subtype for: " +
|
||||
type->type_name());
|
||||
return false;
|
||||
|
@ -550,12 +552,15 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
|||
ast::intrinsic::TextureSignature::Parameters param;
|
||||
|
||||
auto* texture_param = expr->params()[0];
|
||||
if (!texture_param->result_type()->UnwrapPtrIfNeeded()->IsTexture()) {
|
||||
if (!texture_param->result_type()
|
||||
->UnwrapPtrIfNeeded()
|
||||
->Is<ast::type::TextureType>()) {
|
||||
set_error(expr->source(), "invalid first argument for " + ident->name());
|
||||
return false;
|
||||
}
|
||||
ast::type::TextureType* texture =
|
||||
texture_param->result_type()->UnwrapPtrIfNeeded()->AsTexture();
|
||||
ast::type::TextureType* texture = texture_param->result_type()
|
||||
->UnwrapPtrIfNeeded()
|
||||
->As<ast::type::TextureType>();
|
||||
|
||||
bool is_array = false;
|
||||
switch (texture->dim()) {
|
||||
|
|
|
@ -2089,8 +2089,8 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
|||
out << "State";
|
||||
} else if (type->Is<ast::type::StructType>()) {
|
||||
out << type->As<ast::type::StructType>()->name();
|
||||
} else if (type->IsTexture()) {
|
||||
auto* tex = type->AsTexture();
|
||||
} else if (type->Is<ast::type::TextureType>()) {
|
||||
auto* tex = type->As<ast::type::TextureType>();
|
||||
if (tex->IsStorage()) {
|
||||
out << "RW";
|
||||
}
|
||||
|
|
|
@ -712,7 +712,7 @@ bool GeneratorImpl::EmitTextureCall(ast::CallExpression* expr) {
|
|||
auto dim = params[pidx.texture]
|
||||
->result_type()
|
||||
->UnwrapPtrIfNeeded()
|
||||
->AsTexture()
|
||||
->As<ast::type::TextureType>()
|
||||
->dim();
|
||||
switch (dim) {
|
||||
case ast::type::TextureDimension::k2d:
|
||||
|
@ -1838,8 +1838,8 @@ bool GeneratorImpl::EmitType(ast::type::Type* type, const std::string& name) {
|
|||
// The struct type emits as just the name. The declaration would be emitted
|
||||
// as part of emitting the constructed types.
|
||||
out_ << type->As<ast::type::StructType>()->name();
|
||||
} else if (type->IsTexture()) {
|
||||
auto* tex = type->AsTexture();
|
||||
} else if (type->Is<ast::type::TextureType>()) {
|
||||
auto* tex = type->As<ast::type::TextureType>();
|
||||
|
||||
if (tex->IsDepth()) {
|
||||
out_ << "depth";
|
||||
|
|
|
@ -716,10 +716,10 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) {
|
|||
Operand::Int(ConvertStorageClass(sc))};
|
||||
if (var->has_constructor()) {
|
||||
ops.push_back(Operand::Int(init_id));
|
||||
} else if (type->IsTexture()) {
|
||||
} else if (type->Is<ast::type::TextureType>()) {
|
||||
// Decorate storage texture variables with NonRead/Writeable if needed.
|
||||
if (type->AsTexture()->IsStorage()) {
|
||||
switch (type->AsTexture()->AsStorage()->access()) {
|
||||
if (type->As<ast::type::TextureType>()->IsStorage()) {
|
||||
switch (type->As<ast::type::TextureType>()->AsStorage()->access()) {
|
||||
case ast::AccessControl::kWriteOnly:
|
||||
push_annot(
|
||||
spv::Op::OpDecorate,
|
||||
|
@ -1917,8 +1917,10 @@ void Builder::GenerateTextureIntrinsic(ast::IdentifierExpression* ident,
|
|||
ast::CallExpression* call,
|
||||
spirv::Operand result_type,
|
||||
spirv::Operand result_id) {
|
||||
auto* texture_type =
|
||||
call->params()[0]->result_type()->UnwrapAll()->AsTexture();
|
||||
auto* texture_type = call->params()[0]
|
||||
->result_type()
|
||||
->UnwrapAll()
|
||||
->As<ast::type::TextureType>();
|
||||
|
||||
auto* sig = static_cast<const ast::intrinsic::TextureSignature*>(
|
||||
ident->intrinsic_signature());
|
||||
|
@ -2453,8 +2455,8 @@ uint32_t Builder::GenerateTypeIfNeeded(ast::type::Type* type) {
|
|||
}
|
||||
} else if (type->IsVoid()) {
|
||||
push_type(spv::Op::OpTypeVoid, {result});
|
||||
} else if (type->IsTexture()) {
|
||||
if (!GenerateTextureType(type->AsTexture(), result)) {
|
||||
} else if (type->Is<ast::type::TextureType>()) {
|
||||
if (!GenerateTextureType(type->As<ast::type::TextureType>(), result)) {
|
||||
return 0;
|
||||
}
|
||||
} else if (type->Is<ast::type::SamplerType>()) {
|
||||
|
|
|
@ -464,8 +464,8 @@ bool GeneratorImpl::EmitType(ast::type::Type* type) {
|
|||
// The struct, as a type, is just the name. We should have already emitted
|
||||
// the declaration through a call to |EmitStructType| earlier.
|
||||
out_ << type->As<ast::type::StructType>()->name();
|
||||
} else if (type->IsTexture()) {
|
||||
auto* texture = type->AsTexture();
|
||||
} else if (type->Is<ast::type::TextureType>()) {
|
||||
auto* texture = type->As<ast::type::TextureType>();
|
||||
|
||||
out_ << "texture_";
|
||||
if (texture->IsDepth()) {
|
||||
|
|
Loading…
Reference in New Issue