Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
GFXDevice.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_HARDWARE_VIDEO_GFX_DEVICE_H_
34#define DVD_HARDWARE_VIDEO_GFX_DEVICE_H_
35
36#include "config.h"
37
38#include "ClipPlanes.h"
39#include "GFXShaderData.h"
40#include "Pipeline.h"
41#include "Commands.h"
42#include "PushConstants.h"
43#include "RenderAPIWrapper.h"
44#include "RenderStagePass.h"
46
58
59namespace Divide
60{
61
62struct RenderPassParams;
63
64enum class SceneNodeType : U16;
65enum class WindowEvent : U8;
66
67class GUI;
68class GUIText;
69class SceneGUIElements;
70
71class Light;
72class Camera;
73class Quad3D;
74class Texture;
75class Object3D;
76class GFXRTPool;
77class ShadowMap;
78class IMPrimitive;
79class WindowManager;
80class ResourceCache;
81class SceneGraphNode;
82class ProjectManager;
83class SceneShaderData;
84class SceneRenderState;
85class KernelApplication;
86class ShaderComputeQueue;
87class CascadedShadowMapsGenerator;
88
89struct SizeChangeParams;
90struct ShaderBufferDescriptor;
91
92enum class ShadowType : U8;
93
95
96namespace Time
97{
98 class ProfileTimer;
99};
100
101namespace Attorney
102{
103 class GFXDeviceAPI;
104 class GFXDeviceKernel;
105 class GFXDeviceGraphicsResource;
106 class GFXDeviceGFXRTPool;
107 class GFXDeviceProjectManager;
108 class GFXDeviceShaderProgram;
109 class GFXDeviceShadowMap;
110 class GFXDeviceWindowManager;
111 class KernelApplication;
112};
113
114namespace TypeUtil
115{
116 [[nodiscard]] const char* GraphicResourceTypeToName(GraphicsResource::Type type) noexcept;
117
118 [[nodiscard]] const char* RenderStageToString(RenderStage stage) noexcept;
119 [[nodiscard]] RenderStage StringToRenderStage(const char* stage) noexcept;
120
121 [[nodiscard]] const char* RenderPassTypeToString(RenderPassType pass) noexcept;
122 [[nodiscard]] RenderPassType StringToRenderPassType(const char* pass) noexcept;
123};
124
125struct DebugView final : GUIDWrapper
126{
127 DebugView() noexcept
128 : DebugView(-1)
129 {
130 }
131
132 explicit DebugView(const I16 sortIndex) noexcept
133 : GUIDWrapper()
134 , _sortIndex(to_I16(sortIndex))
135 {
136 }
137
139 string _name;
140 Handle<ShaderProgram> _shader = INVALID_HANDLE<ShaderProgram>;
141 Handle<Texture> _texture = INVALID_HANDLE<Texture>;
146 bool _enabled = false;
147 bool _cycleMips = false;
148};
149
151
152template<typename Descriptor, size_t N>
154{
155 static constexpr U8 g_maxFrameLifetime = 6u;
156
158 {
159 Descriptor _descriptor;
160 I64 _id = 0u;
162 };
163
164 DebugPrimitiveHandler() noexcept;
165
167
168 [[nodiscard]] size_t size() const noexcept;
169
170 void reset();
171 void add(const I64 ID, const Descriptor& data) noexcept;
172 void addLocked(const I64 ID, const Descriptor& data) noexcept;
173
175 eastl::fixed_vector<IMPrimitive*, N, true> _debugPrimitives;
176 eastl::fixed_vector<DataEntry, N, true> _debugData;
177};
178
180{
181 explicit ImShaders();
182 ~ImShaders();
183
184 PROPERTY_R_IW( Handle<ShaderProgram>, imShader, INVALID_HANDLE<ShaderProgram> );
185 PROPERTY_R_IW( Handle<ShaderProgram>, imShaderNoTexture, INVALID_HANDLE<ShaderProgram> );
186 PROPERTY_R_IW( Handle<ShaderProgram>, imWorldShader, INVALID_HANDLE<ShaderProgram> );
187 PROPERTY_R_IW( Handle<ShaderProgram>, imWorldShaderNoTexture, INVALID_HANDLE<ShaderProgram> );
188 PROPERTY_R_IW( Handle<ShaderProgram>, imWorldOITShader, INVALID_HANDLE<ShaderProgram> );
189 PROPERTY_R_IW( Handle<ShaderProgram>, imWorldOITShaderNoTexture, INVALID_HANDLE<ShaderProgram> );
190};
191
193
195{
208
209 static std::array<RenderTargetID, Config::MAX_REFLECTIVE_NODES_IN_VIEW> REFLECTION_PLANAR;
210 static std::array<RenderTargetID, Config::MAX_REFRACTIVE_NODES_IN_VIEW> REFRACTION_PLANAR;
211};
212
215{
216 friend class Attorney::GFXDeviceAPI;
220 friend class Attorney::GFXDeviceShaderProgram;
224
225public:
227 {
228 constexpr static RTColourAttachmentSlot ALBEDO = RTColourAttachmentSlot::SLOT_0;
229 constexpr static RTColourAttachmentSlot VELOCITY = RTColourAttachmentSlot::SLOT_1;
230 constexpr static RTColourAttachmentSlot NORMALS = RTColourAttachmentSlot::SLOT_2;
231 constexpr static RTColourAttachmentSlot MODULATE = RTColourAttachmentSlot::SLOT_3;
232 constexpr static RTColourAttachmentSlot ACCUMULATION = ALBEDO;
233 constexpr static RTColourAttachmentSlot REVEALAGE = VELOCITY;
234 };
235
237 {
239 PROPERTY_RW(bool, dirty, true);
240
241 void clear();
242 void update(DescriptorSetUsage usage, const DescriptorSet& newBindingData);
243 void update(DescriptorSetUsage usage, const DescriptorSetBinding& newBindingData);
244 };
245
246 using GFXDescriptorSets = std::array<GFXDescriptorSet, to_base(DescriptorSetUsage::COUNT)>;
247
248public: // GPU interface
249 explicit GFXDevice( PlatformContext& context );
250 ~GFXDevice() override;
251
252 ErrorCode initRenderingAPI(I32 argc, char** argv, RenderAPI API);
253 ErrorCode postInitRenderingAPI(vec2<U16> renderResolution);
254 void closeRenderingAPI();
255
256 void idle(bool fast, U64 deltaTimeUSGame, U64 deltaTimeUSApp);
257
258 void flushCommandBuffer(Handle<GFX::CommandBuffer>&& commandBuffer);
259
260 void debugDraw( const SceneRenderState& sceneRenderState, GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut );
261 void debugDrawLines(const I64 ID, IM::LineDescriptor descriptor) noexcept;
262 void debugDrawBox(const I64 ID, IM::BoxDescriptor descriptor) noexcept;
263 void debugDrawOBB(const I64 ID, IM::OBBDescriptor descriptor) noexcept;
264 void debugDrawSphere(const I64 ID, IM::SphereDescriptor descriptor) noexcept;
265 void debugDrawCone(const I64 ID, IM::ConeDescriptor descriptor) noexcept;
266 void debugDrawFrustum(const I64 ID, IM::FrustumDescriptor descriptor) noexcept;
267 void validateAndUploadDescriptorSets();
271 void generateCubeMap(RenderPassParams& params,
272 U16 arrayOffset,
273 const vec3<F32>& pos,
274 vec2<F32> zPlanes,
275 GFX::CommandBuffer& commandsInOut,
276 GFX::MemoryBarrierCommand& memCmdInOut,
277 mat4<F32>* viewProjectionOut = nullptr);
278
279 void generateDualParaboloidMap(RenderPassParams& params,
280 U16 arrayOffset,
281 const vec3<F32>& pos,
282 vec2<F32> zPlanes,
283 GFX::CommandBuffer& bufferInOut,
284 GFX::MemoryBarrierCommand& memCmdInOut,
285 mat4<F32>* viewProjectionOut = nullptr);
286
287 const GFXShaderData::CamData& cameraData() const noexcept;
288 const GFXShaderData::PrevFrameData& previousFrameData( PlayerIndex player ) const noexcept;
289
291 bool setViewport(const Rect<I32>& viewport);
292 bool setViewport( I32 x, I32 y, I32 width, I32 height );
293 bool setScissor(const Rect<I32>& scissor);
294 bool setScissor( I32 x, I32 y, I32 width, I32 height );
295 void setDepthRange(vec2<F32> depthRange);
296 void setPreviousViewProjectionMatrix( PlayerIndex player, const mat4<F32>& prevViewMatrix, const mat4<F32> prevProjectionMatrix );
297
298 void setCameraSnapshot(PlayerIndex index, const CameraSnapshot& snapshot) noexcept;
299 CameraSnapshot& getCameraSnapshot(PlayerIndex index) noexcept;
300 const CameraSnapshot& getCameraSnapshot(PlayerIndex index) const noexcept;
301
302 F32 renderingAspectRatio() const noexcept;
303 vec2<U16> renderingResolution() const noexcept;
304
305 void setScreenMSAASampleCount(U8 sampleCount);
306 void setShadowMSAASampleCount(ShadowType type, U8 sampleCount);
307
309 void screenshot(std::string_view fileName, GFX::CommandBuffer& bufferInOut ) const;
310
311 ShaderComputeQueue& shaderComputeQueue() noexcept;
312 const ShaderComputeQueue& shaderComputeQueue() const noexcept;
313
314public: // Accessors and Mutators
315
316 [[nodiscard]] Renderer& getRenderer() const;
318 [[nodiscard]] const RenderStateBlock& getNoDepthTestBlock() const noexcept;
319 [[nodiscard]] const RenderStateBlock& get2DStateBlock() const noexcept;
320 [[nodiscard]] GFXRTPool& renderTargetPool() noexcept;
321 [[nodiscard]] const GFXRTPool& renderTargetPool() const noexcept;
322 [[nodiscard]] Handle<ShaderProgram> getRTPreviewShader(bool depthOnly) const noexcept;
323 void registerDrawCall() noexcept;
324 void registerDrawCalls(U32 count) noexcept;
325
326 DebugView* addDebugView(const std::shared_ptr<DebugView>& view);
327 bool removeDebugView(DebugView* view);
328 void toggleDebugView(I16 index, bool state);
329 void toggleDebugGroup(I16 groupID, bool state);
330 void getDebugViewNames(vector<std::tuple<string, I16, I16, bool>>& namesOut);
331 [[nodiscard]] bool getDebugGroupState(I16 groupID) const;
332
333 [[nodiscard]] PerformanceMetrics& getPerformanceMetrics() noexcept;
334 [[nodiscard]] const PerformanceMetrics& getPerformanceMetrics() const noexcept;
335
336 void onThreadCreated(const std::thread::id& threadID, bool isMainRenderThread) const;
337
338 static void FrameInterpolationFactor(const D64 interpolation) noexcept { s_interpolationFactor = interpolation; }
339 [[nodiscard]] static D64 FrameInterpolationFactor() noexcept { return s_interpolationFactor; }
340 [[nodiscard]] static U64 FrameCount() noexcept { return s_frameCount; }
341
342 static const DeviceInformation& GetDeviceInformation() noexcept;
343 static void OverrideDeviceInformation(const DeviceInformation& info) noexcept;
344
345 [[nodiscard]] static bool IsSubmitCommand(GFX::CommandType type) noexcept;
346
347public:
349 [[nodiscard]] RenderTarget_uptr newRT( const RenderTargetDescriptor& descriptor );
350
352 [[nodiscard]] IMPrimitive* newIMP( std::string_view name);
353 [[nodiscard]] bool destroyIMP(IMPrimitive*& primitive);
354
356 [[nodiscard]] VertexBuffer_ptr newVB( const VertexBuffer::Descriptor& descriptor );
357
358 [[nodiscard]] GenericVertexData_ptr newGVD(U32 ringBufferLength, std::string_view name);
359
363 [[nodiscard]] ShaderBuffer_uptr newSB(const ShaderBufferDescriptor& descriptor);
365 [[nodiscard]] Pipeline* newPipeline(const PipelineDescriptor& descriptor);
366
367 // Render the texture using a custom viewport
368 void drawTextureInViewport(const ImageView& texture, SamplerDescriptor sampler, const Rect<I32>& viewport, bool convertToSrgb, bool drawToDepthOnly, bool drawBlend, GFX::CommandBuffer& bufferInOut);
369
370 void blurTarget(RenderTargetHandle& blurSource,
371 RenderTargetHandle& blurBuffer,
372 const RenderTargetHandle& blurTarget,
375 I32 kernelSize,
376 bool gaussian,
377 U8 layerCount,
378 GFX::CommandBuffer& bufferInOut);
379
380 void updateSceneDescriptorSet(GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut ) const;
381
382 [[nodiscard]] GFXDescriptorSet& descriptorSet(DescriptorSetUsage usage) noexcept;
383 [[nodiscard]] const GFXDescriptorSet& descriptorSet(DescriptorSetUsage usage) const noexcept;
384
386 PROPERTY_RW(RenderAPI, renderAPI, RenderAPI::COUNT);
387 PROPERTY_RW(bool, queryPerformanceStats, false);
388 PROPERTY_RW(bool, enableOcclusionCulling, true);
389 PROPERTY_R_IW(U32, frameDrawCalls, 0u);
390 PROPERTY_R_IW(U32, frameDrawCallsPrev, 0u);
391 PROPERTY_R_IW(vec4<U32>, lastCullCount, VECTOR4_ZERO);
392 PROPERTY_R_IW(Rect<I32>, activeViewport, UNIT_VIEWPORT);
393 PROPERTY_R_IW(Rect<I32>, activeScissor, UNIT_VIEWPORT);
394 PROPERTY_R(std::unique_ptr<SceneShaderData>, sceneData);
395 PROPERTY_R(ImShaders_uptr, imShaders);
396
397 [[nodiscard]] bool framePreRender( const FrameEvent& evt ) override;
398 [[nodiscard]] bool frameStarted( const FrameEvent& evt ) override;
399 [[nodiscard]] bool frameEnded( const FrameEvent& evt ) noexcept override;
400
401protected:
402
403 void update(U64 deltaTimeUSFixed, U64 deltaTimeUSApp);
404
405 [[nodiscard]] ErrorCode initDescriptorSets();
406
407 void setScreenMSAASampleCountInternal(U8 sampleCount);
408 void setShadowMSAASampleCountInternal(ShadowType type, U8 sampleCount);
409
410 // returns true if the window and the viewport have different aspect ratios
411 [[nodiscard]] bool fitViewportInWindow(U16 w, U16 h);
412
413 void drawToWindow( DisplayWindow& window );
414 void flushWindow( DisplayWindow& window );
415
416 void onWindowSizeChange(const SizeChangeParams& params);
417 void onResolutionChange(const SizeChangeParams& params);
418
419 void initDebugViews();
420 void renderDebugViews(Rect<I32> targetViewport, I32 padding, GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut );
421
422 void flushCommandBufferInternal(Handle<GFX::CommandBuffer> commandBuffer);
423
424 [[nodiscard]] PipelineDescriptor& getDebugPipeline(const IM::BaseDescriptor& descriptor) noexcept;
425 void debugDrawLines( GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut);
426 void debugDrawBoxes( GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut );
427 void debugDrawOBBs( GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut );
428 void debugDrawCones( GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut );
429 void debugDrawSpheres( GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut );
430 void debugDrawFrustums( GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut );
431
432protected:
433 friend class RenderPassManager;
434 void renderDebugUI(const Rect<I32>& targetViewport, GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut );
435
436protected:
437 friend class RenderPass;
438 friend class RenderPassExecutor;
439
440 void occlusionCull(const RenderPass::PassData& passData,
441 Handle<Texture> hizBuffer,
442 SamplerDescriptor sampler,
443 const CameraSnapshot& cameraSnapshot,
444 bool countCulledNodes,
445 GFX::CommandBuffer& bufferInOut);
446
447 // Returns the HiZ texture that can be sent directly to occlusionCull
448 std::pair<Handle<Texture>, SamplerDescriptor> constructHIZ(RenderTargetID depthBuffer, RenderTargetID HiZTarget, GFX::CommandBuffer& cmdBufferInOut);
449
450 [[nodiscard]] RenderAPIWrapper& getAPIImpl() { return *_api; }
451 [[nodiscard]] const RenderAPIWrapper& getAPIImpl() const { return *_api; }
452
453private:
455 [[nodiscard]] bool uploadGPUBlock();
456 void resizeGPUBlocks(size_t targetSizeCam, size_t targetSizeCullCounter);
457 void setClipPlanes(const FrustumClipPlanes& clipPlanes);
458 void renderFromCamera(const CameraSnapshot& cameraSnapshot);
459 void shadowingSettings(const F32 lightBleedBias, const F32 minShadowVariance) noexcept;
460 void worldAOViewProjectionMatrix(const mat4<F32>& vpMatrix) noexcept;
461
462 [[nodiscard]] ErrorCode createAPIInstance(RenderAPI api);
463
464 void renderThread();
465 void addRenderWork(DELEGATE<void>&& work);
466
467private:
468 RenderAPIWrapper_uptr _api;
469 Renderer_uptr _renderer;
470
471 std::unique_ptr<ShaderComputeQueue> _shaderComputeQueue;
472
479
481
482 std::unique_ptr<GFXRTPool> _rtPool;
483
484 static constexpr U8 s_invalidQueueSampleCount = 255u;
485 U8 _queuedScreenSampleChange = s_invalidQueueSampleCount;
486 std::array<U8, to_base(ShadowType::COUNT)> _queuedShadowSampleChange;
488 RenderStateBlock _defaultStateNoDepthTest{};
490 RenderStateBlock _state2DRendering{};
491 RenderStateBlock _stateDepthOnlyRendering{};
494
496 Handle<ShaderProgram> _previewDepthMapShader = INVALID_HANDLE<ShaderProgram>;
497 Handle<ShaderProgram> _previewRenderTargetColour = INVALID_HANDLE<ShaderProgram>;
498 Handle<ShaderProgram> _previewRenderTargetDepth = INVALID_HANDLE<ShaderProgram>;
499 Handle<ShaderProgram> _renderTargetDraw = INVALID_HANDLE<ShaderProgram>;
500 Handle<ShaderProgram> _hIZConstructProgram = INVALID_HANDLE<ShaderProgram>;
501 Handle<ShaderProgram> _hIZCullProgram = INVALID_HANDLE<ShaderProgram>;
502 Handle<ShaderProgram> _displayShader = INVALID_HANDLE<ShaderProgram>;
503 Handle<ShaderProgram> _depthShader = INVALID_HANDLE<ShaderProgram>;
504 Handle<ShaderProgram> _blurBoxShaderSingle = INVALID_HANDLE<ShaderProgram>;
505 Handle<ShaderProgram> _blurBoxShaderLayered = INVALID_HANDLE<ShaderProgram>;
506 Handle<ShaderProgram> _blurGaussianShaderSingle = INVALID_HANDLE<ShaderProgram>;
507 Handle<ShaderProgram> _blurGaussianShaderLayered = INVALID_HANDLE<ShaderProgram>;
508
509
510 Pipeline* _hIZPipeline = nullptr;
511 Pipeline* _hIZCullPipeline = nullptr;
523
527
530
533
535
537 {
538 static constexpr U8 PER_FRAME_BUFFER_COUNT = 3u;
539
541 {
543 ShaderBuffer_uptr _camDataBuffer = nullptr;
544 ShaderBuffer_uptr _cullCounter = nullptr;
545 size_t _camWritesThisFrame = 0u;
546 size_t _renderWritesThisFrame = 0u;
547 } _perFrameBuffers[PER_FRAME_BUFFER_COUNT];
548
549 size_t _perFrameBufferIndex = 0u;
550 bool _needsResizeCam = false;
551 [[nodiscard]] inline PerFrameBuffers& crtBuffers() noexcept;
552
553 [[nodiscard]] inline const PerFrameBuffers& crtBuffers() const noexcept;
554
555 inline void reset(const bool camBuffer, const bool cullBuffer) noexcept;
556
557 inline void onEndFrame() noexcept;
558
559 } _gfxBuffers;
560
561 Mutex _pipelineCacheLock;
562 hashMap<size_t, Pipeline, NoHash<size_t>> _pipelineCache;
563
564 static constexpr U8 MAX_CAMERA_SNAPSHOTS = 32u;
565 std::stack<CameraSnapshot, eastl::fixed_vector<CameraSnapshot, MAX_CAMERA_SNAPSHOTS, false>> _cameraSnapshots;
566
567 std::array<CameraSnapshot, Config::MAX_LOCAL_PLAYER_COUNT> _cameraSnapshotHistory;
568
569 std::stack<Rect<I32>> _viewportStack;
570 Mutex _imprimitiveMutex;
571
572 PerformanceMetrics _performanceMetrics{};
573
574 using IMPrimitivePool = MemoryPool<IMPrimitive, 1 << 15>;
576
579
581};
582
583namespace Attorney
584{
586 {
587 static void onWindowSizeChange(GFXDevice& device, const SizeChangeParams& params)
588 {
589 device.onWindowSizeChange(params);
590 }
591
592 static void onResolutionChange(GFXDevice& device, const SizeChangeParams& params)
593 {
594 device.onResolutionChange(params);
595 }
596
597 static void update(GFXDevice& device, const U64 deltaTimeUSFixed, const U64 deltaTimeUSApp)
598 {
599 device.update(deltaTimeUSFixed, deltaTimeUSApp);
600 }
601
602 friend class Divide::Kernel;
603 friend class Divide::KernelApplication;
604 };
605
607 {
608 static void onResourceCreate(GFXDevice& device, GraphicsResource::Type type, I64 GUID, U64 nameHash)
609 {
611 device._graphicResources.emplace_back(type, GUID, nameHash);
612 }
613
614 static void onResourceDestroy(GFXDevice& device, GraphicsResource::Type type, I64 GUID, U64 nameHash)
615 {
617 const bool success = dvd_erase_if(device._graphicResources,
618 [type, GUID, nameHash](const auto& crtEntry) noexcept -> bool {
619 if (std::get<1>(crtEntry) != GUID)
620 {
621 return false;
622 }
623
624 DIVIDE_ASSERT(std::get<0>(crtEntry) == type && std::get<2>(crtEntry) == nameHash);
625 return true;
626 });
627 DIVIDE_ASSERT(success);
628
629 }
630
632 };
633
635 {
636 static RenderTarget_uptr newRT(GFXDevice& device, const RenderTargetDescriptor& descriptor)
637 {
638 return device.newRT(descriptor);
639 }
640
641 friend class Divide::GFXRTPool;
642 };
643
645 {
646 static void shadowingSettings(GFXDevice& device, const F32 lightBleedBias, const F32 minShadowVariance) noexcept
647 {
648 device.shadowingSettings(lightBleedBias, minShadowVariance);
649 }
650
652 };
653
655 {
656 static void worldAOViewProjectionMatrix( GFXDevice& device, const mat4<F32>& vpMatrix ) noexcept
657 {
658 device.worldAOViewProjectionMatrix( vpMatrix );
659 }
660
661 friend class Divide::ShadowMap;
663 };
664
666 {
667 static void drawToWindow( GFXDevice& device, DisplayWindow& window )
668 {
669 device.drawToWindow( window );
670 }
671 static void flushWindow( GFXDevice& device, DisplayWindow& window )
672 {
673 device.flushWindow( window );
674 }
675
678 };
679
680}; // namespace Attorney
681}; // namespace Divide
682
683#include "GFXDevice.inl"
684
685#endif //DVD_HARDWARE_VIDEO_GFX_DEVICE_H_
#define PROPERTY_RW(...)
Convenience method to add a class member with public read access and write access.
#define PROPERTY_R(...)
Convenience method to add a class member with public read access but protected write access.
#define PROPERTY_R_IW(...)
Convenience method to add a class member with public read access but protected write access including...
#define FWD_DECLARE_MANAGED_STRUCT(T)
#define DIVIDE_ASSERT(...)
#define FWD_DECLARE_MANAGED_CLASS(T)
char * argv[]
Definition: main.cpp:8
static RenderTarget_uptr newRT(GFXDevice &device, const RenderTargetDescriptor &descriptor)
Definition: GFXDevice.h:636
static void onResourceDestroy(GFXDevice &device, GraphicsResource::Type type, I64 GUID, U64 nameHash)
Definition: GFXDevice.h:614
static void onResourceCreate(GFXDevice &device, GraphicsResource::Type type, I64 GUID, U64 nameHash)
Definition: GFXDevice.h:608
static void onWindowSizeChange(GFXDevice &device, const SizeChangeParams &params)
Definition: GFXDevice.h:587
static void update(GFXDevice &device, const U64 deltaTimeUSFixed, const U64 deltaTimeUSApp)
Definition: GFXDevice.h:597
static void onResolutionChange(GFXDevice &device, const SizeChangeParams &params)
Definition: GFXDevice.h:592
static void shadowingSettings(GFXDevice &device, const F32 lightBleedBias, const F32 minShadowVariance) noexcept
Definition: GFXDevice.h:646
static void worldAOViewProjectionMatrix(GFXDevice &device, const mat4< F32 > &vpMatrix) noexcept
Definition: GFXDevice.h:656
static void drawToWindow(GFXDevice &device, DisplayWindow &window)
Definition: GFXDevice.h:667
static void flushWindow(GFXDevice &device, DisplayWindow &window)
Definition: GFXDevice.h:671
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
Definition: GFXDevice.h:215
Mutex _graphicsResourceMutex
Definition: GFXDevice.h:525
GFX::BindPipelineCommand _blurBoxPipelineLayeredCmd
Definition: GFXDevice.h:520
GFXDescriptorSets _descriptorSets
Definition: GFXDevice.h:524
std::array< U8, to_base(ShadowType::COUNT)> _queuedShadowSampleChange
Definition: GFXDevice.h:486
GFX::BindPipelineCommand _blurGaussianPipelineLayeredCmd
Definition: GFXDevice.h:522
DebugPrimitiveHandler< IM::BoxDescriptor, 16u > _debugBoxes
Definition: GFXDevice.h:474
static IMPrimitivePool s_IMPrimitivePool
Definition: GFXDevice.h:575
void onResolutionChange(const SizeChangeParams &params)
Definition: GFXDevice.cpp:1776
static DeviceInformation s_deviceInformation
Definition: GFXDevice.h:580
static D64 FrameInterpolationFactor() noexcept
Definition: GFXDevice.h:339
GFX::BindPipelineCommand _drawFSTexturePipelineBlendCmd
Definition: GFXDevice.h:517
GFX::BindPipelineCommand _drawFSDepthPipelineCmd
Definition: GFXDevice.h:518
DebugPrimitiveHandler< IM::ConeDescriptor, 16u > _debugCones
Definition: GFXDevice.h:477
void update(U64 deltaTimeUSFixed, U64 deltaTimeUSApp)
Definition: GFXDevice.cpp:1331
GFX::BindPipelineCommand _blurBoxPipelineSingleCmd
Definition: GFXDevice.h:519
RenderTarget_uptr newRT(const RenderTargetDescriptor &descriptor)
Create and return a new framebuffer.
Definition: GFXDevice.cpp:3041
vector< DebugView_ptr > _debugViews
Definition: GFXDevice.h:532
PipelineDescriptor _debugGizmoPipelineNoCull
Definition: GFXDevice.h:514
PipelineDescriptor _debugGizmoPipeline
Definition: GFXDevice.h:512
PipelineDescriptor _debugGizmoPipelineNoCullNoDepth
Definition: GFXDevice.h:515
GFXShaderData _gpuBlock
Definition: GFXDevice.h:529
DebugPrimitiveHandler< IM::FrustumDescriptor, 8u > _debugFrustums
Definition: GFXDevice.h:478
void onWindowSizeChange(const SizeChangeParams &params)
The main entry point for any resolution change request.
Definition: GFXDevice.cpp:1768
std::array< GFXDescriptorSet, to_base(DescriptorSetUsage::COUNT)> GFXDescriptorSets
Definition: GFXDevice.h:246
RenderAPIWrapper_uptr _api
Definition: GFXDevice.h:468
MemoryPool< IMPrimitive, 1<< 15 > IMPrimitivePool
Definition: GFXDevice.h:574
FrustumClipPlanes _clippingPlanes
The interpolation factor between the current and the last frame.
Definition: GFXDevice.h:493
std::unique_ptr< ShaderComputeQueue > _shaderComputeQueue
Definition: GFXDevice.h:471
GFX::BindPipelineCommand _blurGaussianPipelineSingleCmd
Definition: GFXDevice.h:521
Renderer_uptr _renderer
Definition: GFXDevice.h:469
Mutex _queuedCommandbufferLock
Definition: GFXDevice.h:534
CameraSnapshot _activeCameraSnapshot
Definition: GFXDevice.h:480
DebugPrimitiveHandler< IM::SphereDescriptor, 16u > _debugSpheres
Definition: GFXDevice.h:476
void drawToWindow(DisplayWindow &window)
Definition: GFXDevice.cpp:1336
PipelineDescriptor _debugGizmoPipelineNoDepth
Definition: GFXDevice.h:513
GFX::BindPipelineCommand _drawFSTexturePipelineCmd
Definition: GFXDevice.h:516
const RenderAPIWrapper & getAPIImpl() const
Definition: GFXDevice.h:451
void flushWindow(DisplayWindow &window)
Definition: GFXDevice.cpp:1345
static U64 FrameCount() noexcept
Definition: GFXDevice.h:340
static U64 s_frameCount
Definition: GFXDevice.h:578
std::unique_ptr< GFXRTPool > _rtPool
Definition: GFXDevice.h:482
DebugPrimitiveHandler< IM::LineDescriptor, 16u > _debugLines
Definition: GFXDevice.h:473
Mutex _debugViewLock
Definition: GFXDevice.h:531
DebugPrimitiveHandler< IM::OBBDescriptor, 16u > _debugOBBs
Definition: GFXDevice.h:475
vector< std::tuple< GraphicsResource::Type, I64, U64 > > _graphicResources
Definition: GFXDevice.h:526
static D64 s_interpolationFactor
Definition: GFXDevice.h:577
vec2< U16 > _renderingResolution
Definition: GFXDevice.h:528
Utility class that adds basic GUID management to objects.
Definition: GUIDWrapper.h:44
GUIDWrapper() noexcept
Definition: GUIDWrapper.h:46
IMPrimitive replaces immediate mode calls to VB based rendering.
Definition: IMPrimitive.h:58
The kernel is the main system that connects all of our various systems: windows, gfx,...
Definition: Kernel.h:81
Renderer Programming Interface.
TiledForwardShading.
Definition: Renderer.h:50
All the information needed for a single light's shadowmap.
Definition: ShadowMap.h:88
An API-independent representation of a texture.
Definition: Texture.h:83
const char * RenderPassTypeToString(const RenderPassType pass) noexcept
Definition: GFXDevice.cpp:72
RenderStage StringToRenderStage(const char *stage) noexcept
Definition: GFXDevice.cpp:59
const char * GraphicResourceTypeToName(const GraphicsResource::Type type) noexcept
Definition: GFXDevice.cpp:49
const char * RenderStageToString(const RenderStage stage) noexcept
Definition: GFXDevice.cpp:54
RenderPassType StringToRenderPassType(const char *pass) noexcept
Definition: GFXDevice.cpp:77
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
DELEGATE_STD< Ret, Args... > DELEGATE
std::lock_guard< mutex > LockGuard
Definition: SharedMutex.h:55
std::mutex Mutex
Definition: SharedMutex.h:40
int32_t I32
MaterialDebugFlag
Definition: MaterialEnums.h:37
uint8_t U8
int16_t I16
SceneNodeType
ToDo: Move particle emitter to components (it will make them way more dynamic) - Ionut.
Definition: SceneNodeFwd.h:47
RTAttachmentType
This enum is used when creating render targets to define the channel that the texture will attach to.
Definition: RTAttachment.h:47
eastl::vector< Type > vector
Definition: Vector.h:42
hashAlg::unordered_map< K, V, HashFun, Predicate > hashMap
Definition: HashMap.h:55
uint16_t U16
RTColourAttachmentSlot
constexpr I16 to_I16(const T value)
double D64
ShadowType
Definition: ShadowMap.h:40
void debugDraw(GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut) override
U32 RenderTargetID
DescriptorSetUsage
bool dvd_erase_if(eastl::vector< T, A > &vec, Predicate &&pred)
Definition: Vector.h:109
int64_t I64
uint32_t U32
uint64_t U64
constexpr auto to_base(const Type value) -> Type
Definition: GFXDevice.h:158
Descriptor _descriptor
Definition: GFXDevice.h:159
I64 _id
Definition: GFXDevice.h:160
U8 _frameLifeTime
Definition: GFXDevice.h:161
void addLocked(const I64 ID, const Descriptor &data) noexcept
Definition: GFXDevice.inl:84
eastl::fixed_vector< DataEntry, N, true > _debugData
Definition: GFXDevice.h:176
void add(const I64 ID, const Descriptor &data) noexcept
Definition: GFXDevice.inl:77
size_t size() const noexcept
Definition: GFXDevice.inl:55
eastl::fixed_vector< IMPrimitive *, N, true > _debugPrimitives
Definition: GFXDevice.h:175
static constexpr U8 g_maxFrameLifetime
Definition: GFXDevice.h:155
DebugView() noexcept
Definition: GFXDevice.h:127
SamplerDescriptor _sampler
Definition: GFXDevice.h:142
DebugView(const I16 sortIndex) noexcept
Definition: GFXDevice.h:132
UniformData _shaderData
Definition: GFXDevice.h:138
Handle< ShaderProgram > _shader
Definition: GFXDevice.h:140
Handle< Texture > _texture
Definition: GFXDevice.h:141
PROPERTY_RW(DescriptorSet, impl)
PROPERTY_R_IW(Handle< ShaderProgram >, imWorldOITShaderNoTexture, INVALID_HANDLE< ShaderProgram >)
PROPERTY_R_IW(Handle< ShaderProgram >, imWorldShader, INVALID_HANDLE< ShaderProgram >)
PROPERTY_R_IW(Handle< ShaderProgram >, imWorldShaderNoTexture, INVALID_HANDLE< ShaderProgram >)
PROPERTY_R_IW(Handle< ShaderProgram >, imShaderNoTexture, INVALID_HANDLE< ShaderProgram >)
PROPERTY_R_IW(Handle< ShaderProgram >, imWorldOITShader, INVALID_HANDLE< ShaderProgram >)
PROPERTY_R_IW(Handle< ShaderProgram >, imShader, INVALID_HANDLE< ShaderProgram >)
Queries are expensive, so this result MAY BE SEVERAL frames out of date!
static RenderTargetID HI_Z
Definition: GFXDevice.h:204
static RenderTargetID REFLECTION_PLANAR_BLUR
Definition: GFXDevice.h:206
static RenderTargetID OIT
Definition: GFXDevice.h:200
static RenderTargetID BACK_BUFFER
Definition: GFXDevice.h:196
static RenderTargetID NORMALS_RESOLVED
Definition: GFXDevice.h:199
static RenderTargetID OIT_REFLECT
Definition: GFXDevice.h:201
static RenderTargetID HI_Z_REFLECT
Definition: GFXDevice.h:205
static RenderTargetID SSAO_RESULT
Definition: GFXDevice.h:202
static RenderTargetID SCREEN
Definition: GFXDevice.h:197
static RenderTargetID SSR_RESULT
Definition: GFXDevice.h:203
static RenderTargetID REFLECTION_CUBE
Definition: GFXDevice.h:207
static std::array< RenderTargetID, Config::MAX_REFRACTIVE_NODES_IN_VIEW > REFRACTION_PLANAR
Definition: GFXDevice.h:210
static std::array< RenderTargetID, Config::MAX_REFLECTIVE_NODES_IN_VIEW > REFLECTION_PLANAR
Definition: GFXDevice.h:209
static RenderTargetID SCREEN_PREV
Definition: GFXDevice.h:198