Commit 9e6cce2d by Nicolas Capens Committed by Nicolas Capens

Prefer alignas() over ALIGN()

Since the alignas() specifier is part of the type, it cannot be used in a typedef, and compiler-specific attributes have to be used. We abstracted these into the ALIGN() macro before, but used them in other cases where alignas() can be used. Using it where possible avoids formatting weirdness with clang-format. Bug: b/144825072 Change-Id: If4185df296f0b525dd811103ac5bf1191833b154 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39468 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com>
parent 24c49ddd
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
namespace sw { namespace sw {
ALIGN(16, struct Vertex struct alignas(16) Vertex
{ {
union union
{ {
...@@ -52,7 +52,7 @@ ALIGN(16, struct Vertex ...@@ -52,7 +52,7 @@ ALIGN(16, struct Vertex
} projected; } projected;
alignas(16) float v[MAX_INTERFACE_COMPONENTS]; alignas(16) float v[MAX_INTERFACE_COMPONENTS];
}); };
static_assert((sizeof(Vertex) & 0x0000000F) == 0, "Vertex size not a multiple of 16 bytes (alignment requirement)"); static_assert((sizeof(Vertex) & 0x0000000F) == 0, "Vertex size not a multiple of 16 bytes (alignment requirement)");
......
...@@ -71,7 +71,7 @@ typedef ALIGN(16, unsigned int) uint4[4]; ...@@ -71,7 +71,7 @@ typedef ALIGN(16, unsigned int) uint4[4];
typedef ALIGN(8, float) float2[2]; typedef ALIGN(8, float) float2[2];
ALIGN(16, struct int4 struct alignas(16) int4
{ {
int x; int x;
int y; int y;
...@@ -97,9 +97,9 @@ ALIGN(16, struct int4 ...@@ -97,9 +97,9 @@ ALIGN(16, struct int4
{ {
return x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w; return x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w;
} }
}); };
ALIGN(16, struct float4 struct alignas(16) float4
{ {
float x; float x;
float y; float y;
...@@ -125,7 +125,7 @@ ALIGN(16, struct float4 ...@@ -125,7 +125,7 @@ ALIGN(16, struct float4
{ {
return x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w; return x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w;
} }
}); };
inline constexpr float4 vector(float x, float y, float z, float w) inline constexpr float4 vector(float x, float y, float z, float w)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment