Move TextureDimension to type/
This cl pulls TextureDimension out of ast/texture and into type/texture_dimension removing a type dependency on ast. Change-Id: Icf06ec32ee9051286f169ae9538c48416f513039 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117603 Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
d54dabeab5
commit
3cbf3fc4c5
|
@ -586,6 +586,7 @@ libtint_source_set("libtint_core_all_src") {
|
|||
"type/storage_texture.h",
|
||||
"type/struct.h",
|
||||
"type/texture.h",
|
||||
"type/texture_dimension.h",
|
||||
"type/type.h",
|
||||
"type/u32.h",
|
||||
"type/unique_node.h",
|
||||
|
@ -739,6 +740,8 @@ libtint_source_set("libtint_type_src") {
|
|||
"type/struct.h",
|
||||
"type/texture.cc",
|
||||
"type/texture.h",
|
||||
"type/texture_dimension.cc",
|
||||
"type/texture_dimension.h",
|
||||
"type/type.cc",
|
||||
"type/type.h",
|
||||
"type/u32.cc",
|
||||
|
|
|
@ -514,6 +514,8 @@ list(APPEND TINT_LIB_SRCS
|
|||
type/struct.h
|
||||
type/texture.cc
|
||||
type/texture.h
|
||||
type/texture_dimension.cc
|
||||
type/texture_dimension.h
|
||||
type/type.cc
|
||||
type/type.h
|
||||
type/u32.cc
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -20,6 +20,7 @@
|
|||
#include "src/tint/ast/access.h"
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::ast::builtin::test {
|
||||
|
||||
|
@ -185,7 +186,7 @@ struct TextureOverloadCase {
|
|||
const char*,
|
||||
TextureKind,
|
||||
ast::SamplerKind,
|
||||
ast::TextureDimension,
|
||||
type::TextureDimension,
|
||||
TextureDataType,
|
||||
const char*,
|
||||
std::function<Args(ProgramBuilder*)>);
|
||||
|
@ -193,7 +194,7 @@ struct TextureOverloadCase {
|
|||
TextureOverloadCase(ValidTextureOverload,
|
||||
const char*,
|
||||
TextureKind,
|
||||
ast::TextureDimension,
|
||||
type::TextureDimension,
|
||||
TextureDataType,
|
||||
const char*,
|
||||
std::function<Args(ProgramBuilder*)>);
|
||||
|
@ -202,7 +203,7 @@ struct TextureOverloadCase {
|
|||
const char*,
|
||||
Access,
|
||||
ast::TexelFormat,
|
||||
ast::TextureDimension,
|
||||
type::TextureDimension,
|
||||
TextureDataType,
|
||||
const char*,
|
||||
std::function<Args(ProgramBuilder*)>);
|
||||
|
@ -243,7 +244,7 @@ struct TextureOverloadCase {
|
|||
/// Used only when texture_kind is kStorage
|
||||
ast::TexelFormat const texel_format = ast::TexelFormat::kUndefined;
|
||||
/// The dimensions of the texture parameter
|
||||
ast::TextureDimension const texture_dimension;
|
||||
type::TextureDimension const texture_dimension;
|
||||
/// The data type of the texture parameter
|
||||
const TextureDataType texture_data_type;
|
||||
/// Name of the function. e.g. `textureSample`, `textureSampleGrad`, etc
|
||||
|
|
|
@ -21,8 +21,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::DepthMultisampledTexture);
|
|||
namespace tint::ast {
|
||||
namespace {
|
||||
|
||||
bool IsValidDepthDimension(TextureDimension dim) {
|
||||
return dim == TextureDimension::k2d;
|
||||
bool IsValidDepthDimension(type::TextureDimension dim) {
|
||||
return dim == type::TextureDimension::k2d;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -30,7 +30,7 @@ bool IsValidDepthDimension(TextureDimension dim) {
|
|||
DepthMultisampledTexture::DepthMultisampledTexture(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& src,
|
||||
TextureDimension d)
|
||||
type::TextureDimension d)
|
||||
: Base(pid, nid, src, d) {
|
||||
TINT_ASSERT(AST, IsValidDepthDimension(dim));
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "src/tint/ast/texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::ast {
|
||||
|
||||
|
@ -29,7 +30,10 @@ class DepthMultisampledTexture final : public Castable<DepthMultisampledTexture,
|
|||
/// @param nid the unique node identifier
|
||||
/// @param src the source of this node
|
||||
/// @param dim the dimensionality of the texture
|
||||
DepthMultisampledTexture(ProgramID pid, NodeID nid, const Source& src, TextureDimension dim);
|
||||
DepthMultisampledTexture(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& src,
|
||||
type::TextureDimension dim);
|
||||
/// Move constructor
|
||||
DepthMultisampledTexture(DepthMultisampledTexture&&);
|
||||
~DepthMultisampledTexture() override;
|
||||
|
|
|
@ -22,12 +22,12 @@ namespace {
|
|||
using AstDepthMultisampledTextureTest = TestHelper;
|
||||
|
||||
TEST_F(AstDepthMultisampledTextureTest, Dim) {
|
||||
auto* d = create<DepthMultisampledTexture>(TextureDimension::k2d);
|
||||
EXPECT_EQ(d->dim, TextureDimension::k2d);
|
||||
auto* d = create<DepthMultisampledTexture>(type::TextureDimension::k2d);
|
||||
EXPECT_EQ(d->dim, type::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
TEST_F(AstDepthMultisampledTextureTest, FriendlyName) {
|
||||
auto* d = create<DepthMultisampledTexture>(TextureDimension::k2d);
|
||||
auto* d = create<DepthMultisampledTexture>(type::TextureDimension::k2d);
|
||||
EXPECT_EQ(d->FriendlyName(Symbols()), "texture_depth_multisampled_2d");
|
||||
}
|
||||
|
||||
|
|
|
@ -21,14 +21,14 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::DepthTexture);
|
|||
namespace tint::ast {
|
||||
namespace {
|
||||
|
||||
bool IsValidDepthDimension(TextureDimension dim) {
|
||||
return dim == TextureDimension::k2d || dim == TextureDimension::k2dArray ||
|
||||
dim == TextureDimension::kCube || dim == TextureDimension::kCubeArray;
|
||||
bool IsValidDepthDimension(type::TextureDimension dim) {
|
||||
return dim == type::TextureDimension::k2d || dim == type::TextureDimension::k2dArray ||
|
||||
dim == type::TextureDimension::kCube || dim == type::TextureDimension::kCubeArray;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
DepthTexture::DepthTexture(ProgramID pid, NodeID nid, const Source& src, TextureDimension d)
|
||||
DepthTexture::DepthTexture(ProgramID pid, NodeID nid, const Source& src, type::TextureDimension d)
|
||||
: Base(pid, nid, src, d) {
|
||||
TINT_ASSERT(AST, IsValidDepthDimension(dim));
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "src/tint/ast/texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::ast {
|
||||
|
||||
|
@ -29,7 +30,7 @@ class DepthTexture final : public Castable<DepthTexture, Texture> {
|
|||
/// @param nid the unique node identifier
|
||||
/// @param src the source of this node
|
||||
/// @param dim the dimensionality of the texture
|
||||
DepthTexture(ProgramID pid, NodeID nid, const Source& src, TextureDimension dim);
|
||||
DepthTexture(ProgramID pid, NodeID nid, const Source& src, type::TextureDimension dim);
|
||||
/// Move constructor
|
||||
DepthTexture(DepthTexture&&);
|
||||
~DepthTexture() override;
|
||||
|
|
|
@ -22,19 +22,19 @@ namespace {
|
|||
using AstDepthTextureTest = TestHelper;
|
||||
|
||||
TEST_F(AstDepthTextureTest, IsTexture) {
|
||||
Texture* ty = create<DepthTexture>(TextureDimension::kCube);
|
||||
Texture* ty = create<DepthTexture>(type::TextureDimension::kCube);
|
||||
EXPECT_TRUE(ty->Is<DepthTexture>());
|
||||
EXPECT_FALSE(ty->Is<SampledTexture>());
|
||||
EXPECT_FALSE(ty->Is<StorageTexture>());
|
||||
}
|
||||
|
||||
TEST_F(AstDepthTextureTest, Dim) {
|
||||
auto* d = create<DepthTexture>(TextureDimension::kCube);
|
||||
EXPECT_EQ(d->dim, TextureDimension::kCube);
|
||||
auto* d = create<DepthTexture>(type::TextureDimension::kCube);
|
||||
EXPECT_EQ(d->dim, type::TextureDimension::kCube);
|
||||
}
|
||||
|
||||
TEST_F(AstDepthTextureTest, FriendlyName) {
|
||||
auto* d = create<DepthTexture>(TextureDimension::kCube);
|
||||
auto* d = create<DepthTexture>(type::TextureDimension::kCube);
|
||||
EXPECT_EQ(d->FriendlyName(Symbols()), "texture_depth_cube");
|
||||
}
|
||||
|
||||
|
|
|
@ -15,14 +15,15 @@
|
|||
#include "src/tint/ast/external_texture.h"
|
||||
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::ast::ExternalTexture);
|
||||
|
||||
namespace tint::ast {
|
||||
|
||||
// ExternalTexture::ExternalTexture() : Base(ast::TextureDimension::k2d) {}
|
||||
// ExternalTexture::ExternalTexture() : Base(type::TextureDimension::k2d) {}
|
||||
ExternalTexture::ExternalTexture(ProgramID pid, NodeID nid, const Source& src)
|
||||
: Base(pid, nid, src, ast::TextureDimension::k2d) {}
|
||||
: Base(pid, nid, src, type::TextureDimension::k2d) {}
|
||||
|
||||
ExternalTexture::ExternalTexture(ExternalTexture&&) = default;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "src/tint/ast/external_texture.h"
|
||||
|
||||
#include "src/tint/ast/test_helper.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::ast {
|
||||
namespace {
|
||||
|
@ -32,7 +33,7 @@ TEST_F(AstExternalTextureTest, IsTexture) {
|
|||
|
||||
TEST_F(AstExternalTextureTest, Dim) {
|
||||
auto* ty = create<ExternalTexture>();
|
||||
EXPECT_EQ(ty->dim, ast::TextureDimension::k2d);
|
||||
EXPECT_EQ(ty->dim, type::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
TEST_F(AstExternalTextureTest, FriendlyName) {
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace tint::ast {
|
|||
MultisampledTexture::MultisampledTexture(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& src,
|
||||
TextureDimension d,
|
||||
type::TextureDimension d,
|
||||
const Type* ty)
|
||||
: Base(pid, nid, src, d), type(ty) {
|
||||
TINT_ASSERT(AST, type);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "src/tint/ast/texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::ast {
|
||||
|
||||
|
@ -33,7 +34,7 @@ class MultisampledTexture final : public Castable<MultisampledTexture, Texture>
|
|||
MultisampledTexture(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& src,
|
||||
TextureDimension dim,
|
||||
type::TextureDimension dim,
|
||||
const Type* type);
|
||||
/// Move constructor
|
||||
MultisampledTexture(MultisampledTexture&&);
|
||||
|
|
|
@ -39,7 +39,7 @@ using AstMultisampledTextureTest = TestHelper;
|
|||
|
||||
TEST_F(AstMultisampledTextureTest, IsTexture) {
|
||||
auto* f32 = create<F32>();
|
||||
Texture* ty = create<MultisampledTexture>(TextureDimension::kCube, f32);
|
||||
Texture* ty = create<MultisampledTexture>(type::TextureDimension::kCube, f32);
|
||||
EXPECT_FALSE(ty->Is<DepthTexture>());
|
||||
EXPECT_TRUE(ty->Is<MultisampledTexture>());
|
||||
EXPECT_FALSE(ty->Is<SampledTexture>());
|
||||
|
@ -48,19 +48,19 @@ TEST_F(AstMultisampledTextureTest, IsTexture) {
|
|||
|
||||
TEST_F(AstMultisampledTextureTest, Dim) {
|
||||
auto* f32 = create<F32>();
|
||||
auto* s = create<MultisampledTexture>(TextureDimension::k3d, f32);
|
||||
EXPECT_EQ(s->dim, TextureDimension::k3d);
|
||||
auto* s = create<MultisampledTexture>(type::TextureDimension::k3d, f32);
|
||||
EXPECT_EQ(s->dim, type::TextureDimension::k3d);
|
||||
}
|
||||
|
||||
TEST_F(AstMultisampledTextureTest, Type) {
|
||||
auto* f32 = create<F32>();
|
||||
auto* s = create<MultisampledTexture>(TextureDimension::k3d, f32);
|
||||
auto* s = create<MultisampledTexture>(type::TextureDimension::k3d, f32);
|
||||
EXPECT_EQ(s->type, f32);
|
||||
}
|
||||
|
||||
TEST_F(AstMultisampledTextureTest, FriendlyName) {
|
||||
auto* f32 = create<F32>();
|
||||
auto* s = create<MultisampledTexture>(TextureDimension::k3d, f32);
|
||||
auto* s = create<MultisampledTexture>(type::TextureDimension::k3d, f32);
|
||||
EXPECT_EQ(s->FriendlyName(Symbols()), "texture_multisampled_3d<f32>");
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace tint::ast {
|
|||
SampledTexture::SampledTexture(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& src,
|
||||
TextureDimension d,
|
||||
type::TextureDimension d,
|
||||
const Type* ty)
|
||||
: Base(pid, nid, src, d), type(ty) {
|
||||
TINT_ASSERT(AST, type);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "src/tint/ast/texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::ast {
|
||||
|
||||
|
@ -33,7 +34,7 @@ class SampledTexture final : public Castable<SampledTexture, Texture> {
|
|||
SampledTexture(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& src,
|
||||
TextureDimension dim,
|
||||
type::TextureDimension dim,
|
||||
const Type* type);
|
||||
/// Move constructor
|
||||
SampledTexture(SampledTexture&&);
|
||||
|
|
|
@ -24,7 +24,7 @@ using AstSampledTextureTest = TestHelper;
|
|||
|
||||
TEST_F(AstSampledTextureTest, IsTexture) {
|
||||
auto* f32 = create<F32>();
|
||||
Texture* ty = create<SampledTexture>(TextureDimension::kCube, f32);
|
||||
Texture* ty = create<SampledTexture>(type::TextureDimension::kCube, f32);
|
||||
EXPECT_FALSE(ty->Is<DepthTexture>());
|
||||
EXPECT_TRUE(ty->Is<SampledTexture>());
|
||||
EXPECT_FALSE(ty->Is<StorageTexture>());
|
||||
|
@ -32,19 +32,19 @@ TEST_F(AstSampledTextureTest, IsTexture) {
|
|||
|
||||
TEST_F(AstSampledTextureTest, Dim) {
|
||||
auto* f32 = create<F32>();
|
||||
auto* s = create<SampledTexture>(TextureDimension::k3d, f32);
|
||||
EXPECT_EQ(s->dim, TextureDimension::k3d);
|
||||
auto* s = create<SampledTexture>(type::TextureDimension::k3d, f32);
|
||||
EXPECT_EQ(s->dim, type::TextureDimension::k3d);
|
||||
}
|
||||
|
||||
TEST_F(AstSampledTextureTest, Type) {
|
||||
auto* f32 = create<F32>();
|
||||
auto* s = create<SampledTexture>(TextureDimension::k3d, f32);
|
||||
auto* s = create<SampledTexture>(type::TextureDimension::k3d, f32);
|
||||
EXPECT_EQ(s->type, f32);
|
||||
}
|
||||
|
||||
TEST_F(AstSampledTextureTest, FriendlyName) {
|
||||
auto* f32 = create<F32>();
|
||||
auto* s = create<SampledTexture>(TextureDimension::k3d, f32);
|
||||
auto* s = create<SampledTexture>(type::TextureDimension::k3d, f32);
|
||||
EXPECT_EQ(s->FriendlyName(Symbols()), "texture_3d<f32>");
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace tint::ast {
|
|||
StorageTexture::StorageTexture(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& src,
|
||||
TextureDimension d,
|
||||
type::TextureDimension d,
|
||||
TexelFormat fmt,
|
||||
const Type* subtype,
|
||||
Access ac)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "src/tint/ast/access.h"
|
||||
#include "src/tint/ast/texel_format.h"
|
||||
#include "src/tint/ast/texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::ast {
|
||||
|
||||
|
@ -37,7 +38,7 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
|
|||
StorageTexture(ProgramID pid,
|
||||
NodeID nid,
|
||||
const Source& src,
|
||||
TextureDimension dim,
|
||||
type::TextureDimension dim,
|
||||
TexelFormat format,
|
||||
const Type* subtype,
|
||||
Access access_control);
|
||||
|
|
|
@ -23,8 +23,8 @@ using AstStorageTextureTest = TestHelper;
|
|||
|
||||
TEST_F(AstStorageTextureTest, IsTexture) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this);
|
||||
Texture* ty = create<StorageTexture>(TextureDimension::k2dArray, TexelFormat::kRgba32Float,
|
||||
subtype, Access::kRead);
|
||||
Texture* ty = create<StorageTexture>(type::TextureDimension::k2dArray,
|
||||
TexelFormat::kRgba32Float, subtype, Access::kRead);
|
||||
EXPECT_FALSE(ty->Is<DepthTexture>());
|
||||
EXPECT_FALSE(ty->Is<SampledTexture>());
|
||||
EXPECT_TRUE(ty->Is<StorageTexture>());
|
||||
|
@ -32,29 +32,29 @@ TEST_F(AstStorageTextureTest, IsTexture) {
|
|||
|
||||
TEST_F(AstStorageTextureTest, Dim) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this);
|
||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray, TexelFormat::kRgba32Float, subtype,
|
||||
Access::kRead);
|
||||
EXPECT_EQ(s->dim, TextureDimension::k2dArray);
|
||||
auto* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRgba32Float,
|
||||
subtype, Access::kRead);
|
||||
EXPECT_EQ(s->dim, type::TextureDimension::k2dArray);
|
||||
}
|
||||
|
||||
TEST_F(AstStorageTextureTest, Format) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this);
|
||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray, TexelFormat::kRgba32Float, subtype,
|
||||
Access::kRead);
|
||||
auto* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRgba32Float,
|
||||
subtype, Access::kRead);
|
||||
EXPECT_EQ(s->format, TexelFormat::kRgba32Float);
|
||||
}
|
||||
|
||||
TEST_F(AstStorageTextureTest, FriendlyName) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this);
|
||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray, TexelFormat::kRgba32Float, subtype,
|
||||
Access::kRead);
|
||||
auto* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRgba32Float,
|
||||
subtype, Access::kRead);
|
||||
EXPECT_EQ(s->FriendlyName(Symbols()), "texture_storage_2d_array<rgba32float, read>");
|
||||
}
|
||||
|
||||
TEST_F(AstStorageTextureTest, F32) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Float, *this);
|
||||
Type* s = create<StorageTexture>(TextureDimension::k2dArray, TexelFormat::kRgba32Float, subtype,
|
||||
Access::kRead);
|
||||
Type* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRgba32Float,
|
||||
subtype, Access::kRead);
|
||||
|
||||
ASSERT_TRUE(s->Is<Texture>());
|
||||
ASSERT_TRUE(s->Is<StorageTexture>());
|
||||
|
@ -63,8 +63,8 @@ TEST_F(AstStorageTextureTest, F32) {
|
|||
|
||||
TEST_F(AstStorageTextureTest, U32) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRg32Uint, *this);
|
||||
Type* s = create<StorageTexture>(TextureDimension::k2dArray, TexelFormat::kRg32Uint, subtype,
|
||||
Access::kRead);
|
||||
Type* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRg32Uint,
|
||||
subtype, Access::kRead);
|
||||
|
||||
ASSERT_TRUE(s->Is<Texture>());
|
||||
ASSERT_TRUE(s->Is<StorageTexture>());
|
||||
|
@ -73,8 +73,8 @@ TEST_F(AstStorageTextureTest, U32) {
|
|||
|
||||
TEST_F(AstStorageTextureTest, I32) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(TexelFormat::kRgba32Sint, *this);
|
||||
Type* s = create<StorageTexture>(TextureDimension::k2dArray, TexelFormat::kRgba32Sint, subtype,
|
||||
Access::kRead);
|
||||
Type* s = create<StorageTexture>(type::TextureDimension::k2dArray, TexelFormat::kRgba32Sint,
|
||||
subtype, Access::kRead);
|
||||
|
||||
ASSERT_TRUE(s->Is<Texture>());
|
||||
ASSERT_TRUE(s->Is<StorageTexture>());
|
||||
|
|
|
@ -18,66 +18,39 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Texture);
|
|||
|
||||
namespace tint::ast {
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, TextureDimension dim) {
|
||||
bool IsTextureArray(type::TextureDimension dim) {
|
||||
switch (dim) {
|
||||
case TextureDimension::kNone:
|
||||
out << "None";
|
||||
break;
|
||||
case TextureDimension::k1d:
|
||||
out << "1d";
|
||||
break;
|
||||
case TextureDimension::k2d:
|
||||
out << "2d";
|
||||
break;
|
||||
case TextureDimension::k2dArray:
|
||||
out << "2d_array";
|
||||
break;
|
||||
case TextureDimension::k3d:
|
||||
out << "3d";
|
||||
break;
|
||||
case TextureDimension::kCube:
|
||||
out << "cube";
|
||||
break;
|
||||
case TextureDimension::kCubeArray:
|
||||
out << "cube_array";
|
||||
break;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool IsTextureArray(TextureDimension dim) {
|
||||
switch (dim) {
|
||||
case TextureDimension::k2dArray:
|
||||
case TextureDimension::kCubeArray:
|
||||
case type::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::kCubeArray:
|
||||
return true;
|
||||
case TextureDimension::k2d:
|
||||
case TextureDimension::kNone:
|
||||
case TextureDimension::k1d:
|
||||
case TextureDimension::k3d:
|
||||
case TextureDimension::kCube:
|
||||
case type::TextureDimension::k2d:
|
||||
case type::TextureDimension::kNone:
|
||||
case type::TextureDimension::k1d:
|
||||
case type::TextureDimension::k3d:
|
||||
case type::TextureDimension::kCube:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int NumCoordinateAxes(TextureDimension dim) {
|
||||
int NumCoordinateAxes(type::TextureDimension dim) {
|
||||
switch (dim) {
|
||||
case TextureDimension::kNone:
|
||||
case type::TextureDimension::kNone:
|
||||
return 0;
|
||||
case TextureDimension::k1d:
|
||||
case type::TextureDimension::k1d:
|
||||
return 1;
|
||||
case TextureDimension::k2d:
|
||||
case TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2dArray:
|
||||
return 2;
|
||||
case TextureDimension::k3d:
|
||||
case TextureDimension::kCube:
|
||||
case TextureDimension::kCubeArray:
|
||||
case type::TextureDimension::k3d:
|
||||
case type::TextureDimension::kCube:
|
||||
case type::TextureDimension::kCubeArray:
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Texture::Texture(ProgramID pid, NodeID nid, const Source& src, TextureDimension d)
|
||||
Texture::Texture(ProgramID pid, NodeID nid, const Source& src, type::TextureDimension d)
|
||||
: Base(pid, nid, src), dim(d) {}
|
||||
|
||||
Texture::Texture(Texture&&) = default;
|
||||
|
|
|
@ -16,35 +16,13 @@
|
|||
#define SRC_TINT_AST_TEXTURE_H_
|
||||
|
||||
#include "src/tint/ast/type.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::ast {
|
||||
|
||||
/// The dimensionality of the texture
|
||||
enum class TextureDimension {
|
||||
/// Invalid texture
|
||||
kNone = -1,
|
||||
/// 1 dimensional texture
|
||||
k1d,
|
||||
/// 2 dimensional texture
|
||||
k2d,
|
||||
/// 2 dimensional array texture
|
||||
k2dArray,
|
||||
/// 3 dimensional texture
|
||||
k3d,
|
||||
/// cube texture
|
||||
kCube,
|
||||
/// cube array texture
|
||||
kCubeArray,
|
||||
};
|
||||
|
||||
/// @param out the std::ostream to write to
|
||||
/// @param dim the TextureDimension
|
||||
/// @return the std::ostream so calls can be chained
|
||||
std::ostream& operator<<(std::ostream& out, TextureDimension dim);
|
||||
|
||||
/// @param dim the TextureDimension to query
|
||||
/// @return true if the given TextureDimension is an array texture
|
||||
bool IsTextureArray(TextureDimension dim);
|
||||
/// @param dim the type::TextureDimension to query
|
||||
/// @return true if the given type::TextureDimension is an array texture
|
||||
bool IsTextureArray(type::TextureDimension dim);
|
||||
|
||||
/// Returns the number of axes in the coordinate used for accessing
|
||||
/// the texture, where an access is one of: sampling, fetching, load,
|
||||
|
@ -56,9 +34,9 @@ bool IsTextureArray(TextureDimension dim);
|
|||
/// Note: To sample a cube texture, the coordinate has 3 dimensions,
|
||||
/// but textureDimensions on a cube or cube array returns a 2-element
|
||||
/// size, representing the (x,y) size of each cube face, in texels.
|
||||
/// @param dim the TextureDimension to query
|
||||
/// @param dim the type::TextureDimension to query
|
||||
/// @return number of dimensions in a coordinate for the dimensionality
|
||||
int NumCoordinateAxes(TextureDimension dim);
|
||||
int NumCoordinateAxes(type::TextureDimension dim);
|
||||
|
||||
/// A texture type.
|
||||
class Texture : public Castable<Texture, Type> {
|
||||
|
@ -68,13 +46,13 @@ class Texture : public Castable<Texture, Type> {
|
|||
/// @param nid the unique node identifier
|
||||
/// @param src the source of this node
|
||||
/// @param dim the dimensionality of the texture
|
||||
Texture(ProgramID pid, NodeID nid, const Source& src, TextureDimension dim);
|
||||
Texture(ProgramID pid, NodeID nid, const Source& src, type::TextureDimension dim);
|
||||
/// Move constructor
|
||||
Texture(Texture&&);
|
||||
~Texture() override;
|
||||
|
||||
/// The texture dimension
|
||||
const TextureDimension dim;
|
||||
const type::TextureDimension dim;
|
||||
};
|
||||
|
||||
} // namespace tint::ast
|
||||
|
|
|
@ -33,23 +33,23 @@ namespace {
|
|||
using AstTextureTypeTest = TestHelper;
|
||||
|
||||
TEST_F(AstTextureTypeTest, IsTextureArray) {
|
||||
EXPECT_EQ(false, IsTextureArray(TextureDimension::kNone));
|
||||
EXPECT_EQ(false, IsTextureArray(TextureDimension::k1d));
|
||||
EXPECT_EQ(false, IsTextureArray(TextureDimension::k2d));
|
||||
EXPECT_EQ(true, IsTextureArray(TextureDimension::k2dArray));
|
||||
EXPECT_EQ(false, IsTextureArray(TextureDimension::k3d));
|
||||
EXPECT_EQ(false, IsTextureArray(TextureDimension::kCube));
|
||||
EXPECT_EQ(true, IsTextureArray(TextureDimension::kCubeArray));
|
||||
EXPECT_EQ(false, IsTextureArray(type::TextureDimension::kNone));
|
||||
EXPECT_EQ(false, IsTextureArray(type::TextureDimension::k1d));
|
||||
EXPECT_EQ(false, IsTextureArray(type::TextureDimension::k2d));
|
||||
EXPECT_EQ(true, IsTextureArray(type::TextureDimension::k2dArray));
|
||||
EXPECT_EQ(false, IsTextureArray(type::TextureDimension::k3d));
|
||||
EXPECT_EQ(false, IsTextureArray(type::TextureDimension::kCube));
|
||||
EXPECT_EQ(true, IsTextureArray(type::TextureDimension::kCubeArray));
|
||||
}
|
||||
|
||||
TEST_F(AstTextureTypeTest, NumCoordinateAxes) {
|
||||
EXPECT_EQ(0, NumCoordinateAxes(TextureDimension::kNone));
|
||||
EXPECT_EQ(1, NumCoordinateAxes(TextureDimension::k1d));
|
||||
EXPECT_EQ(2, NumCoordinateAxes(TextureDimension::k2d));
|
||||
EXPECT_EQ(2, NumCoordinateAxes(TextureDimension::k2dArray));
|
||||
EXPECT_EQ(3, NumCoordinateAxes(TextureDimension::k3d));
|
||||
EXPECT_EQ(3, NumCoordinateAxes(TextureDimension::kCube));
|
||||
EXPECT_EQ(3, NumCoordinateAxes(TextureDimension::kCubeArray));
|
||||
EXPECT_EQ(0, NumCoordinateAxes(type::TextureDimension::kNone));
|
||||
EXPECT_EQ(1, NumCoordinateAxes(type::TextureDimension::k1d));
|
||||
EXPECT_EQ(2, NumCoordinateAxes(type::TextureDimension::k2d));
|
||||
EXPECT_EQ(2, NumCoordinateAxes(type::TextureDimension::k2dArray));
|
||||
EXPECT_EQ(3, NumCoordinateAxes(type::TextureDimension::k3d));
|
||||
EXPECT_EQ(3, NumCoordinateAxes(type::TextureDimension::kCube));
|
||||
EXPECT_EQ(3, NumCoordinateAxes(type::TextureDimension::kCubeArray));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "src/tint/type/external_texture.h"
|
||||
#include "src/tint/type/multisampled_texture.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "tint/tint.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
@ -76,7 +77,7 @@ class InspectorGetSampledTextureResourceBindingsTest : public InspectorBuilder,
|
|||
class InspectorGetSampledArrayTextureResourceBindingsTest : public InspectorBuilder,
|
||||
public testing::Test {};
|
||||
struct GetSampledTextureTestParams {
|
||||
ast::TextureDimension type_dim;
|
||||
type::TextureDimension type_dim;
|
||||
inspector::ResourceBinding::TextureDimension inspector_dim;
|
||||
inspector::ResourceBinding::SampledKind sampled_kind;
|
||||
};
|
||||
|
@ -100,7 +101,7 @@ class InspectorGetMultisampledTextureResourceBindingsTestWithParam
|
|||
class InspectorGetStorageTextureResourceBindingsTest : public InspectorBuilder,
|
||||
public testing::Test {};
|
||||
struct GetDepthTextureTestParams {
|
||||
ast::TextureDimension type_dim;
|
||||
type::TextureDimension type_dim;
|
||||
inspector::ResourceBinding::TextureDimension inspector_dim;
|
||||
};
|
||||
class InspectorGetDepthTextureResourceBindingsTestWithParam
|
||||
|
@ -110,7 +111,7 @@ class InspectorGetDepthTextureResourceBindingsTestWithParam
|
|||
class InspectorGetDepthMultisampledTextureResourceBindingsTest : public InspectorBuilder,
|
||||
public testing::Test {};
|
||||
|
||||
typedef std::tuple<ast::TextureDimension, ResourceBinding::TextureDimension> DimensionParams;
|
||||
typedef std::tuple<type::TextureDimension, ResourceBinding::TextureDimension> DimensionParams;
|
||||
typedef std::tuple<ast::TexelFormat, ResourceBinding::TexelFormat, ResourceBinding::SampledKind>
|
||||
TexelFormatParams;
|
||||
typedef std::tuple<DimensionParams, TexelFormatParams> GetStorageTextureTestParams;
|
||||
|
@ -1784,14 +1785,14 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
|
|||
MemberInfo{0, ty.i32()},
|
||||
});
|
||||
|
||||
auto* s_texture_type = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
auto* s_texture_type = ty.sampled_texture(type::TextureDimension::k1d, ty.f32());
|
||||
AddResource("s_texture", s_texture_type, 2, 0);
|
||||
AddSampler("s_var", 3, 0);
|
||||
AddGlobalVariable("s_coords", ty.f32());
|
||||
MakeSamplerReferenceBodyFunction("s_func", "s_texture", "s_var", "s_coords", ty.f32(),
|
||||
utils::Empty);
|
||||
|
||||
auto* cs_depth_texture_type = ty.depth_texture(ast::TextureDimension::k2d);
|
||||
auto* cs_depth_texture_type = ty.depth_texture(type::TextureDimension::k2d);
|
||||
AddResource("cs_texture", cs_depth_texture_type, 3, 1);
|
||||
AddComparisonSampler("cs_var", 3, 2);
|
||||
AddGlobalVariable("cs_coords", ty.vec2<f32>());
|
||||
|
@ -1799,14 +1800,15 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
|
|||
MakeComparisonSamplerReferenceBodyFunction("cs_func", "cs_texture", "cs_var", "cs_coords",
|
||||
"cs_depth", ty.f32(), utils::Empty);
|
||||
|
||||
auto* depth_ms_texture_type = ty.depth_multisampled_texture(ast::TextureDimension::k2d);
|
||||
auto* depth_ms_texture_type = ty.depth_multisampled_texture(type::TextureDimension::k2d);
|
||||
AddResource("depth_ms_texture", depth_ms_texture_type, 3, 3);
|
||||
Func("depth_ms_func", utils::Empty, ty.void_(),
|
||||
utils::Vector{
|
||||
Ignore("depth_ms_texture"),
|
||||
});
|
||||
|
||||
auto* st_type = MakeStorageTextureTypes(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint);
|
||||
auto* st_type =
|
||||
MakeStorageTextureTypes(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint);
|
||||
AddStorageTexture("st_var", st_type, 4, 0);
|
||||
MakeStorageTextureBodyFunction("st_func", "st_var", ty.vec2<u32>(), utils::Empty);
|
||||
|
||||
|
@ -2586,7 +2588,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
|
|||
}
|
||||
|
||||
TEST_F(InspectorGetSamplerResourceBindingsTest, Simple) {
|
||||
auto* sampled_texture_type = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
auto* sampled_texture_type = ty.sampled_texture(type::TextureDimension::k1d, ty.f32());
|
||||
AddResource("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
|
@ -2621,7 +2623,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, NoSampler) {
|
|||
}
|
||||
|
||||
TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
|
||||
auto* sampled_texture_type = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
auto* sampled_texture_type = ty.sampled_texture(type::TextureDimension::k1d, ty.f32());
|
||||
AddResource("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
|
@ -2646,7 +2648,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
|
|||
}
|
||||
|
||||
TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
|
||||
auto* sampled_texture_type = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
auto* sampled_texture_type = ty.sampled_texture(type::TextureDimension::k1d, ty.f32());
|
||||
AddResource("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
|
@ -2663,7 +2665,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
|
|||
}
|
||||
|
||||
TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
|
||||
auto* depth_texture_type = ty.depth_texture(ast::TextureDimension::k2d);
|
||||
auto* depth_texture_type = ty.depth_texture(type::TextureDimension::k2d);
|
||||
AddResource("foo_texture", depth_texture_type, 0, 0);
|
||||
AddComparisonSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
||||
|
@ -2684,7 +2686,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
|
|||
}
|
||||
|
||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, Simple) {
|
||||
auto* depth_texture_type = ty.depth_texture(ast::TextureDimension::k2d);
|
||||
auto* depth_texture_type = ty.depth_texture(type::TextureDimension::k2d);
|
||||
AddResource("foo_texture", depth_texture_type, 0, 0);
|
||||
AddComparisonSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
||||
|
@ -2721,7 +2723,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, NoSampler) {
|
|||
}
|
||||
|
||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
|
||||
auto* depth_texture_type = ty.depth_texture(ast::TextureDimension::k2d);
|
||||
auto* depth_texture_type = ty.depth_texture(type::TextureDimension::k2d);
|
||||
AddResource("foo_texture", depth_texture_type, 0, 0);
|
||||
AddComparisonSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
||||
|
@ -2747,7 +2749,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
|
|||
}
|
||||
|
||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
|
||||
auto* depth_texture_type = ty.depth_texture(ast::TextureDimension::k2d);
|
||||
auto* depth_texture_type = ty.depth_texture(type::TextureDimension::k2d);
|
||||
AddResource("foo_texture", depth_texture_type, 0, 0);
|
||||
AddComparisonSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
||||
|
@ -2766,7 +2768,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
|
|||
}
|
||||
|
||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, SkipsSamplers) {
|
||||
auto* sampled_texture_type = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
auto* sampled_texture_type = ty.sampled_texture(type::TextureDimension::k1d, ty.f32());
|
||||
AddResource("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
|
@ -2833,16 +2835,16 @@ TEST_P(InspectorGetSampledTextureResourceBindingsTestWithParam, textureSample) {
|
|||
INSTANTIATE_TEST_SUITE_P(
|
||||
InspectorGetSampledTextureResourceBindingsTest,
|
||||
InspectorGetSampledTextureResourceBindingsTestWithParam,
|
||||
testing::Values(GetSampledTextureTestParams{ast::TextureDimension::k1d,
|
||||
testing::Values(GetSampledTextureTestParams{type::TextureDimension::k1d,
|
||||
inspector::ResourceBinding::TextureDimension::k1d,
|
||||
inspector::ResourceBinding::SampledKind::kFloat},
|
||||
GetSampledTextureTestParams{ast::TextureDimension::k2d,
|
||||
GetSampledTextureTestParams{type::TextureDimension::k2d,
|
||||
inspector::ResourceBinding::TextureDimension::k2d,
|
||||
inspector::ResourceBinding::SampledKind::kFloat},
|
||||
GetSampledTextureTestParams{ast::TextureDimension::k3d,
|
||||
GetSampledTextureTestParams{type::TextureDimension::k3d,
|
||||
inspector::ResourceBinding::TextureDimension::k3d,
|
||||
inspector::ResourceBinding::SampledKind::kFloat},
|
||||
GetSampledTextureTestParams{ast::TextureDimension::kCube,
|
||||
GetSampledTextureTestParams{type::TextureDimension::kCube,
|
||||
inspector::ResourceBinding::TextureDimension::kCube,
|
||||
inspector::ResourceBinding::SampledKind::kFloat}));
|
||||
|
||||
|
@ -2878,10 +2880,10 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
InspectorGetSampledArrayTextureResourceBindingsTest,
|
||||
InspectorGetSampledArrayTextureResourceBindingsTestWithParam,
|
||||
testing::Values(
|
||||
GetSampledTextureTestParams{ast::TextureDimension::k2dArray,
|
||||
GetSampledTextureTestParams{type::TextureDimension::k2dArray,
|
||||
inspector::ResourceBinding::TextureDimension::k2dArray,
|
||||
inspector::ResourceBinding::SampledKind::kFloat},
|
||||
GetSampledTextureTestParams{ast::TextureDimension::kCubeArray,
|
||||
GetSampledTextureTestParams{type::TextureDimension::kCubeArray,
|
||||
inspector::ResourceBinding::TextureDimension::kCubeArray,
|
||||
inspector::ResourceBinding::SampledKind::kFloat}));
|
||||
|
||||
|
@ -2924,13 +2926,13 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
InspectorGetMultisampledTextureResourceBindingsTest,
|
||||
InspectorGetMultisampledTextureResourceBindingsTestWithParam,
|
||||
testing::Values(
|
||||
GetMultisampledTextureTestParams{ast::TextureDimension::k2d,
|
||||
GetMultisampledTextureTestParams{type::TextureDimension::k2d,
|
||||
inspector::ResourceBinding::TextureDimension::k2d,
|
||||
inspector::ResourceBinding::SampledKind::kFloat},
|
||||
GetMultisampledTextureTestParams{ast::TextureDimension::k2d,
|
||||
GetMultisampledTextureTestParams{type::TextureDimension::k2d,
|
||||
inspector::ResourceBinding::TextureDimension::k2d,
|
||||
inspector::ResourceBinding::SampledKind::kSInt},
|
||||
GetMultisampledTextureTestParams{ast::TextureDimension::k2d,
|
||||
GetMultisampledTextureTestParams{type::TextureDimension::k2d,
|
||||
inspector::ResourceBinding::TextureDimension::k2d,
|
||||
inspector::ResourceBinding::SampledKind::kUInt}));
|
||||
|
||||
|
@ -2964,7 +2966,7 @@ TEST_P(InspectorGetStorageTextureResourceBindingsTestWithParam, Simple) {
|
|||
TexelFormatParams format_params;
|
||||
std::tie(dim_params, format_params) = GetParam();
|
||||
|
||||
ast::TextureDimension dim;
|
||||
type::TextureDimension dim;
|
||||
ResourceBinding::TextureDimension expected_dim;
|
||||
std::tie(dim, expected_dim) = dim_params;
|
||||
|
||||
|
@ -2978,14 +2980,14 @@ TEST_P(InspectorGetStorageTextureResourceBindingsTestWithParam, Simple) {
|
|||
|
||||
const ast::Type* dim_type = nullptr;
|
||||
switch (dim) {
|
||||
case ast::TextureDimension::k1d:
|
||||
case type::TextureDimension::k1d:
|
||||
dim_type = ty.u32();
|
||||
break;
|
||||
case ast::TextureDimension::k2d:
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2dArray:
|
||||
dim_type = ty.vec2<u32>();
|
||||
break;
|
||||
case ast::TextureDimension::k3d:
|
||||
case type::TextureDimension::k3d:
|
||||
dim_type = ty.vec3<u32>();
|
||||
break;
|
||||
default:
|
||||
|
@ -3016,13 +3018,13 @@ TEST_P(InspectorGetStorageTextureResourceBindingsTestWithParam, Simple) {
|
|||
INSTANTIATE_TEST_SUITE_P(
|
||||
InspectorGetStorageTextureResourceBindingsTest,
|
||||
InspectorGetStorageTextureResourceBindingsTestWithParam,
|
||||
testing::Combine(testing::Values(std::make_tuple(ast::TextureDimension::k1d,
|
||||
testing::Combine(testing::Values(std::make_tuple(type::TextureDimension::k1d,
|
||||
ResourceBinding::TextureDimension::k1d),
|
||||
std::make_tuple(ast::TextureDimension::k2d,
|
||||
std::make_tuple(type::TextureDimension::k2d,
|
||||
ResourceBinding::TextureDimension::k2d),
|
||||
std::make_tuple(ast::TextureDimension::k2dArray,
|
||||
std::make_tuple(type::TextureDimension::k2dArray,
|
||||
ResourceBinding::TextureDimension::k2dArray),
|
||||
std::make_tuple(ast::TextureDimension::k3d,
|
||||
std::make_tuple(type::TextureDimension::k3d,
|
||||
ResourceBinding::TextureDimension::k3d)),
|
||||
testing::Values(std::make_tuple(ast::TexelFormat::kR32Float,
|
||||
ResourceBinding::TexelFormat::kR32Float,
|
||||
|
@ -3101,17 +3103,17 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
InspectorGetDepthTextureResourceBindingsTest,
|
||||
InspectorGetDepthTextureResourceBindingsTestWithParam,
|
||||
testing::Values(
|
||||
GetDepthTextureTestParams{ast::TextureDimension::k2d,
|
||||
GetDepthTextureTestParams{type::TextureDimension::k2d,
|
||||
inspector::ResourceBinding::TextureDimension::k2d},
|
||||
GetDepthTextureTestParams{ast::TextureDimension::k2dArray,
|
||||
GetDepthTextureTestParams{type::TextureDimension::k2dArray,
|
||||
inspector::ResourceBinding::TextureDimension::k2dArray},
|
||||
GetDepthTextureTestParams{ast::TextureDimension::kCube,
|
||||
GetDepthTextureTestParams{type::TextureDimension::kCube,
|
||||
inspector::ResourceBinding::TextureDimension::kCube},
|
||||
GetDepthTextureTestParams{ast::TextureDimension::kCubeArray,
|
||||
GetDepthTextureTestParams{type::TextureDimension::kCubeArray,
|
||||
inspector::ResourceBinding::TextureDimension::kCubeArray}));
|
||||
|
||||
TEST_F(InspectorGetDepthMultisampledTextureResourceBindingsTest, textureDimensions) {
|
||||
auto* depth_ms_texture_type = ty.depth_multisampled_texture(ast::TextureDimension::k2d);
|
||||
auto* depth_ms_texture_type = ty.depth_multisampled_texture(type::TextureDimension::k2d);
|
||||
AddResource("tex", depth_ms_texture_type, 0, 0);
|
||||
|
||||
Func("ep", utils::Empty, ty.void_(),
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "src/tint/type/f32.h"
|
||||
#include "src/tint/type/i32.h"
|
||||
#include "src/tint/type/matrix.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/type/type.h"
|
||||
#include "src/tint/type/u32.h"
|
||||
#include "src/tint/type/vector.h"
|
||||
|
@ -25,21 +26,21 @@
|
|||
namespace tint::inspector {
|
||||
|
||||
ResourceBinding::TextureDimension TypeTextureDimensionToResourceBindingTextureDimension(
|
||||
const ast::TextureDimension& type_dim) {
|
||||
const type::TextureDimension& type_dim) {
|
||||
switch (type_dim) {
|
||||
case ast::TextureDimension::k1d:
|
||||
case type::TextureDimension::k1d:
|
||||
return ResourceBinding::TextureDimension::k1d;
|
||||
case ast::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2d:
|
||||
return ResourceBinding::TextureDimension::k2d;
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k2dArray:
|
||||
return ResourceBinding::TextureDimension::k2dArray;
|
||||
case ast::TextureDimension::k3d:
|
||||
case type::TextureDimension::k3d:
|
||||
return ResourceBinding::TextureDimension::k3d;
|
||||
case ast::TextureDimension::kCube:
|
||||
case type::TextureDimension::kCube:
|
||||
return ResourceBinding::TextureDimension::kCube;
|
||||
case ast::TextureDimension::kCubeArray:
|
||||
case type::TextureDimension::kCubeArray:
|
||||
return ResourceBinding::TextureDimension::kCubeArray;
|
||||
case ast::TextureDimension::kNone:
|
||||
case type::TextureDimension::kNone:
|
||||
return ResourceBinding::TextureDimension::kNone;
|
||||
}
|
||||
return ResourceBinding::TextureDimension::kNone;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <cstdint>
|
||||
|
||||
#include "src/tint/ast/storage_texture.h"
|
||||
#include "src/tint/ast/texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/type/type.h"
|
||||
|
||||
namespace tint::inspector {
|
||||
|
@ -104,12 +104,12 @@ struct ResourceBinding {
|
|||
TexelFormat image_format;
|
||||
};
|
||||
|
||||
/// Convert from internal ast::TextureDimension to public
|
||||
/// Convert from internal type::TextureDimension to public
|
||||
/// ResourceBinding::TextureDimension
|
||||
/// @param type_dim internal value to convert from
|
||||
/// @returns the publicly visible equivalent
|
||||
ResourceBinding::TextureDimension TypeTextureDimensionToResourceBindingTextureDimension(
|
||||
const ast::TextureDimension& type_dim);
|
||||
const type::TextureDimension& type_dim);
|
||||
|
||||
/// Infer ResourceBinding::SampledKind for a given type::Type
|
||||
/// @param base_type internal type to infer from
|
||||
|
|
|
@ -259,17 +259,17 @@ const ast::Type* InspectorBuilder::GetBaseType(ResourceBinding::SampledKind samp
|
|||
}
|
||||
}
|
||||
|
||||
const ast::Type* InspectorBuilder::GetCoordsType(ast::TextureDimension dim,
|
||||
const ast::Type* InspectorBuilder::GetCoordsType(type::TextureDimension dim,
|
||||
const ast::Type* scalar) {
|
||||
switch (dim) {
|
||||
case ast::TextureDimension::k1d:
|
||||
case type::TextureDimension::k1d:
|
||||
return scalar;
|
||||
case ast::TextureDimension::k2d:
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2dArray:
|
||||
return create<ast::Vector>(scalar, 2u);
|
||||
case ast::TextureDimension::k3d:
|
||||
case ast::TextureDimension::kCube:
|
||||
case ast::TextureDimension::kCubeArray:
|
||||
case type::TextureDimension::k3d:
|
||||
case type::TextureDimension::kCube:
|
||||
case type::TextureDimension::kCubeArray:
|
||||
return create<ast::Vector>(scalar, 3u);
|
||||
default:
|
||||
[=]() { FAIL() << "Unsupported texture dimension: " << dim; }();
|
||||
|
@ -277,7 +277,7 @@ const ast::Type* InspectorBuilder::GetCoordsType(ast::TextureDimension dim,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const ast::Type* InspectorBuilder::MakeStorageTextureTypes(ast::TextureDimension dim,
|
||||
const ast::Type* InspectorBuilder::MakeStorageTextureTypes(type::TextureDimension dim,
|
||||
ast::TexelFormat format) {
|
||||
return ty.storage_texture(dim, format, ast::Access::kWrite);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "src/tint/type/external_texture.h"
|
||||
#include "src/tint/type/multisampled_texture.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "tint/tint.h"
|
||||
|
||||
namespace tint::inspector {
|
||||
|
@ -287,13 +288,13 @@ class InspectorBuilder : public ProgramBuilder {
|
|||
/// @param dim dimensionality of the texture being sampled
|
||||
/// @param scalar the scalar type
|
||||
/// @returns a pointer to a type appropriate for the coord param
|
||||
const ast::Type* GetCoordsType(ast::TextureDimension dim, const ast::Type* scalar);
|
||||
const ast::Type* GetCoordsType(type::TextureDimension dim, const ast::Type* scalar);
|
||||
|
||||
/// Generates appropriate types for a Read-Only StorageTexture
|
||||
/// @param dim the texture dimension of the storage texture
|
||||
/// @param format the texel format of the storage texture
|
||||
/// @returns the storage texture type
|
||||
const ast::Type* MakeStorageTextureTypes(ast::TextureDimension dim, ast::TexelFormat format);
|
||||
const ast::Type* MakeStorageTextureTypes(type::TextureDimension dim, ast::TexelFormat format);
|
||||
|
||||
/// Adds a storage texture variable to the program
|
||||
/// @param name the name of the variable
|
||||
|
|
|
@ -107,6 +107,7 @@
|
|||
#include "src/tint/type/pointer.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/type/u32.h"
|
||||
#include "src/tint/type/vector.h"
|
||||
#include "src/tint/type/void.h"
|
||||
|
@ -1012,7 +1013,7 @@ class ProgramBuilder {
|
|||
|
||||
/// @param dims the dimensionality of the texture
|
||||
/// @returns the depth texture
|
||||
const ast::DepthTexture* depth_texture(ast::TextureDimension dims) const {
|
||||
const ast::DepthTexture* depth_texture(type::TextureDimension dims) const {
|
||||
return builder->create<ast::DepthTexture>(dims);
|
||||
}
|
||||
|
||||
|
@ -1020,14 +1021,14 @@ class ProgramBuilder {
|
|||
/// @param dims the dimensionality of the texture
|
||||
/// @returns the depth texture
|
||||
const ast::DepthTexture* depth_texture(const Source& source,
|
||||
ast::TextureDimension dims) const {
|
||||
type::TextureDimension dims) const {
|
||||
return builder->create<ast::DepthTexture>(source, dims);
|
||||
}
|
||||
|
||||
/// @param dims the dimensionality of the texture
|
||||
/// @returns the multisampled depth texture
|
||||
const ast::DepthMultisampledTexture* depth_multisampled_texture(
|
||||
ast::TextureDimension dims) const {
|
||||
type::TextureDimension dims) const {
|
||||
return builder->create<ast::DepthMultisampledTexture>(dims);
|
||||
}
|
||||
|
||||
|
@ -1036,14 +1037,14 @@ class ProgramBuilder {
|
|||
/// @returns the multisampled depth texture
|
||||
const ast::DepthMultisampledTexture* depth_multisampled_texture(
|
||||
const Source& source,
|
||||
ast::TextureDimension dims) const {
|
||||
type::TextureDimension dims) const {
|
||||
return builder->create<ast::DepthMultisampledTexture>(source, dims);
|
||||
}
|
||||
|
||||
/// @param dims the dimensionality of the texture
|
||||
/// @param subtype the texture subtype.
|
||||
/// @returns the sampled texture
|
||||
const ast::SampledTexture* sampled_texture(ast::TextureDimension dims,
|
||||
const ast::SampledTexture* sampled_texture(type::TextureDimension dims,
|
||||
const ast::Type* subtype) const {
|
||||
return builder->create<ast::SampledTexture>(dims, subtype);
|
||||
}
|
||||
|
@ -1053,7 +1054,7 @@ class ProgramBuilder {
|
|||
/// @param subtype the texture subtype.
|
||||
/// @returns the sampled texture
|
||||
const ast::SampledTexture* sampled_texture(const Source& source,
|
||||
ast::TextureDimension dims,
|
||||
type::TextureDimension dims,
|
||||
const ast::Type* subtype) const {
|
||||
return builder->create<ast::SampledTexture>(source, dims, subtype);
|
||||
}
|
||||
|
@ -1061,7 +1062,7 @@ class ProgramBuilder {
|
|||
/// @param dims the dimensionality of the texture
|
||||
/// @param subtype the texture subtype.
|
||||
/// @returns the multisampled texture
|
||||
const ast::MultisampledTexture* multisampled_texture(ast::TextureDimension dims,
|
||||
const ast::MultisampledTexture* multisampled_texture(type::TextureDimension dims,
|
||||
const ast::Type* subtype) const {
|
||||
return builder->create<ast::MultisampledTexture>(dims, subtype);
|
||||
}
|
||||
|
@ -1071,7 +1072,7 @@ class ProgramBuilder {
|
|||
/// @param subtype the texture subtype.
|
||||
/// @returns the multisampled texture
|
||||
const ast::MultisampledTexture* multisampled_texture(const Source& source,
|
||||
ast::TextureDimension dims,
|
||||
type::TextureDimension dims,
|
||||
const ast::Type* subtype) const {
|
||||
return builder->create<ast::MultisampledTexture>(source, dims, subtype);
|
||||
}
|
||||
|
@ -1080,7 +1081,7 @@ class ProgramBuilder {
|
|||
/// @param format the texel format of the texture
|
||||
/// @param access the access control of the texture
|
||||
/// @returns the storage texture
|
||||
const ast::StorageTexture* storage_texture(ast::TextureDimension dims,
|
||||
const ast::StorageTexture* storage_texture(type::TextureDimension dims,
|
||||
ast::TexelFormat format,
|
||||
ast::Access access) const {
|
||||
auto* subtype = ast::StorageTexture::SubtypeFor(format, *builder);
|
||||
|
@ -1093,7 +1094,7 @@ class ProgramBuilder {
|
|||
/// @param access the access control of the texture
|
||||
/// @returns the storage texture
|
||||
const ast::StorageTexture* storage_texture(const Source& source,
|
||||
ast::TextureDimension dims,
|
||||
type::TextureDimension dims,
|
||||
ast::TexelFormat format,
|
||||
ast::Access access) const {
|
||||
auto* subtype = ast::StorageTexture::SubtypeFor(format, *builder);
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "src/tint/reader/spirv/enum_converter.h"
|
||||
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::reader::spirv {
|
||||
|
||||
EnumConverter::EnumConverter(const FailStream& fs) : fail_stream_(fs) {}
|
||||
|
@ -98,34 +100,34 @@ ast::BuiltinValue EnumConverter::ToBuiltin(spv::BuiltIn b) {
|
|||
return ast::BuiltinValue::kUndefined;
|
||||
}
|
||||
|
||||
ast::TextureDimension EnumConverter::ToDim(spv::Dim dim, bool arrayed) {
|
||||
type::TextureDimension EnumConverter::ToDim(spv::Dim dim, bool arrayed) {
|
||||
if (arrayed) {
|
||||
switch (dim) {
|
||||
case spv::Dim::Dim2D:
|
||||
return ast::TextureDimension::k2dArray;
|
||||
return type::TextureDimension::k2dArray;
|
||||
case spv::Dim::Cube:
|
||||
return ast::TextureDimension::kCubeArray;
|
||||
return type::TextureDimension::kCubeArray;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Fail() << "arrayed dimension must be 2D or Cube. Got " << int(dim);
|
||||
return ast::TextureDimension::kNone;
|
||||
return type::TextureDimension::kNone;
|
||||
}
|
||||
// Assume non-arrayed
|
||||
switch (dim) {
|
||||
case spv::Dim::Dim1D:
|
||||
return ast::TextureDimension::k1d;
|
||||
return type::TextureDimension::k1d;
|
||||
case spv::Dim::Dim2D:
|
||||
return ast::TextureDimension::k2d;
|
||||
return type::TextureDimension::k2d;
|
||||
case spv::Dim::Dim3D:
|
||||
return ast::TextureDimension::k3d;
|
||||
return type::TextureDimension::k3d;
|
||||
case spv::Dim::Cube:
|
||||
return ast::TextureDimension::kCube;
|
||||
return type::TextureDimension::kCube;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Fail() << "invalid dimension: " << int(dim);
|
||||
return ast::TextureDimension::kNone;
|
||||
return type::TextureDimension::kNone;
|
||||
}
|
||||
|
||||
ast::TexelFormat EnumConverter::ToTexelFormat(spv::ImageFormat fmt) {
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "src/tint/ast/pipeline_stage.h"
|
||||
#include "src/tint/reader/spirv/fail_stream.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::reader::spirv {
|
||||
|
||||
|
@ -57,14 +58,14 @@ class EnumConverter {
|
|||
/// @param dim the SPIR-V Dim value
|
||||
/// @param arrayed true if the texture is arrayed
|
||||
/// @returns a Tint AST texture dimension
|
||||
ast::TextureDimension ToDim(spv::Dim dim, bool arrayed);
|
||||
type::TextureDimension ToDim(spv::Dim dim, bool arrayed);
|
||||
|
||||
/// Converts a possibly arrayed SPIR-V Dim to a Tint texture dimension.
|
||||
/// On failure, logs an error and returns kNone
|
||||
/// @param dim the SPIR-V Dim value
|
||||
/// @param arrayed true if the texture is arrayed
|
||||
/// @returns a Tint AST texture dimension
|
||||
ast::TextureDimension ToDim(SpvDim dim, bool arrayed) {
|
||||
type::TextureDimension ToDim(SpvDim dim, bool arrayed) {
|
||||
return ToDim(static_cast<spv::Dim>(dim), arrayed);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::reader::spirv {
|
||||
namespace {
|
||||
|
@ -217,7 +218,7 @@ struct DimCase {
|
|||
spv::Dim dim;
|
||||
bool arrayed;
|
||||
bool expect_success;
|
||||
ast::TextureDimension expected;
|
||||
type::TextureDimension expected;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, DimCase dc) {
|
||||
out << "DimCase{ spv::Dim:::" << int(dc.dim) << " arrayed?:" << int(dc.arrayed)
|
||||
|
@ -256,31 +257,31 @@ INSTANTIATE_TEST_SUITE_P(EnumConverterGood,
|
|||
SpvDimTest,
|
||||
testing::Values(
|
||||
// Non-arrayed
|
||||
DimCase{spv::Dim::Dim1D, false, true, ast::TextureDimension::k1d},
|
||||
DimCase{spv::Dim::Dim2D, false, true, ast::TextureDimension::k2d},
|
||||
DimCase{spv::Dim::Dim3D, false, true, ast::TextureDimension::k3d},
|
||||
DimCase{spv::Dim::Cube, false, true, ast::TextureDimension::kCube},
|
||||
DimCase{spv::Dim::Dim1D, false, true, type::TextureDimension::k1d},
|
||||
DimCase{spv::Dim::Dim2D, false, true, type::TextureDimension::k2d},
|
||||
DimCase{spv::Dim::Dim3D, false, true, type::TextureDimension::k3d},
|
||||
DimCase{spv::Dim::Cube, false, true, type::TextureDimension::kCube},
|
||||
// Arrayed
|
||||
DimCase{spv::Dim::Dim2D, true, true, ast::TextureDimension::k2dArray},
|
||||
DimCase{spv::Dim::Dim2D, true, true, type::TextureDimension::k2dArray},
|
||||
DimCase{spv::Dim::Cube, true, true,
|
||||
ast::TextureDimension::kCubeArray}));
|
||||
type::TextureDimension::kCubeArray}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
EnumConverterBad,
|
||||
SpvDimTest,
|
||||
testing::Values(
|
||||
// Invalid SPIR-V dimensionality.
|
||||
DimCase{spv::Dim::Max, false, false, ast::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::Max, true, false, ast::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::Max, false, false, type::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::Max, true, false, type::TextureDimension::kNone},
|
||||
// Vulkan non-arrayed dimensionalities not supported by WGSL.
|
||||
DimCase{spv::Dim::Rect, false, false, ast::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::Buffer, false, false, ast::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::SubpassData, false, false, ast::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::Rect, false, false, type::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::Buffer, false, false, type::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::SubpassData, false, false, type::TextureDimension::kNone},
|
||||
// Arrayed dimensionalities not supported by WGSL
|
||||
DimCase{spv::Dim::Dim3D, true, false, ast::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::Rect, true, false, ast::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::Buffer, true, false, ast::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::SubpassData, true, false, ast::TextureDimension::kNone}));
|
||||
DimCase{spv::Dim::Dim3D, true, false, type::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::Rect, true, false, type::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::Buffer, true, false, type::TextureDimension::kNone},
|
||||
DimCase{spv::Dim::SubpassData, true, false, type::TextureDimension::kNone}));
|
||||
|
||||
// TexelFormat
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "src/tint/transform/spirv_atomic.h"
|
||||
#include "src/tint/type/depth_texture.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/hashmap.h"
|
||||
#include "src/tint/utils/hashset.h"
|
||||
|
||||
|
@ -5619,9 +5620,9 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
|||
<< inst.PrettyPrint();
|
||||
}
|
||||
switch (texture_type->dims) {
|
||||
case ast::TextureDimension::k2d:
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case ast::TextureDimension::k3d:
|
||||
case type::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k3d:
|
||||
break;
|
||||
default:
|
||||
return Fail() << "ConstOffset is only permitted for 2D, 2D Arrayed, "
|
||||
|
@ -5749,8 +5750,8 @@ bool FunctionEmitter::EmitImageQuery(const spvtools::opt::Instruction& inst) {
|
|||
const ast::Expression* dims_call =
|
||||
create<ast::CallExpression>(Source{}, dims_ident, dims_args);
|
||||
auto dims = texture_type->dims;
|
||||
if ((dims == ast::TextureDimension::kCube) ||
|
||||
(dims == ast::TextureDimension::kCubeArray)) {
|
||||
if ((dims == type::TextureDimension::kCube) ||
|
||||
(dims == type::TextureDimension::kCubeArray)) {
|
||||
// textureDimension returns a 3-element vector but SPIR-V expects 2.
|
||||
dims_call =
|
||||
create<ast::MemberAccessorExpression>(Source{}, dims_call, PrefixSwizzle(2));
|
||||
|
@ -5952,7 +5953,7 @@ FunctionEmitter::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageA
|
|||
if (!texture_type) {
|
||||
return {};
|
||||
}
|
||||
ast::TextureDimension dim = texture_type->dims;
|
||||
type::TextureDimension dim = texture_type->dims;
|
||||
// Number of regular coordinates.
|
||||
uint32_t num_axes = static_cast<uint32_t>(ast::NumCoordinateAxes(dim));
|
||||
bool is_arrayed = ast::IsTextureArray(dim);
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "src/tint/type/depth_texture.h"
|
||||
#include "src/tint/type/multisampled_texture.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/unique_vector.h"
|
||||
|
||||
namespace tint::reader::spirv {
|
||||
|
@ -2481,9 +2482,9 @@ const Type* ParserImpl::GetHandleTypeForSpirvHandle(const spvtools::opt::Instruc
|
|||
}
|
||||
}
|
||||
|
||||
const ast::TextureDimension dim =
|
||||
const type::TextureDimension dim =
|
||||
enum_converter_.ToDim(image_type->dim(), image_type->is_arrayed());
|
||||
if (dim == ast::TextureDimension::kNone) {
|
||||
if (dim == type::TextureDimension::kNone) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -2506,7 +2507,7 @@ const Type* ParserImpl::GetHandleTypeForSpirvHandle(const spvtools::opt::Instruc
|
|||
ast_handle_type = ty_.DepthTexture(dim);
|
||||
}
|
||||
} else if (image_type->is_multisampled()) {
|
||||
if (dim != ast::TextureDimension::k2d) {
|
||||
if (dim != type::TextureDimension::k2d) {
|
||||
Fail() << "WGSL multisampled textures must be 2d and non-arrayed: "
|
||||
"invalid multisampled texture variable or function parameter "
|
||||
<< namer_.Name(obj.result_id()) << ": " << obj.PrettyPrint();
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/hash.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
#include "src/tint/utils/string.h"
|
||||
|
@ -222,24 +223,24 @@ const ast::Type* Sampler::Build(ProgramBuilder& b) const {
|
|||
return b.ty.sampler(kind);
|
||||
}
|
||||
|
||||
Texture::Texture(ast::TextureDimension d) : dims(d) {}
|
||||
Texture::Texture(type::TextureDimension d) : dims(d) {}
|
||||
Texture::Texture(const Texture&) = default;
|
||||
|
||||
DepthTexture::DepthTexture(ast::TextureDimension d) : Base(d) {}
|
||||
DepthTexture::DepthTexture(type::TextureDimension d) : Base(d) {}
|
||||
DepthTexture::DepthTexture(const DepthTexture&) = default;
|
||||
|
||||
const ast::Type* DepthTexture::Build(ProgramBuilder& b) const {
|
||||
return b.ty.depth_texture(dims);
|
||||
}
|
||||
|
||||
DepthMultisampledTexture::DepthMultisampledTexture(ast::TextureDimension d) : Base(d) {}
|
||||
DepthMultisampledTexture::DepthMultisampledTexture(type::TextureDimension d) : Base(d) {}
|
||||
DepthMultisampledTexture::DepthMultisampledTexture(const DepthMultisampledTexture&) = default;
|
||||
|
||||
const ast::Type* DepthMultisampledTexture::Build(ProgramBuilder& b) const {
|
||||
return b.ty.depth_multisampled_texture(dims);
|
||||
}
|
||||
|
||||
MultisampledTexture::MultisampledTexture(ast::TextureDimension d, const Type* t)
|
||||
MultisampledTexture::MultisampledTexture(type::TextureDimension d, const Type* t)
|
||||
: Base(d), type(t) {}
|
||||
MultisampledTexture::MultisampledTexture(const MultisampledTexture&) = default;
|
||||
|
||||
|
@ -247,14 +248,14 @@ const ast::Type* MultisampledTexture::Build(ProgramBuilder& b) const {
|
|||
return b.ty.multisampled_texture(dims, type->Build(b));
|
||||
}
|
||||
|
||||
SampledTexture::SampledTexture(ast::TextureDimension d, const Type* t) : Base(d), type(t) {}
|
||||
SampledTexture::SampledTexture(type::TextureDimension d, const Type* t) : Base(d), type(t) {}
|
||||
SampledTexture::SampledTexture(const SampledTexture&) = default;
|
||||
|
||||
const ast::Type* SampledTexture::Build(ProgramBuilder& b) const {
|
||||
return b.ty.sampled_texture(dims, type->Build(b));
|
||||
}
|
||||
|
||||
StorageTexture::StorageTexture(ast::TextureDimension d, ast::TexelFormat f, ast::Access a)
|
||||
StorageTexture::StorageTexture(type::TextureDimension d, ast::TexelFormat f, ast::Access a)
|
||||
: Base(d), format(f), access(a) {}
|
||||
StorageTexture::StorageTexture(const StorageTexture&) = default;
|
||||
|
||||
|
@ -494,26 +495,26 @@ const spirv::Sampler* TypeManager::Sampler(ast::SamplerKind kind) {
|
|||
return state->samplers_.Get(kind);
|
||||
}
|
||||
|
||||
const spirv::DepthTexture* TypeManager::DepthTexture(ast::TextureDimension dims) {
|
||||
const spirv::DepthTexture* TypeManager::DepthTexture(type::TextureDimension dims) {
|
||||
return state->depth_textures_.Get(dims);
|
||||
}
|
||||
|
||||
const spirv::DepthMultisampledTexture* TypeManager::DepthMultisampledTexture(
|
||||
ast::TextureDimension dims) {
|
||||
type::TextureDimension dims) {
|
||||
return state->depth_multisampled_textures_.Get(dims);
|
||||
}
|
||||
|
||||
const spirv::MultisampledTexture* TypeManager::MultisampledTexture(ast::TextureDimension dims,
|
||||
const spirv::MultisampledTexture* TypeManager::MultisampledTexture(type::TextureDimension dims,
|
||||
const Type* ty) {
|
||||
return state->multisampled_textures_.Get(dims, ty);
|
||||
}
|
||||
|
||||
const spirv::SampledTexture* TypeManager::SampledTexture(ast::TextureDimension dims,
|
||||
const spirv::SampledTexture* TypeManager::SampledTexture(type::TextureDimension dims,
|
||||
const Type* ty) {
|
||||
return state->sampled_textures_.Get(dims, ty);
|
||||
}
|
||||
|
||||
const spirv::StorageTexture* TypeManager::StorageTexture(ast::TextureDimension dims,
|
||||
const spirv::StorageTexture* TypeManager::StorageTexture(type::TextureDimension dims,
|
||||
ast::TexelFormat fmt,
|
||||
ast::Access access) {
|
||||
return state->storage_textures_.Get(dims, fmt, access);
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
#include "src/tint/ast/address_space.h"
|
||||
#include "src/tint/ast/sampler.h"
|
||||
#include "src/tint/ast/storage_texture.h"
|
||||
#include "src/tint/ast/texture.h"
|
||||
#include "src/tint/castable.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/block_allocator.h"
|
||||
|
||||
// Forward declarations
|
||||
|
@ -331,21 +331,21 @@ struct Texture : public Castable<Texture, Type> {
|
|||
|
||||
/// Constructor
|
||||
/// @param d the texture dimensions
|
||||
explicit Texture(ast::TextureDimension d);
|
||||
explicit Texture(type::TextureDimension d);
|
||||
|
||||
/// Copy constructor
|
||||
/// @param other the other type to copy
|
||||
Texture(const Texture& other);
|
||||
|
||||
/// the texture dimensions
|
||||
ast::TextureDimension const dims;
|
||||
type::TextureDimension const dims;
|
||||
};
|
||||
|
||||
/// `texture_depth_D` type
|
||||
struct DepthTexture final : public Castable<DepthTexture, Texture> {
|
||||
/// Constructor
|
||||
/// @param d the texture dimensions
|
||||
explicit DepthTexture(ast::TextureDimension d);
|
||||
explicit DepthTexture(type::TextureDimension d);
|
||||
|
||||
/// Copy constructor
|
||||
/// @param other the other type to copy
|
||||
|
@ -365,7 +365,7 @@ struct DepthTexture final : public Castable<DepthTexture, Texture> {
|
|||
struct DepthMultisampledTexture final : public Castable<DepthMultisampledTexture, Texture> {
|
||||
/// Constructor
|
||||
/// @param d the texture dimensions
|
||||
explicit DepthMultisampledTexture(ast::TextureDimension d);
|
||||
explicit DepthMultisampledTexture(type::TextureDimension d);
|
||||
|
||||
/// Copy constructor
|
||||
/// @param other the other type to copy
|
||||
|
@ -386,7 +386,7 @@ struct MultisampledTexture final : public Castable<MultisampledTexture, Texture>
|
|||
/// Constructor
|
||||
/// @param d the texture dimensions
|
||||
/// @param t the multisampled texture type
|
||||
MultisampledTexture(ast::TextureDimension d, const Type* t);
|
||||
MultisampledTexture(type::TextureDimension d, const Type* t);
|
||||
|
||||
/// Copy constructor
|
||||
/// @param other the other type to copy
|
||||
|
@ -410,7 +410,7 @@ struct SampledTexture final : public Castable<SampledTexture, Texture> {
|
|||
/// Constructor
|
||||
/// @param d the texture dimensions
|
||||
/// @param t the sampled texture type
|
||||
SampledTexture(ast::TextureDimension d, const Type* t);
|
||||
SampledTexture(type::TextureDimension d, const Type* t);
|
||||
|
||||
/// Copy constructor
|
||||
/// @param other the other type to copy
|
||||
|
@ -435,7 +435,7 @@ struct StorageTexture final : public Castable<StorageTexture, Texture> {
|
|||
/// @param d the texture dimensions
|
||||
/// @param f the storage image format
|
||||
/// @param a the access control
|
||||
StorageTexture(ast::TextureDimension d, ast::TexelFormat f, ast::Access a);
|
||||
StorageTexture(type::TextureDimension d, ast::TexelFormat f, ast::Access a);
|
||||
|
||||
/// Copy constructor
|
||||
/// @param other the other type to copy
|
||||
|
@ -595,27 +595,27 @@ class TypeManager {
|
|||
/// @param d the texture dimensions
|
||||
/// @return a DepthTexture type. Repeated calls with the same arguments will
|
||||
/// return the same pointer.
|
||||
const spirv::DepthTexture* DepthTexture(ast::TextureDimension d);
|
||||
const spirv::DepthTexture* DepthTexture(type::TextureDimension d);
|
||||
/// @param d the texture dimensions
|
||||
/// @return a DepthMultisampledTexture type. Repeated calls with the same
|
||||
/// arguments will return the same pointer.
|
||||
const spirv::DepthMultisampledTexture* DepthMultisampledTexture(ast::TextureDimension d);
|
||||
const spirv::DepthMultisampledTexture* DepthMultisampledTexture(type::TextureDimension d);
|
||||
/// @param d the texture dimensions
|
||||
/// @param t the multisampled texture type
|
||||
/// @return a MultisampledTexture type. Repeated calls with the same arguments
|
||||
/// will return the same pointer.
|
||||
const spirv::MultisampledTexture* MultisampledTexture(ast::TextureDimension d, const Type* t);
|
||||
const spirv::MultisampledTexture* MultisampledTexture(type::TextureDimension d, const Type* t);
|
||||
/// @param d the texture dimensions
|
||||
/// @param t the sampled texture type
|
||||
/// @return a SampledTexture type. Repeated calls with the same arguments will
|
||||
/// return the same pointer.
|
||||
const spirv::SampledTexture* SampledTexture(ast::TextureDimension d, const Type* t);
|
||||
const spirv::SampledTexture* SampledTexture(type::TextureDimension d, const Type* t);
|
||||
/// @param d the texture dimensions
|
||||
/// @param f the storage image format
|
||||
/// @param a the access control
|
||||
/// @return a StorageTexture type. Repeated calls with the same arguments will
|
||||
/// return the same pointer.
|
||||
const spirv::StorageTexture* StorageTexture(ast::TextureDimension d,
|
||||
const spirv::StorageTexture* StorageTexture(type::TextureDimension d,
|
||||
ast::TexelFormat f,
|
||||
ast::Access a);
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "src/tint/reader/spirv/parser_type.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::reader::spirv {
|
||||
namespace {
|
||||
|
@ -36,15 +37,15 @@ TEST(SpvParserTypeTest, SameArgumentsGivesSamePointer) {
|
|||
EXPECT_EQ(ty.Alias(sym, ty.I32()), ty.Alias(sym, ty.I32()));
|
||||
EXPECT_EQ(ty.Struct(sym, {ty.I32()}), ty.Struct(sym, {ty.I32()}));
|
||||
EXPECT_EQ(ty.Sampler(ast::SamplerKind::kSampler), ty.Sampler(ast::SamplerKind::kSampler));
|
||||
EXPECT_EQ(ty.DepthTexture(ast::TextureDimension::k2d),
|
||||
ty.DepthTexture(ast::TextureDimension::k2d));
|
||||
EXPECT_EQ(ty.MultisampledTexture(ast::TextureDimension::k2d, ty.I32()),
|
||||
ty.MultisampledTexture(ast::TextureDimension::k2d, ty.I32()));
|
||||
EXPECT_EQ(ty.SampledTexture(ast::TextureDimension::k2d, ty.I32()),
|
||||
ty.SampledTexture(ast::TextureDimension::k2d, ty.I32()));
|
||||
EXPECT_EQ(ty.StorageTexture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
EXPECT_EQ(ty.DepthTexture(type::TextureDimension::k2d),
|
||||
ty.DepthTexture(type::TextureDimension::k2d));
|
||||
EXPECT_EQ(ty.MultisampledTexture(type::TextureDimension::k2d, ty.I32()),
|
||||
ty.MultisampledTexture(type::TextureDimension::k2d, ty.I32()));
|
||||
EXPECT_EQ(ty.SampledTexture(type::TextureDimension::k2d, ty.I32()),
|
||||
ty.SampledTexture(type::TextureDimension::k2d, ty.I32()));
|
||||
EXPECT_EQ(ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
ast::Access::kRead),
|
||||
ty.StorageTexture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
ast::Access::kRead));
|
||||
}
|
||||
|
||||
|
@ -69,27 +70,27 @@ TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) {
|
|||
EXPECT_NE(ty.Struct(sym_a, {ty.I32()}), ty.Struct(sym_b, {ty.I32()}));
|
||||
EXPECT_NE(ty.Sampler(ast::SamplerKind::kSampler),
|
||||
ty.Sampler(ast::SamplerKind::kComparisonSampler));
|
||||
EXPECT_NE(ty.DepthTexture(ast::TextureDimension::k2d),
|
||||
ty.DepthTexture(ast::TextureDimension::k1d));
|
||||
EXPECT_NE(ty.MultisampledTexture(ast::TextureDimension::k2d, ty.I32()),
|
||||
ty.MultisampledTexture(ast::TextureDimension::k3d, ty.I32()));
|
||||
EXPECT_NE(ty.MultisampledTexture(ast::TextureDimension::k2d, ty.I32()),
|
||||
ty.MultisampledTexture(ast::TextureDimension::k2d, ty.U32()));
|
||||
EXPECT_NE(ty.SampledTexture(ast::TextureDimension::k2d, ty.I32()),
|
||||
ty.SampledTexture(ast::TextureDimension::k3d, ty.I32()));
|
||||
EXPECT_NE(ty.SampledTexture(ast::TextureDimension::k2d, ty.I32()),
|
||||
ty.SampledTexture(ast::TextureDimension::k2d, ty.U32()));
|
||||
EXPECT_NE(ty.StorageTexture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
EXPECT_NE(ty.DepthTexture(type::TextureDimension::k2d),
|
||||
ty.DepthTexture(type::TextureDimension::k1d));
|
||||
EXPECT_NE(ty.MultisampledTexture(type::TextureDimension::k2d, ty.I32()),
|
||||
ty.MultisampledTexture(type::TextureDimension::k3d, ty.I32()));
|
||||
EXPECT_NE(ty.MultisampledTexture(type::TextureDimension::k2d, ty.I32()),
|
||||
ty.MultisampledTexture(type::TextureDimension::k2d, ty.U32()));
|
||||
EXPECT_NE(ty.SampledTexture(type::TextureDimension::k2d, ty.I32()),
|
||||
ty.SampledTexture(type::TextureDimension::k3d, ty.I32()));
|
||||
EXPECT_NE(ty.SampledTexture(type::TextureDimension::k2d, ty.I32()),
|
||||
ty.SampledTexture(type::TextureDimension::k2d, ty.U32()));
|
||||
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
ast::Access::kRead),
|
||||
ty.StorageTexture(ast::TextureDimension::k3d, ast::TexelFormat::kR32Uint,
|
||||
ty.StorageTexture(type::TextureDimension::k3d, ast::TexelFormat::kR32Uint,
|
||||
ast::Access::kRead));
|
||||
EXPECT_NE(ty.StorageTexture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
ast::Access::kRead),
|
||||
ty.StorageTexture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Sint,
|
||||
ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Sint,
|
||||
ast::Access::kRead));
|
||||
EXPECT_NE(ty.StorageTexture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
ast::Access::kRead),
|
||||
ty.StorageTexture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
ty.StorageTexture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
ast::Access::kWrite));
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "src/tint/type/external_texture.h"
|
||||
#include "src/tint/type/multisampled_texture.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/reverse.h"
|
||||
#include "src/tint/utils/string.h"
|
||||
|
||||
|
@ -806,29 +807,29 @@ Maybe<const ast::Type*> ParserImpl::sampler_type() {
|
|||
// | TEXTURE_SAMPLED_3D
|
||||
// | TEXTURE_SAMPLED_CUBE
|
||||
// | TEXTURE_SAMPLED_CUBE_ARRAY
|
||||
Maybe<const ast::TextureDimension> ParserImpl::sampled_texture_type() {
|
||||
Maybe<const type::TextureDimension> ParserImpl::sampled_texture_type() {
|
||||
if (match(Token::Type::kTextureSampled1d)) {
|
||||
return ast::TextureDimension::k1d;
|
||||
return type::TextureDimension::k1d;
|
||||
}
|
||||
|
||||
if (match(Token::Type::kTextureSampled2d)) {
|
||||
return ast::TextureDimension::k2d;
|
||||
return type::TextureDimension::k2d;
|
||||
}
|
||||
|
||||
if (match(Token::Type::kTextureSampled2dArray)) {
|
||||
return ast::TextureDimension::k2dArray;
|
||||
return type::TextureDimension::k2dArray;
|
||||
}
|
||||
|
||||
if (match(Token::Type::kTextureSampled3d)) {
|
||||
return ast::TextureDimension::k3d;
|
||||
return type::TextureDimension::k3d;
|
||||
}
|
||||
|
||||
if (match(Token::Type::kTextureSampledCube)) {
|
||||
return ast::TextureDimension::kCube;
|
||||
return type::TextureDimension::kCube;
|
||||
}
|
||||
|
||||
if (match(Token::Type::kTextureSampledCubeArray)) {
|
||||
return ast::TextureDimension::kCubeArray;
|
||||
return type::TextureDimension::kCubeArray;
|
||||
}
|
||||
|
||||
return Failure::kNoMatch;
|
||||
|
@ -847,9 +848,9 @@ Maybe<const ast::Type*> ParserImpl::external_texture() {
|
|||
|
||||
// multisampled_texture_type
|
||||
// : TEXTURE_MULTISAMPLED_2D
|
||||
Maybe<const ast::TextureDimension> ParserImpl::multisampled_texture_type() {
|
||||
Maybe<const type::TextureDimension> ParserImpl::multisampled_texture_type() {
|
||||
if (match(Token::Type::kTextureMultisampled2d)) {
|
||||
return ast::TextureDimension::k2d;
|
||||
return type::TextureDimension::k2d;
|
||||
}
|
||||
|
||||
return Failure::kNoMatch;
|
||||
|
@ -860,18 +861,18 @@ Maybe<const ast::TextureDimension> ParserImpl::multisampled_texture_type() {
|
|||
// | TEXTURE_STORAGE_2D
|
||||
// | TEXTURE_STORAGE_2D_ARRAY
|
||||
// | TEXTURE_STORAGE_3D
|
||||
Maybe<const ast::TextureDimension> ParserImpl::storage_texture_type() {
|
||||
Maybe<const type::TextureDimension> ParserImpl::storage_texture_type() {
|
||||
if (match(Token::Type::kTextureStorage1d)) {
|
||||
return ast::TextureDimension::k1d;
|
||||
return type::TextureDimension::k1d;
|
||||
}
|
||||
if (match(Token::Type::kTextureStorage2d)) {
|
||||
return ast::TextureDimension::k2d;
|
||||
return type::TextureDimension::k2d;
|
||||
}
|
||||
if (match(Token::Type::kTextureStorage2dArray)) {
|
||||
return ast::TextureDimension::k2dArray;
|
||||
return type::TextureDimension::k2dArray;
|
||||
}
|
||||
if (match(Token::Type::kTextureStorage3d)) {
|
||||
return ast::TextureDimension::k3d;
|
||||
return type::TextureDimension::k3d;
|
||||
}
|
||||
|
||||
return Failure::kNoMatch;
|
||||
|
@ -886,19 +887,19 @@ Maybe<const ast::TextureDimension> ParserImpl::storage_texture_type() {
|
|||
Maybe<const ast::Type*> ParserImpl::depth_texture_type() {
|
||||
Source source;
|
||||
if (match(Token::Type::kTextureDepth2d, &source)) {
|
||||
return builder_.ty.depth_texture(source, ast::TextureDimension::k2d);
|
||||
return builder_.ty.depth_texture(source, type::TextureDimension::k2d);
|
||||
}
|
||||
if (match(Token::Type::kTextureDepth2dArray, &source)) {
|
||||
return builder_.ty.depth_texture(source, ast::TextureDimension::k2dArray);
|
||||
return builder_.ty.depth_texture(source, type::TextureDimension::k2dArray);
|
||||
}
|
||||
if (match(Token::Type::kTextureDepthCube, &source)) {
|
||||
return builder_.ty.depth_texture(source, ast::TextureDimension::kCube);
|
||||
return builder_.ty.depth_texture(source, type::TextureDimension::kCube);
|
||||
}
|
||||
if (match(Token::Type::kTextureDepthCubeArray, &source)) {
|
||||
return builder_.ty.depth_texture(source, ast::TextureDimension::kCubeArray);
|
||||
return builder_.ty.depth_texture(source, type::TextureDimension::kCubeArray);
|
||||
}
|
||||
if (match(Token::Type::kTextureDepthMultisampled2d, &source)) {
|
||||
return builder_.ty.depth_multisampled_texture(source, ast::TextureDimension::k2d);
|
||||
return builder_.ty.depth_multisampled_texture(source, type::TextureDimension::k2d);
|
||||
}
|
||||
return Failure::kNoMatch;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "src/tint/reader/wgsl/parser_impl_detail.h"
|
||||
#include "src/tint/reader/wgsl/token.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::ast {
|
||||
class BreakStatement;
|
||||
|
@ -486,14 +487,14 @@ class ParserImpl {
|
|||
/// Parses a `multisampled_texture_type` grammar element
|
||||
/// @returns returns the multisample texture dimension or kNone if none
|
||||
/// matched.
|
||||
Maybe<const ast::TextureDimension> multisampled_texture_type();
|
||||
Maybe<const type::TextureDimension> multisampled_texture_type();
|
||||
/// Parses a `sampled_texture_type` grammar element
|
||||
/// @returns returns the sample texture dimension or kNone if none matched.
|
||||
Maybe<const ast::TextureDimension> sampled_texture_type();
|
||||
Maybe<const type::TextureDimension> sampled_texture_type();
|
||||
/// Parses a `storage_texture_type` grammar element
|
||||
/// @returns returns the storage texture dimension.
|
||||
/// Returns kNone if none matched.
|
||||
Maybe<const ast::TextureDimension> storage_texture_type();
|
||||
Maybe<const type::TextureDimension> storage_texture_type();
|
||||
/// Parses a `depth_texture_type` grammar element
|
||||
/// @returns the parsed Type or nullptr if none matched.
|
||||
Maybe<const ast::Type*> depth_texture_type();
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "src/tint/reader/wgsl/parser_impl_test_helper.h"
|
||||
#include "src/tint/type/depth_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::reader::wgsl {
|
||||
namespace {
|
||||
|
@ -34,7 +35,7 @@ TEST_F(ParserImplTest, DepthTextureType_2d) {
|
|||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<ast::Texture>());
|
||||
ASSERT_TRUE(t->Is<ast::DepthTexture>());
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::k2d);
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k2d);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 17u}}));
|
||||
}
|
||||
|
@ -47,7 +48,7 @@ TEST_F(ParserImplTest, DepthTextureType_2dArray) {
|
|||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<ast::Texture>());
|
||||
ASSERT_TRUE(t->Is<ast::DepthTexture>());
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::k2dArray);
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k2dArray);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 23u}}));
|
||||
}
|
||||
|
@ -60,7 +61,7 @@ TEST_F(ParserImplTest, DepthTextureType_Cube) {
|
|||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<ast::Texture>());
|
||||
ASSERT_TRUE(t->Is<ast::DepthTexture>());
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::kCube);
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::kCube);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 19u}}));
|
||||
}
|
||||
|
@ -73,7 +74,7 @@ TEST_F(ParserImplTest, DepthTextureType_CubeArray) {
|
|||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<ast::Texture>());
|
||||
ASSERT_TRUE(t->Is<ast::DepthTexture>());
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::kCubeArray);
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::kCubeArray);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 25u}}));
|
||||
}
|
||||
|
@ -86,7 +87,7 @@ TEST_F(ParserImplTest, DepthTextureType_Multisampled2d) {
|
|||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<ast::Texture>());
|
||||
ASSERT_TRUE(t->Is<ast::DepthMultisampledTexture>());
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::k2d);
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k2d);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 30u}}));
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include "src/tint/reader/wgsl/parser_impl_test_helper.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::reader::wgsl {
|
||||
namespace {
|
||||
|
@ -30,7 +31,7 @@ TEST_F(ParserImplTest, SampledTextureType_1d) {
|
|||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::TextureDimension::k1d);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::k1d);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
@ -39,7 +40,7 @@ TEST_F(ParserImplTest, SampledTextureType_2d) {
|
|||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::TextureDimension::k2d);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::k2d);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
@ -48,7 +49,7 @@ TEST_F(ParserImplTest, SampledTextureType_2dArray) {
|
|||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::TextureDimension::k2dArray);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::k2dArray);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
@ -57,7 +58,7 @@ TEST_F(ParserImplTest, SampledTextureType_3d) {
|
|||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::TextureDimension::k3d);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::k3d);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
@ -66,7 +67,7 @@ TEST_F(ParserImplTest, SampledTextureType_Cube) {
|
|||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::TextureDimension::kCube);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::kCube);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
@ -75,7 +76,7 @@ TEST_F(ParserImplTest, SampledTextureType_kCubeArray) {
|
|||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::TextureDimension::kCubeArray);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::kCubeArray);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include "src/tint/reader/wgsl/parser_impl_test_helper.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::reader::wgsl {
|
||||
namespace {
|
||||
|
@ -30,7 +31,7 @@ TEST_F(ParserImplTest, StorageTextureType_1d) {
|
|||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::TextureDimension::k1d);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::k1d);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
@ -39,7 +40,7 @@ TEST_F(ParserImplTest, StorageTextureType_2d) {
|
|||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::TextureDimension::k2d);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::k2d);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
@ -48,7 +49,7 @@ TEST_F(ParserImplTest, StorageTextureType_2dArray) {
|
|||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::TextureDimension::k2dArray);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::k2dArray);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
@ -57,7 +58,7 @@ TEST_F(ParserImplTest, StorageTextureType_3d) {
|
|||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::TextureDimension::k3d);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::k3d);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "src/tint/type/depth_texture.h"
|
||||
#include "src/tint/type/multisampled_texture.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::reader::wgsl {
|
||||
namespace {
|
||||
|
@ -62,7 +63,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
|
|||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<ast::Texture>());
|
||||
ASSERT_TRUE(t->Is<ast::DepthTexture>());
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::k2d);
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k2d);
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 17u}}));
|
||||
}
|
||||
|
||||
|
@ -76,7 +77,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32) {
|
|||
ASSERT_TRUE(t->Is<ast::Texture>());
|
||||
ASSERT_TRUE(t->Is<ast::SampledTexture>());
|
||||
ASSERT_TRUE(t->As<ast::SampledTexture>()->type->Is<ast::F32>());
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::k1d);
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k1d);
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 16u}}));
|
||||
}
|
||||
|
||||
|
@ -90,7 +91,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) {
|
|||
ASSERT_TRUE(t->Is<ast::Texture>());
|
||||
ASSERT_TRUE(t->Is<ast::SampledTexture>());
|
||||
ASSERT_TRUE(t->As<ast::SampledTexture>()->type->Is<ast::I32>());
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::k2d);
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k2d);
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 16u}}));
|
||||
}
|
||||
|
||||
|
@ -104,7 +105,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) {
|
|||
ASSERT_TRUE(t->Is<ast::Texture>());
|
||||
ASSERT_TRUE(t->Is<ast::SampledTexture>());
|
||||
ASSERT_TRUE(t->As<ast::SampledTexture>()->type->Is<ast::U32>());
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::k3d);
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k3d);
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 16u}}));
|
||||
}
|
||||
|
||||
|
@ -148,7 +149,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_I32) {
|
|||
ASSERT_TRUE(t->Is<ast::Texture>());
|
||||
ASSERT_TRUE(t->Is<ast::MultisampledTexture>());
|
||||
ASSERT_TRUE(t->As<ast::MultisampledTexture>()->type->Is<ast::I32>());
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::k2d);
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k2d);
|
||||
EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 29u}}));
|
||||
}
|
||||
|
||||
|
@ -192,7 +193,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dRg32Float) {
|
|||
ASSERT_TRUE(t->Is<ast::StorageTexture>());
|
||||
EXPECT_EQ(t->As<ast::StorageTexture>()->format, ast::TexelFormat::kRg32Float);
|
||||
EXPECT_EQ(t->As<ast::StorageTexture>()->access, ast::Access::kRead);
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::k1d);
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k1d);
|
||||
EXPECT_EQ(t->source.range, (Source::Range{{1u, 1u}, {1u, 36u}}));
|
||||
}
|
||||
|
||||
|
@ -208,7 +209,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR32Uint) {
|
|||
ASSERT_TRUE(t->Is<ast::StorageTexture>());
|
||||
EXPECT_EQ(t->As<ast::StorageTexture>()->format, ast::TexelFormat::kR32Uint);
|
||||
EXPECT_EQ(t->As<ast::StorageTexture>()->access, ast::Access::kWrite);
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, ast::TextureDimension::k2d);
|
||||
EXPECT_EQ(t->As<ast::Texture>()->dim, type::TextureDimension::k2d);
|
||||
EXPECT_EQ(t->source.range, (Source::Range{{1u, 1u}, {1u, 35u}}));
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "gmock/gmock.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
|
@ -230,7 +231,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Handle) {
|
|||
// a = b;
|
||||
|
||||
auto make_type = [&] {
|
||||
return ty.storage_texture(ast::TextureDimension::k1d, ast::TexelFormat::kRgba8Unorm,
|
||||
return ty.storage_texture(type::TextureDimension::k1d, ast::TexelFormat::kRgba8Unorm,
|
||||
ast::Access::kWrite);
|
||||
};
|
||||
|
||||
|
@ -360,7 +361,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_Pass) {
|
|||
auto* U = Structure("U", utils::Vector{
|
||||
Member("i", ty.i32()),
|
||||
});
|
||||
GlobalVar("tex", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(0_a),
|
||||
GlobalVar("tex", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Group(0_a),
|
||||
Binding(0_a));
|
||||
GlobalVar("smp", ty.sampler(ast::SamplerKind::kSampler), Group(0_a), Binding(1_a));
|
||||
GlobalVar("u", ty.Of(U), ast::AddressSpace::kUniform, Group(0_a), Binding(2_a));
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "src/tint/resolver/resolver.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/transform/add_block_attribute.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
|
@ -1166,7 +1167,7 @@ TEST_F(ResourceAttributeTest, StorageBufferMissingBinding) {
|
|||
}
|
||||
|
||||
TEST_F(ResourceAttributeTest, TextureMissingBinding) {
|
||||
GlobalVar(Source{{12, 34}}, "G", ty.depth_texture(ast::TextureDimension::k2d));
|
||||
GlobalVar(Source{{12, 34}}, "G", ty.depth_texture(type::TextureDimension::k2d));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
|
@ -1198,9 +1199,9 @@ TEST_F(ResourceAttributeTest, BindingPairMissingGroup) {
|
|||
}
|
||||
|
||||
TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByEntryPoint) {
|
||||
GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
|
||||
GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()),
|
||||
Binding(1_a), Group(2_a));
|
||||
GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
|
||||
GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()),
|
||||
Binding(1_a), Group(2_a));
|
||||
|
||||
Func("F", utils::Empty, ty.void_(),
|
||||
|
@ -1220,9 +1221,9 @@ TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByEntryPoint) {
|
|||
}
|
||||
|
||||
TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByDifferentEntryPoints) {
|
||||
GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
|
||||
GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()),
|
||||
Binding(1_a), Group(2_a));
|
||||
GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
|
||||
GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()),
|
||||
Binding(1_a), Group(2_a));
|
||||
|
||||
Func("F_A", utils::Empty, ty.void_(),
|
||||
|
@ -1582,7 +1583,7 @@ using GroupAndBindingTest = ResolverTest;
|
|||
TEST_F(GroupAndBindingTest, Const_I32) {
|
||||
GlobalConst("b", Expr(4_i));
|
||||
GlobalConst("g", Expr(2_i));
|
||||
GlobalVar("val", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Binding("b"),
|
||||
GlobalVar("val", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Binding("b"),
|
||||
Group("g"));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
@ -1591,7 +1592,7 @@ TEST_F(GroupAndBindingTest, Const_I32) {
|
|||
TEST_F(GroupAndBindingTest, Const_U32) {
|
||||
GlobalConst("b", Expr(4_u));
|
||||
GlobalConst("g", Expr(2_u));
|
||||
GlobalVar("val", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Binding("b"),
|
||||
GlobalVar("val", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Binding("b"),
|
||||
Group("g"));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
@ -1600,14 +1601,14 @@ TEST_F(GroupAndBindingTest, Const_U32) {
|
|||
TEST_F(GroupAndBindingTest, Const_AInt) {
|
||||
GlobalConst("b", Expr(4_a));
|
||||
GlobalConst("g", Expr(2_a));
|
||||
GlobalVar("val", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Binding("b"),
|
||||
GlobalVar("val", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Binding("b"),
|
||||
Group("g"));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
||||
TEST_F(GroupAndBindingTest, Binding_NonConstant) {
|
||||
GlobalVar("val", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
|
||||
GlobalVar("val", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()),
|
||||
Binding(Construct(ty.u32(), Call(Source{{12, 34}}, "dpdx", 1_a))), Group(1_i));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1617,7 +1618,7 @@ TEST_F(GroupAndBindingTest, Binding_NonConstant) {
|
|||
}
|
||||
|
||||
TEST_F(GroupAndBindingTest, Binding_Negative) {
|
||||
GlobalVar("val", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
|
||||
GlobalVar("val", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()),
|
||||
Binding(Source{{12, 34}}, -2_i), Group(1_i));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1625,7 +1626,7 @@ TEST_F(GroupAndBindingTest, Binding_Negative) {
|
|||
}
|
||||
|
||||
TEST_F(GroupAndBindingTest, Binding_F32) {
|
||||
GlobalVar("val", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
|
||||
GlobalVar("val", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()),
|
||||
Binding(Source{{12, 34}}, 2.0_f), Group(1_u));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1633,7 +1634,7 @@ TEST_F(GroupAndBindingTest, Binding_F32) {
|
|||
}
|
||||
|
||||
TEST_F(GroupAndBindingTest, Binding_AFloat) {
|
||||
GlobalVar("val", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
|
||||
GlobalVar("val", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()),
|
||||
Binding(Source{{12, 34}}, 2.0_a), Group(1_u));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1641,7 +1642,7 @@ TEST_F(GroupAndBindingTest, Binding_AFloat) {
|
|||
}
|
||||
|
||||
TEST_F(GroupAndBindingTest, Group_NonConstant) {
|
||||
GlobalVar("val", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Binding(2_u),
|
||||
GlobalVar("val", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Binding(2_u),
|
||||
Group(Construct(ty.u32(), Call(Source{{12, 34}}, "dpdx", 1_a))));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1651,7 +1652,7 @@ TEST_F(GroupAndBindingTest, Group_NonConstant) {
|
|||
}
|
||||
|
||||
TEST_F(GroupAndBindingTest, Group_Negative) {
|
||||
GlobalVar("val", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Binding(2_u),
|
||||
GlobalVar("val", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Binding(2_u),
|
||||
Group(Source{{12, 34}}, -1_i));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1659,7 +1660,7 @@ TEST_F(GroupAndBindingTest, Group_Negative) {
|
|||
}
|
||||
|
||||
TEST_F(GroupAndBindingTest, Group_F32) {
|
||||
GlobalVar("val", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Binding(2_u),
|
||||
GlobalVar("val", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Binding(2_u),
|
||||
Group(Source{{12, 34}}, 1.0_f));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1667,7 +1668,7 @@ TEST_F(GroupAndBindingTest, Group_F32) {
|
|||
}
|
||||
|
||||
TEST_F(GroupAndBindingTest, Group_AFloat) {
|
||||
GlobalVar("val", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Binding(2_u),
|
||||
GlobalVar("val", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Binding(2_u),
|
||||
Group(Source{{12, 34}}, 1.0_a));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "src/tint/sem/variable.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/test_helper.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
using ::testing::ElementsAre;
|
||||
using ::testing::HasSubstr;
|
||||
|
@ -2102,7 +2103,7 @@ inline std::ostream& operator<<(std::ostream& out, Texture data) {
|
|||
}
|
||||
|
||||
struct TextureTestParams {
|
||||
ast::TextureDimension dim;
|
||||
type::TextureDimension dim;
|
||||
Texture type = Texture::kF32;
|
||||
ast::TexelFormat format = ast::TexelFormat::kR32Float;
|
||||
};
|
||||
|
@ -2118,16 +2119,16 @@ class ResolverBuiltinTest_TextureOperation : public ResolverTestWithParam<Textur
|
|||
/// @param dim dimensionality of the texture being sampled
|
||||
/// @param scalar the scalar type
|
||||
/// @returns a pointer to a type appropriate for the coord param
|
||||
const ast::Type* GetCoordsType(ast::TextureDimension dim, const ast::Type* scalar) {
|
||||
const ast::Type* GetCoordsType(type::TextureDimension dim, const ast::Type* scalar) {
|
||||
switch (dim) {
|
||||
case ast::TextureDimension::k1d:
|
||||
case type::TextureDimension::k1d:
|
||||
return scalar;
|
||||
case ast::TextureDimension::k2d:
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2dArray:
|
||||
return ty.vec(scalar, 2);
|
||||
case ast::TextureDimension::k3d:
|
||||
case ast::TextureDimension::kCube:
|
||||
case ast::TextureDimension::kCubeArray:
|
||||
case type::TextureDimension::k3d:
|
||||
case type::TextureDimension::kCube:
|
||||
case type::TextureDimension::kCubeArray:
|
||||
return ty.vec(scalar, 3);
|
||||
default:
|
||||
[=]() { FAIL() << "Unsupported texture dimension: " << dim; }();
|
||||
|
@ -2169,7 +2170,7 @@ TEST_P(ResolverBuiltinTest_SampledTextureOperation, TextureLoadSampled) {
|
|||
|
||||
add_call_param("texture", texture_type, &call_params);
|
||||
add_call_param("coords", coords_type, &call_params);
|
||||
if (dim == ast::TextureDimension::k2dArray) {
|
||||
if (dim == type::TextureDimension::k2dArray) {
|
||||
add_call_param("array_index", ty.i32(), &call_params);
|
||||
}
|
||||
add_call_param("level", ty.i32(), &call_params);
|
||||
|
@ -2193,10 +2194,10 @@ TEST_P(ResolverBuiltinTest_SampledTextureOperation, TextureLoadSampled) {
|
|||
|
||||
INSTANTIATE_TEST_SUITE_P(ResolverTest,
|
||||
ResolverBuiltinTest_SampledTextureOperation,
|
||||
testing::Values(TextureTestParams{ast::TextureDimension::k1d},
|
||||
TextureTestParams{ast::TextureDimension::k2d},
|
||||
TextureTestParams{ast::TextureDimension::k2dArray},
|
||||
TextureTestParams{ast::TextureDimension::k3d}));
|
||||
testing::Values(TextureTestParams{type::TextureDimension::k1d},
|
||||
TextureTestParams{type::TextureDimension::k2d},
|
||||
TextureTestParams{type::TextureDimension::k2dArray},
|
||||
TextureTestParams{type::TextureDimension::k3d}));
|
||||
|
||||
using ResolverBuiltinTest_Texture = ResolverTestWithParam<ast::builtin::test::TextureOverloadCase>;
|
||||
|
||||
|
@ -2469,20 +2470,20 @@ TEST_P(ResolverBuiltinTest_Texture, Call) {
|
|||
switch (param.texture_dimension) {
|
||||
default:
|
||||
FAIL() << "invalid texture dimensions: " << param.texture_dimension;
|
||||
case ast::TextureDimension::k1d:
|
||||
case type::TextureDimension::k1d:
|
||||
EXPECT_TRUE(TypeOf(call)->Is<type::U32>());
|
||||
break;
|
||||
case ast::TextureDimension::k2d:
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case ast::TextureDimension::kCube:
|
||||
case ast::TextureDimension::kCubeArray: {
|
||||
case type::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::kCube:
|
||||
case type::TextureDimension::kCubeArray: {
|
||||
auto* vec = As<type::Vector>(TypeOf(call));
|
||||
ASSERT_NE(vec, nullptr);
|
||||
EXPECT_EQ(vec->Width(), 2u);
|
||||
EXPECT_TRUE(vec->type()->Is<type::U32>());
|
||||
break;
|
||||
}
|
||||
case ast::TextureDimension::k3d: {
|
||||
case type::TextureDimension::k3d: {
|
||||
auto* vec = As<type::Vector>(TypeOf(call));
|
||||
ASSERT_NE(vec, nullptr);
|
||||
EXPECT_EQ(vec->Width(), 3u);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "gmock/gmock.h"
|
||||
#include "src/tint/resolver/dependency_graph.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
|
@ -493,12 +494,12 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
|
|||
}
|
||||
case SymbolUseKind::GlobalVarSampledTexElemType: {
|
||||
auto* node = b.ty.type_name(source, symbol);
|
||||
b.GlobalVar(b.Sym(), b.ty.sampled_texture(ast::TextureDimension::k2d, node));
|
||||
b.GlobalVar(b.Sym(), b.ty.sampled_texture(type::TextureDimension::k2d, node));
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::GlobalVarMultisampledTexElemType: {
|
||||
auto* node = b.ty.type_name(source, symbol);
|
||||
b.GlobalVar(b.Sym(), b.ty.multisampled_texture(ast::TextureDimension::k2d, node));
|
||||
b.GlobalVar(b.Sym(), b.ty.multisampled_texture(type::TextureDimension::k2d, node));
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::GlobalVarValue: {
|
||||
|
@ -1290,12 +1291,12 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
|
|||
GlobalVar(Sym(), ty.vec3(T));
|
||||
GlobalVar(Sym(), ty.mat3x2(T));
|
||||
GlobalVar(Sym(), ty.pointer(T, ast::AddressSpace::kPrivate));
|
||||
GlobalVar(Sym(), ty.sampled_texture(ast::TextureDimension::k2d, T));
|
||||
GlobalVar(Sym(), ty.depth_texture(ast::TextureDimension::k2d));
|
||||
GlobalVar(Sym(), ty.depth_multisampled_texture(ast::TextureDimension::k2d));
|
||||
GlobalVar(Sym(), ty.sampled_texture(type::TextureDimension::k2d, T));
|
||||
GlobalVar(Sym(), ty.depth_texture(type::TextureDimension::k2d));
|
||||
GlobalVar(Sym(), ty.depth_multisampled_texture(type::TextureDimension::k2d));
|
||||
GlobalVar(Sym(), ty.external_texture());
|
||||
GlobalVar(Sym(), ty.multisampled_texture(ast::TextureDimension::k2d, T));
|
||||
GlobalVar(Sym(), ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float,
|
||||
GlobalVar(Sym(), ty.multisampled_texture(type::TextureDimension::k2d, T));
|
||||
GlobalVar(Sym(), ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float,
|
||||
ast::Access::kRead)); //
|
||||
GlobalVar(Sym(), ty.sampler(ast::SamplerKind::kSampler));
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "src/tint/type/multisampled_texture.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/hash.h"
|
||||
#include "src/tint/utils/hashmap.h"
|
||||
#include "src/tint/utils/math.h"
|
||||
|
@ -605,7 +606,7 @@ const type::Sampler* build_sampler_comparison(MatchState& state) {
|
|||
|
||||
bool match_texture(MatchState&,
|
||||
const type::Type* ty,
|
||||
ast::TextureDimension dim,
|
||||
type::TextureDimension dim,
|
||||
const type::Type*& T) {
|
||||
if (ty->Is<Any>()) {
|
||||
T = ty;
|
||||
|
@ -632,17 +633,17 @@ bool match_texture(MatchState&,
|
|||
return state.builder.create<type::SampledTexture>(dim, T); \
|
||||
}
|
||||
|
||||
DECLARE_SAMPLED_TEXTURE(1d, ast::TextureDimension::k1d)
|
||||
DECLARE_SAMPLED_TEXTURE(2d, ast::TextureDimension::k2d)
|
||||
DECLARE_SAMPLED_TEXTURE(2d_array, ast::TextureDimension::k2dArray)
|
||||
DECLARE_SAMPLED_TEXTURE(3d, ast::TextureDimension::k3d)
|
||||
DECLARE_SAMPLED_TEXTURE(cube, ast::TextureDimension::kCube)
|
||||
DECLARE_SAMPLED_TEXTURE(cube_array, ast::TextureDimension::kCubeArray)
|
||||
DECLARE_SAMPLED_TEXTURE(1d, type::TextureDimension::k1d)
|
||||
DECLARE_SAMPLED_TEXTURE(2d, type::TextureDimension::k2d)
|
||||
DECLARE_SAMPLED_TEXTURE(2d_array, type::TextureDimension::k2dArray)
|
||||
DECLARE_SAMPLED_TEXTURE(3d, type::TextureDimension::k3d)
|
||||
DECLARE_SAMPLED_TEXTURE(cube, type::TextureDimension::kCube)
|
||||
DECLARE_SAMPLED_TEXTURE(cube_array, type::TextureDimension::kCubeArray)
|
||||
#undef DECLARE_SAMPLED_TEXTURE
|
||||
|
||||
bool match_texture_multisampled(MatchState&,
|
||||
const type::Type* ty,
|
||||
ast::TextureDimension dim,
|
||||
type::TextureDimension dim,
|
||||
const type::Type*& T) {
|
||||
if (ty->Is<Any>()) {
|
||||
T = ty;
|
||||
|
@ -667,10 +668,10 @@ bool match_texture_multisampled(MatchState&,
|
|||
return state.builder.create<type::MultisampledTexture>(dim, T); \
|
||||
}
|
||||
|
||||
DECLARE_MULTISAMPLED_TEXTURE(2d, ast::TextureDimension::k2d)
|
||||
DECLARE_MULTISAMPLED_TEXTURE(2d, type::TextureDimension::k2d)
|
||||
#undef DECLARE_MULTISAMPLED_TEXTURE
|
||||
|
||||
bool match_texture_depth(MatchState&, const type::Type* ty, ast::TextureDimension dim) {
|
||||
bool match_texture_depth(MatchState&, const type::Type* ty, type::TextureDimension dim) {
|
||||
if (ty->Is<Any>()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -685,10 +686,10 @@ bool match_texture_depth(MatchState&, const type::Type* ty, ast::TextureDimensio
|
|||
return state.builder.create<type::DepthTexture>(dim); \
|
||||
}
|
||||
|
||||
DECLARE_DEPTH_TEXTURE(2d, ast::TextureDimension::k2d)
|
||||
DECLARE_DEPTH_TEXTURE(2d_array, ast::TextureDimension::k2dArray)
|
||||
DECLARE_DEPTH_TEXTURE(cube, ast::TextureDimension::kCube)
|
||||
DECLARE_DEPTH_TEXTURE(cube_array, ast::TextureDimension::kCubeArray)
|
||||
DECLARE_DEPTH_TEXTURE(2d, type::TextureDimension::k2d)
|
||||
DECLARE_DEPTH_TEXTURE(2d_array, type::TextureDimension::k2dArray)
|
||||
DECLARE_DEPTH_TEXTURE(cube, type::TextureDimension::kCube)
|
||||
DECLARE_DEPTH_TEXTURE(cube_array, type::TextureDimension::kCubeArray)
|
||||
#undef DECLARE_DEPTH_TEXTURE
|
||||
|
||||
bool match_texture_depth_multisampled_2d(MatchState&, const type::Type* ty) {
|
||||
|
@ -696,17 +697,17 @@ bool match_texture_depth_multisampled_2d(MatchState&, const type::Type* ty) {
|
|||
return true;
|
||||
}
|
||||
return ty->Is([&](const type::DepthMultisampledTexture* t) {
|
||||
return t->dim() == ast::TextureDimension::k2d;
|
||||
return t->dim() == type::TextureDimension::k2d;
|
||||
});
|
||||
}
|
||||
|
||||
type::DepthMultisampledTexture* build_texture_depth_multisampled_2d(MatchState& state) {
|
||||
return state.builder.create<type::DepthMultisampledTexture>(ast::TextureDimension::k2d);
|
||||
return state.builder.create<type::DepthMultisampledTexture>(type::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
bool match_texture_storage(MatchState&,
|
||||
const type::Type* ty,
|
||||
ast::TextureDimension dim,
|
||||
type::TextureDimension dim,
|
||||
Number& F,
|
||||
Number& A) {
|
||||
if (ty->Is<Any>()) {
|
||||
|
@ -737,10 +738,10 @@ bool match_texture_storage(MatchState&,
|
|||
return state.builder.create<type::StorageTexture>(dim, format, access, T); \
|
||||
}
|
||||
|
||||
DECLARE_STORAGE_TEXTURE(1d, ast::TextureDimension::k1d)
|
||||
DECLARE_STORAGE_TEXTURE(2d, ast::TextureDimension::k2d)
|
||||
DECLARE_STORAGE_TEXTURE(2d_array, ast::TextureDimension::k2dArray)
|
||||
DECLARE_STORAGE_TEXTURE(3d, ast::TextureDimension::k3d)
|
||||
DECLARE_STORAGE_TEXTURE(1d, type::TextureDimension::k1d)
|
||||
DECLARE_STORAGE_TEXTURE(2d, type::TextureDimension::k2d)
|
||||
DECLARE_STORAGE_TEXTURE(2d_array, type::TextureDimension::k2dArray)
|
||||
DECLARE_STORAGE_TEXTURE(3d, type::TextureDimension::k3d)
|
||||
#undef DECLARE_STORAGE_TEXTURE
|
||||
|
||||
bool match_texture_external(MatchState&, const type::Type* ty) {
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/test_helper.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
@ -97,7 +98,7 @@ TEST_F(IntrinsicTableTest, MatchI32) {
|
|||
auto* f32 = create<type::F32>();
|
||||
auto* i32 = create<type::I32>();
|
||||
auto* vec4_f32 = create<type::Vector>(f32, 4u);
|
||||
auto* tex = create<type::SampledTexture>(ast::TextureDimension::k1d, f32);
|
||||
auto* tex = create<type::SampledTexture>(type::TextureDimension::k1d, f32);
|
||||
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, i32, i32},
|
||||
sem::EvaluationStage::kConstant, Source{});
|
||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||
|
@ -115,7 +116,7 @@ TEST_F(IntrinsicTableTest, MatchI32) {
|
|||
|
||||
TEST_F(IntrinsicTableTest, MismatchI32) {
|
||||
auto* f32 = create<type::F32>();
|
||||
auto* tex = create<type::SampledTexture>(ast::TextureDimension::k1d, f32);
|
||||
auto* tex = create<type::SampledTexture>(type::TextureDimension::k1d, f32);
|
||||
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, f32},
|
||||
sem::EvaluationStage::kConstant, Source{});
|
||||
ASSERT_EQ(result.sem, nullptr);
|
||||
|
@ -280,7 +281,7 @@ TEST_F(IntrinsicTableTest, MatchSampler) {
|
|||
auto* f32 = create<type::F32>();
|
||||
auto* vec2_f32 = create<type::Vector>(f32, 2u);
|
||||
auto* vec4_f32 = create<type::Vector>(f32, 4u);
|
||||
auto* tex = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
|
||||
auto* tex = create<type::SampledTexture>(type::TextureDimension::k2d, f32);
|
||||
auto* sampler = create<type::Sampler>(ast::SamplerKind::kSampler);
|
||||
auto result = table->Lookup(BuiltinType::kTextureSample, utils::Vector{tex, sampler, vec2_f32},
|
||||
sem::EvaluationStage::kConstant, Source{});
|
||||
|
@ -300,7 +301,7 @@ TEST_F(IntrinsicTableTest, MatchSampler) {
|
|||
TEST_F(IntrinsicTableTest, MismatchSampler) {
|
||||
auto* f32 = create<type::F32>();
|
||||
auto* vec2_f32 = create<type::Vector>(f32, 2u);
|
||||
auto* tex = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
|
||||
auto* tex = create<type::SampledTexture>(type::TextureDimension::k2d, f32);
|
||||
auto result = table->Lookup(BuiltinType::kTextureSample, utils::Vector{tex, f32, vec2_f32},
|
||||
sem::EvaluationStage::kConstant, Source{});
|
||||
ASSERT_EQ(result.sem, nullptr);
|
||||
|
@ -312,7 +313,7 @@ TEST_F(IntrinsicTableTest, MatchSampledTexture) {
|
|||
auto* f32 = create<type::F32>();
|
||||
auto* vec2_i32 = create<type::Vector>(i32, 2u);
|
||||
auto* vec4_f32 = create<type::Vector>(f32, 4u);
|
||||
auto* tex = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
|
||||
auto* tex = create<type::SampledTexture>(type::TextureDimension::k2d, f32);
|
||||
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32},
|
||||
sem::EvaluationStage::kConstant, Source{});
|
||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||
|
@ -333,7 +334,7 @@ TEST_F(IntrinsicTableTest, MatchMultisampledTexture) {
|
|||
auto* f32 = create<type::F32>();
|
||||
auto* vec2_i32 = create<type::Vector>(i32, 2u);
|
||||
auto* vec4_f32 = create<type::Vector>(f32, 4u);
|
||||
auto* tex = create<type::MultisampledTexture>(ast::TextureDimension::k2d, f32);
|
||||
auto* tex = create<type::MultisampledTexture>(type::TextureDimension::k2d, f32);
|
||||
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32},
|
||||
sem::EvaluationStage::kConstant, Source{});
|
||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||
|
@ -353,7 +354,7 @@ TEST_F(IntrinsicTableTest, MatchDepthTexture) {
|
|||
auto* f32 = create<type::F32>();
|
||||
auto* i32 = create<type::I32>();
|
||||
auto* vec2_i32 = create<type::Vector>(i32, 2u);
|
||||
auto* tex = create<type::DepthTexture>(ast::TextureDimension::k2d);
|
||||
auto* tex = create<type::DepthTexture>(type::TextureDimension::k2d);
|
||||
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32},
|
||||
sem::EvaluationStage::kConstant, Source{});
|
||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||
|
@ -373,7 +374,7 @@ TEST_F(IntrinsicTableTest, MatchDepthMultisampledTexture) {
|
|||
auto* f32 = create<type::F32>();
|
||||
auto* i32 = create<type::I32>();
|
||||
auto* vec2_i32 = create<type::Vector>(i32, 2u);
|
||||
auto* tex = create<type::DepthMultisampledTexture>(ast::TextureDimension::k2d);
|
||||
auto* tex = create<type::DepthMultisampledTexture>(type::TextureDimension::k2d);
|
||||
auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32},
|
||||
sem::EvaluationStage::kConstant, Source{});
|
||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||
|
@ -415,7 +416,7 @@ TEST_F(IntrinsicTableTest, MatchWOStorageTexture) {
|
|||
auto* vec4_f32 = create<type::Vector>(f32, 4u);
|
||||
auto* subtype = type::StorageTexture::SubtypeFor(ast::TexelFormat::kR32Float, Types());
|
||||
auto* tex = create<type::StorageTexture>(
|
||||
ast::TextureDimension::k2d, ast::TexelFormat::kR32Float, ast::Access::kWrite, subtype);
|
||||
type::TextureDimension::k2d, ast::TexelFormat::kR32Float, ast::Access::kWrite, subtype);
|
||||
|
||||
auto result = table->Lookup(BuiltinType::kTextureStore, utils::Vector{tex, vec2_i32, vec4_f32},
|
||||
sem::EvaluationStage::kConstant, Source{});
|
||||
|
@ -629,7 +630,7 @@ TEST_F(IntrinsicTableTest, OverloadOrderByNumberOfParameters) {
|
|||
}
|
||||
|
||||
TEST_F(IntrinsicTableTest, OverloadOrderByMatchingParameter) {
|
||||
auto* tex = create<type::DepthTexture>(ast::TextureDimension::k2d);
|
||||
auto* tex = create<type::DepthTexture>(type::TextureDimension::k2d);
|
||||
auto* bool_ = create<type::Bool>();
|
||||
table->Lookup(BuiltinType::kTextureDimensions, utils::Vector{tex, bool_},
|
||||
sem::EvaluationStage::kConstant, Source{});
|
||||
|
|
|
@ -12,14 +12,13 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/tint/sem/load.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/resolver/resolver.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/sem/test_helper.h"
|
||||
|
||||
#include "src/tint/sem/load.h"
|
||||
#include "src/tint/type/reference.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
|
@ -220,12 +219,12 @@ TEST_F(ResolverLoadTest, FunctionArg_Handles) {
|
|||
// return textureSampleLevel(tp, sp, vec2(), 0);
|
||||
// }
|
||||
// f(t, s);
|
||||
GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
|
||||
GlobalVar("t", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()),
|
||||
utils::Vector{Group(0_a), Binding(0_a)});
|
||||
GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), utils::Vector{Group(0_a), Binding(1_a)});
|
||||
Func("f",
|
||||
utils::Vector{
|
||||
Param("tp", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32())),
|
||||
Param("tp", ty.sampled_texture(type::TextureDimension::k2d, ty.f32())),
|
||||
Param("sp", ty.sampler(ast::SamplerKind::kSampler)),
|
||||
},
|
||||
ty.vec4<f32>(),
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/ast/bitcast_expression.h"
|
||||
#include "src/tint/resolver/resolver.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/type/reference.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
|
@ -54,7 +54,7 @@ TEST_F(ResolverPtrRefValidationTest, AddressOfLet) {
|
|||
TEST_F(ResolverPtrRefValidationTest, AddressOfHandle) {
|
||||
// @group(0) @binding(0) var t: texture_3d<f32>;
|
||||
// &t
|
||||
GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k3d, ty.f32()), Group(0_a),
|
||||
GlobalVar("t", ty.sampled_texture(type::TextureDimension::k3d, ty.f32()), Group(0_a),
|
||||
Binding(0_a));
|
||||
auto* expr = AddressOf(Expr(Source{{12, 34}}, "t"));
|
||||
WrapInFunction(expr);
|
||||
|
@ -94,7 +94,7 @@ TEST_F(ResolverPtrRefValidationTest, AddressOfVectorComponent_IndexAccessor) {
|
|||
TEST_F(ResolverPtrRefValidationTest, IndirectOfAddressOfHandle) {
|
||||
// @group(0) @binding(0) var t: texture_3d<f32>;
|
||||
// *&t
|
||||
GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k3d, ty.f32()), Group(0_a),
|
||||
GlobalVar("t", ty.sampled_texture(type::TextureDimension::k3d, ty.f32()), Group(0_a),
|
||||
Binding(0_a));
|
||||
auto* expr = Deref(AddressOf(Expr(Source{{12, 34}}, "t")));
|
||||
WrapInFunction(expr);
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "src/tint/sem/variable.h"
|
||||
#include "src/tint/type/reference.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
using ::testing::ElementsAre;
|
||||
using ::testing::HasSubstr;
|
||||
|
@ -1886,7 +1887,7 @@ TEST_F(ResolverTest, AddressSpace_SetForSampler) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, AddressSpace_SetForTexture) {
|
||||
auto* t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
auto* t = ty.sampled_texture(type::TextureDimension::k1d, ty.f32());
|
||||
auto* var = GlobalVar("var", t, Binding(0_a), Group(0_a));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
@ -2123,7 +2124,7 @@ TEST_F(ResolverTest, UnaryOp_Negation) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, TextureSampler_TextureSample) {
|
||||
GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1_a),
|
||||
GlobalVar("t", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Group(1_a),
|
||||
Binding(1_a));
|
||||
GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(1_a), Binding(2_a));
|
||||
|
||||
|
@ -2141,7 +2142,7 @@ TEST_F(ResolverTest, TextureSampler_TextureSample) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, TextureSampler_TextureSampleInFunction) {
|
||||
GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1_a),
|
||||
GlobalVar("t", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Group(1_a),
|
||||
Binding(1_a));
|
||||
GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(1_a), Binding(2_a));
|
||||
|
||||
|
@ -2167,7 +2168,7 @@ TEST_F(ResolverTest, TextureSampler_TextureSampleInFunction) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, TextureSampler_TextureSampleFunctionDiamondSameVariables) {
|
||||
GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1_a),
|
||||
GlobalVar("t", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Group(1_a),
|
||||
Binding(1_a));
|
||||
GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(1_a), Binding(2_a));
|
||||
|
||||
|
@ -2202,9 +2203,9 @@ TEST_F(ResolverTest, TextureSampler_TextureSampleFunctionDiamondSameVariables) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, TextureSampler_TextureSampleFunctionDiamondDifferentVariables) {
|
||||
GlobalVar("t1", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1_a),
|
||||
GlobalVar("t1", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Group(1_a),
|
||||
Binding(1_a));
|
||||
GlobalVar("t2", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1_a),
|
||||
GlobalVar("t2", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Group(1_a),
|
||||
Binding(2_a));
|
||||
GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(1_a), Binding(3_a));
|
||||
|
||||
|
@ -2241,7 +2242,7 @@ TEST_F(ResolverTest, TextureSampler_TextureSampleFunctionDiamondDifferentVariabl
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, TextureSampler_TextureDimensions) {
|
||||
GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1_a),
|
||||
GlobalVar("t", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Group(1_a),
|
||||
Binding(2_a));
|
||||
|
||||
auto* call = Call("textureDimensions", "t");
|
||||
|
@ -2270,7 +2271,7 @@ TEST_F(ResolverTest, TextureSampler_Bug1715) { // crbug.com/tint/1715
|
|||
// return textureSampleLevel(*tl, *sl, c, 0.0);
|
||||
// }
|
||||
GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(0_a), Binding(0_a));
|
||||
GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(0_a),
|
||||
GlobalVar("t", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Group(0_a),
|
||||
Binding(1_a));
|
||||
GlobalVar("c", ty.vec2<f32>(), ast::AddressSpace::kUniform, Group(0_a), Binding(2_a));
|
||||
|
||||
|
@ -2289,7 +2290,7 @@ TEST_F(ResolverTest, TextureSampler_Bug1715) { // crbug.com/tint/1715
|
|||
utils::Vector{
|
||||
Param("sl", ty.pointer(ty.sampler(ast::SamplerKind::kSampler),
|
||||
ast::AddressSpace::kFunction)),
|
||||
Param("tl", ty.pointer(ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
|
||||
Param("tl", ty.pointer(ty.sampled_texture(type::TextureDimension::k2d, ty.f32()),
|
||||
ast::AddressSpace::kFunction)),
|
||||
},
|
||||
ty.vec4<f32>(),
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/sem/index_accessor_expression.h"
|
||||
#include "src/tint/sem/member_accessor_expression.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
|
@ -70,7 +71,7 @@ TEST_F(ResolverRootIdentifierTest, GlobalUniformVar) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverRootIdentifierTest, GlobalTextureVar) {
|
||||
auto* a = GlobalVar("a", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
|
||||
auto* a = GlobalVar("a", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()),
|
||||
ast::AddressSpace::kNone, Group(0_a), Binding(0_a));
|
||||
auto* expr = Expr(a);
|
||||
WrapInFunction(Call("textureDimensions", expr));
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "src/tint/sem/expression.h"
|
||||
#include "src/tint/sem/index_accessor_expression.h"
|
||||
#include "src/tint/sem/member_accessor_expression.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/vector.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
@ -180,16 +181,16 @@ TEST_P(SideEffectsBuiltinTest, Test) {
|
|||
GlobalVar("a", ty.atomic(ty.i32()), ast::AddressSpace::kStorage, ast::Access::kReadWrite,
|
||||
Group(0_a), Binding(AInt(next_binding++)));
|
||||
if (c.pipeline_stage != ast::PipelineStage::kCompute) {
|
||||
GlobalVar("t2d", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(0_a),
|
||||
GlobalVar("t2d", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()), Group(0_a),
|
||||
Binding(AInt(next_binding++)));
|
||||
GlobalVar("tdepth2d", ty.depth_texture(ast::TextureDimension::k2d), Group(0_a),
|
||||
GlobalVar("tdepth2d", ty.depth_texture(type::TextureDimension::k2d), Group(0_a),
|
||||
Binding(AInt(next_binding++)));
|
||||
GlobalVar("t2d_arr", ty.sampled_texture(ast::TextureDimension::k2dArray, ty.f32()),
|
||||
GlobalVar("t2d_arr", ty.sampled_texture(type::TextureDimension::k2dArray, ty.f32()),
|
||||
Group(0_a), Binding(AInt(next_binding++)));
|
||||
GlobalVar("t2d_multi", ty.multisampled_texture(ast::TextureDimension::k2d, ty.f32()),
|
||||
GlobalVar("t2d_multi", ty.multisampled_texture(type::TextureDimension::k2d, ty.f32()),
|
||||
Group(0_a), Binding(AInt(next_binding++)));
|
||||
GlobalVar("tstorage2d",
|
||||
ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float,
|
||||
ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float,
|
||||
ast::Access::kWrite),
|
||||
Group(0_a), Binding(AInt(next_binding++)));
|
||||
GlobalVar("s2d", ty.sampler(ast::SamplerKind::kSampler), Group(0_a),
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/type/multisampled_texture.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
|
@ -856,7 +857,7 @@ TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsLast_Pass) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTypeValidationTest, ArrayOfNonStorableType) {
|
||||
auto* tex_ty = ty.sampled_texture(Source{{12, 34}}, ast::TextureDimension::k2d, ty.f32());
|
||||
auto* tex_ty = ty.sampled_texture(Source{{12, 34}}, type::TextureDimension::k2d, ty.f32());
|
||||
GlobalVar("arr", ty.array(tex_ty, 4_i), ast::AddressSpace::kPrivate);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -964,7 +965,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest, CanonicalTest, testing::Val
|
|||
|
||||
namespace SampledTextureTests {
|
||||
struct DimensionParams {
|
||||
ast::TextureDimension dim;
|
||||
type::TextureDimension dim;
|
||||
bool is_valid;
|
||||
};
|
||||
|
||||
|
@ -979,12 +980,12 @@ TEST_P(SampledTextureDimensionTest, All) {
|
|||
INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,
|
||||
SampledTextureDimensionTest,
|
||||
testing::Values( //
|
||||
DimensionParams{ast::TextureDimension::k1d, true},
|
||||
DimensionParams{ast::TextureDimension::k2d, true},
|
||||
DimensionParams{ast::TextureDimension::k2dArray, true},
|
||||
DimensionParams{ast::TextureDimension::k3d, true},
|
||||
DimensionParams{ast::TextureDimension::kCube, true},
|
||||
DimensionParams{ast::TextureDimension::kCubeArray, true}));
|
||||
DimensionParams{type::TextureDimension::k1d, true},
|
||||
DimensionParams{type::TextureDimension::k2d, true},
|
||||
DimensionParams{type::TextureDimension::k2dArray, true},
|
||||
DimensionParams{type::TextureDimension::k3d, true},
|
||||
DimensionParams{type::TextureDimension::kCube, true},
|
||||
DimensionParams{type::TextureDimension::kCubeArray, true}));
|
||||
|
||||
using MultisampledTextureDimensionTest = ResolverTestWithParam<DimensionParams>;
|
||||
TEST_P(MultisampledTextureDimensionTest, All) {
|
||||
|
@ -1002,12 +1003,12 @@ TEST_P(MultisampledTextureDimensionTest, All) {
|
|||
INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,
|
||||
MultisampledTextureDimensionTest,
|
||||
testing::Values( //
|
||||
DimensionParams{ast::TextureDimension::k1d, false},
|
||||
DimensionParams{ast::TextureDimension::k2d, true},
|
||||
DimensionParams{ast::TextureDimension::k2dArray, false},
|
||||
DimensionParams{ast::TextureDimension::k3d, false},
|
||||
DimensionParams{ast::TextureDimension::kCube, false},
|
||||
DimensionParams{ast::TextureDimension::kCubeArray, false}));
|
||||
DimensionParams{type::TextureDimension::k1d, false},
|
||||
DimensionParams{type::TextureDimension::k2d, true},
|
||||
DimensionParams{type::TextureDimension::k2dArray, false},
|
||||
DimensionParams{type::TextureDimension::k3d, false},
|
||||
DimensionParams{type::TextureDimension::kCube, false},
|
||||
DimensionParams{type::TextureDimension::kCubeArray, false}));
|
||||
|
||||
struct TypeParams {
|
||||
builder::ast_type_func_ptr type_func;
|
||||
|
@ -1047,7 +1048,7 @@ TEST_P(SampledTextureTypeTest, All) {
|
|||
Enable(ast::Extension::kF16);
|
||||
GlobalVar(
|
||||
"a",
|
||||
ty.sampled_texture(Source{{12, 34}}, ast::TextureDimension::k2d, params.type_func(*this)),
|
||||
ty.sampled_texture(Source{{12, 34}}, type::TextureDimension::k2d, params.type_func(*this)),
|
||||
Group(0_a), Binding(0_a));
|
||||
|
||||
if (params.is_valid) {
|
||||
|
@ -1066,7 +1067,7 @@ TEST_P(MultisampledTextureTypeTest, All) {
|
|||
auto& params = GetParam();
|
||||
Enable(ast::Extension::kF16);
|
||||
GlobalVar("a",
|
||||
ty.multisampled_texture(Source{{12, 34}}, ast::TextureDimension::k2d,
|
||||
ty.multisampled_texture(Source{{12, 34}}, type::TextureDimension::k2d,
|
||||
params.type_func(*this)),
|
||||
Group(0_a), Binding(0_a));
|
||||
|
||||
|
@ -1086,17 +1087,17 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,
|
|||
|
||||
namespace StorageTextureTests {
|
||||
struct DimensionParams {
|
||||
ast::TextureDimension dim;
|
||||
type::TextureDimension dim;
|
||||
bool is_valid;
|
||||
};
|
||||
|
||||
static constexpr DimensionParams Dimension_cases[] = {
|
||||
DimensionParams{ast::TextureDimension::k1d, true},
|
||||
DimensionParams{ast::TextureDimension::k2d, true},
|
||||
DimensionParams{ast::TextureDimension::k2dArray, true},
|
||||
DimensionParams{ast::TextureDimension::k3d, true},
|
||||
DimensionParams{ast::TextureDimension::kCube, false},
|
||||
DimensionParams{ast::TextureDimension::kCubeArray, false}};
|
||||
DimensionParams{type::TextureDimension::k1d, true},
|
||||
DimensionParams{type::TextureDimension::k2d, true},
|
||||
DimensionParams{type::TextureDimension::k2dArray, true},
|
||||
DimensionParams{type::TextureDimension::k3d, true},
|
||||
DimensionParams{type::TextureDimension::kCube, false},
|
||||
DimensionParams{type::TextureDimension::kCubeArray, false}};
|
||||
|
||||
using StorageTextureDimensionTest = ResolverTestWithParam<DimensionParams>;
|
||||
TEST_P(StorageTextureDimensionTest, All) {
|
||||
|
@ -1156,18 +1157,20 @@ TEST_P(StorageTextureFormatTest, All) {
|
|||
// @group(0) @binding(3)
|
||||
// var d : texture_storage_3d<*, write>;
|
||||
|
||||
auto* st_a = ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d, params.format,
|
||||
auto* st_a = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d, params.format,
|
||||
ast::Access::kWrite);
|
||||
GlobalVar("a", st_a, Group(0_a), Binding(0_a));
|
||||
|
||||
auto* st_b = ty.storage_texture(ast::TextureDimension::k2d, params.format, ast::Access::kWrite);
|
||||
auto* st_b =
|
||||
ty.storage_texture(type::TextureDimension::k2d, params.format, ast::Access::kWrite);
|
||||
GlobalVar("b", st_b, Group(0_a), Binding(1_a));
|
||||
|
||||
auto* st_c =
|
||||
ty.storage_texture(ast::TextureDimension::k2dArray, params.format, ast::Access::kWrite);
|
||||
ty.storage_texture(type::TextureDimension::k2dArray, params.format, ast::Access::kWrite);
|
||||
GlobalVar("c", st_c, Group(0_a), Binding(2_a));
|
||||
|
||||
auto* st_d = ty.storage_texture(ast::TextureDimension::k3d, params.format, ast::Access::kWrite);
|
||||
auto* st_d =
|
||||
ty.storage_texture(type::TextureDimension::k3d, params.format, ast::Access::kWrite);
|
||||
GlobalVar("d", st_d, Group(0_a), Binding(3_a));
|
||||
|
||||
if (params.is_valid) {
|
||||
|
@ -1189,7 +1192,7 @@ TEST_F(StorageTextureAccessTest, MissingAccess_Fail) {
|
|||
// @group(0) @binding(0)
|
||||
// var a : texture_storage_1d<ru32int>;
|
||||
|
||||
auto* st = ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d,
|
||||
auto* st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d,
|
||||
ast::TexelFormat::kR32Uint, ast::Access::kUndefined);
|
||||
|
||||
GlobalVar("a", st, Group(0_a), Binding(0_a));
|
||||
|
@ -1202,7 +1205,7 @@ TEST_F(StorageTextureAccessTest, RWAccess_Fail) {
|
|||
// @group(0) @binding(0)
|
||||
// var a : texture_storage_1d<ru32int, read_write>;
|
||||
|
||||
auto* st = ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d,
|
||||
auto* st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d,
|
||||
ast::TexelFormat::kR32Uint, ast::Access::kReadWrite);
|
||||
|
||||
GlobalVar("a", st, Group(0_a), Binding(0_a));
|
||||
|
@ -1216,7 +1219,7 @@ TEST_F(StorageTextureAccessTest, ReadOnlyAccess_Fail) {
|
|||
// @group(0) @binding(0)
|
||||
// var a : texture_storage_1d<ru32int, read>;
|
||||
|
||||
auto* st = ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d,
|
||||
auto* st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d,
|
||||
ast::TexelFormat::kR32Uint, ast::Access::kRead);
|
||||
|
||||
GlobalVar("a", st, Group(0_a), Binding(0_a));
|
||||
|
@ -1230,7 +1233,7 @@ TEST_F(StorageTextureAccessTest, WriteOnlyAccess_Pass) {
|
|||
// @group(0) @binding(0)
|
||||
// var a : texture_storage_1d<ru32int, write>;
|
||||
|
||||
auto* st = ty.storage_texture(ast::TextureDimension::k1d, ast::TexelFormat::kR32Uint,
|
||||
auto* st = ty.storage_texture(type::TextureDimension::k1d, ast::TexelFormat::kR32Uint,
|
||||
ast::Access::kWrite);
|
||||
|
||||
GlobalVar("a", st, Group(0_a), Binding(0_a));
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "src/tint/sem/statement.h"
|
||||
#include "src/tint/sem/variable.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
using ::testing::ElementsAre;
|
||||
using ::testing::HasSubstr;
|
||||
|
@ -345,7 +346,7 @@ TEST_F(ResolverValidationTest, AddressSpace_SamplerExplicitAddressSpace) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverValidationTest, AddressSpace_TextureExplicitAddressSpace) {
|
||||
auto* t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
auto* t = ty.sampled_texture(type::TextureDimension::k1d, ty.f32());
|
||||
GlobalVar(Source{{12, 34}}, "var", t, ast::AddressSpace::kHandle, Binding(0_a), Group(0_a));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve()) << r()->error();
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/sampler.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/defer.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
#include "src/tint/utils/math.h"
|
||||
|
@ -84,12 +85,12 @@
|
|||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
bool IsValidStorageTextureDimension(ast::TextureDimension dim) {
|
||||
bool IsValidStorageTextureDimension(type::TextureDimension dim) {
|
||||
switch (dim) {
|
||||
case ast::TextureDimension::k1d:
|
||||
case ast::TextureDimension::k2d:
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case ast::TextureDimension::k3d:
|
||||
case type::TextureDimension::k1d:
|
||||
case type::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k3d:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -331,7 +332,7 @@ bool Validator::SampledTexture(const type::SampledTexture* t, const Source& sour
|
|||
|
||||
bool Validator::MultisampledTexture(const type::MultisampledTexture* t,
|
||||
const Source& source) const {
|
||||
if (t->dim() != ast::TextureDimension::k2d) {
|
||||
if (t->dim() != type::TextureDimension::k2d) {
|
||||
AddError("only 2d multisampled textures are supported", source);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/resolver/resolver.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/type/reference.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
@ -1044,7 +1044,7 @@ TEST_F(ResolverVariableTest, GlobalVar_AddressSpace) {
|
|||
auto* storage =
|
||||
GlobalVar("sb", ty.Of(buf), ast::AddressSpace::kStorage, Binding(1_a), Group(0_a));
|
||||
auto* handle =
|
||||
GlobalVar("h", ty.depth_texture(ast::TextureDimension::k2d), Binding(2_a), Group(0_a));
|
||||
GlobalVar("h", ty.depth_texture(type::TextureDimension::k2d), Binding(2_a), Group(0_a));
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/resolver/resolver.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
|
@ -123,8 +123,8 @@ TEST_F(ResolverVariableValidationTest, VarTypeNotConstructible) {
|
|||
TEST_F(ResolverVariableValidationTest, LetTypeNotConstructible) {
|
||||
// @group(0) @binding(0) var t1 : texture_2d<f32>;
|
||||
// let t2 : t1;
|
||||
auto* t1 = GlobalVar("t1", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(0_a),
|
||||
Binding(0_a));
|
||||
auto* t1 = GlobalVar("t1", ty.sampled_texture(type::TextureDimension::k2d, ty.f32()),
|
||||
Group(0_a), Binding(0_a));
|
||||
auto* t2 = Let(Source{{56, 78}}, "t2", Expr(t1));
|
||||
WrapInFunction(t2);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/sem/builtin.h"
|
||||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
@ -638,7 +639,7 @@ struct BuiltinPolyfill::State {
|
|||
};
|
||||
b.Func(name,
|
||||
utils::Vector{
|
||||
b.Param("t", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("t", b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("s", b.ty.sampler(ast::SamplerKind::kSampler)),
|
||||
b.Param("coord", b.ty.vec2<f32>()),
|
||||
},
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/sem/function.h"
|
||||
#include "src/tint/sem/variable.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::MultiplanarExternalTexture);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::MultiplanarExternalTexture::NewBindingPoints);
|
||||
|
@ -140,7 +141,7 @@ struct MultiplanarExternalTexture::State {
|
|||
auto& syms = new_binding_symbols[sem_var];
|
||||
syms.plane_0 = ctx.Clone(global->symbol);
|
||||
syms.plane_1 = b.Symbols().New("ext_tex_plane_1");
|
||||
b.GlobalVar(syms.plane_1, b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32()),
|
||||
b.GlobalVar(syms.plane_1, b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32()),
|
||||
b.Group(AInt(bps.plane_1.group)), b.Binding(AInt(bps.plane_1.binding)));
|
||||
syms.params = b.Symbols().New("ext_tex_params");
|
||||
b.GlobalVar(syms.params, b.ty.type_name("ExternalTextureParams"),
|
||||
|
@ -152,7 +153,7 @@ struct MultiplanarExternalTexture::State {
|
|||
const ast::Expression* cloned_initializer = ctx.Clone(global->initializer);
|
||||
|
||||
auto* replacement =
|
||||
b.Var(syms.plane_0, b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32()),
|
||||
b.Var(syms.plane_0, b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32()),
|
||||
cloned_initializer, cloned_attributes);
|
||||
ctx.Replace(global, replacement);
|
||||
}
|
||||
|
@ -178,7 +179,7 @@ struct MultiplanarExternalTexture::State {
|
|||
syms.plane_1 = b.Symbols().New("ext_tex_plane_1");
|
||||
syms.params = b.Symbols().New("ext_tex_params");
|
||||
auto tex2d_f32 = [&] {
|
||||
return b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32());
|
||||
return b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32());
|
||||
};
|
||||
ctx.Replace(param, b.Param(syms.plane_0, tex2d_f32()));
|
||||
ctx.InsertAfter(fn->params, param, b.Param(syms.plane_1, tex2d_f32()));
|
||||
|
@ -419,17 +420,18 @@ struct MultiplanarExternalTexture::State {
|
|||
texture_sample_external_sym = b.Symbols().New("textureSampleExternal");
|
||||
|
||||
// Emit the textureSampleExternal function.
|
||||
b.Func(
|
||||
texture_sample_external_sym,
|
||||
utils::Vector{
|
||||
b.Param("plane0", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("plane1", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("smp", b.ty.sampler(ast::SamplerKind::kSampler)),
|
||||
b.Param("coord", b.ty.vec2(b.ty.f32())),
|
||||
b.Param("params", b.ty.type_name(params_struct_sym)),
|
||||
},
|
||||
b.ty.vec4(b.ty.f32()),
|
||||
buildTextureBuiltinBody(sem::BuiltinType::kTextureSampleBaseClampToEdge));
|
||||
b.Func(texture_sample_external_sym,
|
||||
utils::Vector{
|
||||
b.Param("plane0",
|
||||
b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("plane1",
|
||||
b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("smp", b.ty.sampler(ast::SamplerKind::kSampler)),
|
||||
b.Param("coord", b.ty.vec2(b.ty.f32())),
|
||||
b.Param("params", b.ty.type_name(params_struct_sym)),
|
||||
},
|
||||
b.ty.vec4(b.ty.f32()),
|
||||
buildTextureBuiltinBody(sem::BuiltinType::kTextureSampleBaseClampToEdge));
|
||||
}
|
||||
|
||||
const ast::IdentifierExpression* exp = b.Expr(texture_sample_external_sym);
|
||||
|
@ -467,16 +469,17 @@ struct MultiplanarExternalTexture::State {
|
|||
auto name = b.Symbols().New("textureLoadExternal");
|
||||
|
||||
// Emit the textureLoadExternal() function.
|
||||
b.Func(
|
||||
name,
|
||||
utils::Vector{
|
||||
b.Param("plane0", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("plane1", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("coord", CreateASTTypeFor(ctx, coord_ty)),
|
||||
b.Param("params", b.ty.type_name(params_struct_sym)),
|
||||
},
|
||||
b.ty.vec4(b.ty.f32()), //
|
||||
buildTextureBuiltinBody(sem::BuiltinType::kTextureLoad));
|
||||
b.Func(name,
|
||||
utils::Vector{
|
||||
b.Param("plane0",
|
||||
b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("plane1",
|
||||
b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("coord", CreateASTTypeFor(ctx, coord_ty)),
|
||||
b.Param("params", b.ty.type_name(params_struct_sym)),
|
||||
},
|
||||
b.ty.vec4(b.ty.f32()), //
|
||||
buildTextureBuiltinBody(sem::BuiltinType::kTextureLoad));
|
||||
|
||||
return name;
|
||||
});
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/sem/function.h"
|
||||
#include "src/tint/sem/statement.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::Texture1DTo2D);
|
||||
|
||||
|
@ -36,7 +37,7 @@ bool ShouldRun(const Program* program) {
|
|||
auto texture = signature.Parameter(sem::ParameterUsage::kTexture);
|
||||
if (texture) {
|
||||
auto* tex = texture->Type()->As<type::Texture>();
|
||||
if (tex->dim() == ast::TextureDimension::k1d) {
|
||||
if (tex->dim() == type::TextureDimension::k1d) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -47,10 +48,10 @@ bool ShouldRun(const Program* program) {
|
|||
if (Switch(
|
||||
program->Sem().Get(var->type),
|
||||
[&](const type::SampledTexture* tex) {
|
||||
return tex->dim() == ast::TextureDimension::k1d;
|
||||
return tex->dim() == type::TextureDimension::k1d;
|
||||
},
|
||||
[&](const type::StorageTexture* storage_tex) {
|
||||
return storage_tex->dim() == ast::TextureDimension::k1d;
|
||||
return storage_tex->dim() == type::TextureDimension::k1d;
|
||||
})) {
|
||||
return true;
|
||||
}
|
||||
|
@ -94,18 +95,18 @@ struct Texture1DTo2D::State {
|
|||
const ast::Variable* r = Switch(
|
||||
sem.Get(v->type),
|
||||
[&](const type::SampledTexture* tex) -> const ast::Variable* {
|
||||
if (tex->dim() == ast::TextureDimension::k1d) {
|
||||
if (tex->dim() == type::TextureDimension::k1d) {
|
||||
auto* type = ctx.dst->create<ast::SampledTexture>(
|
||||
ast::TextureDimension::k2d, CreateASTTypeFor(ctx, tex->type()));
|
||||
type::TextureDimension::k2d, CreateASTTypeFor(ctx, tex->type()));
|
||||
return create_var(v, type);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
},
|
||||
[&](const type::StorageTexture* storage_tex) -> const ast::Variable* {
|
||||
if (storage_tex->dim() == ast::TextureDimension::k1d) {
|
||||
if (storage_tex->dim() == type::TextureDimension::k1d) {
|
||||
auto* type = ctx.dst->create<ast::StorageTexture>(
|
||||
ast::TextureDimension::k2d, storage_tex->texel_format(),
|
||||
type::TextureDimension::k2d, storage_tex->texel_format(),
|
||||
CreateASTTypeFor(ctx, storage_tex->type()), storage_tex->access());
|
||||
return create_var(v, type);
|
||||
} else {
|
||||
|
@ -131,7 +132,7 @@ struct Texture1DTo2D::State {
|
|||
return nullptr;
|
||||
}
|
||||
auto* tex = texture->Type()->As<type::Texture>();
|
||||
if (tex->dim() != ast::TextureDimension::k1d) {
|
||||
if (tex->dim() != type::TextureDimension::k1d) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "src/tint/ast/variable.h"
|
||||
#include "src/tint/debug.h"
|
||||
#include "src/tint/symbol_table.h"
|
||||
#include "src/tint/type/manager.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/hash.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::type::Array);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "src/tint/type/depth_multisampled_texture.h"
|
||||
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/hash.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::type::DepthMultisampledTexture);
|
||||
|
@ -22,13 +23,13 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::DepthMultisampledTexture);
|
|||
namespace tint::type {
|
||||
namespace {
|
||||
|
||||
bool IsValidDepthDimension(ast::TextureDimension dim) {
|
||||
return dim == ast::TextureDimension::k2d;
|
||||
bool IsValidDepthDimension(TextureDimension dim) {
|
||||
return dim == TextureDimension::k2d;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
DepthMultisampledTexture::DepthMultisampledTexture(ast::TextureDimension dim)
|
||||
DepthMultisampledTexture::DepthMultisampledTexture(TextureDimension dim)
|
||||
: Base(utils::Hash(TypeInfo::Of<DepthMultisampledTexture>().full_hashcode, dim), dim) {
|
||||
TINT_ASSERT(Type, IsValidDepthDimension(dim));
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "src/tint/type/texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::type {
|
||||
|
||||
|
@ -26,7 +27,7 @@ class DepthMultisampledTexture final : public Castable<DepthMultisampledTexture,
|
|||
public:
|
||||
/// Constructor
|
||||
/// @param dim the dimensionality of the texture
|
||||
explicit DepthMultisampledTexture(ast::TextureDimension dim);
|
||||
explicit DepthMultisampledTexture(TextureDimension dim);
|
||||
|
||||
/// Destructor
|
||||
~DepthMultisampledTexture() override;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/test_helper.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::type {
|
||||
namespace {
|
||||
|
@ -25,22 +26,22 @@ namespace {
|
|||
using DepthMultisampledTextureTest = TestHelper;
|
||||
|
||||
TEST_F(DepthMultisampledTextureTest, Creation) {
|
||||
auto* a = create<DepthMultisampledTexture>(ast::TextureDimension::k2d);
|
||||
auto* b = create<DepthMultisampledTexture>(ast::TextureDimension::k2d);
|
||||
auto* a = create<DepthMultisampledTexture>(TextureDimension::k2d);
|
||||
auto* b = create<DepthMultisampledTexture>(TextureDimension::k2d);
|
||||
|
||||
EXPECT_EQ(a, b);
|
||||
}
|
||||
|
||||
TEST_F(DepthMultisampledTextureTest, Hash) {
|
||||
auto* a = create<DepthMultisampledTexture>(ast::TextureDimension::k2d);
|
||||
auto* b = create<DepthMultisampledTexture>(ast::TextureDimension::k2d);
|
||||
auto* a = create<DepthMultisampledTexture>(TextureDimension::k2d);
|
||||
auto* b = create<DepthMultisampledTexture>(TextureDimension::k2d);
|
||||
|
||||
EXPECT_EQ(a->unique_hash, b->unique_hash);
|
||||
}
|
||||
|
||||
TEST_F(DepthMultisampledTextureTest, Equals) {
|
||||
auto* a = create<DepthMultisampledTexture>(ast::TextureDimension::k2d);
|
||||
auto* b = create<DepthMultisampledTexture>(ast::TextureDimension::k2d);
|
||||
auto* a = create<DepthMultisampledTexture>(TextureDimension::k2d);
|
||||
auto* b = create<DepthMultisampledTexture>(TextureDimension::k2d);
|
||||
|
||||
EXPECT_TRUE(a->Equals(*a));
|
||||
EXPECT_TRUE(a->Equals(*b));
|
||||
|
@ -48,23 +49,23 @@ TEST_F(DepthMultisampledTextureTest, Equals) {
|
|||
}
|
||||
|
||||
TEST_F(DepthMultisampledTextureTest, Dim) {
|
||||
DepthMultisampledTexture d(ast::TextureDimension::k2d);
|
||||
EXPECT_EQ(d.dim(), ast::TextureDimension::k2d);
|
||||
DepthMultisampledTexture d(TextureDimension::k2d);
|
||||
EXPECT_EQ(d.dim(), TextureDimension::k2d);
|
||||
}
|
||||
|
||||
TEST_F(DepthMultisampledTextureTest, FriendlyName) {
|
||||
DepthMultisampledTexture d(ast::TextureDimension::k2d);
|
||||
DepthMultisampledTexture d(TextureDimension::k2d);
|
||||
EXPECT_EQ(d.FriendlyName(Symbols()), "texture_depth_multisampled_2d");
|
||||
}
|
||||
|
||||
TEST_F(DepthMultisampledTextureTest, Clone) {
|
||||
auto* a = create<DepthMultisampledTexture>(ast::TextureDimension::k2d);
|
||||
auto* a = create<DepthMultisampledTexture>(TextureDimension::k2d);
|
||||
|
||||
type::Manager mgr;
|
||||
type::CloneContext ctx{{nullptr}, {nullptr, &mgr}};
|
||||
|
||||
auto* dt = a->Clone(ctx);
|
||||
EXPECT_EQ(dt->dim(), ast::TextureDimension::k2d);
|
||||
EXPECT_EQ(dt->dim(), TextureDimension::k2d);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "src/tint/type/depth_texture.h"
|
||||
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/hash.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::type::DepthTexture);
|
||||
|
@ -22,14 +23,14 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::DepthTexture);
|
|||
namespace tint::type {
|
||||
namespace {
|
||||
|
||||
bool IsValidDepthDimension(ast::TextureDimension dim) {
|
||||
return dim == ast::TextureDimension::k2d || dim == ast::TextureDimension::k2dArray ||
|
||||
dim == ast::TextureDimension::kCube || dim == ast::TextureDimension::kCubeArray;
|
||||
bool IsValidDepthDimension(TextureDimension dim) {
|
||||
return dim == TextureDimension::k2d || dim == TextureDimension::k2dArray ||
|
||||
dim == TextureDimension::kCube || dim == TextureDimension::kCubeArray;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
DepthTexture::DepthTexture(ast::TextureDimension dim)
|
||||
DepthTexture::DepthTexture(TextureDimension dim)
|
||||
: Base(utils::Hash(TypeInfo::Of<DepthTexture>().full_hashcode, dim), dim) {
|
||||
TINT_ASSERT(Type, IsValidDepthDimension(dim));
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "src/tint/type/texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::type {
|
||||
|
||||
|
@ -26,7 +27,7 @@ class DepthTexture final : public Castable<DepthTexture, Texture> {
|
|||
public:
|
||||
/// Constructor
|
||||
/// @param dim the dimensionality of the texture
|
||||
explicit DepthTexture(ast::TextureDimension dim);
|
||||
explicit DepthTexture(TextureDimension dim);
|
||||
|
||||
/// Destructor
|
||||
~DepthTexture() override;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/test_helper.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::type {
|
||||
namespace {
|
||||
|
@ -25,25 +26,25 @@ namespace {
|
|||
using DepthTextureTest = TestHelper;
|
||||
|
||||
TEST_F(DepthTextureTest, Creation) {
|
||||
auto* a = create<DepthTexture>(ast::TextureDimension::k2d);
|
||||
auto* b = create<DepthTexture>(ast::TextureDimension::k2d);
|
||||
auto* c = create<DepthTexture>(ast::TextureDimension::k2dArray);
|
||||
auto* a = create<DepthTexture>(TextureDimension::k2d);
|
||||
auto* b = create<DepthTexture>(TextureDimension::k2d);
|
||||
auto* c = create<DepthTexture>(TextureDimension::k2dArray);
|
||||
|
||||
EXPECT_EQ(a, b);
|
||||
EXPECT_NE(a, c);
|
||||
}
|
||||
|
||||
TEST_F(DepthTextureTest, Hash) {
|
||||
auto* a = create<DepthTexture>(ast::TextureDimension::k2d);
|
||||
auto* b = create<DepthTexture>(ast::TextureDimension::k2d);
|
||||
auto* a = create<DepthTexture>(TextureDimension::k2d);
|
||||
auto* b = create<DepthTexture>(TextureDimension::k2d);
|
||||
|
||||
EXPECT_EQ(a->unique_hash, b->unique_hash);
|
||||
}
|
||||
|
||||
TEST_F(DepthTextureTest, Equals) {
|
||||
auto* a = create<DepthTexture>(ast::TextureDimension::k2d);
|
||||
auto* b = create<DepthTexture>(ast::TextureDimension::k2d);
|
||||
auto* c = create<DepthTexture>(ast::TextureDimension::k2dArray);
|
||||
auto* a = create<DepthTexture>(TextureDimension::k2d);
|
||||
auto* b = create<DepthTexture>(TextureDimension::k2d);
|
||||
auto* c = create<DepthTexture>(TextureDimension::k2dArray);
|
||||
|
||||
EXPECT_TRUE(a->Equals(*b));
|
||||
EXPECT_FALSE(a->Equals(*c));
|
||||
|
@ -51,7 +52,7 @@ TEST_F(DepthTextureTest, Equals) {
|
|||
}
|
||||
|
||||
TEST_F(DepthTextureTest, IsTexture) {
|
||||
DepthTexture d(ast::TextureDimension::kCube);
|
||||
DepthTexture d(TextureDimension::kCube);
|
||||
Texture* ty = &d;
|
||||
EXPECT_TRUE(ty->Is<DepthTexture>());
|
||||
EXPECT_FALSE(ty->Is<ExternalTexture>());
|
||||
|
@ -60,23 +61,23 @@ TEST_F(DepthTextureTest, IsTexture) {
|
|||
}
|
||||
|
||||
TEST_F(DepthTextureTest, Dim) {
|
||||
DepthTexture d(ast::TextureDimension::kCube);
|
||||
EXPECT_EQ(d.dim(), ast::TextureDimension::kCube);
|
||||
DepthTexture d(TextureDimension::kCube);
|
||||
EXPECT_EQ(d.dim(), TextureDimension::kCube);
|
||||
}
|
||||
|
||||
TEST_F(DepthTextureTest, FriendlyName) {
|
||||
DepthTexture d(ast::TextureDimension::kCube);
|
||||
DepthTexture d(TextureDimension::kCube);
|
||||
EXPECT_EQ(d.FriendlyName(Symbols()), "texture_depth_cube");
|
||||
}
|
||||
|
||||
TEST_F(DepthTextureTest, Clone) {
|
||||
auto* a = create<DepthTexture>(ast::TextureDimension::k2d);
|
||||
auto* a = create<DepthTexture>(TextureDimension::k2d);
|
||||
|
||||
type::Manager mgr;
|
||||
type::CloneContext ctx{{nullptr}, {nullptr, &mgr}};
|
||||
|
||||
auto* dt = a->Clone(ctx);
|
||||
EXPECT_EQ(dt->dim(), ast::TextureDimension::k2d);
|
||||
EXPECT_EQ(dt->dim(), TextureDimension::k2d);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "src/tint/type/external_texture.h"
|
||||
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::type::ExternalTexture);
|
||||
|
||||
|
@ -22,7 +23,7 @@ namespace tint::type {
|
|||
|
||||
ExternalTexture::ExternalTexture()
|
||||
: Base(static_cast<size_t>(TypeInfo::Of<ExternalTexture>().full_hashcode),
|
||||
ast::TextureDimension::k2d) {}
|
||||
TextureDimension::k2d) {}
|
||||
|
||||
ExternalTexture::~ExternalTexture() = default;
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/test_helper.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::type {
|
||||
namespace {
|
||||
|
@ -58,7 +59,7 @@ TEST_F(ExternalTextureTest, IsTexture) {
|
|||
TEST_F(ExternalTextureTest, Dim) {
|
||||
F32 f32;
|
||||
ExternalTexture s;
|
||||
EXPECT_EQ(s.dim(), ast::TextureDimension::k2d);
|
||||
EXPECT_EQ(s.dim(), TextureDimension::k2d);
|
||||
}
|
||||
|
||||
TEST_F(ExternalTextureTest, FriendlyName) {
|
||||
|
|
|
@ -15,13 +15,14 @@
|
|||
#include "src/tint/type/multisampled_texture.h"
|
||||
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/hash.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::type::MultisampledTexture);
|
||||
|
||||
namespace tint::type {
|
||||
|
||||
MultisampledTexture::MultisampledTexture(ast::TextureDimension dim, const Type* type)
|
||||
MultisampledTexture::MultisampledTexture(TextureDimension dim, const Type* type)
|
||||
: Base(utils::Hash(TypeInfo::Of<MultisampledTexture>().full_hashcode, dim, type), dim),
|
||||
type_(type) {
|
||||
TINT_ASSERT(Type, type_);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "src/tint/type/texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::type {
|
||||
|
||||
|
@ -27,7 +28,7 @@ class MultisampledTexture final : public Castable<MultisampledTexture, Texture>
|
|||
/// Constructor
|
||||
/// @param dim the dimensionality of the texture
|
||||
/// @param type the data type of the multisampled texture
|
||||
MultisampledTexture(ast::TextureDimension dim, const Type* type);
|
||||
MultisampledTexture(TextureDimension dim, const Type* type);
|
||||
|
||||
/// Destructor
|
||||
~MultisampledTexture() override;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/test_helper.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::type {
|
||||
namespace {
|
||||
|
@ -26,26 +27,26 @@ namespace {
|
|||
using MultisampledTextureTest = TestHelper;
|
||||
|
||||
TEST_F(MultisampledTextureTest, Creation) {
|
||||
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>());
|
||||
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>());
|
||||
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<F32>());
|
||||
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<I32>());
|
||||
auto* a = create<MultisampledTexture>(TextureDimension::k2d, create<F32>());
|
||||
auto* b = create<MultisampledTexture>(TextureDimension::k2d, create<F32>());
|
||||
auto* c = create<MultisampledTexture>(TextureDimension::k3d, create<F32>());
|
||||
auto* d = create<MultisampledTexture>(TextureDimension::k2d, create<I32>());
|
||||
EXPECT_EQ(a, b);
|
||||
EXPECT_NE(a, c);
|
||||
EXPECT_NE(a, d);
|
||||
}
|
||||
|
||||
TEST_F(MultisampledTextureTest, Hash) {
|
||||
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>());
|
||||
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>());
|
||||
auto* a = create<MultisampledTexture>(TextureDimension::k2d, create<F32>());
|
||||
auto* b = create<MultisampledTexture>(TextureDimension::k2d, create<F32>());
|
||||
EXPECT_EQ(a->unique_hash, b->unique_hash);
|
||||
}
|
||||
|
||||
TEST_F(MultisampledTextureTest, Equals) {
|
||||
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>());
|
||||
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>());
|
||||
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<F32>());
|
||||
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<I32>());
|
||||
auto* a = create<MultisampledTexture>(TextureDimension::k2d, create<F32>());
|
||||
auto* b = create<MultisampledTexture>(TextureDimension::k2d, create<F32>());
|
||||
auto* c = create<MultisampledTexture>(TextureDimension::k3d, create<F32>());
|
||||
auto* d = create<MultisampledTexture>(TextureDimension::k2d, create<I32>());
|
||||
EXPECT_TRUE(a->Equals(*b));
|
||||
EXPECT_FALSE(a->Equals(*c));
|
||||
EXPECT_FALSE(a->Equals(*d));
|
||||
|
@ -54,7 +55,7 @@ TEST_F(MultisampledTextureTest, Equals) {
|
|||
|
||||
TEST_F(MultisampledTextureTest, IsTexture) {
|
||||
F32 f32;
|
||||
MultisampledTexture s(ast::TextureDimension::kCube, &f32);
|
||||
MultisampledTexture s(TextureDimension::kCube, &f32);
|
||||
Texture* ty = &s;
|
||||
EXPECT_FALSE(ty->Is<DepthTexture>());
|
||||
EXPECT_FALSE(ty->Is<ExternalTexture>());
|
||||
|
@ -65,30 +66,30 @@ TEST_F(MultisampledTextureTest, IsTexture) {
|
|||
|
||||
TEST_F(MultisampledTextureTest, Dim) {
|
||||
F32 f32;
|
||||
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||
EXPECT_EQ(s.dim(), ast::TextureDimension::k3d);
|
||||
MultisampledTexture s(TextureDimension::k3d, &f32);
|
||||
EXPECT_EQ(s.dim(), TextureDimension::k3d);
|
||||
}
|
||||
|
||||
TEST_F(MultisampledTextureTest, Type) {
|
||||
F32 f32;
|
||||
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||
MultisampledTexture s(TextureDimension::k3d, &f32);
|
||||
EXPECT_EQ(s.type(), &f32);
|
||||
}
|
||||
|
||||
TEST_F(MultisampledTextureTest, FriendlyName) {
|
||||
F32 f32;
|
||||
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||
MultisampledTexture s(TextureDimension::k3d, &f32);
|
||||
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_multisampled_3d<f32>");
|
||||
}
|
||||
|
||||
TEST_F(MultisampledTextureTest, Clone) {
|
||||
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>());
|
||||
auto* a = create<MultisampledTexture>(TextureDimension::k2d, create<F32>());
|
||||
|
||||
type::Manager mgr;
|
||||
type::CloneContext ctx{{nullptr}, {nullptr, &mgr}};
|
||||
|
||||
auto* mt = a->Clone(ctx);
|
||||
EXPECT_EQ(mt->dim(), ast::TextureDimension::k2d);
|
||||
EXPECT_EQ(mt->dim(), TextureDimension::k2d);
|
||||
EXPECT_TRUE(mt->type()->Is<F32>());
|
||||
}
|
||||
|
||||
|
|
|
@ -15,13 +15,14 @@
|
|||
#include "src/tint/type/sampled_texture.h"
|
||||
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/hash.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::type::SampledTexture);
|
||||
|
||||
namespace tint::type {
|
||||
|
||||
SampledTexture::SampledTexture(ast::TextureDimension dim, const Type* type)
|
||||
SampledTexture::SampledTexture(TextureDimension dim, const Type* type)
|
||||
: Base(utils::Hash(TypeInfo::Of<SampledTexture>().full_hashcode, dim, type), dim), type_(type) {
|
||||
TINT_ASSERT(Type, type_);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "src/tint/type/texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::type {
|
||||
|
||||
|
@ -27,7 +28,7 @@ class SampledTexture final : public Castable<SampledTexture, Texture> {
|
|||
/// Constructor
|
||||
/// @param dim the dimensionality of the texture
|
||||
/// @param type the data type of the sampled texture
|
||||
SampledTexture(ast::TextureDimension dim, const Type* type);
|
||||
SampledTexture(TextureDimension dim, const Type* type);
|
||||
|
||||
/// Destructor
|
||||
~SampledTexture() override;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "src/tint/type/external_texture.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/test_helper.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::type {
|
||||
namespace {
|
||||
|
@ -25,13 +26,13 @@ namespace {
|
|||
using SampledTextureTest = TestHelper;
|
||||
|
||||
TEST_F(SampledTextureTest, Creation) {
|
||||
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>());
|
||||
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>());
|
||||
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<F32>());
|
||||
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<I32>());
|
||||
auto* a = create<SampledTexture>(TextureDimension::kCube, create<F32>());
|
||||
auto* b = create<SampledTexture>(TextureDimension::kCube, create<F32>());
|
||||
auto* c = create<SampledTexture>(TextureDimension::k2d, create<F32>());
|
||||
auto* d = create<SampledTexture>(TextureDimension::kCube, create<I32>());
|
||||
|
||||
EXPECT_TRUE(a->type()->Is<F32>());
|
||||
EXPECT_EQ(a->dim(), ast::TextureDimension::kCube);
|
||||
EXPECT_EQ(a->dim(), TextureDimension::kCube);
|
||||
|
||||
EXPECT_EQ(a, b);
|
||||
EXPECT_NE(a, c);
|
||||
|
@ -39,17 +40,17 @@ TEST_F(SampledTextureTest, Creation) {
|
|||
}
|
||||
|
||||
TEST_F(SampledTextureTest, Hash) {
|
||||
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>());
|
||||
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>());
|
||||
auto* a = create<SampledTexture>(TextureDimension::kCube, create<F32>());
|
||||
auto* b = create<SampledTexture>(TextureDimension::kCube, create<F32>());
|
||||
|
||||
EXPECT_EQ(a->unique_hash, b->unique_hash);
|
||||
}
|
||||
|
||||
TEST_F(SampledTextureTest, Equals) {
|
||||
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>());
|
||||
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>());
|
||||
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<F32>());
|
||||
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<I32>());
|
||||
auto* a = create<SampledTexture>(TextureDimension::kCube, create<F32>());
|
||||
auto* b = create<SampledTexture>(TextureDimension::kCube, create<F32>());
|
||||
auto* c = create<SampledTexture>(TextureDimension::k2d, create<F32>());
|
||||
auto* d = create<SampledTexture>(TextureDimension::kCube, create<I32>());
|
||||
|
||||
EXPECT_TRUE(a->Equals(*b));
|
||||
EXPECT_FALSE(a->Equals(*c));
|
||||
|
@ -59,7 +60,7 @@ TEST_F(SampledTextureTest, Equals) {
|
|||
|
||||
TEST_F(SampledTextureTest, IsTexture) {
|
||||
F32 f32;
|
||||
SampledTexture s(ast::TextureDimension::kCube, &f32);
|
||||
SampledTexture s(TextureDimension::kCube, &f32);
|
||||
Texture* ty = &s;
|
||||
EXPECT_FALSE(ty->Is<DepthTexture>());
|
||||
EXPECT_FALSE(ty->Is<ExternalTexture>());
|
||||
|
@ -69,30 +70,30 @@ TEST_F(SampledTextureTest, IsTexture) {
|
|||
|
||||
TEST_F(SampledTextureTest, Dim) {
|
||||
F32 f32;
|
||||
SampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||
EXPECT_EQ(s.dim(), ast::TextureDimension::k3d);
|
||||
SampledTexture s(TextureDimension::k3d, &f32);
|
||||
EXPECT_EQ(s.dim(), TextureDimension::k3d);
|
||||
}
|
||||
|
||||
TEST_F(SampledTextureTest, Type) {
|
||||
F32 f32;
|
||||
SampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||
SampledTexture s(TextureDimension::k3d, &f32);
|
||||
EXPECT_EQ(s.type(), &f32);
|
||||
}
|
||||
|
||||
TEST_F(SampledTextureTest, FriendlyName) {
|
||||
F32 f32;
|
||||
SampledTexture s(ast::TextureDimension::k3d, &f32);
|
||||
SampledTexture s(TextureDimension::k3d, &f32);
|
||||
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_3d<f32>");
|
||||
}
|
||||
|
||||
TEST_F(SampledTextureTest, Clone) {
|
||||
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>());
|
||||
auto* a = create<SampledTexture>(TextureDimension::kCube, create<F32>());
|
||||
|
||||
type::Manager mgr;
|
||||
type::CloneContext ctx{{nullptr}, {nullptr, &mgr}};
|
||||
|
||||
auto* mt = a->Clone(ctx);
|
||||
EXPECT_EQ(mt->dim(), ast::TextureDimension::kCube);
|
||||
EXPECT_EQ(mt->dim(), TextureDimension::kCube);
|
||||
EXPECT_TRUE(mt->type()->Is<F32>());
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::StorageTexture);
|
|||
|
||||
namespace tint::type {
|
||||
|
||||
StorageTexture::StorageTexture(ast::TextureDimension dim,
|
||||
StorageTexture::StorageTexture(TextureDimension dim,
|
||||
ast::TexelFormat format,
|
||||
ast::Access access,
|
||||
Type* subtype)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "src/tint/ast/access.h"
|
||||
#include "src/tint/ast/storage_texture.h"
|
||||
#include "src/tint/type/texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
// Forward declarations
|
||||
namespace tint::type {
|
||||
|
@ -36,7 +37,7 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
|
|||
/// @param format the texel format of the texture
|
||||
/// @param access the access control type of the texture
|
||||
/// @param subtype the storage subtype. Use SubtypeFor() to calculate this.
|
||||
StorageTexture(ast::TextureDimension dim,
|
||||
StorageTexture(TextureDimension dim,
|
||||
ast::TexelFormat format,
|
||||
ast::Access access,
|
||||
Type* subtype);
|
||||
|
|
|
@ -18,31 +18,30 @@
|
|||
#include "src/tint/type/external_texture.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/test_helper.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::type {
|
||||
namespace {
|
||||
|
||||
struct StorageTextureTest : public TestHelper {
|
||||
StorageTexture* Create(ast::TextureDimension dims, ast::TexelFormat fmt, ast::Access access) {
|
||||
StorageTexture* Create(TextureDimension dims, ast::TexelFormat fmt, ast::Access access) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(fmt, Types());
|
||||
return create<StorageTexture>(dims, fmt, access, subtype);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(StorageTextureTest, Creation) {
|
||||
auto* a = Create(ast::TextureDimension::kCube, ast::TexelFormat::kRgba32Float,
|
||||
ast::Access::kReadWrite);
|
||||
auto* b = Create(ast::TextureDimension::kCube, ast::TexelFormat::kRgba32Float,
|
||||
ast::Access::kReadWrite);
|
||||
auto* a =
|
||||
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
|
||||
auto* b =
|
||||
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
|
||||
auto* c =
|
||||
Create(ast::TextureDimension::k2d, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
|
||||
auto* d =
|
||||
Create(ast::TextureDimension::kCube, ast::TexelFormat::kR32Float, ast::Access::kReadWrite);
|
||||
auto* e =
|
||||
Create(ast::TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kRead);
|
||||
Create(TextureDimension::k2d, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
|
||||
auto* d = Create(TextureDimension::kCube, ast::TexelFormat::kR32Float, ast::Access::kReadWrite);
|
||||
auto* e = Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kRead);
|
||||
|
||||
EXPECT_TRUE(a->type()->Is<F32>());
|
||||
EXPECT_EQ(a->dim(), ast::TextureDimension::kCube);
|
||||
EXPECT_EQ(a->dim(), TextureDimension::kCube);
|
||||
|
||||
EXPECT_EQ(a, b);
|
||||
EXPECT_NE(a, c);
|
||||
|
@ -51,25 +50,23 @@ TEST_F(StorageTextureTest, Creation) {
|
|||
}
|
||||
|
||||
TEST_F(StorageTextureTest, Hash) {
|
||||
auto* a = Create(ast::TextureDimension::kCube, ast::TexelFormat::kRgba32Float,
|
||||
ast::Access::kReadWrite);
|
||||
auto* b = Create(ast::TextureDimension::kCube, ast::TexelFormat::kRgba32Float,
|
||||
ast::Access::kReadWrite);
|
||||
auto* a =
|
||||
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
|
||||
auto* b =
|
||||
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
|
||||
|
||||
EXPECT_EQ(a->unique_hash, b->unique_hash);
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTest, Equals) {
|
||||
auto* a = Create(ast::TextureDimension::kCube, ast::TexelFormat::kRgba32Float,
|
||||
ast::Access::kReadWrite);
|
||||
auto* b = Create(ast::TextureDimension::kCube, ast::TexelFormat::kRgba32Float,
|
||||
ast::Access::kReadWrite);
|
||||
auto* a =
|
||||
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
|
||||
auto* b =
|
||||
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
|
||||
auto* c =
|
||||
Create(ast::TextureDimension::k2d, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
|
||||
auto* d =
|
||||
Create(ast::TextureDimension::kCube, ast::TexelFormat::kR32Float, ast::Access::kReadWrite);
|
||||
auto* e =
|
||||
Create(ast::TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kRead);
|
||||
Create(TextureDimension::k2d, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
|
||||
auto* d = Create(TextureDimension::kCube, ast::TexelFormat::kR32Float, ast::Access::kReadWrite);
|
||||
auto* e = Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kRead);
|
||||
|
||||
EXPECT_TRUE(a->Equals(*b));
|
||||
EXPECT_FALSE(a->Equals(*c));
|
||||
|
@ -79,26 +76,26 @@ TEST_F(StorageTextureTest, Equals) {
|
|||
}
|
||||
|
||||
TEST_F(StorageTextureTest, Dim) {
|
||||
auto* s = Create(ast::TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float,
|
||||
ast::Access::kReadWrite);
|
||||
EXPECT_EQ(s->dim(), ast::TextureDimension::k2dArray);
|
||||
auto* s =
|
||||
Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
|
||||
EXPECT_EQ(s->dim(), TextureDimension::k2dArray);
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTest, Format) {
|
||||
auto* s = Create(ast::TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float,
|
||||
ast::Access::kReadWrite);
|
||||
auto* s =
|
||||
Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
|
||||
EXPECT_EQ(s->texel_format(), ast::TexelFormat::kRgba32Float);
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTest, FriendlyName) {
|
||||
auto* s = Create(ast::TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float,
|
||||
ast::Access::kReadWrite);
|
||||
auto* s =
|
||||
Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
|
||||
EXPECT_EQ(s->FriendlyName(Symbols()), "texture_storage_2d_array<rgba32float, read_write>");
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTest, F32) {
|
||||
Type* s = Create(ast::TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float,
|
||||
ast::Access::kReadWrite);
|
||||
Type* s =
|
||||
Create(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
|
||||
|
||||
auto program = Build();
|
||||
|
||||
|
@ -110,7 +107,7 @@ TEST_F(StorageTextureTest, F32) {
|
|||
|
||||
TEST_F(StorageTextureTest, U32) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(ast::TexelFormat::kRg32Uint, Types());
|
||||
Type* s = create<StorageTexture>(ast::TextureDimension::k2dArray, ast::TexelFormat::kRg32Uint,
|
||||
Type* s = create<StorageTexture>(TextureDimension::k2dArray, ast::TexelFormat::kRg32Uint,
|
||||
ast::Access::kReadWrite, subtype);
|
||||
|
||||
auto program = Build();
|
||||
|
@ -123,7 +120,7 @@ TEST_F(StorageTextureTest, U32) {
|
|||
|
||||
TEST_F(StorageTextureTest, I32) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Sint, Types());
|
||||
Type* s = create<StorageTexture>(ast::TextureDimension::k2dArray, ast::TexelFormat::kRgba32Sint,
|
||||
Type* s = create<StorageTexture>(TextureDimension::k2dArray, ast::TexelFormat::kRgba32Sint,
|
||||
ast::Access::kReadWrite, subtype);
|
||||
|
||||
auto program = Build();
|
||||
|
@ -135,14 +132,14 @@ TEST_F(StorageTextureTest, I32) {
|
|||
}
|
||||
|
||||
TEST_F(StorageTextureTest, Clone) {
|
||||
auto* a = Create(ast::TextureDimension::kCube, ast::TexelFormat::kRgba32Float,
|
||||
ast::Access::kReadWrite);
|
||||
auto* a =
|
||||
Create(TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kReadWrite);
|
||||
|
||||
type::Manager mgr;
|
||||
type::CloneContext ctx{{nullptr}, {nullptr, &mgr}};
|
||||
|
||||
auto* mt = a->Clone(ctx);
|
||||
EXPECT_EQ(mt->dim(), ast::TextureDimension::kCube);
|
||||
EXPECT_EQ(mt->dim(), TextureDimension::kCube);
|
||||
EXPECT_EQ(mt->texel_format(), ast::TexelFormat::kRgba32Float);
|
||||
EXPECT_TRUE(mt->type()->Is<F32>());
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Texture);
|
|||
|
||||
namespace tint::type {
|
||||
|
||||
Texture::Texture(size_t hash, ast::TextureDimension dim) : Base(hash, type::Flags{}), dim_(dim) {}
|
||||
Texture::Texture(size_t hash, TextureDimension dim) : Base(hash, type::Flags{}), dim_(dim) {}
|
||||
|
||||
Texture::~Texture() = default;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define SRC_TINT_TYPE_TEXTURE_H_
|
||||
|
||||
#include "src/tint/ast/texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/type/type.h"
|
||||
|
||||
namespace tint::type {
|
||||
|
@ -26,15 +27,15 @@ class Texture : public Castable<Texture, Type> {
|
|||
/// Constructor
|
||||
/// @param hash the unique hash of the node
|
||||
/// @param dim the dimensionality of the texture
|
||||
Texture(size_t hash, ast::TextureDimension dim);
|
||||
Texture(size_t hash, TextureDimension dim);
|
||||
/// Destructor
|
||||
~Texture() override;
|
||||
|
||||
/// @returns the texture dimension
|
||||
ast::TextureDimension dim() const { return dim_; }
|
||||
TextureDimension dim() const { return dim_; }
|
||||
|
||||
private:
|
||||
ast::TextureDimension const dim_;
|
||||
TextureDimension const dim_;
|
||||
};
|
||||
|
||||
} // namespace tint::type
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright 2023 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::type {
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, type::TextureDimension dim) {
|
||||
switch (dim) {
|
||||
case type::TextureDimension::kNone:
|
||||
out << "None";
|
||||
break;
|
||||
case type::TextureDimension::k1d:
|
||||
out << "1d";
|
||||
break;
|
||||
case type::TextureDimension::k2d:
|
||||
out << "2d";
|
||||
break;
|
||||
case type::TextureDimension::k2dArray:
|
||||
out << "2d_array";
|
||||
break;
|
||||
case type::TextureDimension::k3d:
|
||||
out << "3d";
|
||||
break;
|
||||
case type::TextureDimension::kCube:
|
||||
out << "cube";
|
||||
break;
|
||||
case type::TextureDimension::kCubeArray:
|
||||
out << "cube_array";
|
||||
break;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace tint::type
|
|
@ -0,0 +1,47 @@
|
|||
// Copyright 2023 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.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef SRC_TINT_TYPE_TEXTURE_DIMENSION_H_
|
||||
#define SRC_TINT_TYPE_TEXTURE_DIMENSION_H_
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace tint::type {
|
||||
|
||||
/// The dimensionality of the texture
|
||||
enum class TextureDimension {
|
||||
/// Invalid texture
|
||||
kNone = -1,
|
||||
/// 1 dimensional texture
|
||||
k1d,
|
||||
/// 2 dimensional texture
|
||||
k2d,
|
||||
/// 2 dimensional array texture
|
||||
k2dArray,
|
||||
/// 3 dimensional texture
|
||||
k3d,
|
||||
/// cube texture
|
||||
kCube,
|
||||
/// cube array texture
|
||||
kCubeArray,
|
||||
};
|
||||
|
||||
/// @param out the std::ostream to write to
|
||||
/// @param dim the type::TextureDimension
|
||||
/// @return the std::ostream so calls can be chained
|
||||
std::ostream& operator<<(std::ostream& out, type::TextureDimension dim);
|
||||
|
||||
} // namespace tint::type
|
||||
|
||||
#endif // SRC_TINT_TYPE_TEXTURE_DIMENSION_H_
|
|
@ -20,7 +20,7 @@
|
|||
namespace tint::type {
|
||||
namespace {
|
||||
|
||||
using TextureTypeDimTest = TestParamHelper<ast::TextureDimension>;
|
||||
using TextureTypeDimTest = TestParamHelper<TextureDimension>;
|
||||
|
||||
TEST_P(TextureTypeDimTest, DimMustMatch) {
|
||||
// Check that the dim() query returns the right dimensionality.
|
||||
|
@ -33,12 +33,12 @@ TEST_P(TextureTypeDimTest, DimMustMatch) {
|
|||
|
||||
INSTANTIATE_TEST_SUITE_P(Dimensions,
|
||||
TextureTypeDimTest,
|
||||
::testing::Values(ast::TextureDimension::k1d,
|
||||
ast::TextureDimension::k2d,
|
||||
ast::TextureDimension::k2dArray,
|
||||
ast::TextureDimension::k3d,
|
||||
ast::TextureDimension::kCube,
|
||||
ast::TextureDimension::kCubeArray));
|
||||
::testing::Values(TextureDimension::k1d,
|
||||
TextureDimension::k2d,
|
||||
TextureDimension::k2dArray,
|
||||
TextureDimension::k3d,
|
||||
TextureDimension::kCube,
|
||||
TextureDimension::kCubeArray));
|
||||
|
||||
} // namespace
|
||||
} // namespace tint::type
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "gtest/gtest.h"
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/sem/variable.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
namespace tint::writer {
|
||||
namespace {
|
||||
|
@ -95,17 +96,17 @@ TEST_F(FlattenBindingsTest, NotFlat_MultipleNamespaces) {
|
|||
b.Binding(4_a));
|
||||
|
||||
const size_t num_textures = 6;
|
||||
b.GlobalVar("texture1", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32()),
|
||||
b.GlobalVar("texture1", b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32()),
|
||||
b.Group(5_a), b.Binding(5_a));
|
||||
b.GlobalVar("texture2", b.ty.multisampled_texture(ast::TextureDimension::k2d, b.ty.f32()),
|
||||
b.GlobalVar("texture2", b.ty.multisampled_texture(type::TextureDimension::k2d, b.ty.f32()),
|
||||
b.Group(6_a), b.Binding(6_a));
|
||||
b.GlobalVar("texture3",
|
||||
b.ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float,
|
||||
b.ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float,
|
||||
ast::Access::kWrite),
|
||||
b.Group(7_a), b.Binding(7_a));
|
||||
b.GlobalVar("texture4", b.ty.depth_texture(ast::TextureDimension::k2d), b.Group(8_a),
|
||||
b.GlobalVar("texture4", b.ty.depth_texture(type::TextureDimension::k2d), b.Group(8_a),
|
||||
b.Binding(8_a));
|
||||
b.GlobalVar("texture5", b.ty.depth_multisampled_texture(ast::TextureDimension::k2d),
|
||||
b.GlobalVar("texture5", b.ty.depth_multisampled_texture(type::TextureDimension::k2d),
|
||||
b.Group(9_a), b.Binding(9_a));
|
||||
b.GlobalVar("texture6", b.ty.external_texture(), b.Group(10_a), b.Binding(10_a));
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
#include "src/tint/type/multisampled_texture.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/defer.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
#include "src/tint/utils/scoped_assignment.h"
|
||||
|
@ -1406,8 +1407,8 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
|||
out << ")";
|
||||
// textureSize() on array samplers returns the array size in the
|
||||
// final component, so strip it out.
|
||||
if (texture_type->dim() == ast::TextureDimension::k2dArray ||
|
||||
texture_type->dim() == ast::TextureDimension::kCubeArray) {
|
||||
if (texture_type->dim() == type::TextureDimension::k2dArray ||
|
||||
texture_type->dim() == type::TextureDimension::kCubeArray) {
|
||||
out << ".xy";
|
||||
}
|
||||
return true;
|
||||
|
@ -1548,7 +1549,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
|||
// GLSL requires Dref to be appended to the coordinates, *unless* it's
|
||||
// samplerCubeArrayShadow, in which case it will be handled as a separate
|
||||
// parameter.
|
||||
if (texture_type->dim() == ast::TextureDimension::kCubeArray) {
|
||||
if (texture_type->dim() == type::TextureDimension::kCubeArray) {
|
||||
append_depth_ref_to_coords = false;
|
||||
}
|
||||
|
||||
|
@ -2949,22 +2950,22 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
|||
out << (storage ? "image" : "sampler");
|
||||
|
||||
switch (tex->dim()) {
|
||||
case ast::TextureDimension::k1d:
|
||||
case type::TextureDimension::k1d:
|
||||
out << "1D";
|
||||
break;
|
||||
case ast::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2d:
|
||||
out << ((ms || depth_ms) ? "2DMS" : "2D");
|
||||
break;
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k2dArray:
|
||||
out << ((ms || depth_ms) ? "2DMSArray" : "2DArray");
|
||||
break;
|
||||
case ast::TextureDimension::k3d:
|
||||
case type::TextureDimension::k3d:
|
||||
out << "3D";
|
||||
break;
|
||||
case ast::TextureDimension::kCube:
|
||||
case type::TextureDimension::kCube:
|
||||
out << "Cube";
|
||||
break;
|
||||
case ast::TextureDimension::kCubeArray:
|
||||
case type::TextureDimension::kCubeArray:
|
||||
out << "CubeArray";
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/sampler.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
|
@ -299,7 +300,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitSamplerComparison) {
|
|||
}
|
||||
|
||||
struct GlslDepthTextureData {
|
||||
ast::TextureDimension dim;
|
||||
type::TextureDimension dim;
|
||||
std::string result;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, GlslDepthTextureData data) {
|
||||
|
@ -331,14 +332,14 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
GlslGeneratorImplTest_Type,
|
||||
GlslDepthTexturesTest,
|
||||
testing::Values(
|
||||
GlslDepthTextureData{ast::TextureDimension::k2d, "sampler2DShadow tex;"},
|
||||
GlslDepthTextureData{ast::TextureDimension::k2dArray, "sampler2DArrayShadow tex;"},
|
||||
GlslDepthTextureData{ast::TextureDimension::kCube, "samplerCubeShadow tex;"},
|
||||
GlslDepthTextureData{ast::TextureDimension::kCubeArray, "samplerCubeArrayShadow tex;"}));
|
||||
GlslDepthTextureData{type::TextureDimension::k2d, "sampler2DShadow tex;"},
|
||||
GlslDepthTextureData{type::TextureDimension::k2dArray, "sampler2DArrayShadow tex;"},
|
||||
GlslDepthTextureData{type::TextureDimension::kCube, "samplerCubeShadow tex;"},
|
||||
GlslDepthTextureData{type::TextureDimension::kCubeArray, "samplerCubeArrayShadow tex;"}));
|
||||
|
||||
using GlslDepthMultisampledTexturesTest = TestHelper;
|
||||
TEST_F(GlslDepthMultisampledTexturesTest, Emit) {
|
||||
auto* t = ty.depth_multisampled_texture(ast::TextureDimension::k2d);
|
||||
auto* t = ty.depth_multisampled_texture(type::TextureDimension::k2d);
|
||||
|
||||
GlobalVar("tex", t, Binding(1_a), Group(2_a));
|
||||
|
||||
|
@ -358,7 +359,7 @@ TEST_F(GlslDepthMultisampledTexturesTest, Emit) {
|
|||
|
||||
enum class TextureDataType { F32, U32, I32 };
|
||||
struct GlslSampledTextureData {
|
||||
ast::TextureDimension dim;
|
||||
type::TextureDimension dim;
|
||||
TextureDataType datatype;
|
||||
std::string result;
|
||||
};
|
||||
|
@ -403,99 +404,99 @@ INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Type,
|
|||
GlslSampledTexturesTest,
|
||||
testing::Values(
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::k1d,
|
||||
type::TextureDimension::k1d,
|
||||
TextureDataType::F32,
|
||||
"sampler1D tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::k2d,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::F32,
|
||||
"sampler2D tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::k2dArray,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::F32,
|
||||
"sampler2DArray tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::k3d,
|
||||
type::TextureDimension::k3d,
|
||||
TextureDataType::F32,
|
||||
"sampler3D tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::kCube,
|
||||
type::TextureDimension::kCube,
|
||||
TextureDataType::F32,
|
||||
"samplerCube tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::kCubeArray,
|
||||
type::TextureDimension::kCubeArray,
|
||||
TextureDataType::F32,
|
||||
"samplerCubeArray tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::k1d,
|
||||
type::TextureDimension::k1d,
|
||||
TextureDataType::U32,
|
||||
"usampler1D tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::k2d,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::U32,
|
||||
"usampler2D tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::k2dArray,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::U32,
|
||||
"usampler2DArray tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::k3d,
|
||||
type::TextureDimension::k3d,
|
||||
TextureDataType::U32,
|
||||
"usampler3D tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::kCube,
|
||||
type::TextureDimension::kCube,
|
||||
TextureDataType::U32,
|
||||
"usamplerCube tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::kCubeArray,
|
||||
type::TextureDimension::kCubeArray,
|
||||
TextureDataType::U32,
|
||||
"usamplerCubeArray tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::k1d,
|
||||
type::TextureDimension::k1d,
|
||||
TextureDataType::I32,
|
||||
"isampler1D tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::k2d,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::I32,
|
||||
"isampler2D tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::k2dArray,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::I32,
|
||||
"isampler2DArray tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::k3d,
|
||||
type::TextureDimension::k3d,
|
||||
TextureDataType::I32,
|
||||
"isampler3D tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::kCube,
|
||||
type::TextureDimension::kCube,
|
||||
TextureDataType::I32,
|
||||
"isamplerCube tex;",
|
||||
},
|
||||
GlslSampledTextureData{
|
||||
ast::TextureDimension::kCubeArray,
|
||||
type::TextureDimension::kCubeArray,
|
||||
TextureDataType::I32,
|
||||
"isamplerCubeArray tex;",
|
||||
}));
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
||||
auto* f32 = create<type::F32>();
|
||||
auto* s = create<type::MultisampledTexture>(ast::TextureDimension::k2d, f32);
|
||||
auto* s = create<type::MultisampledTexture>(type::TextureDimension::k2d, f32);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -506,7 +507,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
|||
}
|
||||
|
||||
struct GlslStorageTextureData {
|
||||
ast::TextureDimension dim;
|
||||
type::TextureDimension dim;
|
||||
ast::TexelFormat imgfmt;
|
||||
std::string result;
|
||||
};
|
||||
|
@ -537,31 +538,31 @@ TEST_P(GlslStorageTexturesTest, Emit) {
|
|||
INSTANTIATE_TEST_SUITE_P(
|
||||
GlslGeneratorImplTest_Type,
|
||||
GlslStorageTexturesTest,
|
||||
testing::Values(GlslStorageTextureData{ast::TextureDimension::k1d,
|
||||
testing::Values(GlslStorageTextureData{type::TextureDimension::k1d,
|
||||
ast::TexelFormat::kRgba8Unorm, "image1D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k2d,
|
||||
GlslStorageTextureData{type::TextureDimension::k2d,
|
||||
ast::TexelFormat::kRgba16Float, "image2D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k2dArray,
|
||||
GlslStorageTextureData{type::TextureDimension::k2dArray,
|
||||
ast::TexelFormat::kR32Float, "image2DArray tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k3d, ast::TexelFormat::kRg32Float,
|
||||
"image3D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k1d,
|
||||
GlslStorageTextureData{type::TextureDimension::k3d,
|
||||
ast::TexelFormat::kRg32Float, "image3D tex;"},
|
||||
GlslStorageTextureData{type::TextureDimension::k1d,
|
||||
ast::TexelFormat::kRgba32Float, "image1D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k2d,
|
||||
GlslStorageTextureData{type::TextureDimension::k2d,
|
||||
ast::TexelFormat::kRgba16Uint, "image2D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k2dArray,
|
||||
GlslStorageTextureData{type::TextureDimension::k2dArray,
|
||||
ast::TexelFormat::kR32Uint, "image2DArray tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k3d, ast::TexelFormat::kRg32Uint,
|
||||
GlslStorageTextureData{type::TextureDimension::k3d, ast::TexelFormat::kRg32Uint,
|
||||
"image3D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k1d,
|
||||
GlslStorageTextureData{type::TextureDimension::k1d,
|
||||
ast::TexelFormat::kRgba32Uint, "image1D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k2d,
|
||||
GlslStorageTextureData{type::TextureDimension::k2d,
|
||||
ast::TexelFormat::kRgba16Sint, "image2D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k2dArray,
|
||||
GlslStorageTextureData{type::TextureDimension::k2dArray,
|
||||
ast::TexelFormat::kR32Sint, "image2DArray tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k3d, ast::TexelFormat::kRg32Sint,
|
||||
GlslStorageTextureData{type::TextureDimension::k3d, ast::TexelFormat::kRg32Sint,
|
||||
"image3D tex;"},
|
||||
GlslStorageTextureData{ast::TextureDimension::k1d,
|
||||
GlslStorageTextureData{type::TextureDimension::k1d,
|
||||
ast::TexelFormat::kRgba32Sint, "image1D tex;"}));
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
#include "src/tint/type/multisampled_texture.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/compiler_macros.h"
|
||||
#include "src/tint/utils/defer.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
|
@ -2312,27 +2313,27 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
|||
switch (builtin->Type()) {
|
||||
case sem::BuiltinType::kTextureDimensions:
|
||||
switch (texture_type->dim()) {
|
||||
case ast::TextureDimension::kNone:
|
||||
case type::TextureDimension::kNone:
|
||||
TINT_ICE(Writer, diagnostics_) << "texture dimension is kNone";
|
||||
return false;
|
||||
case ast::TextureDimension::k1d:
|
||||
case type::TextureDimension::k1d:
|
||||
num_dimensions = 1;
|
||||
break;
|
||||
case ast::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2d:
|
||||
num_dimensions = is_ms ? 3 : 2;
|
||||
swizzle = is_ms ? ".xy" : "";
|
||||
break;
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k2dArray:
|
||||
num_dimensions = is_ms ? 4 : 3;
|
||||
swizzle = ".xy";
|
||||
break;
|
||||
case ast::TextureDimension::k3d:
|
||||
case type::TextureDimension::k3d:
|
||||
num_dimensions = 3;
|
||||
break;
|
||||
case ast::TextureDimension::kCube:
|
||||
case type::TextureDimension::kCube:
|
||||
num_dimensions = 2;
|
||||
break;
|
||||
case ast::TextureDimension::kCubeArray:
|
||||
case type::TextureDimension::kCubeArray:
|
||||
num_dimensions = 3;
|
||||
swizzle = ".xy";
|
||||
break;
|
||||
|
@ -2343,11 +2344,11 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
|||
default:
|
||||
TINT_ICE(Writer, diagnostics_) << "texture dimension is not arrayed";
|
||||
return false;
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k2dArray:
|
||||
num_dimensions = is_ms ? 4 : 3;
|
||||
swizzle = ".z";
|
||||
break;
|
||||
case ast::TextureDimension::kCubeArray:
|
||||
case type::TextureDimension::kCubeArray:
|
||||
num_dimensions = 3;
|
||||
swizzle = ".z";
|
||||
break;
|
||||
|
@ -2359,18 +2360,18 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
|||
TINT_ICE(Writer, diagnostics_)
|
||||
<< "texture dimension does not support mips";
|
||||
return false;
|
||||
case ast::TextureDimension::k1d:
|
||||
case type::TextureDimension::k1d:
|
||||
num_dimensions = 2;
|
||||
swizzle = ".y";
|
||||
break;
|
||||
case ast::TextureDimension::k2d:
|
||||
case ast::TextureDimension::kCube:
|
||||
case type::TextureDimension::k2d:
|
||||
case type::TextureDimension::kCube:
|
||||
num_dimensions = 3;
|
||||
swizzle = ".z";
|
||||
break;
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case ast::TextureDimension::k3d:
|
||||
case ast::TextureDimension::kCubeArray:
|
||||
case type::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k3d:
|
||||
case type::TextureDimension::kCubeArray:
|
||||
num_dimensions = 4;
|
||||
swizzle = ".w";
|
||||
break;
|
||||
|
@ -2382,11 +2383,11 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
|||
TINT_ICE(Writer, diagnostics_)
|
||||
<< "texture dimension does not support multisampling";
|
||||
return false;
|
||||
case ast::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2d:
|
||||
num_dimensions = 3;
|
||||
swizzle = ".z";
|
||||
break;
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k2dArray:
|
||||
num_dimensions = 4;
|
||||
swizzle = ".w";
|
||||
break;
|
||||
|
@ -4051,22 +4052,22 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
|||
out << "Texture";
|
||||
|
||||
switch (tex->dim()) {
|
||||
case ast::TextureDimension::k1d:
|
||||
case type::TextureDimension::k1d:
|
||||
out << "1D";
|
||||
break;
|
||||
case ast::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2d:
|
||||
out << ((ms || depth_ms) ? "2DMS" : "2D");
|
||||
break;
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k2dArray:
|
||||
out << ((ms || depth_ms) ? "2DMSArray" : "2DArray");
|
||||
break;
|
||||
case ast::TextureDimension::k3d:
|
||||
case type::TextureDimension::k3d:
|
||||
out << "3D";
|
||||
break;
|
||||
case ast::TextureDimension::kCube:
|
||||
case type::TextureDimension::kCube:
|
||||
out << "Cube";
|
||||
break;
|
||||
case ast::TextureDimension::kCubeArray:
|
||||
case type::TextureDimension::kCubeArray:
|
||||
out << "CubeArray";
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/sampler.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/writer/hlsl/test_helper.h"
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
|
@ -295,7 +296,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitSamplerComparison) {
|
|||
}
|
||||
|
||||
struct HlslDepthTextureData {
|
||||
ast::TextureDimension dim;
|
||||
type::TextureDimension dim;
|
||||
std::string result;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, HlslDepthTextureData data) {
|
||||
|
@ -326,18 +327,18 @@ TEST_P(HlslDepthTexturesTest, Emit) {
|
|||
INSTANTIATE_TEST_SUITE_P(
|
||||
HlslGeneratorImplTest_Type,
|
||||
HlslDepthTexturesTest,
|
||||
testing::Values(HlslDepthTextureData{ast::TextureDimension::k2d,
|
||||
testing::Values(HlslDepthTextureData{type::TextureDimension::k2d,
|
||||
"Texture2D tex : register(t1, space2);"},
|
||||
HlslDepthTextureData{ast::TextureDimension::k2dArray,
|
||||
HlslDepthTextureData{type::TextureDimension::k2dArray,
|
||||
"Texture2DArray tex : register(t1, space2);"},
|
||||
HlslDepthTextureData{ast::TextureDimension::kCube,
|
||||
HlslDepthTextureData{type::TextureDimension::kCube,
|
||||
"TextureCube tex : register(t1, space2);"},
|
||||
HlslDepthTextureData{ast::TextureDimension::kCubeArray,
|
||||
HlslDepthTextureData{type::TextureDimension::kCubeArray,
|
||||
"TextureCubeArray tex : register(t1, space2);"}));
|
||||
|
||||
using HlslDepthMultisampledTexturesTest = TestHelper;
|
||||
TEST_F(HlslDepthMultisampledTexturesTest, Emit) {
|
||||
auto* t = ty.depth_multisampled_texture(ast::TextureDimension::k2d);
|
||||
auto* t = ty.depth_multisampled_texture(type::TextureDimension::k2d);
|
||||
|
||||
GlobalVar("tex", t, Binding(1_a), Group(2_a));
|
||||
|
||||
|
@ -357,7 +358,7 @@ TEST_F(HlslDepthMultisampledTexturesTest, Emit) {
|
|||
|
||||
enum class TextureDataType { F32, U32, I32 };
|
||||
struct HlslSampledTextureData {
|
||||
ast::TextureDimension dim;
|
||||
type::TextureDimension dim;
|
||||
TextureDataType datatype;
|
||||
std::string result;
|
||||
};
|
||||
|
@ -402,99 +403,99 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Type,
|
|||
HlslSampledTexturesTest,
|
||||
testing::Values(
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::k1d,
|
||||
type::TextureDimension::k1d,
|
||||
TextureDataType::F32,
|
||||
"Texture1D<float4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::k2d,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::F32,
|
||||
"Texture2D<float4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::k2dArray,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::F32,
|
||||
"Texture2DArray<float4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::k3d,
|
||||
type::TextureDimension::k3d,
|
||||
TextureDataType::F32,
|
||||
"Texture3D<float4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::kCube,
|
||||
type::TextureDimension::kCube,
|
||||
TextureDataType::F32,
|
||||
"TextureCube<float4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::kCubeArray,
|
||||
type::TextureDimension::kCubeArray,
|
||||
TextureDataType::F32,
|
||||
"TextureCubeArray<float4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::k1d,
|
||||
type::TextureDimension::k1d,
|
||||
TextureDataType::U32,
|
||||
"Texture1D<uint4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::k2d,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::U32,
|
||||
"Texture2D<uint4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::k2dArray,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::U32,
|
||||
"Texture2DArray<uint4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::k3d,
|
||||
type::TextureDimension::k3d,
|
||||
TextureDataType::U32,
|
||||
"Texture3D<uint4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::kCube,
|
||||
type::TextureDimension::kCube,
|
||||
TextureDataType::U32,
|
||||
"TextureCube<uint4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::kCubeArray,
|
||||
type::TextureDimension::kCubeArray,
|
||||
TextureDataType::U32,
|
||||
"TextureCubeArray<uint4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::k1d,
|
||||
type::TextureDimension::k1d,
|
||||
TextureDataType::I32,
|
||||
"Texture1D<int4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::k2d,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::I32,
|
||||
"Texture2D<int4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::k2dArray,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::I32,
|
||||
"Texture2DArray<int4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::k3d,
|
||||
type::TextureDimension::k3d,
|
||||
TextureDataType::I32,
|
||||
"Texture3D<int4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::kCube,
|
||||
type::TextureDimension::kCube,
|
||||
TextureDataType::I32,
|
||||
"TextureCube<int4> tex : register(t1, space2);",
|
||||
},
|
||||
HlslSampledTextureData{
|
||||
ast::TextureDimension::kCubeArray,
|
||||
type::TextureDimension::kCubeArray,
|
||||
TextureDataType::I32,
|
||||
"TextureCubeArray<int4> tex : register(t1, space2);",
|
||||
}));
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
||||
auto* f32 = create<type::F32>();
|
||||
auto* s = create<type::MultisampledTexture>(ast::TextureDimension::k2d, f32);
|
||||
auto* s = create<type::MultisampledTexture>(type::TextureDimension::k2d, f32);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -505,7 +506,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
|||
}
|
||||
|
||||
struct HlslStorageTextureData {
|
||||
ast::TextureDimension dim;
|
||||
type::TextureDimension dim;
|
||||
ast::TexelFormat imgfmt;
|
||||
std::string result;
|
||||
};
|
||||
|
@ -542,31 +543,31 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
HlslGeneratorImplTest_Type,
|
||||
HlslStorageTexturesTest,
|
||||
testing::Values(
|
||||
HlslStorageTextureData{ast::TextureDimension::k1d, ast::TexelFormat::kRgba8Unorm,
|
||||
HlslStorageTextureData{type::TextureDimension::k1d, ast::TexelFormat::kRgba8Unorm,
|
||||
"RWTexture1D<float4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{ast::TextureDimension::k2d, ast::TexelFormat::kRgba16Float,
|
||||
HlslStorageTextureData{type::TextureDimension::k2d, ast::TexelFormat::kRgba16Float,
|
||||
"RWTexture2D<float4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{ast::TextureDimension::k2dArray, ast::TexelFormat::kR32Float,
|
||||
HlslStorageTextureData{type::TextureDimension::k2dArray, ast::TexelFormat::kR32Float,
|
||||
"RWTexture2DArray<float4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{ast::TextureDimension::k3d, ast::TexelFormat::kRg32Float,
|
||||
HlslStorageTextureData{type::TextureDimension::k3d, ast::TexelFormat::kRg32Float,
|
||||
"RWTexture3D<float4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{ast::TextureDimension::k1d, ast::TexelFormat::kRgba32Float,
|
||||
HlslStorageTextureData{type::TextureDimension::k1d, ast::TexelFormat::kRgba32Float,
|
||||
"RWTexture1D<float4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{ast::TextureDimension::k2d, ast::TexelFormat::kRgba16Uint,
|
||||
HlslStorageTextureData{type::TextureDimension::k2d, ast::TexelFormat::kRgba16Uint,
|
||||
"RWTexture2D<uint4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{ast::TextureDimension::k2dArray, ast::TexelFormat::kR32Uint,
|
||||
HlslStorageTextureData{type::TextureDimension::k2dArray, ast::TexelFormat::kR32Uint,
|
||||
"RWTexture2DArray<uint4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{ast::TextureDimension::k3d, ast::TexelFormat::kRg32Uint,
|
||||
HlslStorageTextureData{type::TextureDimension::k3d, ast::TexelFormat::kRg32Uint,
|
||||
"RWTexture3D<uint4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{ast::TextureDimension::k1d, ast::TexelFormat::kRgba32Uint,
|
||||
HlslStorageTextureData{type::TextureDimension::k1d, ast::TexelFormat::kRgba32Uint,
|
||||
"RWTexture1D<uint4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{ast::TextureDimension::k2d, ast::TexelFormat::kRgba16Sint,
|
||||
HlslStorageTextureData{type::TextureDimension::k2d, ast::TexelFormat::kRgba16Sint,
|
||||
"RWTexture2D<int4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{ast::TextureDimension::k2dArray, ast::TexelFormat::kR32Sint,
|
||||
HlslStorageTextureData{type::TextureDimension::k2dArray, ast::TexelFormat::kR32Sint,
|
||||
"RWTexture2DArray<int4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{ast::TextureDimension::k3d, ast::TexelFormat::kRg32Sint,
|
||||
HlslStorageTextureData{type::TextureDimension::k3d, ast::TexelFormat::kRg32Sint,
|
||||
"RWTexture3D<int4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{ast::TextureDimension::k1d, ast::TexelFormat::kRgba32Sint,
|
||||
HlslStorageTextureData{type::TextureDimension::k1d, ast::TexelFormat::kRgba32Sint,
|
||||
"RWTexture1D<int4> tex : register(u1, space2);"}));
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
#include "src/tint/type/reference.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/type/u32.h"
|
||||
#include "src/tint/type/vector.h"
|
||||
#include "src/tint/type/void.h"
|
||||
|
@ -1020,25 +1021,25 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
|||
};
|
||||
|
||||
// MSL requires that `lod` is a constant 0 for 1D textures.
|
||||
bool level_is_constant_zero = texture_type->dim() == ast::TextureDimension::k1d;
|
||||
bool level_is_constant_zero = texture_type->dim() == type::TextureDimension::k1d;
|
||||
|
||||
switch (builtin->Type()) {
|
||||
case sem::BuiltinType::kTextureDimensions: {
|
||||
std::vector<const char*> dims;
|
||||
switch (texture_type->dim()) {
|
||||
case ast::TextureDimension::kNone:
|
||||
case type::TextureDimension::kNone:
|
||||
diagnostics_.add_error(diag::System::Writer, "texture dimension is kNone");
|
||||
return false;
|
||||
case ast::TextureDimension::k1d:
|
||||
case type::TextureDimension::k1d:
|
||||
dims = {"width"};
|
||||
break;
|
||||
case ast::TextureDimension::k2d:
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case ast::TextureDimension::kCube:
|
||||
case ast::TextureDimension::kCubeArray:
|
||||
case type::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::kCube:
|
||||
case type::TextureDimension::kCubeArray:
|
||||
dims = {"width", "height"};
|
||||
break;
|
||||
case ast::TextureDimension::k3d:
|
||||
case type::TextureDimension::k3d:
|
||||
dims = {"width", "height", "depth"};
|
||||
break;
|
||||
}
|
||||
|
@ -1155,14 +1156,14 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
|||
if (usage == Usage::kCoords && e->Type()->UnwrapRef()->is_integer_scalar_or_vector()) {
|
||||
casted = true;
|
||||
switch (texture_type->dim()) {
|
||||
case ast::TextureDimension::k1d:
|
||||
case type::TextureDimension::k1d:
|
||||
out << "uint(";
|
||||
break;
|
||||
case ast::TextureDimension::k2d:
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2dArray:
|
||||
out << "uint2(";
|
||||
break;
|
||||
case ast::TextureDimension::k3d:
|
||||
case type::TextureDimension::k3d:
|
||||
out << "uint3(";
|
||||
break;
|
||||
default:
|
||||
|
@ -1212,17 +1213,17 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
|||
if (auto* ddx = arg(Usage::kDdx)) {
|
||||
auto dim = texture_type->dim();
|
||||
switch (dim) {
|
||||
case ast::TextureDimension::k2d:
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2dArray:
|
||||
maybe_write_comma();
|
||||
out << "gradient2d(";
|
||||
break;
|
||||
case ast::TextureDimension::k3d:
|
||||
case type::TextureDimension::k3d:
|
||||
maybe_write_comma();
|
||||
out << "gradient3d(";
|
||||
break;
|
||||
case ast::TextureDimension::kCube:
|
||||
case ast::TextureDimension::kCubeArray:
|
||||
case type::TextureDimension::kCube:
|
||||
case type::TextureDimension::kCubeArray:
|
||||
maybe_write_comma();
|
||||
out << "gradientcube(";
|
||||
break;
|
||||
|
@ -1257,8 +1258,8 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
|||
if (!has_offset) {
|
||||
// offset argument may need to be provided if we have a component.
|
||||
switch (texture_type->dim()) {
|
||||
case ast::TextureDimension::k2d:
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2dArray:
|
||||
out << "int2(0), ";
|
||||
break;
|
||||
default:
|
||||
|
@ -2624,22 +2625,22 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
|||
}
|
||||
|
||||
switch (tex->dim()) {
|
||||
case ast::TextureDimension::k1d:
|
||||
case type::TextureDimension::k1d:
|
||||
out << "1d";
|
||||
break;
|
||||
case ast::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2d:
|
||||
out << "2d";
|
||||
break;
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k2dArray:
|
||||
out << "2d_array";
|
||||
break;
|
||||
case ast::TextureDimension::k3d:
|
||||
case type::TextureDimension::k3d:
|
||||
out << "3d";
|
||||
break;
|
||||
case ast::TextureDimension::kCube:
|
||||
case type::TextureDimension::kCube:
|
||||
out << "cube";
|
||||
break;
|
||||
case ast::TextureDimension::kCubeArray:
|
||||
case type::TextureDimension::kCubeArray:
|
||||
out << "cube_array";
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/sampler.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/writer/msl/test_helper.h"
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
|
@ -750,7 +751,7 @@ TEST_F(MslGeneratorImplTest, EmitType_SamplerComparison) {
|
|||
}
|
||||
|
||||
struct MslDepthTextureData {
|
||||
ast::TextureDimension dim;
|
||||
type::TextureDimension dim;
|
||||
std::string result;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, MslDepthTextureData data) {
|
||||
|
@ -773,16 +774,16 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
MslGeneratorImplTest,
|
||||
MslDepthTexturesTest,
|
||||
testing::Values(
|
||||
MslDepthTextureData{ast::TextureDimension::k2d, "depth2d<float, access::sample>"},
|
||||
MslDepthTextureData{ast::TextureDimension::k2dArray,
|
||||
MslDepthTextureData{type::TextureDimension::k2d, "depth2d<float, access::sample>"},
|
||||
MslDepthTextureData{type::TextureDimension::k2dArray,
|
||||
"depth2d_array<float, access::sample>"},
|
||||
MslDepthTextureData{ast::TextureDimension::kCube, "depthcube<float, access::sample>"},
|
||||
MslDepthTextureData{ast::TextureDimension::kCubeArray,
|
||||
MslDepthTextureData{type::TextureDimension::kCube, "depthcube<float, access::sample>"},
|
||||
MslDepthTextureData{type::TextureDimension::kCubeArray,
|
||||
"depthcube_array<float, access::sample>"}));
|
||||
|
||||
using MslDepthMultisampledTexturesTest = TestHelper;
|
||||
TEST_F(MslDepthMultisampledTexturesTest, Emit) {
|
||||
type::DepthMultisampledTexture s(ast::TextureDimension::k2d);
|
||||
type::DepthMultisampledTexture s(type::TextureDimension::k2d);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -792,7 +793,7 @@ TEST_F(MslDepthMultisampledTexturesTest, Emit) {
|
|||
}
|
||||
|
||||
struct MslTextureData {
|
||||
ast::TextureDimension dim;
|
||||
type::TextureDimension dim;
|
||||
std::string result;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, MslTextureData data) {
|
||||
|
@ -816,17 +817,17 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
MslGeneratorImplTest,
|
||||
MslSampledtexturesTest,
|
||||
testing::Values(
|
||||
MslTextureData{ast::TextureDimension::k1d, "texture1d<float, access::sample>"},
|
||||
MslTextureData{ast::TextureDimension::k2d, "texture2d<float, access::sample>"},
|
||||
MslTextureData{ast::TextureDimension::k2dArray, "texture2d_array<float, access::sample>"},
|
||||
MslTextureData{ast::TextureDimension::k3d, "texture3d<float, access::sample>"},
|
||||
MslTextureData{ast::TextureDimension::kCube, "texturecube<float, access::sample>"},
|
||||
MslTextureData{ast::TextureDimension::kCubeArray,
|
||||
MslTextureData{type::TextureDimension::k1d, "texture1d<float, access::sample>"},
|
||||
MslTextureData{type::TextureDimension::k2d, "texture2d<float, access::sample>"},
|
||||
MslTextureData{type::TextureDimension::k2dArray, "texture2d_array<float, access::sample>"},
|
||||
MslTextureData{type::TextureDimension::k3d, "texture3d<float, access::sample>"},
|
||||
MslTextureData{type::TextureDimension::kCube, "texturecube<float, access::sample>"},
|
||||
MslTextureData{type::TextureDimension::kCubeArray,
|
||||
"texturecube_array<float, access::sample>"}));
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) {
|
||||
auto* u32 = create<type::U32>();
|
||||
auto* ms = create<type::MultisampledTexture>(ast::TextureDimension::k2d, u32);
|
||||
auto* ms = create<type::MultisampledTexture>(type::TextureDimension::k2d, u32);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -836,7 +837,7 @@ TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) {
|
|||
}
|
||||
|
||||
struct MslStorageTextureData {
|
||||
ast::TextureDimension dim;
|
||||
type::TextureDimension dim;
|
||||
std::string result;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, MslStorageTextureData data) {
|
||||
|
@ -859,11 +860,11 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
MslGeneratorImplTest,
|
||||
MslStorageTexturesTest,
|
||||
testing::Values(
|
||||
MslStorageTextureData{ast::TextureDimension::k1d, "texture1d<float, access::write>"},
|
||||
MslStorageTextureData{ast::TextureDimension::k2d, "texture2d<float, access::write>"},
|
||||
MslStorageTextureData{ast::TextureDimension::k2dArray,
|
||||
MslStorageTextureData{type::TextureDimension::k1d, "texture1d<float, access::write>"},
|
||||
MslStorageTextureData{type::TextureDimension::k2d, "texture2d<float, access::write>"},
|
||||
MslStorageTextureData{type::TextureDimension::k2dArray,
|
||||
"texture2d_array<float, access::write>"},
|
||||
MslStorageTextureData{ast::TextureDimension::k3d, "texture3d<float, access::write>"}));
|
||||
MslStorageTextureData{type::TextureDimension::k3d, "texture3d<float, access::write>"}));
|
||||
|
||||
} // namespace
|
||||
} // namespace tint::writer::msl
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "src/tint/type/multisampled_texture.h"
|
||||
#include "src/tint/type/reference.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/type/vector.h"
|
||||
#include "src/tint/utils/compiler_macros.h"
|
||||
#include "src/tint/utils/defer.h"
|
||||
|
@ -2785,16 +2786,16 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call,
|
|||
std::vector<uint32_t> swizzle;
|
||||
uint32_t spirv_dims = 0;
|
||||
switch (texture_type->dim()) {
|
||||
case ast::TextureDimension::kNone:
|
||||
case type::TextureDimension::kNone:
|
||||
error_ = "texture dimension is kNone";
|
||||
return false;
|
||||
case ast::TextureDimension::k1d:
|
||||
case ast::TextureDimension::k2d:
|
||||
case ast::TextureDimension::k3d:
|
||||
case ast::TextureDimension::kCube:
|
||||
case type::TextureDimension::k1d:
|
||||
case type::TextureDimension::k2d:
|
||||
case type::TextureDimension::k3d:
|
||||
case type::TextureDimension::kCube:
|
||||
break; // No swizzle needed
|
||||
case ast::TextureDimension::kCubeArray:
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::kCubeArray:
|
||||
case type::TextureDimension::k2dArray:
|
||||
swizzle = {0, 1}; // Strip array index
|
||||
spirv_dims = 3; // [width, height, array_count]
|
||||
break;
|
||||
|
@ -2825,8 +2826,8 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call,
|
|||
default:
|
||||
error_ = "texture is not arrayed";
|
||||
return false;
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case ast::TextureDimension::kCubeArray:
|
||||
case type::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::kCubeArray:
|
||||
spirv_dims = 3;
|
||||
break;
|
||||
}
|
||||
|
@ -3764,12 +3765,12 @@ bool Builder::GenerateTextureType(const type::Texture* texture, const Operand& r
|
|||
|
||||
uint32_t array_literal = 0u;
|
||||
const auto dim = texture->dim();
|
||||
if (dim == ast::TextureDimension::k2dArray || dim == ast::TextureDimension::kCubeArray) {
|
||||
if (dim == type::TextureDimension::k2dArray || dim == type::TextureDimension::kCubeArray) {
|
||||
array_literal = 1u;
|
||||
}
|
||||
|
||||
uint32_t dim_literal = SpvDim2D;
|
||||
if (dim == ast::TextureDimension::k1d) {
|
||||
if (dim == type::TextureDimension::k1d) {
|
||||
dim_literal = SpvDim1D;
|
||||
if (texture->Is<type::SampledTexture>()) {
|
||||
push_capability(SpvCapabilitySampled1D);
|
||||
|
@ -3777,10 +3778,10 @@ bool Builder::GenerateTextureType(const type::Texture* texture, const Operand& r
|
|||
push_capability(SpvCapabilityImage1D);
|
||||
}
|
||||
}
|
||||
if (dim == ast::TextureDimension::k3d) {
|
||||
if (dim == type::TextureDimension::k3d) {
|
||||
dim_literal = SpvDim3D;
|
||||
}
|
||||
if (dim == ast::TextureDimension::kCube || dim == ast::TextureDimension::kCubeArray) {
|
||||
if (dim == type::TextureDimension::kCube || dim == type::TextureDimension::kCubeArray) {
|
||||
dim_literal = SpvDimCube;
|
||||
}
|
||||
|
||||
|
@ -3800,7 +3801,7 @@ bool Builder::GenerateTextureType(const type::Texture* texture, const Operand& r
|
|||
sampled_literal = 1u;
|
||||
}
|
||||
|
||||
if (dim == ast::TextureDimension::kCubeArray) {
|
||||
if (dim == type::TextureDimension::kCubeArray) {
|
||||
if (texture->IsAnyOf<type::SampledTexture, type::DepthTexture>()) {
|
||||
push_capability(SpvCapabilitySampledCubeArray);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "src/tint/ast/call_statement.h"
|
||||
#include "src/tint/ast/stage_attribute.h"
|
||||
#include "src/tint/type/depth_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/string.h"
|
||||
#include "src/tint/writer/spirv/spv_dump.h"
|
||||
#include "src/tint/writer/spirv/test_helper.h"
|
||||
|
@ -41,7 +42,7 @@ inline std::ostream& operator<<(std::ostream& out, BuiltinData data) {
|
|||
// This tests that we do not push OpTypeSampledImage and float_0 type twice.
|
||||
TEST_F(BuiltinBuilderTest, Call_TextureSampleCompare_Twice) {
|
||||
auto* s = ty.sampler(ast::SamplerKind::kComparisonSampler);
|
||||
auto* t = ty.depth_texture(ast::TextureDimension::k2d);
|
||||
auto* t = ty.depth_texture(type::TextureDimension::k2d);
|
||||
|
||||
auto* tex = GlobalVar("texture", t, Binding(0_a), Group(0_a));
|
||||
auto* sampler = GlobalVar("sampler", s, Binding(1_a), Group(0_a));
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "src/tint/ast/id_attribute.h"
|
||||
#include "src/tint/ast/stage_attribute.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/writer/spirv/spv_dump.h"
|
||||
#include "src/tint/writer/spirv/test_helper.h"
|
||||
|
||||
|
@ -469,7 +470,7 @@ OpName %9 "unused_entry_point"
|
|||
TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) {
|
||||
// var<uniform_constant> a : texture_storage_2d<r32uint, write>;
|
||||
|
||||
auto* type = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
auto* type = ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
ast::Access::kWrite);
|
||||
|
||||
auto* var_a = GlobalVar("a", type, Binding(0_a), Group(0_a));
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "src/tint/type/depth_texture.h"
|
||||
#include "src/tint/type/multisampled_texture.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/writer/spirv/spv_dump.h"
|
||||
#include "src/tint/writer/spirv/test_helper.h"
|
||||
|
||||
|
@ -631,7 +632,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
PtrData{ast::AddressSpace::kFunction, SpvStorageClassFunction}));
|
||||
|
||||
TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) {
|
||||
auto* two_d = create<type::DepthTexture>(ast::TextureDimension::k2d);
|
||||
auto* two_d = create<type::DepthTexture>(type::TextureDimension::k2d);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -645,7 +646,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, DepthTexture_Generate_2dArray) {
|
||||
auto* two_d_array = create<type::DepthTexture>(ast::TextureDimension::k2dArray);
|
||||
auto* two_d_array = create<type::DepthTexture>(type::TextureDimension::k2dArray);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -659,7 +660,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_2dArray) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) {
|
||||
auto* cube = create<type::DepthTexture>(ast::TextureDimension::kCube);
|
||||
auto* cube = create<type::DepthTexture>(type::TextureDimension::kCube);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -674,7 +675,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) {
|
||||
auto* cube_array = create<type::DepthTexture>(ast::TextureDimension::kCubeArray);
|
||||
auto* cube_array = create<type::DepthTexture>(type::TextureDimension::kCubeArray);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -692,7 +693,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) {
|
|||
|
||||
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) {
|
||||
auto* i32 = create<type::I32>();
|
||||
auto* ms = create<type::MultisampledTexture>(ast::TextureDimension::k2d, i32);
|
||||
auto* ms = create<type::MultisampledTexture>(type::TextureDimension::k2d, i32);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -705,7 +706,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) {
|
|||
|
||||
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) {
|
||||
auto* u32 = create<type::U32>();
|
||||
auto* ms = create<type::MultisampledTexture>(ast::TextureDimension::k2d, u32);
|
||||
auto* ms = create<type::MultisampledTexture>(type::TextureDimension::k2d, u32);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -719,7 +720,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) {
|
|||
|
||||
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) {
|
||||
auto* f32 = create<type::F32>();
|
||||
auto* ms = create<type::MultisampledTexture>(ast::TextureDimension::k2d, f32);
|
||||
auto* ms = create<type::MultisampledTexture>(type::TextureDimension::k2d, f32);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -732,7 +733,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) {
|
||||
auto* s = create<type::SampledTexture>(ast::TextureDimension::k1d, create<type::I32>());
|
||||
auto* s = create<type::SampledTexture>(type::TextureDimension::k1d, create<type::I32>());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -750,7 +751,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) {
|
|||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) {
|
||||
auto* u32 = create<type::U32>();
|
||||
auto* s = create<type::SampledTexture>(ast::TextureDimension::k1d, u32);
|
||||
auto* s = create<type::SampledTexture>(type::TextureDimension::k1d, u32);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -768,7 +769,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) {
|
|||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) {
|
||||
auto* f32 = create<type::F32>();
|
||||
auto* s = create<type::SampledTexture>(ast::TextureDimension::k1d, f32);
|
||||
auto* s = create<type::SampledTexture>(type::TextureDimension::k1d, f32);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -786,7 +787,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) {
|
|||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) {
|
||||
auto* f32 = create<type::F32>();
|
||||
auto* s = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
|
||||
auto* s = create<type::SampledTexture>(type::TextureDimension::k2d, f32);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -800,7 +801,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) {
|
|||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
|
||||
auto* f32 = create<type::F32>();
|
||||
auto* s = create<type::SampledTexture>(ast::TextureDimension::k2dArray, f32);
|
||||
auto* s = create<type::SampledTexture>(type::TextureDimension::k2dArray, f32);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -814,7 +815,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
|
|||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) {
|
||||
auto* f32 = create<type::F32>();
|
||||
auto* s = create<type::SampledTexture>(ast::TextureDimension::k3d, f32);
|
||||
auto* s = create<type::SampledTexture>(type::TextureDimension::k3d, f32);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -828,7 +829,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) {
|
|||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) {
|
||||
auto* f32 = create<type::F32>();
|
||||
auto* s = create<type::SampledTexture>(ast::TextureDimension::kCube, f32);
|
||||
auto* s = create<type::SampledTexture>(type::TextureDimension::kCube, f32);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -843,7 +844,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) {
|
|||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
|
||||
auto* f32 = create<type::F32>();
|
||||
auto* s = create<type::SampledTexture>(ast::TextureDimension::kCubeArray, f32);
|
||||
auto* s = create<type::SampledTexture>(type::TextureDimension::kCubeArray, f32);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -859,7 +860,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) {
|
||||
auto* s = ty.storage_texture(ast::TextureDimension::k1d, ast::TexelFormat::kR32Float,
|
||||
auto* s = ty.storage_texture(type::TextureDimension::k1d, ast::TexelFormat::kR32Float,
|
||||
ast::Access::kWrite);
|
||||
|
||||
GlobalVar("test_var", s, Binding(0_a), Group(0_a));
|
||||
|
@ -874,7 +875,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
|
||||
auto* s = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float,
|
||||
auto* s = ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float,
|
||||
ast::Access::kWrite);
|
||||
|
||||
GlobalVar("test_var", s, Binding(0_a), Group(0_a));
|
||||
|
@ -889,7 +890,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
|
||||
auto* s = ty.storage_texture(ast::TextureDimension::k2dArray, ast::TexelFormat::kR32Float,
|
||||
auto* s = ty.storage_texture(type::TextureDimension::k2dArray, ast::TexelFormat::kR32Float,
|
||||
ast::Access::kWrite);
|
||||
|
||||
GlobalVar("test_var", s, Binding(0_a), Group(0_a));
|
||||
|
@ -904,7 +905,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
|
||||
auto* s = ty.storage_texture(ast::TextureDimension::k3d, ast::TexelFormat::kR32Float,
|
||||
auto* s = ty.storage_texture(type::TextureDimension::k3d, ast::TexelFormat::kR32Float,
|
||||
ast::Access::kWrite);
|
||||
|
||||
GlobalVar("test_var", s, Binding(0_a), Group(0_a));
|
||||
|
@ -919,7 +920,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeFloat_Format_r32float) {
|
||||
auto* s = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float,
|
||||
auto* s = ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Float,
|
||||
ast::Access::kWrite);
|
||||
|
||||
GlobalVar("test_var", s, Binding(0_a), Group(0_a));
|
||||
|
@ -934,7 +935,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeFloat_Format_r32floa
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeSint_Format_r32sint) {
|
||||
auto* s = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Sint,
|
||||
auto* s = ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Sint,
|
||||
ast::Access::kWrite);
|
||||
|
||||
GlobalVar("test_var", s, Binding(0_a), Group(0_a));
|
||||
|
@ -949,7 +950,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeSint_Format_r32sint)
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeUint_Format_r32uint) {
|
||||
auto* s = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
auto* s = ty.storage_texture(type::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
|
||||
ast::Access::kWrite);
|
||||
|
||||
GlobalVar("test_var", s, Binding(0_a), Group(0_a));
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "src/tint/ast/workgroup_attribute.h"
|
||||
#include "src/tint/sem/struct.h"
|
||||
#include "src/tint/sem/switch_statement.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/math.h"
|
||||
#include "src/tint/utils/scoped_assignment.h"
|
||||
#include "src/tint/writer/float_to_string.h"
|
||||
|
@ -500,22 +501,22 @@ bool GeneratorImpl::EmitType(std::ostream& out, const ast::Type* ty) {
|
|||
}
|
||||
|
||||
switch (texture->dim) {
|
||||
case ast::TextureDimension::k1d:
|
||||
case type::TextureDimension::k1d:
|
||||
out << "1d";
|
||||
break;
|
||||
case ast::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2d:
|
||||
out << "2d";
|
||||
break;
|
||||
case ast::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k2dArray:
|
||||
out << "2d_array";
|
||||
break;
|
||||
case ast::TextureDimension::k3d:
|
||||
case type::TextureDimension::k3d:
|
||||
out << "3d";
|
||||
break;
|
||||
case ast::TextureDimension::kCube:
|
||||
case type::TextureDimension::kCube:
|
||||
out << "cube";
|
||||
break;
|
||||
case ast::TextureDimension::kCubeArray:
|
||||
case type::TextureDimension::kCubeArray:
|
||||
out << "cube_array";
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "src/tint/ast/stage_attribute.h"
|
||||
#include "src/tint/ast/variable_decl_statement.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/writer/wgsl/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
@ -116,7 +117,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_Global_Texture) {
|
||||
auto* st = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
auto* st = ty.sampled_texture(type::TextureDimension::k1d, ty.f32());
|
||||
GlobalVar("t", st, Group(0_a), Binding(0_a));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "src/tint/type/depth_texture.h"
|
||||
#include "src/tint/type/multisampled_texture.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/writer/wgsl/test_helper.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
@ -329,7 +330,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Vector_F16) {
|
|||
}
|
||||
|
||||
struct TextureData {
|
||||
ast::TextureDimension dim;
|
||||
type::TextureDimension dim;
|
||||
const char* name;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, TextureData data) {
|
||||
|
@ -353,10 +354,10 @@ TEST_P(WgslGenerator_DepthTextureTest, EmitType_DepthTexture) {
|
|||
INSTANTIATE_TEST_SUITE_P(
|
||||
WgslGeneratorImplTest,
|
||||
WgslGenerator_DepthTextureTest,
|
||||
testing::Values(TextureData{ast::TextureDimension::k2d, "texture_depth_2d"},
|
||||
TextureData{ast::TextureDimension::k2dArray, "texture_depth_2d_array"},
|
||||
TextureData{ast::TextureDimension::kCube, "texture_depth_cube"},
|
||||
TextureData{ast::TextureDimension::kCubeArray, "texture_depth_cube_array"}));
|
||||
testing::Values(TextureData{type::TextureDimension::k2d, "texture_depth_2d"},
|
||||
TextureData{type::TextureDimension::k2dArray, "texture_depth_2d_array"},
|
||||
TextureData{type::TextureDimension::kCube, "texture_depth_cube"},
|
||||
TextureData{type::TextureDimension::kCubeArray, "texture_depth_cube_array"}));
|
||||
|
||||
using WgslGenerator_SampledTextureTest = TestParamHelper<TextureData>;
|
||||
TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_F32) {
|
||||
|
@ -400,12 +401,12 @@ TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_U32) {
|
|||
INSTANTIATE_TEST_SUITE_P(
|
||||
WgslGeneratorImplTest,
|
||||
WgslGenerator_SampledTextureTest,
|
||||
testing::Values(TextureData{ast::TextureDimension::k1d, "texture_1d"},
|
||||
TextureData{ast::TextureDimension::k2d, "texture_2d"},
|
||||
TextureData{ast::TextureDimension::k2dArray, "texture_2d_array"},
|
||||
TextureData{ast::TextureDimension::k3d, "texture_3d"},
|
||||
TextureData{ast::TextureDimension::kCube, "texture_cube"},
|
||||
TextureData{ast::TextureDimension::kCubeArray, "texture_cube_array"}));
|
||||
testing::Values(TextureData{type::TextureDimension::k1d, "texture_1d"},
|
||||
TextureData{type::TextureDimension::k2d, "texture_2d"},
|
||||
TextureData{type::TextureDimension::k2dArray, "texture_2d_array"},
|
||||
TextureData{type::TextureDimension::k3d, "texture_3d"},
|
||||
TextureData{type::TextureDimension::kCube, "texture_cube"},
|
||||
TextureData{type::TextureDimension::kCubeArray, "texture_cube_array"}));
|
||||
|
||||
using WgslGenerator_MultiampledTextureTest = TestParamHelper<TextureData>;
|
||||
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_F32) {
|
||||
|
@ -448,12 +449,12 @@ TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_U32) {
|
|||
}
|
||||
INSTANTIATE_TEST_SUITE_P(WgslGeneratorImplTest,
|
||||
WgslGenerator_MultiampledTextureTest,
|
||||
testing::Values(TextureData{ast::TextureDimension::k2d,
|
||||
testing::Values(TextureData{type::TextureDimension::k2d,
|
||||
"texture_multisampled_2d"}));
|
||||
|
||||
struct StorageTextureData {
|
||||
ast::TexelFormat fmt;
|
||||
ast::TextureDimension dim;
|
||||
type::TextureDimension dim;
|
||||
ast::Access access;
|
||||
const char* name;
|
||||
};
|
||||
|
@ -477,14 +478,14 @@ TEST_P(WgslGenerator_StorageTextureTest, EmitType_StorageTexture) {
|
|||
INSTANTIATE_TEST_SUITE_P(
|
||||
WgslGeneratorImplTest,
|
||||
WgslGenerator_StorageTextureTest,
|
||||
testing::Values(StorageTextureData{ast::TexelFormat::kRgba8Sint, ast::TextureDimension::k1d,
|
||||
testing::Values(StorageTextureData{ast::TexelFormat::kRgba8Sint, type::TextureDimension::k1d,
|
||||
ast::Access::kWrite, "texture_storage_1d<rgba8sint, write>"},
|
||||
StorageTextureData{ast::TexelFormat::kRgba8Sint, ast::TextureDimension::k2d,
|
||||
StorageTextureData{ast::TexelFormat::kRgba8Sint, type::TextureDimension::k2d,
|
||||
ast::Access::kWrite, "texture_storage_2d<rgba8sint, write>"},
|
||||
StorageTextureData{ast::TexelFormat::kRgba8Sint,
|
||||
ast::TextureDimension::k2dArray, ast::Access::kWrite,
|
||||
type::TextureDimension::k2dArray, ast::Access::kWrite,
|
||||
"texture_storage_2d_array<rgba8sint, write>"},
|
||||
StorageTextureData{ast::TexelFormat::kRgba8Sint, ast::TextureDimension::k3d,
|
||||
StorageTextureData{ast::TexelFormat::kRgba8Sint, type::TextureDimension::k3d,
|
||||
ast::Access::kWrite,
|
||||
"texture_storage_3d<rgba8sint, write>"}));
|
||||
|
||||
|
|
Loading…
Reference in New Issue