Skip to content

Commit 5e83655

Browse files
rudybearmeta-codesync[bot]
authored andcommitted
igl | Add static_assert for GPU-critical struct layouts
Reviewed By: dmannemela Differential Revision: D112581392 fbshipit-source-id: ec6dc6e434f3edd4bf0e2255428662353de659a5
1 parent 686c191 commit 5e83655

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/igl/Color.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,7 @@ struct Color {
4444
return &r;
4545
}
4646
};
47+
48+
static_assert(sizeof(Color) == 4 * sizeof(float));
49+
4750
} // namespace igl

src/igl/Common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ struct ScissorRect {
168168
}
169169
};
170170

171+
static_assert(sizeof(ScissorRect) == 4 * sizeof(uint32_t));
172+
static_assert(std::is_trivially_copyable_v<ScissorRect>);
173+
171174
///--------------------------------------
172175
/// MARK: - Size
173176

@@ -216,6 +219,9 @@ struct Viewport {
216219
float maxDepth = 1.0f;
217220
};
218221

222+
static_assert(sizeof(Viewport) == 6 * sizeof(float));
223+
static_assert(std::is_trivially_copyable_v<Viewport>);
224+
219225
inline bool operator==(const Viewport& lhs, const Viewport& rhs) {
220226
return lhs.x == rhs.x && lhs.y == rhs.y && lhs.width == rhs.width && lhs.height == rhs.height &&
221227
lhs.minDepth == rhs.minDepth && lhs.maxDepth == rhs.maxDepth;

0 commit comments

Comments
 (0)