diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index ba10dfeb75..ae9f9ae3d7 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -302,7 +302,6 @@ libtint_source_set("libtint_syntax_tree_src") { "ast/pointer.h", "ast/return_statement.h", "ast/sampled_texture.h", - "ast/sampler.h", "ast/stage_attribute.h", "ast/statement.h", "ast/storage_texture.h", @@ -671,8 +670,6 @@ libtint_source_set("libtint_ast_src") { "ast/return_statement.h", "ast/sampled_texture.cc", "ast/sampled_texture.h", - "ast/sampler.cc", - "ast/sampler.h", "ast/stage_attribute.cc", "ast/stage_attribute.h", "ast/statement.cc", @@ -1345,7 +1342,6 @@ if (tint_build_unittests) { "ast/pointer_test.cc", "ast/return_statement_test.cc", "ast/sampled_texture_test.cc", - "ast/sampler_test.cc", "ast/stage_attribute_test.cc", "ast/storage_texture_test.cc", "ast/stride_attribute_test.cc", diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 56f81d5dcc..cbd9a3ee1d 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -203,8 +203,6 @@ list(APPEND TINT_LIB_SRCS ast/return_statement.h ast/sampled_texture.cc ast/sampled_texture.h - ast/sampler.cc - ast/sampler.h ast/stage_attribute.cc ast/stage_attribute.h ast/statement.cc @@ -866,7 +864,6 @@ if(TINT_BUILD_TESTS) ast/pointer_test.cc ast/return_statement_test.cc ast/sampled_texture_test.cc - ast/sampler_test.cc ast/stage_attribute_test.cc ast/storage_texture_test.cc ast/stride_attribute_test.cc diff --git a/src/tint/ast/alias_test.cc b/src/tint/ast/alias_test.cc index d2fa755081..b35fb1a4d2 100644 --- a/src/tint/ast/alias_test.cc +++ b/src/tint/ast/alias_test.cc @@ -16,7 +16,6 @@ #include "src/tint/ast/array.h" #include "src/tint/ast/matrix.h" #include "src/tint/ast/pointer.h" -#include "src/tint/ast/sampler.h" #include "src/tint/ast/struct.h" #include "src/tint/ast/test_helper.h" #include "src/tint/ast/texture.h" diff --git a/src/tint/ast/builtin_texture_helper_test.cc b/src/tint/ast/builtin_texture_helper_test.cc index d25ec0de20..df09f1180d 100644 --- a/src/tint/ast/builtin_texture_helper_test.cc +++ b/src/tint/ast/builtin_texture_helper_test.cc @@ -149,25 +149,25 @@ const ast::Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b switch (texture_kind) { case ast::builtin::test::TextureKind::kRegular: return b->GlobalVar( - "texture", + kTextureName, b->ty.sampled_texture(texture_dimension, BuildResultVectorComponentType(b)), attrs); case ast::builtin::test::TextureKind::kDepth: - return b->GlobalVar("texture", b->ty.depth_texture(texture_dimension), attrs); + return b->GlobalVar(kTextureName, b->ty.depth_texture(texture_dimension), attrs); case ast::builtin::test::TextureKind::kDepthMultisampled: - return b->GlobalVar("texture", b->ty.depth_multisampled_texture(texture_dimension), + return b->GlobalVar(kTextureName, b->ty.depth_multisampled_texture(texture_dimension), attrs); case ast::builtin::test::TextureKind::kMultisampled: return b->GlobalVar( - "texture", + kTextureName, b->ty.multisampled_texture(texture_dimension, BuildResultVectorComponentType(b)), attrs); case ast::builtin::test::TextureKind::kStorage: { auto* st = b->ty.storage_texture(texture_dimension, texel_format, access); - return b->GlobalVar("texture", st, attrs); + return b->GlobalVar(kTextureName, st, attrs); } } @@ -177,7 +177,7 @@ const ast::Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b const ast::Variable* TextureOverloadCase::BuildSamplerVariable(ProgramBuilder* b) const { utils::Vector attrs = {b->Group(0_a), b->Binding(1_a)}; - return b->GlobalVar("sampler", b->ty.sampler(sampler_kind), attrs); + return b->GlobalVar(kSamplerName, b->ty.sampler(sampler_kind), attrs); } std::vector TextureOverloadCase::ValidCases() { @@ -190,7 +190,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k1d, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kDimensions2d, @@ -200,7 +200,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2d, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kDimensions2dLevel, @@ -211,7 +211,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2d, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture", 1_i); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName, 1_i); }, }, { ValidTextureOverload::kDimensions2dArray, @@ -221,7 +221,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2dArray, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kDimensions2dArrayLevel, @@ -232,7 +232,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2dArray, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture", 1_i); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName, 1_i); }, }, { ValidTextureOverload::kDimensions3d, @@ -242,7 +242,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k3d, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kDimensions3dLevel, @@ -253,7 +253,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k3d, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture", 1_i); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName, 1_i); }, }, { ValidTextureOverload::kDimensionsCube, @@ -263,7 +263,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::kCube, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kDimensionsCubeLevel, @@ -274,7 +274,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::kCube, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture", 1_i); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName, 1_i); }, }, { ValidTextureOverload::kDimensionsCubeArray, @@ -284,7 +284,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::kCubeArray, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kDimensionsCubeArrayLevel, @@ -295,7 +295,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::kCubeArray, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture", 1_i); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName, 1_i); }, }, { ValidTextureOverload::kDimensionsMultisampled2d, @@ -305,7 +305,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2d, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kDimensionsDepth2d, @@ -315,7 +315,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2d, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kDimensionsDepth2dLevel, @@ -326,7 +326,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2d, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture", 1_i); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName, 1_i); }, }, { ValidTextureOverload::kDimensionsDepth2dArray, @@ -336,7 +336,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2dArray, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kDimensionsDepth2dArrayLevel, @@ -347,7 +347,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2dArray, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture", 1_i); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName, 1_i); }, }, { ValidTextureOverload::kDimensionsDepthCube, @@ -357,7 +357,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::kCube, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kDimensionsDepthCubeLevel, @@ -368,7 +368,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::kCube, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture", 1_i); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName, 1_i); }, }, { ValidTextureOverload::kDimensionsDepthCubeArray, @@ -378,7 +378,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::kCubeArray, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kDimensionsDepthCubeArrayLevel, @@ -389,7 +389,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::kCubeArray, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture", 1_i); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName, 1_i); }, }, { ValidTextureOverload::kDimensionsDepthMultisampled2d, @@ -399,7 +399,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2d, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kDimensionsStorageWO1d, @@ -409,7 +409,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k1d, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kDimensionsStorageWO2d, @@ -419,7 +419,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2d, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kDimensionsStorageWO2dArray, @@ -429,7 +429,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2dArray, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kDimensionsStorageWO3d, @@ -439,7 +439,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k3d, TextureDataType::kF32, "textureDimensions", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { @@ -455,8 +455,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureGather", [](ProgramBuilder* b) { return b->ExprList(0_i, // component - "texture", // t - "sampler", // s + kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f)); // coords }, }, @@ -474,8 +474,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureGather", [](ProgramBuilder* b) { return b->ExprList(0_u, // component - "texture", // t - "sampler", // s + kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords b->vec2(3_i, 4_i)); // offset }, @@ -494,8 +494,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureGather", [](ProgramBuilder* b) { return b->ExprList(0_i, // component - "texture", // t - "sampler", // s + kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_i); // array index }, @@ -515,8 +515,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureGather", [](ProgramBuilder* b) { return b->ExprList(0_u, // component - "texture", // t - "sampler", // s + kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_u, // array_index b->vec2(4_i, 5_i)); // offset @@ -535,8 +535,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureGather", [](ProgramBuilder* b) { return b->ExprList(0_i, // component - "texture", // t - "sampler", // s + kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f)); // coords }, }, @@ -554,8 +554,8 @@ std::vector TextureOverloadCase::ValidCases() { "textureGather", [](ProgramBuilder* b) { return b->ExprList(0_u, // component - "texture", // t - "sampler", // s + kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_u); // array_index }, @@ -571,8 +571,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureGather", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f)); // coords }, }, @@ -588,8 +588,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureGather", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords b->vec2(3_i, 4_i)); // offset }, @@ -606,8 +606,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureGather", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_u); // array_index }, @@ -625,8 +625,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureGather", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_i, // array_index b->vec2(4_i, 5_i)); // offset @@ -643,8 +643,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureGather", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f)); // coords }, }, @@ -660,8 +660,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureGather", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_u); // array_index }, @@ -678,8 +678,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureGatherCompare", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_f); // depth_ref }, @@ -697,8 +697,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureGatherCompare", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_f, // depth_ref b->vec2(4_i, 5_i)); // offset @@ -717,8 +717,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureGatherCompare", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_i, // array_index 4_f); // depth_ref @@ -738,8 +738,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureGatherCompare", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_i, // array_index 4_f, // depth_ref @@ -758,8 +758,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureGatherCompare", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_f); // depth_ref }, @@ -777,8 +777,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureGatherCompare", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_u, // array_index 5_f); // depth_ref @@ -792,7 +792,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2dArray, TextureDataType::kF32, "textureNumLayers", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kNumLayersCubeArray, @@ -802,7 +802,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::kCubeArray, TextureDataType::kF32, "textureNumLayers", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kNumLayersDepth2dArray, @@ -812,7 +812,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2dArray, TextureDataType::kF32, "textureNumLayers", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kNumLayersDepthCubeArray, @@ -822,7 +822,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::kCubeArray, TextureDataType::kF32, "textureNumLayers", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kNumLayersStorageWO2dArray, @@ -832,7 +832,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2dArray, TextureDataType::kF32, "textureNumLayers", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kNumLevels2d, @@ -842,7 +842,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2d, TextureDataType::kF32, "textureNumLevels", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kNumLevels2dArray, @@ -852,7 +852,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2dArray, TextureDataType::kF32, "textureNumLevels", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kNumLevels3d, @@ -862,7 +862,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k3d, TextureDataType::kF32, "textureNumLevels", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kNumLevelsCube, @@ -872,7 +872,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::kCube, TextureDataType::kF32, "textureNumLevels", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kNumLevelsCubeArray, @@ -882,7 +882,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::kCubeArray, TextureDataType::kF32, "textureNumLevels", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kNumLevelsDepth2d, @@ -892,7 +892,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2d, TextureDataType::kF32, "textureNumLevels", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kNumLevelsDepth2dArray, @@ -902,7 +902,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2dArray, TextureDataType::kF32, "textureNumLevels", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kNumLevelsDepthCube, @@ -912,7 +912,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::kCube, TextureDataType::kF32, "textureNumLevels", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kNumLevelsDepthCubeArray, @@ -922,7 +922,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::kCubeArray, TextureDataType::kF32, "textureNumLevels", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kNumSamplesMultisampled2d, @@ -932,7 +932,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2d, TextureDataType::kF32, "textureNumSamples", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kNumSamplesDepthMultisampled2d, @@ -942,7 +942,7 @@ std::vector TextureOverloadCase::ValidCases() { type::TextureDimension::k2d, TextureDataType::kF32, "textureNumSamples", - [](ProgramBuilder* b) { return b->ExprList("texture"); }, + [](ProgramBuilder* b) { return b->ExprList(kTextureName); }, }, { ValidTextureOverload::kSample1dF32, @@ -955,9 +955,9 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s - 1_f); // coords + return b->ExprList(kTextureName, // t + kSamplerName, // s + 1_f); // coords }, }, { @@ -971,8 +971,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f)); // coords }, }, @@ -988,8 +988,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords b->vec2(3_i, 4_i)); // offset }, @@ -1006,8 +1006,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_i); // array_index }, @@ -1025,8 +1025,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_u, // array_index b->vec2(4_i, 5_i)); // offset @@ -1043,8 +1043,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f)); // coords }, }, @@ -1060,8 +1060,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords b->vec3(4_i, 5_i, 6_i)); // offset }, @@ -1077,8 +1077,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f)); // coords }, }, @@ -1094,8 +1094,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_i); // array_index }, @@ -1111,8 +1111,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f)); // coords }, }, @@ -1128,8 +1128,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords b->vec2(3_i, 4_i)); // offset }, @@ -1146,8 +1146,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_i); // array_index }, @@ -1165,8 +1165,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_i, // array_index b->vec2(4_i, 5_i)); // offset @@ -1183,8 +1183,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f)); // coords }, }, @@ -1200,8 +1200,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSample", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_u); // array_index }, @@ -1218,8 +1218,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleBias", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_f); // bias }, @@ -1237,8 +1237,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleBias", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_f, // bias b->vec2(4_i, 5_i)); // offset @@ -1257,8 +1257,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleBias", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 4_u, // array_index 3_f); // bias @@ -1278,8 +1278,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleBias", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_i, // array_index 4_f, // bias @@ -1298,8 +1298,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleBias", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_f); // bias }, @@ -1317,8 +1317,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleBias", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_f, // bias b->vec3(5_i, 6_i, 7_i)); // offset @@ -1336,8 +1336,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleBias", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_f); // bias }, @@ -1355,8 +1355,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleBias", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 3_i, // array_index 4_f); // bias @@ -1374,8 +1374,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_f); // level }, @@ -1393,8 +1393,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_f, // level b->vec2(4_i, 5_i)); // offset @@ -1413,8 +1413,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_i, // array_index 4_f); // level @@ -1434,8 +1434,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_i, // array_index 4_f, // level @@ -1454,8 +1454,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_f); // level }, @@ -1473,8 +1473,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_f, // level b->vec3(5_i, 6_i, 7_i)); // offset @@ -1492,8 +1492,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_f); // level }, @@ -1511,8 +1511,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_i, // array_index 5_f); // level @@ -1530,8 +1530,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_u); // level }, @@ -1549,8 +1549,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_i, // level b->vec2(4_i, 5_i)); // offset @@ -1569,8 +1569,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_u, // array_index 4_u); // level @@ -1590,8 +1590,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_u, // array_index 4_u, // level @@ -1610,8 +1610,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_i); // level }, @@ -1629,8 +1629,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_i, // array_index 5_i); // level @@ -1649,8 +1649,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleGrad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords b->vec2(3_f, 4_f), // ddx b->vec2(5_f, 6_f)); // ddy @@ -1670,8 +1670,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleGrad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords b->vec2(3_f, 4_f), // ddx b->vec2(5_f, 6_f), // ddy @@ -1692,8 +1692,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleGrad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_i, // array_index b->vec2(4_f, 5_f), // ddx @@ -1715,8 +1715,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleGrad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_u, // array_index b->vec2(4_f, 5_f), // ddx @@ -1737,8 +1737,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleGrad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords b->vec3(4_f, 5_f, 6_f), // ddx b->vec3(7_f, 8_f, 9_f)); // ddy @@ -1758,8 +1758,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleGrad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords b->vec3(4_f, 5_f, 6_f), // ddx b->vec3(7_f, 8_f, 9_f), // ddy @@ -1779,8 +1779,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleGrad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords b->vec3(4_f, 5_f, 6_f), // ddx b->vec3(7_f, 8_f, 9_f)); // ddy @@ -1800,8 +1800,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleGrad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_u, // array_index b->vec3(5_f, 6_f, 7_f), // ddx @@ -1820,8 +1820,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleCompare", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_f); // depth_ref }, @@ -1839,8 +1839,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleCompare", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_f, // depth_ref b->vec2(4_i, 5_i)); // offset @@ -1859,8 +1859,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleCompare", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 4_i, // array_index 3_f); // depth_ref @@ -1880,8 +1880,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleCompare", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 4_u, // array_index 3_f, // depth_ref @@ -1900,8 +1900,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleCompare", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_f); // depth_ref }, @@ -1919,8 +1919,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleCompare", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_i, // array_index 5_f); // depth_ref @@ -1938,8 +1938,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleCompareLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_f); // depth_ref }, @@ -1957,8 +1957,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleCompareLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_f, // depth_ref b->vec2(4_i, 5_i)); // offset @@ -1977,8 +1977,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleCompareLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_i, // array_index 4_f); // depth_ref @@ -1998,8 +1998,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleCompareLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec2(1_f, 2_f), // coords 3_i, // array_index 4_f, // depth_ref @@ -2018,8 +2018,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleCompareLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_f); // depth_ref }, @@ -2037,8 +2037,8 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureSampleCompareLevel", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - "sampler", // s + return b->ExprList(kTextureName, // t + kSamplerName, // s b->vec3(1_f, 2_f, 3_f), // coords 4_i, // array_index 5_f); // depth_ref @@ -2054,9 +2054,9 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - 1_u, // coords - 3_u); // level + return b->ExprList(kTextureName, // t + 1_u, // coords + 3_u); // level }, }, { @@ -2069,9 +2069,9 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kU32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - 1_i, // coords - 3_i); // level + return b->ExprList(kTextureName, // t + 1_i, // coords + 3_i); // level }, }, { @@ -2084,9 +2084,9 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kI32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t - 1_i, // coords - 3_i); // level + return b->ExprList(kTextureName, // t + 1_i, // coords + 3_i); // level }, }, { @@ -2099,7 +2099,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec2(1_u, 2_u), // coords 3_u); // level }, @@ -2114,7 +2114,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kU32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec2(1_i, 2_i), // coords 3_i); // level }, @@ -2129,7 +2129,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kI32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec2(1_u, 2_u), // coords 3_u); // level }, @@ -2145,7 +2145,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec2(1_i, 2_i), // coords 3_i, // array_index 4_i); // level @@ -2162,7 +2162,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kU32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec2(1_i, 2_i), // coords 3_i, // array_index 4_i); // level @@ -2179,7 +2179,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kI32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec2(1_u, 2_u), // coords 3_u, // array_index 4_u); // level @@ -2195,7 +2195,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec3(1_i, 2_i, 3_i), // coords 4_i); // level }, @@ -2210,7 +2210,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kU32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec3(1_i, 2_i, 3_i), // coords 4_i); // level }, @@ -2225,7 +2225,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kI32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec3(1_u, 2_u, 3_u), // coords 4_u); // level }, @@ -2240,7 +2240,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec2(1_i, 2_i), // coords 3_i); // sample_index }, @@ -2255,7 +2255,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kU32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec2(1_i, 2_i), // coords 3_i); // sample_index }, @@ -2270,7 +2270,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kI32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec2(1_u, 2_u), // coords 3_u); // sample_index }, @@ -2285,7 +2285,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec2(1_i, 2_i), // coords 3_i); // level }, @@ -2301,7 +2301,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec2(1_u, 2_u), // coords 3_u, // array_index 4_u); // level @@ -2317,7 +2317,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureLoad", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec2(1_u, 2_u), // coords 3_u); // sample_index }, @@ -2333,7 +2333,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureStore", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t 1_i, // coords b->vec4(2_f, 3_f, 4_f, 5_f)); // value }, @@ -2349,7 +2349,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureStore", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec2(1_i, 2_i), // coords b->vec4(3_f, 4_f, 5_f, 6_f)); // value }, @@ -2366,7 +2366,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureStore", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec2(1_u, 2_u), // coords 3_u, // array_index b->vec4(4_f, 5_f, 6_f, 7_f)); // value @@ -2383,7 +2383,7 @@ std::vector TextureOverloadCase::ValidCases() { TextureDataType::kF32, "textureStore", [](ProgramBuilder* b) { - return b->ExprList("texture", // t + return b->ExprList(kTextureName, // t b->vec3(1_u, 2_u, 3_u), // coords b->vec4(4_f, 5_f, 6_f, 7_f)); // value }, diff --git a/src/tint/ast/builtin_texture_helper_test.h b/src/tint/ast/builtin_texture_helper_test.h index 7391e8c1ae..7130b9a019 100644 --- a/src/tint/ast/builtin_texture_helper_test.h +++ b/src/tint/ast/builtin_texture_helper_test.h @@ -24,6 +24,12 @@ namespace tint::ast::builtin::test { +/// The name of the texture global variable used by the tests. +static constexpr const char* kTextureName = "Texture"; + +/// The name of the sampler global variable used by the tests. +static constexpr const char* kSamplerName = "Sampler"; + enum class TextureKind { kRegular, kDepth, kDepthMultisampled, kMultisampled, kStorage }; enum class TextureDataType { kF32, kU32, kI32 }; diff --git a/src/tint/ast/builtin_value_bench.cc b/src/tint/ast/builtin_value_bench.cc index b323b6b3ee..879b0a545a 100644 --- a/src/tint/ast/builtin_value_bench.cc +++ b/src/tint/ast/builtin_value_bench.cc @@ -30,7 +30,7 @@ namespace tint::ast { namespace { void BuiltinValueParser(::benchmark::State& state) { - std::array kStrings{ + const char* kStrings[] = { "fragdeccth", "flaget3", "fVag_depth", @@ -117,7 +117,7 @@ void BuiltinValueParser(::benchmark::State& state) { "hrkgYooup_d", }; for (auto _ : state) { - for (auto& str : kStrings) { + for (auto* str : kStrings) { auto result = ParseBuiltinValue(str); benchmark::DoNotOptimize(result); } diff --git a/src/tint/ast/diagnostic_control_bench.cc b/src/tint/ast/diagnostic_control_bench.cc index faf354e57e..6fb501411a 100644 --- a/src/tint/ast/diagnostic_control_bench.cc +++ b/src/tint/ast/diagnostic_control_bench.cc @@ -30,14 +30,14 @@ namespace tint::ast { namespace { void DiagnosticSeverityParser(::benchmark::State& state) { - std::array kStrings{ + const char* kStrings[] = { "erccr", "3o", "eVror", "error", "erro1", "qqrJr", "errll7r", "ppqnfH", "c", "iGf", "info", "invii", "inWWo", "Mxxo", "ogg", "X", "3ff", "off", "oEf", "oPTT", "dxxf", "w44rning", "waSSniVVg", "RarR22g", "warning", "wFni9g", "waring", "VOORRHng", }; for (auto _ : state) { - for (auto& str : kStrings) { + for (auto* str : kStrings) { auto result = ParseDiagnosticSeverity(str); benchmark::DoNotOptimize(result); } @@ -47,7 +47,7 @@ void DiagnosticSeverityParser(::benchmark::State& state) { BENCHMARK(DiagnosticSeverityParser); void DiagnosticRuleParser(::benchmark::State& state) { - std::array kStrings{ + const char* kStrings[] = { "hromium_unyeachable_code", "chrorrillmGunnreachable_c77de", "chromium_unreachable4cod00", "chromium_unreachable_code", "chromium_unracaboo_code", "chromium_unrzzchabl_code", "ciipp11ium_unreachable_cod", "derivXXtive_uniformity", "55erivativeIIunifonn99ity", @@ -55,7 +55,7 @@ void DiagnosticRuleParser(::benchmark::State& state) { "jerivaive_uniforRgty", "derivatbve_unformiy", }; for (auto _ : state) { - for (auto& str : kStrings) { + for (auto* str : kStrings) { auto result = ParseDiagnosticRule(str); benchmark::DoNotOptimize(result); } diff --git a/src/tint/ast/extension_bench.cc b/src/tint/ast/extension_bench.cc index 5f175cc502..3bf35f6791 100644 --- a/src/tint/ast/extension_bench.cc +++ b/src/tint/ast/extension_bench.cc @@ -30,7 +30,7 @@ namespace tint::ast { namespace { void ExtensionParser(::benchmark::State& state) { - std::array kStrings{ + const char* kStrings[] = { "chromium_disableuniformiccy_analysis", "chromil3_disable_unifority_analss", "chromium_disable_Vniformity_analysis", @@ -68,7 +68,7 @@ void ExtensionParser(::benchmark::State& state) { "f", }; for (auto _ : state) { - for (auto& str : kStrings) { + for (auto* str : kStrings) { auto result = ParseExtension(str); benchmark::DoNotOptimize(result); } diff --git a/src/tint/ast/interpolate_attribute_bench.cc b/src/tint/ast/interpolate_attribute_bench.cc index 6382139892..722cb069eb 100644 --- a/src/tint/ast/interpolate_attribute_bench.cc +++ b/src/tint/ast/interpolate_attribute_bench.cc @@ -30,7 +30,7 @@ namespace tint::ast { namespace { void InterpolationTypeParser(::benchmark::State& state) { - std::array kStrings{ + const char* kStrings[] = { "ccat", "3", "fVat", "flat", "1lat", "fqaJ", "flla77", "lippeHHr", "cin", "lbGea", "linear", "liveaii", "liWWe8r", "xxiner", "perggpctXve", @@ -38,7 +38,7 @@ void InterpolationTypeParser(::benchmark::State& state) { "pxxdrspectve", }; for (auto _ : state) { - for (auto& str : kStrings) { + for (auto* str : kStrings) { auto result = ParseInterpolationType(str); benchmark::DoNotOptimize(result); } @@ -48,13 +48,13 @@ void InterpolationTypeParser(::benchmark::State& state) { BENCHMARK(InterpolationTypeParser); void InterpolationSamplingParser(::benchmark::State& state) { - std::array kStrings{ + const char* kStrings[] = { "44enter", "cSSVVter", "centRr", "center", "ent9r", "cente", "VentORr", "cenyroi", "77errtrllnid", "04entroid", "centroid", "enooid", "centzzd", "ceiippr1i", "saXXple", "55IImpnn99", "aHHrrmplSS", "sample", "kkle", "jagRR", "smbe", }; for (auto _ : state) { - for (auto& str : kStrings) { + for (auto* str : kStrings) { auto result = ParseInterpolationSampling(str); benchmark::DoNotOptimize(result); } diff --git a/src/tint/ast/matrix_test.cc b/src/tint/ast/matrix_test.cc index 5d582946bb..2199f782d3 100644 --- a/src/tint/ast/matrix_test.cc +++ b/src/tint/ast/matrix_test.cc @@ -16,7 +16,6 @@ #include "src/tint/ast/alias.h" #include "src/tint/ast/array.h" #include "src/tint/ast/pointer.h" -#include "src/tint/ast/sampler.h" #include "src/tint/ast/struct.h" #include "src/tint/ast/test_helper.h" #include "src/tint/ast/texture.h" diff --git a/src/tint/ast/multisampled_texture_test.cc b/src/tint/ast/multisampled_texture_test.cc index 1bf018749d..adcb79088d 100644 --- a/src/tint/ast/multisampled_texture_test.cc +++ b/src/tint/ast/multisampled_texture_test.cc @@ -20,7 +20,6 @@ #include "src/tint/ast/matrix.h" #include "src/tint/ast/pointer.h" #include "src/tint/ast/sampled_texture.h" -#include "src/tint/ast/sampler.h" #include "src/tint/ast/storage_texture.h" #include "src/tint/ast/struct.h" #include "src/tint/ast/test_helper.h" diff --git a/src/tint/ast/sampler.cc b/src/tint/ast/sampler.cc deleted file mode 100644 index 28bba361b5..0000000000 --- a/src/tint/ast/sampler.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2020 The Tint Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "src/tint/ast/sampler.h" - -#include "src/tint/program_builder.h" - -TINT_INSTANTIATE_TYPEINFO(tint::ast::Sampler); - -namespace tint::ast { - -Sampler::Sampler(ProgramID pid, NodeID nid, const Source& src, type::SamplerKind k) - : Base(pid, nid, src), kind(k) {} - -Sampler::Sampler(Sampler&&) = default; - -Sampler::~Sampler() = default; - -std::string Sampler::FriendlyName(const SymbolTable&) const { - return kind == type::SamplerKind::kSampler ? "sampler" : "sampler_comparison"; -} - -const Sampler* Sampler::Clone(CloneContext* ctx) const { - auto src = ctx->Clone(source); - return ctx->dst->create(src, kind); -} - -} // namespace tint::ast diff --git a/src/tint/ast/sampler.h b/src/tint/ast/sampler.h deleted file mode 100644 index 4227612724..0000000000 --- a/src/tint/ast/sampler.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2020 The Tint Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef SRC_TINT_AST_SAMPLER_H_ -#define SRC_TINT_AST_SAMPLER_H_ - -#include - -#include "src/tint/ast/type.h" -#include "src/tint/type/sampler_kind.h" - -namespace tint::ast { - -/// A sampler type. -class Sampler final : public Castable { - public: - /// Constructor - /// @param pid the identifier of the program that owns this node - /// @param nid the unique node identifier - /// @param src the source of this node - /// @param kind the kind of sampler - Sampler(ProgramID pid, NodeID nid, const Source& src, type::SamplerKind kind); - /// Move constructor - Sampler(Sampler&&); - ~Sampler() override; - - /// @returns true if this is a comparison sampler - bool IsComparison() const { return kind == type::SamplerKind::kComparisonSampler; } - - /// @param symbols the program's symbol table - /// @returns the name for this type that closely resembles how it would be - /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; - - /// Clones this type and all transitive types using the `CloneContext` `ctx`. - /// @param ctx the clone context - /// @return the newly cloned type - const Sampler* Clone(CloneContext* ctx) const override; - - /// The sampler type - const type::SamplerKind kind; -}; - -} // namespace tint::ast - -#endif // SRC_TINT_AST_SAMPLER_H_ diff --git a/src/tint/ast/sampler_test.cc b/src/tint/ast/sampler_test.cc deleted file mode 100644 index a9d5103a14..0000000000 --- a/src/tint/ast/sampler_test.cc +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2020 The Tint Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "src/tint/ast/sampler.h" - -#include "src/tint/ast/test_helper.h" - -namespace tint::ast { -namespace { - -using AstSamplerTest = TestHelper; - -TEST_F(AstSamplerTest, Creation) { - auto* s = create(type::SamplerKind::kSampler); - EXPECT_EQ(s->kind, type::SamplerKind::kSampler); -} - -TEST_F(AstSamplerTest, Creation_ComparisonSampler) { - auto* s = create(type::SamplerKind::kComparisonSampler); - EXPECT_EQ(s->kind, type::SamplerKind::kComparisonSampler); - EXPECT_TRUE(s->IsComparison()); -} - -TEST_F(AstSamplerTest, FriendlyNameSampler) { - auto* s = create(type::SamplerKind::kSampler); - EXPECT_EQ(s->FriendlyName(Symbols()), "sampler"); -} - -TEST_F(AstSamplerTest, FriendlyNameComparisonSampler) { - auto* s = create(type::SamplerKind::kComparisonSampler); - EXPECT_EQ(s->FriendlyName(Symbols()), "sampler_comparison"); -} - -} // namespace -} // namespace tint::ast diff --git a/src/tint/ast/struct_test.cc b/src/tint/ast/struct_test.cc index ac73b035ad..072a197ff0 100644 --- a/src/tint/ast/struct_test.cc +++ b/src/tint/ast/struct_test.cc @@ -18,7 +18,6 @@ #include "src/tint/ast/array.h" #include "src/tint/ast/matrix.h" #include "src/tint/ast/pointer.h" -#include "src/tint/ast/sampler.h" #include "src/tint/ast/test_helper.h" #include "src/tint/ast/texture.h" #include "src/tint/ast/vector.h" diff --git a/src/tint/ast/texture_test.cc b/src/tint/ast/texture_test.cc index 9c1996311e..e1cd4f6812 100644 --- a/src/tint/ast/texture_test.cc +++ b/src/tint/ast/texture_test.cc @@ -18,7 +18,6 @@ #include "src/tint/ast/array.h" #include "src/tint/ast/matrix.h" #include "src/tint/ast/pointer.h" -#include "src/tint/ast/sampler.h" #include "src/tint/ast/struct.h" #include "src/tint/ast/test_helper.h" #include "src/tint/ast/vector.h" diff --git a/src/tint/ast/type.cc b/src/tint/ast/type.cc index cc6c4d8367..6408596c1f 100644 --- a/src/tint/ast/type.cc +++ b/src/tint/ast/type.cc @@ -17,7 +17,6 @@ #include "src/tint/ast/alias.h" #include "src/tint/ast/matrix.h" #include "src/tint/ast/pointer.h" -#include "src/tint/ast/sampler.h" #include "src/tint/ast/texture.h" #include "src/tint/ast/vector.h" #include "src/tint/symbol_table.h" diff --git a/src/tint/inspector/test_inspector_builder.cc b/src/tint/inspector/test_inspector_builder.cc index 96139e243c..677f9c1b5f 100644 --- a/src/tint/inspector/test_inspector_builder.cc +++ b/src/tint/inspector/test_inspector_builder.cc @@ -171,13 +171,15 @@ void InspectorBuilder::MakeStructVariableReferenceBodyFunction( } void InspectorBuilder::AddSampler(const std::string& name, uint32_t group, uint32_t binding) { - GlobalVar(name, sampler_type(), Binding(AInt(binding)), Group(AInt(group))); + GlobalVar(name, ty.sampler(type::SamplerKind::kSampler), Binding(AInt(binding)), + Group(AInt(group))); } void InspectorBuilder::AddComparisonSampler(const std::string& name, uint32_t group, uint32_t binding) { - GlobalVar(name, comparison_sampler_type(), Binding(AInt(binding)), Group(AInt(group))); + GlobalVar(name, ty.sampler(type::SamplerKind::kComparisonSampler), Binding(AInt(binding)), + Group(AInt(group))); } void InspectorBuilder::AddResource(const std::string& name, diff --git a/src/tint/inspector/test_inspector_builder.h b/src/tint/inspector/test_inspector_builder.h index 03d2727d2f..8b32529b9c 100644 --- a/src/tint/inspector/test_inspector_builder.h +++ b/src/tint/inspector/test_inspector_builder.h @@ -332,14 +332,6 @@ class InspectorBuilder : public ProgramBuilder { /// @returns a reference to the Inspector for the built Program. Inspector& Build(); - /// @returns the type for a SamplerKind::kSampler - const ast::Sampler* sampler_type() { return ty.sampler(type::SamplerKind::kSampler); } - - /// @returns the type for a SamplerKind::kComparison - const ast::Sampler* comparison_sampler_type() { - return ty.sampler(type::SamplerKind::kComparisonSampler); - } - protected: /// Program built by this builder. std::unique_ptr program_; diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index d1b8cb3215..e76a48ed5c 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -167,6 +167,9 @@ enum builtin_type { vec4h vec4i vec4u + // https://www.w3.org/TR/WGSL/#sampler-type + sampler + sampler_comparison } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h index 116c5a9a74..7ba1a3b042 100644 --- a/src/tint/program_builder.h +++ b/src/tint/program_builder.h @@ -70,7 +70,6 @@ #include "src/tint/ast/pointer.h" #include "src/tint/ast/return_statement.h" #include "src/tint/ast/sampled_texture.h" -#include "src/tint/ast/sampler.h" #include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/storage_texture.h" #include "src/tint/ast/stride_attribute.h" @@ -105,6 +104,7 @@ #include "src/tint/type/multisampled_texture.h" #include "src/tint/type/pointer.h" #include "src/tint/type/sampled_texture.h" +#include "src/tint/type/sampler_kind.h" #include "src/tint/type/storage_texture.h" #include "src/tint/type/texture_dimension.h" #include "src/tint/type/u32.h" @@ -961,16 +961,23 @@ class ProgramBuilder { } /// @param kind the kind of sampler - /// @returns the sampler - const ast::Sampler* sampler(type::SamplerKind kind) const { - return builder->create(kind); + /// @returns the sampler typename + const ast::TypeName* sampler(type::SamplerKind kind) const { + return sampler(builder->source_, kind); } /// @param source the Source of the node /// @param kind the kind of sampler - /// @returns the sampler - const ast::Sampler* sampler(const Source& source, type::SamplerKind kind) const { - return builder->create(source, kind); + /// @returns the sampler typename + const ast::TypeName* sampler(const Source& source, type::SamplerKind kind) const { + switch (kind) { + case type::SamplerKind::kSampler: + return (*this)(source, "sampler"); + case type::SamplerKind::kComparisonSampler: + return (*this)(source, "sampler_comparison"); + } + TINT_ICE(ProgramBuilder, builder->Diagnostics()) << "invalid sampler kind " << kind; + return nullptr; } /// @param dims the dimensionality of the texture diff --git a/src/tint/reader/spirv/parser_type.h b/src/tint/reader/spirv/parser_type.h index bf36af9130..33f7e05cdc 100644 --- a/src/tint/reader/spirv/parser_type.h +++ b/src/tint/reader/spirv/parser_type.h @@ -19,11 +19,11 @@ #include #include -#include "src/tint/ast/sampler.h" #include "src/tint/ast/storage_texture.h" #include "src/tint/castable.h" #include "src/tint/type/access.h" #include "src/tint/type/address_space.h" +#include "src/tint/type/sampler_kind.h" #include "src/tint/type/texture_dimension.h" #include "src/tint/utils/block_allocator.h" diff --git a/src/tint/reader/wgsl/parser_impl_sampler_test.cc b/src/tint/reader/wgsl/parser_impl_sampler_test.cc index bd3c2d39aa..c1869eac22 100644 --- a/src/tint/reader/wgsl/parser_impl_sampler_test.cc +++ b/src/tint/reader/wgsl/parser_impl_sampler_test.cc @@ -32,8 +32,8 @@ TEST_F(ParserImplTest, SamplerType_Sampler) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - EXPECT_FALSE(t->As()->IsComparison()); + EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As()->name->symbol), + "sampler"); EXPECT_FALSE(p->has_error()); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 8u}})); } @@ -44,8 +44,8 @@ TEST_F(ParserImplTest, SamplerType_ComparisonSampler) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - EXPECT_TRUE(t->As()->IsComparison()); + EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As()->name->symbol), + "sampler_comparison"); EXPECT_FALSE(p->has_error()); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 19u}})); } diff --git a/src/tint/reader/wgsl/parser_impl_texture_sampler_test.cc b/src/tint/reader/wgsl/parser_impl_texture_sampler_test.cc index 636e539732..90a2516c73 100644 --- a/src/tint/reader/wgsl/parser_impl_texture_sampler_test.cc +++ b/src/tint/reader/wgsl/parser_impl_texture_sampler_test.cc @@ -37,8 +37,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_Sampler) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_FALSE(t->As()->IsComparison()); + EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As()->name->symbol), + "sampler"); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 8u}})); } @@ -49,8 +49,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->As()->IsComparison()); + EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As()->name->symbol), + "sampler_comparison"); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 19u}})); } diff --git a/src/tint/reader/wgsl/parser_impl_type_decl_test.cc b/src/tint/reader/wgsl/parser_impl_type_decl_test.cc index 373f9b7d7e..612e1023a3 100644 --- a/src/tint/reader/wgsl/parser_impl_type_decl_test.cc +++ b/src/tint/reader/wgsl/parser_impl_type_decl_test.cc @@ -15,7 +15,6 @@ #include "src/tint/ast/alias.h" #include "src/tint/ast/array.h" #include "src/tint/ast/matrix.h" -#include "src/tint/ast/sampler.h" #include "src/tint/reader/wgsl/parser_impl_test_helper.h" #include "src/tint/type/sampled_texture.h" @@ -689,8 +688,8 @@ TEST_F(ParserImplTest, TypeDecl_Sampler) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); - ASSERT_TRUE(t.value->Is()); - ASSERT_FALSE(t.value->As()->IsComparison()); + EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As()->name->symbol), + "sampler"); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 8u}})); } diff --git a/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc b/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc index f3cec74732..ba2fe61d01 100644 --- a/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc +++ b/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc @@ -15,7 +15,6 @@ #include "src/tint/ast/alias.h" #include "src/tint/ast/array.h" #include "src/tint/ast/matrix.h" -#include "src/tint/ast/sampler.h" #include "src/tint/reader/wgsl/parser_impl_test_helper.h" #include "src/tint/type/sampled_texture.h" @@ -682,8 +681,8 @@ TEST_F(ParserImplTest, TypeDeclWithoutIdent_Sampler) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); - ASSERT_TRUE(t.value->Is()); - ASSERT_FALSE(t.value->As()->IsComparison()); + EXPECT_EQ(p->builder().Symbols().NameFor(t.value->As()->name->symbol), + "sampler"); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 8u}})); } diff --git a/src/tint/resolver/builtin_test.cc b/src/tint/resolver/builtin_test.cc index 7be6162836..007154ed25 100644 --- a/src/tint/resolver/builtin_test.cc +++ b/src/tint/resolver/builtin_test.cc @@ -37,6 +37,7 @@ #include "src/tint/type/sampled_texture.h" #include "src/tint/type/test_helper.h" #include "src/tint/type/texture_dimension.h" +#include "src/tint/utils/string.h" using ::testing::ElementsAre; using ::testing::HasSubstr; @@ -2114,9 +2115,15 @@ class ResolverBuiltinTest_TextureOperation : public ResolverTestWithParamIsAnyOf()) { - GlobalVar(name, type, Binding(0_a), Group(0_a)); + if (auto* type_name = type->As()) { + if (utils::HasPrefix(Symbols().NameFor(type_name->name->symbol), "sampler")) { + GlobalVar(name, type, Binding(0_a), Group(0_a)); + return; + } + } + if (type->Is()) { + GlobalVar(name, type, Binding(0_a), Group(0_a)); } else { GlobalVar(name, type, type::AddressSpace::kPrivate); } diff --git a/src/tint/resolver/dependency_graph.cc b/src/tint/resolver/dependency_graph.cc index d9c3038216..262fbd6656 100644 --- a/src/tint/resolver/dependency_graph.cc +++ b/src/tint/resolver/dependency_graph.cc @@ -50,7 +50,6 @@ #include "src/tint/ast/pointer.h" #include "src/tint/ast/return_statement.h" #include "src/tint/ast/sampled_texture.h" -#include "src/tint/ast/sampler.h" #include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/storage_texture.h" #include "src/tint/ast/stride_attribute.h" @@ -407,7 +406,7 @@ class DependencyScanner { }, [&](Default) { if (!ty->IsAnyOf()) { + ast::ExternalTexture>()) { UnhandledNode(diagnostics_, ty); } }); diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index 538d1513ce..8c889bb29d 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -41,7 +41,6 @@ #include "src/tint/ast/pointer.h" #include "src/tint/ast/return_statement.h" #include "src/tint/ast/sampled_texture.h" -#include "src/tint/ast/sampler.h" #include "src/tint/ast/storage_texture.h" #include "src/tint/ast/switch_statement.h" #include "src/tint/ast/traverse_expressions.h" @@ -289,7 +288,6 @@ type::Type* Resolver::Type(const ast::Type* ty) { } return nullptr; }, - [&](const ast::Sampler* t) { return builder_->create(t->kind); }, [&](const ast::SampledTexture* t) -> type::SampledTexture* { if (auto* el = Type(t->type)) { auto* sem = builder_->create(t->dim, el); @@ -2525,6 +2523,10 @@ type::Type* Resolver::BuiltinType(type::Builtin builtin_ty, const ast::Identifie return vec(u32(), 3u); case type::Builtin::kVec4U: return vec(u32(), 4u); + case type::Builtin::kSampler: + return builder_->create(type::SamplerKind::kSampler); + case type::Builtin::kSamplerComparison: + return builder_->create(type::SamplerKind::kComparisonSampler); case type::Builtin::kUndefined: break; } diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc index eb9133a37d..0da542d807 100644 --- a/src/tint/resolver/validator.cc +++ b/src/tint/resolver/validator.cc @@ -38,7 +38,6 @@ #include "src/tint/ast/pointer.h" #include "src/tint/ast/return_statement.h" #include "src/tint/ast/sampled_texture.h" -#include "src/tint/ast/sampler.h" #include "src/tint/ast/storage_texture.h" #include "src/tint/ast/switch_statement.h" #include "src/tint/ast/traverse_expressions.h" diff --git a/src/tint/templates/enums.tmpl.inc b/src/tint/templates/enums.tmpl.inc index 756abb0666..ab08163fdd 100644 --- a/src/tint/templates/enums.tmpl.inc +++ b/src/tint/templates/enums.tmpl.inc @@ -173,7 +173,7 @@ INSTANTIATE_TEST_SUITE_P(ValidCases, {{$enum}}PrintTest, testing::ValuesIn(kVali {{- /* ------------------------------------------------------------------ */ -}} {{- $enum := Eval "EnumName" $ -}} void {{$enum}}Parser(::benchmark::State& state) { - std::array kStrings{ + const char* kStrings[] = { {{- $exclude := $.NameSet -}} {{- range $entry := $.PublicEntries }} "{{Scramble $entry.Name $exclude}}", @@ -186,7 +186,7 @@ void {{$enum}}Parser(::benchmark::State& state) { {{- end }} }; for (auto _ : state) { - for (auto& str : kStrings) { + for (auto* str : kStrings) { auto result = Parse{{$enum}}(str); benchmark::DoNotOptimize(result); } diff --git a/src/tint/transform/transform.cc b/src/tint/transform/transform.cc index ebf72aaa41..12deb03680 100644 --- a/src/tint/transform/transform.cc +++ b/src/tint/transform/transform.cc @@ -167,7 +167,7 @@ const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const type::Type CreateASTTypeFor(ctx, t->type()), t->access()); } if (auto* s = ty->As()) { - return ctx.dst->create(s->kind()); + return ctx.dst->ty.sampler(s->kind()); } TINT_UNREACHABLE(Transform, ctx.dst->Diagnostics()) << "Unhandled type: " << ty->TypeInfo().name; diff --git a/src/tint/type/access_bench.cc b/src/tint/type/access_bench.cc index 6b163179c6..ab578ebf1d 100644 --- a/src/tint/type/access_bench.cc +++ b/src/tint/type/access_bench.cc @@ -30,7 +30,7 @@ namespace tint::type { namespace { void AccessParser(::benchmark::State& state) { - std::array kStrings{ + const char* kStrings[] = { "ccad", "3", "rVad", "read", "1ead", "rqaJ", "rlla77", "reqqdppriHHe", "rv_wcit", "reabGwrte", "read_write", "read_vriite", "re8d_wriWWe", "Meadxxrite", "wggte", @@ -38,7 +38,7 @@ void AccessParser(::benchmark::State& state) { "wxxidd", }; for (auto _ : state) { - for (auto& str : kStrings) { + for (auto* str : kStrings) { auto result = ParseAccess(str); benchmark::DoNotOptimize(result); } diff --git a/src/tint/type/address_space_bench.cc b/src/tint/type/address_space_bench.cc index 6a6e4c8dc5..ecd3ccf57b 100644 --- a/src/tint/type/address_space_bench.cc +++ b/src/tint/type/address_space_bench.cc @@ -30,7 +30,7 @@ namespace tint::type { namespace { void AddressSpaceParser(::benchmark::State& state) { - std::array kStrings{ + const char* kStrings[] = { "fccnctin", "ucti3", "functVon", "function", "1unction", "unJtqqon", "llun77tion", "ppqqivtHH", "prcv", "bivaGe", "private", "priviive", "8WWivate", "pxxvate", "pXh_cggnstant", @@ -42,7 +42,7 @@ void AddressSpaceParser(::benchmark::State& state) { "jgkrouRR", "wokroub", }; for (auto _ : state) { - for (auto& str : kStrings) { + for (auto* str : kStrings) { auto result = ParseAddressSpace(str); benchmark::DoNotOptimize(result); } diff --git a/src/tint/type/builtin.cc b/src/tint/type/builtin.cc index 30409ca882..1523619aa8 100644 --- a/src/tint/type/builtin.cc +++ b/src/tint/type/builtin.cc @@ -94,6 +94,12 @@ Builtin ParseBuiltin(std::string_view str) { if (str == "mat4x4h") { return Builtin::kMat4X4H; } + if (str == "sampler") { + return Builtin::kSampler; + } + if (str == "sampler_comparison") { + return Builtin::kSamplerComparison; + } if (str == "u32") { return Builtin::kU32; } @@ -184,6 +190,10 @@ std::ostream& operator<<(std::ostream& out, Builtin value) { return out << "mat4x4f"; case Builtin::kMat4X4H: return out << "mat4x4h"; + case Builtin::kSampler: + return out << "sampler"; + case Builtin::kSamplerComparison: + return out << "sampler_comparison"; case Builtin::kU32: return out << "u32"; case Builtin::kVec2F: diff --git a/src/tint/type/builtin.h b/src/tint/type/builtin.h index df3e9da7f5..a69724f5b2 100644 --- a/src/tint/type/builtin.h +++ b/src/tint/type/builtin.h @@ -52,6 +52,8 @@ enum class Builtin { kMat4X3H, kMat4X4F, kMat4X4H, + kSampler, + kSamplerComparison, kU32, kVec2F, kVec2H, @@ -78,11 +80,13 @@ std::ostream& operator<<(std::ostream& out, Builtin value); Builtin ParseBuiltin(std::string_view str); constexpr const char* kBuiltinStrings[] = { - "bool", "f16", "f32", "i32", "mat2x2f", "mat2x2h", "mat2x3f", - "mat2x3h", "mat2x4f", "mat2x4h", "mat3x2f", "mat3x2h", "mat3x3f", "mat3x3h", - "mat3x4f", "mat3x4h", "mat4x2f", "mat4x2h", "mat4x3f", "mat4x3h", "mat4x4f", - "mat4x4h", "u32", "vec2f", "vec2h", "vec2i", "vec2u", "vec3f", - "vec3h", "vec3i", "vec3u", "vec4f", "vec4h", "vec4i", "vec4u", + "bool", "f16", "f32", "i32", "mat2x2f", "mat2x2h", + "mat2x3f", "mat2x3h", "mat2x4f", "mat2x4h", "mat3x2f", "mat3x2h", + "mat3x3f", "mat3x3h", "mat3x4f", "mat3x4h", "mat4x2f", "mat4x2h", + "mat4x3f", "mat4x3h", "mat4x4f", "mat4x4h", "sampler", "sampler_comparison", + "u32", "vec2f", "vec2h", "vec2i", "vec2u", "vec3f", + "vec3h", "vec3i", "vec3u", "vec4f", "vec4h", "vec4i", + "vec4u", }; } // namespace tint::type diff --git a/src/tint/type/builtin_bench.cc b/src/tint/type/builtin_bench.cc index d515e5df9a..8404209d91 100644 --- a/src/tint/type/builtin_bench.cc +++ b/src/tint/type/builtin_bench.cc @@ -30,51 +30,269 @@ namespace tint::type { namespace { void BuiltinParser(::benchmark::State& state) { - std::array kStrings{ - "ccol", "3", "bVol", "bool", "1ool", "bqoJ", - "bllo77", "fppqH", "", "Gb", "f16", "f1vi", - "f8WW", "fxx", "fgg", "X", "332", "f32", - "fE2", "fPTT", "dxx2", "4432", "iSVV2", "RR2", - "i32", "92", "i3", "VOR2", "ma2xyf", "llnarr2772f", - "mat24200", "mat2x2f", "a2oof", "zz2x2f", "miitppx1", "mat2xXXh", - "9II5ann2x2h", "mataSSrHHYh", "mat2x2h", "makkh", "jatgRx", "mb2x2", - "mat2xjf", "at2x3f", "q2x3f", "mat2x3f", "matNN3f", "at23vv", - "QQt2x3f", "maffxr", "mat2xjh", "mNNw2x38", "mat2x3h", "matx3h", - "mrrt2x3h", "Gat2x3h", "mat2x4FF", "at2f", "marrx4f", "mat2x4f", - "t2x4f", "Da2xJJf", "ma84", "m11k4", "matx4h", "maJx4h", - "mat2x4h", "mat2c4h", "mat2x4O", "KK_atvvtt4h", "xx83x2f", "__qatF2", - "matqx2f", "mat3x2f", "33atOx2f", "mtt63x9oQQ", "ma3x66f", "mtOxzz66", - "mat3yy2h", "ZaHH2Z", "mat3x2h", "4WWt3q2h", "mOO3x2h", "oatY2h", - "matx", "ma3xFf", "at3x3w", "mat3x3f", "fGtxKf", "matqKx3f", - "matmmxFf", "at3x3h", "mt3x3q", "mat3xbb", "mat3x3h", "mi3x3h", - "maOO3xq", "matTvvx3h", "maFF3x4f", "Pa00xQf", "mPt3x4f", "mat3x4f", - "ma773xss", "RRCbb3x4f", "mXXt3x4f", "qaCC3xOOh", "ma3s4L", "mXt3x4h", - "mat3x4h", "mat34h", "qa3O4", "mat3x22h", "myzz40XX", "matVViP", - "mannC2f", "mat4x2f", "atx2AHHq", "mat4x2", "fatK2f", "ltgg2h", - "mat4xh", "NTTtcx4h", "mat4x2h", "ma7ppl2h", "mNNt4xg", "uub4XX2h", - "matx3f", "Qt883f", "mt9q3f", "mat4x3f", "m11t4x3f", "22at4iif", - "at4x377", "m2t4xNh", "mVVt4x3h", "FaWW4w11h", "mat4x3h", "mawwx3h", - "Dat4x3h", "mt4x3K", "mat41PPhf", "mat44f", "mYYt4x4f", "mat4x4f", - "mttHH4kk", "mat4rr4f", "WWas4x4f", "Yt4x4h", "mt4qfh", "mav224xuh", - "mat4x4h", "t4x4h", "YYat4h", "may4x4EYY", "Mo2", "uMM", - "u552", "u32", "N", "333", "u33", "mecI", - "vrnK2f", "v2", "vec2f", "ILLcf", "ecf", "UecRY", - "vechh", "qeIIu", "Hec2h", "vec2h", "eQQvv", "e66h", - "7Wc2", "ve055DD", "IIec2i", "vec2", "vec2i", "rec2", - "lec2i", "GeJ2i", "ey2u", "vc2u", "IIeBB2u", "vec2u", - "TTec338", "veUUSS2nnd", "vZx5CC", "kkec3q", "v005if", "vnIIc3f", - "vec3f", "cceW", "cKK", "vec66f", "vePPK", "vexxh", - "qec3h", "vec3h", "veSyMMr", "v3u", "ec", "5eFF3i", - "rrecz44", "vWW", "vec3i", "XJecCZZ", "vePP3", "vec3c", - "ve6ll3u", "vcyy99", "Jec3KK", "vec3u", "_ex3", "Ky3", - "zek3u", "veKSf", "vc4f", "ec4VV", "vec4f", "IAAc4f", - "jbR", "veY4", "ec4h", "vc911", "mmcch", "vec4h", - "vJJch", "lDDcUfC", "vec4g", "CCe", "ec4i", "vIc__i", - "vec4i", "ePPtt", "v3dc4i", "vcyyi", "u4", "v03nnu", - "Cuuecnv", "vec4u", "vX4ll", "vocppu", "vwwc4", + const char* kStrings[] = { + "ccol", + "3", + "bVol", + "bool", + "1ool", + "bqoJ", + "bllo77", + "fppqH", + "", + "Gb", + "f16", + "f1vi", + "f8WW", + "fxx", + "fgg", + "X", + "332", + "f32", + "fE2", + "fPTT", + "dxx2", + "4432", + "iSVV2", + "RR2", + "i32", + "92", + "i3", + "VOR2", + "ma2xyf", + "llnarr2772f", + "mat24200", + "mat2x2f", + "a2oof", + "zz2x2f", + "miitppx1", + "mat2xXXh", + "9II5ann2x2h", + "mataSSrHHYh", + "mat2x2h", + "makkh", + "jatgRx", + "mb2x2", + "mat2xjf", + "at2x3f", + "q2x3f", + "mat2x3f", + "matNN3f", + "at23vv", + "QQt2x3f", + "maffxr", + "mat2xjh", + "mNNw2x38", + "mat2x3h", + "matx3h", + "mrrt2x3h", + "Gat2x3h", + "mat2x4FF", + "at2f", + "marrx4f", + "mat2x4f", + "t2x4f", + "Da2xJJf", + "ma84", + "m11k4", + "matx4h", + "maJx4h", + "mat2x4h", + "mat2c4h", + "mat2x4O", + "KK_atvvtt4h", + "xx83x2f", + "__qatF2", + "matqx2f", + "mat3x2f", + "33atOx2f", + "mtt63x9oQQ", + "ma3x66f", + "mtOxzz66", + "mat3yy2h", + "ZaHH2Z", + "mat3x2h", + "4WWt3q2h", + "mOO3x2h", + "oatY2h", + "matx", + "ma3xFf", + "at3x3w", + "mat3x3f", + "fGtxKf", + "matqKx3f", + "matmmxFf", + "at3x3h", + "mt3x3q", + "mat3xbb", + "mat3x3h", + "mi3x3h", + "maOO3xq", + "matTvvx3h", + "maFF3x4f", + "Pa00xQf", + "mPt3x4f", + "mat3x4f", + "ma773xss", + "RRCbb3x4f", + "mXXt3x4f", + "qaCC3xOOh", + "ma3s4L", + "mXt3x4h", + "mat3x4h", + "mat34h", + "qa3O4", + "mat3x22h", + "myzz40XX", + "matVViP", + "mannC2f", + "mat4x2f", + "atx2AHHq", + "mat4x2", + "fatK2f", + "ltgg2h", + "mat4xh", + "NTTtcx4h", + "mat4x2h", + "ma7ppl2h", + "mNNt4xg", + "uub4XX2h", + "matx3f", + "Qt883f", + "mt9q3f", + "mat4x3f", + "m11t4x3f", + "22at4iif", + "at4x377", + "m2t4xNh", + "mVVt4x3h", + "FaWW4w11h", + "mat4x3h", + "mawwx3h", + "Dat4x3h", + "mt4x3K", + "mat41PPhf", + "mat44f", + "mYYt4x4f", + "mat4x4f", + "mttHH4kk", + "mat4rr4f", + "WWas4x4f", + "Yt4x4h", + "mt4qfh", + "mav224xuh", + "mat4x4h", + "t4x4h", + "YYat4h", + "may4x4EYY", + "daplMor", + "samMMle", + "sampl55r", + "sampler", + "saNpe", + "sa3Ol33", + "s3mpler", + "Iamplercomparismn", + "sampleKrcompannison", + "samlr_copXXison", + "sampler_comparison", + "samplpLL_comparisI", + "smplerfomparison", + "sYmpURDr_comprison", + "u3h", + "IIq", + "u3H", + "u32", + "Qvv", + "66", + "73", + "ve055DD", + "IIec2f", + "vec2", + "vec2f", + "rec2", + "lec2f", + "GeJ2f", + "ey2h", + "vc2h", + "IIeBB2h", + "vec2h", + "TTec338", + "veUUSS2nnd", + "vZx5CC", + "kkec2q", + "v005ii", + "vnIIc2i", + "vec2i", + "cceW", + "cKK", + "vec66i", + "vePPK", + "vexxu", + "qec2u", + "vec2u", + "veSyMMr", + "v2u", + "ec", + "5eFF3f", + "rrecz44", + "vWW", + "vec3f", + "XJecCZZ", + "vePP3", + "vec3c", + "ve6ll3h", + "vcyy99", + "Jec3KK", + "vec3h", + "_ex3", + "Ky3", + "zek3h", + "veKSi", + "vc3i", + "ec3VV", + "vec3i", + "IAAc3i", + "jbR", + "veY4", + "ec3u", + "vc911", + "mmccu", + "vec3u", + "vJJcu", + "lDDcUfC", + "vec3g", + "CCe", + "ec4f", + "vIc__f", + "vec4f", + "ePPtt", + "v3dc4f", + "vcyyf", + "u4", + "v03nnh", + "Cuuecnv", + "vec4h", + "vX4ll", + "vocpph", + "vwwc4", + "veuug", + "vaac", + "TRZccci", + "vec4i", + "vTc4O8", + "vem04i", + "meBB4i", + "Mpp4", + "OOe4u", + "veG4G", + "vec4u", + "11eHH4u", + "veFFe6", + "ve4", }; for (auto _ : state) { - for (auto& str : kStrings) { + for (auto* str : kStrings) { auto result = ParseBuiltin(str); benchmark::DoNotOptimize(result); } diff --git a/src/tint/type/builtin_test.cc b/src/tint/type/builtin_test.cc index 5ef9a17cdf..bb30408ad8 100644 --- a/src/tint/type/builtin_test.cc +++ b/src/tint/type/builtin_test.cc @@ -43,74 +43,139 @@ inline std::ostream& operator<<(std::ostream& out, Case c) { } static constexpr Case kValidCases[] = { - {"bool", Builtin::kBool}, {"f16", Builtin::kF16}, {"f32", Builtin::kF32}, - {"i32", Builtin::kI32}, {"mat2x2f", Builtin::kMat2X2F}, {"mat2x2h", Builtin::kMat2X2H}, - {"mat2x3f", Builtin::kMat2X3F}, {"mat2x3h", Builtin::kMat2X3H}, {"mat2x4f", Builtin::kMat2X4F}, - {"mat2x4h", Builtin::kMat2X4H}, {"mat3x2f", Builtin::kMat3X2F}, {"mat3x2h", Builtin::kMat3X2H}, - {"mat3x3f", Builtin::kMat3X3F}, {"mat3x3h", Builtin::kMat3X3H}, {"mat3x4f", Builtin::kMat3X4F}, - {"mat3x4h", Builtin::kMat3X4H}, {"mat4x2f", Builtin::kMat4X2F}, {"mat4x2h", Builtin::kMat4X2H}, - {"mat4x3f", Builtin::kMat4X3F}, {"mat4x3h", Builtin::kMat4X3H}, {"mat4x4f", Builtin::kMat4X4F}, - {"mat4x4h", Builtin::kMat4X4H}, {"u32", Builtin::kU32}, {"vec2f", Builtin::kVec2F}, - {"vec2h", Builtin::kVec2H}, {"vec2i", Builtin::kVec2I}, {"vec2u", Builtin::kVec2U}, - {"vec3f", Builtin::kVec3F}, {"vec3h", Builtin::kVec3H}, {"vec3i", Builtin::kVec3I}, - {"vec3u", Builtin::kVec3U}, {"vec4f", Builtin::kVec4F}, {"vec4h", Builtin::kVec4H}, - {"vec4i", Builtin::kVec4I}, {"vec4u", Builtin::kVec4U}, + {"bool", Builtin::kBool}, {"f16", Builtin::kF16}, + {"f32", Builtin::kF32}, {"i32", Builtin::kI32}, + {"mat2x2f", Builtin::kMat2X2F}, {"mat2x2h", Builtin::kMat2X2H}, + {"mat2x3f", Builtin::kMat2X3F}, {"mat2x3h", Builtin::kMat2X3H}, + {"mat2x4f", Builtin::kMat2X4F}, {"mat2x4h", Builtin::kMat2X4H}, + {"mat3x2f", Builtin::kMat3X2F}, {"mat3x2h", Builtin::kMat3X2H}, + {"mat3x3f", Builtin::kMat3X3F}, {"mat3x3h", Builtin::kMat3X3H}, + {"mat3x4f", Builtin::kMat3X4F}, {"mat3x4h", Builtin::kMat3X4H}, + {"mat4x2f", Builtin::kMat4X2F}, {"mat4x2h", Builtin::kMat4X2H}, + {"mat4x3f", Builtin::kMat4X3F}, {"mat4x3h", Builtin::kMat4X3H}, + {"mat4x4f", Builtin::kMat4X4F}, {"mat4x4h", Builtin::kMat4X4H}, + {"sampler", Builtin::kSampler}, {"sampler_comparison", Builtin::kSamplerComparison}, + {"u32", Builtin::kU32}, {"vec2f", Builtin::kVec2F}, + {"vec2h", Builtin::kVec2H}, {"vec2i", Builtin::kVec2I}, + {"vec2u", Builtin::kVec2U}, {"vec3f", Builtin::kVec3F}, + {"vec3h", Builtin::kVec3H}, {"vec3i", Builtin::kVec3I}, + {"vec3u", Builtin::kVec3U}, {"vec4f", Builtin::kVec4F}, + {"vec4h", Builtin::kVec4H}, {"vec4i", Builtin::kVec4I}, + {"vec4u", Builtin::kVec4U}, }; static constexpr Case kInvalidCases[] = { - {"ccol", Builtin::kUndefined}, {"3", Builtin::kUndefined}, - {"bVol", Builtin::kUndefined}, {"116", Builtin::kUndefined}, - {"qJ6", Builtin::kUndefined}, {"f17ll", Builtin::kUndefined}, - {"fppqH", Builtin::kUndefined}, {"", Builtin::kUndefined}, - {"Gb", Builtin::kUndefined}, {"i3vi", Builtin::kUndefined}, - {"i8WW", Builtin::kUndefined}, {"ixx", Builtin::kUndefined}, - {"mX2x2gg", Builtin::kUndefined}, {"a2xXf", Builtin::kUndefined}, - {"mat232f", Builtin::kUndefined}, {"Eat2x2h", Builtin::kUndefined}, - {"mPTT2x2h", Builtin::kUndefined}, {"mat2xdxx", Builtin::kUndefined}, - {"m44t2x3f", Builtin::kUndefined}, {"maSS2xVVf", Builtin::kUndefined}, - {"RatR22f", Builtin::kUndefined}, {"mF2x9h", Builtin::kUndefined}, - {"matx3h", Builtin::kUndefined}, {"VOORRH3h", Builtin::kUndefined}, - {"ma2xyf", Builtin::kUndefined}, {"llnarr2774f", Builtin::kUndefined}, - {"mat24400", Builtin::kUndefined}, {"a2ooh", Builtin::kUndefined}, - {"zz2x4h", Builtin::kUndefined}, {"miitppx1", Builtin::kUndefined}, - {"mat3xXXf", Builtin::kUndefined}, {"9II5ann3x2f", Builtin::kUndefined}, - {"mataSSrHHYf", Builtin::kUndefined}, {"makkh", Builtin::kUndefined}, - {"jatgRx", Builtin::kUndefined}, {"mb3x2", Builtin::kUndefined}, - {"mat3xjf", Builtin::kUndefined}, {"at3x3f", Builtin::kUndefined}, - {"q3x3f", Builtin::kUndefined}, {"matNN3h", Builtin::kUndefined}, - {"at33vv", Builtin::kUndefined}, {"QQt3x3h", Builtin::kUndefined}, - {"maffxr", Builtin::kUndefined}, {"mat3xjf", Builtin::kUndefined}, - {"mNNw3x48", Builtin::kUndefined}, {"matx4h", Builtin::kUndefined}, - {"mrrt3x4h", Builtin::kUndefined}, {"Gat3x4h", Builtin::kUndefined}, - {"mat4x2FF", Builtin::kUndefined}, {"at4f", Builtin::kUndefined}, - {"marrx2f", Builtin::kUndefined}, {"t4x2h", Builtin::kUndefined}, - {"Da4xJJh", Builtin::kUndefined}, {"ma82", Builtin::kUndefined}, - {"m11k3", Builtin::kUndefined}, {"matx3f", Builtin::kUndefined}, - {"maJx3f", Builtin::kUndefined}, {"mat4c3h", Builtin::kUndefined}, - {"mat4x3O", Builtin::kUndefined}, {"KK_atvvtt3h", Builtin::kUndefined}, - {"xx84x4f", Builtin::kUndefined}, {"__qatF4", Builtin::kUndefined}, - {"matqx4f", Builtin::kUndefined}, {"33atOx4h", Builtin::kUndefined}, - {"mtt64x9oQQ", Builtin::kUndefined}, {"ma4x66h", Builtin::kUndefined}, - {"zzO6", Builtin::kUndefined}, {"uyy2", Builtin::kUndefined}, - {"HZ", Builtin::kUndefined}, {"ecWq4f", Builtin::kUndefined}, - {"vOO2f", Builtin::kUndefined}, {"oYe2", Builtin::kUndefined}, - {"v2", Builtin::kUndefined}, {"Fe2h", Builtin::kUndefined}, - {"vwch", Builtin::kUndefined}, {"vefi", Builtin::kUndefined}, - {"KKeq2i", Builtin::kUndefined}, {"vFmm2i", Builtin::kUndefined}, - {"vecu", Builtin::kUndefined}, {"qc2u", Builtin::kUndefined}, - {"vecbb", Builtin::kUndefined}, {"iic3", Builtin::kUndefined}, - {"vqOOf", Builtin::kUndefined}, {"vevvTTf", Builtin::kUndefined}, - {"veFF3h", Builtin::kUndefined}, {"00PfQ", Builtin::kUndefined}, - {"vec3P", Builtin::kUndefined}, {"vec77s", Builtin::kUndefined}, - {"vecbbCi", Builtin::kUndefined}, {"vecXXi", Builtin::kUndefined}, - {"CCOOec3", Builtin::kUndefined}, {"vs3u", Builtin::kUndefined}, - {"Xec3u", Builtin::kUndefined}, {"ve4f", Builtin::kUndefined}, - {"qq4", Builtin::kUndefined}, {"vec422", Builtin::kUndefined}, - {"vezzXy", Builtin::kUndefined}, {"ieVVP", Builtin::kUndefined}, - {"venCh", Builtin::kUndefined}, {"vHc4Aq", Builtin::kUndefined}, - {"ve4i", Builtin::kUndefined}, {"vefK", Builtin::kUndefined}, - {"vgg4", Builtin::kUndefined}, {"vecu", Builtin::kUndefined}, - {"4TNc4u", Builtin::kUndefined}, + {"ccol", Builtin::kUndefined}, + {"3", Builtin::kUndefined}, + {"bVol", Builtin::kUndefined}, + {"116", Builtin::kUndefined}, + {"qJ6", Builtin::kUndefined}, + {"f17ll", Builtin::kUndefined}, + {"fppqH", Builtin::kUndefined}, + {"", Builtin::kUndefined}, + {"Gb", Builtin::kUndefined}, + {"i3vi", Builtin::kUndefined}, + {"i8WW", Builtin::kUndefined}, + {"ixx", Builtin::kUndefined}, + {"mX2x2gg", Builtin::kUndefined}, + {"a2xXf", Builtin::kUndefined}, + {"mat232f", Builtin::kUndefined}, + {"Eat2x2h", Builtin::kUndefined}, + {"mPTT2x2h", Builtin::kUndefined}, + {"mat2xdxx", Builtin::kUndefined}, + {"m44t2x3f", Builtin::kUndefined}, + {"maSS2xVVf", Builtin::kUndefined}, + {"RatR22f", Builtin::kUndefined}, + {"mF2x9h", Builtin::kUndefined}, + {"matx3h", Builtin::kUndefined}, + {"VOORRH3h", Builtin::kUndefined}, + {"ma2xyf", Builtin::kUndefined}, + {"llnarr2774f", Builtin::kUndefined}, + {"mat24400", Builtin::kUndefined}, + {"a2ooh", Builtin::kUndefined}, + {"zz2x4h", Builtin::kUndefined}, + {"miitppx1", Builtin::kUndefined}, + {"mat3xXXf", Builtin::kUndefined}, + {"9II5ann3x2f", Builtin::kUndefined}, + {"mataSSrHHYf", Builtin::kUndefined}, + {"makkh", Builtin::kUndefined}, + {"jatgRx", Builtin::kUndefined}, + {"mb3x2", Builtin::kUndefined}, + {"mat3xjf", Builtin::kUndefined}, + {"at3x3f", Builtin::kUndefined}, + {"q3x3f", Builtin::kUndefined}, + {"matNN3h", Builtin::kUndefined}, + {"at33vv", Builtin::kUndefined}, + {"QQt3x3h", Builtin::kUndefined}, + {"maffxr", Builtin::kUndefined}, + {"mat3xjf", Builtin::kUndefined}, + {"mNNw3x48", Builtin::kUndefined}, + {"matx4h", Builtin::kUndefined}, + {"mrrt3x4h", Builtin::kUndefined}, + {"Gat3x4h", Builtin::kUndefined}, + {"mat4x2FF", Builtin::kUndefined}, + {"at4f", Builtin::kUndefined}, + {"marrx2f", Builtin::kUndefined}, + {"t4x2h", Builtin::kUndefined}, + {"Da4xJJh", Builtin::kUndefined}, + {"ma82", Builtin::kUndefined}, + {"m11k3", Builtin::kUndefined}, + {"matx3f", Builtin::kUndefined}, + {"maJx3f", Builtin::kUndefined}, + {"mat4c3h", Builtin::kUndefined}, + {"mat4x3O", Builtin::kUndefined}, + {"KK_atvvtt3h", Builtin::kUndefined}, + {"xx84x4f", Builtin::kUndefined}, + {"__qatF4", Builtin::kUndefined}, + {"matqx4f", Builtin::kUndefined}, + {"33atOx4h", Builtin::kUndefined}, + {"mtt64x9oQQ", Builtin::kUndefined}, + {"ma4x66h", Builtin::kUndefined}, + {"smOlzz66", Builtin::kUndefined}, + {"sampyyer", Builtin::kUndefined}, + {"ZaHHeZ", Builtin::kUndefined}, + {"sWWpleq_compari44on", Builtin::kUndefined}, + {"sampler_compaisoOO", Builtin::kUndefined}, + {"smpeoo_coYparison", Builtin::kUndefined}, + {"", Builtin::kUndefined}, + {"u3", Builtin::kUndefined}, + {"3w", Builtin::kUndefined}, + {"veff", Builtin::kUndefined}, + {"KKeq2f", Builtin::kUndefined}, + {"vFmm2f", Builtin::kUndefined}, + {"vech", Builtin::kUndefined}, + {"qc2h", Builtin::kUndefined}, + {"vecbb", Builtin::kUndefined}, + {"iic2", Builtin::kUndefined}, + {"vqOOi", Builtin::kUndefined}, + {"vevvTTi", Builtin::kUndefined}, + {"veFF2u", Builtin::kUndefined}, + {"00PfQ", Builtin::kUndefined}, + {"vec2P", Builtin::kUndefined}, + {"vec77s", Builtin::kUndefined}, + {"vecbbCf", Builtin::kUndefined}, + {"vecXXf", Builtin::kUndefined}, + {"CCOOec3", Builtin::kUndefined}, + {"vs3u", Builtin::kUndefined}, + {"Xec3h", Builtin::kUndefined}, + {"ve3i", Builtin::kUndefined}, + {"qq3", Builtin::kUndefined}, + {"vec322", Builtin::kUndefined}, + {"vezzXy", Builtin::kUndefined}, + {"ieVVP", Builtin::kUndefined}, + {"venCu", Builtin::kUndefined}, + {"vHc4Aq", Builtin::kUndefined}, + {"ve4f", Builtin::kUndefined}, + {"vefK", Builtin::kUndefined}, + {"vgg4", Builtin::kUndefined}, + {"vech", Builtin::kUndefined}, + {"4TNc4h", Builtin::kUndefined}, + {"ppec7l", Builtin::kUndefined}, + {"zNe4i", Builtin::kUndefined}, + {"uXXb4i", Builtin::kUndefined}, + {"vec4", Builtin::kUndefined}, + {"884K", Builtin::kUndefined}, + {"vq9u", Builtin::kUndefined}, }; using BuiltinParseTest = testing::TestWithParam; diff --git a/src/tint/type/texel_format_bench.cc b/src/tint/type/texel_format_bench.cc index 8cf7a73f69..6a0ea27c14 100644 --- a/src/tint/type/texel_format_bench.cc +++ b/src/tint/type/texel_format_bench.cc @@ -30,7 +30,7 @@ namespace tint::type { namespace { void TexelFormatParser(::benchmark::State& state) { - std::array kStrings{ + const char* kStrings[] = { "bgraunccrm", "blranr3", "bVra8unorm", "bgra8unorm", "bgra1unorm", "bgrJqqnorm", "bgr7ll8unorm", "qq32lppHat", "c2fov", "r32Goat", "r32float", "r3viiloat", "r3WWflo8t", "rxxfMoat", "rXsingg", @@ -57,7 +57,7 @@ void TexelFormatParser(::benchmark::State& state) { "rgba8unorm", "ba8unoqqHHA", "rga8unorm", "rgfa8uKKo", }; for (auto _ : state) { - for (auto& str : kStrings) { + for (auto* str : kStrings) { auto result = ParseTexelFormat(str); benchmark::DoNotOptimize(result); } diff --git a/src/tint/writer/glsl/generator_impl_builtin_texture_test.cc b/src/tint/writer/glsl/generator_impl_builtin_texture_test.cc index cb5a4c81f0..be12076d1d 100644 --- a/src/tint/writer/glsl/generator_impl_builtin_texture_test.cc +++ b/src/tint/writer/glsl/generator_impl_builtin_texture_test.cc @@ -61,41 +61,41 @@ ExpectedResult expected_texture_overload(ast::builtin::test::ValidTextureOverloa case ValidTextureOverload::kDimensionsStorageWO3d: return {"imageSize"}; case ValidTextureOverload::kGather2dF32: - return R"(textureGather(tint_symbol_sampler, vec2(1.0f, 2.0f), 0))"; + return R"(textureGather(Texture_Sampler, vec2(1.0f, 2.0f), 0))"; case ValidTextureOverload::kGather2dOffsetF32: - return R"(textureGatherOffset(tint_symbol_sampler, vec2(1.0f, 2.0f), ivec2(3, 4), int(0u)))"; + return R"(textureGatherOffset(Texture_Sampler, vec2(1.0f, 2.0f), ivec2(3, 4), int(0u)))"; case ValidTextureOverload::kGather2dArrayF32: - return R"(textureGather(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)), 0))"; + return R"(textureGather(Texture_Sampler, vec3(1.0f, 2.0f, float(3)), 0))"; case ValidTextureOverload::kGather2dArrayOffsetF32: - return R"(textureGatherOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3u)), ivec2(4, 5), int(0u)))"; + return R"(textureGatherOffset(Texture_Sampler, vec3(1.0f, 2.0f, float(3u)), ivec2(4, 5), int(0u)))"; case ValidTextureOverload::kGatherCubeF32: - return R"(textureGather(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), 0))"; + return R"(textureGather(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), 0))"; case ValidTextureOverload::kGatherCubeArrayF32: - return R"(textureGather(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), int(0u))"; + return R"(textureGather(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), int(0u))"; case ValidTextureOverload::kGatherDepth2dF32: - return R"(textureGather(tint_symbol_sampler, vec2(1.0f, 2.0f), 0.0))"; + return R"(textureGather(Texture_Sampler, vec2(1.0f, 2.0f), 0.0))"; case ValidTextureOverload::kGatherDepth2dOffsetF32: - return R"(textureGatherOffset(tint_symbol_sampler, vec2(1.0f, 2.0f), 0.0, ivec2(3, 4))"; + return R"(textureGatherOffset(Texture_Sampler, vec2(1.0f, 2.0f), 0.0, ivec2(3, 4))"; case ValidTextureOverload::kGatherDepth2dArrayF32: - return R"(textureGather(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3u)), 0.0))"; + return R"(textureGather(Texture_Sampler, vec3(1.0f, 2.0f, float(3u)), 0.0))"; case ValidTextureOverload::kGatherDepth2dArrayOffsetF32: - return R"(textureGatherOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)), 0.0, ivec2(4, 5)))"; + return R"(textureGatherOffset(Texture_Sampler, vec3(1.0f, 2.0f, float(3)), 0.0, ivec2(4, 5)))"; case ValidTextureOverload::kGatherDepthCubeF32: - return R"(textureGather(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), 0.0))"; + return R"(textureGather(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), 0.0))"; case ValidTextureOverload::kGatherDepthCubeArrayF32: - return R"(textureGather(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), 0.0))"; + return R"(textureGather(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), 0.0))"; case ValidTextureOverload::kGatherCompareDepth2dF32: - return R"(textureGather(tint_symbol_sampler, vec2(1.0f, 2.0f), 3.0f))"; + return R"(textureGather(Texture_Sampler, vec2(1.0f, 2.0f), 3.0f))"; case ValidTextureOverload::kGatherCompareDepth2dOffsetF32: - return R"(textureGatherOffset(tint_symbol_sampler, vec2(1.0f, 2.0f), 3.0f, ivec2(4, 5)))"; + return R"(textureGatherOffset(Texture_Sampler, vec2(1.0f, 2.0f), 3.0f, ivec2(4, 5)))"; case ValidTextureOverload::kGatherCompareDepth2dArrayF32: - return R"(textureGather(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)), 4.0f))"; + return R"(textureGather(Texture_Sampler, vec3(1.0f, 2.0f, float(3)), 4.0f))"; case ValidTextureOverload::kGatherCompareDepth2dArrayOffsetF32: - return R"(textureGatherOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)), 4.0f, ivec2(5, 6)))"; + return R"(textureGatherOffset(Texture_Sampler, vec3(1.0f, 2.0f, float(3)), 4.0f, ivec2(5, 6)))"; case ValidTextureOverload::kGatherCompareDepthCubeF32: - return R"(textureGather(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f))"; + return R"(textureGather(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f))"; case ValidTextureOverload::kGatherCompareDepthCubeArrayF32: - return R"(textureGather(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), 5.0f))"; + return R"(textureGather(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), 5.0f))"; case ValidTextureOverload::kNumLayers2dArray: case ValidTextureOverload::kNumLayersDepth2dArray: case ValidTextureOverload::kNumLayersCubeArray: @@ -117,156 +117,156 @@ ExpectedResult expected_texture_overload(ast::builtin::test::ValidTextureOverloa case ValidTextureOverload::kNumSamplesMultisampled2d: return {"textureSamples"}; case ValidTextureOverload::kSample1dF32: - return R"(texture(tint_symbol_sampler, vec2(1.0f, 0.5f));)"; + return R"(texture(Texture_Sampler, vec2(1.0f, 0.5f));)"; case ValidTextureOverload::kSample2dF32: - return R"(texture(tint_symbol_sampler, vec2(1.0f, 2.0f));)"; + return R"(texture(Texture_Sampler, vec2(1.0f, 2.0f));)"; case ValidTextureOverload::kSample2dOffsetF32: - return R"(textureOffset(tint_symbol_sampler, vec2(1.0f, 2.0f), ivec2(3, 4));)"; + return R"(textureOffset(Texture_Sampler, vec2(1.0f, 2.0f), ivec2(3, 4));)"; case ValidTextureOverload::kSample2dArrayF32: - return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)));)"; + return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, float(3)));)"; case ValidTextureOverload::kSample2dArrayOffsetF32: - return R"(textureOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3u)), ivec2(4, 5));)"; + return R"(textureOffset(Texture_Sampler, vec3(1.0f, 2.0f, float(3u)), ivec2(4, 5));)"; case ValidTextureOverload::kSample3dF32: - return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f));)"; + return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f));)"; case ValidTextureOverload::kSample3dOffsetF32: - return R"(textureOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), ivec3(4, 5, 6));)"; + return R"(textureOffset(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), ivec3(4, 5, 6));)"; case ValidTextureOverload::kSampleCubeF32: - return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f));)"; + return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f));)"; case ValidTextureOverload::kSampleCubeArrayF32: - return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4)));)"; + return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4)));)"; case ValidTextureOverload::kSampleDepth2dF32: - return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, 0.0f));)"; + return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, 0.0f));)"; case ValidTextureOverload::kSampleDepth2dOffsetF32: - return R"(textureOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, 0.0f), ivec2(3, 4));)"; + return R"(textureOffset(Texture_Sampler, vec3(1.0f, 2.0f, 0.0f), ivec2(3, 4));)"; case ValidTextureOverload::kSampleDepth2dArrayF32: - return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, float(3), 0.0f));)"; + return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, float(3), 0.0f));)"; case ValidTextureOverload::kSampleDepth2dArrayOffsetF32: - return R"(textureOffset(tint_symbol_sampler, vec4(1.0f, 2.0f, float(3), 0.0f), ivec2(4, 5));)"; + return R"(textureOffset(Texture_Sampler, vec4(1.0f, 2.0f, float(3), 0.0f), ivec2(4, 5));)"; case ValidTextureOverload::kSampleDepthCubeF32: - return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, 0.0f));)"; + return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, 0.0f));)"; case ValidTextureOverload::kSampleDepthCubeArrayF32: - return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), 0.0f);)"; + return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), 0.0f);)"; case ValidTextureOverload::kSampleBias2dF32: - return R"(texture(tint_symbol_sampler, vec2(1.0f, 2.0f), 3.0f);)"; + return R"(texture(Texture_Sampler, vec2(1.0f, 2.0f), 3.0f);)"; case ValidTextureOverload::kSampleBias2dOffsetF32: - return R"(textureOffset(tint_symbol_sampler, vec2(1.0f, 2.0f), ivec2(4, 5), 3.0f);)"; + return R"(textureOffset(Texture_Sampler, vec2(1.0f, 2.0f), ivec2(4, 5), 3.0f);)"; case ValidTextureOverload::kSampleBias2dArrayF32: - return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, float(4u)), 3.0f);)"; + return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, float(4u)), 3.0f);)"; case ValidTextureOverload::kSampleBias2dArrayOffsetF32: - return R"(textureOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)), ivec2(5, 6), 4.0f);)"; + return R"(textureOffset(Texture_Sampler, vec3(1.0f, 2.0f, float(3)), ivec2(5, 6), 4.0f);)"; case ValidTextureOverload::kSampleBias3dF32: - return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f);)"; + return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f);)"; case ValidTextureOverload::kSampleBias3dOffsetF32: - return R"(textureOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), ivec3(5, 6, 7), 4.0f);)"; + return R"(textureOffset(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), ivec3(5, 6, 7), 4.0f);)"; case ValidTextureOverload::kSampleBiasCubeF32: - return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f);)"; + return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f);)"; case ValidTextureOverload::kSampleBiasCubeArrayF32: - return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(3)), 4.0f);)"; + return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(3)), 4.0f);)"; case ValidTextureOverload::kSampleLevel2dF32: - return R"(textureLod(tint_symbol_sampler, vec2(1.0f, 2.0f), 3.0f);)"; + return R"(textureLod(Texture_Sampler, vec2(1.0f, 2.0f), 3.0f);)"; case ValidTextureOverload::kSampleLevel2dOffsetF32: - return R"(textureLodOffset(tint_symbol_sampler, vec2(1.0f, 2.0f), 3.0f, ivec2(4, 5));)"; + return R"(textureLodOffset(Texture_Sampler, vec2(1.0f, 2.0f), 3.0f, ivec2(4, 5));)"; case ValidTextureOverload::kSampleLevel2dArrayF32: - return R"(textureLod(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)), 4.0f);)"; + return R"(textureLod(Texture_Sampler, vec3(1.0f, 2.0f, float(3)), 4.0f);)"; case ValidTextureOverload::kSampleLevel2dArrayOffsetF32: - return R"(textureLodOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)), 4.0f, ivec2(5, 6));)"; + return R"(textureLodOffset(Texture_Sampler, vec3(1.0f, 2.0f, float(3)), 4.0f, ivec2(5, 6));)"; case ValidTextureOverload::kSampleLevel3dF32: - return R"(textureLod(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f);)"; + return R"(textureLod(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f);)"; case ValidTextureOverload::kSampleLevel3dOffsetF32: - return R"(textureLodOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f, ivec3(5, 6, 7));)"; + return R"(textureLodOffset(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f, ivec3(5, 6, 7));)"; case ValidTextureOverload::kSampleLevelCubeF32: - return R"(textureLod(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f);)"; + return R"(textureLod(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), 4.0f);)"; case ValidTextureOverload::kSampleLevelCubeArrayF32: - return R"(textureLod(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4)), 5.0f);)"; + return R"(textureLod(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4)), 5.0f);)"; case ValidTextureOverload::kSampleLevelDepth2dF32: - return R"(textureLod(tint_symbol_sampler, vec3(1.0f, 2.0f, 0.0f), float(3u));)"; + return R"(textureLod(Texture_Sampler, vec3(1.0f, 2.0f, 0.0f), float(3u));)"; case ValidTextureOverload::kSampleLevelDepth2dOffsetF32: - return R"(textureLodOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, 0.0f), float(3), ivec2(4, 5));)"; + return R"(textureLodOffset(Texture_Sampler, vec3(1.0f, 2.0f, 0.0f), float(3), ivec2(4, 5));)"; case ValidTextureOverload::kSampleLevelDepth2dArrayF32: - return R"(textureLod(tint_symbol_sampler, vec4(1.0f, 2.0f, float(3u), 0.0f), float(4u));)"; + return R"(textureLod(Texture_Sampler, vec4(1.0f, 2.0f, float(3u), 0.0f), float(4u));)"; case ValidTextureOverload::kSampleLevelDepth2dArrayOffsetF32: - return R"(textureLodOffset(tint_symbol_sampler, vec4(1.0f, 2.0f, float(3u), 0.0f), float(4u), ivec2(5, 6));)"; + return R"(textureLodOffset(Texture_Sampler, vec4(1.0f, 2.0f, float(3u), 0.0f), float(4u), ivec2(5, 6));)"; case ValidTextureOverload::kSampleLevelDepthCubeF32: - return R"(textureLod(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, 0.0f), float(4)))"; + return R"(textureLod(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, 0.0f), float(4)))"; case ValidTextureOverload::kSampleLevelDepthCubeArrayF32: - return R"(textureLod(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4)), float(5));)"; + return R"(textureLod(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4)), float(5));)"; case ValidTextureOverload::kSampleGrad2dF32: - return R"(textureGrad(tint_symbol_sampler, vec2(1.0f, 2.0f), vec2(3.0f, 4.0f), vec2(5.0f, 6.0f));)"; + return R"(textureGrad(Texture_Sampler, vec2(1.0f, 2.0f), vec2(3.0f, 4.0f), vec2(5.0f, 6.0f));)"; case ValidTextureOverload::kSampleGrad2dOffsetF32: - return R"(textureGradOffset(tint_symbol_sampler, vec2(1.0f, 2.0f), vec2(3.0f, 4.0f), vec2(5.0f, 6.0f), ivec2(7));)"; + return R"(textureGradOffset(Texture_Sampler, vec2(1.0f, 2.0f), vec2(3.0f, 4.0f), vec2(5.0f, 6.0f), ivec2(7));)"; case ValidTextureOverload::kSampleGrad2dArrayF32: - return R"(textureGrad(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3)), vec2(4.0f, 5.0f), vec2(6.0f, 7.0f));)"; + return R"(textureGrad(Texture_Sampler, vec3(1.0f, 2.0f, float(3)), vec2(4.0f, 5.0f), vec2(6.0f, 7.0f));)"; case ValidTextureOverload::kSampleGrad2dArrayOffsetF32: - return R"(textureGradOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, float(3u)), vec2(4.0f, 5.0f), vec2(6.0f, 7.0f), ivec2(6, 7));)"; + return R"(textureGradOffset(Texture_Sampler, vec3(1.0f, 2.0f, float(3u)), vec2(4.0f, 5.0f), vec2(6.0f, 7.0f), ivec2(6, 7));)"; case ValidTextureOverload::kSampleGrad3dF32: - return R"(textureGrad(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f));)"; + return R"(textureGrad(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f));)"; case ValidTextureOverload::kSampleGrad3dOffsetF32: - return R"(textureGradOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f), ivec3(0, 1, 2));)"; + return R"(textureGradOffset(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f), ivec3(0, 1, 2));)"; case ValidTextureOverload::kSampleGradCubeF32: - return R"(textureGrad(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f));)"; + return R"(textureGrad(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f));)"; case ValidTextureOverload::kSampleGradCubeArrayF32: - return R"(textureGrad(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), vec3(5.0f, 6.0f, 7.0f), vec3(8.0f, 9.0f, 10.0f));)"; + return R"(textureGrad(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), vec3(5.0f, 6.0f, 7.0f), vec3(8.0f, 9.0f, 10.0f));)"; case ValidTextureOverload::kSampleCompareDepth2dF32: - return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f));)"; + return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f));)"; case ValidTextureOverload::kSampleCompareDepth2dOffsetF32: - return R"(textureOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), ivec2(4, 5));)"; + return R"(textureOffset(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), ivec2(4, 5));)"; case ValidTextureOverload::kSampleCompareDepth2dArrayF32: - return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, float(4), 3.0f));)"; + return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, float(4), 3.0f));)"; case ValidTextureOverload::kSampleCompareDepth2dArrayOffsetF32: - return R"(textureOffset(tint_symbol_sampler, vec4(1.0f, 2.0f, float(4u), 3.0f), ivec2(5, 6));)"; + return R"(textureOffset(Texture_Sampler, vec4(1.0f, 2.0f, float(4u), 3.0f), ivec2(5, 6));)"; case ValidTextureOverload::kSampleCompareDepthCubeF32: - return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, 4.0f));)"; + return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, 4.0f));)"; case ValidTextureOverload::kSampleCompareDepthCubeArrayF32: - return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4)), 5.0f);)"; + return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4)), 5.0f);)"; case ValidTextureOverload::kSampleCompareLevelDepth2dF32: - return R"(texture(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f));)"; + return R"(texture(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f));)"; case ValidTextureOverload::kSampleCompareLevelDepth2dOffsetF32: - return R"(textureOffset(tint_symbol_sampler, vec3(1.0f, 2.0f, 3.0f), ivec2(4, 5));)"; + return R"(textureOffset(Texture_Sampler, vec3(1.0f, 2.0f, 3.0f), ivec2(4, 5));)"; case ValidTextureOverload::kSampleCompareLevelDepth2dArrayF32: - return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, float(3), 4.0f));)"; + return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, float(3), 4.0f));)"; case ValidTextureOverload::kSampleCompareLevelDepth2dArrayOffsetF32: - return R"(textureOffset(tint_symbol_sampler, vec4(1.0f, 2.0f, float(3), 4.0f), ivec2(5, 6));)"; + return R"(textureOffset(Texture_Sampler, vec4(1.0f, 2.0f, float(3), 4.0f), ivec2(5, 6));)"; case ValidTextureOverload::kSampleCompareLevelDepthCubeF32: - return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, 4.0f));)"; + return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, 4.0f));)"; case ValidTextureOverload::kSampleCompareLevelDepthCubeArrayF32: - return R"(texture(tint_symbol_sampler, vec4(1.0f, 2.0f, 3.0f, float(4)), 5.0f);)"; + return R"(texture(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4)), 5.0f);)"; case ValidTextureOverload::kLoad1dLevelF32: - return R"(texelFetch(tint_symbol_2, ivec2(uvec2(1u, 0u)), int(3u));)"; + return R"(texelFetch(Texture_1, ivec2(uvec2(1u, 0u)), int(3u));)"; case ValidTextureOverload::kLoad1dLevelU32: case ValidTextureOverload::kLoad1dLevelI32: - return R"(texelFetch(tint_symbol_2, ivec2(1, 0), 3);)"; + return R"(texelFetch(Texture_1, ivec2(1, 0), 3);)"; case ValidTextureOverload::kLoad2dLevelU32: - return R"(texelFetch(tint_symbol_2, ivec2(1, 2), 3);)"; + return R"(texelFetch(Texture_1, ivec2(1, 2), 3);)"; case ValidTextureOverload::kLoad2dLevelF32: case ValidTextureOverload::kLoad2dLevelI32: - return R"(texelFetch(tint_symbol_2, ivec2(uvec2(1u, 2u)), int(3u));)"; + return R"(texelFetch(Texture_1, ivec2(uvec2(1u, 2u)), int(3u));)"; case ValidTextureOverload::kLoad2dArrayLevelF32: case ValidTextureOverload::kLoad2dArrayLevelU32: case ValidTextureOverload::kLoad3dLevelF32: case ValidTextureOverload::kLoad3dLevelU32: - return R"(texelFetch(tint_symbol_2, ivec3(1, 2, 3), 4);)"; + return R"(texelFetch(Texture_1, ivec3(1, 2, 3), 4);)"; case ValidTextureOverload::kLoad2dArrayLevelI32: case ValidTextureOverload::kLoad3dLevelI32: - return R"(texelFetch(tint_symbol_2, ivec3(uvec3(1u, 2u, 3u)), int(4u));)"; + return R"(texelFetch(Texture_1, ivec3(uvec3(1u, 2u, 3u)), int(4u));)"; case ValidTextureOverload::kLoadMultisampled2dF32: case ValidTextureOverload::kLoadMultisampled2dU32: - return R"(texelFetch(tint_symbol_2, ivec2(1, 2), 3);)"; + return R"(texelFetch(Texture_1, ivec2(1, 2), 3);)"; case ValidTextureOverload::kLoadMultisampled2dI32: - return R"(texelFetch(tint_symbol_2, ivec2(uvec2(1u, 2u)), int(3u));)"; + return R"(texelFetch(Texture_1, ivec2(uvec2(1u, 2u)), int(3u));)"; case ValidTextureOverload::kLoadDepth2dLevelF32: - return R"(texelFetch(tint_symbol_2, ivec2(1, 2), 3);)"; + return R"(texelFetch(Texture_1, ivec2(1, 2), 3);)"; case ValidTextureOverload::kLoadDepth2dArrayLevelF32: - return R"(texelFetch(tint_symbol_2, ivec3(uvec3(1u, 2u, 3u)), int(4u));)"; + return R"(texelFetch(Texture_1, ivec3(uvec3(1u, 2u, 3u)), int(4u));)"; case ValidTextureOverload::kLoadDepthMultisampled2dF32: - return R"(texelFetch(tint_symbol_2, ivec2(uvec2(1u, 2u)), int(3u)).x;)"; + return R"(texelFetch(Texture_1, ivec2(uvec2(1u, 2u)), int(3u)).x;)"; case ValidTextureOverload::kStoreWO1dRgba32float: - return R"(imageStore(tint_symbol, ivec2(1, 0), vec4(2.0f, 3.0f, 4.0f, 5.0f));)"; + return R"(imageStore(Texture, ivec2(1, 0), vec4(2.0f, 3.0f, 4.0f, 5.0f));)"; case ValidTextureOverload::kStoreWO2dRgba32float: - return R"(imageStore(tint_symbol, ivec2(1, 2), vec4(3.0f, 4.0f, 5.0f, 6.0f));)"; + return R"(imageStore(Texture, ivec2(1, 2), vec4(3.0f, 4.0f, 5.0f, 6.0f));)"; case ValidTextureOverload::kStoreWO2dArrayRgba32float: - return R"(imageStore(tint_symbol, ivec3(uvec3(1u, 2u, 3u)), vec4(4.0f, 5.0f, 6.0f, 7.0f));)"; + return R"(imageStore(Texture, ivec3(uvec3(1u, 2u, 3u)), vec4(4.0f, 5.0f, 6.0f, 7.0f));)"; case ValidTextureOverload::kStoreWO3dRgba32float: - return R"(imageStore(tint_symbol, ivec3(uvec3(1u, 2u, 3u)), vec4(4.0f, 5.0f, 6.0f, 7.0f));)"; + return R"(imageStore(Texture, ivec3(uvec3(1u, 2u, 3u)), vec4(4.0f, 5.0f, 6.0f, 7.0f));)"; } return ""; } // NOLINT - Ignore the length of this function diff --git a/src/tint/writer/msl/generator_impl.cc b/src/tint/writer/msl/generator_impl.cc index b09c554ce9..71003218c6 100644 --- a/src/tint/writer/msl/generator_impl.cc +++ b/src/tint/writer/msl/generator_impl.cc @@ -2025,60 +2025,81 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { out << " " << param_name; } - if (type->Is()) { - out << " [[stage_in]]"; - } else if (type->is_handle()) { - uint32_t binding = get_binding_index(param); - if (binding == kInvalidBindingIndex) { - return false; - } - if (param->type->Is()) { - out << " [[sampler(" << binding << ")]]"; - } else if (TINT_LIKELY(param->type->Is())) { - out << " [[texture(" << binding << ")]]"; - } else { - TINT_ICE(Writer, diagnostics_) << "invalid handle type entry point parameter"; - return false; - } - } else if (auto* ptr = param->type->As()) { - auto sc = ptr->address_space; - if (sc == type::AddressSpace::kWorkgroup) { - auto& allocations = workgroup_allocations_[func_name]; - out << " [[threadgroup(" << allocations.size() << ")]]"; - allocations.push_back(program_->Sem().Get(ptr->type)->Size()); - } else if (TINT_LIKELY(sc == type::AddressSpace::kStorage || - sc == type::AddressSpace::kUniform)) { + bool ok = Switch( + type, // + [&](const type::Struct*) { + out << " [[stage_in]]"; + return true; + }, + [&](const type::Texture*) { uint32_t binding = get_binding_index(param); if (binding == kInvalidBindingIndex) { return false; } - out << " [[buffer(" << binding << ")]]"; - } else { + out << " [[texture(" << binding << ")]]"; + return true; + }, + [&](const type::Sampler*) { + uint32_t binding = get_binding_index(param); + if (binding == kInvalidBindingIndex) { + return false; + } + out << " [[sampler(" << binding << ")]]"; + return true; + }, + [&](const type::Pointer* ptr) { + switch (ptr->AddressSpace()) { + case type::AddressSpace::kWorkgroup: { + auto& allocations = workgroup_allocations_[func_name]; + out << " [[threadgroup(" << allocations.size() << ")]]"; + allocations.push_back(ptr->StoreType()->Size()); + return true; + } + + case type::AddressSpace::kStorage: + case type::AddressSpace::kUniform: { + uint32_t binding = get_binding_index(param); + if (binding == kInvalidBindingIndex) { + return false; + } + out << " [[buffer(" << binding << ")]]"; + return true; + } + + default: + break; + } TINT_ICE(Writer, diagnostics_) << "invalid pointer address space for entry point parameter"; return false; - } - } else { - auto& attrs = param->attributes; - bool builtin_found = false; - for (auto* attr : attrs) { - auto* builtin = attr->As(); - if (!builtin) { - continue; + }, + [&](Default) { + auto& attrs = param->attributes; + bool builtin_found = false; + for (auto* attr : attrs) { + auto* builtin = attr->As(); + if (!builtin) { + continue; + } + + builtin_found = true; + + auto name = builtin_to_attribute(builtin->builtin); + if (name.empty()) { + diagnostics_.add_error(diag::System::Writer, "unknown builtin"); + return false; + } + out << " [[" << name << "]]"; } - - builtin_found = true; - - auto name = builtin_to_attribute(builtin->builtin); - if (name.empty()) { - diagnostics_.add_error(diag::System::Writer, "unknown builtin"); + if (TINT_UNLIKELY(!builtin_found)) { + TINT_ICE(Writer, diagnostics_) << "Unsupported entry point parameter"; return false; } - out << " [[" << name << "]]"; - } - if (TINT_UNLIKELY(!builtin_found)) { - TINT_ICE(Writer, diagnostics_) << "Unsupported entry point parameter"; - } + return true; + }); + + if (!ok) { + return false; } } out << ") {"; diff --git a/src/tint/writer/msl/generator_impl_builtin_texture_test.cc b/src/tint/writer/msl/generator_impl_builtin_texture_test.cc index 541441667e..028f85109d 100644 --- a/src/tint/writer/msl/generator_impl_builtin_texture_test.cc +++ b/src/tint/writer/msl/generator_impl_builtin_texture_test.cc @@ -24,7 +24,7 @@ std::string expected_texture_overload(ast::builtin::test::ValidTextureOverload o switch (overload) { case ValidTextureOverload::kDimensions1d: case ValidTextureOverload::kDimensionsStorageWO1d: - return R"(texture.get_width(0))"; + return R"(Texture.get_width(0))"; case ValidTextureOverload::kDimensions2d: case ValidTextureOverload::kDimensions2dArray: case ValidTextureOverload::kDimensionsCube: @@ -37,10 +37,10 @@ std::string expected_texture_overload(ast::builtin::test::ValidTextureOverload o case ValidTextureOverload::kDimensionsDepthMultisampled2d: case ValidTextureOverload::kDimensionsStorageWO2d: case ValidTextureOverload::kDimensionsStorageWO2dArray: - return R"(uint2(texture.get_width(), texture.get_height()))"; + return R"(uint2(Texture.get_width(), Texture.get_height()))"; case ValidTextureOverload::kDimensions3d: case ValidTextureOverload::kDimensionsStorageWO3d: - return R"(uint3(texture.get_width(), texture.get_height(), texture.get_depth()))"; + return R"(uint3(Texture.get_width(), Texture.get_height(), Texture.get_depth()))"; case ValidTextureOverload::kDimensions2dLevel: case ValidTextureOverload::kDimensionsCubeLevel: case ValidTextureOverload::kDimensionsCubeArrayLevel: @@ -49,51 +49,51 @@ std::string expected_texture_overload(ast::builtin::test::ValidTextureOverload o case ValidTextureOverload::kDimensionsDepth2dArrayLevel: case ValidTextureOverload::kDimensionsDepthCubeLevel: case ValidTextureOverload::kDimensionsDepthCubeArrayLevel: - return R"(uint2(texture.get_width(1), texture.get_height(1)))"; + return R"(uint2(Texture.get_width(1), Texture.get_height(1)))"; case ValidTextureOverload::kDimensions3dLevel: - return R"(uint3(texture.get_width(1), texture.get_height(1), texture.get_depth(1)))"; + return R"(uint3(Texture.get_width(1), Texture.get_height(1), Texture.get_depth(1)))"; case ValidTextureOverload::kGather2dF32: - return R"(texture.gather(sampler, float2(1.0f, 2.0f), int2(0), component::x))"; + return R"(Texture.gather(Sampler, float2(1.0f, 2.0f), int2(0), component::x))"; case ValidTextureOverload::kGather2dOffsetF32: - return R"(texture.gather(sampler, float2(1.0f, 2.0f), int2(3, 4), component::x))"; + return R"(Texture.gather(Sampler, float2(1.0f, 2.0f), int2(3, 4), component::x))"; case ValidTextureOverload::kGather2dArrayF32: - return R"(texture.gather(sampler, float2(1.0f, 2.0f), 3, int2(0), component::x))"; + return R"(Texture.gather(Sampler, float2(1.0f, 2.0f), 3, int2(0), component::x))"; case ValidTextureOverload::kGather2dArrayOffsetF32: - return R"(texture.gather(sampler, float2(1.0f, 2.0f), 3u, int2(4, 5), component::x))"; + return R"(Texture.gather(Sampler, float2(1.0f, 2.0f), 3u, int2(4, 5), component::x))"; case ValidTextureOverload::kGatherCubeF32: - return R"(texture.gather(sampler, float3(1.0f, 2.0f, 3.0f), component::x))"; + return R"(Texture.gather(Sampler, float3(1.0f, 2.0f, 3.0f), component::x))"; case ValidTextureOverload::kGatherCubeArrayF32: - return R"(texture.gather(sampler, float3(1.0f, 2.0f, 3.0f), 4u, component::x))"; + return R"(Texture.gather(Sampler, float3(1.0f, 2.0f, 3.0f), 4u, component::x))"; case ValidTextureOverload::kGatherDepth2dF32: - return R"(texture.gather(sampler, float2(1.0f, 2.0f)))"; + return R"(Texture.gather(Sampler, float2(1.0f, 2.0f)))"; case ValidTextureOverload::kGatherDepth2dOffsetF32: - return R"(texture.gather(sampler, float2(1.0f, 2.0f), int2(3, 4)))"; + return R"(Texture.gather(Sampler, float2(1.0f, 2.0f), int2(3, 4)))"; case ValidTextureOverload::kGatherDepth2dArrayF32: - return R"(texture.gather(sampler, float2(1.0f, 2.0f), 3u))"; + return R"(Texture.gather(Sampler, float2(1.0f, 2.0f), 3u))"; case ValidTextureOverload::kGatherDepth2dArrayOffsetF32: - return R"(texture.gather(sampler, float2(1.0f, 2.0f), 3, int2(4, 5)))"; + return R"(Texture.gather(Sampler, float2(1.0f, 2.0f), 3, int2(4, 5)))"; case ValidTextureOverload::kGatherDepthCubeF32: - return R"(texture.gather(sampler, float3(1.0f, 2.0f, 3.0f)))"; + return R"(Texture.gather(Sampler, float3(1.0f, 2.0f, 3.0f)))"; case ValidTextureOverload::kGatherDepthCubeArrayF32: - return R"(texture.gather(sampler, float3(1.0f, 2.0f, 3.0f), 4u))"; + return R"(Texture.gather(Sampler, float3(1.0f, 2.0f, 3.0f), 4u))"; case ValidTextureOverload::kGatherCompareDepth2dF32: - return R"(texture.gather_compare(sampler, float2(1.0f, 2.0f), 3.0f))"; + return R"(Texture.gather_compare(Sampler, float2(1.0f, 2.0f), 3.0f))"; case ValidTextureOverload::kGatherCompareDepth2dOffsetF32: - return R"(texture.gather_compare(sampler, float2(1.0f, 2.0f), 3.0f, int2(4, 5)))"; + return R"(Texture.gather_compare(Sampler, float2(1.0f, 2.0f), 3.0f, int2(4, 5)))"; case ValidTextureOverload::kGatherCompareDepth2dArrayF32: - return R"(texture.gather_compare(sampler, float2(1.0f, 2.0f), 3, 4.0f))"; + return R"(Texture.gather_compare(Sampler, float2(1.0f, 2.0f), 3, 4.0f))"; case ValidTextureOverload::kGatherCompareDepth2dArrayOffsetF32: - return R"(texture.gather_compare(sampler, float2(1.0f, 2.0f), 3, 4.0f, int2(5, 6)))"; + return R"(Texture.gather_compare(Sampler, float2(1.0f, 2.0f), 3, 4.0f, int2(5, 6)))"; case ValidTextureOverload::kGatherCompareDepthCubeF32: - return R"(texture.gather_compare(sampler, float3(1.0f, 2.0f, 3.0f), 4.0f))"; + return R"(Texture.gather_compare(Sampler, float3(1.0f, 2.0f, 3.0f), 4.0f))"; case ValidTextureOverload::kGatherCompareDepthCubeArrayF32: - return R"(texture.gather_compare(sampler, float3(1.0f, 2.0f, 3.0f), 4u, 5.0f))"; + return R"(Texture.gather_compare(Sampler, float3(1.0f, 2.0f, 3.0f), 4u, 5.0f))"; case ValidTextureOverload::kNumLayers2dArray: case ValidTextureOverload::kNumLayersCubeArray: case ValidTextureOverload::kNumLayersDepth2dArray: case ValidTextureOverload::kNumLayersDepthCubeArray: case ValidTextureOverload::kNumLayersStorageWO2dArray: - return R"(texture.get_array_size())"; + return R"(Texture.get_array_size())"; case ValidTextureOverload::kNumLevels2d: case ValidTextureOverload::kNumLevels2dArray: case ValidTextureOverload::kNumLevels3d: @@ -103,166 +103,166 @@ std::string expected_texture_overload(ast::builtin::test::ValidTextureOverload o case ValidTextureOverload::kNumLevelsDepth2dArray: case ValidTextureOverload::kNumLevelsDepthCube: case ValidTextureOverload::kNumLevelsDepthCubeArray: - return R"(texture.get_num_mip_levels())"; + return R"(Texture.get_num_mip_levels())"; case ValidTextureOverload::kNumSamplesDepthMultisampled2d: case ValidTextureOverload::kNumSamplesMultisampled2d: - return R"(texture.get_num_samples())"; + return R"(Texture.get_num_samples())"; case ValidTextureOverload::kSample1dF32: - return R"(texture.sample(sampler, 1.0f))"; + return R"(Texture.sample(Sampler, 1.0f))"; case ValidTextureOverload::kSample2dF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f)))"; case ValidTextureOverload::kSample2dOffsetF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), int2(3, 4)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), int2(3, 4)))"; case ValidTextureOverload::kSample2dArrayF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3))"; case ValidTextureOverload::kSample2dArrayOffsetF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3u, int2(4, 5)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3u, int2(4, 5)))"; case ValidTextureOverload::kSample3dF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f)))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f)))"; case ValidTextureOverload::kSample3dOffsetF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), int3(4, 5, 6)))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), int3(4, 5, 6)))"; case ValidTextureOverload::kSampleCubeF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f)))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f)))"; case ValidTextureOverload::kSampleCubeArrayF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), 4))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), 4))"; case ValidTextureOverload::kSampleDepth2dF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f)))"; case ValidTextureOverload::kSampleDepth2dOffsetF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), int2(3, 4)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), int2(3, 4)))"; case ValidTextureOverload::kSampleDepth2dArrayF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3))"; case ValidTextureOverload::kSampleDepth2dArrayOffsetF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3, int2(4, 5)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3, int2(4, 5)))"; case ValidTextureOverload::kSampleDepthCubeF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f)))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f)))"; case ValidTextureOverload::kSampleDepthCubeArrayF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), 4u))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), 4u))"; case ValidTextureOverload::kSampleBias2dF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), bias(3.0f)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), bias(3.0f)))"; case ValidTextureOverload::kSampleBias2dOffsetF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), bias(3.0f), int2(4, 5)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), bias(3.0f), int2(4, 5)))"; case ValidTextureOverload::kSampleBias2dArrayF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), 4u, bias(3.0f)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 4u, bias(3.0f)))"; case ValidTextureOverload::kSampleBias2dArrayOffsetF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3, bias(4.0f), int2(5, 6)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3, bias(4.0f), int2(5, 6)))"; case ValidTextureOverload::kSampleBias3dF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), bias(4.0f)))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), bias(4.0f)))"; case ValidTextureOverload::kSampleBias3dOffsetF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), bias(4.0f), int3(5, 6, 7)))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), bias(4.0f), int3(5, 6, 7)))"; case ValidTextureOverload::kSampleBiasCubeF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), bias(4.0f)))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), bias(4.0f)))"; case ValidTextureOverload::kSampleBiasCubeArrayF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), 3, bias(4.0f)))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), 3, bias(4.0f)))"; case ValidTextureOverload::kSampleLevel2dF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), level(3.0f)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), level(3.0f)))"; case ValidTextureOverload::kSampleLevel2dOffsetF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), level(3.0f), int2(4, 5)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), level(3.0f), int2(4, 5)))"; case ValidTextureOverload::kSampleLevel2dArrayF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3, level(4.0f)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3, level(4.0f)))"; case ValidTextureOverload::kSampleLevel2dArrayOffsetF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3, level(4.0f), int2(5, 6)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3, level(4.0f), int2(5, 6)))"; case ValidTextureOverload::kSampleLevel3dF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), level(4.0f)))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), level(4.0f)))"; case ValidTextureOverload::kSampleLevel3dOffsetF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), level(4.0f), int3(5, 6, 7)))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), level(4.0f), int3(5, 6, 7)))"; case ValidTextureOverload::kSampleLevelCubeF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), level(4.0f)))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), level(4.0f)))"; case ValidTextureOverload::kSampleLevelCubeArrayF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), 4, level(5.0f)))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), 4, level(5.0f)))"; case ValidTextureOverload::kSampleLevelDepth2dF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), level(3u)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), level(3u)))"; case ValidTextureOverload::kSampleLevelDepth2dOffsetF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), level(3), int2(4, 5)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), level(3), int2(4, 5)))"; case ValidTextureOverload::kSampleLevelDepth2dArrayF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3u, level(4u)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3u, level(4u)))"; case ValidTextureOverload::kSampleLevelDepth2dArrayOffsetF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3u, level(4u), int2(5, 6)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3u, level(4u), int2(5, 6)))"; case ValidTextureOverload::kSampleLevelDepthCubeF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), level(4)))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), level(4)))"; case ValidTextureOverload::kSampleLevelDepthCubeArrayF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), 4, level(5)))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), 4, level(5)))"; case ValidTextureOverload::kSampleGrad2dF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), gradient2d(float2(3.0f, 4.0f), float2(5.0f, 6.0f))))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), gradient2d(float2(3.0f, 4.0f), float2(5.0f, 6.0f))))"; case ValidTextureOverload::kSampleGrad2dOffsetF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), gradient2d(float2(3.0f, 4.0f), float2(5.0f, 6.0f)), int2(7)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), gradient2d(float2(3.0f, 4.0f), float2(5.0f, 6.0f)), int2(7)))"; case ValidTextureOverload::kSampleGrad2dArrayF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3, gradient2d(float2(4.0f, 5.0f), float2(6.0f, 7.0f))))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3, gradient2d(float2(4.0f, 5.0f), float2(6.0f, 7.0f))))"; case ValidTextureOverload::kSampleGrad2dArrayOffsetF32: - return R"(texture.sample(sampler, float2(1.0f, 2.0f), 3u, gradient2d(float2(4.0f, 5.0f), float2(6.0f, 7.0f)), int2(6, 7)))"; + return R"(Texture.sample(Sampler, float2(1.0f, 2.0f), 3u, gradient2d(float2(4.0f, 5.0f), float2(6.0f, 7.0f)), int2(6, 7)))"; case ValidTextureOverload::kSampleGrad3dF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), gradient3d(float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f))))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), gradient3d(float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f))))"; case ValidTextureOverload::kSampleGrad3dOffsetF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), gradient3d(float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f)), int3(0, 1, 2)))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), gradient3d(float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f)), int3(0, 1, 2)))"; case ValidTextureOverload::kSampleGradCubeF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), gradientcube(float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f))))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), gradientcube(float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f))))"; case ValidTextureOverload::kSampleGradCubeArrayF32: - return R"(texture.sample(sampler, float3(1.0f, 2.0f, 3.0f), 4u, gradientcube(float3(5.0f, 6.0f, 7.0f), float3(8.0f, 9.0f, 10.0f))))"; + return R"(Texture.sample(Sampler, float3(1.0f, 2.0f, 3.0f), 4u, gradientcube(float3(5.0f, 6.0f, 7.0f), float3(8.0f, 9.0f, 10.0f))))"; case ValidTextureOverload::kSampleCompareDepth2dF32: - return R"(texture.sample_compare(sampler, float2(1.0f, 2.0f), 3.0f))"; + return R"(Texture.sample_compare(Sampler, float2(1.0f, 2.0f), 3.0f))"; case ValidTextureOverload::kSampleCompareDepth2dOffsetF32: - return R"(texture.sample_compare(sampler, float2(1.0f, 2.0f), 3.0f, int2(4, 5)))"; + return R"(Texture.sample_compare(Sampler, float2(1.0f, 2.0f), 3.0f, int2(4, 5)))"; case ValidTextureOverload::kSampleCompareDepth2dArrayF32: - return R"(texture.sample_compare(sampler, float2(1.0f, 2.0f), 4, 3.0f))"; + return R"(Texture.sample_compare(Sampler, float2(1.0f, 2.0f), 4, 3.0f))"; case ValidTextureOverload::kSampleCompareDepth2dArrayOffsetF32: - return R"(texture.sample_compare(sampler, float2(1.0f, 2.0f), 4u, 3.0f, int2(5, 6)))"; + return R"(Texture.sample_compare(Sampler, float2(1.0f, 2.0f), 4u, 3.0f, int2(5, 6)))"; case ValidTextureOverload::kSampleCompareDepthCubeF32: - return R"(texture.sample_compare(sampler, float3(1.0f, 2.0f, 3.0f), 4.0f))"; + return R"(Texture.sample_compare(Sampler, float3(1.0f, 2.0f, 3.0f), 4.0f))"; case ValidTextureOverload::kSampleCompareDepthCubeArrayF32: - return R"(texture.sample_compare(sampler, float3(1.0f, 2.0f, 3.0f), 4, 5.0f))"; + return R"(Texture.sample_compare(Sampler, float3(1.0f, 2.0f, 3.0f), 4, 5.0f))"; case ValidTextureOverload::kSampleCompareLevelDepth2dF32: - return R"(texture.sample_compare(sampler, float2(1.0f, 2.0f), 3.0f, level(0)))"; + return R"(Texture.sample_compare(Sampler, float2(1.0f, 2.0f), 3.0f, level(0)))"; case ValidTextureOverload::kSampleCompareLevelDepth2dOffsetF32: - return R"(texture.sample_compare(sampler, float2(1.0f, 2.0f), 3.0f, level(0), int2(4, 5)))"; + return R"(Texture.sample_compare(Sampler, float2(1.0f, 2.0f), 3.0f, level(0), int2(4, 5)))"; case ValidTextureOverload::kSampleCompareLevelDepth2dArrayF32: - return R"(texture.sample_compare(sampler, float2(1.0f, 2.0f), 3, 4.0f, level(0)))"; + return R"(Texture.sample_compare(Sampler, float2(1.0f, 2.0f), 3, 4.0f, level(0)))"; case ValidTextureOverload::kSampleCompareLevelDepth2dArrayOffsetF32: - return R"(texture.sample_compare(sampler, float2(1.0f, 2.0f), 3, 4.0f, level(0), int2(5, 6)))"; + return R"(Texture.sample_compare(Sampler, float2(1.0f, 2.0f), 3, 4.0f, level(0), int2(5, 6)))"; case ValidTextureOverload::kSampleCompareLevelDepthCubeF32: - return R"(texture.sample_compare(sampler, float3(1.0f, 2.0f, 3.0f), 4.0f, level(0)))"; + return R"(Texture.sample_compare(Sampler, float3(1.0f, 2.0f, 3.0f), 4.0f, level(0)))"; case ValidTextureOverload::kSampleCompareLevelDepthCubeArrayF32: - return R"(texture.sample_compare(sampler, float3(1.0f, 2.0f, 3.0f), 4, 5.0f, level(0)))"; + return R"(Texture.sample_compare(Sampler, float3(1.0f, 2.0f, 3.0f), 4, 5.0f, level(0)))"; case ValidTextureOverload::kLoad1dLevelF32: - return R"(texture.read(uint(1u), 0))"; + return R"(Texture.read(uint(1u), 0))"; case ValidTextureOverload::kLoad1dLevelU32: - return R"(texture.read(uint(1), 0))"; + return R"(Texture.read(uint(1), 0))"; case ValidTextureOverload::kLoad1dLevelI32: - return R"(texture.read(uint(1), 0))"; + return R"(Texture.read(uint(1), 0))"; case ValidTextureOverload::kLoad2dLevelF32: - return R"(texture.read(uint2(uint2(1u, 2u)), 3u))"; + return R"(Texture.read(uint2(uint2(1u, 2u)), 3u))"; case ValidTextureOverload::kLoad2dLevelU32: - return R"(texture.read(uint2(int2(1, 2)), 3))"; + return R"(Texture.read(uint2(int2(1, 2)), 3))"; case ValidTextureOverload::kLoad2dArrayLevelF32: - return R"(texture.read(uint2(int2(1, 2)), 3, 4))"; + return R"(Texture.read(uint2(int2(1, 2)), 3, 4))"; case ValidTextureOverload::kLoad2dArrayLevelU32: - return R"(texture.read(uint2(int2(1, 2)), 3, 4))"; + return R"(Texture.read(uint2(int2(1, 2)), 3, 4))"; case ValidTextureOverload::kLoad2dArrayLevelI32: - return R"(texture.read(uint2(uint2(1u, 2u)), 3u, 4u))"; + return R"(Texture.read(uint2(uint2(1u, 2u)), 3u, 4u))"; case ValidTextureOverload::kLoad3dLevelF32: - return R"(texture.read(uint3(int3(1, 2, 3)), 4))"; + return R"(Texture.read(uint3(int3(1, 2, 3)), 4))"; case ValidTextureOverload::kLoad3dLevelU32: - return R"(texture.read(uint3(int3(1, 2, 3)), 4))"; + return R"(Texture.read(uint3(int3(1, 2, 3)), 4))"; case ValidTextureOverload::kLoad3dLevelI32: - return R"(texture.read(uint3(uint3(1u, 2u, 3u)), 4u))"; + return R"(Texture.read(uint3(uint3(1u, 2u, 3u)), 4u))"; case ValidTextureOverload::kLoadMultisampled2dF32: case ValidTextureOverload::kLoadMultisampled2dU32: - return R"(texture.read(uint2(int2(1, 2)), 3))"; + return R"(Texture.read(uint2(int2(1, 2)), 3))"; case ValidTextureOverload::kLoad2dLevelI32: case ValidTextureOverload::kLoadMultisampled2dI32: - return R"(texture.read(uint2(uint2(1u, 2u)), 3u))"; + return R"(Texture.read(uint2(uint2(1u, 2u)), 3u))"; case ValidTextureOverload::kLoadDepth2dLevelF32: - return R"(texture.read(uint2(int2(1, 2)), 3))"; + return R"(Texture.read(uint2(int2(1, 2)), 3))"; case ValidTextureOverload::kLoadDepth2dArrayLevelF32: - return R"(texture.read(uint2(uint2(1u, 2u)), 3u, 4u))"; + return R"(Texture.read(uint2(uint2(1u, 2u)), 3u, 4u))"; case ValidTextureOverload::kLoadDepthMultisampled2dF32: - return R"(texture.read(uint2(uint2(1u, 2u)), 3u))"; + return R"(Texture.read(uint2(uint2(1u, 2u)), 3u))"; case ValidTextureOverload::kStoreWO1dRgba32float: - return R"(texture.write(float4(2.0f, 3.0f, 4.0f, 5.0f), uint(1)))"; + return R"(Texture.write(float4(2.0f, 3.0f, 4.0f, 5.0f), uint(1)))"; case ValidTextureOverload::kStoreWO2dRgba32float: - return R"(texture.write(float4(3.0f, 4.0f, 5.0f, 6.0f), uint2(int2(1, 2))))"; + return R"(Texture.write(float4(3.0f, 4.0f, 5.0f, 6.0f), uint2(int2(1, 2))))"; case ValidTextureOverload::kStoreWO2dArrayRgba32float: - return R"(texture.write(float4(4.0f, 5.0f, 6.0f, 7.0f), uint2(uint2(1u, 2u)), 3u))"; + return R"(Texture.write(float4(4.0f, 5.0f, 6.0f, 7.0f), uint2(uint2(1u, 2u)), 3u))"; case ValidTextureOverload::kStoreWO3dRgba32float: - return R"(texture.write(float4(4.0f, 5.0f, 6.0f, 7.0f), uint3(uint3(1u, 2u, 3u))))"; + return R"(Texture.write(float4(4.0f, 5.0f, 6.0f, 7.0f), uint3(uint3(1u, 2u, 3u))))"; } return ""; } // NOLINT - Ignore the length of this function diff --git a/src/tint/writer/wgsl/generator_impl.cc b/src/tint/writer/wgsl/generator_impl.cc index 5c76c8655b..7e497eb803 100644 --- a/src/tint/writer/wgsl/generator_impl.cc +++ b/src/tint/writer/wgsl/generator_impl.cc @@ -452,14 +452,6 @@ bool GeneratorImpl::EmitType(std::ostream& out, const ast::Type* ty) { out << ">"; return true; }, - [&](const ast::Sampler* sampler) { - out << "sampler"; - - if (sampler->IsComparison()) { - out << "_comparison"; - } - return true; - }, [&](const ast::ExternalTexture*) { out << "texture_external"; return true;