Skip to content

Commit

Permalink
Math/FieldOffsets: Fix GetAlignedSize when using std430
Browse files Browse the repository at this point in the history
  • Loading branch information
SirLynix committed Nov 17, 2024
1 parent be7d599 commit 093ff7c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 1 addition & 4 deletions include/NZSL/Math/FieldOffsets.inl
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ namespace nzsl

constexpr std::size_t FieldOffsets::GetAlignedSize() const
{
if (m_layout == StructLayout::Std140)
return Nz::AlignPow2(m_size, m_largestFieldAlignment);
else
return m_size;
return Nz::AlignPow2(m_size, m_largestFieldAlignment);
}

constexpr std::size_t FieldOffsets::GetSize() const
Expand Down
3 changes: 2 additions & 1 deletion tests/src/Tests/FieldOffsetsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ TEST_CASE("Field offsets", "[FieldOffsets]")
REQUIRE(fieldOffsets.AddStruct(innerStruct) == 56);
REQUIRE(fieldOffsets.AddField(nzsl::StructFieldType::Float3) == 64);
REQUIRE(fieldOffsets.AddField(nzsl::StructFieldType::Float1) == 76);
REQUIRE(fieldOffsets.GetAlignedSize() == 80);
REQUIRE(fieldOffsets.AddField(nzsl::StructFieldType::Float1) == 80);
REQUIRE(fieldOffsets.GetAlignedSize() == 96);
}
}

Expand Down

0 comments on commit 093ff7c

Please sign in to comment.