summaryrefslogtreecommitdiff
path: root/src/vk/graphics_pipeline_3d_layout.cpp
diff options
context:
space:
mode:
authorFrederico Linhares <fred@linhares.blue>2023-01-12 15:23:16 -0300
committerFrederico Linhares <fred@linhares.blue>2023-01-12 15:23:16 -0300
commit704858045b4f7defb977adb8344ae4428cd02081 (patch)
treea21dfcdbd7836b0a55bdeaf99001e615ada98e0a /src/vk/graphics_pipeline_3d_layout.cpp
parent62367a0bcca75c45eb3e7d1582c4fff18827ddc7 (diff)
refa Use Push constants for 3D models
Diffstat (limited to 'src/vk/graphics_pipeline_3d_layout.cpp')
-rw-r--r--src/vk/graphics_pipeline_3d_layout.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/vk/graphics_pipeline_3d_layout.cpp b/src/vk/graphics_pipeline_3d_layout.cpp
index 4374ab9..db5d210 100644
--- a/src/vk/graphics_pipeline_3d_layout.cpp
+++ b/src/vk/graphics_pipeline_3d_layout.cpp
@@ -19,6 +19,7 @@
#include <array>
#include "../core.hpp"
+#include "uniform_data_object.hpp"
namespace
{
@@ -106,21 +107,15 @@ load_descriptor_set_model_instance(void *obj)
{
auto self = static_cast<VK::GraphicsPipeline3DLayout*>(obj);
- std::array<VkDescriptorSetLayoutBinding, 2> layout_bindings{};
+ std::array<VkDescriptorSetLayoutBinding, 1> layout_bindings{};
layout_bindings[0].binding = 0;
- layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
+ layout_bindings[0].descriptorType =
+ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
layout_bindings[0].descriptorCount = 1;
- layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
+ layout_bindings[0].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
layout_bindings[0].pImmutableSamplers = nullptr;
- layout_bindings[1].binding = 1;
- layout_bindings[1].descriptorType =
- VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
- layout_bindings[1].descriptorCount = 1;
- layout_bindings[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
- layout_bindings[1].pImmutableSamplers = nullptr;
-
VkDescriptorSetLayoutCreateInfo layout_info{};
layout_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
layout_info.pNext = nullptr;
@@ -155,12 +150,17 @@ load_pipeline(void *obj)
self->descriptor_set_view,
self->descriptor_set_model_instance};
+ std::array<VkPushConstantRange, 1> push_constants;
+ push_constants[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
+ push_constants[0].offset = 0;
+ push_constants[0].size = sizeof(VK::ODOModelInstance);
+
VkPipelineLayoutCreateInfo pipeline_layout_info{};
pipeline_layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
pipeline_layout_info.setLayoutCount = set_layouts.size();
pipeline_layout_info.pSetLayouts = set_layouts.data();
- pipeline_layout_info.pushConstantRangeCount = 0;
- pipeline_layout_info.pPushConstantRanges = nullptr;
+ pipeline_layout_info.pushConstantRangeCount = push_constants.size();
+ pipeline_layout_info.pPushConstantRanges = push_constants.data();
if(vkCreatePipelineLayout(
cg_core.vk_device_with_swapchain->device,