Move TexelFormat to builtin
This CL moves ast::TexelFormat to builtin::TexelFormat. Change-Id: Ifb39cc58babdd7e7aa89c19af5336a9498b082ae Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120402 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
2a65163c6d
commit
ba082fdb48
|
@ -701,6 +701,8 @@ libtint_source_set("libtint_builtins_src") {
|
|||
"builtin/builtin_value.h",
|
||||
"builtin/extension.cc",
|
||||
"builtin/extension.h",
|
||||
"builtin/texel_format.cc",
|
||||
"builtin/texel_format.h",
|
||||
]
|
||||
deps = [ ":libtint_base_src" ]
|
||||
}
|
||||
|
@ -758,8 +760,6 @@ libtint_source_set("libtint_type_src") {
|
|||
"type/storage_texture.h",
|
||||
"type/struct.cc",
|
||||
"type/struct.h",
|
||||
"type/texel_format.cc",
|
||||
"type/texel_format.h",
|
||||
"type/texture.cc",
|
||||
"type/texture.h",
|
||||
"type/texture_dimension.cc",
|
||||
|
@ -1298,6 +1298,7 @@ if (tint_build_unittests) {
|
|||
"builtin/address_space_test.cc",
|
||||
"builtin/builtin_value_test.cc",
|
||||
"builtin/extension_test.cc",
|
||||
"builtin/texel_format_test.cc",
|
||||
]
|
||||
deps = [ ":libtint_builtins_src" ]
|
||||
}
|
||||
|
@ -1432,7 +1433,6 @@ if (tint_build_unittests) {
|
|||
"type/sampler_test.cc",
|
||||
"type/storage_texture_test.cc",
|
||||
"type/struct_test.cc",
|
||||
"type/texel_format_test.cc",
|
||||
"type/texture_test.cc",
|
||||
"type/type_test.cc",
|
||||
"type/u32_test.cc",
|
||||
|
@ -1509,6 +1509,7 @@ if (tint_build_unittests) {
|
|||
|
||||
deps = [
|
||||
":libtint_base_src",
|
||||
":libtint_builtins_src",
|
||||
":libtint_transform_src",
|
||||
":libtint_unittests_ast_helper",
|
||||
":libtint_wgsl_reader_src",
|
||||
|
|
|
@ -552,13 +552,13 @@ tint_generated(builtin/access BENCH TEST)
|
|||
tint_generated(builtin/address_space BENCH TEST)
|
||||
tint_generated(builtin/builtin_value BENCH TEST)
|
||||
tint_generated(builtin/extension BENCH TEST)
|
||||
tint_generated(builtin/texel_format BENCH TEST)
|
||||
tint_generated(ast/diagnostic_control BENCH TEST)
|
||||
tint_generated(ast/interpolate_attribute BENCH TEST)
|
||||
tint_generated(resolver/init_conv_intrinsic)
|
||||
tint_generated(sem/builtin_type)
|
||||
tint_generated(sem/parameter_usage)
|
||||
tint_generated(type/builtin BENCH TEST)
|
||||
tint_generated(type/texel_format BENCH TEST)
|
||||
|
||||
if(UNIX)
|
||||
list(APPEND TINT_LIB_SRCS diagnostic/printer_posix.cc)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "src/tint/ast/builtin_texture_helper_test.h"
|
||||
|
||||
#include "src/tint/builtin/texel_format.h"
|
||||
#include "src/tint/type/depth_texture.h"
|
||||
#include "src/tint/type/multisampled_texture.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
|
@ -56,7 +57,7 @@ TextureOverloadCase::TextureOverloadCase(ValidTextureOverload o,
|
|||
TextureOverloadCase::TextureOverloadCase(ValidTextureOverload o,
|
||||
const char* d,
|
||||
tint::builtin::Access acc,
|
||||
type::TexelFormat fmt,
|
||||
tint::builtin::TexelFormat fmt,
|
||||
type::TextureDimension dims,
|
||||
TextureDataType datatype,
|
||||
const char* f,
|
||||
|
@ -405,7 +406,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
ValidTextureOverload::kDimensionsStorageWO1d,
|
||||
"textureDimensions(t : texture_storage_1d<rgba32float>) -> u32",
|
||||
tint::builtin::Access::kWrite,
|
||||
type::TexelFormat::kRgba32Float,
|
||||
tint::builtin::TexelFormat::kRgba32Float,
|
||||
type::TextureDimension::k1d,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
|
@ -415,7 +416,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
ValidTextureOverload::kDimensionsStorageWO2d,
|
||||
"textureDimensions(t : texture_storage_2d<rgba32float>) -> vec2<u32>",
|
||||
tint::builtin::Access::kWrite,
|
||||
type::TexelFormat::kRgba32Float,
|
||||
tint::builtin::TexelFormat::kRgba32Float,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
|
@ -425,7 +426,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
ValidTextureOverload::kDimensionsStorageWO2dArray,
|
||||
"textureDimensions(t : texture_storage_2d_array<rgba32float>) -> vec2<u32>",
|
||||
tint::builtin::Access::kWrite,
|
||||
type::TexelFormat::kRgba32Float,
|
||||
tint::builtin::TexelFormat::kRgba32Float,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
|
@ -435,7 +436,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
ValidTextureOverload::kDimensionsStorageWO3d,
|
||||
"textureDimensions(t : texture_storage_3d<rgba32float>) -> vec3<u32>",
|
||||
tint::builtin::Access::kWrite,
|
||||
type::TexelFormat::kRgba32Float,
|
||||
tint::builtin::TexelFormat::kRgba32Float,
|
||||
type::TextureDimension::k3d,
|
||||
TextureDataType::kF32,
|
||||
"textureDimensions",
|
||||
|
@ -828,7 +829,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
ValidTextureOverload::kNumLayersStorageWO2dArray,
|
||||
"textureNumLayers(t : texture_storage_2d_array<rgba32float>) -> u32",
|
||||
tint::builtin::Access::kWrite,
|
||||
type::TexelFormat::kRgba32Float,
|
||||
tint::builtin::TexelFormat::kRgba32Float,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureNumLayers",
|
||||
|
@ -2328,7 +2329,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : i32,\n"
|
||||
" value : vec4<T>)",
|
||||
tint::builtin::Access::kWrite,
|
||||
type::TexelFormat::kRgba32Float,
|
||||
tint::builtin::TexelFormat::kRgba32Float,
|
||||
type::TextureDimension::k1d,
|
||||
TextureDataType::kF32,
|
||||
"textureStore",
|
||||
|
@ -2344,7 +2345,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec2<i32>,\n"
|
||||
" value : vec4<T>)",
|
||||
tint::builtin::Access::kWrite,
|
||||
type::TexelFormat::kRgba32Float,
|
||||
tint::builtin::TexelFormat::kRgba32Float,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureStore",
|
||||
|
@ -2361,7 +2362,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" array_index : u32,\n"
|
||||
" value : vec4<T>)",
|
||||
tint::builtin::Access::kWrite,
|
||||
type::TexelFormat::kRgba32Float,
|
||||
tint::builtin::TexelFormat::kRgba32Float,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureStore",
|
||||
|
@ -2378,7 +2379,7 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec3<u32>,\n"
|
||||
" value : vec4<T>)",
|
||||
tint::builtin::Access::kWrite,
|
||||
type::TexelFormat::kRgba32Float,
|
||||
tint::builtin::TexelFormat::kRgba32Float,
|
||||
type::TextureDimension::k3d,
|
||||
TextureDataType::kF32,
|
||||
"textureStore",
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "src/tint/builtin/access.h"
|
||||
#include "src/tint/builtin/texel_format.h"
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
@ -208,7 +209,7 @@ struct TextureOverloadCase {
|
|||
TextureOverloadCase(ValidTextureOverload,
|
||||
const char*,
|
||||
tint::builtin::Access,
|
||||
type::TexelFormat,
|
||||
tint::builtin::TexelFormat,
|
||||
type::TextureDimension,
|
||||
TextureDataType,
|
||||
const char*,
|
||||
|
@ -248,7 +249,7 @@ struct TextureOverloadCase {
|
|||
tint::builtin::Access const access = tint::builtin::Access::kReadWrite;
|
||||
/// The image format for the storage texture
|
||||
/// Used only when texture_kind is kStorage
|
||||
type::TexelFormat const texel_format = type::TexelFormat::kUndefined;
|
||||
tint::builtin::TexelFormat const texel_format = tint::builtin::TexelFormat::kUndefined;
|
||||
/// The dimensions of the texture parameter
|
||||
type::TextureDimension const texture_dimension;
|
||||
/// The data type of the texture parameter
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// File generated by tools/src/cmd/gen
|
||||
// using the template:
|
||||
// src/tint/type/texel_format.cc.tmpl
|
||||
// src/tint/builtin/texel_format.cc.tmpl
|
||||
//
|
||||
// Do not modify this file directly
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "src/tint/type/texel_format.h"
|
||||
#include "src/tint/builtin/texel_format.h"
|
||||
|
||||
namespace tint::type {
|
||||
namespace tint::builtin {
|
||||
|
||||
/// ParseTexelFormat parses a TexelFormat from a string.
|
||||
/// @param str the string to parse
|
||||
|
@ -124,4 +124,4 @@ std::ostream& operator<<(std::ostream& out, TexelFormat value) {
|
|||
return out << "<unknown>";
|
||||
}
|
||||
|
||||
} // namespace tint::type
|
||||
} // namespace tint::builtin
|
|
@ -11,12 +11,12 @@ See:
|
|||
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
|
||||
{{- $enum := (Sem.Enum "texel_format") -}}
|
||||
|
||||
#include "src/tint/type/texel_format.h"
|
||||
#include "src/tint/builtin/texel_format.h"
|
||||
|
||||
namespace tint::type {
|
||||
namespace tint::builtin {
|
||||
|
||||
{{ Eval "ParseEnum" $enum}}
|
||||
|
||||
{{ Eval "EnumOStream" $enum}}
|
||||
|
||||
} // namespace tint::type
|
||||
} // namespace tint::builtin
|
|
@ -15,17 +15,17 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// File generated by tools/src/cmd/gen
|
||||
// using the template:
|
||||
// src/tint/type/texel_format.h.tmpl
|
||||
// src/tint/builtin/texel_format.h.tmpl
|
||||
//
|
||||
// Do not modify this file directly
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SRC_TINT_TYPE_TEXEL_FORMAT_H_
|
||||
#define SRC_TINT_TYPE_TEXEL_FORMAT_H_
|
||||
#ifndef SRC_TINT_BUILTIN_TEXEL_FORMAT_H_
|
||||
#define SRC_TINT_BUILTIN_TEXEL_FORMAT_H_
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace tint::type {
|
||||
namespace tint::builtin {
|
||||
|
||||
/// Enumerator of texel formats
|
||||
enum class TexelFormat {
|
||||
|
@ -65,6 +65,6 @@ constexpr const char* kTexelFormatStrings[] = {
|
|||
"rgba32uint", "rgba8sint", "rgba8snorm", "rgba8uint", "rgba8unorm",
|
||||
};
|
||||
|
||||
} // namespace tint::type
|
||||
} // namespace tint::builtin
|
||||
|
||||
#endif // SRC_TINT_TYPE_TEXEL_FORMAT_H_
|
||||
#endif // SRC_TINT_BUILTIN_TEXEL_FORMAT_H_
|
|
@ -11,16 +11,16 @@ See:
|
|||
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
|
||||
{{- $enum := (Sem.Enum "texel_format") -}}
|
||||
|
||||
#ifndef SRC_TINT_TYPE_TEXEL_FORMAT_H_
|
||||
#define SRC_TINT_TYPE_TEXEL_FORMAT_H_
|
||||
#ifndef SRC_TINT_BUILTIN_TEXEL_FORMAT_H_
|
||||
#define SRC_TINT_BUILTIN_TEXEL_FORMAT_H_
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace tint::type {
|
||||
namespace tint::builtin {
|
||||
|
||||
/// Enumerator of texel formats
|
||||
{{ Eval "DeclareEnum" $enum}}
|
||||
|
||||
} // namespace tint::type
|
||||
} // namespace tint::builtin
|
||||
|
||||
#endif // SRC_TINT_TYPE_TEXEL_FORMAT_H_
|
||||
#endif // SRC_TINT_BUILTIN_TEXEL_FORMAT_H_
|
|
@ -15,18 +15,18 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// File generated by tools/src/cmd/gen
|
||||
// using the template:
|
||||
// src/tint/type/texel_format_bench.cc.tmpl
|
||||
// src/tint/builtin/texel_format_bench.cc.tmpl
|
||||
//
|
||||
// Do not modify this file directly
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "src/tint/type/texel_format.h"
|
||||
#include "src/tint/builtin/texel_format.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "benchmark/benchmark.h"
|
||||
|
||||
namespace tint::type {
|
||||
namespace tint::builtin {
|
||||
namespace {
|
||||
|
||||
void TexelFormatParser(::benchmark::State& state) {
|
||||
|
@ -67,4 +67,4 @@ void TexelFormatParser(::benchmark::State& state) {
|
|||
BENCHMARK(TexelFormatParser);
|
||||
|
||||
} // namespace
|
||||
} // namespace tint::type
|
||||
} // namespace tint::builtin
|
|
@ -11,16 +11,16 @@ See:
|
|||
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
|
||||
{{- $enum := (Sem.Enum "texel_format") -}}
|
||||
|
||||
#include "src/tint/type/texel_format.h"
|
||||
#include "src/tint/builtin/texel_format.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "benchmark/benchmark.h"
|
||||
|
||||
namespace tint::type {
|
||||
namespace tint::builtin {
|
||||
namespace {
|
||||
|
||||
{{ Eval "BenchmarkParseEnum" $enum }}
|
||||
|
||||
} // namespace
|
||||
} // namespace tint::type
|
||||
} // namespace tint::builtin
|
|
@ -15,19 +15,20 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// File generated by tools/src/cmd/gen
|
||||
// using the template:
|
||||
// src/tint/type/texel_format_test.cc.tmpl
|
||||
// src/tint/builtin/texel_format_test.cc.tmpl
|
||||
//
|
||||
// Do not modify this file directly
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "src/tint/type/texel_format.h"
|
||||
#include "src/tint/builtin/texel_format.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "src/tint/type/test_helper.h"
|
||||
#include "src/tint/utils/string.h"
|
||||
|
||||
namespace tint::type {
|
||||
namespace tint::builtin {
|
||||
namespace {
|
||||
|
||||
namespace parse_print_tests {
|
||||
|
@ -106,4 +107,4 @@ INSTANTIATE_TEST_SUITE_P(ValidCases, TexelFormatPrintTest, testing::ValuesIn(kVa
|
|||
} // namespace parse_print_tests
|
||||
|
||||
} // namespace
|
||||
} // namespace tint::type
|
||||
} // namespace tint::builtin
|
|
@ -11,17 +11,18 @@ See:
|
|||
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
|
||||
{{- $enum := (Sem.Enum "texel_format") -}}
|
||||
|
||||
#include "src/tint/type/texel_format.h"
|
||||
#include "src/tint/builtin/texel_format.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "src/tint/type/test_helper.h"
|
||||
#include "src/tint/utils/string.h"
|
||||
|
||||
namespace tint::type {
|
||||
namespace tint::builtin {
|
||||
namespace {
|
||||
|
||||
{{ Eval "TestParsePrintEnum" $enum}}
|
||||
|
||||
} // namespace
|
||||
} // namespace tint::type
|
||||
} // namespace tint::builtin
|
|
@ -112,7 +112,7 @@ class InspectorGetDepthMultisampledTextureResourceBindingsTest : public Inspecto
|
|||
public testing::Test {};
|
||||
|
||||
typedef std::tuple<type::TextureDimension, ResourceBinding::TextureDimension> DimensionParams;
|
||||
typedef std::tuple<type::TexelFormat, ResourceBinding::TexelFormat, ResourceBinding::SampledKind>
|
||||
typedef std::tuple<builtin::TexelFormat, ResourceBinding::TexelFormat, ResourceBinding::SampledKind>
|
||||
TexelFormatParams;
|
||||
typedef std::tuple<DimensionParams, TexelFormatParams> GetStorageTextureTestParams;
|
||||
class InspectorGetStorageTextureResourceBindingsTestWithParam
|
||||
|
@ -1812,7 +1812,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
|
|||
});
|
||||
|
||||
auto st_type =
|
||||
MakeStorageTextureTypes(type::TextureDimension::k2d, type::TexelFormat::kR32Uint);
|
||||
MakeStorageTextureTypes(type::TextureDimension::k2d, builtin::TexelFormat::kR32Uint);
|
||||
AddStorageTexture("st_var", st_type, 4, 0);
|
||||
MakeStorageTextureBodyFunction("st_func", "st_var", ty.vec2<u32>(), utils::Empty);
|
||||
|
||||
|
@ -2972,7 +2972,7 @@ TEST_P(InspectorGetStorageTextureResourceBindingsTestWithParam, Simple) {
|
|||
ResourceBinding::TextureDimension expected_dim;
|
||||
std::tie(dim, expected_dim) = dim_params;
|
||||
|
||||
type::TexelFormat format;
|
||||
builtin::TexelFormat format;
|
||||
ResourceBinding::TexelFormat expected_format;
|
||||
ResourceBinding::SampledKind expected_kind;
|
||||
std::tie(format, expected_format, expected_kind) = format_params;
|
||||
|
@ -3028,52 +3028,52 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
ResourceBinding::TextureDimension::k2dArray),
|
||||
std::make_tuple(type::TextureDimension::k3d,
|
||||
ResourceBinding::TextureDimension::k3d)),
|
||||
testing::Values(std::make_tuple(type::TexelFormat::kR32Float,
|
||||
testing::Values(std::make_tuple(builtin::TexelFormat::kR32Float,
|
||||
ResourceBinding::TexelFormat::kR32Float,
|
||||
ResourceBinding::SampledKind::kFloat),
|
||||
std::make_tuple(type::TexelFormat::kR32Sint,
|
||||
std::make_tuple(builtin::TexelFormat::kR32Sint,
|
||||
ResourceBinding::TexelFormat::kR32Sint,
|
||||
ResourceBinding::SampledKind::kSInt),
|
||||
std::make_tuple(type::TexelFormat::kR32Uint,
|
||||
std::make_tuple(builtin::TexelFormat::kR32Uint,
|
||||
ResourceBinding::TexelFormat::kR32Uint,
|
||||
ResourceBinding::SampledKind::kUInt),
|
||||
std::make_tuple(type::TexelFormat::kRg32Float,
|
||||
std::make_tuple(builtin::TexelFormat::kRg32Float,
|
||||
ResourceBinding::TexelFormat::kRg32Float,
|
||||
ResourceBinding::SampledKind::kFloat),
|
||||
std::make_tuple(type::TexelFormat::kRg32Sint,
|
||||
std::make_tuple(builtin::TexelFormat::kRg32Sint,
|
||||
ResourceBinding::TexelFormat::kRg32Sint,
|
||||
ResourceBinding::SampledKind::kSInt),
|
||||
std::make_tuple(type::TexelFormat::kRg32Uint,
|
||||
std::make_tuple(builtin::TexelFormat::kRg32Uint,
|
||||
ResourceBinding::TexelFormat::kRg32Uint,
|
||||
ResourceBinding::SampledKind::kUInt),
|
||||
std::make_tuple(type::TexelFormat::kRgba16Float,
|
||||
std::make_tuple(builtin::TexelFormat::kRgba16Float,
|
||||
ResourceBinding::TexelFormat::kRgba16Float,
|
||||
ResourceBinding::SampledKind::kFloat),
|
||||
std::make_tuple(type::TexelFormat::kRgba16Sint,
|
||||
std::make_tuple(builtin::TexelFormat::kRgba16Sint,
|
||||
ResourceBinding::TexelFormat::kRgba16Sint,
|
||||
ResourceBinding::SampledKind::kSInt),
|
||||
std::make_tuple(type::TexelFormat::kRgba16Uint,
|
||||
std::make_tuple(builtin::TexelFormat::kRgba16Uint,
|
||||
ResourceBinding::TexelFormat::kRgba16Uint,
|
||||
ResourceBinding::SampledKind::kUInt),
|
||||
std::make_tuple(type::TexelFormat::kRgba32Float,
|
||||
std::make_tuple(builtin::TexelFormat::kRgba32Float,
|
||||
ResourceBinding::TexelFormat::kRgba32Float,
|
||||
ResourceBinding::SampledKind::kFloat),
|
||||
std::make_tuple(type::TexelFormat::kRgba32Sint,
|
||||
std::make_tuple(builtin::TexelFormat::kRgba32Sint,
|
||||
ResourceBinding::TexelFormat::kRgba32Sint,
|
||||
ResourceBinding::SampledKind::kSInt),
|
||||
std::make_tuple(type::TexelFormat::kRgba32Uint,
|
||||
std::make_tuple(builtin::TexelFormat::kRgba32Uint,
|
||||
ResourceBinding::TexelFormat::kRgba32Uint,
|
||||
ResourceBinding::SampledKind::kUInt),
|
||||
std::make_tuple(type::TexelFormat::kRgba8Sint,
|
||||
std::make_tuple(builtin::TexelFormat::kRgba8Sint,
|
||||
ResourceBinding::TexelFormat::kRgba8Sint,
|
||||
ResourceBinding::SampledKind::kSInt),
|
||||
std::make_tuple(type::TexelFormat::kRgba8Snorm,
|
||||
std::make_tuple(builtin::TexelFormat::kRgba8Snorm,
|
||||
ResourceBinding::TexelFormat::kRgba8Snorm,
|
||||
ResourceBinding::SampledKind::kFloat),
|
||||
std::make_tuple(type::TexelFormat::kRgba8Uint,
|
||||
std::make_tuple(builtin::TexelFormat::kRgba8Uint,
|
||||
ResourceBinding::TexelFormat::kRgba8Uint,
|
||||
ResourceBinding::SampledKind::kUInt),
|
||||
std::make_tuple(type::TexelFormat::kRgba8Unorm,
|
||||
std::make_tuple(builtin::TexelFormat::kRgba8Unorm,
|
||||
ResourceBinding::TexelFormat::kRgba8Unorm,
|
||||
ResourceBinding::SampledKind::kFloat))));
|
||||
|
||||
|
|
|
@ -71,43 +71,43 @@ ResourceBinding::SampledKind BaseTypeToSampledKind(const type::Type* base_type)
|
|||
}
|
||||
|
||||
ResourceBinding::TexelFormat TypeTexelFormatToResourceBindingTexelFormat(
|
||||
const type::TexelFormat& image_format) {
|
||||
const builtin::TexelFormat& image_format) {
|
||||
switch (image_format) {
|
||||
case type::TexelFormat::kBgra8Unorm:
|
||||
case builtin::TexelFormat::kBgra8Unorm:
|
||||
return ResourceBinding::TexelFormat::kBgra8Unorm;
|
||||
case type::TexelFormat::kR32Uint:
|
||||
case builtin::TexelFormat::kR32Uint:
|
||||
return ResourceBinding::TexelFormat::kR32Uint;
|
||||
case type::TexelFormat::kR32Sint:
|
||||
case builtin::TexelFormat::kR32Sint:
|
||||
return ResourceBinding::TexelFormat::kR32Sint;
|
||||
case type::TexelFormat::kR32Float:
|
||||
case builtin::TexelFormat::kR32Float:
|
||||
return ResourceBinding::TexelFormat::kR32Float;
|
||||
case type::TexelFormat::kRgba8Unorm:
|
||||
case builtin::TexelFormat::kRgba8Unorm:
|
||||
return ResourceBinding::TexelFormat::kRgba8Unorm;
|
||||
case type::TexelFormat::kRgba8Snorm:
|
||||
case builtin::TexelFormat::kRgba8Snorm:
|
||||
return ResourceBinding::TexelFormat::kRgba8Snorm;
|
||||
case type::TexelFormat::kRgba8Uint:
|
||||
case builtin::TexelFormat::kRgba8Uint:
|
||||
return ResourceBinding::TexelFormat::kRgba8Uint;
|
||||
case type::TexelFormat::kRgba8Sint:
|
||||
case builtin::TexelFormat::kRgba8Sint:
|
||||
return ResourceBinding::TexelFormat::kRgba8Sint;
|
||||
case type::TexelFormat::kRg32Uint:
|
||||
case builtin::TexelFormat::kRg32Uint:
|
||||
return ResourceBinding::TexelFormat::kRg32Uint;
|
||||
case type::TexelFormat::kRg32Sint:
|
||||
case builtin::TexelFormat::kRg32Sint:
|
||||
return ResourceBinding::TexelFormat::kRg32Sint;
|
||||
case type::TexelFormat::kRg32Float:
|
||||
case builtin::TexelFormat::kRg32Float:
|
||||
return ResourceBinding::TexelFormat::kRg32Float;
|
||||
case type::TexelFormat::kRgba16Uint:
|
||||
case builtin::TexelFormat::kRgba16Uint:
|
||||
return ResourceBinding::TexelFormat::kRgba16Uint;
|
||||
case type::TexelFormat::kRgba16Sint:
|
||||
case builtin::TexelFormat::kRgba16Sint:
|
||||
return ResourceBinding::TexelFormat::kRgba16Sint;
|
||||
case type::TexelFormat::kRgba16Float:
|
||||
case builtin::TexelFormat::kRgba16Float:
|
||||
return ResourceBinding::TexelFormat::kRgba16Float;
|
||||
case type::TexelFormat::kRgba32Uint:
|
||||
case builtin::TexelFormat::kRgba32Uint:
|
||||
return ResourceBinding::TexelFormat::kRgba32Uint;
|
||||
case type::TexelFormat::kRgba32Sint:
|
||||
case builtin::TexelFormat::kRgba32Sint:
|
||||
return ResourceBinding::TexelFormat::kRgba32Sint;
|
||||
case type::TexelFormat::kRgba32Float:
|
||||
case builtin::TexelFormat::kRgba32Float:
|
||||
return ResourceBinding::TexelFormat::kRgba32Float;
|
||||
case type::TexelFormat::kUndefined:
|
||||
case builtin::TexelFormat::kUndefined:
|
||||
return ResourceBinding::TexelFormat::kNone;
|
||||
}
|
||||
return ResourceBinding::TexelFormat::kNone;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#include "src/tint/type/texel_format.h"
|
||||
#include "src/tint/builtin/texel_format.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/type/type.h"
|
||||
|
||||
|
@ -116,12 +116,12 @@ ResourceBinding::TextureDimension TypeTextureDimensionToResourceBindingTextureDi
|
|||
/// @returns the publicly visible equivalent
|
||||
ResourceBinding::SampledKind BaseTypeToSampledKind(const type::Type* base_type);
|
||||
|
||||
/// Convert from internal type::TexelFormat to public
|
||||
/// Convert from internal builtin::TexelFormat to public
|
||||
/// ResourceBinding::TexelFormat
|
||||
/// @param image_format internal value to convert from
|
||||
/// @returns the publicly visible equivalent
|
||||
ResourceBinding::TexelFormat TypeTexelFormatToResourceBindingTexelFormat(
|
||||
const type::TexelFormat& image_format);
|
||||
const builtin::TexelFormat& image_format);
|
||||
|
||||
} // namespace tint::inspector
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ ast::Type InspectorBuilder::GetCoordsType(type::TextureDimension dim, ast::Type
|
|||
}
|
||||
|
||||
ast::Type InspectorBuilder::MakeStorageTextureTypes(type::TextureDimension dim,
|
||||
type::TexelFormat format) {
|
||||
builtin::TexelFormat format) {
|
||||
return ty.storage_texture(dim, format, builtin::Access::kWrite);
|
||||
}
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ class InspectorBuilder : public ProgramBuilder {
|
|||
/// @param dim the texture dimension of the storage texture
|
||||
/// @param format the texel format of the storage texture
|
||||
/// @returns the storage texture type
|
||||
ast::Type MakeStorageTextureTypes(type::TextureDimension dim, type::TexelFormat format);
|
||||
ast::Type MakeStorageTextureTypes(type::TextureDimension dim, builtin::TexelFormat format);
|
||||
|
||||
/// Adds a storage texture variable to the program
|
||||
/// @param name the name of the variable
|
||||
|
|
|
@ -1389,7 +1389,7 @@ class ProgramBuilder {
|
|||
/// @param access the access control of the texture
|
||||
/// @returns the storage texture
|
||||
ast::Type storage_texture(type::TextureDimension dims,
|
||||
type::TexelFormat format,
|
||||
builtin::TexelFormat format,
|
||||
builtin::Access access) const {
|
||||
return storage_texture(builder->source_, dims, format, access);
|
||||
}
|
||||
|
@ -1401,7 +1401,7 @@ class ProgramBuilder {
|
|||
/// @returns the storage texture
|
||||
ast::Type storage_texture(const Source& source,
|
||||
type::TextureDimension dims,
|
||||
type::TexelFormat format,
|
||||
builtin::TexelFormat format,
|
||||
builtin::Access access) const {
|
||||
switch (dims) {
|
||||
case type::TextureDimension::k1d:
|
||||
|
|
|
@ -130,53 +130,53 @@ type::TextureDimension EnumConverter::ToDim(spv::Dim dim, bool arrayed) {
|
|||
return type::TextureDimension::kNone;
|
||||
}
|
||||
|
||||
type::TexelFormat EnumConverter::ToTexelFormat(spv::ImageFormat fmt) {
|
||||
builtin::TexelFormat EnumConverter::ToTexelFormat(spv::ImageFormat fmt) {
|
||||
switch (fmt) {
|
||||
case spv::ImageFormat::Unknown:
|
||||
return type::TexelFormat::kUndefined;
|
||||
return builtin::TexelFormat::kUndefined;
|
||||
|
||||
// 8 bit channels
|
||||
case spv::ImageFormat::Rgba8:
|
||||
return type::TexelFormat::kRgba8Unorm;
|
||||
return builtin::TexelFormat::kRgba8Unorm;
|
||||
case spv::ImageFormat::Rgba8Snorm:
|
||||
return type::TexelFormat::kRgba8Snorm;
|
||||
return builtin::TexelFormat::kRgba8Snorm;
|
||||
case spv::ImageFormat::Rgba8ui:
|
||||
return type::TexelFormat::kRgba8Uint;
|
||||
return builtin::TexelFormat::kRgba8Uint;
|
||||
case spv::ImageFormat::Rgba8i:
|
||||
return type::TexelFormat::kRgba8Sint;
|
||||
return builtin::TexelFormat::kRgba8Sint;
|
||||
|
||||
// 16 bit channels
|
||||
case spv::ImageFormat::Rgba16ui:
|
||||
return type::TexelFormat::kRgba16Uint;
|
||||
return builtin::TexelFormat::kRgba16Uint;
|
||||
case spv::ImageFormat::Rgba16i:
|
||||
return type::TexelFormat::kRgba16Sint;
|
||||
return builtin::TexelFormat::kRgba16Sint;
|
||||
case spv::ImageFormat::Rgba16f:
|
||||
return type::TexelFormat::kRgba16Float;
|
||||
return builtin::TexelFormat::kRgba16Float;
|
||||
|
||||
// 32 bit channels
|
||||
case spv::ImageFormat::R32ui:
|
||||
return type::TexelFormat::kR32Uint;
|
||||
return builtin::TexelFormat::kR32Uint;
|
||||
case spv::ImageFormat::R32i:
|
||||
return type::TexelFormat::kR32Sint;
|
||||
return builtin::TexelFormat::kR32Sint;
|
||||
case spv::ImageFormat::R32f:
|
||||
return type::TexelFormat::kR32Float;
|
||||
return builtin::TexelFormat::kR32Float;
|
||||
case spv::ImageFormat::Rg32ui:
|
||||
return type::TexelFormat::kRg32Uint;
|
||||
return builtin::TexelFormat::kRg32Uint;
|
||||
case spv::ImageFormat::Rg32i:
|
||||
return type::TexelFormat::kRg32Sint;
|
||||
return builtin::TexelFormat::kRg32Sint;
|
||||
case spv::ImageFormat::Rg32f:
|
||||
return type::TexelFormat::kRg32Float;
|
||||
return builtin::TexelFormat::kRg32Float;
|
||||
case spv::ImageFormat::Rgba32ui:
|
||||
return type::TexelFormat::kRgba32Uint;
|
||||
return builtin::TexelFormat::kRgba32Uint;
|
||||
case spv::ImageFormat::Rgba32i:
|
||||
return type::TexelFormat::kRgba32Sint;
|
||||
return builtin::TexelFormat::kRgba32Sint;
|
||||
case spv::ImageFormat::Rgba32f:
|
||||
return type::TexelFormat::kRgba32Float;
|
||||
return builtin::TexelFormat::kRgba32Float;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Fail() << "invalid image format: " << int(fmt);
|
||||
return type::TexelFormat::kUndefined;
|
||||
return builtin::TexelFormat::kUndefined;
|
||||
}
|
||||
|
||||
} // namespace tint::reader::spirv
|
||||
|
|
|
@ -73,13 +73,13 @@ class EnumConverter {
|
|||
/// On failure, logs an error and returns kNone
|
||||
/// @param fmt the SPIR-V format
|
||||
/// @returns a Tint AST format
|
||||
type::TexelFormat ToTexelFormat(spv::ImageFormat fmt);
|
||||
builtin::TexelFormat ToTexelFormat(spv::ImageFormat fmt);
|
||||
|
||||
/// Converts a SPIR-V Image Format to a TexelFormat
|
||||
/// On failure, logs an error and returns kNone
|
||||
/// @param fmt the SPIR-V format
|
||||
/// @returns a Tint AST format
|
||||
type::TexelFormat ToTexelFormat(SpvImageFormat fmt) {
|
||||
builtin::TexelFormat ToTexelFormat(SpvImageFormat fmt) {
|
||||
return ToTexelFormat(static_cast<spv::ImageFormat>(fmt));
|
||||
}
|
||||
|
||||
|
|
|
@ -293,7 +293,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
struct TexelFormatCase {
|
||||
spv::ImageFormat format;
|
||||
bool expect_success;
|
||||
type::TexelFormat expected;
|
||||
builtin::TexelFormat expected;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, TexelFormatCase ifc) {
|
||||
out << "TexelFormatCase{ spv::ImageFormat:::" << int(ifc.format)
|
||||
|
@ -335,52 +335,52 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
SpvImageFormatTest,
|
||||
testing::Values(
|
||||
// Unknown. This is used for sampled images.
|
||||
TexelFormatCase{spv::ImageFormat::Unknown, true, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Unknown, true, builtin::TexelFormat::kUndefined},
|
||||
// 8 bit channels
|
||||
TexelFormatCase{spv::ImageFormat::Rgba8, true, type::TexelFormat::kRgba8Unorm},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba8Snorm, true, type::TexelFormat::kRgba8Snorm},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba8ui, true, type::TexelFormat::kRgba8Uint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba8i, true, type::TexelFormat::kRgba8Sint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba8, true, builtin::TexelFormat::kRgba8Unorm},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba8Snorm, true, builtin::TexelFormat::kRgba8Snorm},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba8ui, true, builtin::TexelFormat::kRgba8Uint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba8i, true, builtin::TexelFormat::kRgba8Sint},
|
||||
// 16 bit channels
|
||||
TexelFormatCase{spv::ImageFormat::Rgba16ui, true, type::TexelFormat::kRgba16Uint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba16i, true, type::TexelFormat::kRgba16Sint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba16f, true, type::TexelFormat::kRgba16Float},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba16ui, true, builtin::TexelFormat::kRgba16Uint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba16i, true, builtin::TexelFormat::kRgba16Sint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba16f, true, builtin::TexelFormat::kRgba16Float},
|
||||
// 32 bit channels
|
||||
// ... 1 channel
|
||||
TexelFormatCase{spv::ImageFormat::R32ui, true, type::TexelFormat::kR32Uint},
|
||||
TexelFormatCase{spv::ImageFormat::R32i, true, type::TexelFormat::kR32Sint},
|
||||
TexelFormatCase{spv::ImageFormat::R32f, true, type::TexelFormat::kR32Float},
|
||||
TexelFormatCase{spv::ImageFormat::R32ui, true, builtin::TexelFormat::kR32Uint},
|
||||
TexelFormatCase{spv::ImageFormat::R32i, true, builtin::TexelFormat::kR32Sint},
|
||||
TexelFormatCase{spv::ImageFormat::R32f, true, builtin::TexelFormat::kR32Float},
|
||||
// ... 2 channels
|
||||
TexelFormatCase{spv::ImageFormat::Rg32ui, true, type::TexelFormat::kRg32Uint},
|
||||
TexelFormatCase{spv::ImageFormat::Rg32i, true, type::TexelFormat::kRg32Sint},
|
||||
TexelFormatCase{spv::ImageFormat::Rg32f, true, type::TexelFormat::kRg32Float},
|
||||
TexelFormatCase{spv::ImageFormat::Rg32ui, true, builtin::TexelFormat::kRg32Uint},
|
||||
TexelFormatCase{spv::ImageFormat::Rg32i, true, builtin::TexelFormat::kRg32Sint},
|
||||
TexelFormatCase{spv::ImageFormat::Rg32f, true, builtin::TexelFormat::kRg32Float},
|
||||
// ... 4 channels
|
||||
TexelFormatCase{spv::ImageFormat::Rgba32ui, true, type::TexelFormat::kRgba32Uint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba32i, true, type::TexelFormat::kRgba32Sint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba32f, true, type::TexelFormat::kRgba32Float}));
|
||||
TexelFormatCase{spv::ImageFormat::Rgba32ui, true, builtin::TexelFormat::kRgba32Uint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba32i, true, builtin::TexelFormat::kRgba32Sint},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba32f, true, builtin::TexelFormat::kRgba32Float}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
EnumConverterBad,
|
||||
SpvImageFormatTest,
|
||||
testing::Values(
|
||||
// Scanning in order from the SPIR-V spec.
|
||||
TexelFormatCase{spv::ImageFormat::Rg16f, false, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::R11fG11fB10f, false, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::R16f, false, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rgb10A2, false, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg16, false, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg8, false, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::R16, false, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::R8, false, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba16Snorm, false, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg16Snorm, false, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg8Snorm, false, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg16i, false, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg8i, false, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::R8i, false, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rgb10a2ui, false, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg16ui, false, type::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg8ui, false, type::TexelFormat::kUndefined}));
|
||||
TexelFormatCase{spv::ImageFormat::Rg16f, false, builtin::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::R11fG11fB10f, false, builtin::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::R16f, false, builtin::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rgb10A2, false, builtin::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg16, false, builtin::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg8, false, builtin::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::R16, false, builtin::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::R8, false, builtin::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rgba16Snorm, false, builtin::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg16Snorm, false, builtin::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg8Snorm, false, builtin::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg16i, false, builtin::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg8i, false, builtin::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::R8i, false, builtin::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rgb10a2ui, false, builtin::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg16ui, false, builtin::TexelFormat::kUndefined},
|
||||
TexelFormatCase{spv::ImageFormat::Rg8ui, false, builtin::TexelFormat::kUndefined}));
|
||||
|
||||
} // namespace
|
||||
} // namespace tint::reader::spirv
|
||||
|
|
|
@ -2529,7 +2529,7 @@ const Type* ParserImpl::GetHandleTypeForSpirvHandle(const spvtools::opt::Instruc
|
|||
} else {
|
||||
const auto access = builtin::Access::kWrite;
|
||||
const auto format = enum_converter_.ToTexelFormat(image_type->format());
|
||||
if (format == type::TexelFormat::kUndefined) {
|
||||
if (format == builtin::TexelFormat::kUndefined) {
|
||||
return nullptr;
|
||||
}
|
||||
ast_handle_type = ty_.StorageTexture(dim, format, access);
|
||||
|
@ -2546,28 +2546,28 @@ const Type* ParserImpl::GetHandleTypeForSpirvHandle(const spvtools::opt::Instruc
|
|||
return ast_handle_type;
|
||||
}
|
||||
|
||||
const Type* ParserImpl::GetComponentTypeForFormat(type::TexelFormat format) {
|
||||
const Type* ParserImpl::GetComponentTypeForFormat(builtin::TexelFormat format) {
|
||||
switch (format) {
|
||||
case type::TexelFormat::kR32Uint:
|
||||
case type::TexelFormat::kRgba8Uint:
|
||||
case type::TexelFormat::kRg32Uint:
|
||||
case type::TexelFormat::kRgba16Uint:
|
||||
case type::TexelFormat::kRgba32Uint:
|
||||
case builtin::TexelFormat::kR32Uint:
|
||||
case builtin::TexelFormat::kRgba8Uint:
|
||||
case builtin::TexelFormat::kRg32Uint:
|
||||
case builtin::TexelFormat::kRgba16Uint:
|
||||
case builtin::TexelFormat::kRgba32Uint:
|
||||
return ty_.U32();
|
||||
|
||||
case type::TexelFormat::kR32Sint:
|
||||
case type::TexelFormat::kRgba8Sint:
|
||||
case type::TexelFormat::kRg32Sint:
|
||||
case type::TexelFormat::kRgba16Sint:
|
||||
case type::TexelFormat::kRgba32Sint:
|
||||
case builtin::TexelFormat::kR32Sint:
|
||||
case builtin::TexelFormat::kRgba8Sint:
|
||||
case builtin::TexelFormat::kRg32Sint:
|
||||
case builtin::TexelFormat::kRgba16Sint:
|
||||
case builtin::TexelFormat::kRgba32Sint:
|
||||
return ty_.I32();
|
||||
|
||||
case type::TexelFormat::kRgba8Unorm:
|
||||
case type::TexelFormat::kRgba8Snorm:
|
||||
case type::TexelFormat::kR32Float:
|
||||
case type::TexelFormat::kRg32Float:
|
||||
case type::TexelFormat::kRgba16Float:
|
||||
case type::TexelFormat::kRgba32Float:
|
||||
case builtin::TexelFormat::kRgba8Unorm:
|
||||
case builtin::TexelFormat::kRgba8Snorm:
|
||||
case builtin::TexelFormat::kR32Float:
|
||||
case builtin::TexelFormat::kRg32Float:
|
||||
case builtin::TexelFormat::kRgba16Float:
|
||||
case builtin::TexelFormat::kRgba32Float:
|
||||
return ty_.F32();
|
||||
default:
|
||||
break;
|
||||
|
@ -2576,30 +2576,30 @@ const Type* ParserImpl::GetComponentTypeForFormat(type::TexelFormat format) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
unsigned ParserImpl::GetChannelCountForFormat(type::TexelFormat format) {
|
||||
unsigned ParserImpl::GetChannelCountForFormat(builtin::TexelFormat format) {
|
||||
switch (format) {
|
||||
case type::TexelFormat::kR32Float:
|
||||
case type::TexelFormat::kR32Sint:
|
||||
case type::TexelFormat::kR32Uint:
|
||||
case builtin::TexelFormat::kR32Float:
|
||||
case builtin::TexelFormat::kR32Sint:
|
||||
case builtin::TexelFormat::kR32Uint:
|
||||
// One channel
|
||||
return 1;
|
||||
|
||||
case type::TexelFormat::kRg32Float:
|
||||
case type::TexelFormat::kRg32Sint:
|
||||
case type::TexelFormat::kRg32Uint:
|
||||
case builtin::TexelFormat::kRg32Float:
|
||||
case builtin::TexelFormat::kRg32Sint:
|
||||
case builtin::TexelFormat::kRg32Uint:
|
||||
// Two channels
|
||||
return 2;
|
||||
|
||||
case type::TexelFormat::kRgba16Float:
|
||||
case type::TexelFormat::kRgba16Sint:
|
||||
case type::TexelFormat::kRgba16Uint:
|
||||
case type::TexelFormat::kRgba32Float:
|
||||
case type::TexelFormat::kRgba32Sint:
|
||||
case type::TexelFormat::kRgba32Uint:
|
||||
case type::TexelFormat::kRgba8Sint:
|
||||
case type::TexelFormat::kRgba8Snorm:
|
||||
case type::TexelFormat::kRgba8Uint:
|
||||
case type::TexelFormat::kRgba8Unorm:
|
||||
case builtin::TexelFormat::kRgba16Float:
|
||||
case builtin::TexelFormat::kRgba16Sint:
|
||||
case builtin::TexelFormat::kRgba16Uint:
|
||||
case builtin::TexelFormat::kRgba32Float:
|
||||
case builtin::TexelFormat::kRgba32Sint:
|
||||
case builtin::TexelFormat::kRgba32Uint:
|
||||
case builtin::TexelFormat::kRgba8Sint:
|
||||
case builtin::TexelFormat::kRgba8Snorm:
|
||||
case builtin::TexelFormat::kRgba8Uint:
|
||||
case builtin::TexelFormat::kRgba8Unorm:
|
||||
// Four channels
|
||||
return 4;
|
||||
|
||||
|
@ -2610,7 +2610,7 @@ unsigned ParserImpl::GetChannelCountForFormat(type::TexelFormat format) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
const Type* ParserImpl::GetTexelTypeForFormat(type::TexelFormat format) {
|
||||
const Type* ParserImpl::GetTexelTypeForFormat(builtin::TexelFormat format) {
|
||||
const auto* component_type = GetComponentTypeForFormat(format);
|
||||
if (!component_type) {
|
||||
return nullptr;
|
||||
|
|
|
@ -690,19 +690,19 @@ class ParserImpl : Reader {
|
|||
/// format.
|
||||
/// @param format image texel format
|
||||
/// @returns the component type, one of f32, i32, u32
|
||||
const Type* GetComponentTypeForFormat(type::TexelFormat format);
|
||||
const Type* GetComponentTypeForFormat(builtin::TexelFormat format);
|
||||
|
||||
/// Returns the number of channels in the given image format.
|
||||
/// @param format image texel format
|
||||
/// @returns the number of channels in the format
|
||||
unsigned GetChannelCountForFormat(type::TexelFormat format);
|
||||
unsigned GetChannelCountForFormat(builtin::TexelFormat format);
|
||||
|
||||
/// Returns the texel type corresponding to the given image format.
|
||||
/// This the WGSL type used for the texel parameter to textureStore.
|
||||
/// It's always a 4-element vector.
|
||||
/// @param format image texel format
|
||||
/// @returns the texel format
|
||||
const Type* GetTexelTypeForFormat(type::TexelFormat format);
|
||||
const Type* GetTexelTypeForFormat(builtin::TexelFormat format);
|
||||
|
||||
/// Returns the SPIR-V instruction with the given ID, or nullptr.
|
||||
/// @param id the SPIR-V result ID
|
||||
|
|
|
@ -269,7 +269,7 @@ ast::Type SampledTexture::Build(ProgramBuilder& b) const {
|
|||
return b.ty.sampled_texture(dims, type->Build(b));
|
||||
}
|
||||
|
||||
StorageTexture::StorageTexture(type::TextureDimension d, type::TexelFormat f, builtin::Access a)
|
||||
StorageTexture::StorageTexture(type::TextureDimension d, builtin::TexelFormat f, builtin::Access a)
|
||||
: Base(d), format(f), access(a) {}
|
||||
StorageTexture::StorageTexture(const StorageTexture&) = default;
|
||||
|
||||
|
@ -529,7 +529,7 @@ const spirv::SampledTexture* TypeManager::SampledTexture(type::TextureDimension
|
|||
}
|
||||
|
||||
const spirv::StorageTexture* TypeManager::StorageTexture(type::TextureDimension dims,
|
||||
type::TexelFormat fmt,
|
||||
builtin::TexelFormat fmt,
|
||||
builtin::Access access) {
|
||||
return state->storage_textures_.Get(dims, fmt, access);
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
#include "src/tint/ast/type.h"
|
||||
#include "src/tint/builtin/access.h"
|
||||
#include "src/tint/builtin/address_space.h"
|
||||
#include "src/tint/builtin/texel_format.h"
|
||||
#include "src/tint/castable.h"
|
||||
#include "src/tint/symbol.h"
|
||||
#include "src/tint/type/sampler_kind.h"
|
||||
#include "src/tint/type/texel_format.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/block_allocator.h"
|
||||
|
||||
|
@ -434,7 +434,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(type::TextureDimension d, type::TexelFormat f, builtin::Access a);
|
||||
StorageTexture(type::TextureDimension d, builtin::TexelFormat f, builtin::Access a);
|
||||
|
||||
/// Copy constructor
|
||||
/// @param other the other type to copy
|
||||
|
@ -450,7 +450,7 @@ struct StorageTexture final : public Castable<StorageTexture, Texture> {
|
|||
#endif // NDEBUG
|
||||
|
||||
/// the storage image format
|
||||
type::TexelFormat const format;
|
||||
builtin::TexelFormat const format;
|
||||
|
||||
/// the access control
|
||||
builtin::Access const access;
|
||||
|
@ -615,7 +615,7 @@ class TypeManager {
|
|||
/// @return a StorageTexture type. Repeated calls with the same arguments will
|
||||
/// return the same pointer.
|
||||
const spirv::StorageTexture* StorageTexture(type::TextureDimension d,
|
||||
type::TexelFormat f,
|
||||
builtin::TexelFormat f,
|
||||
builtin::Access a);
|
||||
|
||||
private:
|
||||
|
|
|
@ -43,9 +43,9 @@ TEST(SpvParserTypeTest, SameArgumentsGivesSamePointer) {
|
|||
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, type::TexelFormat::kR32Uint,
|
||||
EXPECT_EQ(ty.StorageTexture(type::TextureDimension::k2d, builtin::TexelFormat::kR32Uint,
|
||||
builtin::Access::kRead),
|
||||
ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
|
||||
ty.StorageTexture(type::TextureDimension::k2d, builtin::TexelFormat::kR32Uint,
|
||||
builtin::Access::kRead));
|
||||
}
|
||||
|
||||
|
@ -80,17 +80,17 @@ TEST(SpvParserTypeTest, DifferentArgumentsGivesDifferentPointer) {
|
|||
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, type::TexelFormat::kR32Uint,
|
||||
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, builtin::TexelFormat::kR32Uint,
|
||||
builtin::Access::kRead),
|
||||
ty.StorageTexture(type::TextureDimension::k3d, type::TexelFormat::kR32Uint,
|
||||
ty.StorageTexture(type::TextureDimension::k3d, builtin::TexelFormat::kR32Uint,
|
||||
builtin::Access::kRead));
|
||||
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
|
||||
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, builtin::TexelFormat::kR32Uint,
|
||||
builtin::Access::kRead),
|
||||
ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Sint,
|
||||
ty.StorageTexture(type::TextureDimension::k2d, builtin::TexelFormat::kR32Sint,
|
||||
builtin::Access::kRead));
|
||||
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
|
||||
EXPECT_NE(ty.StorageTexture(type::TextureDimension::k2d, builtin::TexelFormat::kR32Uint,
|
||||
builtin::Access::kRead),
|
||||
ty.StorageTexture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
|
||||
ty.StorageTexture(type::TextureDimension::k2d, builtin::TexelFormat::kR32Uint,
|
||||
builtin::Access::kWrite));
|
||||
}
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Handle) {
|
|||
// a = b;
|
||||
|
||||
auto make_type = [&] {
|
||||
return ty.storage_texture(type::TextureDimension::k1d, type::TexelFormat::kRgba8Unorm,
|
||||
return ty.storage_texture(type::TextureDimension::k1d, builtin::TexelFormat::kRgba8Unorm,
|
||||
builtin::Access::kWrite);
|
||||
};
|
||||
|
||||
|
|
|
@ -2083,7 +2083,7 @@ inline std::ostream& operator<<(std::ostream& out, Texture data) {
|
|||
struct TextureTestParams {
|
||||
type::TextureDimension dim;
|
||||
Texture type = Texture::kF32;
|
||||
type::TexelFormat format = type::TexelFormat::kR32Float;
|
||||
builtin::TexelFormat format = builtin::TexelFormat::kR32Float;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, TextureTestParams data) {
|
||||
out << data.dim << "_" << data.type;
|
||||
|
|
|
@ -484,7 +484,7 @@ class DependencyScanner {
|
|||
graph_.resolved_identifiers.Add(from, ResolvedIdentifier(addr));
|
||||
return;
|
||||
}
|
||||
if (auto fmt = type::ParseTexelFormat(s); fmt != type::TexelFormat::kUndefined) {
|
||||
if (auto fmt = builtin::ParseTexelFormat(s); fmt != builtin::TexelFormat::kUndefined) {
|
||||
graph_.resolved_identifiers.Add(from, ResolvedIdentifier(fmt));
|
||||
return;
|
||||
}
|
||||
|
@ -868,7 +868,7 @@ std::string ResolvedIdentifier::String(const SymbolTable& symbols, diag::List& d
|
|||
if (auto addr = AddressSpace(); addr != builtin::AddressSpace::kUndefined) {
|
||||
return "address space '" + utils::ToString(addr) + "'";
|
||||
}
|
||||
if (auto fmt = TexelFormat(); fmt != type::TexelFormat::kUndefined) {
|
||||
if (auto fmt = TexelFormat(); fmt != builtin::TexelFormat::kUndefined) {
|
||||
return "texel format '" + utils::ToString(fmt) + "'";
|
||||
}
|
||||
TINT_UNREACHABLE(Resolver, diagnostics) << "unhandled ResolvedIdentifier";
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
|
||||
#include "src/tint/ast/module.h"
|
||||
#include "src/tint/builtin/access.h"
|
||||
#include "src/tint/builtin/texel_format.h"
|
||||
#include "src/tint/diagnostic/diagnostic.h"
|
||||
#include "src/tint/sem/builtin_type.h"
|
||||
#include "src/tint/symbol_table.h"
|
||||
#include "src/tint/type/builtin.h"
|
||||
#include "src/tint/type/texel_format.h"
|
||||
#include "src/tint/utils/hashmap.h"
|
||||
|
||||
namespace tint::resolver {
|
||||
|
@ -38,7 +38,7 @@ namespace tint::resolver {
|
|||
/// - builtin::Access
|
||||
/// - builtin::AddressSpace
|
||||
/// - type::Builtin
|
||||
/// - type::TexelFormat
|
||||
/// - builtin::TexelFormat
|
||||
class ResolvedIdentifier {
|
||||
public:
|
||||
ResolvedIdentifier() = default;
|
||||
|
@ -95,13 +95,13 @@ class ResolvedIdentifier {
|
|||
return type::Builtin::kUndefined;
|
||||
}
|
||||
|
||||
/// @return the texel format if the ResolvedIdentifier holds type::TexelFormat, otherwise
|
||||
/// type::TexelFormat::kUndefined
|
||||
type::TexelFormat TexelFormat() const {
|
||||
if (auto n = std::get_if<type::TexelFormat>(&value_)) {
|
||||
/// @return the texel format if the ResolvedIdentifier holds builtin::TexelFormat, otherwise
|
||||
/// builtin::TexelFormat::kUndefined
|
||||
builtin::TexelFormat TexelFormat() const {
|
||||
if (auto n = std::get_if<builtin::TexelFormat>(&value_)) {
|
||||
return *n;
|
||||
}
|
||||
return type::TexelFormat::kUndefined;
|
||||
return builtin::TexelFormat::kUndefined;
|
||||
}
|
||||
|
||||
/// @param value the value to compare the ResolvedIdentifier to
|
||||
|
@ -133,7 +133,7 @@ class ResolvedIdentifier {
|
|||
builtin::Access,
|
||||
builtin::AddressSpace,
|
||||
type::Builtin,
|
||||
type::TexelFormat>
|
||||
builtin::TexelFormat>
|
||||
value_;
|
||||
};
|
||||
|
||||
|
|
|
@ -1501,7 +1501,7 @@ INSTANTIATE_TEST_SUITE_P(Functions,
|
|||
} // namespace resolve_to_address_space
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Resolve to type::TexelFormat tests
|
||||
// Resolve to builtin::TexelFormat tests
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
namespace resolve_to_texel_format {
|
||||
|
||||
|
@ -1519,7 +1519,7 @@ TEST_P(ResolverDependencyGraphResolveToTexelFormat, Resolve) {
|
|||
|
||||
auto resolved = Build().resolved_identifiers.Get(ident);
|
||||
ASSERT_TRUE(resolved);
|
||||
EXPECT_EQ(resolved->TexelFormat(), type::ParseTexelFormat(name))
|
||||
EXPECT_EQ(resolved->TexelFormat(), builtin::ParseTexelFormat(name))
|
||||
<< resolved->String(Symbols(), Diagnostics());
|
||||
}
|
||||
|
||||
|
@ -1571,17 +1571,17 @@ TEST_P(ResolverDependencyGraphResolveToTexelFormat, ShadowedByFunc) {
|
|||
INSTANTIATE_TEST_SUITE_P(Types,
|
||||
ResolverDependencyGraphResolveToTexelFormat,
|
||||
testing::Combine(testing::ValuesIn(kTypeUseKinds),
|
||||
testing::ValuesIn(type::kTexelFormatStrings)));
|
||||
testing::ValuesIn(builtin::kTexelFormatStrings)));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(Values,
|
||||
ResolverDependencyGraphResolveToTexelFormat,
|
||||
testing::Combine(testing::ValuesIn(kValueUseKinds),
|
||||
testing::ValuesIn(type::kTexelFormatStrings)));
|
||||
testing::ValuesIn(builtin::kTexelFormatStrings)));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(Functions,
|
||||
ResolverDependencyGraphResolveToTexelFormat,
|
||||
testing::Combine(testing::ValuesIn(kFuncUseKinds),
|
||||
testing::ValuesIn(type::kTexelFormatStrings)));
|
||||
testing::ValuesIn(builtin::kTexelFormatStrings)));
|
||||
|
||||
} // namespace resolve_to_texel_format
|
||||
|
||||
|
@ -1735,8 +1735,8 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
|
|||
GlobalVar(Sym(), ty.depth_multisampled_texture(type::TextureDimension::k2d));
|
||||
GlobalVar(Sym(), ty.external_texture());
|
||||
GlobalVar(Sym(), ty.multisampled_texture(type::TextureDimension::k2d, T));
|
||||
GlobalVar(Sym(), ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Float,
|
||||
builtin::Access::kRead));
|
||||
GlobalVar(Sym(), ty.storage_texture(type::TextureDimension::k2d,
|
||||
builtin::TexelFormat::kR32Float, builtin::Access::kRead));
|
||||
GlobalVar(Sym(), ty.sampler(type::SamplerKind::kSampler));
|
||||
|
||||
GlobalVar(Sym(), ty.i32(), utils::Vector{Binding(V), Group(V)});
|
||||
|
|
|
@ -184,9 +184,9 @@ TEST_P(ResolverExpressionKindTest, Test) {
|
|||
sym = Sym("rgba8unorm");
|
||||
check_expr = [](const sem::Expression* expr) {
|
||||
ASSERT_NE(expr, nullptr);
|
||||
auto* enum_expr = expr->As<sem::BuiltinEnumExpression<type::TexelFormat>>();
|
||||
auto* enum_expr = expr->As<sem::BuiltinEnumExpression<builtin::TexelFormat>>();
|
||||
ASSERT_NE(enum_expr, nullptr);
|
||||
EXPECT_EQ(enum_expr->Value(), type::TexelFormat::kRgba8Unorm);
|
||||
EXPECT_EQ(enum_expr->Value(), builtin::TexelFormat::kRgba8Unorm);
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -328,7 +328,7 @@ class TemplateNumberMatcher : public NumberMatcher {
|
|||
// TODO(bclayton): See if we can move more of this hand-rolled code to the
|
||||
// template
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
using TexelFormat = type::TexelFormat;
|
||||
using TexelFormat = builtin::TexelFormat;
|
||||
using Access = builtin::Access;
|
||||
using AddressSpace = builtin::AddressSpace;
|
||||
using ParameterUsage = sem::ParameterUsage;
|
||||
|
|
|
@ -414,9 +414,9 @@ TEST_F(IntrinsicTableTest, MatchWOStorageTexture) {
|
|||
auto* i32 = create<type::I32>();
|
||||
auto* vec2_i32 = create<type::Vector>(i32, 2u);
|
||||
auto* vec4_f32 = create<type::Vector>(f32, 4u);
|
||||
auto* subtype = type::StorageTexture::SubtypeFor(type::TexelFormat::kR32Float, Types());
|
||||
auto* subtype = type::StorageTexture::SubtypeFor(builtin::TexelFormat::kR32Float, Types());
|
||||
auto* tex =
|
||||
create<type::StorageTexture>(type::TextureDimension::k2d, type::TexelFormat::kR32Float,
|
||||
create<type::StorageTexture>(type::TextureDimension::k2d, builtin::TexelFormat::kR32Float,
|
||||
builtin::Access::kWrite, subtype);
|
||||
|
||||
auto result = table->Lookup(BuiltinType::kTextureStore, utils::Vector{tex, vec2_i32, vec4_f32},
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::sem::BuiltinEnumExpression<tint::builtin::Access>);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::sem::BuiltinEnumExpression<tint::builtin::AddressSpace>);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::sem::BuiltinEnumExpression<tint::type::TexelFormat>);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::sem::BuiltinEnumExpression<tint::builtin::TexelFormat>);
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
@ -1502,7 +1502,7 @@ sem::BuiltinEnumExpression<builtin::AddressSpace>* Resolver::AddressSpaceExpress
|
|||
return sem_.AsAddressSpace(Expression(expr));
|
||||
}
|
||||
|
||||
sem::BuiltinEnumExpression<type::TexelFormat>* Resolver::TexelFormatExpression(
|
||||
sem::BuiltinEnumExpression<builtin::TexelFormat>* Resolver::TexelFormatExpression(
|
||||
const ast::Expression* expr) {
|
||||
return sem_.AsTexelFormat(Expression(expr));
|
||||
}
|
||||
|
@ -2987,8 +2987,8 @@ sem::Expression* Resolver::Identifier(const ast::IdentifierExpression* expr) {
|
|||
expr, current_statement_, addr);
|
||||
}
|
||||
|
||||
if (auto fmt = resolved->TexelFormat(); fmt != type::TexelFormat::kUndefined) {
|
||||
return builder_->create<sem::BuiltinEnumExpression<type::TexelFormat>>(
|
||||
if (auto fmt = resolved->TexelFormat(); fmt != builtin::TexelFormat::kUndefined) {
|
||||
return builder_->create<sem::BuiltinEnumExpression<builtin::TexelFormat>>(
|
||||
expr, current_statement_, fmt);
|
||||
}
|
||||
|
||||
|
|
|
@ -145,10 +145,11 @@ class Resolver {
|
|||
sem::BuiltinEnumExpression<builtin::AddressSpace>* AddressSpaceExpression(
|
||||
const ast::Expression* expr);
|
||||
|
||||
/// @returns the call of Expression() cast to a sem::BuiltinEnumExpression<type::TexelFormat>.
|
||||
/// If the sem::Expression is not a sem::BuiltinEnumExpression<type::TexelFormat>, then an error
|
||||
/// diagnostic is raised and nullptr is returned.
|
||||
sem::BuiltinEnumExpression<type::TexelFormat>* TexelFormatExpression(
|
||||
/// @returns the call of Expression() cast to a
|
||||
/// sem::BuiltinEnumExpression<builtin::TexelFormat>. If the sem::Expression is not a
|
||||
/// sem::BuiltinEnumExpression<builtin::TexelFormat>, then an error diagnostic is raised and
|
||||
/// nullptr is returned.
|
||||
sem::BuiltinEnumExpression<builtin::TexelFormat>* TexelFormatExpression(
|
||||
const ast::Expression* expr);
|
||||
|
||||
/// @returns the call of Expression() cast to a sem::BuiltinEnumExpression<builtin::Access>*.
|
||||
|
|
|
@ -84,7 +84,7 @@ void SemHelper::ErrorUnexpectedExprKind(const sem::Expression* expr,
|
|||
std::string(wanted),
|
||||
addr->Declaration()->source);
|
||||
},
|
||||
[&](const sem::BuiltinEnumExpression<type::TexelFormat>* fmt) {
|
||||
[&](const sem::BuiltinEnumExpression<builtin::TexelFormat>* fmt) {
|
||||
AddError("cannot use texel format '" + utils::ToString(fmt->Value()) + "' as " +
|
||||
std::string(wanted),
|
||||
fmt->Declaration()->source);
|
||||
|
|
|
@ -120,11 +120,11 @@ class SemHelper {
|
|||
|
||||
/// @param expr the semantic node
|
||||
/// @returns nullptr if @p expr is nullptr, or @p expr cast to
|
||||
/// sem::BuiltinEnumExpression<type::TexelFormat> if the cast is successful, otherwise an error
|
||||
/// diagnostic is raised.
|
||||
sem::BuiltinEnumExpression<type::TexelFormat>* AsTexelFormat(sem::Expression* expr) const {
|
||||
/// sem::BuiltinEnumExpression<builtin::TexelFormat> if the cast is successful, otherwise an
|
||||
/// error diagnostic is raised.
|
||||
sem::BuiltinEnumExpression<builtin::TexelFormat>* AsTexelFormat(sem::Expression* expr) const {
|
||||
if (TINT_LIKELY(expr)) {
|
||||
auto* enum_expr = expr->As<sem::BuiltinEnumExpression<type::TexelFormat>>();
|
||||
auto* enum_expr = expr->As<sem::BuiltinEnumExpression<builtin::TexelFormat>>();
|
||||
if (TINT_LIKELY(enum_expr)) {
|
||||
return enum_expr;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "gtest/gtest.h"
|
||||
#include "src/tint/builtin/address_space.h"
|
||||
#include "src/tint/builtin/extension.h"
|
||||
#include "src/tint/builtin/texel_format.h"
|
||||
#include "src/tint/resolver/resolver_test_helper.h"
|
||||
#include "src/tint/sem/index_accessor_expression.h"
|
||||
#include "src/tint/sem/member_accessor_expression.h"
|
||||
|
@ -191,10 +192,11 @@ TEST_P(SideEffectsBuiltinTest, Test) {
|
|||
Group(0_a), Binding(AInt(next_binding++)));
|
||||
GlobalVar("t2d_multi", ty.multisampled_texture(type::TextureDimension::k2d, ty.f32()),
|
||||
Group(0_a), Binding(AInt(next_binding++)));
|
||||
GlobalVar("tstorage2d",
|
||||
ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Float,
|
||||
tint::builtin::Access::kWrite),
|
||||
Group(0_a), Binding(AInt(next_binding++)));
|
||||
GlobalVar(
|
||||
"tstorage2d",
|
||||
ty.storage_texture(type::TextureDimension::k2d, tint::builtin::TexelFormat::kR32Float,
|
||||
tint::builtin::Access::kWrite),
|
||||
Group(0_a), Binding(AInt(next_binding++)));
|
||||
GlobalVar("s2d", ty.sampler(type::SamplerKind::kSampler), Group(0_a),
|
||||
Binding(AInt(next_binding++)));
|
||||
GlobalVar("scomp", ty.sampler(type::SamplerKind::kComparisonSampler), Group(0_a),
|
||||
|
|
|
@ -1074,7 +1074,7 @@ TEST_P(StorageTextureDimensionTest, All) {
|
|||
// var a : texture_storage_*<r32uint, write>;
|
||||
auto& params = GetParam();
|
||||
|
||||
auto st = ty(Source{{12, 34}}, params.name, utils::ToString(type::TexelFormat::kR32Uint),
|
||||
auto st = ty(Source{{12, 34}}, params.name, utils::ToString(builtin::TexelFormat::kR32Uint),
|
||||
utils::ToString(builtin::Access::kWrite));
|
||||
|
||||
GlobalVar("a", st, Group(0_a), Binding(0_a));
|
||||
|
@ -1091,27 +1091,28 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,
|
|||
testing::ValuesIn(Dimension_cases));
|
||||
|
||||
struct FormatParams {
|
||||
type::TexelFormat format;
|
||||
builtin::TexelFormat format;
|
||||
bool is_valid;
|
||||
};
|
||||
|
||||
static constexpr FormatParams format_cases[] = {FormatParams{type::TexelFormat::kBgra8Unorm, true},
|
||||
FormatParams{type::TexelFormat::kR32Float, true},
|
||||
FormatParams{type::TexelFormat::kR32Sint, true},
|
||||
FormatParams{type::TexelFormat::kR32Uint, true},
|
||||
FormatParams{type::TexelFormat::kRg32Float, true},
|
||||
FormatParams{type::TexelFormat::kRg32Sint, true},
|
||||
FormatParams{type::TexelFormat::kRg32Uint, true},
|
||||
FormatParams{type::TexelFormat::kRgba16Float, true},
|
||||
FormatParams{type::TexelFormat::kRgba16Sint, true},
|
||||
FormatParams{type::TexelFormat::kRgba16Uint, true},
|
||||
FormatParams{type::TexelFormat::kRgba32Float, true},
|
||||
FormatParams{type::TexelFormat::kRgba32Sint, true},
|
||||
FormatParams{type::TexelFormat::kRgba32Uint, true},
|
||||
FormatParams{type::TexelFormat::kRgba8Sint, true},
|
||||
FormatParams{type::TexelFormat::kRgba8Snorm, true},
|
||||
FormatParams{type::TexelFormat::kRgba8Uint, true},
|
||||
FormatParams{type::TexelFormat::kRgba8Unorm, true}};
|
||||
static constexpr FormatParams format_cases[] = {
|
||||
FormatParams{builtin::TexelFormat::kBgra8Unorm, true},
|
||||
FormatParams{builtin::TexelFormat::kR32Float, true},
|
||||
FormatParams{builtin::TexelFormat::kR32Sint, true},
|
||||
FormatParams{builtin::TexelFormat::kR32Uint, true},
|
||||
FormatParams{builtin::TexelFormat::kRg32Float, true},
|
||||
FormatParams{builtin::TexelFormat::kRg32Sint, true},
|
||||
FormatParams{builtin::TexelFormat::kRg32Uint, true},
|
||||
FormatParams{builtin::TexelFormat::kRgba16Float, true},
|
||||
FormatParams{builtin::TexelFormat::kRgba16Sint, true},
|
||||
FormatParams{builtin::TexelFormat::kRgba16Uint, true},
|
||||
FormatParams{builtin::TexelFormat::kRgba32Float, true},
|
||||
FormatParams{builtin::TexelFormat::kRgba32Sint, true},
|
||||
FormatParams{builtin::TexelFormat::kRgba32Uint, true},
|
||||
FormatParams{builtin::TexelFormat::kRgba8Sint, true},
|
||||
FormatParams{builtin::TexelFormat::kRgba8Snorm, true},
|
||||
FormatParams{builtin::TexelFormat::kRgba8Uint, true},
|
||||
FormatParams{builtin::TexelFormat::kRgba8Unorm, true}};
|
||||
|
||||
using StorageTextureFormatTest = ResolverTestWithParam<FormatParams>;
|
||||
TEST_P(StorageTextureFormatTest, All) {
|
||||
|
@ -1185,7 +1186,7 @@ TEST_F(StorageTextureAccessTest, RWAccess_Fail) {
|
|||
// var a : texture_storage_1d<r32uint, read_write>;
|
||||
|
||||
auto st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d,
|
||||
type::TexelFormat::kR32Uint, builtin::Access::kReadWrite);
|
||||
builtin::TexelFormat::kR32Uint, builtin::Access::kReadWrite);
|
||||
|
||||
GlobalVar("a", st, Group(0_a), Binding(0_a));
|
||||
|
||||
|
@ -1199,7 +1200,7 @@ TEST_F(StorageTextureAccessTest, ReadOnlyAccess_Fail) {
|
|||
// var a : texture_storage_1d<r32uint, read>;
|
||||
|
||||
auto st = ty.storage_texture(Source{{12, 34}}, type::TextureDimension::k1d,
|
||||
type::TexelFormat::kR32Uint, builtin::Access::kRead);
|
||||
builtin::TexelFormat::kR32Uint, builtin::Access::kRead);
|
||||
|
||||
GlobalVar("a", st, Group(0_a), Binding(0_a));
|
||||
|
||||
|
@ -1212,7 +1213,7 @@ TEST_F(StorageTextureAccessTest, WriteOnlyAccess_Pass) {
|
|||
// @group(0) @binding(0)
|
||||
// var a : texture_storage_1d<r32uint, write>;
|
||||
|
||||
auto st = ty.storage_texture(type::TextureDimension::k1d, type::TexelFormat::kR32Uint,
|
||||
auto st = ty.storage_texture(type::TextureDimension::k1d, builtin::TexelFormat::kR32Uint,
|
||||
builtin::Access::kWrite);
|
||||
|
||||
GlobalVar("a", st, Group(0_a), Binding(0_a));
|
||||
|
|
|
@ -88,25 +88,25 @@ bool IsValidStorageTextureDimension(type::TextureDimension dim) {
|
|||
}
|
||||
}
|
||||
|
||||
bool IsValidStorageTextureTexelFormat(type::TexelFormat format) {
|
||||
bool IsValidStorageTextureTexelFormat(builtin::TexelFormat format) {
|
||||
switch (format) {
|
||||
case type::TexelFormat::kBgra8Unorm:
|
||||
case type::TexelFormat::kR32Uint:
|
||||
case type::TexelFormat::kR32Sint:
|
||||
case type::TexelFormat::kR32Float:
|
||||
case type::TexelFormat::kRg32Uint:
|
||||
case type::TexelFormat::kRg32Sint:
|
||||
case type::TexelFormat::kRg32Float:
|
||||
case type::TexelFormat::kRgba8Unorm:
|
||||
case type::TexelFormat::kRgba8Snorm:
|
||||
case type::TexelFormat::kRgba8Uint:
|
||||
case type::TexelFormat::kRgba8Sint:
|
||||
case type::TexelFormat::kRgba16Uint:
|
||||
case type::TexelFormat::kRgba16Sint:
|
||||
case type::TexelFormat::kRgba16Float:
|
||||
case type::TexelFormat::kRgba32Uint:
|
||||
case type::TexelFormat::kRgba32Sint:
|
||||
case type::TexelFormat::kRgba32Float:
|
||||
case builtin::TexelFormat::kBgra8Unorm:
|
||||
case builtin::TexelFormat::kR32Uint:
|
||||
case builtin::TexelFormat::kR32Sint:
|
||||
case builtin::TexelFormat::kR32Float:
|
||||
case builtin::TexelFormat::kRg32Uint:
|
||||
case builtin::TexelFormat::kRg32Sint:
|
||||
case builtin::TexelFormat::kRg32Float:
|
||||
case builtin::TexelFormat::kRgba8Unorm:
|
||||
case builtin::TexelFormat::kRgba8Snorm:
|
||||
case builtin::TexelFormat::kRgba8Uint:
|
||||
case builtin::TexelFormat::kRgba8Sint:
|
||||
case builtin::TexelFormat::kRgba16Uint:
|
||||
case builtin::TexelFormat::kRgba16Sint:
|
||||
case builtin::TexelFormat::kRgba16Float:
|
||||
case builtin::TexelFormat::kRgba32Uint:
|
||||
case builtin::TexelFormat::kRgba32Sint:
|
||||
case builtin::TexelFormat::kRgba32Float:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
|
|
@ -1040,7 +1040,7 @@ Transform::ApplyResult BuiltinPolyfill::Apply(const Program* src,
|
|||
auto& sig = builtin->Signature();
|
||||
auto* tex = sig.Parameter(sem::ParameterUsage::kTexture);
|
||||
if (auto* stex = tex->Type()->As<type::StorageTexture>()) {
|
||||
if (stex->texel_format() == type::TexelFormat::kBgra8Unorm) {
|
||||
if (stex->texel_format() == builtin::TexelFormat::kBgra8Unorm) {
|
||||
size_t value_idx = static_cast<size_t>(
|
||||
sig.IndexOf(sem::ParameterUsage::kValue));
|
||||
ctx.Replace(expr, [&ctx, expr, value_idx] {
|
||||
|
@ -1140,10 +1140,11 @@ Transform::ApplyResult BuiltinPolyfill::Apply(const Program* src,
|
|||
if (polyfill.bgra8unorm) {
|
||||
if (auto* ty_expr = src->Sem().Get<sem::TypeExpression>(expr)) {
|
||||
if (auto* tex = ty_expr->Type()->As<type::StorageTexture>()) {
|
||||
if (tex->texel_format() == type::TexelFormat::kBgra8Unorm) {
|
||||
if (tex->texel_format() == builtin::TexelFormat::kBgra8Unorm) {
|
||||
ctx.Replace(expr, [&ctx, tex] {
|
||||
return ctx.dst->Expr(ctx.dst->ty.storage_texture(
|
||||
tex->dim(), type::TexelFormat::kRgba8Unorm, tex->access()));
|
||||
tex->dim(), builtin::TexelFormat::kRgba8Unorm,
|
||||
tex->access()));
|
||||
});
|
||||
made_changes = true;
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
#include <vector>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/builtin/texel_format.h"
|
||||
#include "src/tint/transform/test_helper.h"
|
||||
#include "src/tint/type/builtin.h"
|
||||
#include "src/tint/type/texel_format.h"
|
||||
|
||||
namespace tint::transform {
|
||||
namespace {
|
||||
|
@ -1931,7 +1931,7 @@ std::vector<const char*> Identifiers() {
|
|||
out.push_back(ident);
|
||||
}
|
||||
}
|
||||
for (auto* ident : type::kTexelFormatStrings) {
|
||||
for (auto* ident : builtin::kTexelFormatStrings) {
|
||||
out.push_back(ident);
|
||||
}
|
||||
for (auto* ident : builtin::kAccessStrings) {
|
||||
|
|
|
@ -25,7 +25,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::StorageTexture);
|
|||
namespace tint::type {
|
||||
|
||||
StorageTexture::StorageTexture(TextureDimension dim,
|
||||
type::TexelFormat format,
|
||||
builtin::TexelFormat format,
|
||||
builtin::Access access,
|
||||
Type* subtype)
|
||||
: Base(utils::Hash(TypeInfo::Of<StorageTexture>().full_hashcode, dim, format, access), dim),
|
||||
|
@ -48,35 +48,35 @@ std::string StorageTexture::FriendlyName(const SymbolTable&) const {
|
|||
return out.str();
|
||||
}
|
||||
|
||||
Type* StorageTexture::SubtypeFor(type::TexelFormat format, Manager& type_mgr) {
|
||||
Type* StorageTexture::SubtypeFor(builtin::TexelFormat format, Manager& type_mgr) {
|
||||
switch (format) {
|
||||
case type::TexelFormat::kR32Uint:
|
||||
case type::TexelFormat::kRgba8Uint:
|
||||
case type::TexelFormat::kRg32Uint:
|
||||
case type::TexelFormat::kRgba16Uint:
|
||||
case type::TexelFormat::kRgba32Uint: {
|
||||
case builtin::TexelFormat::kR32Uint:
|
||||
case builtin::TexelFormat::kRgba8Uint:
|
||||
case builtin::TexelFormat::kRg32Uint:
|
||||
case builtin::TexelFormat::kRgba16Uint:
|
||||
case builtin::TexelFormat::kRgba32Uint: {
|
||||
return type_mgr.Get<U32>();
|
||||
}
|
||||
|
||||
case type::TexelFormat::kR32Sint:
|
||||
case type::TexelFormat::kRgba8Sint:
|
||||
case type::TexelFormat::kRg32Sint:
|
||||
case type::TexelFormat::kRgba16Sint:
|
||||
case type::TexelFormat::kRgba32Sint: {
|
||||
case builtin::TexelFormat::kR32Sint:
|
||||
case builtin::TexelFormat::kRgba8Sint:
|
||||
case builtin::TexelFormat::kRg32Sint:
|
||||
case builtin::TexelFormat::kRgba16Sint:
|
||||
case builtin::TexelFormat::kRgba32Sint: {
|
||||
return type_mgr.Get<I32>();
|
||||
}
|
||||
|
||||
case type::TexelFormat::kBgra8Unorm:
|
||||
case type::TexelFormat::kRgba8Unorm:
|
||||
case type::TexelFormat::kRgba8Snorm:
|
||||
case type::TexelFormat::kR32Float:
|
||||
case type::TexelFormat::kRg32Float:
|
||||
case type::TexelFormat::kRgba16Float:
|
||||
case type::TexelFormat::kRgba32Float: {
|
||||
case builtin::TexelFormat::kBgra8Unorm:
|
||||
case builtin::TexelFormat::kRgba8Unorm:
|
||||
case builtin::TexelFormat::kRgba8Snorm:
|
||||
case builtin::TexelFormat::kR32Float:
|
||||
case builtin::TexelFormat::kRg32Float:
|
||||
case builtin::TexelFormat::kRgba16Float:
|
||||
case builtin::TexelFormat::kRgba32Float: {
|
||||
return type_mgr.Get<F32>();
|
||||
}
|
||||
|
||||
case type::TexelFormat::kUndefined:
|
||||
case builtin::TexelFormat::kUndefined:
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "src/tint/builtin/access.h"
|
||||
#include "src/tint/type/texel_format.h"
|
||||
#include "src/tint/builtin/texel_format.h"
|
||||
#include "src/tint/type/texture.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
|
@ -38,7 +38,7 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
|
|||
/// @param access the access control type of the texture
|
||||
/// @param subtype the storage subtype. Use SubtypeFor() to calculate this.
|
||||
StorageTexture(TextureDimension dim,
|
||||
type::TexelFormat format,
|
||||
builtin::TexelFormat format,
|
||||
builtin::Access access,
|
||||
Type* subtype);
|
||||
|
||||
|
@ -53,7 +53,7 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
|
|||
Type* type() const { return subtype_; }
|
||||
|
||||
/// @returns the texel format
|
||||
type::TexelFormat texel_format() const { return texel_format_; }
|
||||
builtin::TexelFormat texel_format() const { return texel_format_; }
|
||||
|
||||
/// @returns the access control
|
||||
builtin::Access access() const { return access_; }
|
||||
|
@ -66,14 +66,14 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
|
|||
/// @param format the storage texture image format
|
||||
/// @param type_mgr the Manager used to build the returned type
|
||||
/// @returns the storage texture subtype for the given TexelFormat
|
||||
static Type* SubtypeFor(type::TexelFormat format, Manager& type_mgr);
|
||||
static Type* SubtypeFor(builtin::TexelFormat format, Manager& type_mgr);
|
||||
|
||||
/// @param ctx the clone context
|
||||
/// @returns a clone of this type
|
||||
StorageTexture* Clone(CloneContext& ctx) const override;
|
||||
|
||||
private:
|
||||
type::TexelFormat const texel_format_;
|
||||
builtin::TexelFormat const texel_format_;
|
||||
builtin::Access const access_;
|
||||
Type* const subtype_;
|
||||
};
|
||||
|
|
|
@ -24,23 +24,25 @@ namespace tint::type {
|
|||
namespace {
|
||||
|
||||
struct StorageTextureTest : public TestHelper {
|
||||
StorageTexture* Create(TextureDimension dims, type::TexelFormat fmt, builtin::Access access) {
|
||||
StorageTexture* Create(TextureDimension dims,
|
||||
builtin::TexelFormat fmt,
|
||||
builtin::Access access) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(fmt, Types());
|
||||
return create<StorageTexture>(dims, fmt, access, subtype);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(StorageTextureTest, Creation) {
|
||||
auto* a = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float,
|
||||
auto* a = Create(TextureDimension::kCube, builtin::TexelFormat::kRgba32Float,
|
||||
builtin::Access::kReadWrite);
|
||||
auto* b = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float,
|
||||
auto* b = Create(TextureDimension::kCube, builtin::TexelFormat::kRgba32Float,
|
||||
builtin::Access::kReadWrite);
|
||||
auto* c = Create(TextureDimension::k2d, builtin::TexelFormat::kRgba32Float,
|
||||
builtin::Access::kReadWrite);
|
||||
auto* d = Create(TextureDimension::kCube, builtin::TexelFormat::kR32Float,
|
||||
builtin::Access::kReadWrite);
|
||||
auto* c =
|
||||
Create(TextureDimension::k2d, type::TexelFormat::kRgba32Float, builtin::Access::kReadWrite);
|
||||
auto* d =
|
||||
Create(TextureDimension::kCube, type::TexelFormat::kR32Float, builtin::Access::kReadWrite);
|
||||
auto* e =
|
||||
Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, builtin::Access::kRead);
|
||||
Create(TextureDimension::kCube, builtin::TexelFormat::kRgba32Float, builtin::Access::kRead);
|
||||
|
||||
EXPECT_TRUE(a->type()->Is<F32>());
|
||||
EXPECT_EQ(a->dim(), TextureDimension::kCube);
|
||||
|
@ -52,25 +54,25 @@ TEST_F(StorageTextureTest, Creation) {
|
|||
}
|
||||
|
||||
TEST_F(StorageTextureTest, Hash) {
|
||||
auto* a = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float,
|
||||
auto* a = Create(TextureDimension::kCube, builtin::TexelFormat::kRgba32Float,
|
||||
builtin::Access::kReadWrite);
|
||||
auto* b = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float,
|
||||
auto* b = Create(TextureDimension::kCube, builtin::TexelFormat::kRgba32Float,
|
||||
builtin::Access::kReadWrite);
|
||||
|
||||
EXPECT_EQ(a->unique_hash, b->unique_hash);
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTest, Equals) {
|
||||
auto* a = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float,
|
||||
auto* a = Create(TextureDimension::kCube, builtin::TexelFormat::kRgba32Float,
|
||||
builtin::Access::kReadWrite);
|
||||
auto* b = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float,
|
||||
auto* b = Create(TextureDimension::kCube, builtin::TexelFormat::kRgba32Float,
|
||||
builtin::Access::kReadWrite);
|
||||
auto* c = Create(TextureDimension::k2d, builtin::TexelFormat::kRgba32Float,
|
||||
builtin::Access::kReadWrite);
|
||||
auto* d = Create(TextureDimension::kCube, builtin::TexelFormat::kR32Float,
|
||||
builtin::Access::kReadWrite);
|
||||
auto* c =
|
||||
Create(TextureDimension::k2d, type::TexelFormat::kRgba32Float, builtin::Access::kReadWrite);
|
||||
auto* d =
|
||||
Create(TextureDimension::kCube, type::TexelFormat::kR32Float, builtin::Access::kReadWrite);
|
||||
auto* e =
|
||||
Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float, builtin::Access::kRead);
|
||||
Create(TextureDimension::kCube, builtin::TexelFormat::kRgba32Float, builtin::Access::kRead);
|
||||
|
||||
EXPECT_TRUE(a->Equals(*b));
|
||||
EXPECT_FALSE(a->Equals(*c));
|
||||
|
@ -80,25 +82,25 @@ TEST_F(StorageTextureTest, Equals) {
|
|||
}
|
||||
|
||||
TEST_F(StorageTextureTest, Dim) {
|
||||
auto* s = Create(TextureDimension::k2dArray, type::TexelFormat::kRgba32Float,
|
||||
auto* s = Create(TextureDimension::k2dArray, builtin::TexelFormat::kRgba32Float,
|
||||
builtin::Access::kReadWrite);
|
||||
EXPECT_EQ(s->dim(), TextureDimension::k2dArray);
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTest, Format) {
|
||||
auto* s = Create(TextureDimension::k2dArray, type::TexelFormat::kRgba32Float,
|
||||
auto* s = Create(TextureDimension::k2dArray, builtin::TexelFormat::kRgba32Float,
|
||||
builtin::Access::kReadWrite);
|
||||
EXPECT_EQ(s->texel_format(), type::TexelFormat::kRgba32Float);
|
||||
EXPECT_EQ(s->texel_format(), builtin::TexelFormat::kRgba32Float);
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTest, FriendlyName) {
|
||||
auto* s = Create(TextureDimension::k2dArray, type::TexelFormat::kRgba32Float,
|
||||
auto* s = Create(TextureDimension::k2dArray, builtin::TexelFormat::kRgba32Float,
|
||||
builtin::Access::kReadWrite);
|
||||
EXPECT_EQ(s->FriendlyName(Symbols()), "texture_storage_2d_array<rgba32float, read_write>");
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTest, F32) {
|
||||
auto* s = Create(TextureDimension::k2dArray, type::TexelFormat::kRgba32Float,
|
||||
auto* s = Create(TextureDimension::k2dArray, builtin::TexelFormat::kRgba32Float,
|
||||
builtin::Access::kReadWrite);
|
||||
|
||||
auto program = Build();
|
||||
|
@ -110,8 +112,8 @@ TEST_F(StorageTextureTest, F32) {
|
|||
}
|
||||
|
||||
TEST_F(StorageTextureTest, U32) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(type::TexelFormat::kRg32Uint, Types());
|
||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray, type::TexelFormat::kRg32Uint,
|
||||
auto* subtype = StorageTexture::SubtypeFor(builtin::TexelFormat::kRg32Uint, Types());
|
||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray, builtin::TexelFormat::kRg32Uint,
|
||||
builtin::Access::kReadWrite, subtype);
|
||||
|
||||
auto program = Build();
|
||||
|
@ -123,8 +125,8 @@ TEST_F(StorageTextureTest, U32) {
|
|||
}
|
||||
|
||||
TEST_F(StorageTextureTest, I32) {
|
||||
auto* subtype = StorageTexture::SubtypeFor(type::TexelFormat::kRgba32Sint, Types());
|
||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray, type::TexelFormat::kRgba32Sint,
|
||||
auto* subtype = StorageTexture::SubtypeFor(builtin::TexelFormat::kRgba32Sint, Types());
|
||||
auto* s = create<StorageTexture>(TextureDimension::k2dArray, builtin::TexelFormat::kRgba32Sint,
|
||||
builtin::Access::kReadWrite, subtype);
|
||||
|
||||
auto program = Build();
|
||||
|
@ -136,7 +138,7 @@ TEST_F(StorageTextureTest, I32) {
|
|||
}
|
||||
|
||||
TEST_F(StorageTextureTest, Clone) {
|
||||
auto* a = Create(TextureDimension::kCube, type::TexelFormat::kRgba32Float,
|
||||
auto* a = Create(TextureDimension::kCube, builtin::TexelFormat::kRgba32Float,
|
||||
builtin::Access::kReadWrite);
|
||||
|
||||
type::Manager mgr;
|
||||
|
@ -144,7 +146,7 @@ TEST_F(StorageTextureTest, Clone) {
|
|||
|
||||
auto* mt = a->Clone(ctx);
|
||||
EXPECT_EQ(mt->dim(), TextureDimension::kCube);
|
||||
EXPECT_EQ(mt->texel_format(), type::TexelFormat::kRgba32Float);
|
||||
EXPECT_EQ(mt->texel_format(), builtin::TexelFormat::kRgba32Float);
|
||||
EXPECT_TRUE(mt->type()->Is<F32>());
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ TEST_F(FlattenBindingsTest, NotFlat_MultipleNamespaces) {
|
|||
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(type::TextureDimension::k2d, type::TexelFormat::kR32Float,
|
||||
b.ty.storage_texture(type::TextureDimension::k2d, builtin::TexelFormat::kR32Float,
|
||||
builtin::Access::kWrite),
|
||||
b.Group(7_a), b.Binding(7_a));
|
||||
b.GlobalVar("texture4", b.ty.depth_texture(type::TextureDimension::k2d), b.Group(8_a),
|
||||
|
|
|
@ -2038,59 +2038,59 @@ bool GeneratorImpl::EmitHandleVariable(const ast::Var* var, const sem::Variable*
|
|||
if (auto* storage = type->As<type::StorageTexture>()) {
|
||||
out << "layout(";
|
||||
switch (storage->texel_format()) {
|
||||
case type::TexelFormat::kBgra8Unorm:
|
||||
case builtin::TexelFormat::kBgra8Unorm:
|
||||
TINT_ICE(Writer, diagnostics_)
|
||||
<< "bgra8unorm should have been polyfilled to rgba8unorm";
|
||||
break;
|
||||
case type::TexelFormat::kR32Uint:
|
||||
case builtin::TexelFormat::kR32Uint:
|
||||
out << "r32ui";
|
||||
break;
|
||||
case type::TexelFormat::kR32Sint:
|
||||
case builtin::TexelFormat::kR32Sint:
|
||||
out << "r32i";
|
||||
break;
|
||||
case type::TexelFormat::kR32Float:
|
||||
case builtin::TexelFormat::kR32Float:
|
||||
out << "r32f";
|
||||
break;
|
||||
case type::TexelFormat::kRgba8Unorm:
|
||||
case builtin::TexelFormat::kRgba8Unorm:
|
||||
out << "rgba8";
|
||||
break;
|
||||
case type::TexelFormat::kRgba8Snorm:
|
||||
case builtin::TexelFormat::kRgba8Snorm:
|
||||
out << "rgba8_snorm";
|
||||
break;
|
||||
case type::TexelFormat::kRgba8Uint:
|
||||
case builtin::TexelFormat::kRgba8Uint:
|
||||
out << "rgba8ui";
|
||||
break;
|
||||
case type::TexelFormat::kRgba8Sint:
|
||||
case builtin::TexelFormat::kRgba8Sint:
|
||||
out << "rgba8i";
|
||||
break;
|
||||
case type::TexelFormat::kRg32Uint:
|
||||
case builtin::TexelFormat::kRg32Uint:
|
||||
out << "rg32ui";
|
||||
break;
|
||||
case type::TexelFormat::kRg32Sint:
|
||||
case builtin::TexelFormat::kRg32Sint:
|
||||
out << "rg32i";
|
||||
break;
|
||||
case type::TexelFormat::kRg32Float:
|
||||
case builtin::TexelFormat::kRg32Float:
|
||||
out << "rg32f";
|
||||
break;
|
||||
case type::TexelFormat::kRgba16Uint:
|
||||
case builtin::TexelFormat::kRgba16Uint:
|
||||
out << "rgba16ui";
|
||||
break;
|
||||
case type::TexelFormat::kRgba16Sint:
|
||||
case builtin::TexelFormat::kRgba16Sint:
|
||||
out << "rgba16i";
|
||||
break;
|
||||
case type::TexelFormat::kRgba16Float:
|
||||
case builtin::TexelFormat::kRgba16Float:
|
||||
out << "rgba16f";
|
||||
break;
|
||||
case type::TexelFormat::kRgba32Uint:
|
||||
case builtin::TexelFormat::kRgba32Uint:
|
||||
out << "rgba32ui";
|
||||
break;
|
||||
case type::TexelFormat::kRgba32Sint:
|
||||
case builtin::TexelFormat::kRgba32Sint:
|
||||
out << "rgba32i";
|
||||
break;
|
||||
case type::TexelFormat::kRgba32Float:
|
||||
case builtin::TexelFormat::kRgba32Float:
|
||||
out << "rgba32f";
|
||||
break;
|
||||
case type::TexelFormat::kUndefined:
|
||||
case builtin::TexelFormat::kUndefined:
|
||||
TINT_ICE(Writer, diagnostics_) << "invalid texel format";
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -522,7 +522,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
|||
|
||||
struct GlslStorageTextureData {
|
||||
type::TextureDimension dim;
|
||||
type::TexelFormat imgfmt;
|
||||
builtin::TexelFormat imgfmt;
|
||||
std::string result;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, GlslStorageTextureData data) {
|
||||
|
@ -553,31 +553,31 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
GlslGeneratorImplTest_Type,
|
||||
GlslStorageTexturesTest,
|
||||
testing::Values(GlslStorageTextureData{type::TextureDimension::k1d,
|
||||
type::TexelFormat::kRgba8Unorm, "image1D tex;"},
|
||||
builtin::TexelFormat::kRgba8Unorm, "image1D tex;"},
|
||||
GlslStorageTextureData{type::TextureDimension::k2d,
|
||||
type::TexelFormat::kRgba16Float, "image2D tex;"},
|
||||
builtin::TexelFormat::kRgba16Float, "image2D tex;"},
|
||||
GlslStorageTextureData{type::TextureDimension::k2dArray,
|
||||
type::TexelFormat::kR32Float, "image2DArray tex;"},
|
||||
builtin::TexelFormat::kR32Float, "image2DArray tex;"},
|
||||
GlslStorageTextureData{type::TextureDimension::k3d,
|
||||
type::TexelFormat::kRg32Float, "image3D tex;"},
|
||||
builtin::TexelFormat::kRg32Float, "image3D tex;"},
|
||||
GlslStorageTextureData{type::TextureDimension::k1d,
|
||||
type::TexelFormat::kRgba32Float, "image1D tex;"},
|
||||
builtin::TexelFormat::kRgba32Float, "image1D tex;"},
|
||||
GlslStorageTextureData{type::TextureDimension::k2d,
|
||||
type::TexelFormat::kRgba16Uint, "image2D tex;"},
|
||||
builtin::TexelFormat::kRgba16Uint, "image2D tex;"},
|
||||
GlslStorageTextureData{type::TextureDimension::k2dArray,
|
||||
type::TexelFormat::kR32Uint, "image2DArray tex;"},
|
||||
builtin::TexelFormat::kR32Uint, "image2DArray tex;"},
|
||||
GlslStorageTextureData{type::TextureDimension::k3d,
|
||||
type::TexelFormat::kRg32Uint, "image3D tex;"},
|
||||
builtin::TexelFormat::kRg32Uint, "image3D tex;"},
|
||||
GlslStorageTextureData{type::TextureDimension::k1d,
|
||||
type::TexelFormat::kRgba32Uint, "image1D tex;"},
|
||||
builtin::TexelFormat::kRgba32Uint, "image1D tex;"},
|
||||
GlslStorageTextureData{type::TextureDimension::k2d,
|
||||
type::TexelFormat::kRgba16Sint, "image2D tex;"},
|
||||
builtin::TexelFormat::kRgba16Sint, "image2D tex;"},
|
||||
GlslStorageTextureData{type::TextureDimension::k2dArray,
|
||||
type::TexelFormat::kR32Sint, "image2DArray tex;"},
|
||||
builtin::TexelFormat::kR32Sint, "image2DArray tex;"},
|
||||
GlslStorageTextureData{type::TextureDimension::k3d,
|
||||
type::TexelFormat::kRg32Sint, "image3D tex;"},
|
||||
builtin::TexelFormat::kRg32Sint, "image3D tex;"},
|
||||
GlslStorageTextureData{type::TextureDimension::k1d,
|
||||
type::TexelFormat::kRgba32Sint, "image1D tex;"}));
|
||||
builtin::TexelFormat::kRgba32Sint, "image1D tex;"}));
|
||||
|
||||
} // namespace
|
||||
} // namespace tint::writer::glsl
|
||||
|
|
|
@ -87,27 +87,27 @@ namespace {
|
|||
|
||||
const char kTempNamePrefix[] = "tint_tmp";
|
||||
|
||||
const char* image_format_to_rwtexture_type(type::TexelFormat image_format) {
|
||||
const char* image_format_to_rwtexture_type(builtin::TexelFormat image_format) {
|
||||
switch (image_format) {
|
||||
case type::TexelFormat::kBgra8Unorm:
|
||||
case type::TexelFormat::kRgba8Unorm:
|
||||
case type::TexelFormat::kRgba8Snorm:
|
||||
case type::TexelFormat::kRgba16Float:
|
||||
case type::TexelFormat::kR32Float:
|
||||
case type::TexelFormat::kRg32Float:
|
||||
case type::TexelFormat::kRgba32Float:
|
||||
case builtin::TexelFormat::kBgra8Unorm:
|
||||
case builtin::TexelFormat::kRgba8Unorm:
|
||||
case builtin::TexelFormat::kRgba8Snorm:
|
||||
case builtin::TexelFormat::kRgba16Float:
|
||||
case builtin::TexelFormat::kR32Float:
|
||||
case builtin::TexelFormat::kRg32Float:
|
||||
case builtin::TexelFormat::kRgba32Float:
|
||||
return "float4";
|
||||
case type::TexelFormat::kRgba8Uint:
|
||||
case type::TexelFormat::kRgba16Uint:
|
||||
case type::TexelFormat::kR32Uint:
|
||||
case type::TexelFormat::kRg32Uint:
|
||||
case type::TexelFormat::kRgba32Uint:
|
||||
case builtin::TexelFormat::kRgba8Uint:
|
||||
case builtin::TexelFormat::kRgba16Uint:
|
||||
case builtin::TexelFormat::kR32Uint:
|
||||
case builtin::TexelFormat::kRg32Uint:
|
||||
case builtin::TexelFormat::kRgba32Uint:
|
||||
return "uint4";
|
||||
case type::TexelFormat::kRgba8Sint:
|
||||
case type::TexelFormat::kRgba16Sint:
|
||||
case type::TexelFormat::kR32Sint:
|
||||
case type::TexelFormat::kRg32Sint:
|
||||
case type::TexelFormat::kRgba32Sint:
|
||||
case builtin::TexelFormat::kRgba8Sint:
|
||||
case builtin::TexelFormat::kRgba16Sint:
|
||||
case builtin::TexelFormat::kR32Sint:
|
||||
case builtin::TexelFormat::kRg32Sint:
|
||||
case builtin::TexelFormat::kRgba32Sint:
|
||||
return "int4";
|
||||
default:
|
||||
return nullptr;
|
||||
|
|
|
@ -520,7 +520,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
|||
|
||||
struct HlslStorageTextureData {
|
||||
type::TextureDimension dim;
|
||||
type::TexelFormat imgfmt;
|
||||
builtin::TexelFormat imgfmt;
|
||||
std::string result;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, HlslStorageTextureData data) {
|
||||
|
@ -556,31 +556,31 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
HlslGeneratorImplTest_Type,
|
||||
HlslStorageTexturesTest,
|
||||
testing::Values(
|
||||
HlslStorageTextureData{type::TextureDimension::k1d, type::TexelFormat::kRgba8Unorm,
|
||||
HlslStorageTextureData{type::TextureDimension::k1d, builtin::TexelFormat::kRgba8Unorm,
|
||||
"RWTexture1D<float4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{type::TextureDimension::k2d, type::TexelFormat::kRgba16Float,
|
||||
HlslStorageTextureData{type::TextureDimension::k2d, builtin::TexelFormat::kRgba16Float,
|
||||
"RWTexture2D<float4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{type::TextureDimension::k2dArray, type::TexelFormat::kR32Float,
|
||||
HlslStorageTextureData{type::TextureDimension::k2dArray, builtin::TexelFormat::kR32Float,
|
||||
"RWTexture2DArray<float4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{type::TextureDimension::k3d, type::TexelFormat::kRg32Float,
|
||||
HlslStorageTextureData{type::TextureDimension::k3d, builtin::TexelFormat::kRg32Float,
|
||||
"RWTexture3D<float4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{type::TextureDimension::k1d, type::TexelFormat::kRgba32Float,
|
||||
HlslStorageTextureData{type::TextureDimension::k1d, builtin::TexelFormat::kRgba32Float,
|
||||
"RWTexture1D<float4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{type::TextureDimension::k2d, type::TexelFormat::kRgba16Uint,
|
||||
HlslStorageTextureData{type::TextureDimension::k2d, builtin::TexelFormat::kRgba16Uint,
|
||||
"RWTexture2D<uint4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{type::TextureDimension::k2dArray, type::TexelFormat::kR32Uint,
|
||||
HlslStorageTextureData{type::TextureDimension::k2dArray, builtin::TexelFormat::kR32Uint,
|
||||
"RWTexture2DArray<uint4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{type::TextureDimension::k3d, type::TexelFormat::kRg32Uint,
|
||||
HlslStorageTextureData{type::TextureDimension::k3d, builtin::TexelFormat::kRg32Uint,
|
||||
"RWTexture3D<uint4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{type::TextureDimension::k1d, type::TexelFormat::kRgba32Uint,
|
||||
HlslStorageTextureData{type::TextureDimension::k1d, builtin::TexelFormat::kRgba32Uint,
|
||||
"RWTexture1D<uint4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{type::TextureDimension::k2d, type::TexelFormat::kRgba16Sint,
|
||||
HlslStorageTextureData{type::TextureDimension::k2d, builtin::TexelFormat::kRgba16Sint,
|
||||
"RWTexture2D<int4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{type::TextureDimension::k2dArray, type::TexelFormat::kR32Sint,
|
||||
HlslStorageTextureData{type::TextureDimension::k2dArray, builtin::TexelFormat::kR32Sint,
|
||||
"RWTexture2DArray<int4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{type::TextureDimension::k3d, type::TexelFormat::kRg32Sint,
|
||||
HlslStorageTextureData{type::TextureDimension::k3d, builtin::TexelFormat::kRg32Sint,
|
||||
"RWTexture3D<int4> tex : register(u1, space2);"},
|
||||
HlslStorageTextureData{type::TextureDimension::k1d, type::TexelFormat::kRgba32Sint,
|
||||
HlslStorageTextureData{type::TextureDimension::k1d, builtin::TexelFormat::kRgba32Sint,
|
||||
"RWTexture1D<int4> tex : register(u1, space2);"}));
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -854,7 +854,8 @@ using MslStorageTexturesTest = TestParamHelper<MslStorageTextureData>;
|
|||
TEST_P(MslStorageTexturesTest, Emit) {
|
||||
auto params = GetParam();
|
||||
|
||||
auto s = ty.storage_texture(params.dim, type::TexelFormat::kR32Float, builtin::Access::kWrite);
|
||||
auto s =
|
||||
ty.storage_texture(params.dim, builtin::TexelFormat::kR32Float, builtin::Access::kWrite);
|
||||
ast::Type type = GlobalVar("test_var", s, Binding(0_a), Group(0_a))->type;
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
|
|
@ -4074,48 +4074,48 @@ void Builder::AddInterpolationDecorations(uint32_t id,
|
|||
}
|
||||
}
|
||||
|
||||
SpvImageFormat Builder::convert_texel_format_to_spv(const type::TexelFormat format) {
|
||||
SpvImageFormat Builder::convert_texel_format_to_spv(const builtin::TexelFormat format) {
|
||||
switch (format) {
|
||||
case type::TexelFormat::kBgra8Unorm:
|
||||
case builtin::TexelFormat::kBgra8Unorm:
|
||||
TINT_ICE(Writer, builder_.Diagnostics())
|
||||
<< "bgra8unorm should have been polyfilled to rgba8unorm";
|
||||
return SpvImageFormatUnknown;
|
||||
case type::TexelFormat::kR32Uint:
|
||||
case builtin::TexelFormat::kR32Uint:
|
||||
return SpvImageFormatR32ui;
|
||||
case type::TexelFormat::kR32Sint:
|
||||
case builtin::TexelFormat::kR32Sint:
|
||||
return SpvImageFormatR32i;
|
||||
case type::TexelFormat::kR32Float:
|
||||
case builtin::TexelFormat::kR32Float:
|
||||
return SpvImageFormatR32f;
|
||||
case type::TexelFormat::kRgba8Unorm:
|
||||
case builtin::TexelFormat::kRgba8Unorm:
|
||||
return SpvImageFormatRgba8;
|
||||
case type::TexelFormat::kRgba8Snorm:
|
||||
case builtin::TexelFormat::kRgba8Snorm:
|
||||
return SpvImageFormatRgba8Snorm;
|
||||
case type::TexelFormat::kRgba8Uint:
|
||||
case builtin::TexelFormat::kRgba8Uint:
|
||||
return SpvImageFormatRgba8ui;
|
||||
case type::TexelFormat::kRgba8Sint:
|
||||
case builtin::TexelFormat::kRgba8Sint:
|
||||
return SpvImageFormatRgba8i;
|
||||
case type::TexelFormat::kRg32Uint:
|
||||
case builtin::TexelFormat::kRg32Uint:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatRg32ui;
|
||||
case type::TexelFormat::kRg32Sint:
|
||||
case builtin::TexelFormat::kRg32Sint:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatRg32i;
|
||||
case type::TexelFormat::kRg32Float:
|
||||
case builtin::TexelFormat::kRg32Float:
|
||||
push_capability(SpvCapabilityStorageImageExtendedFormats);
|
||||
return SpvImageFormatRg32f;
|
||||
case type::TexelFormat::kRgba16Uint:
|
||||
case builtin::TexelFormat::kRgba16Uint:
|
||||
return SpvImageFormatRgba16ui;
|
||||
case type::TexelFormat::kRgba16Sint:
|
||||
case builtin::TexelFormat::kRgba16Sint:
|
||||
return SpvImageFormatRgba16i;
|
||||
case type::TexelFormat::kRgba16Float:
|
||||
case builtin::TexelFormat::kRgba16Float:
|
||||
return SpvImageFormatRgba16f;
|
||||
case type::TexelFormat::kRgba32Uint:
|
||||
case builtin::TexelFormat::kRgba32Uint:
|
||||
return SpvImageFormatRgba32ui;
|
||||
case type::TexelFormat::kRgba32Sint:
|
||||
case builtin::TexelFormat::kRgba32Sint:
|
||||
return SpvImageFormatRgba32i;
|
||||
case type::TexelFormat::kRgba32Float:
|
||||
case builtin::TexelFormat::kRgba32Float:
|
||||
return SpvImageFormatRgba32f;
|
||||
case type::TexelFormat::kUndefined:
|
||||
case builtin::TexelFormat::kUndefined:
|
||||
return SpvImageFormatUnknown;
|
||||
}
|
||||
return SpvImageFormatUnknown;
|
||||
|
|
|
@ -535,7 +535,7 @@ class Builder {
|
|||
/// Converts TexelFormat to SPIR-V and pushes an appropriate capability.
|
||||
/// @param format AST image format type
|
||||
/// @returns SPIR-V image format type
|
||||
SpvImageFormat convert_texel_format_to_spv(const type::TexelFormat format);
|
||||
SpvImageFormat convert_texel_format_to_spv(const builtin::TexelFormat format);
|
||||
|
||||
/// Determines if the given type initializer is created from constant values
|
||||
/// @param expr the expression to check
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace tint::writer::spirv {
|
|||
namespace {
|
||||
|
||||
struct TestData {
|
||||
type::TexelFormat ast_format;
|
||||
builtin::TexelFormat ast_format;
|
||||
SpvImageFormat_ spv_format;
|
||||
bool extended_format = false;
|
||||
};
|
||||
|
@ -45,46 +45,47 @@ TEST_P(ImageFormatConversionTest, ImageFormatConversion) {
|
|||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(BuilderTest,
|
||||
ImageFormatConversionTest,
|
||||
testing::Values(
|
||||
/* WGSL unsupported formats
|
||||
TestData{type::TexelFormat::kR8Unorm, SpvImageFormatR8, true},
|
||||
TestData{type::TexelFormat::kR8Snorm, SpvImageFormatR8Snorm, true},
|
||||
TestData{type::TexelFormat::kR8Uint, SpvImageFormatR8ui, true},
|
||||
TestData{type::TexelFormat::kR8Sint, SpvImageFormatR8i, true},
|
||||
TestData{type::TexelFormat::kR16Uint, SpvImageFormatR16ui, true},
|
||||
TestData{type::TexelFormat::kR16Sint, SpvImageFormatR16i, true},
|
||||
TestData{type::TexelFormat::kR16Float, SpvImageFormatR16f, true},
|
||||
TestData{type::TexelFormat::kRg8Unorm, SpvImageFormatRg8, true},
|
||||
TestData{type::TexelFormat::kRg8Snorm, SpvImageFormatRg8Snorm, true},
|
||||
TestData{type::TexelFormat::kRg8Uint, SpvImageFormatRg8ui, true},
|
||||
TestData{type::TexelFormat::kRg8Sint, SpvImageFormatRg8i, true},
|
||||
TestData{type::TexelFormat::kRg16Uint, SpvImageFormatRg16ui, true},
|
||||
TestData{type::TexelFormat::kRg16Sint, SpvImageFormatRg16i, true},
|
||||
TestData{type::TexelFormat::kRg16Float, SpvImageFormatRg16f, true},
|
||||
TestData{type::TexelFormat::kRgba8UnormSrgb, SpvImageFormatUnknown},
|
||||
TestData{type::TexelFormat::kBgra8Unorm, SpvImageFormatUnknown},
|
||||
TestData{type::TexelFormat::kBgra8UnormSrgb, SpvImageFormatUnknown},
|
||||
TestData{type::TexelFormat::kRgb10A2Unorm, SpvImageFormatRgb10A2, true},
|
||||
TestData{type::TexelFormat::kRg11B10Float, SpvImageFormatR11fG11fB10f, true},
|
||||
*/
|
||||
TestData{type::TexelFormat::kR32Uint, SpvImageFormatR32ui},
|
||||
TestData{type::TexelFormat::kR32Sint, SpvImageFormatR32i},
|
||||
TestData{type::TexelFormat::kR32Float, SpvImageFormatR32f},
|
||||
TestData{type::TexelFormat::kRgba8Unorm, SpvImageFormatRgba8},
|
||||
TestData{type::TexelFormat::kRgba8Snorm, SpvImageFormatRgba8Snorm},
|
||||
TestData{type::TexelFormat::kRgba8Uint, SpvImageFormatRgba8ui},
|
||||
TestData{type::TexelFormat::kRgba8Sint, SpvImageFormatRgba8i},
|
||||
TestData{type::TexelFormat::kRg32Uint, SpvImageFormatRg32ui, true},
|
||||
TestData{type::TexelFormat::kRg32Sint, SpvImageFormatRg32i, true},
|
||||
TestData{type::TexelFormat::kRg32Float, SpvImageFormatRg32f, true},
|
||||
TestData{type::TexelFormat::kRgba16Uint, SpvImageFormatRgba16ui},
|
||||
TestData{type::TexelFormat::kRgba16Sint, SpvImageFormatRgba16i},
|
||||
TestData{type::TexelFormat::kRgba16Float, SpvImageFormatRgba16f},
|
||||
TestData{type::TexelFormat::kRgba32Uint, SpvImageFormatRgba32ui},
|
||||
TestData{type::TexelFormat::kRgba32Sint, SpvImageFormatRgba32i},
|
||||
TestData{type::TexelFormat::kRgba32Float, SpvImageFormatRgba32f}));
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
BuilderTest,
|
||||
ImageFormatConversionTest,
|
||||
testing::Values(
|
||||
/* WGSL unsupported formats
|
||||
TestData{builtin::TexelFormat::kR8Unorm, SpvImageFormatR8, true},
|
||||
TestData{builtin::TexelFormat::kR8Snorm, SpvImageFormatR8Snorm, true},
|
||||
TestData{builtin::TexelFormat::kR8Uint, SpvImageFormatR8ui, true},
|
||||
TestData{builtin::TexelFormat::kR8Sint, SpvImageFormatR8i, true},
|
||||
TestData{builtin::TexelFormat::kR16Uint, SpvImageFormatR16ui, true},
|
||||
TestData{builtin::TexelFormat::kR16Sint, SpvImageFormatR16i, true},
|
||||
TestData{builtin::TexelFormat::kR16Float, SpvImageFormatR16f, true},
|
||||
TestData{builtin::TexelFormat::kRg8Unorm, SpvImageFormatRg8, true},
|
||||
TestData{builtin::TexelFormat::kRg8Snorm, SpvImageFormatRg8Snorm, true},
|
||||
TestData{builtin::TexelFormat::kRg8Uint, SpvImageFormatRg8ui, true},
|
||||
TestData{builtin::TexelFormat::kRg8Sint, SpvImageFormatRg8i, true},
|
||||
TestData{builtin::TexelFormat::kRg16Uint, SpvImageFormatRg16ui, true},
|
||||
TestData{builtin::TexelFormat::kRg16Sint, SpvImageFormatRg16i, true},
|
||||
TestData{builtin::TexelFormat::kRg16Float, SpvImageFormatRg16f, true},
|
||||
TestData{builtin::TexelFormat::kRgba8UnormSrgb, SpvImageFormatUnknown},
|
||||
TestData{builtin::TexelFormat::kBgra8Unorm, SpvImageFormatUnknown},
|
||||
TestData{builtin::TexelFormat::kBgra8UnormSrgb, SpvImageFormatUnknown},
|
||||
TestData{builtin::TexelFormat::kRgb10A2Unorm, SpvImageFormatRgb10A2, true},
|
||||
TestData{builtin::TexelFormat::kRg11B10Float, SpvImageFormatR11fG11fB10f, true},
|
||||
*/
|
||||
TestData{builtin::TexelFormat::kR32Uint, SpvImageFormatR32ui},
|
||||
TestData{builtin::TexelFormat::kR32Sint, SpvImageFormatR32i},
|
||||
TestData{builtin::TexelFormat::kR32Float, SpvImageFormatR32f},
|
||||
TestData{builtin::TexelFormat::kRgba8Unorm, SpvImageFormatRgba8},
|
||||
TestData{builtin::TexelFormat::kRgba8Snorm, SpvImageFormatRgba8Snorm},
|
||||
TestData{builtin::TexelFormat::kRgba8Uint, SpvImageFormatRgba8ui},
|
||||
TestData{builtin::TexelFormat::kRgba8Sint, SpvImageFormatRgba8i},
|
||||
TestData{builtin::TexelFormat::kRg32Uint, SpvImageFormatRg32ui, true},
|
||||
TestData{builtin::TexelFormat::kRg32Sint, SpvImageFormatRg32i, true},
|
||||
TestData{builtin::TexelFormat::kRg32Float, SpvImageFormatRg32f, true},
|
||||
TestData{builtin::TexelFormat::kRgba16Uint, SpvImageFormatRgba16ui},
|
||||
TestData{builtin::TexelFormat::kRgba16Sint, SpvImageFormatRgba16i},
|
||||
TestData{builtin::TexelFormat::kRgba16Float, SpvImageFormatRgba16f},
|
||||
TestData{builtin::TexelFormat::kRgba32Uint, SpvImageFormatRgba32ui},
|
||||
TestData{builtin::TexelFormat::kRgba32Sint, SpvImageFormatRgba32i},
|
||||
TestData{builtin::TexelFormat::kRgba32Float, SpvImageFormatRgba32f}));
|
||||
|
||||
} // namespace
|
||||
} // namespace tint::writer::spirv
|
||||
|
|
|
@ -477,7 +477,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(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
|
||||
auto type = ty.storage_texture(type::TextureDimension::k2d, builtin::TexelFormat::kR32Uint,
|
||||
builtin::Access::kWrite);
|
||||
|
||||
auto* var_a = GlobalVar("a", type, Binding(0_a), Group(0_a));
|
||||
|
|
|
@ -864,7 +864,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) {
|
||||
auto s = ty.storage_texture(type::TextureDimension::k1d, type::TexelFormat::kR32Float,
|
||||
auto s = ty.storage_texture(type::TextureDimension::k1d, builtin::TexelFormat::kR32Float,
|
||||
builtin::Access::kWrite);
|
||||
|
||||
ast::Type ty = GlobalVar("test_var", s, Binding(0_a), Group(0_a))->type;
|
||||
|
@ -879,7 +879,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
|
||||
auto s = ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Float,
|
||||
auto s = ty.storage_texture(type::TextureDimension::k2d, builtin::TexelFormat::kR32Float,
|
||||
builtin::Access::kWrite);
|
||||
|
||||
ast::Type ty = GlobalVar("test_var", s, Binding(0_a), Group(0_a))->type;
|
||||
|
@ -894,7 +894,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
|
||||
auto s = ty.storage_texture(type::TextureDimension::k2dArray, type::TexelFormat::kR32Float,
|
||||
auto s = ty.storage_texture(type::TextureDimension::k2dArray, builtin::TexelFormat::kR32Float,
|
||||
builtin::Access::kWrite);
|
||||
|
||||
ast::Type ty = GlobalVar("test_var", s, Binding(0_a), Group(0_a))->type;
|
||||
|
@ -909,7 +909,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
|
||||
auto s = ty.storage_texture(type::TextureDimension::k3d, type::TexelFormat::kR32Float,
|
||||
auto s = ty.storage_texture(type::TextureDimension::k3d, builtin::TexelFormat::kR32Float,
|
||||
builtin::Access::kWrite);
|
||||
|
||||
ast::Type ty = GlobalVar("test_var", s, Binding(0_a), Group(0_a))->type;
|
||||
|
@ -924,7 +924,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeFloat_Format_r32float) {
|
||||
auto s = ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Float,
|
||||
auto s = ty.storage_texture(type::TextureDimension::k2d, builtin::TexelFormat::kR32Float,
|
||||
builtin::Access::kWrite);
|
||||
|
||||
ast::Type ty = GlobalVar("test_var", s, Binding(0_a), Group(0_a))->type;
|
||||
|
@ -939,7 +939,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeFloat_Format_r32floa
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeSint_Format_r32sint) {
|
||||
auto s = ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Sint,
|
||||
auto s = ty.storage_texture(type::TextureDimension::k2d, builtin::TexelFormat::kR32Sint,
|
||||
builtin::Access::kWrite);
|
||||
|
||||
ast::Type ty = GlobalVar("test_var", s, Binding(0_a), Group(0_a))->type;
|
||||
|
@ -954,7 +954,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeSint_Format_r32sint)
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeUint_Format_r32uint) {
|
||||
auto s = ty.storage_texture(type::TextureDimension::k2d, type::TexelFormat::kR32Uint,
|
||||
auto s = ty.storage_texture(type::TextureDimension::k2d, builtin::TexelFormat::kR32Uint,
|
||||
builtin::Access::kWrite);
|
||||
|
||||
ast::Type ty = GlobalVar("test_var", s, Binding(0_a), Group(0_a))->type;
|
||||
|
|
|
@ -363,9 +363,9 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool GeneratorImpl::EmitImageFormat(std::ostream& out, const type::TexelFormat fmt) {
|
||||
bool GeneratorImpl::EmitImageFormat(std::ostream& out, const builtin::TexelFormat fmt) {
|
||||
switch (fmt) {
|
||||
case type::TexelFormat::kUndefined:
|
||||
case builtin::TexelFormat::kUndefined:
|
||||
diagnostics_.add_error(diag::System::Writer, "unknown image format");
|
||||
return false;
|
||||
default:
|
||||
|
|
|
@ -207,7 +207,7 @@ class GeneratorImpl : public TextGenerator {
|
|||
/// @param out the output stream
|
||||
/// @param fmt the format to generate
|
||||
/// @returns true if the format is emitted
|
||||
bool EmitImageFormat(std::ostream& out, const type::TexelFormat fmt);
|
||||
bool EmitImageFormat(std::ostream& out, const builtin::TexelFormat fmt);
|
||||
/// Handles a unary op expression
|
||||
/// @param out the output stream
|
||||
/// @param expr the expression to emit
|
||||
|
|
|
@ -440,7 +440,7 @@ INSTANTIATE_TEST_SUITE_P(WgslGeneratorImplTest,
|
|||
"texture_multisampled_2d"}));
|
||||
|
||||
struct StorageTextureData {
|
||||
type::TexelFormat fmt;
|
||||
builtin::TexelFormat fmt;
|
||||
type::TextureDimension dim;
|
||||
builtin::Access access;
|
||||
const char* name;
|
||||
|
@ -466,17 +466,17 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
WgslGeneratorImplTest,
|
||||
WgslGenerator_StorageTextureTest,
|
||||
testing::Values(
|
||||
StorageTextureData{type::TexelFormat::kRgba8Sint, type::TextureDimension::k1d,
|
||||
StorageTextureData{builtin::TexelFormat::kRgba8Sint, type::TextureDimension::k1d,
|
||||
builtin::Access::kWrite, "texture_storage_1d<rgba8sint, write>"},
|
||||
StorageTextureData{type::TexelFormat::kRgba8Sint, type::TextureDimension::k2d,
|
||||
StorageTextureData{builtin::TexelFormat::kRgba8Sint, type::TextureDimension::k2d,
|
||||
builtin::Access::kWrite, "texture_storage_2d<rgba8sint, write>"},
|
||||
StorageTextureData{type::TexelFormat::kRgba8Sint, type::TextureDimension::k2dArray,
|
||||
StorageTextureData{builtin::TexelFormat::kRgba8Sint, type::TextureDimension::k2dArray,
|
||||
builtin::Access::kWrite, "texture_storage_2d_array<rgba8sint, write>"},
|
||||
StorageTextureData{type::TexelFormat::kRgba8Sint, type::TextureDimension::k3d,
|
||||
StorageTextureData{builtin::TexelFormat::kRgba8Sint, type::TextureDimension::k3d,
|
||||
builtin::Access::kWrite, "texture_storage_3d<rgba8sint, write>"}));
|
||||
|
||||
struct ImageFormatData {
|
||||
type::TexelFormat fmt;
|
||||
builtin::TexelFormat fmt;
|
||||
const char* name;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, ImageFormatData data) {
|
||||
|
@ -497,22 +497,22 @@ TEST_P(WgslGenerator_ImageFormatTest, EmitType_StorageTexture_ImageFormat) {
|
|||
INSTANTIATE_TEST_SUITE_P(
|
||||
WgslGeneratorImplTest,
|
||||
WgslGenerator_ImageFormatTest,
|
||||
testing::Values(ImageFormatData{type::TexelFormat::kR32Uint, "r32uint"},
|
||||
ImageFormatData{type::TexelFormat::kR32Sint, "r32sint"},
|
||||
ImageFormatData{type::TexelFormat::kR32Float, "r32float"},
|
||||
ImageFormatData{type::TexelFormat::kRgba8Unorm, "rgba8unorm"},
|
||||
ImageFormatData{type::TexelFormat::kRgba8Snorm, "rgba8snorm"},
|
||||
ImageFormatData{type::TexelFormat::kRgba8Uint, "rgba8uint"},
|
||||
ImageFormatData{type::TexelFormat::kRgba8Sint, "rgba8sint"},
|
||||
ImageFormatData{type::TexelFormat::kRg32Uint, "rg32uint"},
|
||||
ImageFormatData{type::TexelFormat::kRg32Sint, "rg32sint"},
|
||||
ImageFormatData{type::TexelFormat::kRg32Float, "rg32float"},
|
||||
ImageFormatData{type::TexelFormat::kRgba16Uint, "rgba16uint"},
|
||||
ImageFormatData{type::TexelFormat::kRgba16Sint, "rgba16sint"},
|
||||
ImageFormatData{type::TexelFormat::kRgba16Float, "rgba16float"},
|
||||
ImageFormatData{type::TexelFormat::kRgba32Uint, "rgba32uint"},
|
||||
ImageFormatData{type::TexelFormat::kRgba32Sint, "rgba32sint"},
|
||||
ImageFormatData{type::TexelFormat::kRgba32Float, "rgba32float"}));
|
||||
testing::Values(ImageFormatData{builtin::TexelFormat::kR32Uint, "r32uint"},
|
||||
ImageFormatData{builtin::TexelFormat::kR32Sint, "r32sint"},
|
||||
ImageFormatData{builtin::TexelFormat::kR32Float, "r32float"},
|
||||
ImageFormatData{builtin::TexelFormat::kRgba8Unorm, "rgba8unorm"},
|
||||
ImageFormatData{builtin::TexelFormat::kRgba8Snorm, "rgba8snorm"},
|
||||
ImageFormatData{builtin::TexelFormat::kRgba8Uint, "rgba8uint"},
|
||||
ImageFormatData{builtin::TexelFormat::kRgba8Sint, "rgba8sint"},
|
||||
ImageFormatData{builtin::TexelFormat::kRg32Uint, "rg32uint"},
|
||||
ImageFormatData{builtin::TexelFormat::kRg32Sint, "rg32sint"},
|
||||
ImageFormatData{builtin::TexelFormat::kRg32Float, "rg32float"},
|
||||
ImageFormatData{builtin::TexelFormat::kRgba16Uint, "rgba16uint"},
|
||||
ImageFormatData{builtin::TexelFormat::kRgba16Sint, "rgba16sint"},
|
||||
ImageFormatData{builtin::TexelFormat::kRgba16Float, "rgba16float"},
|
||||
ImageFormatData{builtin::TexelFormat::kRgba32Uint, "rgba32uint"},
|
||||
ImageFormatData{builtin::TexelFormat::kRgba32Sint, "rgba32sint"},
|
||||
ImageFormatData{builtin::TexelFormat::kRgba32Float, "rgba32float"}));
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Sampler) {
|
||||
auto sampler = ty.sampler(type::SamplerKind::kSampler);
|
||||
|
|
Loading…
Reference in New Issue