Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
PushConstants.cpp
Go to the documentation of this file.
1
2
4
5namespace Divide
6{
7
9{
10 return _data;
11}
12
13const Byte* UniformData::data( const size_t offset ) const noexcept
14{
15 DIVIDE_ASSERT(offset < _buffer.size());
16 return &_buffer[offset];
17}
18
19bool UniformData::remove( const U64 bindingHash )
20{
21 for ( UniformData::Entry& uniform : _data )
22 {
23 if (uniform._bindingHash == bindingHash)
24 {
25 std::memset(&_buffer[uniform._range._startOffset], 0, uniform._range._length);
26 uniform = {};
27 return true;
28 }
29 }
30
31 return false;
32}
33
34bool Merge( UniformData& lhs, UniformData& rhs, bool& partial)
35{
36 for (const UniformData::Entry& ourUniform : lhs._data)
37 {
38 for (const UniformData::Entry& otherUniform : rhs._data)
39 {
40 // If we have the same binding check data on each side to see if it matches
41 if ( ourUniform._bindingHash == otherUniform._bindingHash)
42 {
43 // If we have different types or ranges for the same binding, something is probably wrong, but for our specific case, we just fail to merge.
44 if ( ourUniform._type != otherUniform._type || ourUniform._range != otherUniform._range)
45 {
46 return false;
47 }
48 // If we got here, everything apart from the data (maybe) matches, so we can just overwrite it.
49 }
50
51 lhs.set(otherUniform._bindingHash, otherUniform._type, &rhs._buffer[otherUniform._range._startOffset], otherUniform._range._length);
52 if (!rhs.remove(otherUniform._bindingHash))
53 {
55 }
56
57 partial = true;
58 }
59 }
60
61 return true;
62}
63
64}; //namespace Divide
#define DIVIDE_ASSERT(...)
#define DIVIDE_UNEXPECTED_CALL()
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
std::byte Byte
void Merge(BufferRange &lhs, const BufferRange &rhs) noexcept
Definition: BufferRange.inl:49
uint64_t U64
Definition: PushConstants.h:60
BufferRange _range
Definition: PushConstants.h:62
PushConstantType _type
Definition: PushConstants.h:63
U64 _bindingHash
Definition: PushConstants.h:61
const Byte * data(size_t offset) const noexcept
vector< Entry > UniformDataContainer
Definition: PushConstants.h:66
UniformDataContainer _data
Definition: PushConstants.h:82
bool remove(U64 bindingHash)
const UniformDataContainer & entries() const noexcept
void set(U64 bindingHash, PushConstantType type, const T &value)
eastl::fixed_vector< Byte, 32, true > _buffer
Definition: PushConstants.h:83