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
/*
   Copyright (c) 2014 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 "Hardware/Video/Headers/RenderAPIWrapper.h"

#include "core.h"
#include "Hardware/Video/Direct3D/Buffers/Framebuffer/Headers/d3dRenderTarget.h"
#include "Hardware/Video/Direct3D/Buffers/VertexBuffer/Headers/d3dVertexBuffer.h"
#include "Hardware/Video/Direct3D/Buffers/VertexBuffer/Headers/d3dGenericVertexData.h"
#include "Hardware/Video/Direct3D/Buffers/ShaderBuffer/Headers/d3dConstantBuffer.h"
#include "Hardware/Video/Direct3D/Buffers/PixelBuffer/Headers/d3dPixelBuffer.h"
#include "Hardware/Video/Direct3D/Shaders/Headers/d3dShaderProgram.h"
#include "Hardware/Video/Direct3D/Shaders/Headers/d3dShader.h"
#include "Hardware/Video/Direct3D/Textures/Headers/d3dTexture.h"
#include "Hardware/Video/Direct3D/Headers/d3dEnumTable.h"

namespace Divide {

DEFINE_SINGLETON_EXT1(DX_API, RenderAPIWrapper)

protected:
    DX_API() : RenderAPIWrapper() {}

    ErrorCode initRenderingApi(const vec2<U16>& resolution, I32 argc, char **argv);
    void      closeRenderingApi();
    void changeResolutionInternal(U16 w, U16 h);
    void changeViewport(const vec4<I32>& newViewport) const;
    void setCursorPosition(U16 x, U16 y) const;
    void uploadDrawCommands(const vectorImpl<IndirectDrawCommand>& drawCommands) const;
    ///Change the window's position
    void setWindowPos(U16 w, U16 h)  const;
    void beginFrame();
    void endFrame();

    inline ShaderBuffer* newSB(const bool unbound = false, const bool persistentMapped = true) const { 
        return MemoryManager_NEW d3dConstantBuffer(unbound, persistentMapped); 
    }

    inline IMPrimitive* newIMP() const { 
        return nullptr; 
    }

    inline Framebuffer* newFB(bool multisampled) const { 
        return MemoryManager_NEW d3dRenderTarget(multisampled); 
    }

    inline GenericVertexData* newGVD(const bool persistentMapped = false) const { 
        return MemoryManager_NEW d3dGenericVertexData(persistentMapped); 
    }

    inline VertexBuffer* newVB() const { 
        return MemoryManager_NEW d3dVertexBuffer(); 
    }

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

    inline Texture* newTextureArray(const bool flipped = false) const { 
        return MemoryManager_NEW d3dTexture(TEXTURE_2D_ARRAY, flipped); 
    }

    inline Texture* newTexture2D(const bool flipped = false) const { 
        return MemoryManager_NEW d3dTexture(TEXTURE_2D, flipped); 
    }

    inline Texture* newTextureCubemap(const bool flipped = false) const {
        return MemoryManager_NEW d3dTexture(TEXTURE_CUBE_MAP, flipped); 
    }

    inline ShaderProgram* newShaderProgram(const bool optimise = false) const { 
        return MemoryManager_NEW d3dShaderProgram(optimise); 
    }

    inline Shader* newShader(const stringImpl& name, const  ShaderType& type, const bool optimise = false) const { 
        return MemoryManager_NEW d3dShader(name, type, optimise); 
    }

    bool initShaders();
    bool deInitShaders();

    F32* setProjection(const vec4<F32>& rect, const vec2<F32>& planes);
    F32* setProjection(F32 FoV, F32 aspectRatio, const vec2<F32>& planes);
    void setAnaglyphFrustum(F32 camIOD, const vec2<F32>& zPlanes, F32 aspectRatio, F32 verticalFoV, bool rightFrustum = false);

    void toggleRasterization(bool state);
    void setLineWidth(F32 width);

    void drawText(const TextLabel& textLabel, const vec2<I32>& position);
    void drawPoints(U32 numPoints);

    void updateClipPlanes();
    friend class GFXDevice;
    typedef void (*callback)();
    void dxCommand(callback f){(*f)();};

    void createLoaderThread();

    U64 getFrameDurationGPU() { return 0; }

    void activateStateBlock(const RenderStateBlock& newBlock, RenderStateBlock* const oldBlock) const;

END_SINGLETON

}; //namespace Divide
#endif

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

Diff revisions: vs.
Revision Author Commited Message
331 Diff Diff IonutCava picture IonutCava Sat 06 Dec, 2014 20:53:45 +0000

[Ionut]
- Limited line length to 132 characters to improve readability and diff-comparisons
- Refactored memory allocation/deallocation functions
- Fixed a few compatibility issues with HashMap.h
- Fixed a bug in GPU Skinning shaders (cast a float to int)

330 Diff Diff IonutCava picture IonutCava Fri 10 Oct, 2014 17:19:11 +0000

[Ionut]
- New rendering algorithm :
— Perform second pass for visible nodes gathering all render commands and uploading them to an indirect draw buffer
— Render geometry with indirect draw commands
— Removed per-node range binding of the node buffer. Instead, bind the entire buffer once and index data in shaders
— Use “baseInstance” parameter from IndirectDrawCommand as a node buffer index
— Prefer DSA extensions for updating buffer data where applicable
- Moved all rendering specific code from SceneGraphNode to a new RenderingComponent
- Optimized “toString” utility function

321 Diff Diff IonutCava picture IonutCava Wed 03 Sep, 2014 22:05:15 +0000

[Ionut]
- Added support (and enabled by default) for the EASTL library (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html / https://github.com/paulhodge/EASTL)
— Strings, vectors and hash_maps can be combined from EASTL, STL and Boost (not all combinations work. e.g. EASTL strings with STL/Boost containers due to the lack of a proper hash function)

318 Diff Diff IonutCava picture IonutCava Sat 30 Aug, 2014 17:35:53 +0000

[Ionut]
- Wrapped the entire code in a “Divide” namespace
- VertexBuffers now call “shrink_to_fit” on all internal data storage
- Improved some vector performance by preferring “emplace_back” instead of “push_back” + proepr usage of reserve / resize
- Wrapped OIS specific types and classes in Divide::Input namespace
- Added the messageBox.layout file (forgot it in the previous few commits)

314 Diff Diff IonutCava picture IonutCava Sun 24 Aug, 2014 19:54:33 +0000

[Ionut]
- More AI work
- Added some needed audio dlls

303 Diff Diff IonutCava picture IonutCava Sat 09 Aug, 2014 19:12:32 +0000

[Ionut]
- Fixed mouse movement (change resolution callback properly informs inputInterface of the new window’s width and height)
- Fixed immediate mode emulation rendering (destroyed index buffers for some reason)
- Added axis gizmos for Scene / Scene + Selected Object / Scene + All object cycled via the F5 key in debug

296 Diff Diff k1ngp1n picture k1ngp1n Sun 03 Aug, 2014 14:54:21 +0000

[Ionut]
- nVidia compatibility fixes (GUI, shadows, post-processing)
- Texture bind slots are now part of ShaderProgram class
- Renamed ForwardRenderer class to ForwardPlusRenderer and moved ligh grid creation to it
- More code cleanups and comments

295 Diff Diff k1ngp1n picture k1ngp1n Fri 01 Aug, 2014 20:10:44 +0000

[Ionut]
- If a shader fails to bind, skip draw call. A shader will fail to bind if it wasn’t linked properly, as well
- Moved ShaderManager to the Hardware project due to its tight coupling
- More code cleanup and comments:
— OpenGL wrapper code : GLWrapper.h, GLWrapper.cpp, GLStates.cpp, glShaderProgram.cpp
- Cleaned up Shader.cpp
- Binary shader dump also saves binary format in .fmt file for each binary shader
- Renamed immediate mode primitive files

294 Diff Diff k1ngp1n picture k1ngp1n Wed 30 Jul, 2014 20:19:14 +0000

[Ionut]
- More nVidia compatibility fixes (lighting shaders with textures still fail to compile):
— NS_GLIM compatibility fix (set ELEMENT_ARRAY_BUFFER to 0 in glimBatchData’s VAO on creation when setting attrib pointers)

  • Could improve NS_GLIM performance a lot by caching some buffers instead of re-creating them every time a batch is generated, but it’s suppose to be used only for debugging, so low prio*

- Removed interpolation factor from FrameEvent struct. Only using interpolation factor stored in GFXDevice instance
- Fixed the close button (added GLFW close callback)
- More code style improvements (no new comments yet)

293 k1ngp1n picture k1ngp1n Tue 29 Jul, 2014 20:01:28 +0000

[Ionut]
- Code cleanup and comments in GLFWWrapper (for starters. more to follow)
- Reworked main loop logic (no more delegates and rendering api querying)
- Replaced all GLvoid with regular void
- replaced all boost::this_thread::sleep (deprecated calls) with boost::this_thread::sleep_for