7#include "gfx_pipeline_alpha_vulkan.hpp"
8#include "gfx_device_vulkan_impl.hpp"
9#include "../macros.hpp"
11namespace hi {
inline namespace v1 {
19 vk::BlendFactor::eOne,
20 vk::BlendFactor::eZero,
22 vk::BlendFactor::eOne,
23 vk::BlendFactor::eZero,
25 vk::ColorComponentFlagBits::eA}};
28inline void gfx_pipeline_alpha::draw_in_command_buffer(vk::CommandBuffer commandBuffer, draw_context
const&
context)
30 gfx_pipeline::draw_in_command_buffer(commandBuffer,
context);
32 hi_axiom_not_null(device());
33 device()->flushAllocation(vertexBufferAllocation, 0, vertexBufferData.size() *
sizeof(vertex));
39 device()->alpha_pipeline->drawInCommandBuffer(commandBuffer);
44 pushConstants.viewportScale = scale2{2.0f / extent.width, 2.0f / extent.height};
45 commandBuffer.pushConstants(
47 vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eFragment,
49 sizeof(push_constants),
55 device()->cmdBeginDebugUtilsLabelEXT(commandBuffer,
"draw alpha overlays");
57 device()->cmdEndDebugUtilsLabelEXT(commandBuffer);
62 hi_axiom_not_null(device());
63 return device()->alpha_pipeline->shaderStages;
76inline size_t gfx_pipeline_alpha::getDescriptorSetVersion()
const
83 return push_constants::pushConstantRanges();
86inline vk::VertexInputBindingDescription gfx_pipeline_alpha::createVertexInputBindingDescription()
const
88 return vertex::inputBindingDescription();
93 return vertex::inputAttributeDescriptions();
96inline void gfx_pipeline_alpha::build_vertex_buffers()
102 vk::BufferCreateFlags(),
104 vk::BufferUsageFlagBits::eVertexBuffer,
105 vk::SharingMode::eExclusive};
111 hi_axiom_not_null(device());
113 device()->setDebugUtilsObjectNameEXT(vertexBuffer,
"alpha-pipeline vertex buffer");
114 vertexBufferData = device()->mapMemory<vertex>(vertexBufferAllocation);
117inline void gfx_pipeline_alpha::teardown_vertex_buffers()
119 hi_axiom_not_null(device());
120 device()->unmapMemory(vertexBufferAllocation);
121 device()->destroyBuffer(vertexBuffer, vertexBufferAllocation);
124inline gfx_pipeline_alpha::device_shared::device_shared(gfx_device
const& device) : device(device)
129inline gfx_pipeline_alpha::device_shared::~device_shared() {}
131inline void gfx_pipeline_alpha::device_shared::destroy(gfx_device
const*vulkanDevice)
133 hi_assert_not_null(vulkanDevice);
134 teardownShaders(vulkanDevice);
137inline void gfx_pipeline_alpha::device_shared::drawInCommandBuffer(vk::CommandBuffer
const& commandBuffer)
139 commandBuffer.bindIndexBuffer(device.quadIndexBuffer, 0, vk::IndexType::eUint16);
142inline void gfx_pipeline_alpha::device_shared::place_vertices(vector_span<vertex>& vertices,
aarectangle clipping_rectangle, quad box,
float alpha)
144 hilet clipping_rectangle_ = sfloat_rgba32{clipping_rectangle};
146 vertices.emplace_back(box.p0, clipping_rectangle_, alpha);
147 vertices.emplace_back(box.p1, clipping_rectangle_, alpha);
148 vertices.emplace_back(box.p2, clipping_rectangle_, alpha);
149 vertices.emplace_back(box.p3, clipping_rectangle_, alpha);
152inline void gfx_pipeline_alpha::device_shared::buildShaders()
154 vertexShaderModule = device.loadShader(URL(
"resource:shaders/alpha.vert.spv"));
155 device.setDebugUtilsObjectNameEXT(vertexShaderModule,
"alpha-pipeline vertex shader");
157 fragmentShaderModule = device.loadShader(URL(
"resource:shaders/alpha.frag.spv"));
158 device.setDebugUtilsObjectNameEXT(vertexShaderModule,
"alpha-pipeline fragment shader");
161 {vk::PipelineShaderStageCreateFlags(), vk::ShaderStageFlagBits::eVertex, vertexShaderModule,
"main"},
162 {vk::PipelineShaderStageCreateFlags(), vk::ShaderStageFlagBits::eFragment, fragmentShaderModule,
"main"}};
165inline void gfx_pipeline_alpha::device_shared::teardownShaders(gfx_device
const*vulkanDevice)
167 hi_assert_not_null(vulkanDevice);
168 vulkanDevice->destroy(vertexShaderModule);
169 vulkanDevice->destroy(fragmentShaderModule);
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
std::ptrdiff_t ssize_t
Signed size/index into an array.
Definition misc.hpp:33
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
Class which represents an axis-aligned rectangle.
Definition aarectangle.hpp:29