7#include "gfx_pipeline_vulkan.hpp"
8#include "../container/module.hpp"
9#include "../image/module.hpp"
10#include "../macros.hpp"
11#include <vma/vk_mem_alloc.h>
14namespace hi {
inline namespace v1 {
23 struct alignas(16) vertex {
63 float line_width) noexcept :
70 line_width(line_width)
74 static vk::VertexInputBindingDescription inputBindingDescription()
76 return {0,
sizeof(
vertex), vk::VertexInputRate::eVertex};
82 {0, 0, vk::Format::eR32G32B32A32Sfloat, offsetof(vertex,
position)},
85 {3, 0, vk::Format::eR32G32B32A32Sfloat, offsetof(vertex,
corner_radii)},
86 {4, 0, vk::Format::eR16G16B16A16Sfloat, offsetof(vertex,
fill_color)},
87 {5, 0, vk::Format::eR16G16B16A16Sfloat, offsetof(vertex,
line_color)},
88 {6, 0, vk::Format::eR32Sfloat, offsetof(vertex, line_width)},
94 sfloat_rg32 windowExtent =
extent2{0.0, 0.0};
95 sfloat_rg32 viewportScale =
scale2{0.0, 0.0};
99 return {{vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eFragment, 0,
sizeof(
push_constants)}};
103 struct device_shared final {
104 gfx_device
const& device;
106 vk::ShaderModule vertexShaderModule;
107 vk::ShaderModule fragmentShaderModule;
110 device_shared(gfx_device
const& device);
113 device_shared(device_shared
const&) =
delete;
114 device_shared& operator=(device_shared
const&) =
delete;
115 device_shared(device_shared&&) =
delete;
116 device_shared& operator=(device_shared&&) =
delete;
121 void destroy(gfx_device
const *vulkanDevice);
123 void drawInCommandBuffer(vk::CommandBuffer
const& commandBuffer);
125 static void place_vertices(
126 vector_span<vertex>& vertices,
136 void teardownShaders(gfx_device
const *vulkanDevice);
139 vector_span<vertex> vertexBufferData;
141 ~gfx_pipeline_box() =
default;
142 gfx_pipeline_box(
const gfx_pipeline_box&) =
delete;
143 gfx_pipeline_box& operator=(
const gfx_pipeline_box&) =
delete;
144 gfx_pipeline_box(gfx_pipeline_box&&) =
delete;
145 gfx_pipeline_box& operator=(gfx_pipeline_box&&) =
delete;
147 gfx_pipeline_box(gfx_surface *surface) : gfx_pipeline(surface) {}
149 void draw_in_command_buffer(vk::CommandBuffer commandBuffer,
draw_context const& context)
override;
152 push_constants pushConstants;
154 vk::Buffer vertexBuffer;
155 VmaAllocation vertexBufferAllocation;
160 [[nodiscard]]
size_t getDescriptorSetVersion()
const override;
162 [[nodiscard]] vk::VertexInputBindingDescription createVertexInputBindingDescription()
const override;
166 void build_vertex_buffers()
override;
167 void teardown_vertex_buffers()
override;
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
The HikoGUI API version 1.
Definition lookahead_iterator.hpp:6
A color for each corner of a quad.
Definition quad_color.hpp:20
Class which represents an axis-aligned rectangle.
Definition aarectangle.hpp:29
The 4 radii of the corners of a quad or rectangle.
Definition corner_radii.hpp:19
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_box_vulkan.hpp:18
Definition gfx_pipeline_box_vulkan.hpp:23
sfloat_rgba16 line_color
border color of the box.
Definition gfx_pipeline_box_vulkan.hpp:52
sfloat_rgba32 corner_radii
Shape of each corner, negative values are cut corners, positive values are rounded corners.
Definition gfx_pipeline_box_vulkan.hpp:44
sfloat_rgba32 corner_coordinate
Double 2D coordinates inside the quad, used to determine the distance from the sides and corner insid...
Definition gfx_pipeline_box_vulkan.hpp:40
sfloat_rgba16 fill_color
background color of the box.
Definition gfx_pipeline_box_vulkan.hpp:48
sfloat_rgba32 position
The pixel-coordinates where the origin is located relative to the bottom-left corner of the window.
Definition gfx_pipeline_box_vulkan.hpp:26
sfloat_rgba32 clipping_rectangle
The position in pixels of the clipping rectangle relative to the bottom-left corner of the window,...
Definition gfx_pipeline_box_vulkan.hpp:31
Definition gfx_pipeline_box_vulkan.hpp:93
void destroy(gfx_device const *vulkanDevice)
Definition gfx_pipeline_box_vulkan_impl.hpp:117