10#define GLM_FORCE_RADIANS
11#define GLM_FORCE_DEPTH_ZERO_TO_ONE
13#include <glm/gtc/constants.hpp>
19#include <vulkan/vulkan_core.h>
35 std::unique_ptr<EnginePipeline> pipeline;
36 VkPipelineLayout pipeline_layout;
38 void create_pipeline_layout() {
39 VkPushConstantRange push_constant_range{};
40 push_constant_range.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT;
41 push_constant_range.offset = 0;
44 VkPipelineLayoutCreateInfo pipeline_layout_info{};
45 pipeline_layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
47 std::vector<VkDescriptorSetLayout> descriptor_sets_layouts{};
49 pipeline_layout_info.setLayoutCount = descriptor_sets_layouts.size();
50 pipeline_layout_info.pSetLayouts = descriptor_sets_layouts.data();
52 pipeline_layout_info.pushConstantRangeCount = 1;
53 pipeline_layout_info.pPushConstantRanges = &push_constant_range;
55 if (vkCreatePipelineLayout(
56 device.
device(), &pipeline_layout_info,
nullptr, &pipeline_layout
58 throw std::runtime_error(
"failed to create pipeline layout");
63 void create_pipeline(VkRenderPass render_pass) {
64 assert(pipeline_layout !=
nullptr &&
"Cannot create pipeline before pipeline layout");
68 pipeline_config.render_pass = render_pass;
69 pipeline_config.pipeline_layout = pipeline_layout;
70 std::vector<PipelineShaderData> shaders_data = {
72 SHADERS_DIR+
"/diffuse.vert.spv",
73 VK_SHADER_STAGE_VERTEX_BIT
76 SHADERS_DIR+
"/diffuse.geom.spv",
77 VK_SHADER_STAGE_GEOMETRY_BIT
80 SHADERS_DIR+
"/diffuse.frag.spv",
81 VK_SHADER_STAGE_FRAGMENT_BIT
84 pipeline = std::make_unique<EnginePipeline>(
95 ) : device{device}, descman{descman} {
96 create_pipeline_layout();
97 create_pipeline(render_pass);
101 vkDestroyPipelineLayout(device.
device(), pipeline_layout,
nullptr);
109 VkCommandBuffer command_buffer,
110 std::vector<EngineObjectQuat> &objects,
118 VkCommandBuffer command_buffer,
119 std::vector<EngineObjectQuat> &objects,
123 pipeline->bind(command_buffer);
129 for (
auto &obj: objects) {
130 descman.
bind_texture(command_buffer, pipeline_layout, obj);
132 push.
color = glm::vec4(obj.color, 1.0f);
134 push.
has_normalmap = glm::vec4(obj.model->has_normalmap(), 0.0f, 0.0f, 0.0f);
137 command_buffer, pipeline_layout,
138 VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
141 obj.model->bind(command_buffer);
142 obj.model->draw(command_buffer);
Mega-class responsible for handling everything to do with descriptors.
Definition: engine_descriptors.hpp:23
void bind_texture(VkCommandBuffer command_buffer, VkPipelineLayout pipeline_layout, EngineObjectQuat &object)
Definition: engine_descriptors.hpp:490
void bind_descriptor_set(VkCommandBuffer command_buffer, VkPipelineLayout pipeline_layout, uint32_t frame_index)
Definition: engine_descriptors.hpp:413
void get_regular_layouts(std::vector< VkDescriptorSetLayout > &layouts)
Definition: engine_descriptors.hpp:385
Abstraction around VkDevice, managing everything to do with the physical and logical device,...
Definition: engine_device.hpp:109
VkDevice device()
Definition: engine_device.hpp:482
static void default_pipeline_config_info(PipelineConfigInfo &config_info)
Definition: engine_pipeline.hpp:207
Standard render system used for rendering EngineObjectQuat objects.
Definition: engine_render_system.hpp:31
EngineRenderSystem(EngineDevice &device, EngineDescriptorManager &descman, VkRenderPass render_pass)
[Creating a regular Pipeline]
Definition: engine_render_system.hpp:93
EngineRenderSystem(const EngineRenderSystem &)=delete
void render_engine_objects(VkCommandBuffer command_buffer, std::vector< EngineObjectQuat > &objects, SimplePushConstantData &push, uint32_t frame_index)
Definition: engine_render_system.hpp:117
EngineRenderSystem & operator=(const EngineRenderSystem &)=delete
void render_engine_objects(VkCommandBuffer command_buffer, std::vector< EngineObjectQuat > &objects, uint32_t frame_index)
Definition: engine_render_system.hpp:108
~EngineRenderSystem()
Definition: engine_render_system.hpp:100
Definition: engine_pipeline.hpp:13
Definition: engine_render_system.hpp:21
glm::vec4 color
Definition: engine_render_system.hpp:23
glm::vec4 camera_pos
Definition: engine_render_system.hpp:24
glm::mat4 transform
Definition: engine_render_system.hpp:22
glm::vec4 has_normalmap
Definition: engine_render_system.hpp:25