Panagiotis Christopoulos Charitos пре 12 година
родитељ
комит
a89d4e096b
3 измењених фајлова са 6 додато и 3 уклоњено
  1. 2 0
      include/anki/Config.h.cmake
  2. 1 1
      include/anki/math/Vec4.h
  3. 3 2
      src/renderer/Drawer.cpp

+ 2 - 0
include/anki/Config.h.cmake

@@ -139,6 +139,8 @@
 #	define ANKI_LIKELY(x) __builtin_expect((x), 1)
 #	define ANKI_LIKELY(x) __builtin_expect((x), 1)
 #	define ANKI_UNLIKELY(x) __builtin_expect((x), 0)
 #	define ANKI_UNLIKELY(x) __builtin_expect((x), 0)
 #	define ANKI_RESTRICT __restrict
 #	define ANKI_RESTRICT __restrict
+#	define ANKI_ATTRIBUTE_ALIGNED(attr_, al_) \
+		attr_ __attribute__ ((aligned (al_)))
 #else
 #else
 #	define ANKI_LIKELY(x) ((x) == 1)
 #	define ANKI_LIKELY(x) ((x) == 1)
 #	define ANKI_UNLIKELY(x) ((x) == 1)
 #	define ANKI_UNLIKELY(x) ((x) == 1)

+ 1 - 1
include/anki/math/Vec4.h

@@ -9,7 +9,7 @@ namespace anki {
 /// @{
 /// @{
 
 
 /// 4D vector. SIMD optimized
 /// 4D vector. SIMD optimized
-class Vec4
+ANKI_ATTRIBUTE_ALIGNED(class, 16) Vec4
 {
 {
 public:
 public:
 	/// @name Constructors
 	/// @name Constructors

+ 3 - 2
src/renderer/Drawer.cpp

@@ -29,9 +29,10 @@ static U64 countVerts(U32* indicesCount, I primCount)
 
 
 //==============================================================================
 //==============================================================================
 /// Visitor that sets a uniform
 /// Visitor that sets a uniform
-struct SetupRenderableVariableVisitor
+/// Align it because the clientBlock will store SIMD data
+ANKI_ATTRIBUTE_ALIGN(struct, 16) SetupRenderableVariableVisitor
 {
 {
-	Array<U32, UNIFORM_BLOCK_MAX_SIZE / sizeof(U32)> clientBlock;
+	Array<U8, UNIFORM_BLOCK_MAX_SIZE> clientBlock;
 	const Frustumable* fr = nullptr;
 	const Frustumable* fr = nullptr;
 	Renderer* r = nullptr;
 	Renderer* r = nullptr;
 	Renderable* renderable = nullptr;
 	Renderable* renderable = nullptr;