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
/*
   Copyright (c) 2016 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.

 */

/*The system is similar to the one used in Torque3D (RenderPassMgr /
  RenderBinManager)
  as it was used as an inspiration.
  All credit goes to GarageGames for the idea:
  - http://garagegames.com/
  - https://github.com/GarageGames/Torque3D
  */

#ifndef _RENDER_BIN_H_
#define _RENDER_BIN_H_

#include "Core/Math/Headers/MathMatrices.h"
#include <BetterEnums/include/enum.h>

namespace Divide {

class SceneGraphNode;
class RenderingComponent;
enum class RenderStage : U32;

struct RenderBinItem {
    RenderingComponent* _renderable;
    I32 _sortKeyA;
    I32 _sortKeyB;
    size_t _stateHash;
    F32 _distanceToCameraSq;

    RenderBinItem() : _sortKeyA(-1), _sortKeyB(-1), _stateHash(0), _distanceToCameraSq(-1.0f), _renderable(nullptr) {}
    RenderBinItem(RenderStage currentStage, I32 sortKeyA, I32 sortKeyB, F32 distToCamSq, RenderingComponent& renderable);
};

struct RenderingOrder {
    enum class List : U32 {
        NONE = 0,
        FRONT_TO_BACK = 1,
        BACK_TO_FRONT = 2,
        BY_STATE = 3,
        COUNT
    };
};

//Bins can sold certain node types. This is also the order in which nodes will be rendered!
BETTER_ENUM(RenderBinType, U32, 
    RBT_TERRAIN = 0,
    RBT_OPAQUE,
    RBT_SKY,
    RBT_WATER,
    RBT_VEGETATION_GRASS,
    RBT_TRANSLUCENT,
    RBT_PARTICLES,
    RBT_DECALS,
    RBT_IMPOSTOR,
    COUNT)

enum class RenderBitProperty : U32 {
    TRANSLUCENT = toBit(1)
};

class SceneRenderState;
struct RenderSubPassCmd;
typedef vectorImpl<RenderSubPassCmd> RenderSubPassCmds;
/// This class contains a list of "RenderBinItem"'s and stores them sorted
/// depending on designation
class RenderBin {
    typedef vectorImpl<RenderBinItem> RenderBinStack;

   public:

    friend class RenderQueue;

    RenderBin(RenderBinType rbType,
              RenderingOrder::List renderOrder);

    ~RenderBin();

    void sort(const std::atomic_bool& stopRequested, RenderStage renderStage);
    void populateRenderQueue(const std::atomic_bool& stopRequested, RenderStage renderStage);
    void postRender(const SceneRenderState& renderState, RenderStage renderStage, RenderSubPassCmds& subPassesInOut);
    void refresh();

    void addNodeToBin(const SceneGraphNode& sgn,
                      RenderStage stage,
                      const vec3<F32>& eyePos);

    inline const RenderBinItem& getItem(U16 index) const {
        assert(index < _renderBinStack.size());
        return _renderBinStack[index];
    }

    inline U16 getBinSize() const { return (U16)_renderBinStack.size(); }

    inline RenderBinType getType() const { return _rbType; }

    inline void binIndex(U32 index) { _binIndex = index; }

    inline bool empty() const { return getBinSize() == 0; }

   private:
    // mutable SharedLock _renderBinGetMutex;
    U32 _binIndex;
    U32 _binPropertyMask;
    RenderBinType _rbType;
    RenderBinStack _renderBinStack;
    RenderingOrder::List _renderOrder;
};

};  // namespace Divide
#endif

Commits for Divide-Framework/trunk/Source Code/Rendering/RenderPass/Headers/RenderBin.h

Diff revisions: vs.
Revision Author Commited Message
781 Diff Diff IonutCava picture IonutCava Wed 12 Oct, 2016 16:03:46 +0000

[IonutCava]
- ShaderComputeQueue <-> Material shader request bug fix (element stuck in QUEUED state)
- More Camera class cleanups
- Add a method of removing EnvironmentProbes from their Pool

777 Diff Diff IonutCava picture IonutCava Fri 07 Oct, 2016 16:14:48 +0000

[IonutCava]
- Continue to implement CommandBuffer / RenderPass / RenderSubPass system.
— Rendering artefacts are still present.

703 Diff Diff IonutCava picture IonutCava Wed 11 May, 2016 15:44:57 +0000

[IonutCava]
- Finish XML-based control bindings:
— Allow per bind input params (key id, mouse button index, joystick control data, etc)
— Allow mouse binding (with up to 7 buttons)
— Allow up to 4 joysticks (for now) with 120+ button, POV, Axis, Slider and Vector binding support for each
- Change all hashes in code from U32 to size_t for compatibility with STL/Boost

664 Diff Diff IonutCava picture IonutCava Wed 30 Mar, 2016 16:23:51 +0000

[IonutCava]
- Split some render bin loops into multiple tasks
- Cleaned up the Task class
- Attempt to improve Console multithreaded performance (does not compile yet)

662 Diff Diff IonutCava picture IonutCava Mon 28 Mar, 2016 18:46:06 +0000

[Ionut]
- stopRequested param for Task callbacks should be an atomic const reference
- DebugInterface thread safety updates
- Initial code for locked Tasks (tasks that can’t be reset)

660 Diff Diff IonutCava picture IonutCava Mon 21 Mar, 2016 17:11:19 +0000

[IonutCava]
- Finish Parent<->Children thread pool system
- Use new thread pool system for most multithreaded tasks in the engine: culling, sorting, light preparation, etc
- Add platform specific init/close calls at the start and end of the main function for future use

648 Diff Diff IonutCava picture IonutCava Sun 21 Feb, 2016 16:32:52 +0000

[IonutCava]
- Update copyright notice
- Move BoundingBox and BoundingSphere to a new BoundsComponent
— Add a temp hack in SceneGraphNode to update these

643 Diff Diff IonutCava picture IonutCava Sat 13 Feb, 2016 12:36:20 +0000

[IonutCava]
- Add support for multiple GFX render queues
— Flush all queues in a tight loop
— This may allow populating the render queues from renderbins in parallel

629 Diff Diff IonutCava picture IonutCava Thu 21 Jan, 2016 17:08:04 +0000

[IonutCava]
- New environment mapping system:
— Use previous frame’s list of nodes sorted front to back
— Update reflection for each if they meet the necessary criteria
- Cleanup particle system classes
- Cleanup GenericVertexData class
- Improve argument forwarding to frustum culling tasks

626 IonutCava picture IonutCava Tue 19 Jan, 2016 17:12:16 +0000

[IonutCava]
- All visual entities have a reflection texture by default and it becomes visible above a certain shininess threshold
- More profile-guided optimizations