#!amber # Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # The purpose of this test is to check the behavior of workgroup atomics in # combination with barriers. # This is known to cause issues on the mobile devices given the CTS failures # for webgpu # See: crbug.com/42241359 SHADER compute workgroup_shared_atomic_shader GLSL #version 430 layout(local_size_x = 3, local_size_y = 1, local_size_z = 1) in; layout(set = 0, binding = 0) buffer block1 { uint ssbo_write[]; }; shared uint wg_shared; void main() { if( gl_LocalInvocationID.x == 0){ atomicExchange(wg_shared, 7); } barrier(); atomicAdd(wg_shared,1); barrier(); if(gl_LocalInvocationID.x == 0) { ssbo_write[0] = atomicExchange(wg_shared,0); } } END BUFFER buf_uint DATA_TYPE uint32 SIZE 16 FILL 123 PIPELINE compute pipeline ATTACH workgroup_shared_atomic_shader BIND BUFFER buf_uint AS storage DESCRIPTOR_SET 0 BINDING 0 END RUN pipeline 1 1 1 EXPECT buf_uint IDX 0 EQ 10