//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -stage compute -entry computeMain -target glsl //TEST:SIMPLE(filecheck=CHECK_SPV): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly //TEST:SIMPLE(filecheck=CHECK_HLSL): -allow-glsl -stage compute -entry computeMain -target hlsl -DTARGET_HLSL // not testing cuda due to missing impl //DISABLE_TEST:SIMPLE(filecheck=CHECK_CUDA): -allow-glsl -stage compute -entry computeMain -target cuda -DTARGET_CUDA // not testing cpp due to missing impl //DISABLE_TEST:SIMPLE(filecheck=CHECK_CPP): -allow-glsl -stage compute -entry computeMain -target cpp -DTARGET_CPP //TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl //TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -emit-spirv-directly //TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF):-wgpu -compute -entry computeMain -allow-glsl -xslang -DWGPU // Not testing because CI runners may not support Metal's intrinsics. //DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF):-metal -compute -entry computeMain -allow-glsl -xslang -DMETAL #version 430 //TEST_INPUT:ubuffer(data=[9], stride=4):name=inputBuffer buffer MyBlockName { uint data[]; } inputBuffer; //TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer buffer MyBlockName2 { uint data[]; } outputBuffer; layout(local_size_x = 32) in; __generic bool test1AllEqual() { return true & subgroupAllEqual(T(1)) == true & subgroupAllEqual(T(gl_GlobalInvocationID.x)) == false ; } __generic bool testVAllEqual() { typealias gvec = vector; return true & subgroupAllEqual(gvec(T(1))) == true & subgroupAllEqual(gvec(T(gl_GlobalInvocationID.x))) == false ; } __generic bool test1AllEqual() { return true & subgroupAllEqual(T(1)) == true & subgroupAllEqual(T(gl_GlobalInvocationID.x)) == false ; } __generic bool testVAllEqual() { typealias gvec = vector; return true & subgroupAllEqual(gvec(T(1))) == true & subgroupAllEqual(gvec(T(gl_GlobalInvocationID.x))) == false ; } bool testAllEqual() { return true & test1AllEqual() & testVAllEqual() & testVAllEqual() & testVAllEqual() & test1AllEqual() // WARNING: intel GPU's lack FP64 support & testVAllEqual() & testVAllEqual() & testVAllEqual() & test1AllEqual() & testVAllEqual() & testVAllEqual() & testVAllEqual() & test1AllEqual() & testVAllEqual() & testVAllEqual() & testVAllEqual() & test1AllEqual() & testVAllEqual() & testVAllEqual() & testVAllEqual() & test1AllEqual() & testVAllEqual() & testVAllEqual() & testVAllEqual() & test1AllEqual() & testVAllEqual() & testVAllEqual() & testVAllEqual() & test1AllEqual() & testVAllEqual() & testVAllEqual() & testVAllEqual() & test1AllEqual() & testVAllEqual() & testVAllEqual() & testVAllEqual() & test1AllEqual() & testVAllEqual() & testVAllEqual() & testVAllEqual() & test1AllEqual() & testVAllEqual() & testVAllEqual() & testVAllEqual() & test1AllEqual() & testVAllEqual() & testVAllEqual() & testVAllEqual() ; } [[ForceInline]] void MyBarrier() { #if defined(WGPU) GroupMemoryBarrier(); #else subgroupBarrier(); #endif } [shader("compute")] void computeMain() { //seperate tests since testing concurrency // one is true, rest false, positive outputBuffer.data[0] = 1; #if defined(WGPU) // There is no subgroup barrier for WGSL. // And workgroup barrier requries non uniform control flow. bool t1 = true; #else bool t1 = inputBuffer.data[0] == gl_GlobalInvocationID.x; #endif if (subgroupAny(t1)) { outputBuffer.data[0] = 2; } MyBarrier(); // all false, negative outputBuffer.data[1] = 1; t1 = false; if (!subgroupAny(t1)) { outputBuffer.data[1] = 2; } MyBarrier(); // all true, positive outputBuffer.data[2] = 1; t1 = true; if (subgroupAll(t1)) { outputBuffer.data[2] = 2; } MyBarrier(); // all false, negative outputBuffer.data[3] = 1; t1 = false; if (!subgroupAll(t1)) { outputBuffer.data[3] = 2; } MyBarrier(); outputBuffer.data[4] = 1; // All equal intrinsic is not supported on WGSL as of time of writing. #if !defined(WGPU) && !defined(METAL) if (testAllEqual()) #endif { outputBuffer.data[4] = 2; } MyBarrier(); // CHECK_GLSL: void main( // CHECK_SPV: OpEntryPoint // CHECK_HLSL: void computeMain( // CHECK_CUDA: void computeMain( // CHECK_CPP: void _computeMain( // BUF: 2 // BUF-NEXT: 2 // BUF-NEXT: 2 // BUF-NEXT: 2 // BUF-NEXT: 2 }