Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
vkRenderTarget.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef VK_FRAME_BUFFER_H
34#define VK_FRAME_BUFFER_H
35
37
38#include <vulkan/vulkan_core.h>
39
40namespace Divide
41{
42 namespace Attorney
43 {
44 class VKAPIRenderTarget;
45 }
46
47 class VK_API;
48 class GFXDevice;
49 class vkTexture;
50
51 class vkRenderTarget final : public RenderTarget
52 {
54
55 public:
57
58 [[nodiscard]] bool create() override;
59
60 PROPERTY_R_IW(VkRenderingInfo, renderingInfo);
61
62 private:
63 void begin(VkCommandBuffer cmdBuffer, const RTDrawDescriptor& descriptor, const RTClearDescriptor& clearPolicy, VkPipelineRenderingCreateInfo& pipelineRenderingCreateInfoOut);
64 void end(VkCommandBuffer cmdBuffer, const RTTransitionMask& mask );
65 void blitFrom( VkCommandBuffer cmdBuffer, vkRenderTarget* source, const RTBlitParams& params ) noexcept;
66 void transitionAttachments( VkCommandBuffer cmdBuffer, const RTDrawDescriptor& descriptor, const RTTransitionMask& transitionMask, bool toWrite );
67
68 private:
69 std::array<VkRenderingAttachmentInfo, to_base(RTColourAttachmentSlot::COUNT)> _colourAttachmentInfo{};
70 VkRenderingAttachmentInfo _depthAttachmentInfo{};
71
73
74 std::array<VkRenderingAttachmentInfo, to_base( RTColourAttachmentSlot::COUNT )> _stagingColourAttachmentInfo{};
76
77 std::array<VkImageSubresourceRange, RT_MAX_ATTACHMENT_COUNT> _subresourceRange{};
78
79 bool _keptMSAAData{false};
80 };
81
82 namespace Attorney
83 {
85 {
86 static void begin(vkRenderTarget& rt, VkCommandBuffer cmdBuffer, const RTDrawDescriptor& descriptor, const RTClearDescriptor& clearPolicy, VkPipelineRenderingCreateInfo& pipelineRenderingCreateInfoOut)
87 {
88 rt.begin(cmdBuffer, descriptor, clearPolicy, pipelineRenderingCreateInfoOut);
89 }
90 static void end(vkRenderTarget& rt, VkCommandBuffer cmdBuffer, const RTTransitionMask& mask )
91 {
92 rt.end(cmdBuffer, mask);
93 }
94 static void blitFrom( vkRenderTarget& rt, VkCommandBuffer cmdBuffer, vkRenderTarget* source, const RTBlitParams& params ) noexcept
95 {
96 rt.blitFrom(cmdBuffer, source, params );
97 }
98 friend class Divide::VK_API;
99 };
100 }; // namespace Attorney
101} //namespace Divide
102
103#endif //VK_FRAME_BUFFER_H
static void blitFrom(vkRenderTarget &rt, VkCommandBuffer cmdBuffer, vkRenderTarget *source, const RTBlitParams &params) noexcept
static void end(vkRenderTarget &rt, VkCommandBuffer cmdBuffer, const RTTransitionMask &mask)
static void begin(vkRenderTarget &rt, VkCommandBuffer cmdBuffer, const RTDrawDescriptor &descriptor, const RTClearDescriptor &clearPolicy, VkPipelineRenderingCreateInfo &pipelineRenderingCreateInfoOut)
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
Definition: GFXDevice.h:215
GFXDevice & context() const noexcept
PROPERTY_R_IW(VkRenderingInfo, renderingInfo)
void transitionAttachments(VkCommandBuffer cmdBuffer, const RTDrawDescriptor &descriptor, const RTTransitionMask &transitionMask, bool toWrite)
std::array< VkFormat, to_base(RTColourAttachmentSlot::COUNT)> _colourAttachmentFormats
std::array< VkRenderingAttachmentInfo, to_base(RTColourAttachmentSlot::COUNT)> _stagingColourAttachmentInfo
bool create() override
Init all attachments. Returns false if already called.
void begin(VkCommandBuffer cmdBuffer, const RTDrawDescriptor &descriptor, const RTClearDescriptor &clearPolicy, VkPipelineRenderingCreateInfo &pipelineRenderingCreateInfoOut)
void blitFrom(VkCommandBuffer cmdBuffer, vkRenderTarget *source, const RTBlitParams &params) noexcept
RTDrawDescriptor _previousPolicy
VkRenderingAttachmentInfo _depthAttachmentInfo
std::array< VkImageSubresourceRange, RT_MAX_ATTACHMENT_COUNT > _subresourceRange
std::array< VkRenderingAttachmentInfo, to_base(RTColourAttachmentSlot::COUNT)> _colourAttachmentInfo
void end(VkCommandBuffer cmdBuffer, const RTTransitionMask &mask)
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
eastl::fixed_vector< RTBlitEntry, MAX_BLIT_ENTRIES, false > RTBlitParams
std::array< RTClearEntry, RT_MAX_ATTACHMENT_COUNT > RTClearDescriptor
bool[RT_MAX_ATTACHMENT_COUNT] RTTransitionMask
constexpr auto to_base(const Type value) -> Type