vengine  0.0.1
3D graphics engine
Loading...
Searching...
No Matches
base.cpp
Go to the documentation of this file.
2
3void ven::ARenderSystemBase::createPipelineLayout(const VkDescriptorSetLayout globalSetLayout, const uint32_t pushConstantSize)
4{
5 VkPushConstantRange pushConstantRange{};
6 pushConstantRange.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT;
7 pushConstantRange.offset = 0;
8 pushConstantRange.size = pushConstantSize;
9
13 0,
14 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
15 VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT)
16 .addBinding(1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_SHADER_STAGE_FRAGMENT_BIT)
17 .build();
18
19 const std::vector<VkDescriptorSetLayout> descriptorSetLayouts{
20 globalSetLayout,
21 renderSystemLayout->getDescriptorSetLayout()};
22
23 VkPipelineLayoutCreateInfo pipelineLayoutInfo{};
24 pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
25 pipelineLayoutInfo.setLayoutCount = static_cast<uint32_t>(descriptorSetLayouts.size());
26 pipelineLayoutInfo.pSetLayouts = descriptorSetLayouts.data();
27 pipelineLayoutInfo.pushConstantRangeCount = 1;
28 pipelineLayoutInfo.pPushConstantRanges = &pushConstantRange;
29 if (vkCreatePipelineLayout(m_device.device(), &pipelineLayoutInfo, nullptr, &m_pipelineLayout) != VK_SUCCESS)
30 {
31 throw std::runtime_error("Failed to create pipeline layout");
32 }
33}
34
35void ven::ARenderSystemBase::createPipeline(const VkRenderPass renderPass, const std::string &shadersVertPath, const std::string &shadersFragPath, const bool isLight)
36{
37 assert(m_pipelineLayout && "Cannot create pipeline before pipeline layout");
38 PipelineConfigInfo pipelineConfig{};
40 if (isLight) {
41 pipelineConfig.attributeDescriptions.clear();
42 pipelineConfig.bindingDescriptions.clear();
43 }
44 pipelineConfig.renderPass = renderPass;
45 pipelineConfig.pipelineLayout = m_pipelineLayout;
46 m_shaders = std::make_unique<Shaders>(m_device, shadersVertPath, shadersFragPath, pipelineConfig);
47}
This file contains the ARenderSystemBase class.
void createPipelineLayout(VkDescriptorSetLayout globalSetLayout, uint32_t pushConstantSize)
Definition base.cpp:3
std::unique_ptr< DescriptorSetLayout > renderSystemLayout
Definition ABase.hpp:43
void createPipeline(VkRenderPass renderPass, const std::string &shadersVertPath, const std::string &shadersFragPath, bool isLight)
Definition base.cpp:35
VkPipelineLayout m_pipelineLayout
Definition ABase.hpp:48
Builder & addBinding(uint32_t binding, VkDescriptorType descriptorType, VkShaderStageFlags stageFlags, uint32_t count=1)
Definition setLayout.cpp:5
std::unique_ptr< DescriptorSetLayout > build() const
Definition SetLayout.hpp:32
VkDevice device() const
Definition Device.hpp:54
static void defaultPipelineConfigInfo(PipelineConfigInfo &configInfo)
Definition shaders.cpp:108