Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Cross.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Kristian Arntzen <hans-kristian.arntzen@arm.com>2018-09-17 16:46:39 +0300
committerHans-Kristian Arntzen <hans-kristian.arntzen@arm.com>2018-09-17 16:54:21 +0300
commit737715214e218d90815666ed48ce9194d4f8a1e3 (patch)
tree58e4774c2365fa0c521c08b7934d4d0154798f46 /shaders
parenta77880787dbf040ffde3483c40f28271d795f59f (diff)
Implement atomic increment/decrement in GLSL and HLSL.
Diffstat (limited to 'shaders')
-rw-r--r--shaders/asm/comp/atomic-decrement.asm.comp71
-rw-r--r--shaders/asm/comp/atomic-increment.asm.comp71
2 files changed, 142 insertions, 0 deletions
diff --git a/shaders/asm/comp/atomic-decrement.asm.comp b/shaders/asm/comp/atomic-decrement.asm.comp
new file mode 100644
index 00000000..a87b9318
--- /dev/null
+++ b/shaders/asm/comp/atomic-decrement.asm.comp
@@ -0,0 +1,71 @@
+; SPIR-V
+; Version: 1.0
+; Generator: Wine VKD3D Shader Compiler; 0
+; Bound: 43
+; Schema: 0
+ OpCapability Shader
+ OpCapability SampledBuffer
+ OpCapability ImageBuffer
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint GLCompute %3 "main" %15
+ OpExecutionMode %3 LocalSize 4 1 1
+ OpName %3 "main"
+ OpName %8 "u0"
+ OpName %9 "u0_counters"
+ OpMemberName %9 0 "c"
+ OpName %11 "u0_counter"
+ OpName %15 "vThreadID"
+ OpName %19 "r0"
+ OpDecorate %8 DescriptorSet 0
+ OpDecorate %8 Binding 0
+ OpMemberDecorate %9 0 Offset 0
+ OpDecorate %9 BufferBlock
+ OpDecorate %11 DescriptorSet 1
+ OpDecorate %11 Binding 0
+ OpDecorate %15 BuiltIn GlobalInvocationId
+ %1 = OpTypeVoid
+ %2 = OpTypeFunction %1
+ %5 = OpTypeInt 32 0
+ %6 = OpTypeImage %5 Buffer 0 0 0 2 R32ui
+ %7 = OpTypePointer UniformConstant %6
+ %8 = OpVariable %7 UniformConstant
+ %9 = OpTypeStruct %5
+ %10 = OpTypePointer Uniform %9
+ %11 = OpVariable %10 Uniform
+ %12 = OpTypeInt 32 1
+ %13 = OpTypeVector %12 3
+ %14 = OpTypePointer Input %13
+ %15 = OpVariable %14 Input
+ %16 = OpTypeFloat 32
+ %17 = OpTypeVector %16 4
+ %18 = OpTypePointer Function %17
+ %20 = OpTypePointer Uniform %5
+ %21 = OpConstant %5 0
+ %23 = OpConstant %5 1
+ %26 = OpTypePointer Function %16
+ %33 = OpConstant %12 0
+ %34 = OpConstant %5 2
+ %37 = OpTypePointer Input %12
+ %41 = OpTypeVector %5 4
+ %3 = OpFunction %1 None %2
+ %4 = OpLabel
+ %19 = OpVariable %18 Function
+ %22 = OpAccessChain %20 %11 %21
+ %24 = OpAtomicIDecrement %5 %22 %23 %21
+ %25 = OpBitcast %16 %24
+ %27 = OpInBoundsAccessChain %26 %19 %21
+ OpStore %27 %25
+ %28 = OpLoad %6 %8
+ %29 = OpInBoundsAccessChain %26 %19 %21
+ %30 = OpLoad %16 %29
+ %31 = OpBitcast %12 %30
+ %32 = OpIMul %5 %31 %23
+ %35 = OpShiftRightLogical %5 %33 %34
+ %36 = OpIAdd %5 %32 %35
+ %38 = OpInBoundsAccessChain %37 %15 %21
+ %39 = OpLoad %12 %38
+ %40 = OpBitcast %5 %39
+ %42 = OpCompositeConstruct %41 %40 %40 %40 %40
+ OpImageWrite %28 %36 %42
+ OpReturn
+ OpFunctionEnd
diff --git a/shaders/asm/comp/atomic-increment.asm.comp b/shaders/asm/comp/atomic-increment.asm.comp
new file mode 100644
index 00000000..3acb7115
--- /dev/null
+++ b/shaders/asm/comp/atomic-increment.asm.comp
@@ -0,0 +1,71 @@
+; SPIR-V
+; Version: 1.0
+; Generator: Wine VKD3D Shader Compiler; 0
+; Bound: 43
+; Schema: 0
+ OpCapability Shader
+ OpCapability SampledBuffer
+ OpCapability ImageBuffer
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint GLCompute %3 "main" %15
+ OpExecutionMode %3 LocalSize 4 1 1
+ OpName %3 "main"
+ OpName %8 "u0"
+ OpName %9 "u0_counters"
+ OpMemberName %9 0 "c"
+ OpName %11 "u0_counter"
+ OpName %15 "vThreadID"
+ OpName %19 "r0"
+ OpDecorate %8 DescriptorSet 0
+ OpDecorate %8 Binding 0
+ OpMemberDecorate %9 0 Offset 0
+ OpDecorate %9 BufferBlock
+ OpDecorate %11 DescriptorSet 1
+ OpDecorate %11 Binding 0
+ OpDecorate %15 BuiltIn GlobalInvocationId
+ %1 = OpTypeVoid
+ %2 = OpTypeFunction %1
+ %5 = OpTypeInt 32 0
+ %6 = OpTypeImage %5 Buffer 0 0 0 2 R32ui
+ %7 = OpTypePointer UniformConstant %6
+ %8 = OpVariable %7 UniformConstant
+ %9 = OpTypeStruct %5
+ %10 = OpTypePointer Uniform %9
+ %11 = OpVariable %10 Uniform
+ %12 = OpTypeInt 32 1
+ %13 = OpTypeVector %12 3
+ %14 = OpTypePointer Input %13
+ %15 = OpVariable %14 Input
+ %16 = OpTypeFloat 32
+ %17 = OpTypeVector %16 4
+ %18 = OpTypePointer Function %17
+ %20 = OpTypePointer Uniform %5
+ %21 = OpConstant %5 0
+ %23 = OpConstant %5 1
+ %26 = OpTypePointer Function %16
+ %33 = OpConstant %12 0
+ %34 = OpConstant %5 2
+ %37 = OpTypePointer Input %12
+ %41 = OpTypeVector %5 4
+ %3 = OpFunction %1 None %2
+ %4 = OpLabel
+ %19 = OpVariable %18 Function
+ %22 = OpAccessChain %20 %11 %21
+ %24 = OpAtomicIIncrement %5 %22 %23 %21
+ %25 = OpBitcast %16 %24
+ %27 = OpInBoundsAccessChain %26 %19 %21
+ OpStore %27 %25
+ %28 = OpLoad %6 %8
+ %29 = OpInBoundsAccessChain %26 %19 %21
+ %30 = OpLoad %16 %29
+ %31 = OpBitcast %12 %30
+ %32 = OpIMul %5 %31 %23
+ %35 = OpShiftRightLogical %5 %33 %34
+ %36 = OpIAdd %5 %32 %35
+ %38 = OpInBoundsAccessChain %37 %15 %21
+ %39 = OpLoad %12 %38
+ %40 = OpBitcast %5 %39
+ %42 = OpCompositeConstruct %41 %40 %40 %40 %40
+ OpImageWrite %28 %36 %42
+ OpReturn
+ OpFunctionEnd