UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
vulkan_pipelines.hpp
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2021-2023 CESNET, z. s. p. o.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, is permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * 3. Neither the name of CESNET nor the names of its contributors may be
21 * used to endorse or promote products derived from this software without
22 * specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
26 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
28 * EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#pragma once
39
40#include "vulkan_context.hpp"
41
42#include <string>
43
44namespace vulkan_display_detail{
45
46struct ImageSize{
47 uint32_t width;
48 uint32_t height;
49
50 static ImageSize fromExtent2D(vk::Extent2D extent){
51 return ImageSize{extent.width, extent.height};
52 }
53};
54
56 bool valid = false;
57
58 vk::ShaderModule compute_shader{};
59 vk::PipelineLayout pipeline_layout{};
60 vk::Pipeline pipeline{};
61
62 vk::DescriptorSetLayout source_desc_set_layout{};
63 vk::DescriptorSetLayout destination_desc_set_layout{};
64
65 vk::SamplerYcbcrConversion yCbCr_conversion{};
66 vk::Sampler sampler{};
67
68public:
69 void create(vk::Device device, const std::string& shader_path, vk::Format format);
70
71 void destroy(vk::Device device);
72
73 void record_commands(vk::CommandBuffer cmd_buffer, ImageSize image_size, std::array<vk::DescriptorSet, 2> descriptor_set);
74
75 vk::DescriptorSetLayout get_source_image_desc_set_layout(){ return source_desc_set_layout; }
76
78
79 vk::Sampler get_sampler(){ return sampler; }
80
81 vk::SamplerYcbcrConversion get_yCbCr_conversion(){ return yCbCr_conversion; };
82};
83
84struct RenderArea {
85 uint32_t x;
86 uint32_t y;
87 uint32_t width;
88 uint32_t height;
89};
90
92 bool valid = false;
93
94 vk::SamplerYcbcrConversion yCbCr_conversion{};
95 vk::Sampler sampler{};
96
98 vk::Extent2D render_area_siza{};
99 vk::Viewport viewport{};
100 vk::Rect2D scissor{};
101
102 vk::ShaderModule vertex_shader{};
103 vk::ShaderModule fragment_shader{};
104
105 vk::RenderPass render_pass{};
106 vk::ClearValue clear_color{};
107
108 vk::DescriptorSetLayout image_desc_set_layout{};
109 vk::PipelineLayout pipeline_layout{};
110 vk::Pipeline pipeline{};
111
112public:
113 void create(VulkanContext& context, const std::string& path_to_shaders);
114
115 void destroy(vk::Device device);
116
117 void update_render_area(vk::Extent2D render_area_siza, vk::Extent2D image_size);
118
120 void reconfigure(vk::Device device, vk::Format sampler);
121
122 void record_commands(vk::CommandBuffer cmd_buffer, vk::DescriptorSet image, vk::Framebuffer framebuffer);
123
124 vk::RenderPass get_render_pass(){ return render_pass; }
125
126 vk::DescriptorSetLayout get_image_desc_set_layout(){ return image_desc_set_layout; }
127
128 vk::Sampler get_sampler(){ return sampler; }
129
130 vk::SamplerYcbcrConversion get_yCbCr_conversion(){ return yCbCr_conversion; };
131};
132
133
134} //vulkan_display_detail
vk::SamplerYcbcrConversion get_yCbCr_conversion()
vk::DescriptorSetLayout get_destination_image_desc_set_layout()
vk::DescriptorSetLayout destination_desc_set_layout
void create(vk::Device device, const std::string &shader_path, vk::Format format)
vk::DescriptorSetLayout get_source_image_desc_set_layout()
void record_commands(vk::CommandBuffer cmd_buffer, ImageSize image_size, std::array< vk::DescriptorSet, 2 > descriptor_set)
vk::SamplerYcbcrConversion yCbCr_conversion
void record_commands(vk::CommandBuffer cmd_buffer, vk::DescriptorSet image, vk::Framebuffer framebuffer)
void update_render_area(vk::Extent2D render_area_siza, vk::Extent2D image_size)
vk::DescriptorSetLayout get_image_desc_set_layout()
void create(VulkanContext &context, const std::string &path_to_shaders)
vk::SamplerYcbcrConversion get_yCbCr_conversion()
void reconfigure(vk::Device device, vk::Format sampler)
vk::DescriptorSetLayout image_desc_set_layout
static ImageSize fromExtent2D(vk::Extent2D extent)