2022-11-30 02:47:27 +00:00
|
|
|
ByteAddressBuffer sb : register(t0, space0);
|
transform: Fixes for DecomposeMemoryAccess
CloneContext::Replace(T* what, T* with) is bug-prone, as complex transforms may want to clone `what` multiple times, or not at all. In both cases, this will likely result in an ICE as either the replacement will be reachable multiple times, or not at all.
The CTS test: webgpu:shader,execution,robust_access:linear_memory:storageClass="storage";storageMode="read_write";access="read";atomic=true;baseType="i32"
Was triggering this brokenness with DecomposeMemoryAccess's use of CloneContext::Replace(T*, T*).
Switch the usage of CloneContext::Replace(T*, T*) to the new function form.
As std::function is copyable, it cannot hold a captured std::unique_ptr.
This prevented the Replace() lambdas from capturing the necessary `BufferAccess` data, as this held a `std::unique_ptr<Offset>`.
To fix this, use a `BlockAllocator` for Offsets, and use raw pointers instead.
Because the function passed to Replace() is called just before the node is cloned, insertion of new functions will occur just before the currently evaluated module-scope entity.
This allows us to remove the "insert_after" arguments to LoadFunc(), StoreFunc(), and AtomicFunc().
We can also kill the icky InsertGlobal() and TypeDeclOf() helpers.
Bug: tint:993
Change-Id: I60972bc13a2fa819a163ee2671f61e82d0e68d2a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58222
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-07-15 20:29:09 +00:00
|
|
|
|
|
|
|
struct tint_symbol_1 {
|
|
|
|
uint idx : SV_GroupIndex;
|
|
|
|
};
|
|
|
|
|
2022-11-30 02:47:27 +00:00
|
|
|
float2x2 tint_symbol_14(ByteAddressBuffer buffer, uint offset) {
|
|
|
|
return float2x2(asfloat(buffer.Load2((offset + 0u))), asfloat(buffer.Load2((offset + 8u))));
|
|
|
|
}
|
|
|
|
|
|
|
|
float2x3 tint_symbol_15(ByteAddressBuffer buffer, uint offset) {
|
2021-07-13 12:18:13 +00:00
|
|
|
return float2x3(asfloat(buffer.Load3((offset + 0u))), asfloat(buffer.Load3((offset + 16u))));
|
|
|
|
}
|
|
|
|
|
2022-11-30 02:47:27 +00:00
|
|
|
float2x4 tint_symbol_16(ByteAddressBuffer buffer, uint offset) {
|
|
|
|
return float2x4(asfloat(buffer.Load4((offset + 0u))), asfloat(buffer.Load4((offset + 16u))));
|
|
|
|
}
|
|
|
|
|
|
|
|
float3x2 tint_symbol_17(ByteAddressBuffer buffer, uint offset) {
|
2021-07-13 12:18:13 +00:00
|
|
|
return float3x2(asfloat(buffer.Load2((offset + 0u))), asfloat(buffer.Load2((offset + 8u))), asfloat(buffer.Load2((offset + 16u))));
|
|
|
|
}
|
|
|
|
|
2022-11-30 02:47:27 +00:00
|
|
|
float3x3 tint_symbol_18(ByteAddressBuffer buffer, uint offset) {
|
|
|
|
return float3x3(asfloat(buffer.Load3((offset + 0u))), asfloat(buffer.Load3((offset + 16u))), asfloat(buffer.Load3((offset + 32u))));
|
|
|
|
}
|
|
|
|
|
|
|
|
float3x4 tint_symbol_19(ByteAddressBuffer buffer, uint offset) {
|
|
|
|
return float3x4(asfloat(buffer.Load4((offset + 0u))), asfloat(buffer.Load4((offset + 16u))), asfloat(buffer.Load4((offset + 32u))));
|
|
|
|
}
|
|
|
|
|
|
|
|
float4x2 tint_symbol_20(ByteAddressBuffer buffer, uint offset) {
|
|
|
|
return float4x2(asfloat(buffer.Load2((offset + 0u))), asfloat(buffer.Load2((offset + 8u))), asfloat(buffer.Load2((offset + 16u))), asfloat(buffer.Load2((offset + 24u))));
|
|
|
|
}
|
|
|
|
|
|
|
|
float4x3 tint_symbol_21(ByteAddressBuffer buffer, uint offset) {
|
|
|
|
return float4x3(asfloat(buffer.Load3((offset + 0u))), asfloat(buffer.Load3((offset + 16u))), asfloat(buffer.Load3((offset + 32u))), asfloat(buffer.Load3((offset + 48u))));
|
|
|
|
}
|
|
|
|
|
|
|
|
float4x4 tint_symbol_22(ByteAddressBuffer buffer, uint offset) {
|
|
|
|
return float4x4(asfloat(buffer.Load4((offset + 0u))), asfloat(buffer.Load4((offset + 16u))), asfloat(buffer.Load4((offset + 32u))), asfloat(buffer.Load4((offset + 48u))));
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef float3 tint_symbol_23_ret[2];
|
|
|
|
tint_symbol_23_ret tint_symbol_23(ByteAddressBuffer buffer, uint offset) {
|
|
|
|
float3 arr_1[2] = (float3[2])0;
|
2021-07-16 19:47:44 +00:00
|
|
|
{
|
2022-11-30 02:47:27 +00:00
|
|
|
for(uint i = 0u; (i < 2u); i = (i + 1u)) {
|
|
|
|
arr_1[i] = asfloat(buffer.Load3((offset + (i * 16u))));
|
2021-07-16 19:47:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return arr_1;
|
2021-07-13 12:18:13 +00:00
|
|
|
}
|
|
|
|
|
2021-08-04 22:15:28 +00:00
|
|
|
void main_inner(uint idx) {
|
2022-11-30 02:47:27 +00:00
|
|
|
const float scalar_f32 = asfloat(sb.Load((544u * idx)));
|
|
|
|
const int scalar_i32 = asint(sb.Load(((544u * idx) + 4u)));
|
|
|
|
const uint scalar_u32 = sb.Load(((544u * idx) + 8u));
|
|
|
|
const float2 vec2_f32 = asfloat(sb.Load2(((544u * idx) + 16u)));
|
|
|
|
const int2 vec2_i32 = asint(sb.Load2(((544u * idx) + 24u)));
|
|
|
|
const uint2 vec2_u32 = sb.Load2(((544u * idx) + 32u));
|
|
|
|
const float3 vec3_f32 = asfloat(sb.Load3(((544u * idx) + 48u)));
|
|
|
|
const int3 vec3_i32 = asint(sb.Load3(((544u * idx) + 64u)));
|
|
|
|
const uint3 vec3_u32 = sb.Load3(((544u * idx) + 80u));
|
|
|
|
const float4 vec4_f32 = asfloat(sb.Load4(((544u * idx) + 96u)));
|
|
|
|
const int4 vec4_i32 = asint(sb.Load4(((544u * idx) + 112u)));
|
|
|
|
const uint4 vec4_u32 = sb.Load4(((544u * idx) + 128u));
|
|
|
|
const float2x2 mat2x2_f32 = tint_symbol_14(sb, ((544u * idx) + 144u));
|
|
|
|
const float2x3 mat2x3_f32 = tint_symbol_15(sb, ((544u * idx) + 160u));
|
|
|
|
const float2x4 mat2x4_f32 = tint_symbol_16(sb, ((544u * idx) + 192u));
|
|
|
|
const float3x2 mat3x2_f32 = tint_symbol_17(sb, ((544u * idx) + 224u));
|
|
|
|
const float3x3 mat3x3_f32 = tint_symbol_18(sb, ((544u * idx) + 256u));
|
|
|
|
const float3x4 mat3x4_f32 = tint_symbol_19(sb, ((544u * idx) + 304u));
|
|
|
|
const float4x2 mat4x2_f32 = tint_symbol_20(sb, ((544u * idx) + 352u));
|
|
|
|
const float4x3 mat4x3_f32 = tint_symbol_21(sb, ((544u * idx) + 384u));
|
|
|
|
const float4x4 mat4x4_f32 = tint_symbol_22(sb, ((544u * idx) + 448u));
|
|
|
|
const float3 arr2_vec3_f32[2] = tint_symbol_23(sb, ((544u * idx) + 512u));
|
2021-08-04 22:15:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[numthreads(1, 1, 1)]
|
|
|
|
void main(tint_symbol_1 tint_symbol) {
|
|
|
|
main_inner(tint_symbol.idx);
|
2021-07-13 12:18:13 +00:00
|
|
|
return;
|
|
|
|
}
|