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-11-13 16:50:17 +0300
committerHans-Kristian Arntzen <hans-kristian.arntzen@arm.com>2018-11-13 16:50:46 +0300
commit2a8a4fe7067704801e544d1ba264517f6d45878a (patch)
tree09f0b99e65b31b2f69ad9c7d11e1f6be7c161cbc /shaders
parent14a3ce4a20f7df71f2d49c805cdafb3574f8d588 (diff)
GLSL: Support extended arithmetic opcodes.
- uaddCarry - usubBorrow - umulExtended - imulExtended
Diffstat (limited to 'shaders')
-rw-r--r--shaders/desktop-only/comp/extended-arithmetic.desktop.comp41
1 files changed, 41 insertions, 0 deletions
diff --git a/shaders/desktop-only/comp/extended-arithmetic.desktop.comp b/shaders/desktop-only/comp/extended-arithmetic.desktop.comp
new file mode 100644
index 00000000..9623751b
--- /dev/null
+++ b/shaders/desktop-only/comp/extended-arithmetic.desktop.comp
@@ -0,0 +1,41 @@
+#version 450
+layout(local_size_x = 1) in;
+
+layout(binding = 0, std430) buffer SSBOUint
+{
+ uint a, b, c, d;
+ uvec2 a2, b2, c2, d2;
+ uvec3 a3, b3, c3, d3;
+ uvec4 a4, b4, c4, d4;
+} u;
+
+layout(binding = 1, std430) buffer SSBOInt
+{
+ int a, b, c, d;
+ ivec2 a2, b2, c2, d2;
+ ivec3 a3, b3, c3, d3;
+ ivec4 a4, b4, c4, d4;
+} i;
+
+void main()
+{
+ u.c = uaddCarry(u.a, u.b, u.d);
+ u.c2 = uaddCarry(u.a2, u.b2, u.d2);
+ u.c3 = uaddCarry(u.a3, u.b3, u.d3);
+ u.c4 = uaddCarry(u.a4, u.b4, u.d4);
+
+ u.c = usubBorrow(u.a, u.b, u.d);
+ u.c2 = usubBorrow(u.a2, u.b2, u.d2);
+ u.c3 = usubBorrow(u.a3, u.b3, u.d3);
+ u.c4 = usubBorrow(u.a4, u.b4, u.d4);
+
+ umulExtended(u.a, u.b, u.c, u.d);
+ umulExtended(u.a2, u.b2, u.c2, u.d2);
+ umulExtended(u.a3, u.b3, u.c3, u.d3);
+ umulExtended(u.a4, u.b4, u.c4, u.d4);
+
+ imulExtended(i.a, i.b, i.c, i.d);
+ imulExtended(i.a2, i.b2, i.c2, i.d2);
+ imulExtended(i.a3, i.b3, i.c3, i.d3);
+ imulExtended(i.a4, i.b4, i.c4, i.d4);
+}