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
/*
   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.

 */

#ifndef _WRAPPER_DX_H_
#define _WRAPPER_DX_H_

#include "Platform/Video/Headers/RenderAPIWrapper.h"

#include "Platform/Video/Direct3D/Buffers/RenderTarget/Headers/d3dRenderTarget.h"
#include "Platform/Video/Direct3D/Buffers/VertexBuffer/Headers/d3dVertexBuffer.h"
#include "Platform/Video/Direct3D/Buffers/VertexBuffer/Headers/d3dGenericVertexData.h"
#include "Platform/Video/Direct3D/Buffers/ShaderBuffer/Headers/d3dConstantBuffer.h"
#include "Platform/Video/Direct3D/Buffers/PixelBuffer/Headers/d3dPixelBuffer.h"
#include "Platform/Video/Direct3D/Shaders/Headers/d3dShaderProgram.h"
#include "Platform/Video/Direct3D/Textures/Headers/d3dTexture.h"
#include "Platform/Video/Direct3D/Headers/d3dEnumTable.h"

namespace Divide {

DEFINE_SINGLETON_W_SPECIFIER(DX_API, RenderAPIWrapper, final)
  protected:
    DX_API() : RenderAPIWrapper() {}
    virtual ~DX_API() {}

    ErrorCode initRenderingAPI(I32 argc, char** argv) override;
    void closeRenderingAPI() override;
    void changeViewport(const vec4<I32>& newViewport) const override;
    void registerCommandBuffer(const ShaderBuffer& commandBuffer) const override;
    bool makeTexturesResident(const TextureDataContainer& textureData) override;
    bool makeTextureResident(const TextureData& textureData) override;
    void beginFrame() override;
    void endFrame(bool swapBuffers) override;

    inline ShaderBuffer* newSB(GFXDevice& context,
                               const U32 ringBufferLength = 1,
                               const bool unbound = false,
                               const bool persistentMapped = true,
                               BufferUpdateFrequency frequency =
                                   BufferUpdateFrequency::ONCE) const override {
        return MemoryManager_NEW d3dConstantBuffer(context,
                                                   ringBufferLength,
                                                   unbound,
                                                   persistentMapped,
                                                   frequency);
    }

    inline IMPrimitive* newIMP(GFXDevice& context) const override { return nullptr; }

    inline RenderTarget* newRT(GFXDevice& context, bool multisampled) const override {
        return MemoryManager_NEW d3dRenderTarget(context, multisampled);
    }

    inline GenericVertexData* newGVD(GFXDevice& context,
                                     const U32 ringBufferLength = 1) const override {
        return MemoryManager_NEW d3dGenericVertexData(context, ringBufferLength);
    }

    inline VertexBuffer* newVB(GFXDevice& context) const override {
        return MemoryManager_NEW d3dVertexBuffer(context);
    }

    inline PixelBuffer* newPB(GFXDevice& context, const PBType& type) const override {
        return MemoryManager_NEW d3dPixelBuffer(context, type);
    }

    inline Texture* newTexture(GFXDevice& context, const stringImpl& name, const stringImpl& resourceLocation, TextureType type, bool asyncLoad) const override {
        return MemoryManager_NEW d3dTexture(context, name, resourceLocation, type, asyncLoad);
    }

    inline ShaderProgram* newShaderProgram(GFXDevice& context, const stringImpl& name, const stringImpl& resourceLocation, bool asyncLoad) const override {
        return MemoryManager_NEW d3dShaderProgram(context, name, resourceLocation, asyncLoad);
    }

    bool initShaders() override;
    bool deInitShaders() override;

    void toggleDepthWrites(bool state) override;
    void toggleRasterization(bool state) override;

    void drawText(const TextLabel& textLabel, const vec2<F32>& position) override;
    void draw(const GenericDrawCommand& cmd);
    void updateClipPlanes() override;
    void syncToThread(std::thread::id threadID) override;

    U64 getFrameDurationGPU() override { return 0; }
    void activateStateBlock(const RenderStateBlock& newBlock,
                            const RenderStateBlock& oldBlock) const override;

END_SINGLETON

};  // namespace Divide
#endif

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

Diff revisions: vs.
Revision Author Commited Message
727 Diff Diff IonutCava picture IonutCava Tue 14 Jun, 2016 16:01:38 +0000

[IonutCava]
- Remove node and cmd buffers from GFXDevice and add them as a new BufferData struct to RenderPass class.
— Each render pass holds its own buffers
- Improvements / fixes to the CSM code
- Added a global toggle to enable/disable custom memory allocators

725 Diff Diff IonutCava picture IonutCava Fri 10 Jun, 2016 12:44:46 +0000

[IonutCava]
- Removed GFX drawPoints and drawTriangle calls and replaced them with a single draw command that takes a GenericDrawCommand parameter.
- Updated CSM code. Shadows now render in the correct position again. Still has issues.

718 Diff Diff IonutCava picture IonutCava Thu 02 Jun, 2016 16:02:48 +0000

[IonutCava]
- Code cleanup:
— Rename Framebuffer to RenderTarget. Only OpenGL uses the Framebuffer nomenclature.
— Remove base Shader class as only OpenGL will have separate shaders (and eventually move to pipeline objects) as Direct3D uses FX files and may end up with different structure
— Remove drawBox3D, drawSphere3D and drawLines from GFXDevice class and add them as member functions to the IMPrimitive class (renamed to fromXYZ)
— Pull some elements from SceneManager and move them to standalone classes (W.I.P.)

715 Diff Diff IonutCava picture IonutCava Fri 27 May, 2016 16:19:22 +0000

[IonutCava]
- Added initial Fade In / Fade Out post effect (used for scene transitions for now)
- Added a GUI Interface that handles a list of GUI elements (used by GUI and SceneGUIElements)
- Fixed some race conditions related to multi-threaded scene loading (a lot remain to be fixed)
- Improved per-thread GPU sync system a bit
- Simplified Singleton define macros (although we should get rid of singletons all together)

714 Diff Diff IonutCava picture IonutCava Thu 26 May, 2016 16:26:23 +0000

[IonutCava]
- Initial code for multithreaded scene load:
— Tasks can have a “sync with gpu” flag that will cause them to use a shared context (so they can call GL functions)
- Added per scene GUI lists that get passed to the main GUI class (still need a base class to hold the map and accessors to avoid code duplication)
- Re-enabled threading unit tests

712 Diff Diff IonutCava picture IonutCava Tue 24 May, 2016 16:18:37 +0000

[IonutCava]
- Added the concept of “buffer” to be used by GenericVertexData and ShaderBuffer without caring if it’s persistent or not.
— Persistent buffers handle their own locking instead of relying on the parent class
- HiZ occlusion culling fixes and optimizations

692 Diff Diff IonutCava picture IonutCava Wed 27 Apr, 2016 16:24:26 +0000

[IonutCava]
- Resource system cleanup:
— Resource name and resource file location (if any) is now passed only via explicit constructors! (ResourceDescriptors already contain this data, so why use setters?)
- Fix a bug with ortho projection matrix calculation (set m[3][3] to 1. this was skipped when the identity() call was changed to zero() in the ortho() function)
— This also fixed text rendering

657 Diff Diff IonutCava picture IonutCava Sun 06 Mar, 2016 18:54:25 +0000

[Ionut]
- Small corrections to the resolution change system and its relation to the GUI rendering system

655 Diff Diff IonutCava picture IonutCava Wed 02 Mar, 2016 17:22:28 +0000

[IonutCava]
- Rebalance responsibilities between Kernel and Application
— Application handles the main loop and calls the appropriate kernel methods

654 IonutCava picture IonutCava Tue 01 Mar, 2016 17:22:09 +0000

[Ionut]
- Moved window related code from rendering API code into proper classes:
— DisplayWindow handles SDL based window management
— WindowManager handles multiple DisplayWindow instances
— Code still needs proper extensive testing
- Small performance optimizations