Skip to content

Commit

Permalink
Merge pull request #1143 from KhronosGroup/interlock
Browse files Browse the repository at this point in the history
Merge SPV_EXT_fragment_shader_interlock with fixes
  • Loading branch information
HansKristian-Work authored Sep 4, 2019
2 parents a06997a + 0286442 commit f24654d
Show file tree
Hide file tree
Showing 50 changed files with 2,618 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
RWByteAddressBuffer _9 : register(u6, space0);
globallycoherent RasterizerOrderedByteAddressBuffer _42 : register(u3, space0);
RasterizerOrderedByteAddressBuffer _52 : register(u4, space0);
RWTexture2D<unorm float4> img4 : register(u5, space0);
RasterizerOrderedTexture2D<unorm float4> img : register(u0, space0);
RasterizerOrderedTexture2D<unorm float4> img3 : register(u2, space0);
RasterizerOrderedTexture2D<uint> img2 : register(u1, space0);

void frag_main()
{
_9.Store(0, uint(0));
img4[int2(1, 1)] = float4(1.0f, 0.0f, 0.0f, 1.0f);
img[int2(0, 0)] = img3[int2(0, 0)];
uint _39;
InterlockedAdd(img2[int2(0, 0)], 1u, _39);
_42.Store(0, uint(int(_42.Load(0)) + 42));
uint _55;
_42.InterlockedAnd(4, _52.Load(0), _55);
}

void main()
{
frag_main();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#pragma clang diagnostic ignored "-Wunused-variable"

#include <metal_stdlib>
#include <simd/simd.h>
#include <metal_atomic>

using namespace metal;

struct Buffer3
{
int baz;
};

struct Buffer
{
int foo;
uint bar;
};

struct Buffer2
{
uint quux;
};

struct spvDescriptorSetBuffer0
{
device Buffer3* m_9 [[id(0)]];
texture2d<float, access::write> img4 [[id(1)]];
texture2d<float, access::write> img [[id(2), raster_order_group(0)]];
texture2d<float> img3 [[id(3), raster_order_group(0)]];
volatile device Buffer* m_34 [[id(4), raster_order_group(0)]];
device Buffer2* m_44 [[id(5), raster_order_group(0)]];
};

fragment void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]])
{
(*spvDescriptorSet0.m_9).baz = 0;
spvDescriptorSet0.img4.write(float4(1.0, 0.0, 0.0, 1.0), uint2(int2(1)));
spvDescriptorSet0.img.write(spvDescriptorSet0.img3.read(uint2(int2(0))), uint2(int2(0)));
(*spvDescriptorSet0.m_34).foo += 42;
uint _49 = atomic_fetch_and_explicit((volatile device atomic_uint*)&(*spvDescriptorSet0.m_34).bar, (*spvDescriptorSet0.m_44).quux, memory_order_relaxed);
}

33 changes: 33 additions & 0 deletions reference/opt/shaders-msl/frag/pixel-interlock-ordered.msl2.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#pragma clang diagnostic ignored "-Wunused-variable"

#include <metal_stdlib>
#include <simd/simd.h>
#include <metal_atomic>

using namespace metal;

struct Buffer3
{
int baz;
};

struct Buffer
{
int foo;
uint bar;
};

struct Buffer2
{
uint quux;
};

fragment void main0(device Buffer3& _9 [[buffer(0)]], volatile device Buffer& _34 [[buffer(1), raster_order_group(0)]], device Buffer2& _44 [[buffer(2), raster_order_group(0)]], texture2d<float, access::write> img4 [[texture(0)]], texture2d<float, access::write> img [[texture(1), raster_order_group(0)]], texture2d<float> img3 [[texture(2), raster_order_group(0)]])
{
_9.baz = 0;
img4.write(float4(1.0, 0.0, 0.0, 1.0), uint2(int2(1)));
img.write(img3.read(uint2(int2(0))), uint2(int2(0)));
_34.foo += 42;
uint _49 = atomic_fetch_and_explicit((volatile device atomic_uint*)&_34.bar, _44.quux, memory_order_relaxed);
}

23 changes: 23 additions & 0 deletions reference/opt/shaders/frag/pixel-interlock-ordered.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#version 450
#extension GL_ARB_fragment_shader_interlock : require
layout(pixel_interlock_ordered) in;

layout(binding = 2, std430) coherent buffer Buffer
{
int foo;
uint bar;
} _30;

layout(binding = 0, rgba8) uniform writeonly image2D img;
layout(binding = 1, r32ui) uniform uimage2D img2;

void main()
{
beginInvocationInterlockARB();
imageStore(img, ivec2(0), vec4(1.0, 0.0, 0.0, 1.0));
uint _27 = imageAtomicAdd(img2, ivec2(0), 1u);
_30.foo += 42;
uint _41 = atomicAnd(_30.bar, 255u);
endInvocationInterlockARB();
}

23 changes: 23 additions & 0 deletions reference/opt/shaders/frag/pixel-interlock-unordered.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#version 450
#extension GL_ARB_fragment_shader_interlock : require
layout(pixel_interlock_unordered) in;

layout(binding = 2, std430) coherent buffer Buffer
{
int foo;
uint bar;
} _30;

layout(binding = 0, rgba8) uniform writeonly image2D img;
layout(binding = 1, r32ui) uniform uimage2D img2;

void main()
{
beginInvocationInterlockARB();
imageStore(img, ivec2(0), vec4(1.0, 0.0, 0.0, 1.0));
uint _27 = imageAtomicAdd(img2, ivec2(0), 1u);
_30.foo += 42;
uint _41 = atomicAnd(_30.bar, 255u);
endInvocationInterlockARB();
}

23 changes: 23 additions & 0 deletions reference/opt/shaders/frag/sample-interlock-ordered.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#version 450
#extension GL_ARB_fragment_shader_interlock : require
layout(sample_interlock_ordered) in;

layout(binding = 2, std430) coherent buffer Buffer
{
int foo;
uint bar;
} _30;

layout(binding = 0, rgba8) uniform writeonly image2D img;
layout(binding = 1, r32ui) uniform uimage2D img2;

void main()
{
beginInvocationInterlockARB();
imageStore(img, ivec2(0), vec4(1.0, 0.0, 0.0, 1.0));
uint _27 = imageAtomicAdd(img2, ivec2(0), 1u);
_30.foo += 42;
uint _47 = atomicAnd(_30.bar, uint(gl_SampleMaskIn[0]));
endInvocationInterlockARB();
}

23 changes: 23 additions & 0 deletions reference/opt/shaders/frag/sample-interlock-unordered.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#version 450
#extension GL_ARB_fragment_shader_interlock : require
layout(sample_interlock_unordered) in;

layout(binding = 2, std430) coherent buffer Buffer
{
int foo;
uint bar;
} _30;

layout(binding = 0, rgba8) uniform writeonly image2D img;
layout(binding = 1, r32ui) uniform uimage2D img2;

void main()
{
beginInvocationInterlockARB();
imageStore(img, ivec2(0), vec4(1.0, 0.0, 0.0, 1.0));
uint _27 = imageAtomicAdd(img2, ivec2(0), 1u);
_30.foo += 42;
uint _41 = atomicAnd(_30.bar, 255u);
endInvocationInterlockARB();
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
RasterizerOrderedByteAddressBuffer _7 : register(u1, space0);
RWByteAddressBuffer _9 : register(u0, space0);

static float4 gl_FragCoord;
struct SPIRV_Cross_Input
{
float4 gl_FragCoord : SV_Position;
};

void callee2()
{
int _31 = int(gl_FragCoord.x);
_7.Store(_31 * 4 + 0, _7.Load(_31 * 4 + 0) + 1u);
}

void callee()
{
int _39 = int(gl_FragCoord.x);
_9.Store(_39 * 4 + 0, _9.Load(_39 * 4 + 0) + 1u);
callee2();
}

void frag_main()
{
callee();
}

void main(SPIRV_Cross_Input stage_input)
{
gl_FragCoord = stage_input.gl_FragCoord;
frag_main();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
RasterizerOrderedByteAddressBuffer _7 : register(u1, space0);
RWByteAddressBuffer _13 : register(u2, space0);
RasterizerOrderedByteAddressBuffer _9 : register(u0, space0);

static float4 gl_FragCoord;
struct SPIRV_Cross_Input
{
float4 gl_FragCoord : SV_Position;
};

void callee2()
{
int _44 = int(gl_FragCoord.x);
_7.Store(_44 * 4 + 0, _7.Load(_44 * 4 + 0) + 1u);
}

void callee()
{
int _52 = int(gl_FragCoord.x);
_9.Store(_52 * 4 + 0, _9.Load(_52 * 4 + 0) + 1u);
callee2();
if (true)
{
}
}

void _35()
{
_13.Store(int(gl_FragCoord.x) * 4 + 0, 4u);
}

void frag_main()
{
callee();
_35();
}

void main(SPIRV_Cross_Input stage_input)
{
gl_FragCoord = stage_input.gl_FragCoord;
frag_main();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
RasterizerOrderedByteAddressBuffer _7 : register(u1, space0);
RasterizerOrderedByteAddressBuffer _9 : register(u0, space0);

static float4 gl_FragCoord;
struct SPIRV_Cross_Input
{
float4 gl_FragCoord : SV_Position;
};

void callee2()
{
int _37 = int(gl_FragCoord.x);
_7.Store(_37 * 4 + 0, _7.Load(_37 * 4 + 0) + 1u);
}

void callee()
{
int _45 = int(gl_FragCoord.x);
_9.Store(_45 * 4 + 0, _9.Load(_45 * 4 + 0) + 1u);
callee2();
}

void _29()
{
}

void _31()
{
}

void frag_main()
{
callee();
_29();
_31();
}

void main(SPIRV_Cross_Input stage_input)
{
gl_FragCoord = stage_input.gl_FragCoord;
frag_main();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
RasterizerOrderedByteAddressBuffer _14 : register(u1, space0);
RasterizerOrderedByteAddressBuffer _35 : register(u0, space0);

static float4 gl_FragCoord;
struct SPIRV_Cross_Input
{
float4 gl_FragCoord : SV_Position;
};

void callee2()
{
int _25 = int(gl_FragCoord.x);
_14.Store(_25 * 4 + 0, _14.Load(_25 * 4 + 0) + 1u);
}

void callee()
{
int _38 = int(gl_FragCoord.x);
_35.Store(_38 * 4 + 0, _35.Load(_38 * 4 + 0) + 1u);
callee2();
}

void frag_main()
{
callee();
}

void main(SPIRV_Cross_Input stage_input)
{
gl_FragCoord = stage_input.gl_FragCoord;
frag_main();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
RWByteAddressBuffer _9 : register(u6, space0);
globallycoherent RasterizerOrderedByteAddressBuffer _42 : register(u3, space0);
RasterizerOrderedByteAddressBuffer _52 : register(u4, space0);
RWTexture2D<unorm float4> img4 : register(u5, space0);
RasterizerOrderedTexture2D<unorm float4> img : register(u0, space0);
RasterizerOrderedTexture2D<unorm float4> img3 : register(u2, space0);
RasterizerOrderedTexture2D<uint> img2 : register(u1, space0);

void frag_main()
{
_9.Store(0, uint(0));
img4[int2(1, 1)] = float4(1.0f, 0.0f, 0.0f, 1.0f);
img[int2(0, 0)] = img3[int2(0, 0)];
uint _39;
InterlockedAdd(img2[int2(0, 0)], 1u, _39);
_42.Store(0, uint(int(_42.Load(0)) + 42));
uint _55;
_42.InterlockedAnd(4, _52.Load(0), _55);
}

void main()
{
frag_main();
}
Loading

0 comments on commit f24654d

Please sign in to comment.