aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/AtomicMinMaxS32Shared.glsl
blob: 82b76bccf24f3e037f4a90c75e4ee79f5d5204e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int Helper_AtomicMaxS32(int offset, int value)
{
    uint oldValue, newValue;
    do
    {
        oldValue = $SHARED_MEM$[offset];
        newValue = uint(max(int(oldValue), value));
    } while (atomicCompSwap($SHARED_MEM$[offset], oldValue, newValue) != oldValue);
    return int(oldValue);
}

int Helper_AtomicMinS32(int offset, int value)
{
    uint oldValue, newValue;
    do
    {
        oldValue = $SHARED_MEM$[offset];
        newValue = uint(min(int(oldValue), value));
    } while (atomicCompSwap($SHARED_MEM$[offset], oldValue, newValue) != oldValue);
    return int(oldValue);
}