Remove depreated APIs and WGSL

WGSL:
* Remove vertex_idx and instance_idx.
  These are now vertex_index and instance_index.
  It seems this was removed once before, then reverted due to CTS
  failures, but the original change never landed again.
* Remove the [[set(n)]] decoration. This has been [[group(n)]] for
  months now.

API:
* Remove deprecated enums from transform::VertexFormat.
* Remove transform::Renamer constructor that takes a Config. This should
  be passed by DataMap.
* Remove ast::AccessControl alias to ast::Access.

Change-Id: I988c96c4269b02a5d77163409f261fd5923188e0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56541
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton 2021-07-06 10:20:19 +00:00 committed by Tint LUCI CQ
parent 692fc20797
commit 9545fb76b6
25 changed files with 84 additions and 134 deletions

View File

@ -738,20 +738,18 @@ int main(int argc, const char** argv) {
#endif // TINT_BUILD_SPV_WRITER #endif // TINT_BUILD_SPV_WRITER
#if TINT_BUILD_MSL_WRITER #if TINT_BUILD_MSL_WRITER
case Format::kMsl: { case Format::kMsl: {
tint::transform::Renamer::Config renamer_config{ transform_inputs.Add<tint::transform::Renamer::Config>(
tint::transform::Renamer::Target::kMslKeywords}; tint::transform::Renamer::Target::kMslKeywords);
transform_manager.append( transform_manager.Add<tint::transform::Renamer>();
std::make_unique<tint::transform::Renamer>(renamer_config));
transform_manager.Add<tint::transform::Msl>(); transform_manager.Add<tint::transform::Msl>();
break; break;
} }
#endif // TINT_BUILD_MSL_WRITER #endif // TINT_BUILD_MSL_WRITER
#if TINT_BUILD_HLSL_WRITER #if TINT_BUILD_HLSL_WRITER
case Format::kHlsl: { case Format::kHlsl: {
tint::transform::Renamer::Config renamer_config{ transform_inputs.Add<tint::transform::Renamer::Config>(
tint::transform::Renamer::Target::kHlslKeywords}; tint::transform::Renamer::Target::kHlslKeywords);
transform_manager.append( transform_manager.Add<tint::transform::Renamer>();
std::make_unique<tint::transform::Renamer>(renamer_config));
transform_manager.Add<tint::transform::Hlsl>(); transform_manager.Add<tint::transform::Hlsl>();
break; break;
} }

View File

@ -38,9 +38,6 @@ enum Access {
/// @return the std::ostream so calls can be chained /// @return the std::ostream so calls can be chained
std::ostream& operator<<(std::ostream& out, Access access); std::ostream& operator<<(std::ostream& out, Access access);
/// [DEPRECATED]: Old name in use by Dawn.
using AccessControl = Access;
} // namespace ast } // namespace ast
} // namespace tint } // namespace tint

View File

@ -73,10 +73,10 @@ ast::Builtin ident_to_builtin(const std::string& str) {
if (str == "position") { if (str == "position") {
return ast::Builtin::kPosition; return ast::Builtin::kPosition;
} }
if (str == "vertex_idx" || str == "vertex_index") { if (str == "vertex_index") {
return ast::Builtin::kVertexIndex; return ast::Builtin::kVertexIndex;
} }
if (str == "instance_idx" || str == "instance_index") { if (str == "instance_index") {
return ast::Builtin::kInstanceIndex; return ast::Builtin::kInstanceIndex;
} }
if (str == "front_facing") { if (str == "front_facing") {
@ -115,7 +115,6 @@ const char kLocationDecoration[] = "location";
const char kOverrideDecoration[] = "override"; const char kOverrideDecoration[] = "override";
const char kSizeDecoration[] = "size"; const char kSizeDecoration[] = "size";
const char kAlignDecoration[] = "align"; const char kAlignDecoration[] = "align";
const char kSetDecoration[] = "set";
const char kStageDecoration[] = "stage"; const char kStageDecoration[] = "stage";
const char kStrideDecoration[] = "stride"; const char kStrideDecoration[] = "stride";
const char kWorkgroupSizeDecoration[] = "workgroup_size"; const char kWorkgroupSizeDecoration[] = "workgroup_size";
@ -130,7 +129,7 @@ bool is_decoration(Token t) {
s == kBlockDecoration || s == kBuiltinDecoration || s == kBlockDecoration || s == kBuiltinDecoration ||
s == kGroupDecoration || s == kInterpolateDecoration || s == kGroupDecoration || s == kInterpolateDecoration ||
s == kLocationDecoration || s == kOverrideDecoration || s == kLocationDecoration || s == kOverrideDecoration ||
s == kSetDecoration || s == kSizeDecoration || s == kStageDecoration || s == kSizeDecoration || s == kStageDecoration ||
s == kStrideDecoration || s == kWorkgroupSizeDecoration; s == kStrideDecoration || s == kWorkgroupSizeDecoration;
} }
@ -3007,7 +3006,7 @@ Maybe<ast::Decoration*> ParserImpl::decoration() {
}); });
} }
if (s == kSetDecoration || s == kGroupDecoration) { if (s == kGroupDecoration) {
const char* use = "group decoration"; const char* use = "group decoration";
return expect_paren_block(use, [&]() -> Result { return expect_paren_block(use, [&]() -> Result {
auto val = expect_positive_sint(use); auto val = expect_positive_sint(use);

View File

@ -108,9 +108,7 @@ INSTANTIATE_TEST_SUITE_P(
BuiltinTest, BuiltinTest,
testing::Values( testing::Values(
BuiltinData{"position", ast::Builtin::kPosition}, BuiltinData{"position", ast::Builtin::kPosition},
BuiltinData{"vertex_idx", ast::Builtin::kVertexIndex},
BuiltinData{"vertex_index", ast::Builtin::kVertexIndex}, BuiltinData{"vertex_index", ast::Builtin::kVertexIndex},
BuiltinData{"instance_idx", ast::Builtin::kInstanceIndex},
BuiltinData{"instance_index", ast::Builtin::kInstanceIndex}, BuiltinData{"instance_index", ast::Builtin::kInstanceIndex},
BuiltinData{"front_facing", ast::Builtin::kFrontFacing}, BuiltinData{"front_facing", ast::Builtin::kFrontFacing},
BuiltinData{"frag_depth", ast::Builtin::kFragDepth}, BuiltinData{"frag_depth", ast::Builtin::kFragDepth},
@ -355,22 +353,6 @@ TEST_F(ParserImplTest, Decoration_Binding_MissingInvalid) {
"1:9: expected signed integer literal for binding decoration"); "1:9: expected signed integer literal for binding decoration");
} }
// DEPRECATED
TEST_F(ParserImplTest, Decoration_set) {
auto p = parser("set(4)");
auto deco = p->decoration();
EXPECT_TRUE(deco.matched);
EXPECT_FALSE(deco.errored);
ASSERT_NE(deco.value, nullptr);
auto* var_deco = deco.value->As<ast::Decoration>();
ASSERT_FALSE(p->has_error());
ASSERT_NE(var_deco, nullptr);
ASSERT_TRUE(var_deco->Is<ast::GroupDecoration>());
auto* group = var_deco->As<ast::GroupDecoration>();
EXPECT_EQ(group->value(), 4u);
}
TEST_F(ParserImplTest, Decoration_group) { TEST_F(ParserImplTest, Decoration_group) {
auto p = parser("group(4)"); auto p = parser("group(4)");
auto deco = p->decoration(); auto deco = p->decoration();

View File

@ -595,7 +595,7 @@ Resolver::VariableInfo* Resolver::Variable(ast::Variable* var,
return info; return info;
} }
ast::AccessControl Resolver::DefaultAccessForStorageClass( ast::Access Resolver::DefaultAccessForStorageClass(
ast::StorageClass storage_class) { ast::StorageClass storage_class) {
// https://gpuweb.github.io/gpuweb/wgsl/#storage-class // https://gpuweb.github.io/gpuweb/wgsl/#storage-class
switch (storage_class) { switch (storage_class) {

View File

@ -363,8 +363,7 @@ class Resolver {
/// @param storage_class the storage class /// @param storage_class the storage class
/// @returns the default access control for the given storage class /// @returns the default access control for the given storage class
ast::AccessControl DefaultAccessForStorageClass( ast::Access DefaultAccessForStorageClass(ast::StorageClass storage_class);
ast::StorageClass storage_class);
/// @returns the resolved type of the ast::Expression `expr` /// @returns the resolved type of the ast::Expression `expr`
/// @param expr the expression /// @param expr the expression

View File

@ -153,7 +153,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Aliases) {
TEST_F(ResolverStorageClassValidationTest, UniformBuffer_Struct_Runtime) { TEST_F(ResolverStorageClassValidationTest, UniformBuffer_Struct_Runtime) {
// [[block]] struct S { m: array<f32>; }; // [[block]] struct S { m: array<f32>; };
// [[set(0), binding(0)]] var<uniform, > svar : S; // [[group(0), binding(0)]] var<uniform, > svar : S;
auto* s = Structure(Source{{12, 34}}, "S", {Member("m", ty.array<i32>())}, auto* s = Structure(Source{{12, 34}}, "S", {Member("m", ty.array<i32>())},
{create<ast::StructBlockDecoration>()}); {create<ast::StructBlockDecoration>()});

View File

@ -59,7 +59,7 @@ class Pointer : public Castable<Pointer, Type> {
private: private:
Type const* const subtype_; Type const* const subtype_;
ast::StorageClass const storage_class_; ast::StorageClass const storage_class_;
ast::AccessControl const access_; ast::Access const access_;
}; };
} // namespace sem } // namespace sem

View File

@ -59,7 +59,7 @@ class Reference : public Castable<Reference, Type> {
private: private:
Type const* const subtype_; Type const* const subtype_;
ast::StorageClass const storage_class_; ast::StorageClass const storage_class_;
ast::AccessControl const access_; ast::Access const access_;
}; };
} // namespace sem } // namespace sem

View File

@ -15,6 +15,7 @@
#include "src/transform/array_length_from_uniform.h" #include "src/transform/array_length_from_uniform.h"
#include <memory> #include <memory>
#include <string>
#include <utility> #include <utility>
#include "src/ast/struct_block_decoration.h" #include "src/ast/struct_block_decoration.h"
@ -45,7 +46,7 @@ void ArrayLengthFromUniform::Run(CloneContext& ctx,
if (cfg == nullptr) { if (cfg == nullptr) {
ctx.dst->Diagnostics().add_error( ctx.dst->Diagnostics().add_error(
diag::System::Transform, diag::System::Transform,
"missing transform data for ArrayLengthFromUniform"); "missing transform data for " + std::string(TypeInfo().name));
return; return;
} }

View File

@ -29,7 +29,9 @@ using ArrayLengthFromUniformTest = TransformTest;
TEST_F(ArrayLengthFromUniformTest, Error_MissingTransformData) { TEST_F(ArrayLengthFromUniformTest, Error_MissingTransformData) {
auto* src = ""; auto* src = "";
auto* expect = "error: missing transform data for ArrayLengthFromUniform"; auto* expect =
"error: missing transform data for "
"tint::transform::ArrayLengthFromUniform";
auto got = Run<InlinePointerLets, Simplify, ArrayLengthFromUniform>(src); auto got = Run<InlinePointerLets, Simplify, ArrayLengthFromUniform>(src);

View File

@ -14,6 +14,7 @@
#include "src/transform/binding_remapper.h" #include "src/transform/binding_remapper.h"
#include <string>
#include <unordered_set> #include <unordered_set>
#include <utility> #include <utility>
@ -46,7 +47,7 @@ void BindingRemapper::Run(CloneContext& ctx, const DataMap& inputs, DataMap&) {
if (!remappings) { if (!remappings) {
ctx.dst->Diagnostics().add_error( ctx.dst->Diagnostics().add_error(
diag::System::Transform, diag::System::Transform,
"BindingRemapper did not find the remapping data"); "missing transform data for " + std::string(TypeInfo().name));
return; return;
} }

View File

@ -382,7 +382,8 @@ struct S {
fn f() {} fn f() {}
)"; )";
auto* expect = "error: BindingRemapper did not find the remapping data"; auto* expect =
"error: missing transform data for tint::transform::BindingRemapper";
auto got = Run<BindingRemapper>(src); auto got = Run<BindingRemapper>(src);

View File

@ -15,6 +15,7 @@
#include "src/transform/canonicalize_entry_point_io.h" #include "src/transform/canonicalize_entry_point_io.h"
#include <algorithm> #include <algorithm>
#include <string>
#include <utility> #include <utility>
#include "src/program_builder.h" #include "src/program_builder.h"
@ -70,7 +71,7 @@ void CanonicalizeEntryPointIO::Run(CloneContext& ctx,
if (cfg == nullptr) { if (cfg == nullptr) {
ctx.dst->Diagnostics().add_error( ctx.dst->Diagnostics().add_error(
diag::System::Transform, diag::System::Transform,
"missing transform data for CanonicalizeEntryPointIO"); "missing transform data for " + std::string(TypeInfo().name));
return; return;
} }

View File

@ -25,7 +25,9 @@ using CanonicalizeEntryPointIOTest = TransformTest;
TEST_F(CanonicalizeEntryPointIOTest, Error_MissingTransformData) { TEST_F(CanonicalizeEntryPointIOTest, Error_MissingTransformData) {
auto* src = ""; auto* src = "";
auto* expect = "error: missing transform data for CanonicalizeEntryPointIO"; auto* expect =
"error: missing transform data for "
"tint::transform::CanonicalizeEntryPointIO";
auto got = Run<CanonicalizeEntryPointIO>(src); auto got = Run<CanonicalizeEntryPointIO>(src);

View File

@ -881,8 +881,7 @@ Renamer::Config::Config(Target t) : target(t) {}
Renamer::Config::Config(const Config&) = default; Renamer::Config::Config(const Config&) = default;
Renamer::Config::~Config() = default; Renamer::Config::~Config() = default;
Renamer::Renamer() : deprecated_cfg_(Target::kAll) {} Renamer::Renamer() = default;
Renamer::Renamer(const Config& config) : deprecated_cfg_(config) {}
Renamer::~Renamer() = default; Renamer::~Renamer() = default;
Output Renamer::Run(const Program* in, const DataMap& inputs) { Output Renamer::Run(const Program* in, const DataMap& inputs) {
@ -918,14 +917,15 @@ Output Renamer::Run(const Program* in, const DataMap& inputs) {
Data::Remappings remappings; Data::Remappings remappings;
auto* cfg = inputs.Get<Config>(); Target target = Target::kAll;
if (!cfg) {
cfg = &deprecated_cfg_; if (auto* cfg = inputs.Get<Config>()) {
target = cfg->target;
} }
ctx.ReplaceAll([&](Symbol sym_in) { ctx.ReplaceAll([&](Symbol sym_in) {
auto name_in = ctx.src->Symbols().NameFor(sym_in); auto name_in = ctx.src->Symbols().NameFor(sym_in);
switch (cfg->target) { switch (target) {
case Target::kAll: case Target::kAll:
// Always rename. // Always rename.
break; break;

View File

@ -56,7 +56,8 @@ class Renamer : public Castable<Renamer, Transform> {
kMslKeywords, kMslKeywords,
}; };
/// Configuration options for the transform /// Optional configuration options for the transform.
/// If omitted, then the renamer will use Target::kAll.
struct Config : public Castable<Config, transform::Data> { struct Config : public Castable<Config, transform::Data> {
/// Constructor /// Constructor
/// @param tgt the targets to rename /// @param tgt the targets to rename
@ -75,11 +76,6 @@ class Renamer : public Castable<Renamer, Transform> {
/// Constructor using a the configuration provided in the input Data /// Constructor using a the configuration provided in the input Data
Renamer(); Renamer();
/// Constructor
/// @param config the configuration for the transform
/// [DEPRECATED] Pass Config as input Data
explicit Renamer(const Config& config);
/// Destructor /// Destructor
~Renamer() override; ~Renamer() override;
@ -88,9 +84,6 @@ class Renamer : public Castable<Renamer, Transform> {
/// @param data optional extra transform-specific input data /// @param data optional extra transform-specific input data
/// @returns the transformation result /// @returns the transformation result
Output Run(const Program* program, const DataMap& data = {}) override; Output Run(const Program* program, const DataMap& data = {}) override;
private:
Config const deprecated_cfg_;
}; };
} // namespace transform } // namespace transform

View File

@ -35,7 +35,9 @@ void SingleEntryPoint::Run(CloneContext& ctx, const DataMap& inputs, DataMap&) {
auto* cfg = inputs.Get<Config>(); auto* cfg = inputs.Get<Config>();
if (cfg == nullptr) { if (cfg == nullptr) {
ctx.dst->Diagnostics().add_error( ctx.dst->Diagnostics().add_error(
diag::System::Transform, "missing transform data for SingleEntryPoint"); diag::System::Transform,
"missing transform data for " + std::string(TypeInfo().name));
return; return;
} }

View File

@ -27,7 +27,8 @@ using SingleEntryPointTest = TransformTest;
TEST_F(SingleEntryPointTest, Error_MissingTransformData) { TEST_F(SingleEntryPointTest, Error_MissingTransformData) {
auto* src = ""; auto* src = "";
auto* expect = "error: missing transform data for SingleEntryPoint"; auto* expect =
"error: missing transform data for tint::transform::SingleEntryPoint";
auto got = Run<SingleEntryPoint>(src); auto got = Run<SingleEntryPoint>(src);

View File

@ -426,7 +426,7 @@ struct State {
// Returns a u32 loaded from buffer_base + offset. // Returns a u32 loaded from buffer_base + offset.
auto load_u32 = [&] { auto load_u32 = [&] {
return LoadPrimitive(array_base, offset, buffer, VertexFormat::kU32); return LoadPrimitive(array_base, offset, buffer, VertexFormat::kUint32);
}; };
// Returns a i32 loaded from buffer_base + offset. // Returns a i32 loaded from buffer_base + offset.
@ -434,7 +434,8 @@ struct State {
// Returns a u32 loaded from buffer_base + offset + 4. // Returns a u32 loaded from buffer_base + offset + 4.
auto load_next_u32 = [&] { auto load_next_u32 = [&] {
return LoadPrimitive(array_base, offset + 4, buffer, VertexFormat::kU32); return LoadPrimitive(array_base, offset + 4, buffer,
VertexFormat::kUint32);
}; };
// Returns a i32 loaded from buffer_base + offset + 4. // Returns a i32 loaded from buffer_base + offset + 4.
@ -446,8 +447,8 @@ struct State {
// `offset` must be `min_alignment` bytes aligned. // `offset` must be `min_alignment` bytes aligned.
auto load_u16_h = [&] { auto load_u16_h = [&] {
auto low_u32_offset = offset & ~3u; auto low_u32_offset = offset & ~3u;
auto* low_u32 = auto* low_u32 = LoadPrimitive(array_base, low_u32_offset, buffer,
LoadPrimitive(array_base, low_u32_offset, buffer, VertexFormat::kU32); VertexFormat::kUint32);
switch (offset & 3) { switch (offset & 3) {
case 0: case 0:
return ctx.dst->Shl(low_u32, 16u); return ctx.dst->Shl(low_u32, 16u);
@ -457,7 +458,7 @@ struct State {
return ctx.dst->And(low_u32, 0xffff0000u); return ctx.dst->And(low_u32, 0xffff0000u);
default: { // 3: default: { // 3:
auto* high_u32 = LoadPrimitive(array_base, low_u32_offset + 4, buffer, auto* high_u32 = LoadPrimitive(array_base, low_u32_offset + 4, buffer,
VertexFormat::kU32); VertexFormat::kUint32);
auto* shr = ctx.dst->Shr(low_u32, 8u); auto* shr = ctx.dst->Shr(low_u32, 8u);
auto* shl = ctx.dst->Shl(high_u32, 24u); auto* shl = ctx.dst->Shl(high_u32, 24u);
return ctx.dst->And(ctx.dst->Or(shl, shr), 0xffff0000u); return ctx.dst->And(ctx.dst->Or(shl, shr), 0xffff0000u);
@ -469,8 +470,8 @@ struct State {
// The high 16 bits are 0. // The high 16 bits are 0.
auto load_u16_l = [&] { auto load_u16_l = [&] {
auto low_u32_offset = offset & ~3u; auto low_u32_offset = offset & ~3u;
auto* low_u32 = auto* low_u32 = LoadPrimitive(array_base, low_u32_offset, buffer,
LoadPrimitive(array_base, low_u32_offset, buffer, VertexFormat::kU32); VertexFormat::kUint32);
switch (offset & 3) { switch (offset & 3) {
case 0: case 0:
return ctx.dst->And(low_u32, 0xffffu); return ctx.dst->And(low_u32, 0xffffu);
@ -480,7 +481,7 @@ struct State {
return ctx.dst->Shr(low_u32, 16u); return ctx.dst->Shr(low_u32, 16u);
default: { // 3: default: { // 3:
auto* high_u32 = LoadPrimitive(array_base, low_u32_offset + 4, buffer, auto* high_u32 = LoadPrimitive(array_base, low_u32_offset + 4, buffer,
VertexFormat::kU32); VertexFormat::kUint32);
auto* shr = ctx.dst->Shr(low_u32, 24u); auto* shr = ctx.dst->Shr(low_u32, 24u);
auto* shl = ctx.dst->Shl(high_u32, 8u); auto* shl = ctx.dst->Shl(high_u32, 8u);
return ctx.dst->And(ctx.dst->Or(shl, shr), 0xffffu); return ctx.dst->And(ctx.dst->Or(shl, shr), 0xffffu);
@ -504,31 +505,31 @@ struct State {
// Vectors of basic primitives // Vectors of basic primitives
case VertexFormat::kUint32x2: case VertexFormat::kUint32x2:
return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.u32(), return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.u32(),
VertexFormat::kU32, 2); VertexFormat::kUint32, 2);
case VertexFormat::kUint32x3: case VertexFormat::kUint32x3:
return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.u32(), return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.u32(),
VertexFormat::kU32, 3); VertexFormat::kUint32, 3);
case VertexFormat::kUint32x4: case VertexFormat::kUint32x4:
return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.u32(), return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.u32(),
VertexFormat::kU32, 4); VertexFormat::kUint32, 4);
case VertexFormat::kSint32x2: case VertexFormat::kSint32x2:
return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.i32(), return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.i32(),
VertexFormat::kI32, 2); VertexFormat::kSint32, 2);
case VertexFormat::kSint32x3: case VertexFormat::kSint32x3:
return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.i32(), return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.i32(),
VertexFormat::kI32, 3); VertexFormat::kSint32, 3);
case VertexFormat::kSint32x4: case VertexFormat::kSint32x4:
return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.i32(), return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.i32(),
VertexFormat::kI32, 4); VertexFormat::kSint32, 4);
case VertexFormat::kFloat32x2: case VertexFormat::kFloat32x2:
return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.f32(), return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.f32(),
VertexFormat::kF32, 2); VertexFormat::kFloat32, 2);
case VertexFormat::kFloat32x3: case VertexFormat::kFloat32x3:
return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.f32(), return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.f32(),
VertexFormat::kF32, 3); VertexFormat::kFloat32, 3);
case VertexFormat::kFloat32x4: case VertexFormat::kFloat32x4:
return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.f32(), return LoadVec(array_base, offset, buffer, 4, ctx.dst->ty.f32(),
VertexFormat::kF32, 4); VertexFormat::kFloat32, 4);
case VertexFormat::kUint8x2: { case VertexFormat::kUint8x2: {
// yyxx0000, yyxx0000 // yyxx0000, yyxx0000
@ -639,7 +640,8 @@ struct State {
/// of the vertex array (each index is 4-bytes). /// of the vertex array (each index is 4-bytes).
/// @param offset the byte offset of the data from `buffer_base` /// @param offset the byte offset of the data from `buffer_base`
/// @param buffer the index of the vertex buffer /// @param buffer the index of the vertex buffer
/// @param format VertexFormat::kU32, VertexFormat::kI32 or VertexFormat::kF32 /// @param format VertexFormat::kUint32, VertexFormat::kSint32 or
/// VertexFormat::kFloat32
ast::Expression* LoadPrimitive(Symbol array_base, ast::Expression* LoadPrimitive(Symbol array_base,
uint32_t offset, uint32_t offset,
uint32_t buffer, uint32_t buffer,
@ -662,10 +664,10 @@ struct State {
} else { } else {
// Unaligned load // Unaligned load
uint32_t offset_aligned = offset & ~3u; uint32_t offset_aligned = offset & ~3u;
auto* low = auto* low = LoadPrimitive(array_base, offset_aligned, buffer,
LoadPrimitive(array_base, offset_aligned, buffer, VertexFormat::kU32); VertexFormat::kUint32);
auto* high = LoadPrimitive(array_base, offset_aligned + 4u, buffer, auto* high = LoadPrimitive(array_base, offset_aligned + 4u, buffer,
VertexFormat::kU32); VertexFormat::kUint32);
uint32_t shift = 8u * (offset & 3u); uint32_t shift = 8u * (offset & 3u);
@ -675,11 +677,11 @@ struct State {
} }
switch (format) { switch (format) {
case VertexFormat::kU32: case VertexFormat::kUint32:
return u32; return u32;
case VertexFormat::kI32: case VertexFormat::kSint32:
return ctx.dst->Bitcast(ctx.dst->ty.i32(), u32); return ctx.dst->Bitcast(ctx.dst->ty.i32(), u32);
case VertexFormat::kF32: case VertexFormat::kFloat32:
return ctx.dst->Bitcast(ctx.dst->ty.f32(), u32); return ctx.dst->Bitcast(ctx.dst->ty.f32(), u32);
default: default:
break; break;

View File

@ -58,38 +58,7 @@ enum class VertexFormat {
kSint32x3, // sint32x3 kSint32x3, // sint32x3
kSint32x4, // sint32x4 kSint32x4, // sint32x4
// Deprecated names kLastEntry = kSint32x4,
kVec2U8 = kUint8x2,
kVec4U8 = kUint8x4,
kVec2I8 = kSint8x2,
kVec4I8 = kSint8x4,
kVec2U8Norm = kUnorm8x2,
kVec4U8Norm = kUnorm8x4,
kVec2I8Norm = kSnorm8x2,
kVec4I8Norm = kSnorm8x4,
kVec2U16 = kUint16x2,
kVec4U16 = kUint16x4,
kVec2I16 = kSint16x2,
kVec4I16 = kSint16x4,
kVec2U16Norm = kUnorm16x2,
kVec4U16Norm = kUnorm16x4,
kVec2I16Norm = kSnorm16x2,
kVec4I16Norm = kSnorm16x4,
kVec2F16 = kFloat16x2,
kVec4F16 = kFloat16x4,
kF32 = kFloat32,
kVec2F32 = kFloat32x2,
kVec3F32 = kFloat32x3,
kVec4F32 = kFloat32x4,
kU32 = kUint32,
kVec2U32 = kUint32x2,
kVec3U32 = kUint32x3,
kVec4U32 = kUint32x4,
kI32 = kSint32,
kVec2I32 = kSint32x2,
kVec3I32 = kSint32x3,
kVec4I32 = kSint32x4,
kLastEntry = kVec4I32
}; };
/// Describes if a vertex attributes increments with vertex index or instance /// Describes if a vertex attributes increments with vertex index or instance

View File

@ -544,7 +544,7 @@ fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(
cfg.vertex_state = { cfg.vertex_state = {
{{16, {{16,
InputStepMode::kVertex, InputStepMode::kVertex,
{{VertexFormat::kFloat32, 0, 0}, {VertexFormat::kVec4F32, 0, 1}}}}}; {{VertexFormat::kFloat32, 0, 0}, {VertexFormat::kFloat32x4, 0, 1}}}}};
cfg.entry_point_name = "main"; cfg.entry_point_name = "main";
DataMap data; DataMap data;
@ -596,9 +596,9 @@ fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(
VertexPulling::Config cfg; VertexPulling::Config cfg;
cfg.vertex_state = {{ cfg.vertex_state = {{
{8, InputStepMode::kVertex, {{VertexFormat::kVec2F32, 0, 0}}}, {8, InputStepMode::kVertex, {{VertexFormat::kFloat32x2, 0, 0}}},
{12, InputStepMode::kVertex, {{VertexFormat::kVec3F32, 0, 1}}}, {12, InputStepMode::kVertex, {{VertexFormat::kFloat32x3, 0, 1}}},
{16, InputStepMode::kVertex, {{VertexFormat::kVec4F32, 0, 2}}}, {16, InputStepMode::kVertex, {{VertexFormat::kFloat32x4, 0, 2}}},
}}; }};
cfg.entry_point_name = "main"; cfg.entry_point_name = "main";
@ -651,7 +651,7 @@ fn main([[builtin(vertex_index)]] tint_pulling_vertex_index_1 : u32) -> [[builti
cfg.vertex_state = { cfg.vertex_state = {
{{16, {{16,
InputStepMode::kVertex, InputStepMode::kVertex,
{{VertexFormat::kFloat32, 0, 0}, {VertexFormat::kVec4F32, 0, 1}}}}}; {{VertexFormat::kFloat32, 0, 0}, {VertexFormat::kFloat32x4, 0, 1}}}}};
cfg.entry_point_name = "main"; cfg.entry_point_name = "main";
DataMap data; DataMap data;

View File

@ -81,12 +81,12 @@ class TestHelperBase : public BODY, public ProgramBuilder {
}(); }();
transform::Manager transform_manager; transform::Manager transform_manager;
transform::Renamer::Config renamer_config{ transform::DataMap transform_data;
transform::Renamer::Target::kHlslKeywords}; transform_data.Add<transform::Renamer::Config>(
transform_manager.append( transform::Renamer::Target::kHlslKeywords);
std::make_unique<tint::transform::Renamer>(renamer_config)); transform_manager.Add<tint::transform::Renamer>();
transform_manager.append(std::make_unique<tint::transform::Hlsl>()); transform_manager.Add<tint::transform::Hlsl>();
auto result = transform_manager.Run(program.get()); auto result = transform_manager.Run(program.get(), transform_data);
[&]() { [&]() {
ASSERT_TRUE(result.program.IsValid()) ASSERT_TRUE(result.program.IsValid())
<< formatter.format(result.program.Diagnostics()); << formatter.format(result.program.Diagnostics());

View File

@ -5,4 +5,4 @@ struct Light {
[[block]] struct Lights { [[block]] struct Lights {
light : [[stride(32)]] array<Light>; light : [[stride(32)]] array<Light>;
}; };
[[set(0), binding(1)]] var<storage, read> lights : Lights; [[group(0), binding(1)]] var<storage, read> lights : Lights;

View File

@ -8,12 +8,12 @@ struct vertexUniformBuffer2 {
transform2 : mat2x2<f32>; transform2 : mat2x2<f32>;
}; };
[[set(0), binding(0)]] var<uniform> x_20 : vertexUniformBuffer1; [[group(0), binding(0)]] var<uniform> x_20 : vertexUniformBuffer1;
[[set(1), binding(0)]] var<uniform> x_26 : vertexUniformBuffer2; [[group(1), binding(0)]] var<uniform> x_26 : vertexUniformBuffer2;
[[stage(vertex)]] [[stage(vertex)]]
fn main([[builtin(vertex_idx)]] gl_VertexIndex : u32) -> [[builtin(position)]] vec4<f32> { fn main([[builtin(vertex_index)]] gl_VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
var indexable : array<vec2<f32>, 3>; var indexable : array<vec2<f32>, 3>;
let x_23 : mat2x2<f32> = x_20.transform1; let x_23 : mat2x2<f32> = x_20.transform1;
let x_28 : mat2x2<f32> = x_26.transform2; let x_28 : mat2x2<f32> = x_26.transform2;