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

#include "Utility/Headers/Colours.h"
#include "Core/Math/Headers/Line.h"
#include "Core/Math/Headers/MathMatrices.h"
#include "Platform/Video/Headers/Pipeline.h"
#include "Platform/Video/Headers/GraphicsResource.h"
#include "Platform/Video/Buffers/VertexBuffer/Headers/VertexDataInterface.h"

namespace Divide {

class Texture;
namespace GFX {
    class CommandBuffer;
};
enum class PrimitiveType : U32;

FWD_DECLARE_MANAGED_CLASS(IMPrimitive);

/// IMPrimitive replaces immediate mode calls to VB based rendering
class NOINITVTABLE IMPrimitive : public VertexDataInterface {
   public:
    inline void setRenderStates(const DELEGATE_CBK<void>& setupStatesCallback,
                                const DELEGATE_CBK<void>& releaseStatesCallback) {
        _setupStates = setupStatesCallback;
        _resetStates = releaseStatesCallback;
    }

    inline void clearRenderStates() {
        _setupStates = nullptr;
        _resetStates = nullptr;
    }

    inline void setupStates() {
        if (_setupStates) {
            _setupStates();
        }
    }

    inline void resetStates() {
        if (_resetStates) {
            _resetStates();
        }
    }

    inline const Pipeline* pipeline() const {
        return _pipeline;
    }

    virtual void pipeline(const Pipeline& pipeline);

    virtual void draw(const GenericDrawCommand& cmd) = 0;

    virtual void beginBatch(bool reserveBuffers, 
                            unsigned int vertexCount,
                            unsigned int attributeCount) = 0;

    virtual void begin(PrimitiveType type) = 0;
    virtual void vertex(F32 x, F32 y, F32 z) = 0;
    inline void vertex(const vec3<F32>& vert) {
        vertex(vert.x, vert.y, vert.z);
    }
    virtual void attribute1i(U32 attribLocation, I32 value) = 0;
    virtual void attribute1f(U32 attribLocation, F32 value) = 0;
    virtual void attribute4ub(U32 attribLocation, U8 x, U8 y, U8 z,  U8 w) = 0;
    virtual void attribute4f(U32 attribLocation, F32 x, F32 y, F32 z, F32 w) = 0;
    inline void attribute4ub(U32 attribLocation, const vec4<U8>& value) {
        attribute4ub(attribLocation, value.x, value.y, value.z, value.w);
    }
    inline void attribute4f(U32 attribLocation, const vec4<F32>& value) {
        attribute4f(attribLocation, value.x, value.y, value.z, value.w);
    }

    virtual void end() = 0;
    virtual void endBatch() = 0;

    void clear();

    inline void paused(bool state) { _paused = state; }
    inline bool paused() const { return _paused; }
    inline void forceWireframe(bool state) { _forceWireframe = state; }
    inline bool forceWireframe() const { return _forceWireframe; }
    inline bool hasRenderStates() const {
        return (!_setupStates && !_resetStates);
    }

    inline const mat4<F32>& worldMatrix() const { return _worldMatrix; }
    inline void worldMatrix(const mat4<F32>& worldMatrix) {
        _worldMatrix.set(worldMatrix);
    }
    inline void resetWorldMatrix() { _worldMatrix.identity(); }

    inline void name(const stringImpl& name) {
#       ifdef _DEBUG
        _name = name;
#       else
        ACKNOWLEDGE_UNUSED(name);
#       endif
    }

    virtual GFX::CommandBuffer& toCommandBuffer() const = 0;

    void fromBox(const vec3<F32>& min,
                 const vec3<F32>& max,
                 const UColour& colour = DefaultColours::WHITE);
    void fromSphere(const vec3<F32>& center,
                    F32 radius,
                    const UColour& colour = DefaultColours::WHITE);
    void fromLines(const vectorImpl<Line>& lines);
    void fromLines(const vectorImpl<Line>& lines,
                   const Rect<I32>& viewport);
   protected:
    void fromLines(const vectorImpl<Line>& lines,
                   const Rect<I32>& viewport,  //<only for ortho mode
                   const bool inViewport);
   protected:
   GFX::CommandBuffer* _cmdBuffer = nullptr;

    IMPrimitive(GFXDevice& context);
#ifdef _DEBUG
    stringImpl _name;
#endif
   public:
    virtual ~IMPrimitive();

   public:

    const Pipeline* _pipeline;
    const Texture* _texture;

   protected:
    // render in wireframe mode
    bool _forceWireframe;

   private:
    /// If _pause is true, rendering for the current primitive is skipped and
    /// nothing is modified (e.g. zombie counters)
    bool _paused;
    /// 2 functions used to setup or reset states
    DELEGATE_CBK<void> _setupStates;
    DELEGATE_CBK<void> _resetStates;
    /// The transform matrix for this element
    mat4<F32> _worldMatrix;
};

};  // namespace Divide

#endif

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

Diff revisions: vs.
Revision Author Commited Message
1004 Diff Diff IonutCava picture IonutCava Wed 20 Dec, 2017 17:16:32 +0000

[Ionut]
- More GUI cleanup (added multiple GUIButton events)
- Typedef vec4<U8> and vec4<F32> to UColour and FColour respectively for easier to read code.

988 Diff Diff IonutCava picture IonutCava Thu 30 Nov, 2017 23:08:51 +0000

[Ionut]
- Add a Rect class (basic wrapper around a vec4)
- More work on MouseEvent system

953 Diff Diff IonutCava picture IonutCava Sat 28 Oct, 2017 21:57:10 +0000

[Ionut]
- Fix blinking issue by caching and hashing pipelines to that we don’t overwrite pipelines used by other elements

940 Diff Diff IonutCava picture IonutCava Fri 18 Aug, 2017 16:18:44 +0000

[Ionut]
- Generate GFX::CommandBuffers only from GFX::CommandBufferPools.
— We shouldn’t be allocating any new GFX::CommandBuffers at runtime now.
— ToDo: Add a similar system for Pipelines
- Add 2 command buffer pools to GFXDevice: a primary one used for rendering and a large, secondary one used for command generation

933 Diff Diff IonutCava picture IonutCava Tue 15 Aug, 2017 00:02:05 +0000

[Ionut]
- CommandBuffer Part 2/3: code compiles and splash screen renders and application doesn’t crash (still has drawing issues)

932 Diff Diff IonutCava picture IonutCava Mon 14 Aug, 2017 16:17:59 +0000

[Ionut]
- Transition every GPU call to the new GFX::CommandBuffer system.
- Part 1/3: Infrastructure. Does not compile yet; (ToDo: part 2/3: transition commands to new infrastructure. part 3/3: debug and optimize)

Currently supported commands:
BEGIN_RENDER_PASS
END_RENDER_PASS
BEGIN_RENDER_SUB_PASS
END_RENDER_SUB_PASS
SET_VIEWPORT
SET_SCISSOR
BIND_PIPELINE
BIND_DESCRIPTOR_SETS
SEND_PUSH_CONSTANTS
DRAW_COMMANDS
DRAW_TEXT
DISPATCH_COMPUTE

929 Diff Diff IonutCava picture IonutCava Sat 12 Aug, 2017 17:34:44 +0000

[Ionut]
- More work on finishing up new PushConstant / Command buffer rendering system:
— Everything compiles and runs but with graphical and performance issues

904 Diff Diff IonutCava picture IonutCava Sun 25 Jun, 2017 21:38:57 +0000

[Ionut]
- Rework the way GPU queries are handled via GenericDrawCommand rendering options.

893 Diff Diff IonutCava picture IonutCava Sun 18 Jun, 2017 17:33:07 +0000

[Ionut]
- Initial implementation of a PipelineStateObject (holds shader program, rasterizer state, etc)
- Rework PCH implementation a bit because VS2017 no longer has a /ZM option

882 IonutCava picture IonutCava Thu 23 Mar, 2017 16:49:48 +0000

[IonutCava]
- More work on tessellated terrain rendering: got the mesh to render properly and match the collision mesh’s layout.
- Fixed a bug with GenericDrawCommand RenderOptions
- Added a “query number of generated primitives” option to GenericDrawCommand