Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
RenderAPIWrapper.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_RENDER_API_H_
34#define DVD_RENDER_API_H_
35
37
38namespace CEGUI {
39 class Texture;
40};
41
42namespace Divide {
43
44namespace GFX {
45 class CommandBuffer;
46 struct CommandBase;
47 enum class CommandType : U8;
48};
49
50enum class ErrorCode : I8;
51
52template <typename T> class vec4;
53
54class Texture;
55class ShaderProgram;
56class ResourceCache;
57class DisplayWindow;
58
59struct Configuration;
60struct TextElementBatch;
61struct RenderTargetDescriptor;
62struct ShaderBufferDescriptor;
63
68
69struct VideoModes {
70 // Video resolution
72 // Red bits per pixel
74 // Green bits per pixel
76 // Blue bits per pixel
78};
79
82{
103 size_t _bufferVRAMUsage{ 0u };
104};
105
107{
109 U8 _major { 0u };
110 U8 _minor { 0u };
111 U8 _patch { 0u };
112 U8 _variant { 0u };
113 };
114
115 U32 _maxWorgroupCount[3] = {65535u, 65535u, 65535u};
116 U32 _maxWorgroupSize[3] = {1024u, 1024u, 64u};
117 size_t _maxSizeBytesUBO = 64 * 1024;
118 size_t _maxSizeBytesSSBO = 1024 * 1024 * 1024u;
119 size_t _maxComputeSharedMemoryBytes = 1024 * 1024 * 1024;
136 U32 _maxDrawIndirectCount = std::numeric_limits<U16>::max();
140};
141
143{
144 const char* _name = nullptr;
146};
147
150public:
151 virtual ~RenderAPIWrapper() = default;
152
153protected:
154 friend class GFXDevice;
155
156 [[nodiscard]] virtual bool drawToWindow(DisplayWindow& window) = 0;
157 virtual void onRenderThreadLoopStart() = 0;
158 virtual void onRenderThreadLoopEnd() = 0;
159 virtual void prepareFlushWindow(DisplayWindow& window) = 0;
160 virtual void flushWindow(DisplayWindow& window) = 0;
161 [[nodiscard]] virtual bool frameStarted() = 0;
162 [[nodiscard]] virtual bool frameEnded() = 0;
163
164 virtual void idle(bool fast) = 0;
165
166 virtual ErrorCode initRenderingAPI(I32 argc, char** argv, Configuration& config) = 0;
167 virtual void closeRenderingAPI() = 0;
168
169 virtual void preFlushCommandBuffer(Handle<GFX::CommandBuffer> commandBuffer) = 0;
170 virtual void flushCommand(GFX::CommandBase* cmd) = 0;
171 virtual void postFlushCommandBuffer(Handle<GFX::CommandBuffer> commandBuffer) = 0;
172
173 virtual bool setViewportInternal(const Rect<I32>& newViewport) = 0;
174 virtual bool setScissorInternal(const Rect<I32>& newScissor) = 0;
175
176 virtual void onThreadCreated(const std::thread::id& threadID, bool isMainRenderThread ) = 0;
177
178 virtual bool bindShaderResources( const DescriptorSetEntries& descriptorSetEntries ) = 0;
179
180 virtual void initDescriptorSets() = 0;
181
182 virtual RenderTarget_uptr newRT( const RenderTargetDescriptor& descriptor ) const = 0;
183 virtual GenericVertexData_ptr newGVD( U32 ringBufferLength, std::string_view name ) const = 0;
184 virtual ShaderBuffer_uptr newSB( const ShaderBufferDescriptor& descriptor ) const = 0;
185};
186
188
189}; // namespace Divide
190
191#endif //DVD_RENDER_API_H_
#define FWD_DECLARE_MANAGED_CLASS(T)
#define NOINITVTABLE
char * argv[]
Definition: main.cpp:8
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
Definition: GFXDevice.h:215
Renderer Programming Interface.
virtual void prepareFlushWindow(DisplayWindow &window)=0
virtual bool frameEnded()=0
virtual ~RenderAPIWrapper()=default
virtual ErrorCode initRenderingAPI(I32 argc, char **argv, Configuration &config)=0
virtual void onRenderThreadLoopEnd()=0
virtual bool setScissorInternal(const Rect< I32 > &newScissor)=0
virtual void flushWindow(DisplayWindow &window)=0
virtual bool setViewportInternal(const Rect< I32 > &newViewport)=0
virtual void idle(bool fast)=0
virtual bool frameStarted()=0
virtual bool bindShaderResources(const DescriptorSetEntries &descriptorSetEntries)=0
virtual void initDescriptorSets()=0
virtual RenderTarget_uptr newRT(const RenderTargetDescriptor &descriptor) const =0
virtual void postFlushCommandBuffer(Handle< GFX::CommandBuffer > commandBuffer)=0
virtual void onThreadCreated(const std::thread::id &threadID, bool isMainRenderThread)=0
virtual bool drawToWindow(DisplayWindow &window)=0
virtual ShaderBuffer_uptr newSB(const ShaderBufferDescriptor &descriptor) const =0
virtual void flushCommand(GFX::CommandBase *cmd)=0
virtual GenericVertexData_ptr newGVD(U32 ringBufferLength, std::string_view name) const =0
virtual void onRenderThreadLoopStart()=0
virtual void closeRenderingAPI()=0
virtual void preFlushCommandBuffer(Handle< GFX::CommandBuffer > commandBuffer)=0
TiledForwardShading.
Definition: Renderer.h:50
constexpr U8 MAX_CULL_DISTANCES
Definition: config.h:131
constexpr U8 MAX_CLIP_DISTANCES
Definition: config.h:127
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
std::array< DescriptorSetEntry, to_base(DescriptorSetUsage::COUNT)> DescriptorSetEntries
int32_t I32
uint8_t U8
constexpr U32 U32_MAX
uint32_t U32
uint64_t U64
VersionInformation _versionInfo
Queries are expensive, so this result MAY BE SEVERAL frames out of date!
U64 _verticesSubmitted
Returns the time in milliseconds that it took to render one frame.
size_t _uniformBufferVRAMUsage
Total VRAM used for shader uniform storage across all used shader programs.
U64 _tessellationInvocations
Number of times the tessellation control shader has been invoked.
U32 _syncObjectsInFlight[3]
Number of active sync objects.
size_t _bufferVRAMUsage
Total VRAM usage for all shader buffers.
U32 _scratchBufferQueueUsage[2]
Scratch buffer queue usage.
U64 _queuedGPUFrames
How many frames are still queued up for execution on the GPU.
U64 _tessellationPatches
Number of patches processed by the tessellation control shader.