7#include "gfx_pipeline_vulkan.hpp"
8#include "../container/module.hpp"
9#include "../macros.hpp"
10#include <vma/vk_mem_alloc.h>
13namespace hi {
inline namespace v1 {
22 struct alignas(16) vertex {
41 static vk::VertexInputBindingDescription inputBindingDescription()
43 return {0,
sizeof(
vertex), vk::VertexInputRate::eVertex};
49 {0, 0, vk::Format::eR32G32B32A32Sfloat, offsetof(vertex,
position)},
51 {2, 0, vk::Format::eR32Sfloat, offsetof(vertex,
alpha)},
57 sfloat_rg32 windowExtent =
extent2{0.0, 0.0};
58 sfloat_rg32 viewportScale =
scale2{0.0, 0.0};
62 return {{vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eFragment, 0,
sizeof(
push_constants)}};
66 struct device_shared {
67 gfx_device
const& device;
69 vk::ShaderModule vertexShaderModule;
70 vk::ShaderModule fragmentShaderModule;
73 device_shared(gfx_device
const& device);
76 device_shared(device_shared
const&) =
delete;
77 device_shared& operator=(device_shared
const&) =
delete;
78 device_shared(device_shared&&) =
delete;
79 device_shared& operator=(device_shared&&) =
delete;
84 void destroy(gfx_device
const *vulkanDevice);
86 void drawInCommandBuffer(vk::CommandBuffer
const& commandBuffer);
88 static void place_vertices(vector_span<vertex>& vertices,
aarectangle clipping_rectangle, quad box,
float alpha);
92 void teardownShaders(gfx_device
const *vulkanDevice);
95 vector_span<vertex> vertexBufferData;
97 ~gfx_pipeline_alpha() =
default;
98 gfx_pipeline_alpha(
const gfx_pipeline_alpha&) =
delete;
99 gfx_pipeline_alpha& operator=(
const gfx_pipeline_alpha&) =
delete;
100 gfx_pipeline_alpha(gfx_pipeline_alpha&&) =
delete;
101 gfx_pipeline_alpha& operator=(gfx_pipeline_alpha&&) =
delete;
103 gfx_pipeline_alpha(gfx_surface *surface) : gfx_pipeline(surface) {}
105 void draw_in_command_buffer(vk::CommandBuffer commandBuffer,
draw_context const& context)
override;
108 push_constants pushConstants;
110 vk::Buffer vertexBuffer;
111 VmaAllocation vertexBufferAllocation;
117 [[nodiscard]]
size_t getDescriptorSetVersion()
const override;
119 [[nodiscard]] vk::VertexInputBindingDescription createVertexInputBindingDescription()
const override;
123 void build_vertex_buffers()
override;
124 void teardown_vertex_buffers()
override;
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
The HikoGUI API version 1.
Definition lookahead_iterator.hpp:6
Class which represents an axis-aligned rectangle.
Definition aarectangle.hpp:29
A high-level geometric extent.
Definition extent2.hpp:29
Draw context for drawing using the HikoGUI shaders.
Definition draw_context.hpp:208
Definition gfx_pipeline_alpha_vulkan.hpp:17
Definition gfx_pipeline_alpha_vulkan.hpp:22
sfloat_rgba32 clipping_rectangle
The position in pixels of the clipping rectangle relative to the bottom-left corner of the window,...
Definition gfx_pipeline_alpha_vulkan.hpp:30
float alpha
The alpha value of the resulting pixels inside the quad.
Definition gfx_pipeline_alpha_vulkan.hpp:34
sfloat_rgba32 position
The pixel-coordinates where the origin is located relative to the bottom-left corner of the window.
Definition gfx_pipeline_alpha_vulkan.hpp:25
Definition gfx_pipeline_alpha_vulkan.hpp:56
void destroy(gfx_device const *vulkanDevice)
Definition gfx_pipeline_alpha_vulkan_impl.hpp:131