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
/*
   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_STATE_BLOCK_H
#define _RENDER_STATE_BLOCK_H

#include "RenderAPIEnums.h"
#include "Platform/Headers/PlatformDefines.h"

namespace Divide {

class RenderStateBlock : public GUIDWrapper {
   public:
      typedef hashMapImpl<size_t, RenderStateBlock> RenderStateMap;
      static RenderStateMap s_stateBlockMap;
   private:
      static SharedLock s_stateBlockMapMutex;
   public:
       static void init();
       static void clear();
       /// Retrieve a state block by hash value.
       /// If the hash value doesn't exist in the state block map, return the default state block
       static const RenderStateBlock& get(size_t renderStateBlockHash);
       /// Returns false if the specified hash is not found in the map
       static const RenderStateBlock& get(size_t renderStateBlockHash, bool& blockFound);

   protected:
    /// Colour Writes
    P32 _colourWrite;

    /// Rasterizer
    CullMode _cullMode;
    bool _cullEnabled;

    /// Depth
    bool _zEnable;
    ComparisonFunction _zFunc;
    F32 _zBias;
    F32 _zUnits;

    /// Stencil
    bool _stencilEnable;
    U32 _stencilRef;
    U32 _stencilMask;
    U32 _stencilWriteMask;
    StencilOperation _stencilFailOp;
    StencilOperation _stencilZFailOp;
    StencilOperation _stencilPassOp;
    ComparisonFunction _stencilFunc;

    FillMode _fillMode;

    size_t _cachedHash;

    static size_t s_defaultCacheValue;

  private:
    void operator=(const RenderStateBlock& b) = delete;
    void clean();

   public:
    RenderStateBlock();
    RenderStateBlock(const RenderStateBlock& b);

    void setDefaultValues();

    void setFillMode(FillMode mode);
    void setZBias(F32 zBias, F32 zUnits);
    void setZFunc(ComparisonFunction zFunc = ComparisonFunction::LEQUAL);
    void flipCullMode();
    void setCullMode(CullMode mode);
    void setZRead(const bool enable);

    void setStencil(bool enable,
                    U32 stencilRef = 0,
                    StencilOperation stencilFailOp  = StencilOperation::KEEP,
                    StencilOperation stencilZFailOp = StencilOperation::KEEP,
                    StencilOperation stencilPassOp  = StencilOperation::KEEP,
                    ComparisonFunction stencilFunc = ComparisonFunction::NEVER);

    void setStencilReadWriteMask(U32 read, U32 write);

    void setColourWrites(bool red, bool green, bool blue, bool alpha);

    inline P32 colourWrite() const {
        return _colourWrite;
    }
   
    inline CullMode cullMode() const {
        return _cullMode;
    }
    inline bool cullEnabled() const {
        return _cullEnabled;
    }
    inline bool zEnable() const {
        return _zEnable;
    }
    inline ComparisonFunction zFunc() const {
        return _zFunc;
    }
    inline F32 zBias() const {
        return _zBias;
    }
    inline F32 zUnits() const {
        return _zUnits;
    }
    inline bool stencilEnable() const {
        return _stencilEnable;
    }
    inline U32 stencilRef() const {
        return _stencilRef;
    }
    inline U32 stencilMask() const {
        return _stencilMask;
    }
    inline U32 stencilWriteMask() const {
        return _stencilWriteMask;
    }
    inline StencilOperation stencilFailOp() const {
        return _stencilFailOp;
    }
    inline StencilOperation stencilZFailOp() const {
        return _stencilZFailOp;
    }
    inline StencilOperation stencilPassOp() const {
        return _stencilPassOp;
    }
    inline ComparisonFunction stencilFunc() const {
        return _stencilFunc;
    }
    inline FillMode fillMode() const {
        return _fillMode;
    }
    inline size_t getHash() const {
        return _cachedHash;
    }
    bool operator==(const RenderStateBlock& RSBD) const {
        return _cachedHash == RSBD._cachedHash;
    }
    bool operator!=(const RenderStateBlock& RSBD) const {
        return _cachedHash != RSBD._cachedHash;
    }
};

};  // namespace Divide
#endif

Commits for Divide-Framework/trunk/Source Code/Platform/Video/Headers/RenderStateBlock.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

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

[IonutCava]
- Update copyright notice

821 Diff Diff IonutCava picture IonutCava Tue 17 Jan, 2017 17:15:45 +0000

[IonutCava]
- Profile guided optimizations

818 Diff Diff IonutCava picture IonutCava Mon 16 Jan, 2017 17:23:20 +0000

[IonutCava]
- Units get their bound node setup by the SGN UnitComponent and not during creation
- Profile guided optimizations

807 Diff Diff IonutCava picture IonutCava Mon 09 Jan, 2017 17:06:26 +0000

[IonutCava]
- Split PlatformDefines.h into 2. Move data type defines to PlatformDataTypes.h
- Continue to improve velocity map calculation
- Remove “destroy()” calls from most classes. Attempt to move as many classes to the RAII system.

799 Diff Diff IonutCava picture IonutCava Thu 24 Nov, 2016 22:55:23 +0000

[IonutCava]
- Performance analysis guided optimizations.

771 Diff Diff IonutCava picture IonutCava Tue 27 Sep, 2016 15:39:49 +0000

[IonutCava]
- Modify GFXDevice::flushRenderQueues so that it creates command buffers instead of directly calling rendering calls:
— Command buffers contain buffer, shader, texture and geometry info
— Command buffer state is now parsed and set at the API level instead of GFXDevice level
— This will allow easier porting to low level APIs later on
- Indirect draw is now a GenericDrawCommand render option instead of an explicit buffer draw parameter

740 Diff Diff IonutCava picture IonutCava Sat 25 Jun, 2016 17:09:50 +0000

[IonutCava]
- More scene changing related fixes
- GUIDWrapper is now a core feature instead of a utility

721 Diff Diff IonutCava picture IonutCava Wed 08 Jun, 2016 15:47:49 +0000

[IonutCava]
- Spelling: change all references from our code of “color” to the PROPER British version of “colour” because it sounds 100x better

703 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