Lugdunum
0.1.0
src
lug
Graphics
Vulkan
Render
DescriptorSetPool
MaterialTextures.cpp
Go to the documentation of this file.
1
#include <
lug/Graphics/Vulkan/Render/DescriptorSetPool/MaterialTextures.hpp
>
2
3
#include <
lug/Graphics/Vulkan/Renderer.hpp
>
4
5
namespace
lug
{
6
namespace
Graphics {
7
namespace
Vulkan
{
8
namespace
Render {
9
namespace
DescriptorSetPool {
10
11
MaterialTextures::MaterialTextures
(
Renderer
& renderer) :
DescriptorSetPool
(renderer) {}
12
13
const
DescriptorSet
*
MaterialTextures::allocate
(
const
API::GraphicsPipeline
& pipeline,
const
std::vector<const ::lug::Graphics::Vulkan::Render::Texture*>& textures) {
14
// Generate hash
15
size_t
hash = textures.size();
16
for
(uint32_t i = 0; i < textures.size(); ++i) {
17
hash ^= textures[i]->getHandle().value + 0x9e3779b9 + (hash << 6) + (hash >> 2);
18
}
19
20
const
auto
& result =
DescriptorSetPool::allocate
(
21
hash,
22
pipeline.
getLayout
()->
getDescriptorSetLayouts
()[3]
23
);
24
25
if
(std::get<0>(result) && std::get<1>(result)) {
26
std::vector<VkDescriptorImageInfo> imageInfos(textures.size());
27
28
for
(uint32_t i = 0; i < textures.size(); ++i) {
29
imageInfos[i].sampler =
static_cast<
VkSampler
>
(textures[i]->getSampler());
30
imageInfos[i].imageView =
static_cast<
VkImageView
>
(textures[i]->getImageView());
31
imageInfos[i].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
32
}
33
34
35
std::get<1>(result)->getDescriptorSet().updateImages(
36
0,
37
0,
38
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
39
imageInfos
40
);
41
}
42
43
return
std::get<1>(result);
44
}
45
46
}
// DescriptorSetPool
47
}
// Render
48
}
// Vulkan
49
}
// Graphics
50
}
// lug
lug::Graphics::Vulkan::Render::DescriptorSetPool::MaterialTextures::MaterialTextures
MaterialTextures(Renderer &renderer)
Definition:
MaterialTextures.cpp:11
lug::Graphics::Vulkan::Render::DescriptorSetPool::DescriptorSet
Definition:
DescriptorSet.hpp:14
lug::Graphics::Vulkan::Render::DescriptorSetPool::MaterialTextures::allocate
const DescriptorSet * allocate(const API::GraphicsPipeline &pipeline, const std::vector< const ::lug::Graphics::Vulkan::Render::Texture *> &textures)
Definition:
MaterialTextures.cpp:13
Vulkan
Definition:
Vulkan.hpp:155
lug::Graphics::Vulkan::Render::DescriptorSetPool::DescriptorSetPool::allocate
std::tuple< bool, const DescriptorSet * > allocate(size_t hash, const API::DescriptorSetLayout &descriptorSetLayout)
Definition:
DescriptorSetPool.inl:47
Renderer.hpp
lug
Definition:
Application.hpp:11
lug::Graphics::Vulkan::API::GraphicsPipeline::getLayout
const PipelineLayout * getLayout() const
Definition:
GraphicsPipeline.cpp:53
lug::Graphics::Vulkan::API::PipelineLayout::getDescriptorSetLayouts
const std::vector< DescriptorSetLayout > & getDescriptorSetLayouts() const
Gets the DescriptorSetLayouts of the PipelineLayout. The PipelineLayout owns these DescriptorSetLayou...
Definition:
PipelineLayout.inl:1
lug::Graphics::Vulkan::Renderer
Definition:
Renderer.hpp:21
lug::Graphics::Vulkan::API::GraphicsPipeline
Definition:
GraphicsPipeline.hpp:17
lug::Graphics::Vulkan::Render::DescriptorSetPool::DescriptorSetPool
Definition:
DescriptorSet.hpp:12
MaterialTextures.hpp
Generated by
1.8.13