Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
RenderTarget.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 DVD_RENDER_TARGET_H_
34#define DVD_RENDER_TARGET_H_
35
36#include "RTDrawDescriptor.h"
37#include "RTAttachment.h"
40
41namespace Divide {
42
43class RenderTarget;
45{
46 RenderTarget* _rt{ nullptr };
48};
49
51{
58};
59
61 public:
62 enum class Usage : U8 {
63 RT_READ_WRITE = 0,
64 RT_READ_ONLY = 1,
65 RT_WRITE_ONLY = 2
66 };
67
68 protected:
69 explicit RenderTarget(GFXDevice& context, const RenderTargetDescriptor& descriptor);
70
71 public:
73 [[nodiscard]] virtual bool create();
74
75 [[nodiscard]] bool hasAttachment(RTAttachmentType type, RTColourAttachmentSlot slot = RTColourAttachmentSlot::SLOT_0 ) const;
76 [[nodiscard]] bool usesAttachment(RTAttachmentType type, RTColourAttachmentSlot slot = RTColourAttachmentSlot::SLOT_0 ) const;
77 [[nodiscard]] RTAttachment* getAttachment(RTAttachmentType type, RTColourAttachmentSlot slot = RTColourAttachmentSlot::SLOT_0 ) const;
78 [[nodiscard]] U8 getAttachmentCount(RTAttachmentType type) const noexcept;
79 [[nodiscard]] U8 getSampleCount() const noexcept;
80
82 bool resize(U16 width, U16 height);
84 bool updateSampleCount(U8 newSampleCount);
85
86
87 [[nodiscard]] U16 getWidth() const noexcept;
88 [[nodiscard]] U16 getHeight() const noexcept;
89 [[nodiscard]] vec2<U16> getResolution() const noexcept;
90 F32& depthClearValue() noexcept;
91
92 [[nodiscard]] const Str<64>& name() const noexcept;
93
94 protected:
95 [[nodiscard]] virtual bool initAttachment(RTAttachment* att, RTAttachmentType type, RTColourAttachmentSlot slot);
96
97 [[nodiscard]] bool autoResolveAttachment(RTAttachment* att) const;
98
99 protected:
101
102 RTAttachment_uptr _attachments[RT_MAX_ATTACHMENT_COUNT]{};
103 bool _attachmentsUsed[RT_MAX_ATTACHMENT_COUNT] = {};
104 bool _attachmentsAutoResolve[RT_MAX_ATTACHMENT_COUNT] = {};
105};
106
108
109}; // namespace Divide
110
111#endif //DVD_RENDER_TARGET_H_
#define FWD_DECLARE_MANAGED_CLASS(T)
#define NOINITVTABLE
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
Definition: GFXDevice.h:215
Utility class that adds basic GUID management to objects.
Definition: GUIDWrapper.h:44
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
eastl::fixed_vector< ExternalRTAttachmentDescriptor, RT_MAX_ATTACHMENT_COUNT, false > ExternalRTAttachmentDescriptors
Definition: RTAttachment.h:104
uint8_t U8
RTAttachmentType
This enum is used when creating render targets to define the channel that the texture will attach to.
Definition: RTAttachment.h:47
uint16_t U16
eastl::fixed_vector< InternalRTAttachmentDescriptor, RT_MAX_ATTACHMENT_COUNT, false > InternalRTAttachmentDescriptors
Definition: RTAttachment.h:103
constexpr RenderTargetID INVALID_RENDER_TARGET_ID
RTColourAttachmentSlot
U32 RenderTargetID
ExternalRTAttachmentDescriptors _externalAttachments
Definition: RenderTarget.h:53
InternalRTAttachmentDescriptors _attachments
Definition: RenderTarget.h:52
RenderTargetID _targetID
Definition: RenderTarget.h:47