Lugdunum  0.1.0
Material.cpp
Go to the documentation of this file.
2 
5 
6 namespace lug {
7 namespace Graphics {
8 namespace Vulkan {
9 namespace Render {
10 namespace BufferPool {
11 
12 Material::Material(Renderer& renderer) : BufferPool(renderer, {
13  renderer.getDevice().getQueue("queue_graphics")->getQueueFamily()->getIdx(),
14  renderer.getDevice().getQueue("queue_transfer")->getQueueFamily()->getIdx()
15 }) {}
16 
18  const auto& result = BufferPool::allocate(material.getHandle().value, material.isDirty());
19  material.clearDirty();
20 
21  if (std::get<0>(result) && std::get<1>(result)) {
22  // Update the buffer if the BufferPool told us that we need to
23  cmdBuffer.updateBuffer(
24  *std::get<1>(result)->getBuffer(),
25  &material.getConstants(), sizeof(::
26  lug::Graphics::Render::Material::Constants),
27  std::get<1>(result)->getOffset()
28  );
29  }
30 
31  return std::get<1>(result);
32 }
33 
34 } // BufferPool
35 } // Render
36 } // Vulkan
37 } // Graphics
38 } // lug
uint32_t value
Access of the raw value of the above bytefield.
Definition: Resource.hpp:48
const SubBuffer * allocate(const API::CommandBuffer &cmdBuffer, ::lug::Graphics::Render::Material &material)
Definition: Material.cpp:17
std::tuple< bool, const SubBuffer * > allocate(size_t hash, bool dirty)
Definition: BufferPool.inl:7
const API::Queue * getQueue(const std::string &queueName) const
Definition: Device.cpp:70
Handle getHandle() const
Returns the handle of the Resource.
Definition: Resource.inl:133
const Constants & getConstants() const
Definition: Material.inl:11
const QueueFamily * getQueueFamily() const
Definition: Queue.cpp:86
Class for Material. Is a Resource.
Definition: Material.hpp:25
bool isDirty(uint32_t currentFrame) const
Definition: DirtyObject.inl:21