Browse Source

Fix a bug in the prev commit and workaround issue #9

Panagiotis Christopoulos Charitos 9 years ago
parent
commit
c94d22d825
4 changed files with 11 additions and 5 deletions
  1. 2 2
      shaders/Pps.frag.glsl
  2. 2 2
      shaders/Pps.vert.glsl
  3. 1 1
      src/anki/util/Atomic.h
  4. 6 0
      tests/util/Atomic.cpp

+ 2 - 2
shaders/Pps.frag.glsl

@@ -34,9 +34,9 @@ layout(std140, ANKI_SS_BINDING(0, 0)) readonly buffer s0_
 	Luminance u_luminance;
 };
 
-layout(location = 0) in vec2 in_uv;
+layout(location = 1) in vec2 in_uv;
 #if SMAA_ENABLED
-layout(location = 1) in vec4 in_smaaOffset;
+layout(location = 0) in vec4 in_smaaOffset;
 #endif
 
 layout(location = 0) out vec3 out_color;

+ 2 - 2
shaders/Pps.vert.glsl

@@ -12,9 +12,9 @@
 #include "shaders/SMAA.hlsl"
 #endif
 
-layout(location = 0) out vec2 out_uv;
+layout(location = 1) out vec2 out_uv;
 #if SMAA_ENABLED
-layout(location = 1) out vec4 out_smaaOffset;
+layout(location = 0) out vec4 out_smaaOffset;
 #endif
 
 void main(void)

+ 1 - 1
src/anki/util/Atomic.h

@@ -103,7 +103,7 @@ public:
 		// Do a trick to workaround the fact that __atomic_fetch_add doesn't take into account the size of the type
 		// if that type is a pointer.
 		Value v = Value(0);
-		v -= a;
+		v += a;
 		return __atomic_fetch_sub(&m_val, v, static_cast<int>(memOrd));
 #else
 #error "TODO"

+ 6 - 0
tests/util/Atomic.cpp

@@ -32,6 +32,12 @@ ANKI_TEST(Util, Atomic)
 		ANKI_TEST_EXPECT_EQ(a.load(), b);
 	}
 
+	{
+		Atomic<U32> a{3};
+		a.fetchSub(1);
+		ANKI_TEST_EXPECT_EQ(a.load(), 2);
+	}
+
 	{
 		U32 u[2];
 		Atomic<U32*> a{&u[0]};