Path: blob/main_old/src/tests/gl_tests/AtomicCounterBufferTest.cpp
1693 views
//1// Copyright 2017 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//5// AtomicCounterBufferTest:6// Various tests related for atomic counter buffers.7//89#include "test_utils/ANGLETest.h"10#include "test_utils/gl_raii.h"1112using namespace angle;1314namespace15{1617class AtomicCounterBufferTest : public ANGLETest18{19protected:20AtomicCounterBufferTest()21{22setWindowWidth(128);23setWindowHeight(128);24setConfigRedBits(8);25setConfigGreenBits(8);26setConfigBlueBits(8);27setConfigAlphaBits(8);28}29};3031// Test GL_ATOMIC_COUNTER_BUFFER is not supported with version lower than ES31.32TEST_P(AtomicCounterBufferTest, AtomicCounterBufferBindings)33{34ASSERT_EQ(3, getClientMajorVersion());35GLBuffer atomicCounterBuffer;36glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, atomicCounterBuffer.get());37if (getClientMinorVersion() < 1)38{39EXPECT_GL_ERROR(GL_INVALID_ENUM);40}41else42{43EXPECT_GL_NO_ERROR();44}45}4647class AtomicCounterBufferTest31 : public AtomicCounterBufferTest48{};4950// Linking should fail if counters in vertex shader exceed gl_MaxVertexAtomicCounters.51TEST_P(AtomicCounterBufferTest31, ExceedMaxVertexAtomicCounters)52{53constexpr char kVS[] =54"#version 310 es\n"55"layout(binding = 0) uniform atomic_uint foo[gl_MaxVertexAtomicCounters + 1];\n"56"void main()\n"57"{\n"58" atomicCounterIncrement(foo[0]);\n"59"}\n";60constexpr char kFS[] =61"#version 310 es\n"62"void main()\n"63"{\n"64"}\n";6566GLuint program = CompileProgram(kVS, kFS);67EXPECT_EQ(0u, program);68}6970// Counters matching across shader stages should fail if offsets aren't all specified.71// GLSL ES Spec 3.10.4, section 9.2.1.72TEST_P(AtomicCounterBufferTest31, OffsetNotAllSpecified)73{74constexpr char kVS[] =75"#version 310 es\n"76"layout(binding = 0, offset = 4) uniform atomic_uint foo;\n"77"void main()\n"78"{\n"79" atomicCounterIncrement(foo);\n"80"}\n";81constexpr char kFS[] =82"#version 310 es\n"83"layout(binding = 0) uniform atomic_uint foo;\n"84"void main()\n"85"{\n"86"}\n";8788GLuint program = CompileProgram(kVS, kFS);89EXPECT_EQ(0u, program);90}9192// Counters matching across shader stages should fail if offsets aren't all specified with same93// value.94TEST_P(AtomicCounterBufferTest31, OffsetNotAllSpecifiedWithSameValue)95{96constexpr char kVS[] =97"#version 310 es\n"98"layout(binding = 0, offset = 4) uniform atomic_uint foo;\n"99"void main()\n"100"{\n"101" atomicCounterIncrement(foo);\n"102"}\n";103constexpr char kFS[] =104"#version 310 es\n"105"layout(binding = 0, offset = 8) uniform atomic_uint foo;\n"106"void main()\n"107"{\n"108"}\n";109110GLuint program = CompileProgram(kVS, kFS);111EXPECT_EQ(0u, program);112}113114// Tests atomic counter reads using compute shaders. Used as a confidence check for the translator.115TEST_P(AtomicCounterBufferTest31, AtomicCounterReadCompute)116{117// Skipping due to a bug on the Adreno OpenGLES Android driver.118// http://anglebug.com/2925119ANGLE_SKIP_TEST_IF(IsAndroid() && IsAdreno() && IsOpenGLES());120121constexpr char kComputeShaderSource[] = R"(#version 310 es122layout(local_size_x=1, local_size_y=1, local_size_z=1) in;123124void atomicCounterInFunction(in atomic_uint counter[3]);125126layout(binding = 0, offset = 8) uniform atomic_uint ac[3];127128void atomicCounterInFunction(in atomic_uint counter[3])129{130atomicCounter(counter[0]);131}132133void main()134{135atomicCounterInFunction(ac);136atomicCounter(ac[gl_LocalInvocationIndex + 1u]);137})";138139ANGLE_GL_COMPUTE_PROGRAM(program, kComputeShaderSource);140EXPECT_GL_NO_ERROR();141}142143// Test atomic counter read.144TEST_P(AtomicCounterBufferTest31, AtomicCounterRead)145{146// Skipping test while we work on enabling atomic counter buffer support in th D3D renderer.147// http://anglebug.com/1729148ANGLE_SKIP_TEST_IF(IsD3D11());149150constexpr char kFS[] =151"#version 310 es\n"152"precision highp float;\n"153"layout(binding = 0, offset = 4) uniform atomic_uint ac;\n"154"out highp vec4 my_color;\n"155"void main()\n"156"{\n"157" my_color = vec4(0.0);\n"158" uint a1 = atomicCounter(ac);\n"159" if (a1 == 3u) my_color = vec4(1.0);\n"160"}\n";161162ANGLE_GL_PROGRAM(program, essl31_shaders::vs::Simple(), kFS);163164glUseProgram(program.get());165166// The initial value of counter 'ac' is 3u.167unsigned int bufferData[3] = {11u, 3u, 1u};168GLBuffer atomicCounterBuffer;169glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomicCounterBuffer);170glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(bufferData), bufferData, GL_STATIC_DRAW);171172glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, atomicCounterBuffer);173174drawQuad(program.get(), essl31_shaders::PositionAttrib(), 0.0f);175ASSERT_GL_NO_ERROR();176EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::white);177}178179// Test a bug in vulkan back-end where recreating the atomic counter storage should trigger state180// update in the context181TEST_P(AtomicCounterBufferTest31, DependentAtomicCounterBufferChange)182{183// Skipping test while we work on enabling atomic counter buffer support in th D3D renderer.184// http://anglebug.com/1729185ANGLE_SKIP_TEST_IF(IsD3D11());186187constexpr char kFS[] =188"#version 310 es\n"189"precision highp float;\n"190"layout(binding = 0, offset = 4) uniform atomic_uint ac;\n"191"out highp vec4 my_color;\n"192"void main()\n"193"{\n"194" my_color = vec4(0.0);\n"195" uint a1 = atomicCounter(ac);\n"196" if (a1 == 3u) my_color = vec4(1.0);\n"197" if (a1 == 19u) my_color = vec4(1.0, 0.0, 0.0, 1.0);\n"198"}\n";199200ANGLE_GL_PROGRAM(program, essl31_shaders::vs::Simple(), kFS);201202glUseProgram(program.get());203204// The initial value of counter 'ac' is 3u.205unsigned int bufferDataLeft[3] = {11u, 3u, 1u};206GLBuffer atomicCounterBuffer;207glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomicCounterBuffer);208glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(bufferDataLeft), bufferDataLeft, GL_STATIC_DRAW);209210glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, atomicCounterBuffer);211// Draw left quad212glViewport(0, 0, getWindowWidth() / 2, getWindowHeight());213drawQuad(program.get(), essl31_shaders::PositionAttrib(), 0.0f);214// Draw right quad215unsigned int bufferDataRight[3] = {11u, 19u, 1u};216glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(bufferDataRight), bufferDataRight,217GL_STATIC_DRAW);218glViewport(getWindowWidth() / 2, 0, getWindowWidth() / 2, getWindowHeight());219drawQuad(program.get(), essl31_shaders::PositionAttrib(), 0.0f);220ASSERT_GL_NO_ERROR();221EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::white);222EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 2, 0, GLColor::red);223}224225// Updating atomic counter buffer's offsets was optimized based on a count of valid bindings.226// This test will fail if there are bugs in how we count valid bindings.227TEST_P(AtomicCounterBufferTest31, AtomicCounterBufferRangeRead)228{229// Skipping due to a bug on the Qualcomm driver.230// http://anglebug.com/3726231ANGLE_SKIP_TEST_IF(IsNexus5X() && IsOpenGLES());232233// Skipping test while we work on enabling atomic counter buffer support in th D3D renderer.234// http://anglebug.com/1729235ANGLE_SKIP_TEST_IF(IsD3D11());236237constexpr char kFS[] =238"#version 310 es\n"239"precision highp float;\n"240"layout(binding = 0, offset = 4) uniform atomic_uint ac;\n"241"out highp vec4 my_color;\n"242"void main()\n"243"{\n"244" my_color = vec4(0.0);\n"245" uint a1 = atomicCounter(ac);\n"246" if (a1 == 3u) my_color = vec4(1.0);\n"247"}\n";248249ANGLE_GL_PROGRAM(program, essl31_shaders::vs::Simple(), kFS);250251glUseProgram(program.get());252253// The initial value of counter 'ac' is 3u.254unsigned int bufferData[] = {0u, 0u, 0u, 0u, 0u, 11u, 3u, 1u};255constexpr GLintptr kOffset = 20;256GLint maxAtomicCounterBuffers = 0;257GLBuffer atomicCounterBuffer;258259glGetIntegerv(GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS, &maxAtomicCounterBuffers);260// Repeatedly bind the same buffer (GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS + 1) times261// A bug in counting valid atomic counter buffers will cause a crash when we262// exceed GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS263for (int32_t i = 0; i < maxAtomicCounterBuffers + 1; i++)264{265glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomicCounterBuffer);266glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(bufferData), bufferData, GL_STATIC_DRAW);267glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0, atomicCounterBuffer, kOffset,268sizeof(bufferData) - kOffset);269}270271drawQuad(program.get(), essl31_shaders::PositionAttrib(), 0.0f);272ASSERT_GL_NO_ERROR();273EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::white);274}275276// Updating atomic counter buffer's offsets was optimized based on a count of valid bindings.277// Repeatedly bind/unbind buffers across available binding points. The test will fail if278// there are bugs in how we count valid bindings.279TEST_P(AtomicCounterBufferTest31, AtomicCounterBufferRepeatedBindUnbind)280{281// Skipping test while we work on enabling atomic counter buffer support in th D3D renderer.282// http://anglebug.com/1729283ANGLE_SKIP_TEST_IF(IsD3D11());284285constexpr char kFS[] =286"#version 310 es\n"287"precision highp float;\n"288"layout(binding = 0, offset = 4) uniform atomic_uint ac;\n"289"out highp vec4 my_color;\n"290"void main()\n"291"{\n"292" my_color = vec4(0.0);\n"293" uint a1 = atomicCounter(ac);\n"294" if (a1 == 3u) my_color = vec4(1.0);\n"295"}\n";296297ANGLE_GL_PROGRAM(program, essl31_shaders::vs::Simple(), kFS);298299glUseProgram(program.get());300301constexpr int32_t kBufferCount = 16;302// The initial value of counter 'ac' is 3u.303unsigned int bufferData[3] = {11u, 3u, 1u};304GLBuffer atomicCounterBuffer[kBufferCount];305// Populate atomicCounterBuffer[0] with valid data and the rest with nullptr306for (int32_t bufferIndex = 0; bufferIndex < kBufferCount; bufferIndex++)307{308glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomicCounterBuffer[bufferIndex]);309glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(bufferData),310(bufferIndex == 0) ? bufferData : nullptr, GL_STATIC_DRAW);311}312313GLint maxAtomicCounterBuffers = 0;314glGetIntegerv(GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS, &maxAtomicCounterBuffers);315316// Cycle through multiple buffers317for (int32_t i = 0; i < kBufferCount; i++)318{319constexpr int32_t kBufferIndices[kBufferCount] = {7, 12, 15, 5, 13, 14, 1, 2,3200, 6, 4, 9, 8, 11, 3, 10};321int32_t bufferIndex = kBufferIndices[i];322323// Randomly bind/unbind buffers to/from different binding points,324// capped by GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS325for (int32_t bufferCount = 0; bufferCount < maxAtomicCounterBuffers; bufferCount++)326{327constexpr uint32_t kBindingSlotsSize = kBufferCount;328constexpr uint32_t kBindingSlots[kBindingSlotsSize] = {1, 3, 4, 14, 15, 9, 0, 6,32912, 11, 8, 5, 10, 2, 7, 13};330331uint32_t bindingSlotIndex = bufferCount % kBindingSlotsSize;332uint32_t bindingSlot = kBindingSlots[bindingSlotIndex];333uint32_t bindingPoint = bindingSlot % maxAtomicCounterBuffers;334bool even = (bufferCount % 2 == 0);335int32_t bufferId = (even) ? 0 : atomicCounterBuffer[bufferIndex];336337glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, bindingPoint, bufferId);338}339}340341// Bind atomicCounterBuffer[0] to slot 0 and verify result342glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, atomicCounterBuffer[0]);343drawQuad(program.get(), essl31_shaders::PositionAttrib(), 0.0f);344ASSERT_GL_NO_ERROR();345EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::white);346}347348// Test atomic counter increment and decrement.349TEST_P(AtomicCounterBufferTest31, AtomicCounterIncrementAndDecrement)350{351constexpr char kCS[] =352"#version 310 es\n"353"layout(local_size_x=1, local_size_y=1, local_size_z=1) in;\n"354"layout(binding = 0, offset = 4) uniform atomic_uint ac[2];\n"355"void main()\n"356"{\n"357" atomicCounterIncrement(ac[0]);\n"358" atomicCounterDecrement(ac[1]);\n"359"}\n";360361ANGLE_GL_COMPUTE_PROGRAM(program, kCS);362363glUseProgram(program.get());364365// The initial value of 'ac[0]' is 3u, 'ac[1]' is 1u.366unsigned int bufferData[3] = {11u, 3u, 1u};367GLBuffer atomicCounterBuffer;368glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomicCounterBuffer);369glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(bufferData), bufferData, GL_STATIC_DRAW);370371glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, atomicCounterBuffer);372373glDispatchCompute(1, 1, 1);374EXPECT_GL_NO_ERROR();375376glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT);377378glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomicCounterBuffer);379void *mappedBuffer =380glMapBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0, sizeof(GLuint) * 3, GL_MAP_READ_BIT);381memcpy(bufferData, mappedBuffer, sizeof(bufferData));382glUnmapBuffer(GL_ATOMIC_COUNTER_BUFFER);383384EXPECT_EQ(11u, bufferData[0]);385EXPECT_EQ(4u, bufferData[1]);386EXPECT_EQ(0u, bufferData[2]);387}388389// Tests multiple atomic counter buffers.390TEST_P(AtomicCounterBufferTest31, AtomicCounterMultipleBuffers)391{392GLint maxAtomicCounterBuffers = 0;393glGetIntegerv(GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS, &maxAtomicCounterBuffers);394constexpr unsigned int kBufferCount = 3;395// ES 3.1 table 20.45 only guarantees 1 atomic counter buffer396ANGLE_SKIP_TEST_IF(maxAtomicCounterBuffers < static_cast<int>(kBufferCount));397398constexpr char kComputeShaderSource[] = R"(#version 310 es399layout(local_size_x=1, local_size_y=1, local_size_z=1) in;400layout(binding = 0) uniform atomic_uint ac1;401layout(binding = 1) uniform atomic_uint ac2;402layout(binding = 2) uniform atomic_uint ac3;403404void main()405{406atomicCounterIncrement(ac1);407atomicCounterIncrement(ac2);408atomicCounterIncrement(ac3);409})";410411ANGLE_GL_COMPUTE_PROGRAM(program, kComputeShaderSource);412413glUseProgram(program);414415GLBuffer atomicCounterBuffers[kBufferCount];416417for (unsigned int ii = 0; ii < kBufferCount; ++ii)418{419GLuint initialData[1] = {ii};420glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomicCounterBuffers[ii]);421glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(initialData), initialData, GL_STATIC_DRAW);422423glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, ii, atomicCounterBuffers[ii]);424}425426glDispatchCompute(1, 1, 1);427EXPECT_GL_NO_ERROR();428429glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT);430431for (unsigned int ii = 0; ii < kBufferCount; ++ii)432{433glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomicCounterBuffers[ii]);434GLuint *mappedBuffer = static_cast<GLuint *>(435glMapBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0, sizeof(GLuint), GL_MAP_READ_BIT));436EXPECT_EQ(ii + 1, mappedBuffer[0]);437glUnmapBuffer(GL_ATOMIC_COUNTER_BUFFER);438}439}440441// Test atomic counter array of array.442TEST_P(AtomicCounterBufferTest31, AtomicCounterArrayOfArray)443{444// Fails on D3D. Some counters are double-incremented while some are untouched, hinting at a445// bug in index translation. http://anglebug.com/3783446ANGLE_SKIP_TEST_IF(IsD3D11());447448// Nvidia's OpenGL driver fails to compile the shader. http://anglebug.com/3791449ANGLE_SKIP_TEST_IF(IsOpenGL() && IsNVIDIA());450451// Intel's Windows OpenGL driver crashes in this test. http://anglebug.com/3791452ANGLE_SKIP_TEST_IF(IsOpenGL() && IsIntel() && IsWindows());453454constexpr char kCS[] = R"(#version 310 es455layout(local_size_x=1, local_size_y=1, local_size_z=1) in;456layout(binding = 0) uniform atomic_uint ac[7][5][3];457458void f0(in atomic_uint ac)459{460atomicCounterIncrement(ac);461}462463void f1(in atomic_uint ac[3])464{465atomicCounterIncrement(ac[0]);466f0(ac[1]);467int index = 2;468f0(ac[index]);469}470471void f2(in atomic_uint ac[5][3])472{473// Increment all in ac[0], ac[1] and ac[2]474for (int i = 0; i < 3; ++i)475{476for (int j = 0; j < 2; ++j)477{478f0(ac[i][j]);479}480f0(ac[i][2]);481}482483// Increment all in ac[3]484f1(ac[3]);485486// Increment all in ac[4]487for (int i = 0; i < 2; ++i)488{489atomicCounterIncrement(ac[4][i]);490}491f0(ac[4][2]);492}493494void f3(in atomic_uint ac[7][5][3])495{496// Increment all in ac[0], ac[1], ac[2] and ac[3]497f2(ac[0]);498for (int i = 1; i < 4; ++i)499{500f2(ac[i]);501}502503// Increment all in ac[5][0], ac[5][1], ac[5][2] and ac[5][3]504for (int i = 0; i < 4; ++i)505{506f1(ac[5][i]);507}508509// Increment all in ac[5][4][0], ac[5][4][1] and ac[5][4][2]510f0(ac[5][4][0]);511for (int i = 1; i < 3; ++i)512{513f0(ac[5][4][i]);514}515516// Increment all in ac[6]517for (int i = 0; i < 5; ++i)518{519for (int j = 0; j < 2; ++j)520{521atomicCounterIncrement(ac[6][i][j]);522}523atomicCounterIncrement(ac[6][i][2]);524}525}526527void main()528{529// Increment all in ac except ac[4]530f3(ac);531532// Increment all in ac[4]533f2(ac[4]);534})";535536constexpr uint32_t kAtomicCounterRows = 7;537constexpr uint32_t kAtomicCounterCols = 5;538constexpr uint32_t kAtomicCounterDepth = 3;539constexpr uint32_t kAtomicCounterCount =540kAtomicCounterRows * kAtomicCounterCols * kAtomicCounterDepth;541542GLint maxAtomicCounters = 0;543glGetIntegerv(GL_MAX_COMPUTE_ATOMIC_COUNTERS, &maxAtomicCounters);544EXPECT_GL_NO_ERROR();545546// Required minimum is 8 by the spec547EXPECT_GE(maxAtomicCounters, 8);548ANGLE_SKIP_TEST_IF(static_cast<uint32_t>(maxAtomicCounters) < kAtomicCounterCount);549550ANGLE_GL_COMPUTE_PROGRAM(program, kCS);551glUseProgram(program.get());552553// The initial value of atomic counters is 0, 1, 2, ...554unsigned int bufferData[kAtomicCounterCount] = {};555for (uint32_t index = 0; index < kAtomicCounterCount; ++index)556{557bufferData[index] = index;558}559560GLBuffer atomicCounterBuffer;561glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomicCounterBuffer);562glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(bufferData), bufferData, GL_STATIC_DRAW);563564glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, atomicCounterBuffer);565566glDispatchCompute(1, 1, 1);567EXPECT_GL_NO_ERROR();568569glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT);570571unsigned int result[kAtomicCounterCount] = {};572glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomicCounterBuffer);573void *mappedBuffer =574glMapBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0, sizeof(bufferData), GL_MAP_READ_BIT);575memcpy(result, mappedBuffer, sizeof(bufferData));576glUnmapBuffer(GL_ATOMIC_COUNTER_BUFFER);577578for (uint32_t index = 0; index < kAtomicCounterCount; ++index)579{580EXPECT_EQ(result[index], bufferData[index] + 1) << "index " << index;581}582}583584// Test inactive atomic counter585TEST_P(AtomicCounterBufferTest31, AtomicCounterInactive)586{587constexpr char kFS[] =588"#version 310 es\n"589"precision highp float;\n"590591// This inactive atomic counter should be removed by RemoveInactiveInterfaceVariables592"layout(binding = 0) uniform atomic_uint inactive;\n"593594"out highp vec4 my_color;\n"595"void main()\n"596"{\n"597" my_color = vec4(0.0, 1.0, 0.0, 1.0);\n"598"}\n";599600ANGLE_GL_PROGRAM(program, essl31_shaders::vs::Simple(), kFS);601glUseProgram(program);602603drawQuad(program, essl31_shaders::PositionAttrib(), 0.0f);604ASSERT_GL_NO_ERROR();605606EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);607}608609// Test inactive memoryBarrierAtomicCounter610TEST_P(AtomicCounterBufferTest31, AtomicCounterMemoryBarrier)611{612constexpr char kFS[] =613"#version 310 es\n"614"precision highp float;\n"615// This inactive atomic counter should be removed by RemoveInactiveInterfaceVariables616"layout(binding = 0) uniform atomic_uint inactive;\n"617"out highp vec4 my_color;\n"618"void main()\n"619"{\n"620" my_color = vec4(0.0, 1.0, 0.0, 1.0);\n"621// This barrier should be removed by RemoveAtomicCounterBuiltins because622// there are no active atomic counters623" memoryBarrierAtomicCounter();\n"624"}\n";625626ANGLE_GL_PROGRAM(program, essl31_shaders::vs::Simple(), kFS);627glUseProgram(program);628629drawQuad(program, essl31_shaders::PositionAttrib(), 0.0f);630ASSERT_GL_NO_ERROR();631632EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);633}634635GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AtomicCounterBufferTest);636GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AtomicCounterBufferTest31);637ANGLE_INSTANTIATE_TEST_ES3_AND_ES31(AtomicCounterBufferTest);638ANGLE_INSTANTIATE_TEST_ES31_AND(AtomicCounterBufferTest31,639WithDirectSPIRVGeneration(ES31_VULKAN()));640641} // namespace642643644