Skip to content

Commit

Permalink
Fix root constant argument binding after re-creating program bindings…
Browse files Browse the repository at this point in the history
… set (fill unused data with pre-defined constants)
  • Loading branch information
egorodet committed Oct 5, 2024
1 parent e7356f6 commit 7de1ed4
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,17 @@ UniquePtr<RootConstantAccessor> RootConstantBuffer::ReserveRootConstant(Data::Si
return std::make_unique<Accessor>(*this, buffer_range, root_constant_size);
}

void RootConstantBuffer::ReleaseRootConstant(const Accessor& reservation)
void RootConstantBuffer::ReleaseRootConstant(const Accessor& accessor)
{
META_FUNCTION_TASK();
m_free_ranges.Add(reservation.GetBufferRange());
Data::Bytes& data = GetData();
const Accessor::Range& data_range = accessor.GetBufferRange();

// Clear data range, so that root constant is updated when set again for the same range
std::fill(data.data() + data_range.GetStart(), data.data() + data_range.GetEnd(),
std::numeric_limits<Data::Byte>::max());

m_free_ranges.Add(accessor.GetBufferRange());
}

void RootConstantBuffer::SetRootConstant(const Accessor& accessor, const Rhi::RootConstant& root_constant)
Expand All @@ -134,7 +141,7 @@ Data::Bytes& RootConstantBuffer::GetData()
META_FUNCTION_TASK();
if (static_cast<Data::Size>(m_buffer_data.size()) != m_deferred_size)
{
m_buffer_data.resize(m_deferred_size);
m_buffer_data.resize(m_deferred_size, std::numeric_limits<Data::Byte>::max());
}
return m_buffer_data;
}
Expand Down

0 comments on commit 7de1ed4

Please sign in to comment.