type::StorageTexture: Remove set_type()
The subtype of a storage texture is statically determinisic from the ImageFormat, and does not need to be late-set by the TypeDeterminer. Add StorageTexture::SubtypeFor() helper for returning the subtype for a given ImageFormat, and add the subtype as another immutable constructor parameter. Bug: tint:390 Change-Id: Ibe732293e3142064b60f4e666a7eb39ae8db50e7 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40064 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
b17aea159c
commit
48b384168c
|
@ -177,9 +177,8 @@ ast::Variable* TextureOverloadCase::buildTextureVariable(
|
|||
nullptr, decos);
|
||||
|
||||
case ast::intrinsic::test::TextureKind::kStorage: {
|
||||
auto* st =
|
||||
b->create<type::StorageTexture>(texture_dimension, image_format);
|
||||
st->set_type(datatype);
|
||||
auto* st = b->create<type::StorageTexture>(texture_dimension,
|
||||
image_format, datatype);
|
||||
|
||||
auto* ac = b->create<type::AccessControl>(access_control, st);
|
||||
return b->Global("texture", ast::StorageClass::kUniformConstant, ac,
|
||||
|
|
|
@ -1894,8 +1894,9 @@ type::Pointer* ParserImpl::GetTypeForHandleVar(
|
|||
if (format == type::ImageFormat::kNone) {
|
||||
return nullptr;
|
||||
}
|
||||
auto* subtype = type::StorageTexture::SubtypeFor(format, &builder_);
|
||||
ast_store_type = builder_.create<type::AccessControl>(
|
||||
access, builder_.create<type::StorageTexture>(dim, format));
|
||||
access, builder_.create<type::StorageTexture>(dim, format, subtype));
|
||||
}
|
||||
} else {
|
||||
Fail() << "unsupported: UniformConstant variable is not a recognized "
|
||||
|
|
|
@ -543,7 +543,9 @@ Maybe<type::Type*> ParserImpl::texture_sampler_types() {
|
|||
if (format.errored)
|
||||
return Failure::kErrored;
|
||||
|
||||
return builder_.create<type::StorageTexture>(storage.value, format.value);
|
||||
auto* subtype = type::StorageTexture::SubtypeFor(format.value, &builder_);
|
||||
return builder_.create<type::StorageTexture>(storage.value, format.value,
|
||||
subtype);
|
||||
}
|
||||
|
||||
return Failure::kNoMatch;
|
||||
|
|
|
@ -141,16 +141,10 @@ std::ostream& operator<<(std::ostream& out, ImageFormat format) {
|
|||
return out;
|
||||
}
|
||||
|
||||
StorageTexture::StorageTexture(TextureDimension dim, ImageFormat format)
|
||||
: Base(dim), image_format_(format) {}
|
||||
|
||||
void StorageTexture::set_type(Type* const type) {
|
||||
type_ = type;
|
||||
}
|
||||
|
||||
Type* StorageTexture::type() const {
|
||||
return type_;
|
||||
}
|
||||
StorageTexture::StorageTexture(TextureDimension dim,
|
||||
ImageFormat format,
|
||||
type::Type* subtype)
|
||||
: Base(dim), image_format_(format), subtype_(subtype) {}
|
||||
|
||||
StorageTexture::StorageTexture(StorageTexture&&) = default;
|
||||
|
||||
|
@ -163,7 +157,62 @@ std::string StorageTexture::type_name() const {
|
|||
}
|
||||
|
||||
StorageTexture* StorageTexture::Clone(CloneContext* ctx) const {
|
||||
return ctx->dst->create<StorageTexture>(dim(), image_format_);
|
||||
return ctx->dst->create<StorageTexture>(dim(), image_format_,
|
||||
ctx->Clone(subtype_));
|
||||
}
|
||||
|
||||
type::Type* StorageTexture::SubtypeFor(type::ImageFormat format,
|
||||
ProgramBuilder* builder) {
|
||||
switch (format) {
|
||||
case type::ImageFormat::kR8Uint:
|
||||
case type::ImageFormat::kR16Uint:
|
||||
case type::ImageFormat::kRg8Uint:
|
||||
case type::ImageFormat::kR32Uint:
|
||||
case type::ImageFormat::kRg16Uint:
|
||||
case type::ImageFormat::kRgba8Uint:
|
||||
case type::ImageFormat::kRg32Uint:
|
||||
case type::ImageFormat::kRgba16Uint:
|
||||
case type::ImageFormat::kRgba32Uint: {
|
||||
return builder->create<type::U32>();
|
||||
}
|
||||
|
||||
case type::ImageFormat::kR8Sint:
|
||||
case type::ImageFormat::kR16Sint:
|
||||
case type::ImageFormat::kRg8Sint:
|
||||
case type::ImageFormat::kR32Sint:
|
||||
case type::ImageFormat::kRg16Sint:
|
||||
case type::ImageFormat::kRgba8Sint:
|
||||
case type::ImageFormat::kRg32Sint:
|
||||
case type::ImageFormat::kRgba16Sint:
|
||||
case type::ImageFormat::kRgba32Sint: {
|
||||
return builder->create<type::I32>();
|
||||
}
|
||||
|
||||
case type::ImageFormat::kR8Unorm:
|
||||
case type::ImageFormat::kRg8Unorm:
|
||||
case type::ImageFormat::kRgba8Unorm:
|
||||
case type::ImageFormat::kRgba8UnormSrgb:
|
||||
case type::ImageFormat::kBgra8Unorm:
|
||||
case type::ImageFormat::kBgra8UnormSrgb:
|
||||
case type::ImageFormat::kRgb10A2Unorm:
|
||||
case type::ImageFormat::kR8Snorm:
|
||||
case type::ImageFormat::kRg8Snorm:
|
||||
case type::ImageFormat::kRgba8Snorm:
|
||||
case type::ImageFormat::kR16Float:
|
||||
case type::ImageFormat::kR32Float:
|
||||
case type::ImageFormat::kRg16Float:
|
||||
case type::ImageFormat::kRg11B10Float:
|
||||
case type::ImageFormat::kRg32Float:
|
||||
case type::ImageFormat::kRgba16Float:
|
||||
case type::ImageFormat::kRgba32Float: {
|
||||
return builder->create<type::F32>();
|
||||
}
|
||||
|
||||
case type::ImageFormat::kNone:
|
||||
break;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
|
|
@ -69,17 +69,15 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
|
|||
/// Constructor
|
||||
/// @param dim the dimensionality of the texture
|
||||
/// @param format the image format of the texture
|
||||
StorageTexture(TextureDimension dim, ImageFormat format);
|
||||
/// @param subtype the storage subtype. Use SubtypeFor() to calculate this.
|
||||
StorageTexture(TextureDimension dim, ImageFormat format, type::Type* subtype);
|
||||
|
||||
/// Move constructor
|
||||
StorageTexture(StorageTexture&&);
|
||||
~StorageTexture() override;
|
||||
|
||||
/// @param type the subtype of the storage texture
|
||||
void set_type(Type* const type);
|
||||
|
||||
/// @returns the subtype of the storage texture set with set_type
|
||||
Type* type() const;
|
||||
/// @returns the storage subtype
|
||||
Type* type() const { return subtype_; }
|
||||
|
||||
/// @returns the image format
|
||||
ImageFormat image_format() const { return image_format_; }
|
||||
|
@ -92,10 +90,14 @@ class StorageTexture : public Castable<StorageTexture, Texture> {
|
|||
/// @return the newly cloned type
|
||||
StorageTexture* Clone(CloneContext* ctx) const override;
|
||||
|
||||
/// @param format the storage texture image format
|
||||
/// @param builder the ProgramBuilder used to build the returned type
|
||||
/// @returns the storage texture subtype for the given ImageFormat
|
||||
static type::Type* SubtypeFor(ImageFormat format, ProgramBuilder* builder);
|
||||
|
||||
private:
|
||||
ImageFormat const image_format_;
|
||||
|
||||
Type* type_ = nullptr; // Semantic info
|
||||
Type* const subtype_;
|
||||
};
|
||||
|
||||
} // namespace type
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2020 The Tint Authors.
|
||||
// Copyright 2020 The Tint Authors->
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -39,8 +39,10 @@ namespace {
|
|||
using StorageTextureTest = TestHelper;
|
||||
|
||||
TEST_F(StorageTextureTest, Is) {
|
||||
StorageTexture s(TextureDimension::k2dArray, ImageFormat::kRgba32Float);
|
||||
Type* ty = &s;
|
||||
auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, this);
|
||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
|
||||
ImageFormat::kRgba32Float, subtype);
|
||||
Type* ty = s;
|
||||
EXPECT_FALSE(ty->Is<AccessControl>());
|
||||
EXPECT_FALSE(ty->Is<Alias>());
|
||||
EXPECT_FALSE(ty->Is<Array>());
|
||||
|
@ -57,31 +59,41 @@ TEST_F(StorageTextureTest, Is) {
|
|||
}
|
||||
|
||||
TEST_F(StorageTextureTest, IsTexture) {
|
||||
StorageTexture s(TextureDimension::k2dArray, ImageFormat::kRgba32Float);
|
||||
Texture* ty = &s;
|
||||
auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, this);
|
||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
|
||||
ImageFormat::kRgba32Float, subtype);
|
||||
Texture* ty = s;
|
||||
EXPECT_FALSE(ty->Is<DepthTexture>());
|
||||
EXPECT_FALSE(ty->Is<SampledTexture>());
|
||||
EXPECT_TRUE(ty->Is<StorageTexture>());
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTest, Dim) {
|
||||
StorageTexture s(TextureDimension::k2dArray, ImageFormat::kRgba32Float);
|
||||
EXPECT_EQ(s.dim(), TextureDimension::k2dArray);
|
||||
auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, this);
|
||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
|
||||
ImageFormat::kRgba32Float, subtype);
|
||||
EXPECT_EQ(s->dim(), TextureDimension::k2dArray);
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTest, Format) {
|
||||
StorageTexture s(TextureDimension::k2dArray, ImageFormat::kRgba32Float);
|
||||
EXPECT_EQ(s.image_format(), ImageFormat::kRgba32Float);
|
||||
auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, this);
|
||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
|
||||
ImageFormat::kRgba32Float, subtype);
|
||||
EXPECT_EQ(s->image_format(), ImageFormat::kRgba32Float);
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTest, TypeName) {
|
||||
StorageTexture s(TextureDimension::k2dArray, ImageFormat::kRgba32Float);
|
||||
EXPECT_EQ(s.type_name(), "__storage_texture_2d_array_rgba32float");
|
||||
auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, this);
|
||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
|
||||
ImageFormat::kRgba32Float, subtype);
|
||||
EXPECT_EQ(s->type_name(), "__storage_texture_2d_array_rgba32float");
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTest, F32) {
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(ImageFormat::kRgba32Float, this);
|
||||
Type* s = create<StorageTexture>(TextureDimension::k2dArray,
|
||||
ImageFormat::kRgba32Float);
|
||||
ImageFormat::kRgba32Float, subtype);
|
||||
TypeDeterminer td(this);
|
||||
|
||||
ASSERT_TRUE(td.Determine()) << td.error();
|
||||
|
@ -91,8 +103,10 @@ TEST_F(StorageTextureTest, F32) {
|
|||
}
|
||||
|
||||
TEST_F(StorageTextureTest, U32) {
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(ImageFormat::kRg32Uint, this);
|
||||
Type* s = create<StorageTexture>(TextureDimension::k2dArray,
|
||||
ImageFormat::kRg32Uint);
|
||||
ImageFormat::kRg32Uint, subtype);
|
||||
TypeDeterminer td(this);
|
||||
|
||||
ASSERT_TRUE(td.Determine()) << td.error();
|
||||
|
@ -102,8 +116,10 @@ TEST_F(StorageTextureTest, U32) {
|
|||
}
|
||||
|
||||
TEST_F(StorageTextureTest, I32) {
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(ImageFormat::kRgba32Sint, this);
|
||||
Type* s = create<StorageTexture>(TextureDimension::k2dArray,
|
||||
ImageFormat::kRgba32Sint);
|
||||
ImageFormat::kRgba32Sint, subtype);
|
||||
TypeDeterminer td(this);
|
||||
|
||||
ASSERT_TRUE(td.Determine()) << td.error();
|
||||
|
@ -113,8 +129,10 @@ TEST_F(StorageTextureTest, I32) {
|
|||
}
|
||||
|
||||
TEST_F(StorageTextureTest, MinBufferBindingSize) {
|
||||
StorageTexture s(TextureDimension::k2dArray, ImageFormat::kRgba32Sint);
|
||||
EXPECT_EQ(0u, s.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
auto* subtype = StorageTexture::SubtypeFor(ImageFormat::kRgba32Sint, this);
|
||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray,
|
||||
ImageFormat::kRgba32Sint, subtype);
|
||||
EXPECT_EQ(0u, s->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -116,23 +116,6 @@ bool TypeDeterminer::Determine() {
|
|||
}
|
||||
|
||||
bool TypeDeterminer::DetermineInternal() {
|
||||
std::vector<type::StorageTexture*> storage_textures;
|
||||
|
||||
for (auto& it : builder_->Types().types()) {
|
||||
if (auto* storage =
|
||||
it.second->UnwrapIfNeeded()->As<type::StorageTexture>()) {
|
||||
storage_textures.emplace_back(storage);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* storage : storage_textures) {
|
||||
if (!DetermineStorageTextureSubtype(storage)) {
|
||||
set_error(Source{}, "unable to determine storage texture subtype for: " +
|
||||
storage->type_name());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* var : builder_->AST().GlobalVariables()) {
|
||||
variable_stack_.set_global(var->symbol(), CreateVariableInfo(var));
|
||||
|
||||
|
@ -1166,66 +1149,6 @@ TypeDeterminer::VariableInfo* TypeDeterminer::CreateVariableInfo(
|
|||
return info;
|
||||
}
|
||||
|
||||
bool TypeDeterminer::DetermineStorageTextureSubtype(type::StorageTexture* tex) {
|
||||
if (tex->type() != nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (tex->image_format()) {
|
||||
case type::ImageFormat::kR8Uint:
|
||||
case type::ImageFormat::kR16Uint:
|
||||
case type::ImageFormat::kRg8Uint:
|
||||
case type::ImageFormat::kR32Uint:
|
||||
case type::ImageFormat::kRg16Uint:
|
||||
case type::ImageFormat::kRgba8Uint:
|
||||
case type::ImageFormat::kRg32Uint:
|
||||
case type::ImageFormat::kRgba16Uint:
|
||||
case type::ImageFormat::kRgba32Uint: {
|
||||
tex->set_type(builder_->create<type::U32>());
|
||||
return true;
|
||||
}
|
||||
|
||||
case type::ImageFormat::kR8Sint:
|
||||
case type::ImageFormat::kR16Sint:
|
||||
case type::ImageFormat::kRg8Sint:
|
||||
case type::ImageFormat::kR32Sint:
|
||||
case type::ImageFormat::kRg16Sint:
|
||||
case type::ImageFormat::kRgba8Sint:
|
||||
case type::ImageFormat::kRg32Sint:
|
||||
case type::ImageFormat::kRgba16Sint:
|
||||
case type::ImageFormat::kRgba32Sint: {
|
||||
tex->set_type(builder_->create<type::I32>());
|
||||
return true;
|
||||
}
|
||||
|
||||
case type::ImageFormat::kR8Unorm:
|
||||
case type::ImageFormat::kRg8Unorm:
|
||||
case type::ImageFormat::kRgba8Unorm:
|
||||
case type::ImageFormat::kRgba8UnormSrgb:
|
||||
case type::ImageFormat::kBgra8Unorm:
|
||||
case type::ImageFormat::kBgra8UnormSrgb:
|
||||
case type::ImageFormat::kRgb10A2Unorm:
|
||||
case type::ImageFormat::kR8Snorm:
|
||||
case type::ImageFormat::kRg8Snorm:
|
||||
case type::ImageFormat::kRgba8Snorm:
|
||||
case type::ImageFormat::kR16Float:
|
||||
case type::ImageFormat::kR32Float:
|
||||
case type::ImageFormat::kRg16Float:
|
||||
case type::ImageFormat::kRg11B10Float:
|
||||
case type::ImageFormat::kRg32Float:
|
||||
case type::ImageFormat::kRgba16Float:
|
||||
case type::ImageFormat::kRgba32Float: {
|
||||
tex->set_type(builder_->create<type::F32>());
|
||||
return true;
|
||||
}
|
||||
|
||||
case type::ImageFormat::kNone:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void TypeDeterminer::SetType(ast::Expression* expr, type::Type* type) const {
|
||||
return builder_->Sem().Add(expr,
|
||||
builder_->create<semantic::Expression>(type));
|
||||
|
|
|
@ -148,10 +148,6 @@ class TypeDeterminer {
|
|||
/// @param stmt the statement to check
|
||||
/// @returns false on error
|
||||
bool DetermineVariableStorageClass(ast::Statement* stmt);
|
||||
/// Determines the result type based off a storage texture format
|
||||
/// @param tex the storage texture
|
||||
/// @returns false on error
|
||||
bool DetermineStorageTextureSubtype(type::StorageTexture* tex);
|
||||
|
||||
/// Creates the nodes and adds them to the semantic::Info mappings of the
|
||||
/// ProgramBuilder.
|
||||
|
|
|
@ -1323,7 +1323,8 @@ TEST_P(Intrinsic_StorageTextureOperation, TextureLoadRo) {
|
|||
|
||||
auto* coords_type = get_coords_type(dim, ty.i32());
|
||||
|
||||
type::Type* texture_type = create<type::StorageTexture>(dim, format);
|
||||
auto* subtype = type::StorageTexture::SubtypeFor(format, this);
|
||||
type::Type* texture_type = create<type::StorageTexture>(dim, format, subtype);
|
||||
|
||||
ast::ExpressionList call_params;
|
||||
|
||||
|
|
|
@ -407,7 +407,8 @@ using HlslStoragetexturesTest = TestParamHelper<HlslStorageTextureData>;
|
|||
TEST_P(HlslStoragetexturesTest, Emit) {
|
||||
auto params = GetParam();
|
||||
|
||||
auto* s = create<type::StorageTexture>(params.dim, params.imgfmt);
|
||||
auto* subtype = type::StorageTexture::SubtypeFor(params.imgfmt, this);
|
||||
auto* s = create<type::StorageTexture>(params.dim, params.imgfmt, subtype);
|
||||
auto* ac =
|
||||
create<type::AccessControl>(params.ro ? ast::AccessControl::kReadOnly
|
||||
: ast::AccessControl::kWriteOnly,
|
||||
|
|
|
@ -421,8 +421,10 @@ using MslStorageTexturesTest = TestParamHelper<MslStorageTextureData>;
|
|||
TEST_P(MslStorageTexturesTest, Emit) {
|
||||
auto params = GetParam();
|
||||
|
||||
auto* s =
|
||||
create<type::StorageTexture>(params.dim, type::ImageFormat::kR16Float);
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, this);
|
||||
auto* s = create<type::StorageTexture>(params.dim,
|
||||
type::ImageFormat::kR16Float, subtype);
|
||||
auto* ac =
|
||||
create<type::AccessControl>(params.ro ? ast::AccessControl::kReadOnly
|
||||
: ast::AccessControl::kWriteOnly,
|
||||
|
|
|
@ -542,8 +542,10 @@ OpName %5 "c"
|
|||
TEST_F(BuilderTest, GlobalVar_TextureStorageReadOnly) {
|
||||
// var<uniform_constant> a : [[access(read)]] texture_storage_2d<r32uint>;
|
||||
|
||||
auto* type = create<type::StorageTexture>(type::TextureDimension::k2d,
|
||||
type::ImageFormat::kR32Uint);
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, this);
|
||||
auto* type = create<type::StorageTexture>(
|
||||
type::TextureDimension::k2d, type::ImageFormat::kR32Uint, subtype);
|
||||
|
||||
auto* ac = create<type::AccessControl>(ast::AccessControl::kReadOnly, type);
|
||||
|
||||
|
@ -565,8 +567,10 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageReadOnly) {
|
|||
TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) {
|
||||
// var<uniform_constant> a : [[access(write)]] texture_storage_2d<r32uint>;
|
||||
|
||||
auto* type = create<type::StorageTexture>(type::TextureDimension::k2d,
|
||||
type::ImageFormat::kR32Uint);
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, this);
|
||||
auto* type = create<type::StorageTexture>(
|
||||
type::TextureDimension::k2d, type::ImageFormat::kR32Uint, subtype);
|
||||
Global("test_var", ast::StorageClass::kNone, type);
|
||||
|
||||
auto* ac = create<type::AccessControl>(ast::AccessControl::kWriteOnly, type);
|
||||
|
@ -592,8 +596,10 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageWithDifferentAccess) {
|
|||
// var<uniform_constant> a : [[access(read)]] texture_storage_2d<r32uint>;
|
||||
// var<uniform_constant> b : [[access(write)]] texture_storage_2d<r32uint>;
|
||||
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, this);
|
||||
auto* st = create<type::StorageTexture>(type::TextureDimension::k2d,
|
||||
type::ImageFormat::kR32Uint);
|
||||
type::ImageFormat::kR32Uint, subtype);
|
||||
|
||||
Global("test_var", ast::StorageClass::kNone, st);
|
||||
|
||||
|
|
|
@ -874,8 +874,10 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R16Float) {
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, this);
|
||||
auto* s = create<type::StorageTexture>(type::TextureDimension::k1d,
|
||||
type::ImageFormat::kR16Float);
|
||||
type::ImageFormat::kR16Float, subtype);
|
||||
|
||||
Global("test_var", ast::StorageClass::kNone, s);
|
||||
|
||||
|
@ -894,8 +896,10 @@ OpCapability StorageImageExtendedFormats
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8SNorm) {
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Snorm, this);
|
||||
auto* s = create<type::StorageTexture>(type::TextureDimension::k1d,
|
||||
type::ImageFormat::kR8Snorm);
|
||||
type::ImageFormat::kR8Snorm, subtype);
|
||||
|
||||
Global("test_var", ast::StorageClass::kNone, s);
|
||||
|
||||
|
@ -914,8 +918,10 @@ OpCapability StorageImageExtendedFormats
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8UNorm) {
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Unorm, this);
|
||||
auto* s = create<type::StorageTexture>(type::TextureDimension::k1d,
|
||||
type::ImageFormat::kR8Unorm);
|
||||
type::ImageFormat::kR8Unorm, subtype);
|
||||
|
||||
Global("test_var", ast::StorageClass::kNone, s);
|
||||
|
||||
|
@ -934,8 +940,10 @@ OpCapability StorageImageExtendedFormats
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8Uint) {
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Uint, this);
|
||||
auto* s = create<type::StorageTexture>(type::TextureDimension::k1d,
|
||||
type::ImageFormat::kR8Uint);
|
||||
type::ImageFormat::kR8Uint, subtype);
|
||||
|
||||
Global("test_var", ast::StorageClass::kNone, s);
|
||||
|
||||
|
@ -949,8 +957,10 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8Uint) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8Sint) {
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(type::ImageFormat::kR8Sint, this);
|
||||
auto* s = create<type::StorageTexture>(type::TextureDimension::k1d,
|
||||
type::ImageFormat::kR8Sint);
|
||||
type::ImageFormat::kR8Sint, subtype);
|
||||
|
||||
Global("test_var", ast::StorageClass::kNone, s);
|
||||
|
||||
|
@ -964,8 +974,10 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8Sint) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_array) {
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, this);
|
||||
auto* s = create<type::StorageTexture>(type::TextureDimension::k1dArray,
|
||||
type::ImageFormat::kR16Float);
|
||||
type::ImageFormat::kR16Float, subtype);
|
||||
|
||||
Global("test_var", ast::StorageClass::kNone, s);
|
||||
|
||||
|
@ -984,8 +996,10 @@ OpCapability StorageImageExtendedFormats
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, this);
|
||||
auto* s = create<type::StorageTexture>(type::TextureDimension::k2d,
|
||||
type::ImageFormat::kR16Float);
|
||||
type::ImageFormat::kR16Float, subtype);
|
||||
|
||||
Global("test_var", ast::StorageClass::kNone, s);
|
||||
|
||||
|
@ -999,8 +1013,10 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, this);
|
||||
auto* s = create<type::StorageTexture>(type::TextureDimension::k2dArray,
|
||||
type::ImageFormat::kR16Float);
|
||||
type::ImageFormat::kR16Float, subtype);
|
||||
|
||||
Global("test_var", ast::StorageClass::kNone, s);
|
||||
|
||||
|
@ -1014,8 +1030,10 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(type::ImageFormat::kR16Float, this);
|
||||
auto* s = create<type::StorageTexture>(type::TextureDimension::k3d,
|
||||
type::ImageFormat::kR16Float);
|
||||
type::ImageFormat::kR16Float, subtype);
|
||||
|
||||
Global("test_var", ast::StorageClass::kNone, s);
|
||||
|
||||
|
@ -1030,8 +1048,10 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
|
|||
|
||||
TEST_F(BuilderTest_Type,
|
||||
StorageTexture_Generate_SampledTypeFloat_Format_r32float) {
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Float, this);
|
||||
auto* s = create<type::StorageTexture>(type::TextureDimension::k2d,
|
||||
type::ImageFormat::kR32Float);
|
||||
type::ImageFormat::kR32Float, subtype);
|
||||
|
||||
Global("test_var", ast::StorageClass::kNone, s);
|
||||
|
||||
|
@ -1046,8 +1066,10 @@ TEST_F(BuilderTest_Type,
|
|||
|
||||
TEST_F(BuilderTest_Type,
|
||||
StorageTexture_Generate_SampledTypeSint_Format_r32sint) {
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Sint, this);
|
||||
auto* s = create<type::StorageTexture>(type::TextureDimension::k2d,
|
||||
type::ImageFormat::kR32Sint);
|
||||
type::ImageFormat::kR32Sint, subtype);
|
||||
|
||||
Global("test_var", ast::StorageClass::kNone, s);
|
||||
|
||||
|
@ -1062,8 +1084,10 @@ TEST_F(BuilderTest_Type,
|
|||
|
||||
TEST_F(BuilderTest_Type,
|
||||
StorageTexture_Generate_SampledTypeUint_Format_r32uint) {
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(type::ImageFormat::kR32Uint, this);
|
||||
auto* s = create<type::StorageTexture>(type::TextureDimension::k2d,
|
||||
type::ImageFormat::kR32Uint);
|
||||
type::ImageFormat::kR32Uint, subtype);
|
||||
|
||||
Global("test_var", ast::StorageClass::kNone, s);
|
||||
|
||||
|
|
|
@ -386,7 +386,8 @@ using WgslGenerator_StorageTextureTest = TestParamHelper<StorageTextureData>;
|
|||
TEST_P(WgslGenerator_StorageTextureTest, EmitType_StorageTexture) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* t = create<type::StorageTexture>(param.dim, param.fmt);
|
||||
auto* subtype = type::StorageTexture::SubtypeFor(param.fmt, this);
|
||||
auto* t = create<type::StorageTexture>(param.dim, param.fmt, subtype);
|
||||
auto* ac = create<type::AccessControl>(param.access, t);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
|
Loading…
Reference in New Issue