Lines Matching defs:NL

510 			NL "layout(local_size_x = 1, local_size_y = 1) in;" NL "layout(std430) buffer Output {" NL "  vec4 data;" NL
511 "} g_out;" NL "void main() {" NL " g_out.data = vec4(1.0, 2.0, 3.0, 4.0);" NL "}";
921 return NL "1. Verify that declared local work size has correct effect." NL
922 "2. Verify that the number of shader invocations is correct." NL
923 "3. Verify that the built-in variables: gl_WorkGroupSize, gl_WorkGroupID, gl_GlobalInvocationID," NL
924 " gl_LocalInvocationID and gl_LocalInvocationIndex has correct values." NL
930 return NL "1. Create several CS with various local sizes." NL
931 "2. Dispatch each CS with DispatchCompute and DispatchComputeIndirect commands." NL
947 ss << NL "layout(local_size_x = " << x << ", local_size_y = " << y << ", local_size_z = " << z
948 << ") in;" NL "layout(std430, binding = " << binding
949 << ") buffer Output {" NL " uvec4 local_id[];" NL "} g_out;" NL "void main() {" NL
952 << ") && gl_WorkGroupID == uvec3(0) &&" NL " gl_GlobalInvocationID == gl_LocalInvocationID) {" NL
953 " g_out.local_id[gl_LocalInvocationIndex] = uvec4(gl_LocalInvocationID, 0);" NL " } else {" NL
954 " g_out.local_id[gl_LocalInvocationIndex] = uvec4(0xffff);" NL " }" NL "}";
1081 return NL "1. Create CS which uses array of UBOs." NL
1082 "2. Dispatch CS with DispatchCompute and DispatchComputeIndirect commands." NL
1083 "3. Read data from each UBO and write it to SSBO." NL "4. Verify SSBO content." NL
1101 ss << NL "layout(local_size_x = " << local_size.x() << ", local_size_y = " << local_size.y()
1102 << ", local_size_z = " << local_size.z() << ") in;" NL "const uvec3 kGlobalSize = uvec3(" << global_size.x()
1104 << ");" NL "layout(std140) uniform InputBuffer {" NL " vec4 data["
1106 << "];" NL "} g_in_buffer[12];" NL "layout(std430) buffer OutputBuffer {" NL " vec4 data0["
1107 << global_size.x() * global_size.y() * global_size.z() << "];" NL " vec4 data1["
1108 << global_size.x() * global_size.y() * global_size.z() << "];" NL " vec4 data2["
1109 << global_size.x() * global_size.y() * global_size.z() << "];" NL " vec4 data3["
1110 << global_size.x() * global_size.y() * global_size.z() << "];" NL " vec4 data4["
1111 << global_size.x() * global_size.y() * global_size.z() << "];" NL " vec4 data5["
1112 << global_size.x() * global_size.y() * global_size.z() << "];" NL " vec4 data6["
1113 << global_size.x() * global_size.y() * global_size.z() << "];" NL " vec4 data7["
1114 << global_size.x() * global_size.y() * global_size.z() << "];" NL " vec4 data8["
1115 << global_size.x() * global_size.y() * global_size.z() << "];" NL " vec4 data9["
1116 << global_size.x() * global_size.y() * global_size.z() << "];" NL " vec4 data10["
1117 << global_size.x() * global_size.y() * global_size.z() << "];" NL " vec4 data11["
1119 << "];" NL "} g_out_buffer;" NL "void main() {" NL " uint global_index = gl_GlobalInvocationID.x +" NL
1120 " gl_GlobalInvocationID.y * kGlobalSize.x +" NL
1121 " gl_GlobalInvocationID.z * kGlobalSize.x * kGlobalSize.y;" NL
1122 " g_out_buffer.data0[global_index] = g_in_buffer[0].data[global_index];" NL
1123 " g_out_buffer.data1[global_index] = g_in_buffer[1].data[global_index];" NL
1124 " g_out_buffer.data2[global_index] = g_in_buffer[2].data[global_index];" NL
1125 " g_out_buffer.data3[global_index] = g_in_buffer[3].data[global_index];" NL
1126 " g_out_buffer.data4[global_index] = g_in_buffer[4].data[global_index];" NL
1127 " g_out_buffer.data5[global_index] = g_in_buffer[5].data[global_index];" NL
1128 " g_out_buffer.data6[global_index] = g_in_buffer[6].data[global_index];" NL
1129 " g_out_buffer.data7[global_index] = g_in_buffer[7].data[global_index];" NL
1130 " g_out_buffer.data8[global_index] = g_in_buffer[8].data[global_index];" NL
1131 " g_out_buffer.data9[global_index] = g_in_buffer[9].data[global_index];" NL
1132 " g_out_buffer.data10[global_index] = g_in_buffer[10].data[global_index];" NL
1133 " g_out_buffer.data11[global_index] = g_in_buffer[11].data[global_index];" NL "}";
1259 return NL "Compute Shader resources - Textures";
1264 return NL "Verify that texture access works correctly in CS.";
1269 return NL "1. Create CS which uses all sampler types (sampler2D, sampler3D," NL " sampler2DArray)." NL
1270 "2. Dispatch CS with DispatchCompute and DispatchComputeIndirect commands." NL
1271 "3. Sample each texture and write sampled value to SSBO." NL "4. Verify SSBO content." NL
1277 return NL "Everything works as expected.";
1289 ss << NL "layout(local_size_x = " << local_size.x() << ", local_size_y = " << local_size.y()
1290 << ", local_size_z = " << local_size.z() << ") in;" NL "const uvec3 kGlobalSize = uvec3(" << global_size.x()
1292 << ");" NL "uniform sampler2D g_sampler0;" NL "uniform lowp sampler3D g_sampler1;" NL
1293 "uniform mediump sampler2DArray g_sampler2;" NL "layout(std430) buffer OutputBuffer {" NL " vec4 data0["
1294 << global_size.x() * global_size.y() * global_size.z() << "];" NL " vec4 data1["
1295 << global_size.x() * global_size.y() * global_size.z() << "];" NL " vec4 data2["
1297 << "];" NL "} g_out_buffer;" NL "void main() {" NL " uint global_index = gl_GlobalInvocationID.x +" NL
1298 " gl_GlobalInvocationID.y * kGlobalSize.x +" NL
1299 " gl_GlobalInvocationID.z * kGlobalSize.x * kGlobalSize.y;" NL
1301 "vec2(kGlobalSize));" NL " g_out_buffer.data1[global_index] = textureProj(g_sampler1, "
1302 "vec4(vec3(gl_GlobalInvocationID) / vec3(kGlobalSize), 1.0));" NL
1304 "ivec2(0));" NL "}";
1435 return NL "Compute Shader resources - Images";
1440 return NL "Verify that reading/writing GPU memory via image variables work as expected.";
1445 return NL "1. Create CS which uses two image2D variables to read and write underlying GPU memory." NL
1446 "2. Dispatch CS with DispatchCompute and DispatchComputeIndirect commands." NL
1447 "3. Verify memory content." NL "4. Repeat for different texture and CS work sizes.";
1452 return NL "Everything works as expected.";
1467 ss << NL "#extension GL_OES_shader_image_atomic : enable";
1469 ss << NL "layout(local_size_x = " << local_size.x() << ", local_size_y = " << local_size.y()
1471 << ") in;" NL "layout(r32ui, binding=0) coherent uniform mediump uimage2D g_image1;" NL
1472 "layout(r32ui, binding=1) uniform mediump uimage2D g_image2;" NL "const uvec3 kGlobalSize = uvec3("
1474 << ");" NL "void main() {" NL
1475 " if (gl_GlobalInvocationID.x >= kGlobalSize.x || gl_GlobalInvocationID.y >= kGlobalSize.y) return;" NL
1482 ss << NL " imageStore(g_image1, ivec2(gl_GlobalInvocationID), color);" NL
1483 " uvec4 c = imageLoad(g_image1, ivec2(gl_GlobalInvocationID));" NL
1484 " imageStore(g_image2, ivec2(gl_GlobalInvocationID), c);" NL "}";
1490 ss << NL " imageStore(g_image1, ivec2(gl_GlobalInvocationID), uvec4(0));" NL
1491 " imageAtomicAdd(g_image1, ivec2(gl_GlobalInvocationID), color.x);" NL
1492 " uvec4 c = imageLoad(g_image1, ivec2(gl_GlobalInvocationID));" NL
1493 " imageStore(g_image2, ivec2(gl_GlobalInvocationID), c);" NL "}";
1603 NL "const vec2 g_quad[] = vec2[](vec2(-1, -1), vec2(1, -1), vec2(-1, 1), vec2(1, 1));" NL "void main() {" NL
1604 " gl_Position = vec4(g_quad[gl_VertexID], 0, 1);" NL "}";
1607 NL "layout(location = 0) out mediump vec4 o_color;" NL "uniform mediump usampler2D g_image1;" NL
1608 "uniform mediump usampler2D g_image2;" NL "void main() {" NL
1609 " mediump uvec4 c1 = texelFetch(g_image1, ivec2(gl_FragCoord.xy), 0);" NL
1610 " mediump uvec4 c2 = texelFetch(g_image2, ivec2(gl_FragCoord.xy), 0);" NL
1611 " if (c1 == c2) o_color = vec4(float(c1.x)/255.0, 1.0, 1.0, 1.0);" NL
1612 " else o_color = vec4(1, 0, 0, 1);" NL "}";
1661 return NL
1662 "1. Verify that Atomic Counters work as expected in CS." NL
1668 return NL
1669 "1. Create CS which uses two atomic_uint variables." NL
1670 "2. In CS write values returned by atomicCounterIncrement and atomicCounterDecrement functions to SSBO." NL
1671 "3. Dispatch CS with DispatchCompute and DispatchComputeIndirect commands." NL "4. Verify SSBO content." NL
1689 ss << NL "layout(local_size_x = " << local_size.x() << ", local_size_y = " << local_size.y()
1691 << ") in;" NL "layout(std430, binding = 0) buffer Output {" NL " uint inc_data["
1692 << global_size.x() * global_size.y() * global_size.z() << "];" NL " uint dec_data["
1694 << "];" NL "};" NL "layout(binding = 0, offset = 0) uniform atomic_uint g_inc_counter;" NL
1695 "layout(binding = 0, offset = 4) uniform atomic_uint g_dec_counter;" NL "void main() {" NL
1696 " uint index = atomicCounterIncrement(g_inc_counter);" NL " inc_data[index] = index;" NL
1697 " dec_data[index] = atomicCounterDecrement(g_dec_counter);" NL "}";
1834 return NL "1. Verify that all types of uniform variables work as expected in CS." NL
1840 return NL "1. Create CS which uses all (single precision and integer) types of uniform variables." NL
1841 "2. Update uniform variables with Uniform* commands." NL
1862 const char* const glsl_cs = NL
1863 "layout(local_size_x = 1) in;" NL "buffer Result {" NL " int g_result;" NL "};" NL "uniform float g_0;" NL
1864 "uniform vec2 g_1;" NL "uniform vec3 g_2;" NL "uniform vec4 g_3;" NL "uniform mat2 g_4;" NL
1865 "uniform mat2x3 g_5;" NL "uniform mat2x4 g_6;" NL "uniform mat3x2 g_7;" NL "uniform mat3 g_8;" NL
1866 "uniform mat3x4 g_9;" NL "uniform mat4x2 g_10;" NL "uniform mat4x3 g_11;" NL "uniform mat4 g_12;" NL
1867 "uniform int g_13;" NL "uniform ivec2 g_14;" NL "uniform ivec3 g_15;" NL "uniform ivec4 g_16;" NL
1868 "uniform uint g_17;" NL "uniform uvec2 g_18;" NL "uniform uvec3 g_19;" NL "uniform uvec4 g_20;" NL NL
1869 "void main() {" NL " g_result = 1;" NL NL " if (g_0 != 1.0) g_result = 0;" NL
1870 " if (g_1 != vec2(2.0, 3.0)) g_result = 0;" NL " if (g_2 != vec3(4.0, 5.0, 6.0)) g_result = 0;" NL
1871 " if (g_3 != vec4(7.0, 8.0, 9.0, 10.0)) g_result = 0;" NL NL
1872 " if (g_4 != mat2(11.0, 12.0, 13.0, 14.0)) g_result = 0;" NL
1873 " if (g_5 != mat2x3(15.0, 16.0, 17.0, 18.0, 19.0, 20.0)) g_result = 0;" NL
1874 " if (g_6 != mat2x4(21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0)) g_result = 0;" NL NL
1875 " if (g_7 != mat3x2(29.0, 30.0, 31.0, 32.0, 33.0, 34.0)) g_result = 0;" NL
1876 " if (g_8 != mat3(35.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 43.0)) g_result = 0;" NL
1878 "0;" NL NL " if (g_10 != mat4x2(56.0, 57.0, 58.0, 59.0, 60.0, 61.0, 62.0, 63.0)) g_result = 0;" NL
1880 "0;" NL " if (g_12 != mat4(75.0, 76.0, 77.0, 78.0, 79.0, 80.0, 81.0, 82.0, 83.0, 84.0, 85.0, 86.0, 87.0, "
1881 "88.0, 89.0, 90.0)) g_result = 0;" NL NL " if (g_13 != 91) g_result = 0;" NL
1882 " if (g_14 != ivec2(92, 93)) g_result = 0;" NL " if (g_15 != ivec3(94, 95, 96)) g_result = 0;" NL
1883 " if (g_16 != ivec4(97, 98, 99, 100)) g_result = 0;" NL NL " if (g_17 != 101u) g_result = 0;" NL
1884 " if (g_18 != uvec2(102u, 103u)) g_result = 0;" NL
1885 " if (g_19 != uvec3(104u, 105u, 106u)) g_result = 0;" NL
1886 " if (g_20 != uvec4(107u, 108u, 109u, 110u)) g_result = 0;" NL "}";
2009 return NL "Verify that all (gl_WorkGroupSize, gl_WorkGroupID, gl_LocalInvocationID," NL
2010 "gl_GlobalInvocationID, gl_NumWorkGroups, gl_WorkGroupSize)" NL
2016 return NL "1. Create CS which writes all built-in variables to SSBO." NL
2017 "2. Dispatch CS with DispatchCompute and DispatchComputeIndirect commands." NL
2018 "3. Verify SSBO content." NL "4. Repeat for several different local and global work sizes.";
2034 ss << NL "layout(local_size_x = " << local_size.x() << ", local_size_y = " << local_size.y()
2035 << ", local_size_z = " << local_size.z() << ") in;" NL "const uvec3 kGlobalSize = uvec3(" << global_size.x()
2037 << ");" NL "layout(std430) buffer OutputBuffer {" NL " uvec4 num_work_groups["
2038 << global_size.x() * global_size.y() * global_size.z() << "];" NL " uvec4 work_group_size["
2039 << global_size.x() * global_size.y() * global_size.z() << "];" NL " uvec4 work_group_id["
2040 << global_size.x() * global_size.y() * global_size.z() << "];" NL " uvec4 local_invocation_id["
2041 << global_size.x() * global_size.y() * global_size.z() << "];" NL " uvec4 global_invocation_id["
2042 << global_size.x() * global_size.y() * global_size.z() << "];" NL " uvec4 local_invocation_index["
2044 << "];" NL "} g_out_buffer;" NL "void main() {" NL
2045 " if ((gl_WorkGroupSize * gl_WorkGroupID + gl_LocalInvocationID) != gl_GlobalInvocationID) return;" NL
2046 " uint global_index = gl_GlobalInvocationID.x +" NL
2047 " gl_GlobalInvocationID.y * kGlobalSize.x +" NL
2048 " gl_GlobalInvocationID.z * kGlobalSize.x * kGlobalSize.y;" NL
2049 " g_out_buffer.num_work_groups[global_index] = uvec4(gl_NumWorkGroups, 0);" NL
2050 " g_out_buffer.work_group_size[global_index] = uvec4(gl_WorkGroupSize, 0);" NL
2051 " g_out_buffer.work_group_id[global_index] = uvec4(gl_WorkGroupID, 0);" NL
2052 " g_out_buffer.local_invocation_id[global_index] = uvec4(gl_LocalInvocationID, 0);" NL
2053 " g_out_buffer.global_invocation_id[global_index] = uvec4(gl_GlobalInvocationID, 0);" NL
2054 " g_out_buffer.local_invocation_index[global_index] = uvec4(gl_LocalInvocationIndex);" NL "}";
2224 return NL "CS max values";
2229 return NL "Verify (on the API and GLSL side) that all GL_MAX_COMPUTE_* values are not less than" NL
2235 return NL "1. Use all API commands to query all GL_MAX_COMPUTE_* values. Verify that they are correct." NL
2241 return NL "Everything works as expected.";
2351 NL "layout(local_size_x = 1) in;" NL "layout(std430) buffer Output {" NL " int g_output;" NL "};" NL
2352 "uniform ivec3 MaxComputeWorkGroupCount;" NL "uniform ivec3 MaxComputeWorkGroupSize;" NL
2353 "uniform int MaxComputeUniformComponents;" NL "uniform int MaxComputeTextureImageUnits;" NL
2354 "uniform int MaxComputeImageUniforms;" NL "uniform int MaxComputeAtomicCounters;" NL
2355 "uniform int MaxComputeAtomicCounterBuffers;" NL "void main() {" NL " g_output = 1;" NL
2356 " if (MaxComputeWorkGroupCount != gl_MaxComputeWorkGroupCount) g_output = 0;" NL
2357 " if (MaxComputeWorkGroupSize != gl_MaxComputeWorkGroupSize) g_output = 0;" NL
2358 " if (MaxComputeUniformComponents != gl_MaxComputeUniformComponents) g_output = 0;" NL
2359 " if (MaxComputeTextureImageUnits != gl_MaxComputeTextureImageUnits) g_output = 0;" NL
2360 " if (MaxComputeImageUniforms != gl_MaxComputeImageUniforms) g_output = 0;" NL
2361 " if (MaxComputeAtomicCounters != gl_MaxComputeAtomicCounters) g_output = 0;" NL
2362 " if (MaxComputeAtomicCounterBuffers != gl_MaxComputeAtomicCounterBuffers) g_output = 0;" NL "}";
2435 return NL "Verify that calling AttachShader with multiple shader objects of type COMPUTE_SHADER generates "
2441 return NL "Try to attach multiple shader objects of the same type and verify that proper error is generated.";
2451 const char* const cs1[2] = { "#version 310 es", NL "layout(local_size_x = 1) in;" NL "void Run();" NL
2452 "void main() {" NL " Run();" NL "}" };
2455 "#version 310 es" NL "layout(binding = 0, std430) buffer Output {" NL " vec4 g_output;" NL "};" NL
2456 "vec4 CalculateOutput();" NL "void Run() {" NL " g_output = CalculateOutput();" NL "}";
2459 "#version 310 es" NL "layout(local_size_x = 1) in;" NL "layout(binding = 0, std430) buffer Output {" NL
2460 " vec4 g_output;" NL "};" NL "vec4 CalculateOutput() {" NL " g_output = vec4(0);" NL
2461 " return vec4(1, 2, 3, 4);" NL "}";
2528 return NL "1. Verify that building separable CS program works as expected." NL
2534 return NL "1. Create, compile and link CS using CreateShaderProgramv command." NL
2548 NL "layout(local_size_x = 1) in;" NL "void Run();" NL "void main() {" NL " Run();" NL "}",
2550 NL "layout(binding = 0, std430) buffer Output {" NL " vec4 g_output;" NL "};" NL
2551 "vec4 CalculateOutput();" NL "void Run() {" NL " g_output = CalculateOutput();" NL "}",
2553 NL "vec4 CalculateOutput() {" NL " g_output = vec4(0);" NL " return vec4(1, 2, 3, 4);" NL "}"
2619 return NL "1. Verify that shared array of uints works as expected." NL
2620 "2. Verify that shared memory written by one invocation is observable by other invocations" NL
2626 return NL "1. Create and dispatch CS with DispatchCompute and DispatchComputeIndirect commands." NL
2627 "2. Verify results written by CS to SSBO." NL
2697 NL "layout(local_size_x = 128) in;" NL "layout(std430) buffer Output {" NL " uint g_output[];" NL "};" NL
2698 "shared uint g_shared_data[128];" NL "void main() {" NL
2699 " g_shared_data[gl_LocalInvocationID.x] = gl_LocalInvocationIndex;" NL
2701 NL " barrier();" // wait for all stores to finish
2702 NL " g_output[gl_GlobalInvocationID.x] = 1u;" NL " if (gl_LocalInvocationIndex < 127u) {" NL
2705 NL " if (res != (gl_LocalInvocationIndex + 1u)) {" NL " g_output[gl_GlobalInvocationID.x] = 0u;" NL
2706 " }" NL " }" NL "}";
2741 return NL "1. Verify that vectors, matrices, structers and arrays of those can be used" NL
2742 " as a shared memory." NL
2743 "2. Verify that shared memory can be indexed with constant values, built-in" NL
2744 " variables and dynamic expressions." NL
2745 "3. Verify that memoryBarrierAtomicCounter(), memoryBarrierImage(), memoryBarrier()," NL
2746 " memoryBarrierBuffer() and memoryBarrierShared() built-in functions are accepted" NL
2752 return NL "1. Create and dispatch CS with DispatchCompute and DispatchComputeIndirect commands." NL
2821 const char* const glsl_cs = NL
2822 "layout(local_size_x = 128) in;" NL "layout(std430) buffer Output {" NL " vec4 g_output[256];" NL "};" NL
2823 "struct SubData {" NL " mat2x4 data;" NL "};" NL "struct Data {" NL " vec3 data0;" NL " uint index;" NL
2824 " SubData data1;" NL "};" NL "shared Data g_shared_data[256];" NL "shared int g_shared_buf[2];" NL
2825 "void main() {" NL " if (gl_LocalInvocationID.x == 0u) {" NL " g_shared_buf[1] = 1;" NL
2826 " g_shared_buf[1u + gl_LocalInvocationID.x] = 0;" NL " g_shared_buf[0] = 128;" NL
2827 " g_output[0] = vec4(g_shared_buf[1]);" NL " g_output[128] = vec4(g_shared_buf[0]);" NL
2829 NL " } else {" NL " uint index = gl_LocalInvocationIndex;" NL
2830 " g_shared_data[index].index = index;" NL " g_shared_data[index + 128u].index = index + 128u;" NL
2831 " g_shared_data[index].data1.data = mat2x4(0.0);" NL
2832 " g_shared_data[index + 128u].data1.data = mat2x4(0.0);" NL
2834 NL " g_output[index + 128u] = vec4(g_shared_data[index + 128u].index);" NL
2836 NL " }" NL " memoryBarrierAtomicCounter();" NL " memoryBarrierImage();" NL
2838 NL "}";
2865 return NL "DispatchComputeIndirect command";
2870 return NL
2871 "1. Verify that DispatchComputeIndirect command works as described in the OpenGL specification." NL
2872 "2. Verify that <offset> parameter is correctly applied." NL
2873 "3. Verify that updating dispatch buffer with different methods (BufferData, BufferSubData, MapBuffer)" NL
2874 " just before DispatchComputeIndirect call works as expected." NL
2880 return NL
2881 "1. Create CS and dispatch indirect buffer." NL "2. Dispatch CS with DispatchComputeIndirect command." NL
2882 "3. Update dispatch indirect buffer." NL
2888 return NL "Everything works as expected.";
2968 NL "layout(local_size_x = 1) in;" NL "layout(std430) buffer Output {" NL " uint g_output[];" NL "};" NL
2969 "uniform uvec3 g_global_size;" NL "void main() {" NL " uint global_index = gl_GlobalInvocationID.x +" NL
2970 " gl_GlobalInvocationID.y * g_global_size.x +" NL
2971 " gl_GlobalInvocationID.z * g_global_size.x * g_global_size.y;" NL
2972 " if (gl_NumWorkGroups != g_global_size) {" NL " g_output[global_index] = 0xffffu;" NL
2973 " return;" NL " }" NL " g_output[global_index] = global_index;" NL "}";
3056 return NL "Separable CS Programs - Compute and non-compute stages (1)";
3060 return NL "1. Verify that compute and non-compute stages can be attached to one pipeline object." NL
3065 return NL "1. Create VS, FS and CS. Attach all created stages to one pipeline object." NL
3066 "2. Bind pipeline object." NL "3. Invoke compute stage with DispatchCompute commmand." NL
3067 "4. Issue MemoryBarrier command." NL
3068 "5. Issue DrawArrays command which uses data written by the compute stage." NL "6. Verify result.";
3072 return NL "Everything works as expected.";
3090 const char* const glsl_cs = NL
3091 "layout(local_size_x = 4) in;" NL "layout(std430) buffer Output {" NL " vec4 g_output[4];" NL "};" NL
3092 "void main() {" NL " const vec2 quad[4] = vec2[](vec2(-1, -1), vec2(1, -1), vec2(-1, 1), vec2(1, 1));" NL
3093 " g_output[gl_GlobalInvocationID.x] = vec4(quad[gl_GlobalInvocationID.x], 0, 1);" NL "}";
3101 NL "layout(location = 0) in vec4 i_position;" NL "void main() {" NL " gl_Position = i_position;" NL "}";
3106 const char* const glsl_fs = NL "layout(location = 0) out mediump vec4 o_color;" NL "void main() {" NL
3107 " o_color = vec4(0, 1, 0, 1);" NL "}";
3160 return NL "Separable CS Programs - Compute and non-compute stages (2)";
3164 return NL "1. Verify that data computed by the compute stage is visible to non-compute stage after "
3165 "MemoryBarrier command." NL "2. Verify that ProgramParameteri(program, GL_PROGRAM_SEPARABLE, "
3166 "GL_TRUE) command works correctly for CS." NL
3171 return NL "1. Create VS, FS and CS. Attach all created stages to one pipeline object." NL
3172 "2. Bind pipeline object." NL "3. Invoke compute stage with DispatchCompute commmand." NL
3173 "4. Issue MemoryBarrier command." NL
3174 "5. Issue DrawArrays command which uses data written to the buffer object by the compute stage." NL
3179 return NL "Everything works as expected.";
3208 "#version 310 es" NL "layout(binding = 1, std430) buffer Input {" NL " mediump vec2 g_input[4];" NL "};" NL
3209 "flat out mediump vec3 color;" NL "void main() {" NL
3210 " gl_Position = vec4(g_input[gl_VertexID], 0.0, 1.0);" NL " color = vec3(0.0, 1.0, 0.0);" NL "}";
3212 "#version 310 es" NL "flat in mediump vec3 color;" NL "layout(location = 0) out mediump vec4 g_color;" NL
3213 "void main() {" NL " g_color = vec4(color, 1.0);" NL "}";
3215 "#version 310 es" NL "layout(local_size_x = 4) in;" NL "layout(binding = 1, std430) buffer Output {" NL
3216 " vec2 g_output[gl_WorkGroupSize.x];" NL "};" NL "void main() {" NL
3217 " if (gl_GlobalInvocationID.x == 0u) {" NL " g_output[0] = vec2(-0.8, -0.8);" NL
3218 " } else if (gl_GlobalInvocationID.x == 1u) {" NL " g_output[1] = vec2(0.8, -0.8);" NL
3219 " } else if (gl_GlobalInvocationID.x == 2u) {" NL " g_output[2] = vec2(-0.8, 0.8);" NL
3220 " } else if (gl_GlobalInvocationID.x == 3u) {" NL " g_output[3] = vec2(0.8, 0.8);" NL " }" NL "}";
3278 return NL "Separable CS Programs - Compute stage";
3282 return NL "Verify that compute shader stage selected with UseProgram command has precedence" NL
3287 return NL "1. Create CS0 with CreateProgram command. Create CS1 with CreateShaderProgramv command." NL
3288 "2. Verify that CS program selected with UseProgram is dispatched even if there is active" NL
3293 return NL "Everything works as expected.";
3312 "#version 310 es" NL "layout(local_size_x = 1) in;" NL "layout(binding = 3, std430) buffer Output {" NL
3313 " int g_output;" NL "};" NL "void main() {" NL " g_output = 1;" NL "}";
3315 "#version 310 es" NL "layout(local_size_x = 1) in;" NL "layout(binding = 3, std430) buffer Output {" NL
3316 " int g_output;" NL "};" NL "void main() {" NL " g_output = 2;" NL "}";
3425 return NL "Atomic functions";
3429 return NL "1. Verify that atomicAdd function works as expected with int and uint parameters." NL
3430 "2. Verify that shared memory can be used with atomic functions." NL
3435 return NL "1. Use shared memory as a 'counter' with-in one CS work group." NL
3436 "2. Each shader invocation increments/decrements 'counter' value using atomicAdd function." NL
3437 "3. Values returned by atomicAdd function are written to SSBO." NL
3442 return NL "Everything works as expected.";
3457 NL "layout(local_size_x = 8) in;" NL "layout(std430, binding = 0) buffer Output {" NL
3458 " uint g_add_output[8];" NL " int g_sub_output[8];" NL "};" NL "shared uint g_add_value;" NL
3459 "shared int g_sub_value;" NL "void main() {" NL " if (gl_LocalInvocationIndex == 0u) {" NL
3460 " g_add_value = 0u;" NL " g_sub_value = 7;" NL " }" NL
3461 " g_add_output[gl_LocalInvocationIndex] = 0u;" NL " g_sub_output[gl_LocalInvocationIndex] = 0;" NL
3462 " groupMemoryBarrier();" NL " barrier();" NL
3463 " g_add_output[gl_LocalInvocationIndex] = atomicAdd(g_add_value, 1u);" NL
3464 " g_sub_output[gl_LocalInvocationIndex] = atomicAdd(g_sub_value, -1);" NL "}";
3522 return NL "Atomic functions - buffer variables";
3526 return NL "1. Verify that all atomic functions (atomicExchange, atomicMin, atomicMax," NL
3527 " atomicAnd, atomicOr, atomicXor and atomicCompSwap) works as expected with buffer variables." NL
3528 "2. Verify that atomic functions work with parameters being constants and" NL
3529 " with parameters being uniforms." NL
3534 return NL "1. Create CS that uses all atomic functions. Values returned by the atomic functions are written to "
3535 "SSBO." NL "2. Dispatch CS with DispatchCompute and DispatchComputeIndirect commands." NL
3536 "3. Verify SSBO content." NL
3541 return NL "Everything works as expected.";
3552 ss << NL "layout(local_size_x = " << local_size.x() << ", local_size_y = " << local_size.y()
3553 << ", local_size_z = " << local_size.z() << ") in;" NL "const uvec3 kGlobalSize = uvec3(" << global_size.x()
3555 << ");" NL "layout(std430, binding = 0) buffer OutputU {" NL " uint g_uint_out["
3557 << "];" NL "};" NL "layout(std430, binding = 1) buffer OutputI {" NL " int data["
3559 << "];" NL "} g_int_out;" NL "uniform uint g_uint_value[8];" NL "void main() {" NL
3560 " uint global_index = gl_GlobalInvocationID.x +" NL
3561 " gl_GlobalInvocationID.y * kGlobalSize.x +" NL
3562 " gl_GlobalInvocationID.z * kGlobalSize.x * kGlobalSize.y;" NL
3563 " atomicExchange(g_uint_out[global_index], g_uint_value[0]);" NL
3564 " atomicMin(g_uint_out[global_index], g_uint_value[1]);" NL
3565 " atomicMax(g_uint_out[global_index], g_uint_value[2]);" NL
3566 " atomicAnd(g_uint_out[global_index], g_uint_value[3]);" NL
3567 " atomicOr(g_uint_out[global_index], g_uint_value[4]);" NL " if (g_uint_value[0] > 0u) {" NL
3569 NL " atomicXor(g_uint_out[global_index], g_uint_value[5]);" NL " }" NL
3570 " atomicCompSwap(g_uint_out[global_index], g_uint_value[6], g_uint_value[7]);" NL NL
3571 " atomicExchange(g_int_out.data[global_index], 3);" NL " atomicMin(g_int_out.data[global_index], 1);" NL
3572 " atomicMax(g_int_out.data[global_index], 2);" NL " atomicAnd(g_int_out.data[global_index], 0x1);" NL
3573 " atomicOr(g_int_out.data[global_index], 0x3);" NL " atomicXor(g_int_out.data[global_index], 0x1);" NL
3574 " atomicCompSwap(g_int_out.data[global_index], 0x2, 0x7);" NL "}";
3684 return NL "Atomic functions - shared variables";
3688 return NL "1. Verify that all atomic functions (atomicExchange, atomicMin, atomicMax," NL
3689 " atomicAnd, atomicOr, atomicXor and atomicCompSwap) works as expected with shared variables." NL
3690 "2. Verify that atomic functions work with parameters being constants and" NL
3691 " with parameters being uniforms." NL
3696 return NL "1. Create CS that uses all atomic functions. Values returned by the atomic functions are written to "
3697 "SSBO." NL "2. Dispatch CS with DispatchCompute and DispatchComputeIndirect commands." NL
3698 "3. Verify SSBO content." NL
3703 return NL "Everything works as expected.";
3713 ss << NL "layout(local_size_x = " << local_size.x() << ", local_size_y = " << local_size.y()
3715 << ") in;" NL "layout(std430, binding = 0) buffer Output {" NL " uint g_uint_out["
3716 << local_size.x() * local_size.y() * local_size.z() << "];" NL " int g_int_out["
3717 << local_size.x() * local_size.y() * local_size.z() << "];" NL "};" NL "shared uint g_shared_uint["
3718 << local_size.x() * local_size.y() * local_size.z() << "];" NL "shared int g_shared_int["
3720 << "];" NL "uniform uint g_uint_value[8];" NL "void main() {" NL
3721 " atomicExchange(g_shared_uint[gl_LocalInvocationIndex], g_uint_value[0]);" NL
3722 " atomicMin(g_shared_uint[gl_LocalInvocationIndex], g_uint_value[1]);" NL
3723 " atomicMax(g_shared_uint[gl_LocalInvocationIndex], g_uint_value[2]);" NL
3724 " atomicAnd(g_shared_uint[gl_LocalInvocationIndex], g_uint_value[3]);" NL
3725 " atomicOr(g_shared_uint[gl_LocalInvocationIndex], g_uint_value[4]);" NL
3726 " atomicXor(g_shared_uint[gl_LocalInvocationIndex], g_uint_value[5]);" NL
3727 " atomicCompSwap(g_shared_uint[gl_LocalInvocationIndex], g_uint_value[6], g_uint_value[7]);" NL NL
3728 " atomicExchange(g_shared_int[gl_LocalInvocationIndex], 3);" NL
3729 " atomicMin(g_shared_int[gl_LocalInvocationIndex], 1);" NL
3730 " atomicMax(g_shared_int[gl_LocalInvocationIndex], 2);" NL
3731 " atomicAnd(g_shared_int[gl_LocalInvocationIndex], 0x1);" NL " if (g_uint_value[1] > 0u) {" NL
3732 " atomicOr(g_shared_int[gl_LocalInvocationIndex], 0x3);" NL
3733 " atomicXor(g_shared_int[gl_LocalInvocationIndex], 0x1);" NL
3734 " atomicCompSwap(g_shared_int[gl_LocalInvocationIndex], 0x2, 0x7);" NL " }" NL NL
3735 " g_uint_out[gl_LocalInvocationIndex] = g_shared_uint[gl_LocalInvocationIndex];" NL
3736 " g_int_out[gl_LocalInvocationIndex] = g_shared_int[gl_LocalInvocationIndex];" NL "}";
3842 return NL "Copy Image";
3846 return NL "Verify that copying two textures using CS works as expected.";
3850 return NL "Use shader image load and store operations to copy two textures in the CS.";
3854 return NL "Everything works as expected.";
3871 NL "#define TILE_WIDTH 8" NL "#define TILE_HEIGHT 8" NL
3872 "const ivec2 kTileSize = ivec2(TILE_WIDTH, TILE_HEIGHT);" NL NL
3873 "layout(binding = 0, rgba8) readonly uniform mediump image2D g_input_image;" NL
3874 "layout(binding = 1, rgba8) writeonly uniform mediump image2D g_output_image;" NL NL
3875 "layout(local_size_x=TILE_WIDTH, local_size_y=TILE_HEIGHT) in;" NL NL "void main() {" NL
3876 " ivec2 tile_xy = ivec2(gl_WorkGroupID);" NL " ivec2 thread_xy = ivec2(gl_LocalInvocationID);" NL
3877 " ivec2 pixel_xy = tile_xy * kTileSize + thread_xy;" NL NL
3878 " vec4 pixel = imageLoad(g_input_image, pixel_xy);" NL
3879 " imageStore(g_output_image, pixel_xy, pixel);" NL "}";
3937 return NL "CS as an additional pipeline stage - Before VS (1)";
3941 return NL "Verify that CS which runs just before VS and modifies VBO content works as expected.";
3945 return NL "1. Prepare VBO and VAO for a drawing operation." NL "2. Run CS to modify existing VBO content." NL
3946 "3. Issue MemoryBarrier(GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT) command." NL
3947 "4. Issue draw call command." NL "5. Verify that the framebuffer content is as expected.";
3951 return NL "Everything works as expected.";
3967 const char* const glsl_cs = NL "layout(local_size_x = 4) in;" NL "struct Vertex {" NL " vec4 position;" NL
3968 " vec4 color;" NL "};" NL "layout(binding = 0, std430) buffer VertexBuffer {" NL
3969 " Vertex g_vertex[];" NL "};" NL "uniform float g_scale;" NL "void main() {" NL
3970 " g_vertex[gl_GlobalInvocationID.x].position.xyz *= g_scale;" NL
3971 " g_vertex[gl_GlobalInvocationID.x].color *= vec4(0.0, 1.0, 0.0, 1.0);" NL "}";
3981 NL "layout(location = 0) in mediump vec4 g_position;" NL "layout(location = 1) in mediump vec4 g_color;" NL
3982 "flat out mediump vec4 color;" NL "void main() {" NL " gl_Position = g_position;" NL
3983 " color = g_color;" NL "}";
3985 NL "flat in mediump vec4 color;" NL "layout(location = 0) out mediump vec4 g_color;" NL "void main() {" NL
3986 " g_color = color;" NL "}";
4044 return NL "CS as an additional pipeline stage - Before VS (2)";
4048 return NL "Verify that a complex scenario where CS is used to generate drawing commands" NL
4049 "and write them to a draw indirect buffer works as expected. This is a practial usage of CS." NL
4054 return NL "1. Run CS which will generate four sets of draw call parameters and write them to the draw indirect "
4055 "buffer." NL "2. One set of draw call parameters will be: 0, 0, 0, 0" NL
4056 " (which means that an object is outside of the viewing frustum and should not be drawn)." NL
4057 "3. Issue MemoryBarrier(GL_COMMAND_BARRIER_BIT) command." NL
4058 "4. Issue four draw indirect commands." NL "5. Verify that the framebuffer content is as expected.";
4062 return NL "Everything works as expected.";
4093 NL "layout(local_size_x = 4) in;" NL "struct DrawCommand {" NL " uint count;" NL
4094 " uint instance_count;" NL " uint first_index;" NL " int base_vertex;" NL " uint base_instance;" NL
4095 "};" NL "layout(std430) buffer;" NL "layout(binding = 0) readonly buffer ObjectBuffer {" NL
4096 " mat4 transform[4];" NL " uint count[4];" NL " uint first_index[4];" NL "} g_objects;" NL
4097 "layout(binding = 1) writeonly buffer DrawCommandBuffer {" NL " DrawCommand g_command[4];" NL "};" NL
4098 "bool IsObjectVisible(uint id) {" NL
4099 " if (g_objects.transform[id][3].x < -1.0 || g_objects.transform[id][3].x > 1.0) return false;" NL
4100 " if (g_objects.transform[id][3][1] < -1.0 || g_objects.transform[id][3][1] > 1.0) return false;" NL
4101 " if (g_objects.transform[id][3][2] < -1.0 || g_objects.transform[id][3].z > 1.0) return false;" NL
4102 " return true;" NL "}" NL "void main() {" NL " uint id = gl_GlobalInvocationID.x;" NL
4103 " g_command[id].count = 0u;" NL " g_command[id].instance_count = 0u;" NL
4104 " g_command[id].first_index = 0u;" NL " g_command[id].base_vertex = int(0);" NL
4105 " g_command[id].base_instance = 0u;" NL " if (IsObjectVisible(id)) {" NL
4106 " g_command[id].count = g_objects.count[id];" NL " g_command[id].instance_count = 1u;" NL
4107 " g_command[id].first_index = g_objects.first_index[id];" NL " }" NL "}";
4114 NL "layout(location = 0) in mediump vec4 g_position;" NL "layout(location = 1) in mediump vec3 g_color;" NL
4115 "flat out mediump vec3 color;" NL "layout(binding = 0, std430) buffer ObjectBuffer {" NL
4116 " mediump mat4 transform[4];" NL " uint count[4];" NL " uint first_index[4];" NL "} g_objects;" NL
4117 "uniform int g_object_id;" NL "void main() {" NL
4118 " gl_Position = g_objects.transform[g_object_id] * g_position;" NL " color = g_color;" NL "}";
4120 NL "flat in mediump vec3 color;" NL "layout(location = 0) out mediump vec4 g_color;" NL "void main() {" NL
4121 " g_color = vec4(color, 1.0);" NL "}";
4229 return NL "Compute Chain";
4233 return NL "1. Verify that dispatching several compute kernels that work in a sequence" NL
4234 " with a common set of resources works as expected." NL
4235 "2. Verify that indexing nested structures with built-in variables work as expected." NL
4236 "3. Verify that two kernels can write to the same resource without MemoryBarrier" NL
4241 return NL "1. Create a set of GPU resources (buffers, images, atomic counters)." NL
4242 "2. Dispatch Kernel0 that write to these resources." NL "3. Issue MemoryBarrier command." NL
4243 "4. Dispatch Kernel1 that read/write from/to these resources." NL "5. Issue MemoryBarrier command." NL
4244 "6. Dispatch Kernel2 that read/write from/to these resources." NL
4249 return NL "Everything works as expected.";
4260 return NL "precision highp image2D;" NL "struct S0 {" NL " int m0[8];" NL "};" NL "struct S1 {" NL
4261 " S0 m0[8];" NL "};" NL "layout(binding = 0, std430) buffer Buffer0 {" NL " int m0[5];" NL
4262 " S1 m1[8];" NL "} g_buffer0;" NL "layout(binding = 1, std430) buffer Buffer1 {" NL
4263 " uint data[8];" NL "} g_buffer1;" NL "layout(binding = 2, std430) buffer Buffer2 {" NL
4264 " int data[256];" NL "} g_buffer2;" NL "layout(binding = 3, std430) buffer Buffer3 {" NL
4265 " int data[256];" NL "} g_buffer3;" NL "layout(binding = 4, std430) buffer Buffer4 {" NL
4266 " mat4 data0;" NL " mat4 data1;" NL "} g_buffer4;" NL
4267 "layout(binding = 0, rgba8) writeonly uniform mediump image2D g_image0;" NL
4276 ss << NL "layout(local_size_x = 4, local_size_y = 4, local_size_z = 4) in;" NL
4277 "void UpdateBuffer0(uvec3 id, int add_val) {" NL " if (id.x < 8u && id.y < 8u && id.z < 8u) {" NL
4278 " g_buffer0.m1[id.z].m0[id.y].m0[id.x] += add_val;" NL " }" NL "}" NL
4279 "uniform int g_add_value;" NL "uniform uint g_counter_y;" NL "uniform vec4 g_image_value;" NL
4280 "void main() {" NL " uvec3 id = gl_GlobalInvocationID;" NL " UpdateBuffer0(id, 1);" NL
4281 " UpdateBuffer0(id, g_add_value);" NL " if (id == uvec3(1, g_counter_y, 1)) {" NL
4282 " uint idx = atomicCounterIncrement(g_counter[1]);" NL " g_buffer1.data[idx] = idx;" NL
4283 " idx = atomicCounterIncrement(g_counter[1]);" NL " g_buffer1.data[idx] = idx;" NL " }" NL
4284 " if (id.x < 4u && id.y < 4u && id.z == 0u) {" NL
4285 " imageStore(g_image0, ivec2(id.xy), g_image_value);" NL " }" NL
4286 " if (id.x < 2u && id.y == 0u && id.z == 0u) {" NL
4287 " g_buffer2.data[id.x] -= int(g_counter_y);" NL " }" NL "}";
4291 ss << NL "layout(local_size_x = 4, local_size_y = 4, local_size_z = 1) in;"
4293 NL "uniform mat4 g_mvp;" NL "void main() {" NL " if (gl_GlobalInvocationID == uvec3(0)) {" NL
4294 " g_buffer4.data0 *= g_mvp;" NL " }" NL " if (gl_WorkGroupID == uvec3(0)) {" NL
4296 "g_mvp[gl_LocalInvocationID.x][gl_LocalInvocationID.y];" NL " }" NL "}";
4300 ss << NL "layout(local_size_x = 4, local_size_y = 4, local_size_z = 4) in;" NL "void main() {" NL "}";
4544 return NL "CS as an additional pipeline stage - After FS";
4548 return NL "1. Verify that CS which runs just after FS to do a post-processing on a rendered image works as "
4549 "expected." NL "2. Verify that CS used as a post-processing filter works as expected." NL
4555 return NL
4556 "1. Render image to Texture0 using VS and FS." NL
4557 "2. Use Texture0 as an input to Kernel0 which performs post-processing and writes result to Texture1." NL
4558 "3. Issue MemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT) command." NL
4559 "4. Use Texture1 as an input to Kernel1 which performs post-processing and writes result to Texture0." NL
4560 "5. Issue MemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT) command." NL
4565 return NL "Everything works as expected.";
4587 NL "const mediump vec2 g_vertex[4] = vec2[4](vec2(0.0), vec2(-1.0, -1.0), vec2(3.0, -1.0), vec2(-1.0, "
4588 "3.0));" NL "void main() {" NL " gl_Position = vec4(g_vertex[gl_VertexID], 0.0, 1.0);" NL "}";
4589 const char* const glsl_fs = NL "layout(location = 0) out mediump vec4 g_color;" NL "void main() {" NL
4590 " g_color = vec4(1.0, 0.0, 0.0, 1.0);" NL "}";
4597 NL "#define TILE_WIDTH 4" NL "#define TILE_HEIGHT 4" NL
4598 "const ivec2 kTileSize = ivec2(TILE_WIDTH, TILE_HEIGHT);" NL NL
4599 "layout(binding = 0, rgba8) readonly uniform mediump image2D g_input_image;" NL
4600 "layout(binding = 1, rgba8) writeonly uniform mediump image2D g_output_image;" NL NL
4601 "layout(local_size_x = TILE_WIDTH, local_size_y=TILE_HEIGHT) in;" NL NL "void main() {" NL
4602 " ivec2 tile_xy = ivec2(gl_WorkGroupID);" NL " ivec2 thread_xy = ivec2(gl_LocalInvocationID);" NL NL
4603 " if (thread_xy == ivec2(0)) {" NL " ivec2 pixel_xy = tile_xy * kTileSize;" NL
4604 " for (int y = 0; y < TILE_HEIGHT; ++y) {" NL " for (int x = 0; x < TILE_WIDTH; ++x) {" NL
4605 " imageStore(g_output_image, pixel_xy + ivec2(x, y), vec4(0, 1, 0, 1));" NL " }" NL
4606 " }" NL " }" NL "}";
4614 NL "#define TILE_WIDTH 8" NL "#define TILE_HEIGHT 8" NL
4615 "const ivec2 kTileSize = ivec2(TILE_WIDTH, TILE_HEIGHT);" NL NL
4616 "layout(binding = 0, rgba8) readonly uniform mediump image2D g_input_image;" NL
4617 "layout(binding = 1, rgba8) writeonly uniform mediump image2D g_output_image;" NL NL
4618 "layout(local_size_x = TILE_WIDTH, local_size_y=TILE_HEIGHT) in;" NL NL "vec4 Process(vec4 ic) {" NL
4619 " return ic + vec4(1.0, 0.0, 0.0, 0.0);" NL "}" NL "void main() {" NL
4620 " ivec2 tile_xy = ivec2(gl_WorkGroupID);" NL " ivec2 thread_xy = ivec2(gl_LocalInvocationID);" NL
4621 " ivec2 pixel_xy = tile_xy * kTileSize + thread_xy;" NL
4622 " vec4 ic = imageLoad(g_input_image, pixel_xy);" NL
4623 " imageStore(g_output_image, pixel_xy, Process(ic));" NL "}";
4720 return NL "CS as an additional pipeline stage - After XFB";
4724 return NL "1. Verify that CS which process data fedback by VS works as expected." NL
4725 "2. Verify that XFB and SSBO works correctly together in one shader." NL
4731 return NL "1. Draw triangle with XFB enabled. Some data is written to the XFB buffer." NL
4732 "2. Use XFB buffer as 'input SSBO' in CS. Process data and write it to 'output SSBO'." NL
4737 return NL "Everything works as expected.";
4766 NL "layout(location = 0) in mediump vec4 g_position;" NL "layout(location = 1) in mediump vec4 g_color;" NL
4767 "struct Vertex {" NL " mediump vec4 position;" NL " mediump vec4 color;" NL "};" NL
4768 "flat out mediump vec4 color;" NL "layout(binding = 0) buffer StageData {" NL " Vertex vertex[];" NL
4769 "} g_vs_buffer;" NL "void main() {" NL " gl_Position = g_position;" NL " color = g_color;" NL
4770 " g_vs_buffer.vertex[gl_VertexID].position = g_position;" NL
4771 " g_vs_buffer.vertex[gl_VertexID].color = g_color;" NL "}";
4773 NL "flat mediump in vec4 color;" NL "layout(location = 0) out mediump vec4 g_color;" NL "void main() {" NL
4774 " g_color = color;" NL "}";
4786 NL "layout(local_size_x = 3) in;" NL "struct Vertex {" NL " vec4 position;" NL " vec4 color;" NL "};" NL
4787 "layout(binding = 3, std430) buffer Buffer {" NL " Vertex g_vertex[3];" NL "};" NL
4788 "uniform vec4 g_color1;" NL "uniform int g_two;" NL "void UpdateVertex2(int i) {" NL
4789 " g_vertex[i].color -= vec4(-1, 1, 0, 0);" NL "}" NL "void main() {" NL
4790 " switch (gl_GlobalInvocationID.x) {" NL
4791 " case 0u: g_vertex[gl_GlobalInvocationID.x].color += vec4(1, 0, 0, 0); break;" NL
4792 " case 1u: g_vertex[1].color += g_color1; break;" NL " case 2u: UpdateVertex2(g_two); break;" NL
4793 " default: return;" NL " }" NL "}";
4899 return NL "Shared Memory - Indexing";
4903 return NL "1. Verify that indexing various types of shared memory works as expected." NL
4904 "2. Verify that indexing shared memory with different types of expressions work as expected." NL
4909 return NL "1. Create CS which uses shared memory in many different ways." NL
4910 "2. Write to shared memory using different expressions." NL "3. Validate shared memory content." NL
4915 return NL "Everyting works as expected.";
4932 NL "layout(binding = 3, rgba8) uniform mediump writeonly image2D g_result_image;" NL
4933 "layout (local_size_x = 4,local_size_y=4 ) in;" NL "shared vec4 g_shared1[4];" NL
4934 "shared mat4 g_shared2;" NL "shared struct {" NL " float data[4];" NL "} g_shared3[4];" NL
4935 "shared struct Type { float data[4]; } g_shared4[4];" NL "shared Type g_shared5[4];" NL
4936 "uniform bool g_true;" NL "uniform float g_values[16];" NL NL "void Sync() {" NL
4937 " groupMemoryBarrier();" NL " barrier();" NL "}" NL "void SetMemory(ivec2 xy, float value) {" NL
4938 " g_shared1[xy.y][gl_LocalInvocationID.x] = value;" NL " g_shared2[xy.y][xy.x] = value;" NL
4939 " g_shared3[xy[1]].data[xy[0]] = value;" NL " g_shared4[xy.y].data[xy[0]] = value;" NL
4940 " g_shared5[gl_LocalInvocationID.y].data[gl_LocalInvocationID.x] = value;" NL "}" NL
4941 "bool CheckMemory(ivec2 xy, float expected) {" NL
4942 " if (g_shared1[xy.y][xy[0]] != expected) return false;" NL
4943 " if (g_shared2[xy[1]][xy[0]] != expected) return false;" NL
4944 " if (g_shared3[gl_LocalInvocationID.y].data[gl_LocalInvocationID.x] != expected) return false;" NL
4945 " if (g_shared4[gl_LocalInvocationID.y].data[xy.x] != expected) return false;" NL
4946 " if (g_shared5[xy.y].data[xy.x] != expected) return false;" NL " return true;" NL "}" NL
4947 "void main() {" NL " ivec2 thread_xy = ivec2(gl_LocalInvocationID);" NL
4948 " vec4 result = vec4(0.0, 1.0, 0.0, 1.0);" NL NL
4949 " SetMemory(thread_xy, g_values[gl_LocalInvocationIndex] * 1.0);" NL " Sync();" NL
4951 "1.0);" NL NL " SetMemory(thread_xy, g_values[gl_LocalInvocationIndex] * -1.0);" NL " Sync();" NL
4953 "1.0);" NL NL " if (g_true && gl_LocalInvocationID.x < 10u) {" NL
4954 " SetMemory(thread_xy, g_values[gl_LocalInvocationIndex] * 7.0);" NL " Sync();" NL
4956 "1.0);" NL " }" NL NL " imageStore(g_result_image, thread_xy, result);" NL "}";
5023 return NL "Shared Memory - 16K";
5027 return NL "Support for 16K of shared memory is required by the OpenGL specifaction. Verify if an "
5032 return NL "Create and dispatch CS which uses 16K of shared memory.";
5036 return NL "Everything works as expected.";
5050 const char* const glsl_cs = NL
5051 "layout(local_size_x = 64) in;" NL
5053 NL "layout(std430) buffer Output {" NL " Type g_output[64];" NL "};" NL NL "void main() {" NL
5054 " int id = int(gl_GlobalInvocationID.x);" NL
5056 "vec4(1.0)," NL " vec4(1.0), vec4(1.0), vec4(1.0), vec4(1.0), vec4(1.0), "
5057 "vec4(1.0), vec4(1.0), vec4(1.0));" NL " memoryBarrierShared();" NL " barrier();" NL NL
5058 " vec4 sum = vec4(0.0);" NL " int sum_count = 0;" NL " for (int i = id - 6; i < id + 9; ++i) {" NL
5059 " if (id >= 0 && id < g_shared.length()) {" NL " sum += g_shared[id].v[0];" NL
5060 " sum += g_shared[id].v[1];" NL " sum += g_shared[id].v[2];" NL
5061 " sum += g_shared[id].v[3];" NL " sum += g_shared[id].v[4];" NL
5062 " sum += g_shared[id].v[5];" NL " sum += g_shared[id].v[6];" NL
5063 " sum += g_shared[id].v[7];" NL " sum += g_shared[id].v[8];" NL
5064 " sum += g_shared[id].v[9];" NL " sum += g_shared[id].v[10];" NL
5065 " sum += g_shared[id].v[11];" NL " sum += g_shared[id].v[12];" NL
5066 " sum += g_shared[id].v[13];" NL " sum += g_shared[id].v[14];" NL
5067 " sum += g_shared[id].v[15];" NL " sum_count += 16;" NL " }" NL " }" NL
5068 " sum = abs((sum / float(sum_count)) - vec4(1.0));" NL
5069 " if (sum.x > 0.0000001f || sum.y > 0.0000001f || sum.z > 0.0000001f || sum.w > 0.0000001f) return;" NL NL
5070 " g_output[id] = g_shared[id];" NL "}";
5123 return NL "Maximum number of resources in one shader";
5127 return NL "1. Verify that using 4 SSBOs, 12 UBOs, 8 atomic counters" NL " in one CS works as expected.";
5131 return NL "Create and dispatch CS. Verify result.";
5135 return NL "Everything works as expected.";
5206 NL "layout(local_size_x = 1) in;" NL "layout(std140, binding = 0) buffer ShaderStorageBlock {" NL
5207 " uint data;" NL "} g_shader_storage[4];" NL "layout(std140, binding = 0) uniform UniformBlock {" NL
5208 " uint data;" NL "} g_uniform[12];" NL
5209 "layout(binding = 0, offset = 0) uniform atomic_uint g_atomic_counter0;" NL
5210 "layout(binding = 0, offset = 4) uniform atomic_uint g_atomic_counter1;" NL
5211 "layout(binding = 0, offset = 8) uniform atomic_uint g_atomic_counter2;" NL
5212 "layout(binding = 0, offset = 12) uniform atomic_uint g_atomic_counter3;" NL
5213 "layout(binding = 0, offset = 16) uniform atomic_uint g_atomic_counter4;" NL
5214 "layout(binding = 0, offset = 20) uniform atomic_uint g_atomic_counter5;" NL
5215 "layout(binding = 0, offset = 24) uniform atomic_uint g_atomic_counter6;" NL
5216 "layout(binding = 0, offset = 28) uniform atomic_uint g_atomic_counter7;" NL
5217 "uniform uint g_uniform_def[480];" NL "uniform uint g_index;" NL NL "uint Add() {" NL
5218 " switch (g_index) {" NL " case 0u: return atomicCounter(g_atomic_counter0);" NL
5219 " case 1u: return atomicCounter(g_atomic_counter1);" NL
5220 " case 2u: return atomicCounter(g_atomic_counter2);" NL
5221 " case 3u: return atomicCounter(g_atomic_counter3);" NL
5222 " case 4u: return atomicCounter(g_atomic_counter4);" NL
5223 " case 5u: return atomicCounter(g_atomic_counter5);" NL
5224 " case 6u: return atomicCounter(g_atomic_counter6);" NL
5225 " case 7u: return atomicCounter(g_atomic_counter7);" NL " }" NL "}" NL "void main() {" NL
5226 " switch (g_index) {" NL " case 0u: {" NL " g_shader_storage[0].data += g_uniform[0].data;" NL
5227 " g_shader_storage[0].data += Add();" NL " g_shader_storage[0].data += g_uniform_def[0];" NL
5228 " break;" NL " }" NL " case 1u: {" NL
5229 " g_shader_storage[1].data += g_uniform[1].data;" NL " g_shader_storage[1].data += Add();" NL
5230 " g_shader_storage[1].data += g_uniform_def[1];" NL " break;" NL " }" NL " case 2u: {" NL
5231 " g_shader_storage[2].data += g_uniform[2].data;" NL " g_shader_storage[2].data += Add();" NL
5232 " g_shader_storage[2].data += g_uniform_def[2];" NL " break;" NL " }" NL " case 3u: {" NL
5233 " g_shader_storage[3].data += g_uniform[3].data;" NL " g_shader_storage[3].data += Add();" NL
5234 " g_shader_storage[3].data += g_uniform_def[3];" NL " break;" NL " }" NL " }" NL "}";
5268 return NL "gl_WorkGroupSize usage";
5272 return NL "Verify gl_WorkGroupSize usage rules.";
5276 return NL "";
5280 return NL "";
5291 if (!CheckCompilationError("#version 310 es" NL "layout(std430) buffer Output {" NL " uint g_output;" NL
5292 "};" NL "void main() {" NL " g_output = gl_WorkGroupSize.x;" NL "}"))
5297 if (!CheckCompilationError("#version 310 es" NL "layout(std430) buffer Output {" NL " uint g_output;" NL
5298 "};" NL "void main() {" NL " g_output = gl_WorkGroupSize.x;" NL "}" NL
5308 ss << "layout(std430) buffer Output {" NL " uint g_output;" NL "};" NL "layout(local_size_"
5310 << " = 1) in;" NL "void main() {" NL " g_output = gl_WorkGroupSize.x + gl_WorkGroupSize.z;" NL "}";
5364 return NL "API errors - no active program";
5368 return NL "Verify that appropriate errors are generated by the OpenGL API.";
5372 return NL "";
5376 return NL "";
5420 const char* const glsl_vs = NL "layout(location = 0) in mediump vec4 g_position;" NL "void main() {" NL
5421 " gl_Position = g_position;" NL "}";
5423 NL "layout(location = 0) out mediump vec4 g_color;" NL "void main() {" NL " g_color = vec4(1);" NL "}";
5477 return NL "API errors - invalid work group count";
5481 return NL "Verify that appropriate errors are generated by the OpenGL API.";
5485 return NL "";
5489 return NL "";
5504 NL "layout(local_size_x = 1) in;" NL "layout(std430) buffer Output {" NL " uint g_output[];" NL "};" NL
5505 "void main() {" NL
5506 " g_output[gl_GlobalInvocationID.x * gl_GlobalInvocationID.y * gl_GlobalInvocationID.z] = 0u;" NL "}";
5571 return NL "API errors - incorrect DispatchComputeIndirect usage";
5575 return NL "Verify that appropriate errors are generated by the OpenGL API.";
5579 return NL "";
5583 return NL "";
5601 NL "layout(local_size_x = 1) in;" NL "layout(std430) buffer Output {" NL " uint g_output[];" NL "};" NL
5602 "void main() {" NL " g_output[gl_GlobalInvocationID.x] = 0u;" NL "}";
5679 return NL "API errors - program state";
5683 return NL "Verify that appropriate errors are generated by the OpenGL API.";
5687 return NL "";
5691 return NL "";
5705 const char* const glsl_vs = NL "layout(location = 0) in mediump vec4 g_position;" NL "void main() {" NL
5706 " gl_Position = g_position;" NL "}";
5708 NL "layout(location = 0) out mediump vec4 g_color;" NL "void main() {" NL " g_color = vec4(1);" NL "}";
5740 "#version 310 es" NL "layout(local_size_x = 1) in;" NL "layout(std430) buffer Output {" NL
5741 " uint g_output[];" NL "};" NL "void main() {" NL " g_output[gl_GlobalInvocationID.x] = 0;" NL "}";
5789 return NL "Compile-time errors";
5793 return NL "Verify that appropriate errors are generated by the GLSL compiler.";
5797 return NL "";
5801 return NL "";
5807 ss << "#version 310 es" NL "layout(local_size_x = " << x << ", local_size_y = " << y << ", local_size_z = " << z
5808 << ") in;" NL "layout(std430) buffer Output {" NL " uint g_output[];" NL "};" NL "void main() {" NL
5809 " g_output[gl_GlobalInvocationID.x] = 0;" NL "}";
5815 if (!Compile("#version 300 es" NL "layout(local_size_x = 1) in;" NL "layout(std430) buffer Output {" NL
5816 " uint g_output[];" NL "};" NL "void main() {" NL " g_output[gl_GlobalInvocationID.x] = 0;" NL
5820 if (!Compile("#version 310 es" NL "layout(local_size_x = 1) in;" NL "layout(local_size_x = 2) in;" NL
5821 "layout(std430) buffer Output {" NL " uint g_output[];" NL "};" NL "void main() {" NL
5822 " g_output[gl_GlobalInvocationID.x] = 0;" NL "}"))
5825 if (!Compile("#version 310 es" NL "layout(local_size_x = 1) in;" NL "in uint x;" NL
5826 "layout(std430) buffer Output {" NL " uint g_output[];" NL "};" NL "void main() {" NL
5827 " g_output[gl_GlobalInvocationID.x] = x;" NL "}"))
5830 if (!Compile("#version 310 es" NL "layout(local_size_x = 1) in;" NL "out uint x;" NL
5831 "layout(std430) buffer Output {" NL " uint g_output[];" NL "};" NL "void main() {" NL
5832 " g_output[gl_GlobalInvocationID.x] = 0;" NL " x = 0;" NL "}"))
5884 return NL "Link-time errors";
5888 return NL "Verify that appropriate errors are generated by the GLSL linker.";
5892 return NL "";
5896 return NL "";
5902 NL "layout(local_size_x = 1, local_size_y = 1) in;" NL "layout(std430) buffer Output {" NL " vec4 data;" NL
5903 "} g_out;" NL "void main() {" NL " g_out.data = vec4(1.0, 2.0, 3.0, 4.0);" NL "}";
5904 const char* const glsl_vs = NL "layout(location = 0) in mediump vec4 g_position;" NL "void main() {" NL
5905 " gl_Position = g_position;" NL "}";
5907 NL "layout(location = 0) out mediump vec4 g_color;" NL "void main() {" NL " g_color = vec4(1);" NL "}";
5933 const char* const glsl_cs2 = NL "layout(std430) buffer Output {" NL " vec4 data;" NL "} g_out;" NL
5934 "void main() {" NL " g_out.data = vec4(1.0, 2.0, 3.0, 4.0);" NL "}";
5951 return NL "gl_WorkGroupSize is an constant";
5955 return NL "Verify that gl_WorkGroupSize can be used as an constant expression.";
5959 return NL "";
5963 return NL "";
5979 NL "layout(local_size_x = 2, local_size_y = 3, local_size_z = 4) in;" NL
5980 "layout(std430, binding = 0) buffer Output {" NL " uint g_buffer[22u + gl_WorkGroupSize.x];" NL "};" NL
5981 "shared uint g_shared[gl_WorkGroupSize.x * gl_WorkGroupSize.y * gl_WorkGroupSize.z];" NL
5982 "uniform uint g_uniform[gl_WorkGroupSize.z + 20u];" NL "void main() {" NL
5983 " g_shared[gl_LocalInvocationIndex] = 1U;" NL " groupMemoryBarrier();" NL " barrier();" NL
5984 " uint sum = 0u;" NL
5985 " for (uint i = 0u; i < gl_WorkGroupSize.x * gl_WorkGroupSize.y * gl_WorkGroupSize.z; ++i) {" NL
5986 " sum += g_shared[i];" NL " }" NL " sum += g_uniform[gl_LocalInvocationIndex];" NL
5987 " g_buffer[gl_LocalInvocationIndex] = sum;" NL "}";