Lugdunum  0.1.0
Queue.cpp
Go to the documentation of this file.
2 
5 
6 namespace lug {
7 namespace Graphics {
8 namespace Vulkan {
9 namespace Render {
10 
12  auto meshInstance = node.getMeshInstance();
13 
14  uint32_t i = 0;
15  for (auto& primitiveSet : meshInstance->mesh->getPrimitiveSets()) {
16  Resource::SharedPtr<Render::Material> material = Resource::SharedPtr<Render::Material>::cast(meshInstance->materials[i] ? meshInstance->materials[i] : primitiveSet.material);
17 
18  if (!material) {
19  continue;
20  }
21 
22  // Determine the pipeline id
23  Pipeline::Id pipelineId = 0;
24  {
25  Render::Mesh::PrimitiveSetData* primitiveSetData = static_cast<Render::Mesh::PrimitiveSetData*>(primitiveSet._data);
26  Pipeline::Id::PrimitivePart pipelineIdPrimitivePart = primitiveSetData->pipelineIdPrimitivePart;
27  Pipeline::Id::MaterialPart pipelineIdMaterialPart = material->getPipelineId();
28 
29  Pipeline::Id::ExtraPart pipelineIdExtraPart;
30  pipelineIdExtraPart.displayMode = static_cast<uint32_t>(renderer.getDisplayMode());
31  pipelineIdExtraPart.irradianceMapInfo = static_cast<uint32_t>(material->getIrradianceMap() && material->getIrradianceMap()->getEnvironnementTexture() ? 1 : 0);
32  pipelineIdExtraPart.prefilteredMapInfo = static_cast<uint32_t>(material->getPrefilteredMap() && material->getPrefilteredMap()->getEnvironnementTexture() ? 1 : 0);
33 
34  pipelineId = Pipeline::Id::create(pipelineIdPrimitivePart, pipelineIdMaterialPart, pipelineIdExtraPart);
35  }
36 
37  // Add in the list
38  _primitiveSets[pipelineId].push_back(Queue::PrimitiveSetInstance{
39  /* node */ &node,
40  /* primitiveSet */ &primitiveSet,
41  /* material */ material.get()
42  });
43 
44  ++i;
45  }
46 }
47 
49  _lights[_lightsCount] = &node;
50  ++_lightsCount;
51 }
52 
55 }
56 
57 void Queue::clear() {
58  _primitiveSets.clear();
59  _lightsCount = 0;
60 }
61 
62 const std::map<Render::Pipeline::Id, std::vector<Queue::PrimitiveSetInstance>> Queue::getPrimitiveSets() const {
63  return _primitiveSets;
64 }
65 
66 const std::vector<Scene::Node*> Queue::getLights() const {
67  return _lights;
68 }
69 
70 std::size_t Queue::getLightsCount() const {
71  return _lightsCount;
72 }
73 
75  return _skyBox;
76 }
77 
78 } // Render
79 } // Vulkan
80 } // Graphics
81 } // lug
Id of the Pipeline. It&#39;s a concatenation of three parts: PrimitivePart, MaterialPart and PipelinePart...
Definition: Pipeline.hpp:33
Describes the material. How is the material composed, with textures, no textures, etc...
Definition: Pipeline.hpp:61
std::map< Render::Pipeline::Id, std::vector< PrimitiveSetInstance > > _primitiveSets
Definition: Queue.hpp:51
Resource::SharedPtr< Render::SkyBox > _skyBox
Definition: Queue.hpp:56
const std::vector< Scene::Node * > getLights() const
Definition: Queue.cpp:66
Dummy class for a shared pointer.
Definition: Resource.hpp:66
void addMeshInstance(Scene::Node &node, const lug::Graphics::Renderer &renderer) override final
Definition: Queue.cpp:11
const std::map< Render::Pipeline::Id, std::vector< PrimitiveSetInstance > > getPrimitiveSets() const
Definition: Queue.cpp:62
void clear() override final
Definition: Queue.cpp:57
static Id create(PrimitivePart primitivePart, MaterialPart materialPart, ExtraPart extraPart)
Create a pipeline id.
Definition: Pipeline.hpp:154
Pipeline::Id::PrimitivePart pipelineIdPrimitivePart
Definition: Mesh.hpp:25
void addLight(Scene::Node &node) override final
Definition: Queue.cpp:48
const MeshInstance * getMeshInstance() const
Definition: Node.inl:25
uint32_t irradianceMapInfo
1 texture, 0 no texture.
Definition: Pipeline.hpp:83
uint32_t displayMode
Corresponding to the value in Renderer::DisplayMode.
Definition: Pipeline.hpp:82
void addSkyBox(Resource::SharedPtr<::lug::Graphics::Render::SkyBox > skyBox) override final
Definition: Queue.cpp:53
static SharedPtr< T > cast(const SharedPtr< RhsT > &rhs)
Dynamic casting of a SharedPtr to another one (RhsT to T)
const Resource::SharedPtr< Render::SkyBox > getSkyBox() const
Definition: Queue.cpp:74
uint32_t prefilteredMapInfo
1 texture, 0 no texture
Definition: Pipeline.hpp:84
std::size_t getLightsCount() const
Definition: Queue.cpp:70
const DisplayMode & getDisplayMode() const
Definition: Renderer.inl:13
std::vector< Scene::Node * > _lights
Definition: Queue.hpp:53