libER 0.1.4.2
ELDEN RING API library
Loading...
Searching...
No Matches
draw.hpp
Go to the documentation of this file.
1
8#pragma once
9
10#include <coresystem/task.hpp>
12
13#include <utility>
14
15// D3D12 resource forward declarations
16struct ID3D12Device;
17struct ID3D12RootSignature;
18struct ID3D12CommandQueue;
19
20struct D3D12_VIEWPORT;
21struct D3D12_CPU_DESCRIPTOR_HANDLE;
22
23struct tagRECT;
24
26using D3D12_RECT = tagRECT;
27using HANDLE = void*;
29
30namespace from {
31namespace GXBS {
49public:
60 enum scene {
61 HDR_SCENE,
62 UI_SCENE
63 };
64
66
72 CS::CSEzTask::register_task(CS::CSTaskGroup::GraphicsStep);
73 }
74
83 virtual void draw() = 0;
84
90 scene get_scene() const noexcept {
91 return this->draw_scene;
92 }
93
99 void set_scene(scene new_scene) noexcept {
100 this->draw_scene = new_scene;
101 }
102
111 ID3D12Device& get_device() noexcept {
112 return *this->device;
113 }
114
120 ID3D12RootSignature& get_root_signature() noexcept {
121 return *this->root_signature;
122 }
123
129 ID3D12CommandQueue& get_command_queue() noexcept {
130 return *this->command_queue;
131 }
132
138 D3D12_CPU_DESCRIPTOR_HANDLE& get_render_target_view() noexcept {
139 return *this->render_target_view;
140 }
141
147 D3D12_CPU_DESCRIPTOR_HANDLE& get_depth_stencil_view() noexcept {
148 return *this->depth_stencil_view;
149 }
150
156 const D3D12_VIEWPORT& get_viewport() noexcept {
157 return *this->viewport;
158 }
159
165 const D3D12_RECT& get_scissor_rect() noexcept {
166 return *this->scissor_rect;
167 }
168
174 float get_delta_time() noexcept {
175 return this->delta_time;
176 }
177
183 int get_times_called() noexcept {
184 return this->times_called;
185 }
186
187private:
188 void ref_for_callback() noexcept {
189 if (!std::exchange(this->callback_referenced, true))
190 static_cast<DLUT::DLReferenceCountObject*>(this)->ref();
191 }
192
193 void unref_after_callback() noexcept {
194 if (std::exchange(this->callback_referenced, false))
195 static_cast<DLUT::DLReferenceCountObject*>(this)->unref();
196 }
197
198 LIBERAPI void eztask_execute(FD4::FD4TaskData* data) override final;
199
200 friend bool liber_draw_callback(uintptr_t device_context, GXDrawTask* task);
201
202 ID3D12Device* device = nullptr;
203 ID3D12RootSignature* root_signature = nullptr;
204 ID3D12CommandQueue* command_queue = nullptr;
205 D3D12_CPU_DESCRIPTOR_HANDLE* render_target_view = nullptr;
206 D3D12_CPU_DESCRIPTOR_HANDLE* depth_stencil_view = nullptr;
207 D3D12_VIEWPORT* viewport = nullptr;
208 D3D12_RECT* scissor_rect = nullptr;
209 scene draw_scene = HDR_SCENE;
210 bool callback_referenced = false;
211 float delta_time = 0.0f;
212 int times_called = 0;
213};
214} // namespace GXBS
215} // namespace from
Inherit from this minimal task interface to create a custom task.
Definition task.hpp:51
virtual LIBERAPI void register_task(CSTaskGroup task_group)
Register a task to be called in a specified task group.
Class for implementing reference counting garbage collection.
Definition utility.hpp:47
void ref() noexcept
Increment the object's reference count.
Definition utility.hpp:75
void unref()
Unreference object; there cannot be more ref() calls than unref() calls.
Definition utility.hpp:86
Abstract graphics draw task base.
Definition draw.hpp:48
scene get_scene() const noexcept
Get the scene, which selects the layer to draw on.
Definition draw.hpp:90
virtual void draw()=0
The abstract method that is called whenever the task executes after being registered by from::GXBS::G...
void set_scene(scene new_scene) noexcept
Set the scene object, which selects the layer to draw on.
Definition draw.hpp:99
int get_times_called() noexcept
Get how many times this draw task has been called.
Definition draw.hpp:183
scene
Whether the task should draw on top of the UI.
Definition draw.hpp:60
const D3D12_VIEWPORT & get_viewport() noexcept
Get the current viewport dimensions.
Definition draw.hpp:156
D3D12_CPU_DESCRIPTOR_HANDLE & get_render_target_view() noexcept
Get the render target view handle.
Definition draw.hpp:138
D3D12_CPU_DESCRIPTOR_HANDLE & get_depth_stencil_view() noexcept
Get the depth stencil view handle.
Definition draw.hpp:147
ID3D12CommandQueue & get_command_queue() noexcept
Get the ID3D12CommandQueue interface.
Definition draw.hpp:129
ID3D12RootSignature & get_root_signature() noexcept
Get the ID3D12RootSignature interface.
Definition draw.hpp:120
void register_task()
Register the draw task, i.e. start its execution.
Definition draw.hpp:71
float get_delta_time() noexcept
Get the delta time of this frame.
Definition draw.hpp:174
ID3D12Device & get_device() noexcept
Get the ID3D12Device interface.
Definition draw.hpp:111
const D3D12_RECT & get_scissor_rect() noexcept
Get the scissor rect dimensions.
Definition draw.hpp:165
Namespace CS task interface.
Dantelion2 utility.