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

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

View File

@@ -29,7 +29,9 @@ using ArrayLengthFromUniformTest = TransformTest;
TEST_F(ArrayLengthFromUniformTest, Error_MissingTransformData) {
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);

View File

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

View File

@@ -382,7 +382,8 @@ struct S {
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);

View File

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

View File

@@ -25,7 +25,9 @@ using CanonicalizeEntryPointIOTest = TransformTest;
TEST_F(CanonicalizeEntryPointIOTest, Error_MissingTransformData) {
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);

View File

@@ -881,8 +881,7 @@ Renamer::Config::Config(Target t) : target(t) {}
Renamer::Config::Config(const Config&) = default;
Renamer::Config::~Config() = default;
Renamer::Renamer() : deprecated_cfg_(Target::kAll) {}
Renamer::Renamer(const Config& config) : deprecated_cfg_(config) {}
Renamer::Renamer() = default;
Renamer::~Renamer() = default;
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;
auto* cfg = inputs.Get<Config>();
if (!cfg) {
cfg = &deprecated_cfg_;
Target target = Target::kAll;
if (auto* cfg = inputs.Get<Config>()) {
target = cfg->target;
}
ctx.ReplaceAll([&](Symbol sym_in) {
auto name_in = ctx.src->Symbols().NameFor(sym_in);
switch (cfg->target) {
switch (target) {
case Target::kAll:
// Always rename.
break;

View File

@@ -56,7 +56,8 @@ class Renamer : public Castable<Renamer, Transform> {
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> {
/// Constructor
/// @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
Renamer();
/// Constructor
/// @param config the configuration for the transform
/// [DEPRECATED] Pass Config as input Data
explicit Renamer(const Config& config);
/// Destructor
~Renamer() override;
@@ -88,9 +84,6 @@ class Renamer : public Castable<Renamer, Transform> {
/// @param data optional extra transform-specific input data
/// @returns the transformation result
Output Run(const Program* program, const DataMap& data = {}) override;
private:
Config const deprecated_cfg_;
};
} // namespace transform

View File

@@ -35,7 +35,9 @@ void SingleEntryPoint::Run(CloneContext& ctx, const DataMap& inputs, DataMap&) {
auto* cfg = inputs.Get<Config>();
if (cfg == nullptr) {
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;
}

View File

@@ -27,7 +27,8 @@ using SingleEntryPointTest = TransformTest;
TEST_F(SingleEntryPointTest, Error_MissingTransformData) {
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);

View File

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

View File

@@ -58,38 +58,7 @@ enum class VertexFormat {
kSint32x3, // sint32x3
kSint32x4, // sint32x4
// Deprecated names
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
kLastEntry = kSint32x4,
};
/// 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 = {
{{16,
InputStepMode::kVertex,
{{VertexFormat::kFloat32, 0, 0}, {VertexFormat::kVec4F32, 0, 1}}}}};
{{VertexFormat::kFloat32, 0, 0}, {VertexFormat::kFloat32x4, 0, 1}}}}};
cfg.entry_point_name = "main";
DataMap data;
@@ -596,9 +596,9 @@ fn main([[builtin(vertex_index)]] tint_pulling_vertex_index : u32) -> [[builtin(
VertexPulling::Config cfg;
cfg.vertex_state = {{
{8, InputStepMode::kVertex, {{VertexFormat::kVec2F32, 0, 0}}},
{12, InputStepMode::kVertex, {{VertexFormat::kVec3F32, 0, 1}}},
{16, InputStepMode::kVertex, {{VertexFormat::kVec4F32, 0, 2}}},
{8, InputStepMode::kVertex, {{VertexFormat::kFloat32x2, 0, 0}}},
{12, InputStepMode::kVertex, {{VertexFormat::kFloat32x3, 0, 1}}},
{16, InputStepMode::kVertex, {{VertexFormat::kFloat32x4, 0, 2}}},
}};
cfg.entry_point_name = "main";
@@ -651,7 +651,7 @@ fn main([[builtin(vertex_index)]] tint_pulling_vertex_index_1 : u32) -> [[builti
cfg.vertex_state = {
{{16,
InputStepMode::kVertex,
{{VertexFormat::kFloat32, 0, 0}, {VertexFormat::kVec4F32, 0, 1}}}}};
{{VertexFormat::kFloat32, 0, 0}, {VertexFormat::kFloat32x4, 0, 1}}}}};
cfg.entry_point_name = "main";
DataMap data;