Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
RTAttachment.h
Go to the documentation of this file.
1/*
2Copyright (c) 2018 DIVIDE-Studio
3Copyright (c) 2009 Ionut Cava
4
5This file is part of DIVIDE Framework.
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software
9and associated documentation files (the "Software"), to deal in the Software
10without restriction,
11including without limitation the rights to use, copy, modify, merge, publish,
12distribute, sublicense,
13and/or sell copies of the Software, and to permit persons to whom the
14Software is furnished to do so,
15subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in
18all copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED,
22INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23PARTICULAR PURPOSE AND NONINFRINGEMENT.
24IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25DAMAGES OR OTHER LIABILITY,
26WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27IN CONNECTION WITH THE SOFTWARE
28OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30*/
31
32#pragma once
33#ifndef DVD_RENDER_TARGET_ATTACHMENT_H_
34#define DVD_RENDER_TARGET_ATTACHMENT_H_
35
39
40namespace Divide {
41
42class Texture;
44
45
47enum class RTAttachmentType : U8 {
48 COLOUR = 0,
49 DEPTH,
51 COUNT
52};
53
55{
56 explicit RTAttachmentDescriptor( const SamplerDescriptor sampler, const RTAttachmentType type, const RTColourAttachmentSlot slot, const bool autoResolve) noexcept
57 : _sampler(sampler)
58 , _type(type)
59 , _slot(slot)
60 , _autoResolve(autoResolve)
61 {
62 }
63
68 bool _autoResolve{true};
69};
70
73
74// External attachments get added last and OVERRIDE any normal attachments found at the same type+index location
76{
78 const SamplerDescriptor sampler,
79 const RTAttachmentType type,
80 const RTColourAttachmentSlot slot,
81 bool autoResolve = true )
82 : RTAttachmentDescriptor(sampler, type, slot, autoResolve)
83 {
84 _externalAttachment = attachment;
85 }
86};
87
89{
91 const SamplerDescriptor sampler,
92 const RTAttachmentType type,
93 const RTColourAttachmentSlot slot,
94 bool autoResolve = true)
95 : RTAttachmentDescriptor(sampler, type, slot, autoResolve)
96 , _texDescriptor(descriptor)
97 {
98 }
99
101};
102
103using InternalRTAttachmentDescriptors = eastl::fixed_vector<InternalRTAttachmentDescriptor, RT_MAX_ATTACHMENT_COUNT, false>;
104using ExternalRTAttachmentDescriptors = eastl::fixed_vector<ExternalRTAttachmentDescriptor, RT_MAX_ATTACHMENT_COUNT, false>;
105
106class RenderTarget;
107class RTAttachment final
108{
109 public:
110 enum class Layout : U8
111 {
112 UNDEFINED = 0u,
115 };
116
117 public:
118 explicit RTAttachment(RenderTarget& parent, const RTAttachmentDescriptor& descriptor) noexcept;
120
121 [[nodiscard]] Handle<Texture> texture() const;
122
123 void setTexture( Handle<Texture> renderTexture, Handle<Texture> resolveTexture) noexcept;
124
125 RenderTarget& parent() noexcept;
126 [[nodiscard]] const RenderTarget& parent() const noexcept;
127
130
131 PROPERTY_R_IW(Handle<Texture>, renderTexture, INVALID_HANDLE<Texture> );
132 PROPERTY_R_IW(Handle<Texture>, resolvedTexture, INVALID_HANDLE<Texture> );
133
134 PROPERTY_RW(U32, binding, 0u);
135 PROPERTY_RW(bool, changed, false);
136
137 protected:
139};
140
142
143}; //namespace Divide
144
145#endif //DVD_RENDER_TARGET_ATTACHMENT_H_
#define FWD_DECLARE_MANAGED_CLASS(T)
void setTexture(Handle< Texture > renderTexture, Handle< Texture > resolveTexture) noexcept
Handle< Texture > texture() const
RenderTarget & parent() noexcept
RTAttachmentDescriptor _descriptor
Definition: RTAttachment.h:128
PROPERTY_R_IW(Handle< Texture >, resolvedTexture, INVALID_HANDLE< Texture >)
PROPERTY_R_IW(Handle< Texture >, renderTexture, INVALID_HANDLE< Texture >)
RenderTarget & _parent
Definition: RTAttachment.h:138
PROPERTY_RW(bool, changed, false)
PROPERTY_RW(U32, binding, 0u)
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
static constexpr U32 RT_DEPTH_ATTACHMENT_IDX
Definition: RTAttachment.h:71
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
eastl::fixed_vector< InternalRTAttachmentDescriptor, RT_MAX_ATTACHMENT_COUNT, false > InternalRTAttachmentDescriptors
Definition: RTAttachment.h:103
RTColourAttachmentSlot
static constexpr U8 RT_MAX_ATTACHMENT_COUNT
Definition: RTAttachment.h:72
uint32_t U32
constexpr auto to_base(const Type value) -> Type
ExternalRTAttachmentDescriptor(RTAttachment *attachment, const SamplerDescriptor sampler, const RTAttachmentType type, const RTColourAttachmentSlot slot, bool autoResolve=true)
Definition: RTAttachment.h:77
InternalRTAttachmentDescriptor(TextureDescriptor &descriptor, const SamplerDescriptor sampler, const RTAttachmentType type, const RTColourAttachmentSlot slot, bool autoResolve=true)
Definition: RTAttachment.h:90
SamplerDescriptor _sampler
Definition: RTAttachment.h:64
RTColourAttachmentSlot _slot
Definition: RTAttachment.h:67
RTAttachmentDescriptor(const SamplerDescriptor sampler, const RTAttachmentType type, const RTColourAttachmentSlot slot, const bool autoResolve) noexcept
Definition: RTAttachment.h:56
RTAttachment * _externalAttachment
Definition: RTAttachment.h:65