GLSL: fix barriers.

Bug: tint:1416
Change-Id: I138932cc0d702289684c4db80b4640df43b41833
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79420
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Stephen White 2022-02-05 00:15:34 +00:00 committed by Tint LUCI CQ
parent b79f51ece3
commit deec53332f
45 changed files with 66 additions and 60 deletions
src/writer/glsl
test

View File

@ -1165,9 +1165,9 @@ bool GeneratorImpl::EmitBarrierCall(std::ostream& out,
// TODO(crbug.com/tint/661): Combine sequential barriers to a single
// instruction.
if (builtin->Type() == sem::BuiltinType::kWorkgroupBarrier) {
out << "memoryBarrierShared()";
out << "barrier()";
} else if (builtin->Type() == sem::BuiltinType::kStorageBarrier) {
out << "memoryBarrierBuffer()";
out << "{ barrier(); memoryBarrierBuffer(); }";
} else {
TINT_UNREACHABLE(Writer, diagnostics_)
<< "unexpected barrier builtin type " << sem::str(builtin->Type());

View File

@ -645,6 +645,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Unpack2x16Float) {
HasSubstr("f16tof32(uint2(tint_tmp & 0xffff, tint_tmp >> 16))"));
}
#endif
TEST_F(GlslGeneratorImplTest_Builtin, StorageBarrier) {
Func("main", {}, ty.void_(),
{CallStmt(Call("storageBarrier"))},
@ -656,9 +658,12 @@ TEST_F(GlslGeneratorImplTest_Builtin, StorageBarrier) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
EXPECT_EQ(gen.result(), R"(layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
EXPECT_EQ(gen.result(), R"(#version 310 es
precision mediump float;
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main() {
DeviceMemoryBarrierWithGroupSync();
{ barrier(); memoryBarrierBuffer(); };
return;
}
)");
@ -675,16 +680,17 @@ TEST_F(GlslGeneratorImplTest_Builtin, WorkgroupBarrier) {
GeneratorImpl& gen = Build();
ASSERT_TRUE(gen.Generate()) << gen.error();
EXPECT_EQ(gen.result(), R"(layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
EXPECT_EQ(gen.result(), R"(#version 310 es
precision mediump float;
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main() {
GroupMemoryBarrierWithGroupSync();
barrier();
return;
}
)");
}
#endif
TEST_F(GlslGeneratorImplTest_Builtin, DotI32) {
Global("v", ty.vec3<i32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(Call("dot", "v", "v")));

View File

@ -28,7 +28,7 @@ void f(uint local_invocation_index) {
s.data[i] = 0;
}
}
memoryBarrierShared();
barrier();
result.tint_symbol = s.data[ubo.dynamic_idx];
}

View File

@ -28,7 +28,7 @@ void f(uint local_invocation_index) {
s.data[i] = 0;
}
}
memoryBarrierShared();
barrier();
s.data[ubo.dynamic_idx] = 1;
result.tint_symbol = s.data[3];
}

View File

@ -71,7 +71,7 @@ void tint_symbol(uvec3 local_id, uvec3 global_id, uint local_invocation_index) {
mm_Bsub[i][i_1] = 0.0f;
}
}
memoryBarrierShared();
barrier();
uint tileRow = (local_id.y * RowPerThread);
uint tileCol = (local_id.x * ColPerThread);
uint globalRow = (global_id.y * RowPerThread);
@ -113,7 +113,7 @@ void tint_symbol(uvec3 local_id, uvec3 global_id, uint local_invocation_index) {
}
}
}
memoryBarrierShared();
barrier();
{
for(uint k = 0u; (k < TileInner); k = (k + 1u)) {
{
@ -134,7 +134,7 @@ void tint_symbol(uvec3 local_id, uvec3 global_id, uint local_invocation_index) {
}
}
}
memoryBarrierShared();
barrier();
}
}
{

View File

@ -32,7 +32,7 @@ void tint_symbol(uvec3 WorkGroupID, uvec3 LocalInvocationID, uint local_invocati
tile[i_1][i_2] = vec3(0.0f, 0.0f, 0.0f);
}
}
memoryBarrierShared();
barrier();
uint filterOffset = ((params.filterDim - 1u) / 2u);
ivec2 dims = textureSize(inputTex_1, 0);
ivec2 baseIndex = (ivec2(((WorkGroupID.xy * uvec2(params.blockDim, 4u)) + (LocalInvocationID.xy * uvec2(4u, 1u)))) - ivec2(int(filterOffset), 0));
@ -49,7 +49,7 @@ void tint_symbol(uvec3 WorkGroupID, uvec3 LocalInvocationID, uint local_invocati
}
}
}
memoryBarrierShared();
barrier();
{
for(uint r = 0u; (r < 4u); r = (r + 1u)) {
{

View File

@ -277,7 +277,7 @@ void mm_matMul_i1_i1_i1_(inout int dimAOuter, inout int dimInner, inout int dimB
}
}
}
memoryBarrierShared();
barrier();
k = 0;
{
for(; (k < 64); k = (k + 1)) {
@ -309,7 +309,7 @@ void mm_matMul_i1_i1_i1_(inout int dimAOuter, inout int dimInner, inout int dimB
}
}
}
memoryBarrierShared();
barrier();
}
}
innerRow_4 = 0;
@ -387,7 +387,7 @@ void tint_symbol_2(uvec3 tint_symbol_3, uvec3 tint_symbol_4, uint local_invocati
mm_Asub[i][i_1] = 0.0f;
}
}
memoryBarrierShared();
barrier();
tint_symbol = tint_symbol_3;
tint_symbol_1 = tint_symbol_4;
main_1();

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0);
}
memoryBarrierShared();
barrier();
atomicAdd_794055();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0u);
}
memoryBarrierShared();
barrier();
atomicAdd_d5db1d();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0u);
}
memoryBarrierShared();
barrier();
atomicAnd_34edd3();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0);
}
memoryBarrierShared();
barrier();
atomicAnd_45a819();
}

View File

@ -18,7 +18,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0);
}
memoryBarrierShared();
barrier();
atomicCompareExchangeWeak_89ea3b();
}

View File

@ -18,7 +18,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0u);
}
memoryBarrierShared();
barrier();
atomicCompareExchangeWeak_b2ab2c();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0u);
}
memoryBarrierShared();
barrier();
atomicExchange_0a5dca();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0);
}
memoryBarrierShared();
barrier();
atomicExchange_e114ba();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0u);
}
memoryBarrierShared();
barrier();
atomicLoad_361bf1();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0);
}
memoryBarrierShared();
barrier();
atomicLoad_afcc03();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0);
}
memoryBarrierShared();
barrier();
atomicMax_a89cc3();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0u);
}
memoryBarrierShared();
barrier();
atomicMax_beccfc();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0);
}
memoryBarrierShared();
barrier();
atomicMin_278235();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0u);
}
memoryBarrierShared();
barrier();
atomicMin_69d383();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0u);
}
memoryBarrierShared();
barrier();
atomicOr_5e3d61();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0);
}
memoryBarrierShared();
barrier();
atomicOr_d09248();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0u);
}
memoryBarrierShared();
barrier();
atomicStore_726882();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0);
}
memoryBarrierShared();
barrier();
atomicStore_8bea94();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0u);
}
memoryBarrierShared();
barrier();
atomicSub_0d26c2();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0);
}
memoryBarrierShared();
barrier();
atomicSub_77883a();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0);
}
memoryBarrierShared();
barrier();
atomicXor_75dc95();
}

View File

@ -10,7 +10,7 @@ void compute_main(uint local_invocation_index) {
{
atomicExchange(arg_0, 0u);
}
memoryBarrierShared();
barrier();
atomicXor_c8e6be();
}

View File

@ -2,7 +2,7 @@
precision mediump float;
void storageBarrier_d87211() {
memoryBarrierBuffer();
{ barrier(); memoryBarrierBuffer(); };
}
void compute_main() {

View File

@ -2,7 +2,7 @@
precision mediump float;
void workgroupBarrier_a17f7f() {
memoryBarrierShared();
barrier();
}
void compute_main() {

View File

@ -6,7 +6,7 @@ void tint_symbol(uint local_invocation_index) {
{
i = 0;
}
memoryBarrierShared();
barrier();
i = 123;
int use = (i + 1);
}

View File

@ -9,7 +9,7 @@ void tint_symbol(uint local_invocation_index) {
v[i] = 0;
}
}
memoryBarrierShared();
barrier();
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -6,7 +6,7 @@ void tint_symbol(uint local_invocation_index) {
{
v = mat2x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
}
memoryBarrierShared();
barrier();
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -6,7 +6,7 @@ void tint_symbol(uint local_invocation_index) {
{
v = 0;
}
memoryBarrierShared();
barrier();
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -12,7 +12,7 @@ void tint_symbol(uint local_invocation_index) {
S tint_symbol_1 = S(0, 0.0f);
v = tint_symbol_1;
}
memoryBarrierShared();
barrier();
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -6,7 +6,7 @@ void tint_symbol(uint local_invocation_index) {
{
v = ivec3(0, 0, 0);
}
memoryBarrierShared();
barrier();
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -204,7 +204,7 @@ void tint_symbol(uint idx) {
m98 = mat2(0.0f, 0.0f, 0.0f, 0.0f);
m99 = mat2(0.0f, 0.0f, 0.0f, 0.0f);
}
memoryBarrierShared();
barrier();
m00[0][0] = 1.0f;
m01[0][0] = 1.0f;
m02[0][0] = 1.0f;

View File

@ -10,7 +10,7 @@ void main1(uint local_invocation_index) {
{
a = 0;
}
memoryBarrierShared();
barrier();
a = 42;
uses_a();
}
@ -32,7 +32,7 @@ void main2(uint local_invocation_index_1) {
{
b = 0;
}
memoryBarrierShared();
barrier();
b = 7;
uses_b();
}
@ -75,7 +75,7 @@ void main3(uint local_invocation_index_2) {
a = 0;
b = 0;
}
memoryBarrierShared();
barrier();
outer();
no_uses();
}

View File

@ -40,7 +40,7 @@ void main_1() {
break;
}
}
memoryBarrierShared();
barrier();
}
}
if ((lid == 0)) {

View File

@ -44,7 +44,7 @@ void main_1() {
break;
}
}
memoryBarrierShared();
barrier();
}
}
if ((lid == 0)) {

View File

@ -37,7 +37,7 @@ void main_1() {
float x_13 = GLF_live2gl_FragCoord.x;
if ((int(x_13) < 120)) {
} else {
memoryBarrierShared();
barrier();
}
}
}
@ -62,7 +62,7 @@ void main_1() {
}
float x_16 = GLF_live2gl_FragCoord.x;
GLF_dead3x = x_16;
memoryBarrierShared();
barrier();
}
}
x_12.x_compute_data[0] = 42u;

View File

@ -41,7 +41,7 @@ void main_1() {
float x_13 = GLF_live2gl_FragCoord.x;
if ((int(x_13) < 120)) {
} else {
memoryBarrierShared();
barrier();
}
}
}
@ -66,7 +66,7 @@ void main_1() {
}
float x_16 = GLF_live2gl_FragCoord.x;
GLF_dead3x = x_16;
memoryBarrierShared();
barrier();
}
}
x_12.x_compute_data[0] = 42u;

View File

@ -70,7 +70,7 @@ void main_1() {
float x_118 = x_10.injectionSwitch.x;
float x_120 = x_10.injectionSwitch.y;
if ((x_118 > x_120)) {
memoryBarrierShared();
barrier();
}
}
}

View File

@ -74,7 +74,7 @@ void main_1() {
float x_118 = x_10.injectionSwitch.x;
float x_120 = x_10.injectionSwitch.y;
if ((x_118 > x_120)) {
memoryBarrierShared();
barrier();
}
}
}