diff options
author | dan sinclair <dj2@everburning.com> | 2019-04-18 13:43:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-18 13:43:52 -0400 |
commit | 9d7d3bb684694eb43faff42bad8c400e533eaecd (patch) | |
tree | d5faaf59eaed7d8011a06dee49454ca6a58f7aad /src/buffer.cc | |
parent | b07f6a2db894a3b173040afd5acc044172df67bd (diff) | |
download | amber-9d7d3bb684694eb43faff42bad8c400e533eaecd.tar.gz |
Fix format sizes due to layout. (#482)
The STD140 and 430 layouts were not handled properly by the format code.
This CL extends the code to add the correct format padding for the
layouts and updates the buffer code to attempt to read the expected
number of values and handle the padding as needed.
Diffstat (limited to 'src/buffer.cc')
-rw-r--r-- | src/buffer.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/buffer.cc b/src/buffer.cc index d8cfd8b..7ea6485 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -172,8 +172,10 @@ Result Buffer::SetData(const std::vector<Value>& data) { } ++i; } - // Need to add an extra element if this is std140 and there are 3 elements. - if (format_->IsStd140() && format_->RowCount() == 3) + // For formats which we've padded to the the layout, make sure we skip over + // the space in the buffer. + size_t pad = format_->ValuesPerRow() - format_->GetComponents().size(); + for (size_t j = 0; j < pad; ++j) ptr += (format_->GetComponents()[0].num_bits / 8); } return {}; |