Cogs.Core
MaterialPropertyBuffer.cpp
1#include "Foundation/Logging/Logger.h"
2
3#include "MaterialPropertyBuffer.h"
4#include "Context.h"
5
6namespace {
7 using namespace Cogs::Core;
8 Cogs::Logging::Log logger = Cogs::Logging::getLogger("MaterialPropertyBuffer");
9}
10
11void Cogs::Core::MaterialPropertyBuffer::setValue(size_t offset, size_t propertySize, const uint8_t * data)
12{
13 assert(content.size() >= offset + propertySize);
14
15 for (size_t i = 0; i < propertySize; ++i) {
16 content[offset + i] = data[i];
17 }
18
19 ++generation;
20}
21
23 size_t propertySize,
24 const uint8_t * data)
25{
26 size_t offset = propertyAlignment * ((size + propertyAlignment - 1) / propertyAlignment);
27
28 size = offset + propertySize;
29
30 content.resize(size);
31
32 for (size_t i = 0; i < propertySize; ++i) {
33 content[offset + i] = data[i];
34 }
35
36 return { offset, propertySize };
37}
38
39void Cogs::Core::MaterialPropertyBuffer::finalize(Context* /*context*/)
40{
41 //LOG_DEBUG(logger, "Packed size=%zu (%u vec4's)", content.size(), quadScalarCount);
42}
43
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
Log implementation class.
Definition: LogManager.h:139
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
constexpr Log getLogger(const char(&name)[LEN]) noexcept
Definition: LogManager.h:180
COGSCORE_DLL_API void setValue(size_t offset, size_t propertySize, const uint8_t *data)
Set the property value for the property located at offset to that pointed to by data.
std::vector< uint8_t > content
Default content for property buffer instances created from this buffer.
COGSCORE_DLL_API MaterialPropertyDescriptor addProperty(size_t propertyAlignment, size_t propertySize, const uint8_t *data)
Add the value pointed to by data, with the given propertySize, to the buffer.
Contains location/size information for a property.