11 namespace BufferPool {
20 size_t hash = nodes.size() * 2;
21 for (
auto node : nodes) {
22 hash ^=
reinterpret_cast<size_t>(node) + 0x9e3779b9 + (hash << 6) + (hash >> 2);
23 hash ^= node->getLight()->getHandle().value + 0x9e3779b9 + (hash << 6) + (hash >> 2);
26 const auto& result =
BufferPool::allocate(hash, std::any_of(nodes.cbegin(), nodes.cend(), [¤tFrame](const ::lug::Graphics::Scene::Node* node) {
27 return node->getLight()->isDirty(currentFrame) || node->isDirty(currentFrame);
30 for (
auto node : nodes) {
31 node->getLight()->clearDirty(currentFrame);
32 node->clearDirty(currentFrame);
35 if (std::get<0>(result) && std::get<1>(result)) {
37 for (uint32_t i = 0; i < nodes.size(); ++i) {
38 const auto& light = nodes[i]->getLight();
41 light->getData(lightData, *nodes[i]);
43 cmdBuffer.updateBuffer(
44 *std::get<1>(result)->getBuffer(),
45 &lightData,
sizeof(lightData),
50 const uint32_t lightsNb =
static_cast<uint32_t
>(nodes.size());
51 cmdBuffer.updateBuffer(
52 *std::get<1>(result)->getBuffer(),
53 &lightsNb,
sizeof(uint32_t),
57 return std::get<1>(result);
std::tuple< bool, const SubBuffer * > allocate(size_t hash, bool dirty)
const API::Queue * getQueue(const std::string &queueName) const
Light(Renderer &renderer)
const QueueFamily * getQueueFamily() const
const SubBuffer * allocate(uint32_t currentFrame, const API::CommandBuffer &cmdBuffer, const std::vector<::lug::Graphics::Scene::Node *> nodes)
API::Device & getDevice()
static constexpr uint32_t strideShader