mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-19 01:46:35 +00:00
tint: Change all ProgramBuilder literals to 'i' or 'u' suffix
Unsuffixed integer literals are currently treated as i32, but will shortly become AbstractInteger. To keep tests behaving identically to how they are currently, change all test literals to using either 'i' or 'u' suffixes. Bug: tint:1504 Change-Id: Ic373d18ce1c718a16b6905568aec89da3641d36b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88845 Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
8b9d1e0800
commit
0ce9ab042e
@@ -20,6 +20,8 @@
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::AddEmptyEntryPoint);
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
|
||||
AddEmptyEntryPoint::AddEmptyEntryPoint() = default;
|
||||
@@ -37,7 +39,7 @@ bool AddEmptyEntryPoint::ShouldRun(const Program* program, const DataMap&) const
|
||||
|
||||
void AddEmptyEntryPoint::Run(CloneContext& ctx, const DataMap&, DataMap&) const {
|
||||
ctx.dst->Func(ctx.dst->Symbols().New("unused_entry_point"), {}, ctx.dst->ty.void_(), {},
|
||||
{ctx.dst->Stage(ast::PipelineStage::kCompute), ctx.dst->WorkgroupSize(1)});
|
||||
{ctx.dst->Stage(ast::PipelineStage::kCompute), ctx.dst->WorkgroupSize(1_i)});
|
||||
ctx.Clone();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ TEST_F(AddEmptyEntryPointTest, EmptyModule) {
|
||||
auto* src = R"()";
|
||||
|
||||
auto* expect = R"(
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn unused_entry_point() {
|
||||
}
|
||||
)";
|
||||
@@ -70,7 +70,7 @@ TEST_F(AddEmptyEntryPointTest, NameClash) {
|
||||
auto* src = R"(var<private> unused_entry_point : f32;)";
|
||||
|
||||
auto* expect = R"(
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn unused_entry_point_1() {
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ void ArrayLengthFromUniform::Run(CloneContext& ctx, const DataMap& inputs, DataM
|
||||
ctx.dst->Sym(),
|
||||
{ctx.dst->Member(kBufferSizeMemberName,
|
||||
ctx.dst->ty.array(ctx.dst->ty.vec4(ctx.dst->ty.u32()),
|
||||
(max_buffer_size_index / 4) + 1))});
|
||||
u32((max_buffer_size_index / 4) + 1)))});
|
||||
buffer_size_ubo = ctx.dst->Global(
|
||||
ctx.dst->Sym(), ctx.dst->ty.Of(buffer_size_struct), ast::StorageClass::kUniform,
|
||||
ast::AttributeList{
|
||||
@@ -154,50 +154,50 @@ void ArrayLengthFromUniform::Run(CloneContext& ctx, const DataMap& inputs, DataM
|
||||
|
||||
std::unordered_set<uint32_t> used_size_indices;
|
||||
|
||||
IterateArrayLengthOnStorageVar(
|
||||
ctx, [&](const ast::CallExpression* call_expr, const sem::VariableUser* storage_buffer_sem,
|
||||
const sem::GlobalVariable* var) {
|
||||
auto binding = var->BindingPoint();
|
||||
auto idx_itr = cfg->bindpoint_to_size_index.find(binding);
|
||||
if (idx_itr == cfg->bindpoint_to_size_index.end()) {
|
||||
return;
|
||||
}
|
||||
IterateArrayLengthOnStorageVar(ctx, [&](const ast::CallExpression* call_expr,
|
||||
const sem::VariableUser* storage_buffer_sem,
|
||||
const sem::GlobalVariable* var) {
|
||||
auto binding = var->BindingPoint();
|
||||
auto idx_itr = cfg->bindpoint_to_size_index.find(binding);
|
||||
if (idx_itr == cfg->bindpoint_to_size_index.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t size_index = idx_itr->second;
|
||||
used_size_indices.insert(size_index);
|
||||
uint32_t size_index = idx_itr->second;
|
||||
used_size_indices.insert(size_index);
|
||||
|
||||
// Load the total storage buffer size from the UBO.
|
||||
uint32_t array_index = size_index / 4;
|
||||
auto* vec_expr = ctx.dst->IndexAccessor(
|
||||
ctx.dst->MemberAccessor(get_ubo()->symbol, kBufferSizeMemberName), array_index);
|
||||
uint32_t vec_index = size_index % 4;
|
||||
auto* total_storage_buffer_size = ctx.dst->IndexAccessor(vec_expr, vec_index);
|
||||
// Load the total storage buffer size from the UBO.
|
||||
uint32_t array_index = size_index / 4;
|
||||
auto* vec_expr = ctx.dst->IndexAccessor(
|
||||
ctx.dst->MemberAccessor(get_ubo()->symbol, kBufferSizeMemberName), u32(array_index));
|
||||
uint32_t vec_index = size_index % 4;
|
||||
auto* total_storage_buffer_size = ctx.dst->IndexAccessor(vec_expr, u32(vec_index));
|
||||
|
||||
// Calculate actual array length
|
||||
// total_storage_buffer_size - array_offset
|
||||
// array_length = ----------------------------------------
|
||||
// array_stride
|
||||
const ast::Expression* total_size = total_storage_buffer_size;
|
||||
auto* storage_buffer_type = storage_buffer_sem->Type()->UnwrapRef();
|
||||
const sem::Array* array_type = nullptr;
|
||||
if (auto* str = storage_buffer_type->As<sem::Struct>()) {
|
||||
// The variable is a struct, so subtract the byte offset of the array
|
||||
// member.
|
||||
auto* array_member_sem = str->Members().back();
|
||||
array_type = array_member_sem->Type()->As<sem::Array>();
|
||||
total_size = ctx.dst->Sub(total_storage_buffer_size, array_member_sem->Offset());
|
||||
} else if (auto* arr = storage_buffer_type->As<sem::Array>()) {
|
||||
array_type = arr;
|
||||
} else {
|
||||
TINT_ICE(Transform, ctx.dst->Diagnostics())
|
||||
<< "expected form of arrayLength argument to be &array_var or "
|
||||
"&struct_var.array_member";
|
||||
return;
|
||||
}
|
||||
auto* array_length = ctx.dst->Div(total_size, array_type->Stride());
|
||||
// Calculate actual array length
|
||||
// total_storage_buffer_size - array_offset
|
||||
// array_length = ----------------------------------------
|
||||
// array_stride
|
||||
const ast::Expression* total_size = total_storage_buffer_size;
|
||||
auto* storage_buffer_type = storage_buffer_sem->Type()->UnwrapRef();
|
||||
const sem::Array* array_type = nullptr;
|
||||
if (auto* str = storage_buffer_type->As<sem::Struct>()) {
|
||||
// The variable is a struct, so subtract the byte offset of the array
|
||||
// member.
|
||||
auto* array_member_sem = str->Members().back();
|
||||
array_type = array_member_sem->Type()->As<sem::Array>();
|
||||
total_size = ctx.dst->Sub(total_storage_buffer_size, u32(array_member_sem->Offset()));
|
||||
} else if (auto* arr = storage_buffer_type->As<sem::Array>()) {
|
||||
array_type = arr;
|
||||
} else {
|
||||
TINT_ICE(Transform, ctx.dst->Diagnostics())
|
||||
<< "expected form of arrayLength argument to be &array_var or "
|
||||
"&struct_var.array_member";
|
||||
return;
|
||||
}
|
||||
auto* array_length = ctx.dst->Div(total_size, u32(array_type->Stride()));
|
||||
|
||||
ctx.Replace(call_expr, array_length);
|
||||
});
|
||||
ctx.Replace(call_expr, array_length);
|
||||
});
|
||||
|
||||
ctx.Clone();
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::BuiltinPolyfill);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::BuiltinPolyfill::Config);
|
||||
|
||||
@@ -57,7 +59,7 @@ struct BuiltinPolyfill::State {
|
||||
return b.ty.vec<u32>(width);
|
||||
};
|
||||
auto V = [&](uint32_t value) -> const ast::Expression* {
|
||||
return ScalarOrVector(width, value);
|
||||
return ScalarOrVector(width, u32(value));
|
||||
};
|
||||
b.Func(
|
||||
name, {b.Param("v", T(ty))}, T(ty),
|
||||
@@ -112,7 +114,7 @@ struct BuiltinPolyfill::State {
|
||||
return b.ty.vec<u32>(width);
|
||||
};
|
||||
auto V = [&](uint32_t value) -> const ast::Expression* {
|
||||
return ScalarOrVector(width, value);
|
||||
return ScalarOrVector(width, u32(value));
|
||||
};
|
||||
auto B = [&](const ast::Expression* value) -> const ast::Expression* {
|
||||
if (width == 1) {
|
||||
@@ -175,13 +177,13 @@ struct BuiltinPolyfill::State {
|
||||
};
|
||||
|
||||
ast::StatementList body = {
|
||||
b.Decl(b.Let("s", nullptr, b.Call("min", "offset", W))),
|
||||
b.Decl(b.Let("e", nullptr, b.Call("min", W, b.Add("s", "count")))),
|
||||
b.Decl(b.Let("s", nullptr, b.Call("min", "offset", u32(W)))),
|
||||
b.Decl(b.Let("e", nullptr, b.Call("min", u32(W), b.Add("s", "count")))),
|
||||
};
|
||||
|
||||
switch (polyfill.extract_bits) {
|
||||
case Level::kFull:
|
||||
body.emplace_back(b.Decl(b.Let("shl", nullptr, b.Sub(W, "e"))));
|
||||
body.emplace_back(b.Decl(b.Let("shl", nullptr, b.Sub(u32(W), "e"))));
|
||||
body.emplace_back(b.Decl(b.Let("shr", nullptr, b.Add("shl", "s"))));
|
||||
body.emplace_back(
|
||||
b.Return(b.Shr(b.Shl("v", vecN_u32(b.Expr("shl"))), vecN_u32(b.Expr("shr")))));
|
||||
@@ -221,7 +223,7 @@ struct BuiltinPolyfill::State {
|
||||
return b.ty.vec<u32>(width);
|
||||
};
|
||||
auto V = [&](uint32_t value) -> const ast::Expression* {
|
||||
return ScalarOrVector(width, value);
|
||||
return ScalarOrVector(width, u32(value));
|
||||
};
|
||||
auto B = [&](const ast::Expression* value) -> const ast::Expression* {
|
||||
if (width == 1) {
|
||||
@@ -238,7 +240,7 @@ struct BuiltinPolyfill::State {
|
||||
x = b.Call("select", //
|
||||
b.Construct(U(), "v"), //
|
||||
b.Construct(U(), b.Complement("v")), //
|
||||
b.LessThan("v", ScalarOrVector(width, 0)));
|
||||
b.LessThan("v", ScalarOrVector(width, 0_i)));
|
||||
}
|
||||
|
||||
b.Func(
|
||||
@@ -295,7 +297,7 @@ struct BuiltinPolyfill::State {
|
||||
return b.ty.vec<u32>(width);
|
||||
};
|
||||
auto V = [&](uint32_t value) -> const ast::Expression* {
|
||||
return ScalarOrVector(width, value);
|
||||
return ScalarOrVector(width, u32(value));
|
||||
};
|
||||
auto B = [&](const ast::Expression* value) -> const ast::Expression* {
|
||||
if (width == 1) {
|
||||
@@ -368,15 +370,16 @@ struct BuiltinPolyfill::State {
|
||||
};
|
||||
|
||||
ast::StatementList body = {
|
||||
b.Decl(b.Let("s", nullptr, b.Call("min", "offset", W))),
|
||||
b.Decl(b.Let("e", nullptr, b.Call("min", W, b.Add("s", "count")))),
|
||||
b.Decl(b.Let("s", nullptr, b.Call("min", "offset", u32(W)))),
|
||||
b.Decl(b.Let("e", nullptr, b.Call("min", u32(W), b.Add("s", "count")))),
|
||||
};
|
||||
|
||||
switch (polyfill.insert_bits) {
|
||||
case Level::kFull:
|
||||
// let mask = ((1 << s) - 1) ^ ((1 << e) - 1)
|
||||
body.emplace_back(b.Decl(b.Let(
|
||||
"mask", nullptr, b.Xor(b.Sub(b.Shl(1u, "s"), 1u), b.Sub(b.Shl(1u, "e"), 1u)))));
|
||||
body.emplace_back(
|
||||
b.Decl(b.Let("mask", nullptr,
|
||||
b.Xor(b.Sub(b.Shl(1_u, "s"), 1_u), b.Sub(b.Shl(1_u, "e"), 1_u)))));
|
||||
// return ((n << s) & mask) | (v & ~mask)
|
||||
body.emplace_back(b.Return(b.Or(b.And(b.Shl("n", U("s")), V("mask")),
|
||||
b.And("v", V(b.Complement("mask"))))));
|
||||
@@ -403,10 +406,6 @@ struct BuiltinPolyfill::State {
|
||||
}
|
||||
|
||||
private:
|
||||
/// Aliases
|
||||
using u32 = ProgramBuilder::u32;
|
||||
using i32 = ProgramBuilder::i32;
|
||||
|
||||
/// @returns the AST type for the given sem type
|
||||
const ast::Type* T(const sem::Type* ty) const { return CreateASTTypeFor(ctx, ty); }
|
||||
|
||||
|
||||
@@ -604,7 +604,7 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn tint_first_leading_bit(v : i32) -> i32 {
|
||||
var x = select(u32(v), u32(~(v)), (v < 0));
|
||||
var x = select(u32(v), u32(~(v)), (v < 0i));
|
||||
let b16 = select(0u, 16u, bool((x & 4294901760u)));
|
||||
x = (x >> b16);
|
||||
let b8 = select(0u, 8u, bool((x & 65280u)));
|
||||
@@ -670,7 +670,7 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn tint_first_leading_bit(v : vec3<i32>) -> vec3<i32> {
|
||||
var x = select(vec3<u32>(v), vec3<u32>(~(v)), (v < vec3<i32>(0)));
|
||||
var x = select(vec3<u32>(v), vec3<u32>(~(v)), (v < vec3<i32>(0i)));
|
||||
let b16 = select(vec3<u32>(0u), vec3<u32>(16u), vec3<bool>((x & vec3<u32>(4294901760u))));
|
||||
x = (x >> b16);
|
||||
let b8 = select(vec3<u32>(0u), vec3<u32>(8u), vec3<bool>((x & vec3<u32>(65280u))));
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::CalculateArrayLength);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::CalculateArrayLength::BufferSizeIntrinsic);
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
|
||||
namespace {
|
||||
@@ -168,7 +170,7 @@ void CalculateArrayLength::Run(CloneContext& ctx, const DataMap&, DataMap&) cons
|
||||
// RWByteAddressBuffer.GetDimensions()
|
||||
auto* buffer_size_result = ctx.dst->Decl(
|
||||
ctx.dst->Var(ctx.dst->Sym(), ctx.dst->ty.u32(),
|
||||
ast::StorageClass::kNone, ctx.dst->Expr(0u)));
|
||||
ast::StorageClass::kNone, ctx.dst->Expr(0_u)));
|
||||
|
||||
// Call storage_buffer.GetDimensions(&buffer_size_result)
|
||||
auto* call_get_dims = ctx.dst->CallStmt(ctx.dst->Call(
|
||||
@@ -192,7 +194,8 @@ void CalculateArrayLength::Run(CloneContext& ctx, const DataMap&, DataMap&) cons
|
||||
// the array member.
|
||||
auto* array_member_sem = str->Members().back();
|
||||
array_type = array_member_sem->Type()->As<sem::Array>();
|
||||
total_size = ctx.dst->Sub(total_size, array_member_sem->Offset());
|
||||
total_size =
|
||||
ctx.dst->Sub(total_size, u32(array_member_sem->Offset()));
|
||||
} else if (auto* arr = storage_buffer_type->As<sem::Array>()) {
|
||||
array_type = arr;
|
||||
} else {
|
||||
@@ -202,8 +205,9 @@ void CalculateArrayLength::Run(CloneContext& ctx, const DataMap&, DataMap&) cons
|
||||
return name;
|
||||
}
|
||||
uint32_t array_stride = array_type->Size();
|
||||
auto* array_length_var = ctx.dst->Decl(ctx.dst->Let(
|
||||
name, ctx.dst->ty.u32(), ctx.dst->Div(total_size, array_stride)));
|
||||
auto* array_length_var = ctx.dst->Decl(
|
||||
ctx.dst->Let(name, ctx.dst->ty.u32(),
|
||||
ctx.dst->Div(total_size, u32(array_stride))));
|
||||
|
||||
// Insert the array length calculations at the top of the block
|
||||
ctx.InsertBefore(block->statements, block->statements[0],
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "src/tint/sem/function.h"
|
||||
#include "src/tint/transform/unshadow.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::CanonicalizeEntryPointIO);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::CanonicalizeEntryPointIO::Config);
|
||||
|
||||
@@ -190,8 +192,8 @@ struct CanonicalizeEntryPointIO::State {
|
||||
} else if (builtin->builtin == ast::Builtin::kSampleMask) {
|
||||
// Vulkan requires the type of a SampleMask builtin to be an array.
|
||||
// Declare it as array<u32, 1> and then load the first element.
|
||||
ast_type = ctx.dst->ty.array(ast_type, 1);
|
||||
value = ctx.dst->IndexAccessor(value, 0);
|
||||
ast_type = ctx.dst->ty.array(ast_type, 1_u);
|
||||
value = ctx.dst->IndexAccessor(value, 0_i);
|
||||
}
|
||||
}
|
||||
ctx.dst->Global(symbol, ast_type, ast::StorageClass::kInput, std::move(attributes));
|
||||
@@ -356,7 +358,7 @@ struct CanonicalizeEntryPointIO::State {
|
||||
for (auto& outval : wrapper_output_values) {
|
||||
if (HasSampleMask(outval.attributes)) {
|
||||
// Combine the authored sample mask with the fixed mask.
|
||||
outval.value = ctx.dst->And(outval.value, cfg.fixed_sample_mask);
|
||||
outval.value = ctx.dst->And(outval.value, u32(cfg.fixed_sample_mask));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -365,7 +367,7 @@ struct CanonicalizeEntryPointIO::State {
|
||||
// using the fixed sample mask.
|
||||
AddOutput("fixed_sample_mask", ctx.dst->create<sem::U32>(),
|
||||
{ctx.dst->Builtin(ast::Builtin::kSampleMask)},
|
||||
ctx.dst->Expr(cfg.fixed_sample_mask));
|
||||
ctx.dst->Expr(u32(cfg.fixed_sample_mask)));
|
||||
}
|
||||
|
||||
/// Add a point size builtin to the wrapper function output.
|
||||
@@ -458,8 +460,8 @@ struct CanonicalizeEntryPointIO::State {
|
||||
if (HasSampleMask(attributes)) {
|
||||
// Vulkan requires the type of a SampleMask builtin to be an array.
|
||||
// Declare it as array<u32, 1> and then store to the first element.
|
||||
type = ctx.dst->ty.array(type, 1);
|
||||
lhs = ctx.dst->IndexAccessor(lhs, 0);
|
||||
type = ctx.dst->ty.array(type, 1_u);
|
||||
lhs = ctx.dst->IndexAccessor(lhs, 0_i);
|
||||
}
|
||||
ctx.dst->Global(name, type, ast::StorageClass::kOutput, std::move(attributes));
|
||||
wrapper_body.push_back(ctx.dst->Assign(lhs, outval.value));
|
||||
@@ -668,9 +670,9 @@ struct CanonicalizeEntryPointIO::State {
|
||||
case ast::Builtin::kSampleMask:
|
||||
// gl_SampleMask is an array of i32. Retrieve the first element and
|
||||
// bitcast it to u32.
|
||||
value = ctx.dst->IndexAccessor(value, 0);
|
||||
value = ctx.dst->IndexAccessor(value, 0_i);
|
||||
value = ctx.dst->Bitcast(ast_type, value);
|
||||
ast_type = ctx.dst->ty.array(ctx.dst->ty.i32(), 1);
|
||||
ast_type = ctx.dst->ty.array(ctx.dst->ty.i32(), 1_u);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -678,7 +678,7 @@ fn frag_main() -> FragOutput {
|
||||
|
||||
@builtin(frag_depth) @internal(disable_validation__ignore_storage_class) var<out> depth_1 : f32;
|
||||
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<out> mask_1 : array<u32, 1>;
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<out> mask_1 : array<u32, 1u>;
|
||||
|
||||
struct FragOutput {
|
||||
color : vec4<f32>,
|
||||
@@ -699,7 +699,7 @@ fn frag_main() {
|
||||
let inner_result = frag_main_inner();
|
||||
color_1 = inner_result.color;
|
||||
depth_1 = inner_result.depth;
|
||||
mask_1[0] = inner_result.mask;
|
||||
mask_1[0i] = inner_result.mask;
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -733,7 +733,7 @@ struct FragOutput {
|
||||
|
||||
@builtin(frag_depth) @internal(disable_validation__ignore_storage_class) var<out> depth_1 : f32;
|
||||
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<out> mask_1 : array<u32, 1>;
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<out> mask_1 : array<u32, 1u>;
|
||||
|
||||
fn frag_main_inner() -> FragOutput {
|
||||
var output : FragOutput;
|
||||
@@ -748,7 +748,7 @@ fn frag_main() {
|
||||
let inner_result = frag_main_inner();
|
||||
color_1 = inner_result.color;
|
||||
depth_1 = inner_result.depth;
|
||||
mask_1[0] = inner_result.mask;
|
||||
mask_1[0i] = inner_result.mask;
|
||||
}
|
||||
|
||||
struct FragOutput {
|
||||
@@ -3870,9 +3870,9 @@ fn main(@builtin(sample_index) sample_index : u32,
|
||||
auto* expect = R"(
|
||||
@builtin(sample_index) @internal(disable_validation__ignore_storage_class) var<in> sample_index_1 : u32;
|
||||
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<in> mask_in_1 : array<u32, 1>;
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<in> mask_in_1 : array<u32, 1u>;
|
||||
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<out> value : array<u32, 1>;
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<out> value : array<u32, 1u>;
|
||||
|
||||
fn main_inner(sample_index : u32, mask_in : u32) -> u32 {
|
||||
return mask_in;
|
||||
@@ -3880,8 +3880,8 @@ fn main_inner(sample_index : u32, mask_in : u32) -> u32 {
|
||||
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let inner_result = main_inner(sample_index_1, mask_in_1[0]);
|
||||
value[0] = inner_result;
|
||||
let inner_result = main_inner(sample_index_1, mask_in_1[0i]);
|
||||
value[0i] = inner_result;
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -3905,9 +3905,9 @@ fn fragment_main(@builtin(sample_index) sample_index : u32,
|
||||
auto* expect = R"(
|
||||
@builtin(sample_index) @internal(disable_validation__ignore_storage_class) var<in> gl_SampleID : i32;
|
||||
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<in> gl_SampleMaskIn : array<i32, 1>;
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<in> gl_SampleMaskIn : array<i32, 1u>;
|
||||
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<out> gl_SampleMask : array<i32, 1>;
|
||||
@builtin(sample_mask) @internal(disable_validation__ignore_storage_class) var<out> gl_SampleMask : array<i32, 1u>;
|
||||
|
||||
fn fragment_main(sample_index : u32, mask_in : u32) -> u32 {
|
||||
return mask_in;
|
||||
@@ -3915,8 +3915,8 @@ fn fragment_main(sample_index : u32, mask_in : u32) -> u32 {
|
||||
|
||||
@stage(fragment)
|
||||
fn main() {
|
||||
let inner_result = fragment_main(bitcast<u32>(gl_SampleID), bitcast<u32>(gl_SampleMaskIn[0]));
|
||||
gl_SampleMask[0] = bitcast<i32>(inner_result);
|
||||
let inner_result = fragment_main(bitcast<u32>(gl_SampleID), bitcast<u32>(gl_SampleMaskIn[0i]));
|
||||
gl_SampleMask[0i] = bitcast<i32>(inner_result);
|
||||
}
|
||||
)";
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
#include "src/tint/utils/hash.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::DecomposeMemoryAccess);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::DecomposeMemoryAccess::Intrinsic);
|
||||
|
||||
@@ -63,7 +65,7 @@ struct OffsetExpr : Offset {
|
||||
auto* type = ctx.src->Sem().Get(expr)->Type()->UnwrapRef();
|
||||
auto* res = ctx.Clone(expr);
|
||||
if (!type->Is<sem::U32>()) {
|
||||
res = ctx.dst->Construct<ProgramBuilder::u32>(res);
|
||||
res = ctx.dst->Construct<u32>(res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -77,7 +79,7 @@ struct OffsetLiteral : Castable<OffsetLiteral, Offset> {
|
||||
explicit OffsetLiteral(uint32_t lit) : literal(lit) {}
|
||||
|
||||
const ast::Expression* Build(CloneContext& ctx) const override {
|
||||
return ctx.dst->Expr(literal);
|
||||
return ctx.dst->Expr(u32(literal));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -467,13 +469,13 @@ struct DecomposeMemoryAccess::State {
|
||||
// }
|
||||
auto load = LoadFunc(buf_ty, arr_ty->ElemType()->UnwrapRef(), var_user);
|
||||
auto* arr = b.Var(b.Symbols().New("arr"), CreateASTTypeFor(ctx, arr_ty));
|
||||
auto* i = b.Var(b.Symbols().New("i"), nullptr, b.Expr(0u));
|
||||
auto* i = b.Var(b.Symbols().New("i"), nullptr, b.Expr(0_u));
|
||||
auto* for_init = b.Decl(i);
|
||||
auto* for_cond = b.create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kLessThan, b.Expr(i), b.Expr(arr_ty->Count()));
|
||||
auto* for_cont = b.Assign(i, b.Add(i, 1u));
|
||||
ast::BinaryOp::kLessThan, b.Expr(i), b.Expr(u32(arr_ty->Count())));
|
||||
auto* for_cont = b.Assign(i, b.Add(i, 1_u));
|
||||
auto* arr_el = b.IndexAccessor(arr, i);
|
||||
auto* el_offset = b.Add(b.Expr("offset"), b.Mul(i, arr_ty->Stride()));
|
||||
auto* el_offset = b.Add(b.Expr("offset"), b.Mul(i, u32(arr_ty->Stride())));
|
||||
auto* el_val = b.Call(load, "buffer", el_offset);
|
||||
auto* for_loop =
|
||||
b.For(for_init, for_cond, for_cont, b.Block(b.Assign(arr_el, el_val)));
|
||||
@@ -490,12 +492,12 @@ struct DecomposeMemoryAccess::State {
|
||||
auto* vec_ty = mat_ty->ColumnType();
|
||||
Symbol load = LoadFunc(buf_ty, vec_ty, var_user);
|
||||
for (uint32_t i = 0; i < mat_ty->columns(); i++) {
|
||||
auto* offset = b.Add("offset", i * mat_ty->ColumnStride());
|
||||
auto* offset = b.Add("offset", u32(i * mat_ty->ColumnStride()));
|
||||
values.emplace_back(b.Call(load, "buffer", offset));
|
||||
}
|
||||
} else if (auto* str = el_ty->As<sem::Struct>()) {
|
||||
for (auto* member : str->Members()) {
|
||||
auto* offset = b.Add("offset", member->Offset());
|
||||
auto* offset = b.Add("offset", u32(member->Offset()));
|
||||
Symbol load = LoadFunc(buf_ty, member->Type()->UnwrapRef(), var_user);
|
||||
values.emplace_back(b.Call(load, "buffer", offset));
|
||||
}
|
||||
@@ -561,13 +563,13 @@ struct DecomposeMemoryAccess::State {
|
||||
// }
|
||||
auto* array = b.Var(b.Symbols().New("array"), nullptr, b.Expr("value"));
|
||||
auto store = StoreFunc(buf_ty, arr_ty->ElemType()->UnwrapRef(), var_user);
|
||||
auto* i = b.Var(b.Symbols().New("i"), nullptr, b.Expr(0u));
|
||||
auto* i = b.Var(b.Symbols().New("i"), nullptr, b.Expr(0_u));
|
||||
auto* for_init = b.Decl(i);
|
||||
auto* for_cond = b.create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kLessThan, b.Expr(i), b.Expr(arr_ty->Count()));
|
||||
auto* for_cont = b.Assign(i, b.Add(i, 1u));
|
||||
ast::BinaryOp::kLessThan, b.Expr(i), b.Expr(u32(arr_ty->Count())));
|
||||
auto* for_cont = b.Assign(i, b.Add(i, 1_u));
|
||||
auto* arr_el = b.IndexAccessor(array, i);
|
||||
auto* el_offset = b.Add(b.Expr("offset"), b.Mul(i, arr_ty->Stride()));
|
||||
auto* el_offset = b.Add(b.Expr("offset"), b.Mul(i, u32(arr_ty->Stride())));
|
||||
auto* store_stmt = b.CallStmt(b.Call(store, "buffer", el_offset, arr_el));
|
||||
auto* for_loop = b.For(for_init, for_cond, for_cont, b.Block(store_stmt));
|
||||
|
||||
@@ -576,14 +578,14 @@ struct DecomposeMemoryAccess::State {
|
||||
auto* vec_ty = mat_ty->ColumnType();
|
||||
Symbol store = StoreFunc(buf_ty, vec_ty, var_user);
|
||||
for (uint32_t i = 0; i < mat_ty->columns(); i++) {
|
||||
auto* offset = b.Add("offset", i * mat_ty->ColumnStride());
|
||||
auto* access = b.IndexAccessor("value", i);
|
||||
auto* offset = b.Add("offset", u32(i * mat_ty->ColumnStride()));
|
||||
auto* access = b.IndexAccessor("value", u32(i));
|
||||
auto* call = b.Call(store, "buffer", offset, access);
|
||||
body.emplace_back(b.CallStmt(call));
|
||||
}
|
||||
} else if (auto* str = el_ty->As<sem::Struct>()) {
|
||||
for (auto* member : str->Members()) {
|
||||
auto* offset = b.Add("offset", member->Offset());
|
||||
auto* offset = b.Add("offset", u32(member->Offset()));
|
||||
auto* access =
|
||||
b.MemberAccessor("value", ctx.Clone(member->Declaration()->symbol));
|
||||
Symbol store = StoreFunc(buf_ty, member->Type()->UnwrapRef(), var_user);
|
||||
|
||||
@@ -23,11 +23,12 @@
|
||||
#include "src/tint/transform/test_helper.h"
|
||||
#include "src/tint/transform/unshadow.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
namespace {
|
||||
|
||||
using DecomposeStridedArrayTest = TransformTest;
|
||||
using f32 = ProgramBuilder::f32;
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ShouldRunEmptyModule) {
|
||||
ProgramBuilder b;
|
||||
@@ -35,26 +36,26 @@ TEST_F(DecomposeStridedArrayTest, ShouldRunEmptyModule) {
|
||||
}
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ShouldRunNonStridedArray) {
|
||||
// var<private> arr : array<f32, 4>
|
||||
// var<private> arr : array<f32, 4u>
|
||||
|
||||
ProgramBuilder b;
|
||||
b.Global("arr", b.ty.array<f32, 4>(), ast::StorageClass::kPrivate);
|
||||
b.Global("arr", b.ty.array<f32, 4u>(), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(ShouldRun<DecomposeStridedArray>(Program(std::move(b))));
|
||||
}
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ShouldRunDefaultStridedArray) {
|
||||
// var<private> arr : @stride(4) array<f32, 4>
|
||||
// var<private> arr : @stride(4) array<f32, 4u>
|
||||
|
||||
ProgramBuilder b;
|
||||
b.Global("arr", b.ty.array<f32, 4>(4), ast::StorageClass::kPrivate);
|
||||
b.Global("arr", b.ty.array<f32, 4u>(4), ast::StorageClass::kPrivate);
|
||||
EXPECT_TRUE(ShouldRun<DecomposeStridedArray>(Program(std::move(b))));
|
||||
}
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ShouldRunExplicitStridedArray) {
|
||||
// var<private> arr : @stride(16) array<f32, 4>
|
||||
// var<private> arr : @stride(16) array<f32, 4u>
|
||||
|
||||
ProgramBuilder b;
|
||||
b.Global("arr", b.ty.array<f32, 4>(16), ast::StorageClass::kPrivate);
|
||||
b.Global("arr", b.ty.array<f32, 4u>(16), ast::StorageClass::kPrivate);
|
||||
EXPECT_TRUE(ShouldRun<DecomposeStridedArray>(Program(std::move(b))));
|
||||
}
|
||||
|
||||
@@ -68,33 +69,33 @@ TEST_F(DecomposeStridedArrayTest, Empty) {
|
||||
}
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, PrivateDefaultStridedArray) {
|
||||
// var<private> arr : @stride(4) array<f32, 4>
|
||||
// var<private> arr : @stride(4) array<f32, 4u>
|
||||
//
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let a : @stride(4) array<f32, 4> = a;
|
||||
// let a : @stride(4) array<f32, 4u> = a;
|
||||
// let b : f32 = arr[1];
|
||||
// }
|
||||
|
||||
ProgramBuilder b;
|
||||
b.Global("arr", b.ty.array<f32, 4>(4), ast::StorageClass::kPrivate);
|
||||
b.Global("arr", b.ty.array<f32, 4u>(4), ast::StorageClass::kPrivate);
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4>(4), b.Expr("arr"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor("arr", 1))),
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4u>(4), b.Expr("arr"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor("arr", 1_i))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
var<private> arr : array<f32, 4>;
|
||||
var<private> arr : array<f32, 4u>;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let a : array<f32, 4> = arr;
|
||||
let b : f32 = arr[1];
|
||||
let a : array<f32, 4u> = arr;
|
||||
let b : f32 = arr[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -104,24 +105,24 @@ fn f() {
|
||||
}
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, PrivateStridedArray) {
|
||||
// var<private> arr : @stride(32) array<f32, 4>
|
||||
// var<private> arr : @stride(32) array<f32, 4u>
|
||||
//
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let a : @stride(32) array<f32, 4> = a;
|
||||
// let a : @stride(32) array<f32, 4u> = a;
|
||||
// let b : f32 = arr[1];
|
||||
// }
|
||||
|
||||
ProgramBuilder b;
|
||||
b.Global("arr", b.ty.array<f32, 4>(32), ast::StorageClass::kPrivate);
|
||||
b.Global("arr", b.ty.array<f32, 4u>(32), ast::StorageClass::kPrivate);
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4>(32), b.Expr("arr"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor("arr", 1))),
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4u>(32), b.Expr("arr"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor("arr", 1_i))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@@ -130,12 +131,12 @@ struct strided_arr {
|
||||
el : f32,
|
||||
}
|
||||
|
||||
var<private> arr : array<strided_arr, 4>;
|
||||
var<private> arr : array<strided_arr, 4u>;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let a : array<strided_arr, 4> = arr;
|
||||
let b : f32 = arr[1].el;
|
||||
let a : array<strided_arr, 4u> = arr;
|
||||
let b : f32 = arr[1i].el;
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -146,26 +147,26 @@ fn f() {
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ReadUniformStridedArray) {
|
||||
// struct S {
|
||||
// a : @stride(32) array<f32, 4>,
|
||||
// a : @stride(32) array<f32, 4u>,
|
||||
// };
|
||||
// @group(0) @binding(0) var<uniform> s : S;
|
||||
//
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let a : @stride(32) array<f32, 4> = s.a;
|
||||
// let a : @stride(32) array<f32, 4u> = s.a;
|
||||
// let b : f32 = s.a[1];
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4>(32))});
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(32))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4>(32), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1))),
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4u>(32), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@@ -175,15 +176,15 @@ struct strided_arr {
|
||||
}
|
||||
|
||||
struct S {
|
||||
a : array<strided_arr, 4>,
|
||||
a : array<strided_arr, 4u>,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<uniform> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let a : array<strided_arr, 4> = s.a;
|
||||
let b : f32 = s.a[1].el;
|
||||
let a : array<strided_arr, 4u> = s.a;
|
||||
let b : f32 = s.a[1i].el;
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -194,41 +195,42 @@ fn f() {
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ReadUniformDefaultStridedArray) {
|
||||
// struct S {
|
||||
// a : @stride(16) array<vec4<f32>, 4>,
|
||||
// a : @stride(16) array<vec4<f32>, 4u>,
|
||||
// };
|
||||
// @group(0) @binding(0) var<uniform> s : S;
|
||||
//
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let a : @stride(16) array<vec4<f32>, 4> = s.a;
|
||||
// let a : @stride(16) array<vec4<f32>, 4u> = s.a;
|
||||
// let b : f32 = s.a[1][2];
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array(b.ty.vec4<f32>(), 4, 16))});
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array(b.ty.vec4<f32>(), 4_u, 16))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.array(b.ty.vec4<f32>(), 4, 16), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(),
|
||||
b.IndexAccessor(b.IndexAccessor(b.MemberAccessor("s", "a"), 1), 2))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
});
|
||||
b.Func(
|
||||
"f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.array(b.ty.vec4<f32>(), 4_u, 16), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(),
|
||||
b.IndexAccessor(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 2_i))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect =
|
||||
R"(
|
||||
struct S {
|
||||
a : array<vec4<f32>, 4>,
|
||||
a : array<vec4<f32>, 4u>,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<uniform> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let a : array<vec4<f32>, 4> = s.a;
|
||||
let b : f32 = s.a[1][2];
|
||||
let a : array<vec4<f32>, 4u> = s.a;
|
||||
let b : f32 = s.a[1i][2i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -239,26 +241,26 @@ fn f() {
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ReadStorageStridedArray) {
|
||||
// struct S {
|
||||
// a : @stride(32) array<f32, 4>,
|
||||
// a : @stride(32) array<f32, 4u>,
|
||||
// };
|
||||
// @group(0) @binding(0) var<storage> s : S;
|
||||
//
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let a : @stride(32) array<f32, 4> = s.a;
|
||||
// let a : @stride(32) array<f32, 4u> = s.a;
|
||||
// let b : f32 = s.a[1];
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4>(32))});
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(32))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4>(32), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1))),
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4u>(32), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@@ -268,15 +270,15 @@ struct strided_arr {
|
||||
}
|
||||
|
||||
struct S {
|
||||
a : array<strided_arr, 4>,
|
||||
a : array<strided_arr, 4u>,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<storage> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let a : array<strided_arr, 4> = s.a;
|
||||
let b : f32 = s.a[1].el;
|
||||
let a : array<strided_arr, 4u> = s.a;
|
||||
let b : f32 = s.a[1i].el;
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -287,39 +289,39 @@ fn f() {
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ReadStorageDefaultStridedArray) {
|
||||
// struct S {
|
||||
// a : @stride(4) array<f32, 4>,
|
||||
// a : @stride(4) array<f32, 4u>,
|
||||
// };
|
||||
// @group(0) @binding(0) var<storage> s : S;
|
||||
//
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let a : @stride(4) array<f32, 4> = s.a;
|
||||
// let a : @stride(4) array<f32, 4u> = s.a;
|
||||
// let b : f32 = s.a[1];
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4>(4))});
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(4))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4>(4), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1))),
|
||||
b.Decl(b.Let("a", b.ty.array<f32, 4u>(4), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
struct S {
|
||||
a : array<f32, 4>,
|
||||
a : array<f32, 4u>,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<storage> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let a : array<f32, 4> = s.a;
|
||||
let b : f32 = s.a[1];
|
||||
let a : array<f32, 4u> = s.a;
|
||||
let b : f32 = s.a[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -330,30 +332,30 @@ fn f() {
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, WriteStorageStridedArray) {
|
||||
// struct S {
|
||||
// a : @stride(32) array<f32, 4>,
|
||||
// a : @stride(32) array<f32, 4u>,
|
||||
// };
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
//
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// s.a = @stride(32) array<f32, 4>();
|
||||
// s.a = @stride(32) array<f32, 4>(1.0, 2.0, 3.0, 4.0);
|
||||
// s.a[1] = 5.0;
|
||||
// s.a = @stride(32) array<f32, 4u>();
|
||||
// s.a = @stride(32) array<f32, 4u>(1.0, 2.0, 3.0, 4.0);
|
||||
// s.a[1i] = 5.0;
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4>(32))});
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(32))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
|
||||
b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array<f32, 4>(32))),
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array<f32, 4u>(32))),
|
||||
b.Assign(b.MemberAccessor("s", "a"),
|
||||
b.Construct(b.ty.array<f32, 4>(32), 1.0f, 2.0f, 3.0f, 4.0f)),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1), 5.0f),
|
||||
b.Construct(b.ty.array<f32, 4u>(32), 1.0f, 2.0f, 3.0f, 4.0f)),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5.0f),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect =
|
||||
@@ -364,16 +366,16 @@ struct strided_arr {
|
||||
}
|
||||
|
||||
struct S {
|
||||
a : array<strided_arr, 4>,
|
||||
a : array<strided_arr, 4u>,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
s.a = array<strided_arr, 4>();
|
||||
s.a = array<strided_arr, 4>(strided_arr(1.0), strided_arr(2.0), strided_arr(3.0), strided_arr(4.0));
|
||||
s.a[1].el = 5.0;
|
||||
s.a = array<strided_arr, 4u>();
|
||||
s.a = array<strided_arr, 4u>(strided_arr(1.0), strided_arr(2.0), strided_arr(3.0), strided_arr(4.0));
|
||||
s.a[1i].el = 5.0;
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -384,45 +386,45 @@ fn f() {
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, WriteStorageDefaultStridedArray) {
|
||||
// struct S {
|
||||
// a : @stride(4) array<f32, 4>,
|
||||
// a : @stride(4) array<f32, 4u>,
|
||||
// };
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
//
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// s.a = @stride(4) array<f32, 4>();
|
||||
// s.a = @stride(4) array<f32, 4>(1.0, 2.0, 3.0, 4.0);
|
||||
// s.a = @stride(4) array<f32, 4u>();
|
||||
// s.a = @stride(4) array<f32, 4u>(1.0, 2.0, 3.0, 4.0);
|
||||
// s.a[1] = 5.0;
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4>(4))});
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(4))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
|
||||
b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array<f32, 4>(4))),
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array<f32, 4u>(4))),
|
||||
b.Assign(b.MemberAccessor("s", "a"),
|
||||
b.Construct(b.ty.array<f32, 4>(4), 1.0f, 2.0f, 3.0f, 4.0f)),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1), 5.0f),
|
||||
b.Construct(b.ty.array<f32, 4u>(4), 1.0f, 2.0f, 3.0f, 4.0f)),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5.0f),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect =
|
||||
R"(
|
||||
struct S {
|
||||
a : array<f32, 4>,
|
||||
a : array<f32, 4u>,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
s.a = array<f32, 4>();
|
||||
s.a = array<f32, 4>(1.0, 2.0, 3.0, 4.0);
|
||||
s.a[1] = 5.0;
|
||||
s.a = array<f32, 4u>();
|
||||
s.a = array<f32, 4u>(1.0, 2.0, 3.0, 4.0);
|
||||
s.a[1i] = 5.0;
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -433,7 +435,7 @@ fn f() {
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) {
|
||||
// struct S {
|
||||
// a : @stride(32) array<f32, 4>,
|
||||
// a : @stride(32) array<f32, 4u>,
|
||||
// };
|
||||
// @group(0) @binding(0) var<storage, read_write> s : S;
|
||||
//
|
||||
@@ -443,11 +445,11 @@ TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) {
|
||||
// let b = &*&*(a);
|
||||
// let c = *b;
|
||||
// let d = (*b)[1];
|
||||
// (*b) = @stride(32) array<f32, 4>(1.0, 2.0, 3.0, 4.0);
|
||||
// (*b) = @stride(32) array<f32, 4u>(1.0, 2.0, 3.0, 4.0);
|
||||
// (*b)[1] = 5.0;
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4>(32))});
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(32))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
|
||||
b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
@@ -455,13 +457,13 @@ TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) {
|
||||
b.Decl(b.Let("a", nullptr, b.AddressOf(b.MemberAccessor("s", "a")))),
|
||||
b.Decl(b.Let("b", nullptr, b.AddressOf(b.Deref(b.AddressOf(b.Deref("a")))))),
|
||||
b.Decl(b.Let("c", nullptr, b.Deref("b"))),
|
||||
b.Decl(b.Let("d", nullptr, b.IndexAccessor(b.Deref("b"), 1))),
|
||||
b.Assign(b.Deref("b"), b.Construct(b.ty.array<f32, 4>(32), 1.0f, 2.0f, 3.0f, 4.0f)),
|
||||
b.Assign(b.IndexAccessor(b.Deref("b"), 1), 5.0f),
|
||||
b.Decl(b.Let("d", nullptr, b.IndexAccessor(b.Deref("b"), 1_i))),
|
||||
b.Assign(b.Deref("b"), b.Construct(b.ty.array<f32, 4u>(32), 1.0f, 2.0f, 3.0f, 4.0f)),
|
||||
b.Assign(b.IndexAccessor(b.Deref("b"), 1_i), 5.0f),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect =
|
||||
@@ -472,17 +474,17 @@ struct strided_arr {
|
||||
}
|
||||
|
||||
struct S {
|
||||
a : array<strided_arr, 4>,
|
||||
a : array<strided_arr, 4u>,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let c = s.a;
|
||||
let d = s.a[1].el;
|
||||
s.a = array<strided_arr, 4>(strided_arr(1.0), strided_arr(2.0), strided_arr(3.0), strided_arr(4.0));
|
||||
s.a[1].el = 5.0;
|
||||
let d = s.a[1i].el;
|
||||
s.a = array<strided_arr, 4u>(strided_arr(1.0), strided_arr(2.0), strided_arr(3.0), strided_arr(4.0));
|
||||
s.a[1i].el = 5.0;
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -492,7 +494,7 @@ fn f() {
|
||||
}
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) {
|
||||
// type ARR = @stride(32) array<f32, 4>;
|
||||
// type ARR = @stride(32) array<f32, 4u>;
|
||||
// struct S {
|
||||
// a : ARR,
|
||||
// };
|
||||
@@ -507,22 +509,22 @@ TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) {
|
||||
// s.a[1] = 5.0;
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
b.Alias("ARR", b.ty.array<f32, 4>(32));
|
||||
b.Alias("ARR", b.ty.array<f32, 4u>(32));
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.type_name("ARR"))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
|
||||
b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.type_name("ARR"), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i))),
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.type_name("ARR"))),
|
||||
b.Assign(b.MemberAccessor("s", "a"),
|
||||
b.Construct(b.ty.type_name("ARR"), 1.0f, 2.0f, 3.0f, 4.0f)),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1), 5.0f),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5.0f),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@@ -531,7 +533,7 @@ struct strided_arr {
|
||||
el : f32,
|
||||
}
|
||||
|
||||
type ARR = array<strided_arr, 4>;
|
||||
type ARR = array<strided_arr, 4u>;
|
||||
|
||||
struct S {
|
||||
a : ARR,
|
||||
@@ -539,13 +541,13 @@ struct S {
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let a : ARR = s.a;
|
||||
let b : f32 = s.a[1].el;
|
||||
let b : f32 = s.a[1i].el;
|
||||
s.a = ARR();
|
||||
s.a = ARR(strided_arr(1.0), strided_arr(2.0), strided_arr(3.0), strided_arr(4.0));
|
||||
s.a[1].el = 5.0;
|
||||
s.a[1i].el = 5.0;
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -555,8 +557,8 @@ fn f() {
|
||||
}
|
||||
|
||||
TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) {
|
||||
// type ARR_A = @stride(8) array<f32, 2>;
|
||||
// type ARR_B = @stride(128) array<@stride(16) array<ARR_A, 3>, 4>;
|
||||
// type ARR_A = @stride(8) array<f32, 2u>;
|
||||
// type ARR_B = @stride(128) array<@stride(16) array<ARR_A, 3u>, 4u>;
|
||||
// struct S {
|
||||
// a : ARR_B,
|
||||
// };
|
||||
@@ -565,7 +567,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) {
|
||||
// @stage(compute) @workgroup_size(1)
|
||||
// fn f() {
|
||||
// let a : ARR_B = s.a;
|
||||
// let b : array<@stride(8) array<f32, 2>, 3> = s.a[3];
|
||||
// let b : array<@stride(8) array<f32, 2u>, 3u> = s.a[3];
|
||||
// let c = s.a[3][2];
|
||||
// let d = s.a[3][2][1];
|
||||
// s.a = ARR_B();
|
||||
@@ -575,46 +577,46 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) {
|
||||
ProgramBuilder b;
|
||||
b.Alias("ARR_A", b.ty.array<f32, 2>(8));
|
||||
b.Alias("ARR_B",
|
||||
b.ty.array( //
|
||||
b.ty.array(b.ty.type_name("ARR_A"), 3, 16), //
|
||||
4, 128));
|
||||
b.ty.array( //
|
||||
b.ty.array(b.ty.type_name("ARR_A"), 3_u, 16), //
|
||||
4_u, 128));
|
||||
auto* S = b.Structure("S", {b.Member("a", b.ty.type_name("ARR_B"))});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
|
||||
b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("a", b.ty.type_name("ARR_B"), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.array(b.ty.type_name("ARR_A"), 3, 16),
|
||||
b.Decl(b.Let("b", b.ty.array(b.ty.type_name("ARR_A"), 3_u, 16),
|
||||
b.IndexAccessor( //
|
||||
b.MemberAccessor("s", "a"), //
|
||||
3))),
|
||||
3_i))),
|
||||
b.Decl(b.Let("c", b.ty.type_name("ARR_A"),
|
||||
b.IndexAccessor( //
|
||||
b.IndexAccessor( //
|
||||
b.MemberAccessor("s", "a"), //
|
||||
3),
|
||||
2))),
|
||||
3_i),
|
||||
2_i))),
|
||||
b.Decl(b.Let("d", b.ty.f32(),
|
||||
b.IndexAccessor( //
|
||||
b.IndexAccessor( //
|
||||
b.IndexAccessor( //
|
||||
b.MemberAccessor("s", "a"), //
|
||||
3),
|
||||
2),
|
||||
1))),
|
||||
3_i),
|
||||
2_i),
|
||||
1_i))),
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.type_name("ARR_B"))),
|
||||
b.Assign(b.IndexAccessor( //
|
||||
b.IndexAccessor( //
|
||||
b.IndexAccessor( //
|
||||
b.MemberAccessor("s", "a"), //
|
||||
3),
|
||||
2),
|
||||
1),
|
||||
3_i),
|
||||
2_i),
|
||||
1_i),
|
||||
5.0f),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect =
|
||||
@@ -624,14 +626,14 @@ struct strided_arr {
|
||||
el : f32,
|
||||
}
|
||||
|
||||
type ARR_A = array<strided_arr, 2>;
|
||||
type ARR_A = array<strided_arr, 2u>;
|
||||
|
||||
struct strided_arr_1 {
|
||||
@size(128)
|
||||
el : array<ARR_A, 3>,
|
||||
el : array<ARR_A, 3u>,
|
||||
}
|
||||
|
||||
type ARR_B = array<strided_arr_1, 4>;
|
||||
type ARR_B = array<strided_arr_1, 4u>;
|
||||
|
||||
struct S {
|
||||
a : ARR_B,
|
||||
@@ -639,14 +641,14 @@ struct S {
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let a : ARR_B = s.a;
|
||||
let b : array<ARR_A, 3> = s.a[3].el;
|
||||
let c : ARR_A = s.a[3].el[2];
|
||||
let d : f32 = s.a[3].el[2][1].el;
|
||||
let b : array<ARR_A, 3u> = s.a[3i].el;
|
||||
let c : ARR_A = s.a[3i].el[2i];
|
||||
let d : f32 = s.a[3i].el[2i][1i].el;
|
||||
s.a = ARR_B();
|
||||
s.a[3].el[2][1].el = 5.0;
|
||||
s.a[3i].el[2i][1i].el = 5.0;
|
||||
}
|
||||
)";
|
||||
|
||||
|
||||
@@ -40,8 +40,7 @@ struct MatrixInfo {
|
||||
/// @returns a new ast::Array that holds an vector column for each row of the
|
||||
/// matrix.
|
||||
const ast::Array* array(ProgramBuilder* b) const {
|
||||
return b->ty.array(b->ty.vec<ProgramBuilder::f32>(matrix->rows()), matrix->columns(),
|
||||
stride);
|
||||
return b->ty.array(b->ty.vec<f32>(matrix->rows()), u32(matrix->columns()), stride);
|
||||
}
|
||||
|
||||
/// Equality operator
|
||||
@@ -172,7 +171,7 @@ void DecomposeStridedMatrix::Run(CloneContext& ctx, const DataMap&, DataMap&) co
|
||||
auto mat = ctx.dst->Sym("m");
|
||||
ast::ExpressionList columns(info.matrix->columns());
|
||||
for (uint32_t i = 0; i < static_cast<uint32_t>(columns.size()); i++) {
|
||||
columns[i] = ctx.dst->IndexAccessor(mat, i);
|
||||
columns[i] = ctx.dst->IndexAccessor(mat, u32(i));
|
||||
}
|
||||
ctx.dst->Func(name,
|
||||
{
|
||||
@@ -213,7 +212,7 @@ void DecomposeStridedMatrix::Run(CloneContext& ctx, const DataMap&, DataMap&) co
|
||||
auto arr = ctx.dst->Sym("arr");
|
||||
ast::ExpressionList columns(info.matrix->columns());
|
||||
for (uint32_t i = 0; i < static_cast<uint32_t>(columns.size()); i++) {
|
||||
columns[i] = ctx.dst->IndexAccessor(arr, i);
|
||||
columns[i] = ctx.dst->IndexAccessor(arr, u32(i));
|
||||
}
|
||||
ctx.dst->Func(name,
|
||||
{
|
||||
|
||||
@@ -24,11 +24,12 @@
|
||||
#include "src/tint/transform/test_helper.h"
|
||||
#include "src/tint/transform/unshadow.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
namespace {
|
||||
|
||||
using DecomposeStridedMatrixTest = TransformTest;
|
||||
using f32 = ProgramBuilder::f32;
|
||||
|
||||
TEST_F(DecomposeStridedMatrixTest, ShouldRunEmptyModule) {
|
||||
auto* src = R"()";
|
||||
@@ -82,7 +83,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix) {
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@@ -98,7 +99,7 @@ fn arr_to_mat2x2_stride_32(arr : @stride(32) array<vec2<f32>, 2u>) -> mat2x2<f32
|
||||
return mat2x2<f32>(arr[0u], arr[1u]);
|
||||
}
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let x : mat2x2<f32> = arr_to_mat2x2_stride_32(s.m);
|
||||
}
|
||||
@@ -132,14 +133,15 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformColumn) {
|
||||
}),
|
||||
});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("x", b.ty.vec2<f32>(), b.IndexAccessor(b.MemberAccessor("s", "m"), 1))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
});
|
||||
b.Func(
|
||||
"f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("x", b.ty.vec2<f32>(), b.IndexAccessor(b.MemberAccessor("s", "m"), 1_i))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
struct S {
|
||||
@@ -150,9 +152,9 @@ struct S {
|
||||
|
||||
@group(0) @binding(0) var<uniform> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let x : vec2<f32> = s.m[1];
|
||||
let x : vec2<f32> = s.m[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -190,7 +192,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix_DefaultStride) {
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@@ -203,7 +205,7 @@ struct S {
|
||||
|
||||
@group(0) @binding(0) var<uniform> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let x : mat2x2<f32> = s.m;
|
||||
}
|
||||
@@ -244,7 +246,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageMatrix) {
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@@ -260,7 +262,7 @@ fn arr_to_mat2x2_stride_32(arr : @stride(32) array<vec2<f32>, 2u>) -> mat2x2<f32
|
||||
return mat2x2<f32>(arr[0u], arr[1u]);
|
||||
}
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let x : mat2x2<f32> = arr_to_mat2x2_stride_32(s.m);
|
||||
}
|
||||
@@ -295,14 +297,15 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageColumn) {
|
||||
});
|
||||
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
|
||||
b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("x", b.ty.vec2<f32>(), b.IndexAccessor(b.MemberAccessor("s", "m"), 1))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
});
|
||||
b.Func(
|
||||
"f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Decl(b.Let("x", b.ty.vec2<f32>(), b.IndexAccessor(b.MemberAccessor("s", "m"), 1_i))),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
struct S {
|
||||
@@ -313,9 +316,9 @@ struct S {
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let x : vec2<f32> = s.m[1];
|
||||
let x : vec2<f32> = s.m[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -355,7 +358,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageMatrix) {
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@@ -371,7 +374,7 @@ fn mat2x2_stride_32_to_arr(m : mat2x2<f32>) -> @stride(32) array<vec2<f32>, 2u>
|
||||
return @stride(32) array<vec2<f32>, 2u>(m[0u], m[1u]);
|
||||
}
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
s.m = mat2x2_stride_32_to_arr(mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0)));
|
||||
}
|
||||
@@ -408,11 +411,11 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageColumn) {
|
||||
b.GroupAndBinding(0, 0));
|
||||
b.Func("f", {}, b.ty.void_(),
|
||||
{
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "m"), 1), b.vec2<f32>(1.0f, 2.0f)),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "m"), 1_i), b.vec2<f32>(1.0f, 2.0f)),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@@ -424,9 +427,9 @@ struct S {
|
||||
|
||||
@group(0) @binding(0) var<storage, read_write> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
s.m[1] = vec2<f32>(1.0, 2.0);
|
||||
s.m[1i] = vec2<f32>(1.0, 2.0);
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -471,14 +474,14 @@ TEST_F(DecomposeStridedMatrixTest, ReadWriteViaPointerLets) {
|
||||
b.Decl(b.Let("a", nullptr, b.AddressOf(b.MemberAccessor("s", "m")))),
|
||||
b.Decl(b.Let("b", nullptr, b.AddressOf(b.Deref(b.AddressOf(b.Deref("a")))))),
|
||||
b.Decl(b.Let("x", nullptr, b.Deref("b"))),
|
||||
b.Decl(b.Let("y", nullptr, b.IndexAccessor(b.Deref("b"), 1))),
|
||||
b.Decl(b.Let("z", nullptr, b.IndexAccessor("x", 1))),
|
||||
b.Decl(b.Let("y", nullptr, b.IndexAccessor(b.Deref("b"), 1_i))),
|
||||
b.Decl(b.Let("z", nullptr, b.IndexAccessor("x", 1_i))),
|
||||
b.Assign(b.Deref("b"), b.mat2x2<f32>(b.vec2<f32>(1.0f, 2.0f), b.vec2<f32>(3.0f, 4.0f))),
|
||||
b.Assign(b.IndexAccessor(b.Deref("b"), 1), b.vec2<f32>(5.0f, 6.0f)),
|
||||
b.Assign(b.IndexAccessor(b.Deref("b"), 1_i), b.vec2<f32>(5.0f, 6.0f)),
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@@ -498,13 +501,13 @@ fn mat2x2_stride_32_to_arr(m : mat2x2<f32>) -> @stride(32) array<vec2<f32>, 2u>
|
||||
return @stride(32) array<vec2<f32>, 2u>(m[0u], m[1u]);
|
||||
}
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let x = arr_to_mat2x2_stride_32(s.m);
|
||||
let y = s.m[1];
|
||||
let z = x[1];
|
||||
let y = s.m[1i];
|
||||
let z = x[1i];
|
||||
s.m = mat2x2_stride_32_to_arr(mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0)));
|
||||
s.m[1] = vec2<f32>(5.0, 6.0);
|
||||
s.m[1i] = vec2<f32>(5.0, 6.0);
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -542,7 +545,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadPrivateMatrix) {
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@@ -555,7 +558,7 @@ struct S {
|
||||
|
||||
var<private> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
let x : mat2x2<f32> = s.m;
|
||||
}
|
||||
@@ -596,7 +599,7 @@ TEST_F(DecomposeStridedMatrixTest, WritePrivateMatrix) {
|
||||
},
|
||||
{
|
||||
b.Stage(ast::PipelineStage::kCompute),
|
||||
b.WorkgroupSize(1),
|
||||
b.WorkgroupSize(1_i),
|
||||
});
|
||||
|
||||
auto* expect = R"(
|
||||
@@ -609,7 +612,7 @@ struct S {
|
||||
|
||||
var<private> s : S;
|
||||
|
||||
@stage(compute) @workgroup_size(1)
|
||||
@stage(compute) @workgroup_size(1i)
|
||||
fn f() {
|
||||
s.m = mat2x2<f32>(vec2<f32>(1.0, 2.0), vec2<f32>(3.0, 4.0));
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::ExpandCompoundAssignment);
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
|
||||
ExpandCompoundAssignment::ExpandCompoundAssignment() = default;
|
||||
@@ -172,8 +174,8 @@ void ExpandCompoundAssignment::Run(CloneContext& ctx, const DataMap&, DataMap&)
|
||||
auto* sem_lhs = ctx.src->Sem().Get(inc_dec->lhs);
|
||||
const ast::IntLiteralExpression* one =
|
||||
sem_lhs->Type()->UnwrapRef()->is_signed_integer_scalar()
|
||||
? ctx.dst->Expr(1)->As<ast::IntLiteralExpression>()
|
||||
: ctx.dst->Expr(1u)->As<ast::IntLiteralExpression>();
|
||||
? ctx.dst->Expr(1_i)->As<ast::IntLiteralExpression>()
|
||||
: ctx.dst->Expr(1_u)->As<ast::IntLiteralExpression>();
|
||||
auto op = inc_dec->increment ? ast::BinaryOp::kAdd : ast::BinaryOp::kSubtract;
|
||||
state.Expand(inc_dec, inc_dec->lhs, one, op);
|
||||
}
|
||||
|
||||
@@ -473,7 +473,7 @@ fn main() {
|
||||
auto* expect = R"(
|
||||
fn main() {
|
||||
var v : i32;
|
||||
v = (v + 1);
|
||||
v = (v + 1i);
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -513,7 +513,7 @@ fn main() {
|
||||
auto* expect = R"(
|
||||
fn main() {
|
||||
var v : i32;
|
||||
v = (v - 1);
|
||||
v = (v - 1i);
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -556,7 +556,7 @@ fn main() {
|
||||
var v : i32;
|
||||
let p = &(v);
|
||||
let tint_symbol = &(*(p));
|
||||
*(tint_symbol) = (*(tint_symbol) + 1);
|
||||
*(tint_symbol) = (*(tint_symbol) + 1i);
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -584,7 +584,7 @@ struct S {
|
||||
|
||||
fn main() {
|
||||
var s : S;
|
||||
s.m = (s.m + 1);
|
||||
s.m = (s.m + 1i);
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -617,7 +617,7 @@ fn idx() -> i32 {
|
||||
|
||||
fn main() {
|
||||
let tint_symbol = &(a[idx()]);
|
||||
*(tint_symbol) = (*(tint_symbol) + 1);
|
||||
*(tint_symbol) = (*(tint_symbol) + 1i);
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -651,7 +651,7 @@ fn idx() -> i32 {
|
||||
fn main() {
|
||||
let tint_symbol = &(v);
|
||||
let tint_symbol_1 = idx();
|
||||
(*(tint_symbol))[tint_symbol_1] = ((*(tint_symbol))[tint_symbol_1] + 1);
|
||||
(*(tint_symbol))[tint_symbol_1] = ((*(tint_symbol))[tint_symbol_1] + 1i);
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -671,7 +671,7 @@ fn main() {
|
||||
auto* expect = R"(
|
||||
fn main() {
|
||||
var v : vec4<i32>;
|
||||
v.y = (v.y + 1);
|
||||
v.y = (v.y + 1i);
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -727,7 +727,7 @@ fn main() {
|
||||
continuing {
|
||||
let tint_symbol = &(a[idx1()]);
|
||||
let tint_symbol_1 = idx2();
|
||||
(*(tint_symbol))[tint_symbol_1] = ((*(tint_symbol))[tint_symbol_1] + 1);
|
||||
(*(tint_symbol))[tint_symbol_1] = ((*(tint_symbol))[tint_symbol_1] + 1i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ fn f() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
var<private> a : i32 = 123;
|
||||
var<private> a : i32 = 123i;
|
||||
|
||||
var<private> b : u32 = 123u;
|
||||
|
||||
@@ -66,7 +66,7 @@ fn f() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
var<private> a : i32 = 123;
|
||||
var<private> a : i32 = 123i;
|
||||
|
||||
var<private> b : u32 = 123u;
|
||||
|
||||
@@ -95,7 +95,7 @@ fn f() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
var<private> a : i32 = 123;
|
||||
var<private> a : i32 = 123i;
|
||||
|
||||
var<private> b : u32 = 123u;
|
||||
|
||||
@@ -124,7 +124,7 @@ fn f() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
var<private> a : vec3<i32> = vec3<i32>(123);
|
||||
var<private> a : vec3<i32> = vec3<i32>(123i);
|
||||
|
||||
var<private> b : vec3<u32> = vec3<u32>(123u);
|
||||
|
||||
@@ -153,7 +153,7 @@ fn f() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
var<private> a : vec3<i32> = vec3<i32>(123);
|
||||
var<private> a : vec3<i32> = vec3<i32>(123i);
|
||||
|
||||
var<private> b : vec3<u32> = vec3<u32>(123u);
|
||||
|
||||
@@ -182,7 +182,7 @@ fn f() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
var<private> a : vec3<i32> = vec3<i32>(123);
|
||||
var<private> a : vec3<i32> = vec3<i32>(123i);
|
||||
|
||||
var<private> b : vec3<u32> = vec3<u32>(123u);
|
||||
|
||||
@@ -212,13 +212,13 @@ fn f() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
var<private> a : vec4<i32> = vec4<i32>(1, 2, 3, 4);
|
||||
var<private> a : vec4<i32> = vec4<i32>(1i, 2i, 3i, 4i);
|
||||
|
||||
var<private> b : vec4<i32> = vec4<i32>(1, 2, 4, 5);
|
||||
var<private> b : vec4<i32> = vec4<i32>(1i, 2i, 4i, 5i);
|
||||
|
||||
var<private> c : vec4<i32> = vec4<i32>(1, 2, 3, 4);
|
||||
var<private> c : vec4<i32> = vec4<i32>(1i, 2i, 3i, 4i);
|
||||
|
||||
var<private> d : vec4<i32> = vec4<i32>(1, 2, 3, 4);
|
||||
var<private> d : vec4<i32> = vec4<i32>(1i, 2i, 3i, 4i);
|
||||
|
||||
var<private> e : vec4<bool> = vec4<bool>(false, true, false, true);
|
||||
|
||||
@@ -243,7 +243,7 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : i32 = 123;
|
||||
var a : i32 = 123i;
|
||||
var b : u32 = 123u;
|
||||
var c : f32 = 123.0;
|
||||
var d : bool = true;
|
||||
@@ -267,7 +267,7 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : i32 = 123;
|
||||
var a : i32 = 123i;
|
||||
var b : u32 = 123u;
|
||||
var c : f32 = 123.0;
|
||||
var d : bool = true;
|
||||
@@ -291,7 +291,7 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : i32 = 123;
|
||||
var a : i32 = 123i;
|
||||
var b : u32 = 123u;
|
||||
var c : f32 = 123.0;
|
||||
var d : bool = true;
|
||||
@@ -306,7 +306,7 @@ fn f() {
|
||||
TEST_F(FoldConstantsTest, Function_Vector_NoConversion) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var a : vec3<i32> = vec3<i32>(123);
|
||||
var a : vec3<i32> = vec3<i32>(123i);
|
||||
var b : vec3<u32> = vec3<u32>(123u);
|
||||
var c : vec3<f32> = vec3<f32>(123.0);
|
||||
var d : vec3<bool> = vec3<bool>(true);
|
||||
@@ -315,7 +315,7 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : vec3<i32> = vec3<i32>(123);
|
||||
var a : vec3<i32> = vec3<i32>(123i);
|
||||
var b : vec3<u32> = vec3<u32>(123u);
|
||||
var c : vec3<f32> = vec3<f32>(123.0);
|
||||
var d : vec3<bool> = vec3<bool>(true);
|
||||
@@ -339,7 +339,7 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : vec3<i32> = vec3<i32>(123);
|
||||
var a : vec3<i32> = vec3<i32>(123i);
|
||||
var b : vec3<u32> = vec3<u32>(123u);
|
||||
var c : vec3<f32> = vec3<f32>(123.0);
|
||||
var d : vec3<bool> = vec3<bool>(true);
|
||||
@@ -363,7 +363,7 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : vec3<i32> = vec3<i32>(123);
|
||||
var a : vec3<i32> = vec3<i32>(123i);
|
||||
var b : vec3<u32> = vec3<u32>(123u);
|
||||
var c : vec3<f32> = vec3<f32>(123.0);
|
||||
var d : vec3<bool> = vec3<bool>(true);
|
||||
@@ -388,10 +388,10 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : vec4<i32> = vec4<i32>(1, 2, 3, 4);
|
||||
var b : vec4<i32> = vec4<i32>(1, 2, 4, 5);
|
||||
var c : vec4<i32> = vec4<i32>(1, 2, 3, 4);
|
||||
var d : vec4<i32> = vec4<i32>(1, 2, 3, 4);
|
||||
var a : vec4<i32> = vec4<i32>(1i, 2i, 3i, 4i);
|
||||
var b : vec4<i32> = vec4<i32>(1i, 2i, 4i, 5i);
|
||||
var c : vec4<i32> = vec4<i32>(1i, 2i, 3i, 4i);
|
||||
var d : vec4<i32> = vec4<i32>(1i, 2i, 3i, 4i);
|
||||
var e : vec4<bool> = vec4<bool>(false, true, false, true);
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::MultiplanarExternalTexture);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::MultiplanarExternalTexture::NewBindingPoints);
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
namespace {
|
||||
|
||||
@@ -261,7 +263,6 @@ struct MultiplanarExternalTexture::State {
|
||||
/// Creates the gammaCorrection function if needed and returns a call
|
||||
/// expression to it.
|
||||
void createGammaCorrectionFn() {
|
||||
using f32 = ProgramBuilder::f32;
|
||||
ast::VariableList varList = {b.Param("v", b.ty.vec3<f32>()),
|
||||
b.Param("params", b.ty.type_name(gamma_transfer_struct_sym))};
|
||||
|
||||
@@ -298,7 +299,6 @@ struct MultiplanarExternalTexture::State {
|
||||
/// @param call_type determines which function body to generate
|
||||
/// @returns a statement list that makes of the body of the chosen function
|
||||
ast::StatementList createTexFnExtStatementList(sem::BuiltinType call_type) {
|
||||
using f32 = ProgramBuilder::f32;
|
||||
const ast::CallExpression* single_plane_call = nullptr;
|
||||
const ast::CallExpression* plane_0_call = nullptr;
|
||||
const ast::CallExpression* plane_1_call = nullptr;
|
||||
@@ -311,11 +311,11 @@ struct MultiplanarExternalTexture::State {
|
||||
plane_1_call = b.Call("textureSampleLevel", "plane1", "smp", "coord", 0.0f);
|
||||
} else if (call_type == sem::BuiltinType::kTextureLoad) {
|
||||
// textureLoad(plane0, coords.xy, 0);
|
||||
single_plane_call = b.Call("textureLoad", "plane0", "coord", 0);
|
||||
single_plane_call = b.Call("textureLoad", "plane0", "coord", 0_i);
|
||||
// textureLoad(plane0, coords.xy, 0);
|
||||
plane_0_call = b.Call("textureLoad", "plane0", "coord", 0);
|
||||
plane_0_call = b.Call("textureLoad", "plane0", "coord", 0_i);
|
||||
// textureLoad(plane1, coords.xy, 0);
|
||||
plane_1_call = b.Call("textureLoad", "plane1", "coord", 0);
|
||||
plane_1_call = b.Call("textureLoad", "plane1", "coord", 0_i);
|
||||
} else {
|
||||
TINT_ICE(Transform, b.Diagnostics()) << "unhandled builtin: " << call_type;
|
||||
}
|
||||
@@ -325,7 +325,7 @@ struct MultiplanarExternalTexture::State {
|
||||
b.Decl(b.Var("color", b.ty.vec3(b.ty.f32()))),
|
||||
// if ((params.numPlanes == 1u))
|
||||
b.If(b.create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kEqual, b.MemberAccessor("params", "numPlanes"), b.Expr(1u)),
|
||||
ast::BinaryOp::kEqual, b.MemberAccessor("params", "numPlanes"), b.Expr(1_u)),
|
||||
b.Block(
|
||||
// color = textureLoad(plane0, coord, 0).rgb;
|
||||
b.Assign("color", b.MemberAccessor(single_plane_call, "rgb"))),
|
||||
|
||||
@@ -392,9 +392,9 @@ fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
color = textureLoad(plane0, coord, 0i).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
@@ -460,9 +460,9 @@ fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
color = textureLoad(plane0, coord, 0i).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
@@ -549,9 +549,9 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
color = textureLoad(plane0, coord, 0i).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
@@ -632,9 +632,9 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
color = textureLoad(plane0, coord, 0i).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::Robustness);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::Robustness::Config);
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
|
||||
/// State holds the current transform state
|
||||
@@ -59,7 +61,6 @@ struct Robustness::State {
|
||||
auto* ret_unwrapped = ret_type->UnwrapRef();
|
||||
|
||||
ProgramBuilder& b = *ctx.dst;
|
||||
using u32 = ProgramBuilder::u32;
|
||||
|
||||
struct Value {
|
||||
const ast::Expression* expr = nullptr; // If null, then is a constant
|
||||
@@ -103,7 +104,7 @@ struct Robustness::State {
|
||||
limit.is_signed = false; // Like size, limit is always unsigned.
|
||||
if (size.expr) {
|
||||
// Dynamic size
|
||||
limit.expr = b.Sub(size.expr, 1u);
|
||||
limit.expr = b.Sub(size.expr, 1_u);
|
||||
} else {
|
||||
// Constant size
|
||||
limit.u32 = size.u32 - 1u;
|
||||
@@ -158,10 +159,10 @@ struct Robustness::State {
|
||||
|
||||
// Convert idx and limit to expressions, so we can emit `min(idx, limit)`.
|
||||
if (!idx.expr) {
|
||||
idx.expr = b.Expr(idx.u32);
|
||||
idx.expr = b.Expr(u32(idx.u32));
|
||||
}
|
||||
if (!limit.expr) {
|
||||
limit.expr = b.Expr(limit.u32);
|
||||
limit.expr = b.Expr(u32(limit.u32));
|
||||
}
|
||||
|
||||
// Perform the clamp with `min(idx, limit)`
|
||||
@@ -182,8 +183,8 @@ struct Robustness::State {
|
||||
|
||||
// Convert idx to an expression, so we can emit the new accessor.
|
||||
if (!idx.expr) {
|
||||
idx.expr = idx.is_signed ? static_cast<const ast::Expression*>(b.Expr(idx.i32))
|
||||
: static_cast<const ast::Expression*>(b.Expr(idx.u32));
|
||||
idx.expr = idx.is_signed ? static_cast<const ast::Expression*>(b.Expr(i32(idx.i32)))
|
||||
: static_cast<const ast::Expression*>(b.Expr(u32(idx.u32)));
|
||||
}
|
||||
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
@@ -236,8 +237,8 @@ struct Robustness::State {
|
||||
level_arg = [&] {
|
||||
auto* arg = expr->args[level_idx];
|
||||
auto* num_levels = b.Call("textureNumLevels", ctx.Clone(texture_arg));
|
||||
auto* zero = b.Expr(0);
|
||||
auto* max = ctx.dst->Sub(num_levels, 1);
|
||||
auto* zero = b.Expr(0_i);
|
||||
auto* max = ctx.dst->Sub(num_levels, 1_i);
|
||||
auto* clamped = b.Call("clamp", ctx.Clone(arg), zero, max);
|
||||
return clamped;
|
||||
};
|
||||
@@ -250,7 +251,7 @@ struct Robustness::State {
|
||||
: b.Call("textureDimensions", ctx.Clone(texture_arg));
|
||||
auto* zero = b.Construct(CreateASTTypeFor(ctx, coords_ty));
|
||||
auto* max =
|
||||
ctx.dst->Sub(texture_dims, b.Construct(CreateASTTypeFor(ctx, coords_ty), 1));
|
||||
ctx.dst->Sub(texture_dims, b.Construct(CreateASTTypeFor(ctx, coords_ty), 1_i));
|
||||
auto* clamped_coords = b.Call("clamp", ctx.Clone(coords_arg), zero, max);
|
||||
ctx.Replace(coords_arg, clamped_coords);
|
||||
}
|
||||
@@ -259,8 +260,8 @@ struct Robustness::State {
|
||||
if (array_idx >= 0) {
|
||||
auto* arg = expr->args[array_idx];
|
||||
auto* num_layers = b.Call("textureNumLayers", ctx.Clone(texture_arg));
|
||||
auto* zero = b.Expr(0);
|
||||
auto* max = ctx.dst->Sub(num_layers, 1);
|
||||
auto* zero = b.Expr(0_i);
|
||||
auto* max = ctx.dst->Sub(num_layers, 1_i);
|
||||
auto* clamped = b.Call("clamp", ctx.Clone(arg), zero, max);
|
||||
ctx.Replace(arg, clamped);
|
||||
}
|
||||
@@ -268,7 +269,7 @@ struct Robustness::State {
|
||||
// Clamp the level argument, if provided
|
||||
if (level_idx >= 0) {
|
||||
auto* arg = expr->args[level_idx];
|
||||
ctx.Replace(arg, level_arg ? level_arg() : ctx.dst->Expr(0));
|
||||
ctx.Replace(arg, level_arg ? level_arg() : ctx.dst->Expr(0_i));
|
||||
}
|
||||
|
||||
return nullptr; // Clone, which will use the argument replacements above.
|
||||
|
||||
@@ -138,7 +138,7 @@ TEST_F(RobustnessTest, Array_Idx_Scalar) {
|
||||
var<private> a : array<f32, 3>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[1];
|
||||
var b : f32 = a[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -146,7 +146,7 @@ fn f() {
|
||||
var<private> a : array<f32, 3>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[1];
|
||||
var b : f32 = a[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -158,7 +158,7 @@ fn f() {
|
||||
TEST_F(RobustnessTest, Array_Idx_Scalar_OutOfOrder) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[1];
|
||||
var b : f32 = a[1i];
|
||||
}
|
||||
|
||||
var<private> a : array<f32, 3>;
|
||||
@@ -166,7 +166,7 @@ var<private> a : array<f32, 3>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[1];
|
||||
var b : f32 = a[1i];
|
||||
}
|
||||
|
||||
var<private> a : array<f32, 3>;
|
||||
@@ -242,7 +242,7 @@ fn f() {
|
||||
var<private> a : array<f32, 3>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[0];
|
||||
var b : f32 = a[0i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -262,7 +262,7 @@ var<private> a : array<f32, 3>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[0];
|
||||
var b : f32 = a[0i];
|
||||
}
|
||||
|
||||
var<private> a : array<f32, 3>;
|
||||
@@ -286,7 +286,7 @@ fn f() {
|
||||
var<private> a : array<f32, 3>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[2];
|
||||
var b : f32 = a[2i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -306,7 +306,7 @@ var<private> a : array<f32, 3>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[2];
|
||||
var b : f32 = a[2i];
|
||||
}
|
||||
|
||||
var<private> a : array<f32, 3>;
|
||||
@@ -402,7 +402,7 @@ TEST_F(RobustnessTest, Vector_Idx_Scalar) {
|
||||
var<private> a : vec3<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[1];
|
||||
var b : f32 = a[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -410,7 +410,7 @@ fn f() {
|
||||
var<private> a : vec3<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[1];
|
||||
var b : f32 = a[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -422,7 +422,7 @@ fn f() {
|
||||
TEST_F(RobustnessTest, Vector_Idx_Scalar_OutOfOrder) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[1];
|
||||
var b : f32 = a[1i];
|
||||
}
|
||||
|
||||
var<private> a : vec3<f32>;
|
||||
@@ -430,7 +430,7 @@ var<private> a : vec3<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[1];
|
||||
var b : f32 = a[1i];
|
||||
}
|
||||
|
||||
var<private> a : vec3<f32>;
|
||||
@@ -506,7 +506,7 @@ fn f() {
|
||||
var<private> a : vec3<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a.xy[1];
|
||||
var b : f32 = a.xy[1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -526,7 +526,7 @@ var<private> a : vec3<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a.xy[1];
|
||||
var b : f32 = a.xy[1i];
|
||||
}
|
||||
|
||||
var<private> a : vec3<f32>;
|
||||
@@ -654,7 +654,7 @@ fn f() {
|
||||
var<private> a : vec3<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[0];
|
||||
var b : f32 = a[0i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -674,7 +674,7 @@ var<private> a : vec3<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[0];
|
||||
var b : f32 = a[0i];
|
||||
}
|
||||
|
||||
var<private> a : vec3<f32>;
|
||||
@@ -698,7 +698,7 @@ fn f() {
|
||||
var<private> a : vec3<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[2];
|
||||
var b : f32 = a[2i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -718,7 +718,7 @@ var<private> a : vec3<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[2];
|
||||
var b : f32 = a[2i];
|
||||
}
|
||||
|
||||
var<private> a : vec3<f32>;
|
||||
@@ -734,7 +734,7 @@ TEST_F(RobustnessTest, Matrix_Idx_Scalar) {
|
||||
var<private> a : mat3x2<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[2][1];
|
||||
var b : f32 = a[2i][1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -742,7 +742,7 @@ fn f() {
|
||||
var<private> a : mat3x2<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[2][1];
|
||||
var b : f32 = a[2i][1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -754,7 +754,7 @@ fn f() {
|
||||
TEST_F(RobustnessTest, Matrix_Idx_Scalar_OutOfOrder) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[2][1];
|
||||
var b : f32 = a[2i][1i];
|
||||
}
|
||||
|
||||
var<private> a : mat3x2<f32>;
|
||||
@@ -762,7 +762,7 @@ var<private> a : mat3x2<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[2][1];
|
||||
var b : f32 = a[2i][1i];
|
||||
}
|
||||
|
||||
var<private> a : mat3x2<f32>;
|
||||
@@ -790,7 +790,7 @@ var<private> a : mat3x2<f32>;
|
||||
var<private> c : i32;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[min(u32(((c + 2) - 3)), 2u)][1];
|
||||
var b : f32 = a[min(u32(((c + 2) - 3)), 2u)][1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -812,7 +812,7 @@ var<private> a : mat3x2<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[min(u32(((c + 2) - 3)), 2u)][1];
|
||||
var b : f32 = a[min(u32(((c + 2) - 3)), 2u)][1i];
|
||||
}
|
||||
|
||||
var<private> c : i32;
|
||||
@@ -842,7 +842,7 @@ var<private> a : mat3x2<f32>;
|
||||
var<private> c : i32;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[1][min(u32(((c + 2) - 3)), 1u)];
|
||||
var b : f32 = a[1i][min(u32(((c + 2) - 3)), 1u)];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -864,7 +864,7 @@ var<private> a : mat3x2<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[1][min(u32(((c + 2) - 3)), 1u)];
|
||||
var b : f32 = a[1i][min(u32(((c + 2) - 3)), 1u)];
|
||||
}
|
||||
|
||||
var<private> c : i32;
|
||||
@@ -890,7 +890,7 @@ fn f() {
|
||||
var<private> a : mat3x2<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[0][1];
|
||||
var b : f32 = a[0i][1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -910,7 +910,7 @@ var<private> a : mat3x2<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[0][1];
|
||||
var b : f32 = a[0i][1i];
|
||||
}
|
||||
|
||||
var<private> a : mat3x2<f32>;
|
||||
@@ -934,7 +934,7 @@ fn f() {
|
||||
var<private> a : mat3x2<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[2][0];
|
||||
var b : f32 = a[2i][0i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -954,7 +954,7 @@ var<private> a : mat3x2<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[2][0];
|
||||
var b : f32 = a[2i][0i];
|
||||
}
|
||||
|
||||
var<private> a : mat3x2<f32>;
|
||||
@@ -978,7 +978,7 @@ fn f() {
|
||||
var<private> a : mat3x2<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[2][1];
|
||||
var b : f32 = a[2i][1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -998,7 +998,7 @@ var<private> a : mat3x2<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[2][1];
|
||||
var b : f32 = a[2i][1i];
|
||||
}
|
||||
|
||||
var<private> a : mat3x2<f32>;
|
||||
@@ -1022,7 +1022,7 @@ fn f() {
|
||||
var<private> a : mat3x2<f32>;
|
||||
|
||||
fn f() {
|
||||
var b : f32 = a[2][1];
|
||||
var b : f32 = a[2i][1i];
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -1042,7 +1042,7 @@ var<private> a : mat3x2<f32>;
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var b : f32 = a[2][1];
|
||||
var b : f32 = a[2i][1i];
|
||||
}
|
||||
|
||||
var<private> a : mat3x2<f32>;
|
||||
@@ -1202,14 +1202,14 @@ fn f() {
|
||||
var array_idx : i32;
|
||||
var level_idx : i32;
|
||||
var sample_idx : i32;
|
||||
textureLoad(tex_1d, clamp(1, i32(), (textureDimensions(tex_1d, clamp(level_idx, 0, (textureNumLevels(tex_1d) - 1))) - i32(1))), clamp(level_idx, 0, (textureNumLevels(tex_1d) - 1)));
|
||||
textureLoad(tex_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d, clamp(level_idx, 0, (textureNumLevels(tex_2d) - 1))) - vec2<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_2d) - 1)));
|
||||
textureLoad(tex_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d_arr, clamp(level_idx, 0, (textureNumLevels(tex_2d_arr) - 1))) - vec2<i32>(1))), clamp(array_idx, 0, (textureNumLayers(tex_2d_arr) - 1)), clamp(level_idx, 0, (textureNumLevels(tex_2d_arr) - 1)));
|
||||
textureLoad(tex_3d, clamp(vec3<i32>(1, 2, 3), vec3<i32>(), (textureDimensions(tex_3d, clamp(level_idx, 0, (textureNumLevels(tex_3d) - 1))) - vec3<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_3d) - 1)));
|
||||
textureLoad(tex_ms_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_ms_2d) - vec2<i32>(1))), sample_idx);
|
||||
textureLoad(tex_depth_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d, clamp(level_idx, 0, (textureNumLevels(tex_depth_2d) - 1))) - vec2<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_depth_2d) - 1)));
|
||||
textureLoad(tex_depth_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d_arr, clamp(level_idx, 0, (textureNumLevels(tex_depth_2d_arr) - 1))) - vec2<i32>(1))), clamp(array_idx, 0, (textureNumLayers(tex_depth_2d_arr) - 1)), clamp(level_idx, 0, (textureNumLevels(tex_depth_2d_arr) - 1)));
|
||||
textureLoad(tex_external, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_external) - vec2<i32>(1))));
|
||||
textureLoad(tex_1d, clamp(1, i32(), (textureDimensions(tex_1d, clamp(level_idx, 0i, (textureNumLevels(tex_1d) - 1i))) - i32(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_1d) - 1i)));
|
||||
textureLoad(tex_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d, clamp(level_idx, 0i, (textureNumLevels(tex_2d) - 1i))) - vec2<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_2d) - 1i)));
|
||||
textureLoad(tex_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d_arr, clamp(level_idx, 0i, (textureNumLevels(tex_2d_arr) - 1i))) - vec2<i32>(1i))), clamp(array_idx, 0i, (textureNumLayers(tex_2d_arr) - 1i)), clamp(level_idx, 0i, (textureNumLevels(tex_2d_arr) - 1i)));
|
||||
textureLoad(tex_3d, clamp(vec3<i32>(1, 2, 3), vec3<i32>(), (textureDimensions(tex_3d, clamp(level_idx, 0i, (textureNumLevels(tex_3d) - 1i))) - vec3<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_3d) - 1i)));
|
||||
textureLoad(tex_ms_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_ms_2d) - vec2<i32>(1i))), sample_idx);
|
||||
textureLoad(tex_depth_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d, clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d) - 1i))) - vec2<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d) - 1i)));
|
||||
textureLoad(tex_depth_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d_arr, clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d_arr) - 1i))) - vec2<i32>(1i))), clamp(array_idx, 0i, (textureNumLayers(tex_depth_2d_arr) - 1i)), clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d_arr) - 1i)));
|
||||
textureLoad(tex_external, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_external) - vec2<i32>(1i))));
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -1252,14 +1252,14 @@ fn f() {
|
||||
var array_idx : i32;
|
||||
var level_idx : i32;
|
||||
var sample_idx : i32;
|
||||
textureLoad(tex_1d, clamp(1, i32(), (textureDimensions(tex_1d, clamp(level_idx, 0, (textureNumLevels(tex_1d) - 1))) - i32(1))), clamp(level_idx, 0, (textureNumLevels(tex_1d) - 1)));
|
||||
textureLoad(tex_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d, clamp(level_idx, 0, (textureNumLevels(tex_2d) - 1))) - vec2<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_2d) - 1)));
|
||||
textureLoad(tex_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d_arr, clamp(level_idx, 0, (textureNumLevels(tex_2d_arr) - 1))) - vec2<i32>(1))), clamp(array_idx, 0, (textureNumLayers(tex_2d_arr) - 1)), clamp(level_idx, 0, (textureNumLevels(tex_2d_arr) - 1)));
|
||||
textureLoad(tex_3d, clamp(vec3<i32>(1, 2, 3), vec3<i32>(), (textureDimensions(tex_3d, clamp(level_idx, 0, (textureNumLevels(tex_3d) - 1))) - vec3<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_3d) - 1)));
|
||||
textureLoad(tex_ms_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_ms_2d) - vec2<i32>(1))), sample_idx);
|
||||
textureLoad(tex_depth_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d, clamp(level_idx, 0, (textureNumLevels(tex_depth_2d) - 1))) - vec2<i32>(1))), clamp(level_idx, 0, (textureNumLevels(tex_depth_2d) - 1)));
|
||||
textureLoad(tex_depth_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d_arr, clamp(level_idx, 0, (textureNumLevels(tex_depth_2d_arr) - 1))) - vec2<i32>(1))), clamp(array_idx, 0, (textureNumLayers(tex_depth_2d_arr) - 1)), clamp(level_idx, 0, (textureNumLevels(tex_depth_2d_arr) - 1)));
|
||||
textureLoad(tex_external, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_external) - vec2<i32>(1))));
|
||||
textureLoad(tex_1d, clamp(1, i32(), (textureDimensions(tex_1d, clamp(level_idx, 0i, (textureNumLevels(tex_1d) - 1i))) - i32(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_1d) - 1i)));
|
||||
textureLoad(tex_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d, clamp(level_idx, 0i, (textureNumLevels(tex_2d) - 1i))) - vec2<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_2d) - 1i)));
|
||||
textureLoad(tex_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d_arr, clamp(level_idx, 0i, (textureNumLevels(tex_2d_arr) - 1i))) - vec2<i32>(1i))), clamp(array_idx, 0i, (textureNumLayers(tex_2d_arr) - 1i)), clamp(level_idx, 0i, (textureNumLevels(tex_2d_arr) - 1i)));
|
||||
textureLoad(tex_3d, clamp(vec3<i32>(1, 2, 3), vec3<i32>(), (textureDimensions(tex_3d, clamp(level_idx, 0i, (textureNumLevels(tex_3d) - 1i))) - vec3<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_3d) - 1i)));
|
||||
textureLoad(tex_ms_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_ms_2d) - vec2<i32>(1i))), sample_idx);
|
||||
textureLoad(tex_depth_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d, clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d) - 1i))) - vec2<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d) - 1i)));
|
||||
textureLoad(tex_depth_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d_arr, clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d_arr) - 1i))) - vec2<i32>(1i))), clamp(array_idx, 0i, (textureNumLayers(tex_depth_2d_arr) - 1i)), clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d_arr) - 1i)));
|
||||
textureLoad(tex_external, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_external) - vec2<i32>(1i))));
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var tex_1d : texture_1d<f32>;
|
||||
@@ -1313,10 +1313,10 @@ fn f() {
|
||||
@group(0) @binding(3) var tex3d : texture_storage_3d<rgba8sint, write>;
|
||||
|
||||
fn f() {
|
||||
textureStore(tex1d, clamp(10, i32(), (textureDimensions(tex1d) - i32(1))), vec4<i32>());
|
||||
textureStore(tex2d, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d) - vec2<i32>(1))), vec4<i32>());
|
||||
textureStore(tex2d_arr, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d_arr) - vec2<i32>(1))), clamp(50, 0, (textureNumLayers(tex2d_arr) - 1)), vec4<i32>());
|
||||
textureStore(tex3d, clamp(vec3<i32>(10, 20, 30), vec3<i32>(), (textureDimensions(tex3d) - vec3<i32>(1))), vec4<i32>());
|
||||
textureStore(tex1d, clamp(10, i32(), (textureDimensions(tex1d) - i32(1i))), vec4<i32>());
|
||||
textureStore(tex2d, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d) - vec2<i32>(1i))), vec4<i32>());
|
||||
textureStore(tex2d_arr, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d_arr) - vec2<i32>(1i))), clamp(50, 0i, (textureNumLayers(tex2d_arr) - 1i)), vec4<i32>());
|
||||
textureStore(tex3d, clamp(vec3<i32>(10, 20, 30), vec3<i32>(), (textureDimensions(tex3d) - vec3<i32>(1i))), vec4<i32>());
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -1347,10 +1347,10 @@ fn f() {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
textureStore(tex1d, clamp(10, i32(), (textureDimensions(tex1d) - i32(1))), vec4<i32>());
|
||||
textureStore(tex2d, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d) - vec2<i32>(1))), vec4<i32>());
|
||||
textureStore(tex2d_arr, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d_arr) - vec2<i32>(1))), clamp(50, 0, (textureNumLayers(tex2d_arr) - 1)), vec4<i32>());
|
||||
textureStore(tex3d, clamp(vec3<i32>(10, 20, 30), vec3<i32>(), (textureDimensions(tex3d) - vec3<i32>(1))), vec4<i32>());
|
||||
textureStore(tex1d, clamp(10, i32(), (textureDimensions(tex1d) - i32(1i))), vec4<i32>());
|
||||
textureStore(tex2d, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d) - vec2<i32>(1i))), vec4<i32>());
|
||||
textureStore(tex2d_arr, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d_arr) - vec2<i32>(1i))), clamp(50, 0i, (textureNumLayers(tex2d_arr) - 1i)), vec4<i32>());
|
||||
textureStore(tex3d, clamp(vec3<i32>(10, 20, 30), vec3<i32>(), (textureDimensions(tex3d) - vec3<i32>(1i))), vec4<i32>());
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var tex1d : texture_storage_1d<rgba8sint, write>;
|
||||
@@ -1498,21 +1498,21 @@ struct U {
|
||||
@group(1) @binding(0) var<uniform> u : U;
|
||||
|
||||
fn f() {
|
||||
var i32_sa1 : f32 = s.a[3];
|
||||
var i32_sa2 : f32 = s.a[1];
|
||||
var i32_sa3 : f32 = s.a[0];
|
||||
var i32_sa4 : f32 = s.a[0];
|
||||
var i32_sa5 : f32 = s.a[0];
|
||||
var i32_sa1 : f32 = s.a[3i];
|
||||
var i32_sa2 : f32 = s.a[1i];
|
||||
var i32_sa3 : f32 = s.a[0i];
|
||||
var i32_sa4 : f32 = s.a[0i];
|
||||
var i32_sa5 : f32 = s.a[0i];
|
||||
var i32_sb1 : f32 = s.b[min(4u, (arrayLength(&(s.b)) - 1u))];
|
||||
var i32_sb2 : f32 = s.b[min(1u, (arrayLength(&(s.b)) - 1u))];
|
||||
var i32_sb3 : f32 = s.b[min(0u, (arrayLength(&(s.b)) - 1u))];
|
||||
var i32_sb4 : f32 = s.b[min(0u, (arrayLength(&(s.b)) - 1u))];
|
||||
var i32_sb5 : f32 = s.b[min(0u, (arrayLength(&(s.b)) - 1u))];
|
||||
var i32_ua1 : f32 = u.a[3].x;
|
||||
var i32_ua2 : f32 = u.a[1].x;
|
||||
var i32_ua3 : f32 = u.a[0].x;
|
||||
var i32_ua4 : f32 = u.a[0].x;
|
||||
var i32_ua5 : f32 = u.a[0].x;
|
||||
var i32_ua1 : f32 = u.a[3i].x;
|
||||
var i32_ua2 : f32 = u.a[1i].x;
|
||||
var i32_ua3 : f32 = u.a[0i].x;
|
||||
var i32_ua4 : f32 = u.a[0i].x;
|
||||
var i32_ua5 : f32 = u.a[0i].x;
|
||||
var u32_sa1 : f32 = s.a[0u];
|
||||
var u32_sa2 : f32 = s.a[1u];
|
||||
var u32_sa3 : f32 = s.a[3u];
|
||||
@@ -1571,11 +1571,11 @@ fn f() {
|
||||
var i32_sb3 : f32 = s.b[0];
|
||||
var i32_sb4 : f32 = s.b[-1];
|
||||
var i32_sb5 : f32 = s.b[-4];
|
||||
var i32_ua1 : f32 = u.a[3].x;
|
||||
var i32_ua2 : f32 = u.a[1].x;
|
||||
var i32_ua3 : f32 = u.a[0].x;
|
||||
var i32_ua4 : f32 = u.a[0].x;
|
||||
var i32_ua5 : f32 = u.a[0].x;
|
||||
var i32_ua1 : f32 = u.a[3i].x;
|
||||
var i32_ua2 : f32 = u.a[1i].x;
|
||||
var i32_ua3 : f32 = u.a[0i].x;
|
||||
var i32_ua4 : f32 = u.a[0i].x;
|
||||
var i32_ua5 : f32 = u.a[0i].x;
|
||||
var u32_sa1 : f32 = s.a[0u];
|
||||
var u32_sa2 : f32 = s.a[1u];
|
||||
var u32_sa3 : f32 = s.a[3u];
|
||||
@@ -1626,11 +1626,11 @@ struct U {
|
||||
@group(1) @binding(0) var<uniform> u : U;
|
||||
|
||||
fn f() {
|
||||
var i32_sa1 : f32 = s.a[3];
|
||||
var i32_sa2 : f32 = s.a[1];
|
||||
var i32_sa3 : f32 = s.a[0];
|
||||
var i32_sa4 : f32 = s.a[0];
|
||||
var i32_sa5 : f32 = s.a[0];
|
||||
var i32_sa1 : f32 = s.a[3i];
|
||||
var i32_sa2 : f32 = s.a[1i];
|
||||
var i32_sa3 : f32 = s.a[0i];
|
||||
var i32_sa4 : f32 = s.a[0i];
|
||||
var i32_sa5 : f32 = s.a[0i];
|
||||
var i32_sb1 : f32 = s.b[min(4u, (arrayLength(&(s.b)) - 1u))];
|
||||
var i32_sb2 : f32 = s.b[min(1u, (arrayLength(&(s.b)) - 1u))];
|
||||
var i32_sb3 : f32 = s.b[min(0u, (arrayLength(&(s.b)) - 1u))];
|
||||
|
||||
@@ -110,7 +110,7 @@ const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const sem::Type*
|
||||
if (a->IsRuntimeSized()) {
|
||||
return ctx.dst->ty.array(el, nullptr, std::move(attrs));
|
||||
} else {
|
||||
return ctx.dst->ty.array(el, a->Count(), std::move(attrs));
|
||||
return ctx.dst->ty.array(el, u32(a->Count()), std::move(attrs));
|
||||
}
|
||||
}
|
||||
if (auto* s = ty->As<sem::Struct>()) {
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "src/tint/transform/test_helper.h"
|
||||
#include "src/tint/transform/utils/get_insertion_point.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
namespace {
|
||||
|
||||
@@ -27,10 +29,10 @@ using GetInsertionPointTest = ::testing::Test;
|
||||
|
||||
TEST_F(GetInsertionPointTest, Block) {
|
||||
// fn f() {
|
||||
// var a = 1;
|
||||
// var a = 1i;
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* expr = b.Expr(1);
|
||||
auto* expr = b.Expr(1_i);
|
||||
auto* var = b.Decl(b.Var("a", nullptr, expr));
|
||||
auto* block = b.Block(var);
|
||||
b.Func("f", {}, b.ty.void_(), {block});
|
||||
@@ -48,11 +50,11 @@ TEST_F(GetInsertionPointTest, Block) {
|
||||
|
||||
TEST_F(GetInsertionPointTest, ForLoopInit) {
|
||||
// fn f() {
|
||||
// for(var a = 1; true; ) {
|
||||
// for(var a = 1i; true; ) {
|
||||
// }
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* expr = b.Expr(1);
|
||||
auto* expr = b.Expr(1_i);
|
||||
auto* var = b.Decl(b.Var("a", nullptr, expr));
|
||||
auto* fl = b.For(var, b.Expr(true), {}, b.Block());
|
||||
auto* func_block = b.Block(fl);
|
||||
@@ -70,11 +72,11 @@ TEST_F(GetInsertionPointTest, ForLoopInit) {
|
||||
|
||||
TEST_F(GetInsertionPointTest, ForLoopCont_Invalid) {
|
||||
// fn f() {
|
||||
// for(; true; var a = 1) {
|
||||
// for(; true; var a = 1i) {
|
||||
// }
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* expr = b.Expr(1);
|
||||
auto* expr = b.Expr(1_i);
|
||||
auto* var = b.Decl(b.Var("a", nullptr, expr));
|
||||
auto* s = b.For({}, b.Expr(true), var, b.Block());
|
||||
b.Func("f", {}, b.ty.void_(), {s});
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "src/tint/transform/test_helper.h"
|
||||
#include "src/tint/transform/utils/hoist_to_decl_before.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
namespace {
|
||||
|
||||
@@ -31,7 +33,7 @@ TEST_F(HoistToDeclBeforeTest, VarInit) {
|
||||
// var a = 1;
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* expr = b.Expr(1);
|
||||
auto* expr = b.Expr(1_i);
|
||||
auto* var = b.Decl(b.Var("a", nullptr, expr));
|
||||
b.Func("f", {}, b.ty.void_(), {var});
|
||||
|
||||
@@ -49,7 +51,7 @@ TEST_F(HoistToDeclBeforeTest, VarInit) {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
let tint_symbol = 1;
|
||||
let tint_symbol = 1i;
|
||||
var a = tint_symbol;
|
||||
}
|
||||
)";
|
||||
@@ -59,11 +61,11 @@ fn f() {
|
||||
|
||||
TEST_F(HoistToDeclBeforeTest, ForLoopInit) {
|
||||
// fn f() {
|
||||
// for(var a = 1; true; ) {
|
||||
// for(var a = 1i; true; ) {
|
||||
// }
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* expr = b.Expr(1);
|
||||
auto* expr = b.Expr(1_i);
|
||||
auto* s = b.For(b.Decl(b.Var("a", nullptr, expr)), b.Expr(true), {}, b.Block());
|
||||
b.Func("f", {}, b.ty.void_(), {s});
|
||||
|
||||
@@ -81,7 +83,7 @@ TEST_F(HoistToDeclBeforeTest, ForLoopInit) {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
let tint_symbol = 1;
|
||||
let tint_symbol = 1i;
|
||||
for(var a = tint_symbol; true; ) {
|
||||
}
|
||||
}
|
||||
@@ -133,11 +135,11 @@ fn f() {
|
||||
|
||||
TEST_F(HoistToDeclBeforeTest, ForLoopCont) {
|
||||
// fn f() {
|
||||
// for(; true; var a = 1) {
|
||||
// for(; true; var a = 1i) {
|
||||
// }
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* expr = b.Expr(1);
|
||||
auto* expr = b.Expr(1_i);
|
||||
auto* s = b.For({}, b.Expr(true), b.Decl(b.Var("a", nullptr, expr)), b.Block());
|
||||
b.Func("f", {}, b.ty.void_(), {s});
|
||||
|
||||
@@ -163,7 +165,7 @@ fn f() {
|
||||
}
|
||||
|
||||
continuing {
|
||||
let tint_symbol = 1;
|
||||
let tint_symbol = 1i;
|
||||
var a = tint_symbol;
|
||||
}
|
||||
}
|
||||
@@ -223,8 +225,8 @@ TEST_F(HoistToDeclBeforeTest, Array1D) {
|
||||
// var b = a[0];
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* var1 = b.Decl(b.Var("a", b.ty.array<ProgramBuilder::i32, 10>()));
|
||||
auto* expr = b.IndexAccessor("a", 0);
|
||||
auto* var1 = b.Decl(b.Var("a", b.ty.array<i32, 10>()));
|
||||
auto* expr = b.IndexAccessor("a", 0_i);
|
||||
auto* var2 = b.Decl(b.Var("b", nullptr, expr));
|
||||
b.Func("f", {}, b.ty.void_(), {var1, var2});
|
||||
|
||||
@@ -242,8 +244,8 @@ TEST_F(HoistToDeclBeforeTest, Array1D) {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : array<i32, 10>;
|
||||
let tint_symbol = a[0];
|
||||
var a : array<i32, 10u>;
|
||||
let tint_symbol = a[0i];
|
||||
var b = tint_symbol;
|
||||
}
|
||||
)";
|
||||
@@ -258,8 +260,8 @@ TEST_F(HoistToDeclBeforeTest, Array2D) {
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
|
||||
auto* var1 = b.Decl(b.Var("a", b.ty.array(b.ty.array<ProgramBuilder::i32, 10>(), 10)));
|
||||
auto* expr = b.IndexAccessor(b.IndexAccessor("a", 0), 0);
|
||||
auto* var1 = b.Decl(b.Var("a", b.ty.array(b.ty.array<i32, 10>(), 10_i)));
|
||||
auto* expr = b.IndexAccessor(b.IndexAccessor("a", 0_i), 0_i);
|
||||
auto* var2 = b.Decl(b.Var("b", nullptr, expr));
|
||||
b.Func("f", {}, b.ty.void_(), {var1, var2});
|
||||
|
||||
@@ -277,8 +279,8 @@ TEST_F(HoistToDeclBeforeTest, Array2D) {
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
var a : array<array<i32, 10>, 10>;
|
||||
let tint_symbol = a[0][0];
|
||||
var a : array<array<i32, 10u>, 10i>;
|
||||
let tint_symbol = a[0i][0i];
|
||||
var b = tint_symbol;
|
||||
}
|
||||
)";
|
||||
@@ -328,11 +330,11 @@ fn f() {
|
||||
|
||||
TEST_F(HoistToDeclBeforeTest, Prepare_ForLoopCont) {
|
||||
// fn f() {
|
||||
// for(; true; var a = 1) {
|
||||
// for(; true; var a = 1i) {
|
||||
// }
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
auto* expr = b.Expr(1);
|
||||
auto* expr = b.Expr(1_i);
|
||||
auto* s = b.For({}, b.Expr(true), b.Decl(b.Var("a", nullptr, expr)), b.Block());
|
||||
b.Func("f", {}, b.ty.void_(), {s});
|
||||
|
||||
@@ -358,7 +360,7 @@ fn f() {
|
||||
}
|
||||
|
||||
continuing {
|
||||
var a = 1;
|
||||
var a = 1i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -414,11 +416,11 @@ TEST_F(HoistToDeclBeforeTest, InsertBefore_Block) {
|
||||
// fn foo() {
|
||||
// }
|
||||
// fn f() {
|
||||
// var a = 1;
|
||||
// var a = 1i;
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
b.Func("foo", {}, b.ty.void_(), {});
|
||||
auto* var = b.Decl(b.Var("a", nullptr, b.Expr(1)));
|
||||
auto* var = b.Decl(b.Var("a", nullptr, b.Expr(1_i)));
|
||||
b.Func("f", {}, b.ty.void_(), {var});
|
||||
|
||||
Program original(std::move(b));
|
||||
@@ -440,7 +442,7 @@ fn foo() {
|
||||
|
||||
fn f() {
|
||||
foo();
|
||||
var a = 1;
|
||||
var a = 1i;
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -451,12 +453,12 @@ TEST_F(HoistToDeclBeforeTest, InsertBefore_ForLoopInit) {
|
||||
// fn foo() {
|
||||
// }
|
||||
// fn f() {
|
||||
// for(var a = 1; true;) {
|
||||
// for(var a = 1i; true;) {
|
||||
// }
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
b.Func("foo", {}, b.ty.void_(), {});
|
||||
auto* var = b.Decl(b.Var("a", nullptr, b.Expr(1)));
|
||||
auto* var = b.Decl(b.Var("a", nullptr, b.Expr(1_i)));
|
||||
auto* s = b.For(var, b.Expr(true), {}, b.Block());
|
||||
b.Func("f", {}, b.ty.void_(), {s});
|
||||
|
||||
@@ -479,7 +481,7 @@ fn foo() {
|
||||
|
||||
fn f() {
|
||||
foo();
|
||||
for(var a = 1; true; ) {
|
||||
for(var a = 1i; true; ) {
|
||||
}
|
||||
}
|
||||
)";
|
||||
@@ -491,14 +493,14 @@ TEST_F(HoistToDeclBeforeTest, InsertBefore_ForLoopCont) {
|
||||
// fn foo() {
|
||||
// }
|
||||
// fn f() {
|
||||
// var a = 1;
|
||||
// for(; true; a+=1) {
|
||||
// var a = 1i;
|
||||
// for(; true; a+=1i) {
|
||||
// }
|
||||
// }
|
||||
ProgramBuilder b;
|
||||
b.Func("foo", {}, b.ty.void_(), {});
|
||||
auto* var = b.Decl(b.Var("a", nullptr, b.Expr(1)));
|
||||
auto* cont = b.CompoundAssign("a", b.Expr(1), ast::BinaryOp::kAdd);
|
||||
auto* var = b.Decl(b.Var("a", nullptr, b.Expr(1_i)));
|
||||
auto* cont = b.CompoundAssign("a", b.Expr(1_i), ast::BinaryOp::kAdd);
|
||||
auto* s = b.For({}, b.Expr(true), cont, b.Block());
|
||||
b.Func("f", {}, b.ty.void_(), {var, s});
|
||||
|
||||
@@ -520,7 +522,7 @@ fn foo() {
|
||||
}
|
||||
|
||||
fn f() {
|
||||
var a = 1;
|
||||
var a = 1i;
|
||||
loop {
|
||||
if (!(true)) {
|
||||
break;
|
||||
@@ -530,7 +532,7 @@ fn f() {
|
||||
|
||||
continuing {
|
||||
foo();
|
||||
a += 1;
|
||||
a += 1i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::VertexPulling);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::VertexPulling::Config);
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::transform {
|
||||
|
||||
namespace {
|
||||
@@ -250,11 +252,11 @@ struct State {
|
||||
void AddVertexStorageBuffers() {
|
||||
// Creating the struct type
|
||||
static const char kStructName[] = "TintVertexData";
|
||||
auto* struct_type = ctx.dst->Structure(
|
||||
ctx.dst->Symbols().New(kStructName),
|
||||
{
|
||||
ctx.dst->Member(GetStructBufferName(), ctx.dst->ty.array<ProgramBuilder::u32>()),
|
||||
});
|
||||
auto* struct_type =
|
||||
ctx.dst->Structure(ctx.dst->Symbols().New(kStructName),
|
||||
{
|
||||
ctx.dst->Member(GetStructBufferName(), ctx.dst->ty.array<u32>()),
|
||||
});
|
||||
for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) {
|
||||
// The decorated variable with struct type
|
||||
ctx.dst->Global(GetVertexBufferName(i), ctx.dst->ty.Of(struct_type),
|
||||
@@ -297,7 +299,7 @@ struct State {
|
||||
|
||||
auto* attribute_offset = index_expr;
|
||||
if (buffer_layout.array_stride != 4) {
|
||||
attribute_offset = ctx.dst->Mul(index_expr, buffer_layout.array_stride / 4u);
|
||||
attribute_offset = ctx.dst->Mul(index_expr, u32(buffer_layout.array_stride / 4u));
|
||||
}
|
||||
|
||||
// let pulling_offset_n = <attribute_offset>
|
||||
@@ -359,13 +361,13 @@ struct State {
|
||||
case BaseType::kI32:
|
||||
ty = ctx.dst->ty.i32();
|
||||
for (uint32_t i = fmt_dt.width; i < var_dt.width; i++) {
|
||||
values.emplace_back(ctx.dst->Expr((i == 3) ? 1 : 0));
|
||||
values.emplace_back(ctx.dst->Expr(i32((i == 3) ? 1 : 0)));
|
||||
}
|
||||
break;
|
||||
case BaseType::kU32:
|
||||
ty = ctx.dst->ty.u32();
|
||||
for (uint32_t i = fmt_dt.width; i < var_dt.width; i++) {
|
||||
values.emplace_back(ctx.dst->Expr((i == 3) ? 1u : 0u));
|
||||
values.emplace_back(ctx.dst->Expr(u32((i == 3) ? 1u : 0u)));
|
||||
}
|
||||
break;
|
||||
case BaseType::kF32:
|
||||
@@ -403,10 +405,6 @@ struct State {
|
||||
uint32_t offset,
|
||||
uint32_t buffer,
|
||||
VertexFormat format) {
|
||||
using u32 = ProgramBuilder::u32;
|
||||
using i32 = ProgramBuilder::i32;
|
||||
using f32 = ProgramBuilder::f32;
|
||||
|
||||
// Returns a u32 loaded from buffer_base + offset.
|
||||
auto load_u32 = [&] {
|
||||
return LoadPrimitive(array_base, offset, buffer, VertexFormat::kUint32);
|
||||
@@ -433,17 +431,17 @@ struct State {
|
||||
LoadPrimitive(array_base, low_u32_offset, buffer, VertexFormat::kUint32);
|
||||
switch (offset & 3) {
|
||||
case 0:
|
||||
return ctx.dst->Shl(low_u32, 16u);
|
||||
return ctx.dst->Shl(low_u32, 16_u);
|
||||
case 1:
|
||||
return ctx.dst->And(ctx.dst->Shl(low_u32, 8u), 0xffff0000u);
|
||||
return ctx.dst->And(ctx.dst->Shl(low_u32, 8_u), 0xffff0000_u);
|
||||
case 2:
|
||||
return ctx.dst->And(low_u32, 0xffff0000u);
|
||||
return ctx.dst->And(low_u32, 0xffff0000_u);
|
||||
default: { // 3:
|
||||
auto* high_u32 = LoadPrimitive(array_base, low_u32_offset + 4, buffer,
|
||||
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);
|
||||
auto* shr = ctx.dst->Shr(low_u32, 8_u);
|
||||
auto* shl = ctx.dst->Shl(high_u32, 24_u);
|
||||
return ctx.dst->And(ctx.dst->Or(shl, shr), 0xffff0000_u);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -456,17 +454,17 @@ struct State {
|
||||
LoadPrimitive(array_base, low_u32_offset, buffer, VertexFormat::kUint32);
|
||||
switch (offset & 3) {
|
||||
case 0:
|
||||
return ctx.dst->And(low_u32, 0xffffu);
|
||||
return ctx.dst->And(low_u32, 0xffff_u);
|
||||
case 1:
|
||||
return ctx.dst->And(ctx.dst->Shr(low_u32, 8u), 0xffffu);
|
||||
return ctx.dst->And(ctx.dst->Shr(low_u32, 8_u), 0xffff_u);
|
||||
case 2:
|
||||
return ctx.dst->Shr(low_u32, 16u);
|
||||
return ctx.dst->Shr(low_u32, 16_u);
|
||||
default: { // 3:
|
||||
auto* high_u32 = LoadPrimitive(array_base, low_u32_offset + 4, buffer,
|
||||
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);
|
||||
auto* shr = ctx.dst->Shr(low_u32, 24_u);
|
||||
auto* shl = ctx.dst->Shl(high_u32, 8_u);
|
||||
return ctx.dst->And(ctx.dst->Or(shl, shr), 0xffff_u);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -517,25 +515,25 @@ struct State {
|
||||
// yyxx0000, yyxx0000
|
||||
auto* u16s = ctx.dst->vec2<u32>(load_u16_h());
|
||||
// xx000000, yyxx0000
|
||||
auto* shl = ctx.dst->Shl(u16s, ctx.dst->vec2<u32>(8u, 0u));
|
||||
auto* shl = ctx.dst->Shl(u16s, ctx.dst->vec2<u32>(8_u, 0_u));
|
||||
// 000000xx, 000000yy
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec2<u32>(24u));
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec2<u32>(24_u));
|
||||
}
|
||||
case VertexFormat::kUint8x4: {
|
||||
// wwzzyyxx, wwzzyyxx, wwzzyyxx, wwzzyyxx
|
||||
auto* u32s = ctx.dst->vec4<u32>(load_u32());
|
||||
// xx000000, yyxx0000, zzyyxx00, wwzzyyxx
|
||||
auto* shl = ctx.dst->Shl(u32s, ctx.dst->vec4<u32>(24u, 16u, 8u, 0u));
|
||||
auto* shl = ctx.dst->Shl(u32s, ctx.dst->vec4<u32>(24_u, 16_u, 8_u, 0_u));
|
||||
// 000000xx, 000000yy, 000000zz, 000000ww
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec4<u32>(24u));
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec4<u32>(24_u));
|
||||
}
|
||||
case VertexFormat::kUint16x2: {
|
||||
// yyyyxxxx, yyyyxxxx
|
||||
auto* u32s = ctx.dst->vec2<u32>(load_u32());
|
||||
// xxxx0000, yyyyxxxx
|
||||
auto* shl = ctx.dst->Shl(u32s, ctx.dst->vec2<u32>(16u, 0u));
|
||||
auto* shl = ctx.dst->Shl(u32s, ctx.dst->vec2<u32>(16_u, 0_u));
|
||||
// 0000xxxx, 0000yyyy
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec2<u32>(16u));
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec2<u32>(16_u));
|
||||
}
|
||||
case VertexFormat::kUint16x4: {
|
||||
// yyyyxxxx, wwwwzzzz
|
||||
@@ -543,33 +541,33 @@ struct State {
|
||||
// yyyyxxxx, yyyyxxxx, wwwwzzzz, wwwwzzzz
|
||||
auto* xxyy = ctx.dst->MemberAccessor(u32s, "xxyy");
|
||||
// xxxx0000, yyyyxxxx, zzzz0000, wwwwzzzz
|
||||
auto* shl = ctx.dst->Shl(xxyy, ctx.dst->vec4<u32>(16u, 0u, 16u, 0u));
|
||||
auto* shl = ctx.dst->Shl(xxyy, ctx.dst->vec4<u32>(16_u, 0_u, 16_u, 0_u));
|
||||
// 0000xxxx, 0000yyyy, 0000zzzz, 0000wwww
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec4<u32>(16u));
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec4<u32>(16_u));
|
||||
}
|
||||
case VertexFormat::kSint8x2: {
|
||||
// yyxx0000, yyxx0000
|
||||
auto* i16s = ctx.dst->vec2<i32>(load_i16_h());
|
||||
// xx000000, yyxx0000
|
||||
auto* shl = ctx.dst->Shl(i16s, ctx.dst->vec2<u32>(8u, 0u));
|
||||
auto* shl = ctx.dst->Shl(i16s, ctx.dst->vec2<u32>(8_u, 0_u));
|
||||
// ssssssxx, ssssssyy
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec2<u32>(24u));
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec2<u32>(24_u));
|
||||
}
|
||||
case VertexFormat::kSint8x4: {
|
||||
// wwzzyyxx, wwzzyyxx, wwzzyyxx, wwzzyyxx
|
||||
auto* i32s = ctx.dst->vec4<i32>(load_i32());
|
||||
// xx000000, yyxx0000, zzyyxx00, wwzzyyxx
|
||||
auto* shl = ctx.dst->Shl(i32s, ctx.dst->vec4<u32>(24u, 16u, 8u, 0u));
|
||||
auto* shl = ctx.dst->Shl(i32s, ctx.dst->vec4<u32>(24_u, 16_u, 8_u, 0_u));
|
||||
// ssssssxx, ssssssyy, sssssszz, ssssssww
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec4<u32>(24u));
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec4<u32>(24_u));
|
||||
}
|
||||
case VertexFormat::kSint16x2: {
|
||||
// yyyyxxxx, yyyyxxxx
|
||||
auto* i32s = ctx.dst->vec2<i32>(load_i32());
|
||||
// xxxx0000, yyyyxxxx
|
||||
auto* shl = ctx.dst->Shl(i32s, ctx.dst->vec2<u32>(16u, 0u));
|
||||
auto* shl = ctx.dst->Shl(i32s, ctx.dst->vec2<u32>(16_u, 0_u));
|
||||
// ssssxxxx, ssssyyyy
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec2<u32>(16u));
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec2<u32>(16_u));
|
||||
}
|
||||
case VertexFormat::kSint16x4: {
|
||||
// yyyyxxxx, wwwwzzzz
|
||||
@@ -577,9 +575,9 @@ struct State {
|
||||
// yyyyxxxx, yyyyxxxx, wwwwzzzz, wwwwzzzz
|
||||
auto* xxyy = ctx.dst->MemberAccessor(i32s, "xxyy");
|
||||
// xxxx0000, yyyyxxxx, zzzz0000, wwwwzzzz
|
||||
auto* shl = ctx.dst->Shl(xxyy, ctx.dst->vec4<u32>(16u, 0u, 16u, 0u));
|
||||
auto* shl = ctx.dst->Shl(xxyy, ctx.dst->vec4<u32>(16_u, 0_u, 16_u, 0_u));
|
||||
// ssssxxxx, ssssyyyy, sssszzzz, sssswwww
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec4<u32>(16u));
|
||||
return ctx.dst->Shr(shl, ctx.dst->vec4<u32>(16_u));
|
||||
}
|
||||
case VertexFormat::kUnorm8x2:
|
||||
return ctx.dst->MemberAccessor(ctx.dst->Call("unpack4x8unorm", load_u16_l()), "xy");
|
||||
@@ -623,17 +621,17 @@ struct State {
|
||||
uint32_t offset,
|
||||
uint32_t buffer,
|
||||
VertexFormat format) {
|
||||
const ast::Expression* u32 = nullptr;
|
||||
const ast::Expression* u = nullptr;
|
||||
if ((offset & 3) == 0) {
|
||||
// Aligned load.
|
||||
|
||||
const ast ::Expression* index = nullptr;
|
||||
if (offset > 0) {
|
||||
index = ctx.dst->Add(array_base, offset / 4);
|
||||
index = ctx.dst->Add(array_base, u32(offset / 4));
|
||||
} else {
|
||||
index = ctx.dst->Expr(array_base);
|
||||
}
|
||||
u32 = ctx.dst->IndexAccessor(
|
||||
u = ctx.dst->IndexAccessor(
|
||||
ctx.dst->MemberAccessor(GetVertexBufferName(buffer), GetStructBufferName()), index);
|
||||
|
||||
} else {
|
||||
@@ -645,18 +643,18 @@ struct State {
|
||||
|
||||
uint32_t shift = 8u * (offset & 3u);
|
||||
|
||||
auto* low_shr = ctx.dst->Shr(low, shift);
|
||||
auto* high_shl = ctx.dst->Shl(high, 32u - shift);
|
||||
u32 = ctx.dst->Or(low_shr, high_shl);
|
||||
auto* low_shr = ctx.dst->Shr(low, u32(shift));
|
||||
auto* high_shl = ctx.dst->Shl(high, u32(32u - shift));
|
||||
u = ctx.dst->Or(low_shr, high_shl);
|
||||
}
|
||||
|
||||
switch (format) {
|
||||
case VertexFormat::kUint32:
|
||||
return u32;
|
||||
return u;
|
||||
case VertexFormat::kSint32:
|
||||
return ctx.dst->Bitcast(ctx.dst->ty.i32(), u32);
|
||||
return ctx.dst->Bitcast(ctx.dst->ty.i32(), u);
|
||||
case VertexFormat::kFloat32:
|
||||
return ctx.dst->Bitcast(ctx.dst->ty.f32(), u32);
|
||||
return ctx.dst->Bitcast(ctx.dst->ty.f32(), u);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1178,7 +1178,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi
|
||||
snorm8x4 = unpack4x8snorm(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]).x;
|
||||
uint16x2 = vec3<u32>(((vec2<u32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]) << vec2<u32>(16u, 0u)) >> vec2<u32>(16u)), 0u);
|
||||
uint16x4 = (((vec2<u32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)], tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)]).xxyy << vec4<u32>(16u, 0u, 16u, 0u)) >> vec4<u32>(16u))).xy;
|
||||
sint16x2 = vec4<i32>(((vec2<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)])) << vec2<u32>(16u, 0u)) >> vec2<u32>(16u)), 0, 1);
|
||||
sint16x2 = vec4<i32>(((vec2<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)])) << vec2<u32>(16u, 0u)) >> vec2<u32>(16u)), 0i, 1i);
|
||||
sint16x4 = (((vec2<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)])).xxyy << vec4<u32>(16u, 0u, 16u, 0u)) >> vec4<u32>(16u))).x;
|
||||
unorm16x2 = vec3<f32>(unpack2x16unorm(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), 0.0);
|
||||
unorm16x4 = vec4<f32>(unpack2x16unorm(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), unpack2x16unorm(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)])).x;
|
||||
@@ -1194,8 +1194,8 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi
|
||||
uint32x2 = vec4<u32>(vec2<u32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)], tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)]), 0u, 1u);
|
||||
uint32x3 = vec4<u32>(vec3<u32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)], tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)], tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 18u)]), 1u);
|
||||
uint32x4 = vec4<u32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)], tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)], tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 18u)], tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 19u)]).xy;
|
||||
sint32 = vec4<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), 0, 0, 1);
|
||||
sint32x2 = vec3<i32>(vec2<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)])), 0);
|
||||
sint32 = vec4<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), 0i, 0i, 1i);
|
||||
sint32x2 = vec3<i32>(vec2<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)])), 0i);
|
||||
sint32x3 = vec3<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)]), bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 18u)])).x;
|
||||
sint32x4 = vec4<i32>(bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 16u)]), bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 17u)]), bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 18u)]), bitcast<i32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(buffer_array_base_0 + 19u)])).xy;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ WrapArraysInStructs::WrappedArrayInfo WrapArraysInStructs::WrapArray(
|
||||
if (!array->IsStrideImplicit()) {
|
||||
attrs.emplace_back(c.dst->create<ast::StrideAttribute>(array->Stride()));
|
||||
}
|
||||
return c.dst->ty.array(el_type(c), array->Count(), std::move(attrs));
|
||||
return c.dst->ty.array(el_type(c), u32(array->Count()), std::move(attrs));
|
||||
};
|
||||
|
||||
// Structure() will create and append the ast::Struct to the
|
||||
|
||||
@@ -208,10 +208,10 @@ struct ZeroInitWorkgroupMemory::State {
|
||||
auto idx = b.Symbols().New("idx");
|
||||
auto* init = b.Decl(b.Var(idx, b.ty.u32(), local_index()));
|
||||
auto* cond = b.create<ast::BinaryExpression>(ast::BinaryOp::kLessThan, b.Expr(idx),
|
||||
b.Expr(num_iterations));
|
||||
auto* cont =
|
||||
b.Assign(idx, b.Add(idx, workgroup_size_const ? b.Expr(workgroup_size_const)
|
||||
: workgroup_size_expr()));
|
||||
b.Expr(u32(num_iterations)));
|
||||
auto* cont = b.Assign(
|
||||
idx, b.Add(idx, workgroup_size_const ? b.Expr(u32(workgroup_size_const))
|
||||
: workgroup_size_expr()));
|
||||
|
||||
auto block =
|
||||
DeclareArrayIndices(num_iterations, array_indices, [&] { return b.Expr(idx); });
|
||||
@@ -227,8 +227,8 @@ struct ZeroInitWorkgroupMemory::State {
|
||||
// if (local_index < num_iterations) {
|
||||
// ...
|
||||
// }
|
||||
auto* cond = b.create<ast::BinaryExpression>(ast::BinaryOp::kLessThan,
|
||||
local_index(), b.Expr(num_iterations));
|
||||
auto* cond = b.create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kLessThan, local_index(), b.Expr(u32(num_iterations)));
|
||||
auto block = DeclareArrayIndices(num_iterations, array_indices,
|
||||
[&] { return b.Expr(local_index()); });
|
||||
for (auto& s : stmts) {
|
||||
@@ -337,9 +337,9 @@ struct ZeroInitWorkgroupMemory::State {
|
||||
auto name = array_index_names.at(index);
|
||||
auto* mod = (num_iterations > index.modulo)
|
||||
? b.create<ast::BinaryExpression>(ast::BinaryOp::kModulo, iteration(),
|
||||
b.Expr(index.modulo))
|
||||
b.Expr(u32(index.modulo)))
|
||||
: iteration();
|
||||
auto* div = (index.division != 1u) ? b.Div(mod, index.division) : mod;
|
||||
auto* div = (index.division != 1u) ? b.Div(mod, u32(index.division)) : mod;
|
||||
auto* decl = b.Decl(b.Let(name, b.ty.u32(), div));
|
||||
stmts.emplace_back(decl);
|
||||
}
|
||||
@@ -371,7 +371,7 @@ struct ZeroInitWorkgroupMemory::State {
|
||||
workgroup_size_expr = [this, expr, size = workgroup_size_expr] {
|
||||
auto* e = ctx.Clone(expr);
|
||||
if (ctx.src->TypeOf(expr)->UnwrapRef()->Is<sem::I32>()) {
|
||||
e = b.Construct<ProgramBuilder::u32>(e);
|
||||
e = b.Construct<u32>(e);
|
||||
}
|
||||
return size ? b.Mul(size(), e) : e;
|
||||
};
|
||||
@@ -381,8 +381,8 @@ struct ZeroInitWorkgroupMemory::State {
|
||||
// Fold workgroup_size_const in to workgroup_size_expr
|
||||
workgroup_size_expr = [this, is_signed, const_size = workgroup_size_const,
|
||||
expr_size = workgroup_size_expr] {
|
||||
return is_signed ? b.Mul(expr_size(), static_cast<int32_t>(const_size))
|
||||
: b.Mul(expr_size(), const_size);
|
||||
return is_signed ? b.Mul(expr_size(), i32(const_size))
|
||||
: b.Mul(expr_size(), u32(const_size));
|
||||
};
|
||||
}
|
||||
// Indicate that workgroup_size_expr should be used instead of the
|
||||
|
||||
Reference in New Issue
Block a user