Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
   Copyright (c) 2017 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software
   and associated documentation files (the "Software"), to deal in the Software
   without restriction,
   including without limitation the rights to use, copy, modify, merge, publish,
   distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
   PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
   IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

#ifndef _RENDER_TARGET_H_
#define _RENDER_TARGET_H_

#include "RTDrawDescriptor.h"
#include "RTAttachmentPool.h"
#include "Platform/Video/Headers/GraphicsResource.h"

namespace Divide {
    constexpr U32 RT_MAX_ATTACHMENTS = 32;

struct RenderTargetID {
    RenderTargetID() : RenderTargetID(RenderTargetUsage::COUNT)
    {
    }

    RenderTargetID(RenderTargetUsage usage) : RenderTargetID(usage, 0)
    {
    }

    RenderTargetID(RenderTargetUsage usage, U32 index)
        : _index(index),
          _usage(usage)
    {
    }

    U32 _index = 0;
    RenderTargetUsage _usage = RenderTargetUsage::COUNT;
};

class RenderTarget;
struct RenderTargetHandle {
    RenderTargetHandle()
        : RenderTargetHandle(RenderTargetID(), nullptr)
    {
    }

    RenderTargetHandle(RenderTargetID targetID, RenderTarget* rt)
        : _rt(rt),
        _targetID(targetID)
    {
    }

    RenderTarget* _rt;
    RenderTargetID _targetID;
};

struct RenderTargetDescriptor {
    U8 _attachmentCount = 0;
    stringImpl _name = "";
    vec2<U16>  _resolution = vec2<U16>(1u);
    RTAttachmentDescriptor* _attachments;
    F32 _depthValue = 1.0f;
    vec2<F32> _depthRange = vec2<F32>(0.0f, 1.0f);
};

class NOINITVTABLE RenderTarget : public GraphicsResource, public GUIDWrapper {
   public:
    enum class RenderTargetUsage : U32 {
        RT_READ_WRITE = 0,
        RT_READ_ONLY = 1,
        RT_WRITE_ONLY = 2
    };

   protected:
    explicit RenderTarget(GFXDevice& context, const RenderTargetDescriptor& descriptor);

   public:
    virtual ~RenderTarget();

    static RTDrawDescriptor& defaultPolicy();
    static RTDrawDescriptor& defaultPolicyKeepDepth();
    static RTDrawDescriptor& defaultPolicyDepthOnly();

    /// Resize all attachments
    virtual bool resize(U16 width, U16 height) = 0;

    virtual const RTAttachment& getAttachment(RTAttachmentType type, U8 index) const;

    /// Use by multilayered FB's
    virtual void drawToLayer(RTAttachmentType type, U8 index, U16 layer, bool includeDepth = true) = 0;
    // This call sets the target mip level to write to
    // If an attachment does not support the specified mip level, it will be DISABLED to avoid completeness errors
    virtual void setMipLevel(U16 writeLevel) = 0;
    virtual void begin(const RTDrawDescriptor& drawPolicy) = 0;
    virtual void end() = 0;
    virtual void bind(U8 unit, RTAttachmentType type, U8 index) = 0;
    virtual void readData(const vec4<U16>& rect, GFXImageFormat imageFormat, GFXDataFormat dataType, bufferPtr outData) = 0;
    virtual void blitFrom(RenderTarget* inputFB, bool blitColour = true, bool blitDepth = false) = 0;
    virtual void blitFrom(RenderTarget* inputFB, U8 index, bool blitColour = true, bool blitDepth = false) = 0;

    /// Used by cubemap FB's
    void drawToFace(RTAttachmentType type, U8 index, U16 nFace, bool includeDepth = true);

    void readData(GFXImageFormat imageFormat, GFXDataFormat dataType, bufferPtr outData);

    U16 getWidth()  const;
    U16 getHeight() const;

    F32& depthClearValue();

    const stringImpl& getName() const;

   protected:
    RTAttachmentPool* _attachmentPool;
    RenderTargetDescriptor _descriptor;

   protected:
    static RTDrawDescriptor s_policyDefault;
    static RTDrawDescriptor s_policyKeepDepth;
    static RTDrawDescriptor s_policyDepthOnly;
};

};  // namespace Divide

#endif //_RENDER_TARGET_H_

Commits for Divide-Framework/trunk/Source Code/Platform/Video/Buffers/RenderTarget/Headers/RenderTarget.h

Diff revisions: vs.
Revision Author Commited Message
912 Diff Diff IonutCava picture IonutCava Sun 02 Jul, 2017 23:42:39 +0000

[Ionut]
- Add experimental Weighted Blended Order Independed Transparency (ref: http://casual-effects.blogspot.co.uk/2015/03/implemented-weighted-blended-order.html)
— Add per drawbuffer blend
— All translucent renderbin items go via the new OIT 2-step rendering: accumulation and composition
- Make sure we have proper blend enabled for text rendering
- Add a primitive form of PushConstants (unused yet. Emulated via Uniform calls)
- Fix bug with XMLParser not using case insensitive key lookups

911 Diff Diff IonutCava picture IonutCava Fri 30 Jun, 2017 21:08:09 +0000

[Ionut]
- Use RTAttachmentDescriptor and RenderTargetDescriptor to initialise render targets.
— All formats and attachments need to be specified upfront!

909 Diff Diff IonutCava picture IonutCava Thu 29 Jun, 2017 23:57:18 +0000

[Ionut]
- Rework RenderTarget class
— RTAttachment now deal with textures directly
— RT size needs to be specified upfront
- Application class is no longer a Singleton but passed around in the PlatformContext

907 Diff Diff IonutCava picture IonutCava Wed 28 Jun, 2017 23:16:40 +0000

[Ionut]
- Rework texture loading, mip map generation, sampler usage, etc
- ResourceDescriptor for textures now ONLY takes a TextureDescriptor as a property descriptor. Sampler must be assigned to the tex descriptor:
— ToDo: Separate samplers completely from textures and assign them from a pool to textures at bind time

854 Diff Diff IonutCava picture IonutCava Wed 08 Feb, 2017 17:14:03 +0000

[IonutCava]
- Texture usage cleanup
- Reflection and Refraction cleanup for CUBE targets: use CUBE_MAP_ARRAY instead of multiple targets

836 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice

824 Diff Diff IonutCava picture IonutCava Thu 19 Jan, 2017 17:18:03 +0000

[IonutCava]
- Prev Frame attachment system removed from RenderTargets
— Concept too high level for RT. Moved prev depth buffer to GFX class
- Other small optimizations.

815 Diff Diff IonutCava picture IonutCava Thu 12 Jan, 2017 23:33:01 +0000

[IonutCava]
- Fixed viewport alignment issue
- Added per-player RenderTargets (added index support to GFXRTPool)
- Initial implementation of per-player cameras
— Removed defaultCamera
— Scenes now use a baseCamera as a template for new player cameras

809 Diff Diff IonutCava picture IonutCava Tue 10 Jan, 2017 17:16:26 +0000

[IonutCava]
- Move velocity calc to the normal colour pass.
- Optimise glFramebuffer and cleanup RTAttachment class

808 IonutCava picture IonutCava Mon 09 Jan, 2017 20:44:28 +0000

[IonutCava]
- Small cleanups