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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#include "stdafx.h"

#include "Headers/RTAttachmentPool.h"

#include "Core/Headers/Kernel.h"
#include "Core/Headers/Console.h"
#include "Core/Headers/StringHelper.h"
#include "Core/Resources/Headers/ResourceCache.h"

#include "Utility/Headers/Localization.h"

#include "Platform/Video/Headers/GFXDevice.h"
#include "Platform/Video/Textures/Headers/Texture.h"

namespace Divide {

namespace {
    const char* getAttachmentName(RTAttachmentType type) {
        switch (type) {
        case RTAttachmentType::Colour:  return "Colour";
        case RTAttachmentType::Depth:   return "Depth";
        case RTAttachmentType::Stencil: return "Stencil";
        };

        return "ERROR";
    };
};

RTAttachmentPool::RTAttachmentPool(RenderTarget& parent, U8 colourAttCount)
    : _parent(parent)
{
    _attachmentCount.fill(0);
    _attachment[to_base(RTAttachmentType::Colour)].resize(colourAttCount, nullptr);
    _attachment[to_base(RTAttachmentType::Depth)].resize(1, nullptr);
    _attachment[to_base(RTAttachmentType::Stencil)].resize(1, nullptr);
}

RTAttachmentPool::~RTAttachmentPool()
{
}

void RTAttachmentPool::copy(const RTAttachmentPool& other) {
    for (U8 i = 0; i < to_base(RTAttachmentType::COUNT); ++i) {
        for (U8 j = 0; j < other._attachment[i].size(); ++j) {
            const RTAttachment_ptr& att = other._attachment[i][j];
            if (att != nullptr) {
                RTAttachmentDescriptor descriptor = {};
                descriptor._clearColour = att->clearColour();
                descriptor._index = j;
                descriptor._type = static_cast<RTAttachmentType>(i);
                descriptor._texDescriptor = att->texture()->getDescriptor();

                update(descriptor);
            }
        }
    }
}

RTAttachment_ptr& RTAttachmentPool::update(const RTAttachmentDescriptor& descriptor) {
    U8 index = descriptor._index;
    RTAttachmentType type = descriptor._type;
    assert(index < to_U8(_attachment[to_U32(type)].size()));

    RTAttachment_ptr& ptr = getInternal(_attachment, type, index);
    if (ptr != nullptr) {
        // Replacing existing attachment
        Console::d_printfn(Locale::get(_ID("WARNING_REPLACING_RT_ATTACHMENT")), 
                           _parent.getGUID(),
                           getAttachmentName(type),
                           index);
        // Just to be clear about our intentions
        ptr.reset();
        --_attachmentCount[to_U32(type)];

        _attachmentCache[to_U32(type)].resize(0);
        for (const RTAttachment_ptr& att : _attachment[to_U32(type)]) {
            if (att && att->used()) {
                _attachmentCache[to_U32(type)].push_back(att);
            }
        }
    }

    ptr = std::make_shared<RTAttachment>(descriptor);

    ResourceDescriptor textureAttachment(Util::StringFormat("FBO_%s_Att_%s_%d_%d",
                                                            _parent.getName().c_str(),
                                                            getAttachmentName(type),
                                                            index,
                                                            _parent.getGUID()));
    textureAttachment.setThreadedLoading(false);
    textureAttachment.setPropertyDescriptor(descriptor._texDescriptor);

    GFXDevice& context = _parent.context();
    ResourceCache& parentCache = context.parent().resourceCache();
    Texture_ptr tex = CreateResource<Texture>(parentCache, textureAttachment);
    assert(tex);

    Texture::TextureLoadInfo info;
    tex->loadData(info, NULL, vec2<U16>(_parent.getWidth(), _parent.getHeight()));

    ptr->texture(tex);

    ++_attachmentCount[to_U32(type)];

    _attachmentCache[to_U32(type)].push_back(ptr);

    return ptr;
}

bool RTAttachmentPool::clear(RTAttachmentType type, U8 index) {
    RTAttachment_ptr& ptr = getInternal(_attachment, type, index);
    if (ptr != nullptr) {
        ptr.reset();
        return true;
    }

    return false;
}

RTAttachment_ptr& RTAttachmentPool::getInternal(AttachmentPool& pool, RTAttachmentType type, U8 index) {
    switch (type) {
        case RTAttachmentType::Colour:
        {
            assert(index < to_U8(_attachment[to_U32(type)].size()));
            return pool[to_base(RTAttachmentType::Colour)][index];
        }
        case RTAttachmentType::Depth:
        {
            assert(index == 0);
            return pool[to_base(RTAttachmentType::Depth)].front();
        }
        case RTAttachmentType::Stencil:
        {
            assert(index == 0);
            return pool[to_base(RTAttachmentType::Stencil)].front();
        }
    }

    DIVIDE_UNEXPECTED_CALL("Invalid render target attachment type");
    return pool[0][0];
}

const RTAttachment_ptr& RTAttachmentPool::getInternal(const AttachmentPool& pool, RTAttachmentType type, U8 index) const {
    switch (type) {
        case RTAttachmentType::Colour:
        {
            assert(index < to_U8(_attachment[to_U32(type)].size()));
            return pool[to_base(RTAttachmentType::Colour)][index];
        }
        case RTAttachmentType::Depth:
        {
            assert(index == 0);
            return pool[to_base(RTAttachmentType::Depth)].front();
        }
        case RTAttachmentType::Stencil:
        {
            assert(index == 0);
            return pool[to_base(RTAttachmentType::Stencil)].front();
        }
    }

    DIVIDE_UNEXPECTED_CALL("Invalid render target attachment type");
    return pool[0][0];
}

RTAttachment_ptr& RTAttachmentPool::get(RTAttachmentType type, U8 index) {
    return getInternal(_attachment, type, index);
}

const RTAttachment_ptr& RTAttachmentPool::get(RTAttachmentType type, U8 index) const {
    return getInternal(_attachment, type, index);
}

const vectorImpl<RTAttachment_ptr>& RTAttachmentPool::get(RTAttachmentType type) const {
    return _attachmentCache[to_base(type)];
}

U8 RTAttachmentPool::attachmentCount(RTAttachmentType type) const {
    return _attachmentCount[to_U32(type)];
}

}; //namespace Divide

Commits for Divide-Framework/trunk/Source Code/Platform/Video/Buffers/RenderTarget/RTAttachmentPool.cpp

Diff revisions: vs.
Revision Author Commited Message
963 Diff Diff IonutCava picture IonutCava Sun 05 Nov, 2017 18:31:51 +0000

[Ionut]
- More multi-window fixes
- Profile guided performance improvements

916 Diff Diff IonutCava picture IonutCava Thu 06 Jul, 2017 23:01:19 +0000

[Ionut]
- Performance optimizations

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

898 Diff Diff IonutCava picture IonutCava Thu 22 Jun, 2017 22:05:34 +0000

[IonutCava]
- Use vectorImpl instead of vector in the few remaining places it wasn’t used
- Force GLIM to use the submitRenderCommand / GenericDrawCommand system
- Add basic framework for a “pushConstants” type buffer that will replace Uniform() calls
- Add some code to allow hardware query rewrite in the future

890 Diff Diff IonutCava picture IonutCava Sun 14 May, 2017 20:54:59 +0000

[Ionut]
- Add pre-compiled header support
- Initial code for per-stage tessellation computation

872 Diff Diff IonutCava picture IonutCava Mon 06 Mar, 2017 23:23:20 +0000

[IonutCava]
- Optimise static casts

867 Diff Diff IonutCava picture IonutCava Mon 20 Feb, 2017 17:01:12 +0000

[IonutCava]
- Rename to_XNN and to_const_XNN functions to reflect the target data type they are converting to.
- Cleanup Angle namespace and remove all “inDegrees” parameters from rotation functions. Use aliases to differentiate between Degree and Radian parameters.
- Profile guided optimizations.

824 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.