7#include "gfx_pipeline_vulkan.hpp"
8#include "gfx_device_vulkan_impl.hpp"
9#include "gfx_surface_vulkan.hpp"
10#include "../telemetry/telemetry.hpp"
11#include "../macros.hpp"
15namespace hi {
inline namespace v1 {
19 hi_axiom_not_null(surface);
20 return surface->device();
23inline void gfx_pipeline::draw_in_command_buffer(vk::CommandBuffer commandBuffer, draw_context
const&
context)
25 commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, intrinsic);
28 if (descriptorSetVersion < getDescriptorSetVersion()) {
29 descriptorSetVersion = getDescriptorSetVersion();
31 hi_axiom_not_null(device());
32 device()->updateDescriptorSets(createWriteDescriptorSet(), {});
35 commandBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, pipelineLayout, 0, {descriptorSet}, {});
39inline void gfx_pipeline::build_descriptor_sets()
45 descriptorSet =
nullptr;
50 vk::DescriptorSetLayoutCreateFlags(),
54 hi_axiom_not_null(device());
62 descriptorPool = device()->createDescriptorPool(
63 {vk::DescriptorPoolCreateFlags(),
74 descriptorSetVersion = 0;
77inline void gfx_pipeline::teardown_descriptor_sets()
83 hi_axiom_not_null(device());
84 device()->destroy(descriptorPool);
85 device()->destroy(descriptorSetLayout);
86 descriptorSet =
nullptr;
89inline vk::PipelineDepthStencilStateCreateInfo gfx_pipeline::getPipelineDepthStencilStateCreateInfo()
const
93 vk::PipelineDepthStencilStateCreateFlags(),
96 vk::CompareOp::eGreaterOrEqual,
100 vk::StencilOpState(),
112 vk::BlendFactor::eOne,
113 vk::BlendFactor::eOneMinusSrcAlpha,
115 vk::BlendFactor::eOne,
116 vk::BlendFactor::eOneMinusSrcAlpha,
118 vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | vk::ColorComponentFlagBits::eB |
119 vk::ColorComponentFlagBits::eA}};
122inline void gfx_pipeline::build_pipeline(vk::RenderPass renderPass, uint32_t
renderSubpass, vk::Extent2D
_extent)
124 hi_log_info(
"buildPipeline previous size ({}, {})", extent.width, extent.height);
127 const auto pushConstantRanges = createPushConstantRanges();
130 const auto shaderStages = createShaderStages();
137 hi_axiom_not_null(device());
138 pipelineLayout = device()->createPipelineLayout(
139 {vk::PipelineLayoutCreateFlags(),
143 pushConstantRanges.data()});
146 vk::PipelineVertexInputStateCreateFlags(),
153 vk::PipelineInputAssemblyStateCreateFlags(), vk::PrimitiveTopology::eTriangleList,
VK_FALSE};
164 hilet
scissor = vk::Rect2D{vk::Offset2D{0, 0}, extent};
169 vk::PipelineViewportStateCreateFlags(),
176 vk::PipelineRasterizationStateCreateFlags(),
179 vk::PolygonMode::eFill,
180 vk::CullModeFlagBits::eBack,
181 vk::FrontFace::eCounterClockwise,
190 vk::PipelineMultisampleStateCreateFlags(),
191 vk::SampleCountFlagBits::e1,
206 vk::PipelineColorBlendStateCreateFlags(),
218 vk::PipelineCreateFlags(),
237 hi_axiom_not_null(device());
239 hi_log_info(
"/buildPipeline new size ({}, {})", extent.width, extent.height);
242inline void gfx_pipeline::teardown_pipeline()
244 hi_axiom_not_null(device());
245 device()->destroy(intrinsic);
246 device()->destroy(pipelineLayout);
249inline void gfx_pipeline::build_for_new_device()
251 build_vertex_buffers();
254inline void gfx_pipeline::teardown_for_device_lost()
256 teardown_vertex_buffers();
259inline void gfx_pipeline::build_for_new_swapchain(vk::RenderPass renderPass, uint32_t
renderSubpass, vk::Extent2D
_extent)
263 build_descriptor_sets();
267inline void gfx_pipeline::teardown_for_swapchain_lost()
270 teardown_descriptor_sets();
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377