Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/drivers/d3d12/rendering_device_driver_d3d12.h
21436 views
1
/**************************************************************************/
2
/* rendering_device_driver_d3d12.h */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#pragma once
32
33
#include "core/templates/a_hash_map.h"
34
#include "core/templates/hash_map.h"
35
#include "core/templates/paged_allocator.h"
36
#include "core/templates/rb_map.h"
37
#include "core/templates/self_list.h"
38
#include "rendering_shader_container_d3d12.h"
39
#include "servers/rendering/rendering_device_driver.h"
40
41
#if !defined(_MSC_VER) && !defined(__REQUIRED_RPCNDR_H_VERSION__)
42
// Match current version used by MinGW, MSVC and Direct3D 12 headers use 500.
43
#define __REQUIRED_RPCNDR_H_VERSION__ 475
44
#endif // !defined(_MSC_VER) && !defined(__REQUIRED_RPCNDR_H_VERSION__)
45
46
GODOT_GCC_WARNING_PUSH
47
GODOT_GCC_WARNING_IGNORE("-Wimplicit-fallthrough")
48
GODOT_GCC_WARNING_IGNORE("-Wmissing-field-initializers")
49
GODOT_GCC_WARNING_IGNORE("-Wnon-virtual-dtor")
50
GODOT_GCC_WARNING_IGNORE("-Wshadow")
51
GODOT_GCC_WARNING_IGNORE("-Wswitch")
52
GODOT_CLANG_WARNING_PUSH
53
GODOT_CLANG_WARNING_IGNORE("-Wimplicit-fallthrough")
54
GODOT_CLANG_WARNING_IGNORE("-Wmissing-field-initializers")
55
GODOT_CLANG_WARNING_IGNORE("-Wnon-virtual-dtor")
56
GODOT_CLANG_WARNING_IGNORE("-Wstring-plus-int")
57
GODOT_CLANG_WARNING_IGNORE("-Wswitch")
58
59
#include <thirdparty/directx_headers/include/directx/d3dx12.h>
60
61
GODOT_GCC_WARNING_POP
62
GODOT_CLANG_WARNING_POP
63
64
#include <wrl/client.h>
65
66
#ifdef DEV_ENABLED
67
#define CUSTOM_INFO_QUEUE_ENABLED 0
68
#endif
69
70
class RenderingContextDriverD3D12;
71
72
namespace D3D12MA {
73
class Allocation;
74
class Allocator;
75
class VirtualBlock;
76
}; // namespace D3D12MA
77
78
struct IDXGIAdapter;
79
struct IDXGISwapChain3;
80
81
// Design principles:
82
// - D3D12 structs are zero-initialized and fields not requiring a non-zero value are omitted (except in cases where expresivity reasons apply).
83
class RenderingDeviceDriverD3D12 : public RenderingDeviceDriver {
84
/*****************/
85
/**** GENERIC ****/
86
/*****************/
87
88
struct D3D12Format {
89
DXGI_FORMAT family = DXGI_FORMAT_UNKNOWN;
90
DXGI_FORMAT general_format = DXGI_FORMAT_UNKNOWN;
91
UINT swizzle = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
92
DXGI_FORMAT dsv_format = DXGI_FORMAT_UNKNOWN;
93
};
94
95
static const D3D12Format RD_TO_D3D12_FORMAT[RDD::DATA_FORMAT_MAX];
96
97
struct DeviceLimits {
98
uint64_t max_srvs_per_shader_stage = 0;
99
uint64_t max_cbvs_per_shader_stage = 0;
100
uint64_t max_samplers_across_all_stages = 0;
101
uint64_t max_uavs_across_all_stages = 0;
102
uint64_t timestamp_frequency = 0;
103
};
104
105
struct SubgroupCapabilities {
106
uint32_t size = 0;
107
bool wave_ops_supported = false;
108
uint32_t supported_stages_flags_rd() const;
109
uint32_t supported_operations_flags_rd() const;
110
};
111
112
struct ShaderCapabilities {
113
D3D_SHADER_MODEL shader_model = (D3D_SHADER_MODEL)0;
114
bool native_16bit_ops = false;
115
};
116
117
struct FormatCapabilities {
118
bool relaxed_casting_supported = false;
119
};
120
121
struct BarrierCapabilities {
122
bool enhanced_barriers_supported = false;
123
};
124
125
struct MiscFeaturesSupport {
126
bool depth_bounds_supported = false;
127
};
128
129
struct SamplerCapabilities {
130
bool aniso_filter_with_point_mip_supported = false;
131
};
132
133
RenderingContextDriverD3D12 *context_driver = nullptr;
134
RenderingContextDriver::Device context_device;
135
Microsoft::WRL::ComPtr<IDXGIAdapter> adapter;
136
Microsoft::WRL::ComPtr<ID3D12Device> device;
137
DeviceLimits device_limits;
138
RDD::Capabilities device_capabilities;
139
uint32_t feature_level = 0; // Major * 10 + minor.
140
SubgroupCapabilities subgroup_capabilities;
141
RDD::MultiviewCapabilities multiview_capabilities;
142
FragmentShadingRateCapabilities fsr_capabilities;
143
FragmentDensityMapCapabilities fdm_capabilities;
144
ShaderCapabilities shader_capabilities;
145
FormatCapabilities format_capabilities;
146
BarrierCapabilities barrier_capabilities;
147
MiscFeaturesSupport misc_features_support;
148
SamplerCapabilities sampler_capabilities;
149
RenderingShaderContainerFormatD3D12 shader_container_format;
150
String pipeline_cache_id;
151
D3D12_HEAP_TYPE dynamic_persistent_upload_heap = D3D12_HEAP_TYPE_UPLOAD;
152
153
struct DescriptorHeap {
154
struct Allocation {
155
uint64_t virtual_alloc_handle = {}; // This is the handle value in "D3D12MA::VirtualAllocation".
156
D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle = {};
157
D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle = {};
158
};
159
160
Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> heap;
161
D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle = {};
162
D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle = {};
163
uint32_t increment_size = 0;
164
165
Microsoft::WRL::ComPtr<D3D12MA::VirtualBlock> virtual_block;
166
167
Error initialize(ID3D12Device *p_device, D3D12_DESCRIPTOR_HEAP_TYPE p_type, uint32_t p_num_descriptors, bool p_shader_visible);
168
169
Error allocate(uint32_t p_descriptor_count, Allocation &r_allocation);
170
void free(const Allocation &p_allocation);
171
};
172
173
// Some IHVs do not allow creating descriptor heaps beyond a certain limit, so they must be pooled.
174
struct CPUDescriptorHeapPool {
175
struct Allocation : DescriptorHeap::Allocation {
176
uint32_t heap_index = UINT_MAX;
177
};
178
179
BinaryMutex mutex;
180
LocalVector<DescriptorHeap> heaps;
181
182
D3D12_DESCRIPTOR_HEAP_TYPE type = {};
183
uint32_t increment_size = 0;
184
185
void initialize(ID3D12Device *p_device, D3D12_DESCRIPTOR_HEAP_TYPE p_type);
186
187
Error allocate(uint32_t p_descriptor_count, ID3D12Device *p_device, Allocation &r_allocation);
188
void free(const Allocation &p_allocation);
189
};
190
191
DescriptorHeap resource_descriptor_heap;
192
DescriptorHeap sampler_descriptor_heap;
193
CPUDescriptorHeapPool resource_descriptor_heap_pool;
194
CPUDescriptorHeapPool rtv_descriptor_heap_pool;
195
CPUDescriptorHeapPool dsv_descriptor_heap_pool;
196
197
CPUDescriptorHeapPool::Allocation null_rtv_alloc;
198
199
struct {
200
Microsoft::WRL::ComPtr<ID3D12CommandSignature> draw;
201
Microsoft::WRL::ComPtr<ID3D12CommandSignature> draw_indexed;
202
Microsoft::WRL::ComPtr<ID3D12CommandSignature> dispatch;
203
} indirect_cmd_signatures;
204
205
static void STDMETHODCALLTYPE _debug_message_func(D3D12_MESSAGE_CATEGORY p_category, D3D12_MESSAGE_SEVERITY p_severity, D3D12_MESSAGE_ID p_id, LPCSTR p_description, void *p_context);
206
void _set_object_name(ID3D12Object *p_object, String p_object_name);
207
Error _initialize_device();
208
Error _check_capabilities();
209
Error _get_device_limits();
210
Error _initialize_allocator();
211
Error _initialize_frames(uint32_t p_frame_count);
212
Error _initialize_command_signatures();
213
214
public:
215
Error initialize(uint32_t p_device_index, uint32_t p_frame_count) override final;
216
217
private:
218
/****************/
219
/**** MEMORY ****/
220
/****************/
221
222
Microsoft::WRL::ComPtr<D3D12MA::Allocator> allocator;
223
224
/******************/
225
/**** RESOURCE ****/
226
/******************/
227
228
struct ResourceInfo {
229
struct States {
230
// As many subresources as mipmaps * layers; planes (for depth-stencil) are tracked together.
231
TightLocalVector<D3D12_RESOURCE_STATES> subresource_states; // Used only if not a view.
232
uint32_t last_batch_with_uav_barrier = 0;
233
};
234
235
ID3D12Resource *resource = nullptr; // Non-null even if not owned.
236
struct {
237
Microsoft::WRL::ComPtr<ID3D12Resource> resource;
238
Microsoft::WRL::ComPtr<D3D12MA::Allocation> allocation;
239
States states;
240
} owner_info; // All empty if the resource is not owned.
241
States *states_ptr = nullptr; // Own or from another if it doesn't own the D3D12 resource.
242
};
243
244
struct BarrierRequest {
245
static const uint32_t MAX_GROUPS = 4;
246
// Maybe this is too much data to have it locally. Benchmarking may reveal that
247
// cache would be used better by having a maximum of local subresource masks and beyond
248
// that have an allocated vector with the rest.
249
static const uint32_t MAX_SUBRESOURCES = 4096;
250
ID3D12Resource *dx_resource = nullptr;
251
uint8_t subres_mask_qwords = 0;
252
uint8_t planes = 0;
253
struct Group {
254
D3D12_RESOURCE_STATES states = {};
255
static_assert(MAX_SUBRESOURCES % 64 == 0);
256
uint64_t subres_mask[MAX_SUBRESOURCES / 64] = {};
257
} groups[MAX_GROUPS];
258
uint8_t groups_count = 0;
259
static const D3D12_RESOURCE_STATES DELETED_GROUP = D3D12_RESOURCE_STATES(0xFFFFFFFFU);
260
};
261
262
struct CommandBufferInfo;
263
264
void _resource_transition_batch(CommandBufferInfo *p_command_buffer, ResourceInfo *p_resource, uint32_t p_subresource, uint32_t p_num_planes, D3D12_RESOURCE_STATES p_new_state);
265
void _resource_transitions_flush(CommandBufferInfo *p_command_buffer);
266
267
/*****************/
268
/**** BUFFERS ****/
269
/*****************/
270
271
struct BufferInfo : public ResourceInfo {
272
D3D12_GPU_VIRTUAL_ADDRESS gpu_virtual_address = {};
273
DataFormat texel_format = DATA_FORMAT_MAX;
274
uint64_t size = 0;
275
struct {
276
bool is_dynamic : 1; // Only used for tracking (e.g. Vulkan needs these checks).
277
} flags = {};
278
279
bool is_dynamic() const { return flags.is_dynamic; }
280
};
281
282
struct BufferDynamicInfo : BufferInfo {
283
uint32_t frame_idx = UINT32_MAX;
284
uint8_t *persistent_ptr = nullptr;
285
#ifdef DEBUG_ENABLED
286
// For tracking that a persistent buffer isn't mapped twice in the same frame.
287
uint64_t last_frame_mapped = 0;
288
#endif
289
};
290
291
public:
292
virtual BufferID buffer_create(uint64_t p_size, BitField<BufferUsageBits> p_usage, MemoryAllocationType p_allocation_type, uint64_t p_frames_drawn) override final;
293
virtual bool buffer_set_texel_format(BufferID p_buffer, DataFormat p_format) override final;
294
virtual void buffer_free(BufferID p_buffer) override final;
295
virtual uint64_t buffer_get_allocation_size(BufferID p_buffer) override final;
296
virtual uint8_t *buffer_map(BufferID p_buffer) override final;
297
virtual void buffer_unmap(BufferID p_buffer) override final;
298
virtual uint8_t *buffer_persistent_map_advance(BufferID p_buffer, uint64_t p_frames_drawn) override final;
299
virtual uint64_t buffer_get_dynamic_offsets(Span<BufferID> p_buffers) override final;
300
virtual uint64_t buffer_get_device_address(BufferID p_buffer) override final;
301
302
/*****************/
303
/**** TEXTURE ****/
304
/*****************/
305
private:
306
struct TextureInfo : public ResourceInfo {
307
DataFormat format = DATA_FORMAT_MAX;
308
CD3DX12_RESOURCE_DESC desc = {};
309
uint32_t base_layer = 0;
310
uint32_t layers = 0;
311
uint32_t base_mip = 0;
312
uint32_t mipmaps = 0;
313
314
struct {
315
D3D12_SHADER_RESOURCE_VIEW_DESC srv;
316
D3D12_UNORDERED_ACCESS_VIEW_DESC uav;
317
} view_descs = {};
318
319
TextureInfo *main_texture = nullptr;
320
321
#ifdef DEBUG_ENABLED
322
bool created_from_extension = false;
323
#endif
324
};
325
326
HashMap<DXGI_FORMAT, uint32_t> format_sample_counts_mask_cache;
327
Mutex format_sample_counts_mask_cache_mutex;
328
329
uint32_t _find_max_common_supported_sample_count(VectorView<DXGI_FORMAT> p_formats);
330
UINT _compute_component_mapping(const TextureView &p_view);
331
UINT _compute_plane_slice(DataFormat p_format, BitField<TextureAspectBits> p_aspect_bits);
332
UINT _compute_plane_slice(DataFormat p_format, TextureAspect p_aspect);
333
UINT _compute_subresource_from_layers(TextureInfo *p_texture, const TextureSubresourceLayers &p_layers, uint32_t p_layer_offset);
334
335
void _discard_texture_subresources(const TextureInfo *p_tex_info, const CommandBufferInfo *p_cmd_buf_info);
336
337
protected:
338
virtual bool _unordered_access_supported_by_format(DataFormat p_format);
339
340
public:
341
virtual TextureID texture_create(const TextureFormat &p_format, const TextureView &p_view) override final;
342
virtual TextureID texture_create_from_extension(uint64_t p_native_texture, TextureType p_type, DataFormat p_format, uint32_t p_array_layers, bool p_depth_stencil, uint32_t p_mipmaps) override final;
343
virtual TextureID texture_create_shared(TextureID p_original_texture, const TextureView &p_view) override final;
344
virtual TextureID texture_create_shared_from_slice(TextureID p_original_texture, const TextureView &p_view, TextureSliceType p_slice_type, uint32_t p_layer, uint32_t p_layers, uint32_t p_mipmap, uint32_t p_mipmaps) override final;
345
virtual void texture_free(TextureID p_texture) override final;
346
virtual uint64_t texture_get_allocation_size(TextureID p_texture) override final;
347
virtual void texture_get_copyable_layout(TextureID p_texture, const TextureSubresource &p_subresource, TextureCopyableLayout *r_layout) override final;
348
virtual Vector<uint8_t> texture_get_data(TextureID p_texture, uint32_t p_layer) override final;
349
virtual BitField<TextureUsageBits> texture_get_usages_supported_by_format(DataFormat p_format, bool p_cpu_readable) override final;
350
virtual bool texture_can_make_shared_with_format(TextureID p_texture, DataFormat p_format, bool &r_raw_reinterpretation) override final;
351
352
private:
353
TextureID _texture_create_shared_from_slice(TextureID p_original_texture, const TextureView &p_view, TextureSliceType p_slice_type, uint32_t p_layer, uint32_t p_layers, uint32_t p_mipmap, uint32_t p_mipmaps);
354
355
public:
356
/*****************/
357
/**** SAMPLER ****/
358
/*****************/
359
private:
360
LocalVector<D3D12_SAMPLER_DESC> samplers;
361
362
struct SamplerDescriptorHeapAllocation : DescriptorHeap::Allocation {
363
uint32_t key = 0;
364
uint32_t use_count = 1;
365
};
366
367
RBMap<uint32_t, SamplerDescriptorHeapAllocation> sampler_descriptor_heap_allocations;
368
369
public:
370
virtual SamplerID sampler_create(const SamplerState &p_state) final override;
371
virtual void sampler_free(SamplerID p_sampler) final override;
372
virtual bool sampler_is_format_supported_for_filter(DataFormat p_format, SamplerFilter p_filter) override final;
373
374
/**********************/
375
/**** VERTEX ARRAY ****/
376
/**********************/
377
private:
378
struct VertexFormatInfo {
379
TightLocalVector<D3D12_INPUT_ELEMENT_DESC> input_elem_descs;
380
TightLocalVector<UINT> vertex_buffer_strides;
381
};
382
383
public:
384
virtual VertexFormatID vertex_format_create(Span<VertexAttribute> p_vertex_attribs, const VertexAttributeBindingsMap &p_vertex_bindings) override final;
385
virtual void vertex_format_free(VertexFormatID p_vertex_format) override final;
386
387
/******************/
388
/**** BARRIERS ****/
389
/******************/
390
391
virtual void command_pipeline_barrier(
392
CommandBufferID p_cmd_buffer,
393
BitField<PipelineStageBits> p_src_stages,
394
BitField<PipelineStageBits> p_dst_stages,
395
VectorView<RDD::MemoryAccessBarrier> p_memory_barriers,
396
VectorView<RDD::BufferBarrier> p_buffer_barriers,
397
VectorView<RDD::TextureBarrier> p_texture_barriers,
398
VectorView<AccelerationStructureBarrier> p_acceleration_structure_barriers) override final;
399
400
private:
401
/****************/
402
/**** FENCES ****/
403
/****************/
404
405
struct FenceInfo {
406
Microsoft::WRL::ComPtr<ID3D12Fence> d3d_fence = nullptr;
407
HANDLE event_handle = nullptr;
408
UINT64 fence_value = 0;
409
};
410
411
public:
412
virtual FenceID fence_create() override;
413
virtual Error fence_wait(FenceID p_fence) override;
414
virtual void fence_free(FenceID p_fence) override;
415
416
private:
417
/********************/
418
/**** SEMAPHORES ****/
419
/********************/
420
421
struct SemaphoreInfo {
422
Microsoft::WRL::ComPtr<ID3D12Fence> d3d_fence = nullptr;
423
UINT64 fence_value = 0;
424
};
425
426
virtual SemaphoreID semaphore_create() override;
427
virtual void semaphore_free(SemaphoreID p_semaphore) override;
428
429
/******************/
430
/**** COMMANDS ****/
431
/******************/
432
433
// ----- QUEUE FAMILY -----
434
435
virtual CommandQueueFamilyID command_queue_family_get(BitField<CommandQueueFamilyBits> p_cmd_queue_family_bits, RenderingContextDriver::SurfaceID p_surface = 0) override;
436
437
private:
438
// ----- QUEUE -----
439
440
struct CommandQueueInfo {
441
Microsoft::WRL::ComPtr<ID3D12CommandQueue> d3d_queue;
442
};
443
444
public:
445
virtual CommandQueueID command_queue_create(CommandQueueFamilyID p_cmd_queue_family, bool p_identify_as_main_queue = false) override;
446
virtual Error command_queue_execute_and_present(CommandQueueID p_cmd_queue, VectorView<SemaphoreID> p_wait_semaphores, VectorView<CommandBufferID> p_cmd_buffers, VectorView<SemaphoreID> p_cmd_semaphores, FenceID p_cmd_fence, VectorView<SwapChainID> p_swap_chains) override;
447
virtual void command_queue_free(CommandQueueID p_cmd_queue) override;
448
449
private:
450
// ----- POOL -----
451
struct CommandPoolInfo {
452
CommandQueueFamilyID queue_family;
453
CommandBufferType buffer_type = COMMAND_BUFFER_TYPE_PRIMARY;
454
// Since there are no command pools in D3D12, we need to track the command buffers created by this pool
455
// so that we can free them when the pool is freed.
456
SelfList<CommandBufferInfo>::List command_buffers;
457
};
458
459
public:
460
virtual CommandPoolID command_pool_create(CommandQueueFamilyID p_cmd_queue_family, CommandBufferType p_cmd_buffer_type) override final;
461
virtual bool command_pool_reset(CommandPoolID p_cmd_pool) override final;
462
virtual void command_pool_free(CommandPoolID p_cmd_pool) override final;
463
464
// ----- BUFFER -----
465
466
private:
467
// Belongs to RENDERING-SUBPASS, but needed here.
468
struct FramebufferInfo;
469
struct RenderPassInfo;
470
struct RenderPassState {
471
struct AttachmentLayout {
472
struct AspectLayout {
473
TextureLayout cur_layout = TEXTURE_LAYOUT_UNDEFINED;
474
TextureLayout expected_layout = TEXTURE_LAYOUT_UNDEFINED;
475
};
476
477
AspectLayout aspect_layouts[TEXTURE_ASPECT_MAX];
478
};
479
480
uint32_t current_subpass = UINT32_MAX;
481
const FramebufferInfo *fb_info = nullptr;
482
const RenderPassInfo *pass_info = nullptr;
483
CD3DX12_RECT region_rect = {};
484
bool region_is_all = false;
485
LocalVector<AttachmentLayout> attachment_layouts;
486
487
const VertexFormatInfo *vf_info = nullptr;
488
D3D12_VERTEX_BUFFER_VIEW vertex_buffer_views[8] = {};
489
uint32_t vertex_buffer_count = 0;
490
};
491
492
struct DynParams {
493
D3D12_PRIMITIVE_TOPOLOGY primitive_topology = {};
494
Color blend_constant;
495
float depth_bounds_min = 0.0f;
496
float depth_bounds_max = 1.0f;
497
uint32_t stencil_reference = 0;
498
};
499
500
// Leveraging knowledge of actual usage and D3D12 specifics (namely, command lists from the same allocator
501
// can't be freely begun and ended), an allocator per list works better.
502
struct CommandBufferInfo {
503
// Store a self list reference to be used by the command pool.
504
SelfList<CommandBufferInfo> command_buffer_info_elem{ this };
505
506
Microsoft::WRL::ComPtr<ID3D12CommandAllocator> cmd_allocator;
507
Microsoft::WRL::ComPtr<ID3D12GraphicsCommandList> cmd_list;
508
Microsoft::WRL::ComPtr<ID3D12GraphicsCommandList1> cmd_list_1;
509
Microsoft::WRL::ComPtr<ID3D12GraphicsCommandList5> cmd_list_5;
510
Microsoft::WRL::ComPtr<ID3D12GraphicsCommandList7> cmd_list_7;
511
512
ID3D12PipelineState *graphics_pso = nullptr;
513
ID3D12PipelineState *compute_pso = nullptr;
514
515
DynParams dyn_params;
516
bool pending_dyn_params = true;
517
518
uint32_t graphics_root_signature_crc = 0;
519
uint32_t compute_root_signature_crc = 0;
520
521
RenderPassState render_pass_state;
522
bool descriptor_heaps_set = false;
523
524
HashMap<ResourceInfo::States *, BarrierRequest> res_barriers_requests;
525
LocalVector<D3D12_RESOURCE_BARRIER> res_barriers;
526
uint32_t res_barriers_count = 0;
527
uint32_t res_barriers_batch = 0;
528
529
CPUDescriptorHeapPool::Allocation uav_alloc;
530
CPUDescriptorHeapPool::Allocation rtv_alloc;
531
CPUDescriptorHeapPool::Allocation dsv_alloc;
532
};
533
534
public:
535
virtual CommandBufferID command_buffer_create(CommandPoolID p_cmd_pool) override final;
536
virtual bool command_buffer_begin(CommandBufferID p_cmd_buffer) override final;
537
virtual bool command_buffer_begin_secondary(CommandBufferID p_cmd_buffer, RenderPassID p_render_pass, uint32_t p_subpass, FramebufferID p_framebuffer) override final;
538
virtual void command_buffer_end(CommandBufferID p_cmd_buffer) override final;
539
virtual void command_buffer_execute_secondary(CommandBufferID p_cmd_buffer, VectorView<CommandBufferID> p_secondary_cmd_buffers) override final;
540
541
private:
542
/********************/
543
/**** SWAP CHAIN ****/
544
/********************/
545
546
struct SwapChain {
547
Microsoft::WRL::ComPtr<IDXGISwapChain3> d3d_swap_chain;
548
RenderingContextDriver::SurfaceID surface = RenderingContextDriver::SurfaceID();
549
UINT present_flags = 0;
550
UINT sync_interval = 1;
551
UINT creation_flags = 0;
552
RenderPassID render_pass;
553
TightLocalVector<ID3D12Resource *> render_targets;
554
TightLocalVector<TextureInfo> render_targets_info;
555
TightLocalVector<FramebufferID> framebuffers;
556
RDD::DataFormat data_format = DATA_FORMAT_MAX;
557
};
558
559
void _swap_chain_release(SwapChain *p_swap_chain);
560
void _swap_chain_release_buffers(SwapChain *p_swap_chain);
561
562
public:
563
virtual SwapChainID swap_chain_create(RenderingContextDriver::SurfaceID p_surface) override;
564
virtual Error swap_chain_resize(CommandQueueID p_cmd_queue, SwapChainID p_swap_chain, uint32_t p_desired_framebuffer_count) override;
565
virtual FramebufferID swap_chain_acquire_framebuffer(CommandQueueID p_cmd_queue, SwapChainID p_swap_chain, bool &r_resize_required) override;
566
virtual RenderPassID swap_chain_get_render_pass(SwapChainID p_swap_chain) override;
567
virtual DataFormat swap_chain_get_format(SwapChainID p_swap_chain) override;
568
virtual void swap_chain_free(SwapChainID p_swap_chain) override;
569
570
/*********************/
571
/**** FRAMEBUFFER ****/
572
/*********************/
573
private:
574
struct FramebufferInfo {
575
bool is_screen = false;
576
Size2i size;
577
578
TightLocalVector<uint32_t> attachments_handle_inds; // RTV heap index for color; DSV heap index for DSV.
579
CPUDescriptorHeapPool::Allocation rtv_alloc;
580
CPUDescriptorHeapPool::Allocation dsv_alloc; // Used only for depth-stencil attachments.
581
582
TightLocalVector<TextureID> attachments; // Color and depth-stencil. Used if not screen.
583
TextureID vrs_attachment;
584
};
585
586
D3D12_RENDER_TARGET_VIEW_DESC _make_rtv_for_texture(const TextureInfo *p_texture_info, uint32_t p_mipmap_offset, uint32_t p_layer_offset, uint32_t p_layers, bool p_add_bases = true);
587
D3D12_UNORDERED_ACCESS_VIEW_DESC _make_ranged_uav_for_texture(const TextureInfo *p_texture_info, uint32_t p_mipmap_offset, uint32_t p_layer_offset, uint32_t p_layers, bool p_add_bases = true);
588
D3D12_DEPTH_STENCIL_VIEW_DESC _make_dsv_for_texture(const TextureInfo *p_texture_info, uint32_t p_mipmap_offset, uint32_t p_layer_offset, uint32_t p_layers, bool p_add_bases = true);
589
590
FramebufferID _framebuffer_create(RenderPassID p_render_pass, VectorView<TextureID> p_attachments, uint32_t p_width, uint32_t p_height, bool p_is_screen);
591
592
public:
593
virtual FramebufferID framebuffer_create(RenderPassID p_render_pass, VectorView<TextureID> p_attachments, uint32_t p_width, uint32_t p_height) override final;
594
virtual void framebuffer_free(FramebufferID p_framebuffer) override final;
595
596
/****************/
597
/**** SHADER ****/
598
/****************/
599
600
private:
601
static const uint32_t ROOT_SIGNATURE_SIZE = 256;
602
static const uint32_t PUSH_CONSTANT_SIZE = 128; // Mimicking Vulkan.
603
604
enum {
605
// We can only aim to set a maximum here, since depending on the shader
606
// there may be more or less root signature free for descriptor tables.
607
// Therefore, we'll have to rely on the final check at runtime, when building
608
// the root signature structure for a given shader.
609
// To be precise, these may be present or not, and their size vary statically:
610
// - Push constant (we'll assume this is always present to avoid reserving much
611
// more space for descriptor sets than needed for almost any imaginable case,
612
// given that most shader templates feature push constants).
613
// - NIR-DXIL runtime data.
614
MAX_UNIFORM_SETS = (ROOT_SIGNATURE_SIZE - PUSH_CONSTANT_SIZE) / sizeof(uint32_t),
615
};
616
617
struct ShaderInfo {
618
uint32_t dxil_push_constant_size = 0;
619
uint32_t nir_runtime_data_root_param_idx = UINT32_MAX;
620
PipelineType pipeline_type = PIPELINE_TYPE_RASTERIZATION;
621
622
struct UniformBindingInfo {
623
uint32_t stages = 0; // Actual shader stages using the uniform (0 if totally optimized out).
624
ResourceClass res_class = RES_CLASS_INVALID;
625
UniformType type = UNIFORM_TYPE_MAX;
626
uint32_t length = UINT32_MAX;
627
bool writable = false;
628
uint32_t resource_descriptor_offset = UINT32_MAX;
629
uint32_t sampler_descriptor_offset = UINT32_MAX;
630
uint32_t root_param_idx = UINT32_MAX;
631
};
632
633
struct UniformSet {
634
TightLocalVector<UniformBindingInfo> bindings;
635
uint32_t resource_root_param_idx = UINT32_MAX;
636
uint32_t resource_descriptor_count = 0;
637
uint32_t sampler_root_param_idx = UINT32_MAX;
638
uint32_t sampler_descriptor_count = 0;
639
};
640
641
TightLocalVector<UniformSet> sets;
642
643
struct SpecializationConstant {
644
uint32_t constant_id = UINT32_MAX;
645
uint32_t int_value = UINT32_MAX;
646
uint64_t stages_bit_offsets[D3D12_BITCODE_OFFSETS_NUM_STAGES] = {};
647
};
648
649
TightLocalVector<SpecializationConstant> specialization_constants;
650
uint32_t spirv_specialization_constants_ids_mask = 0;
651
652
HashMap<ShaderStage, Vector<uint8_t>> stages_bytecode;
653
654
Microsoft::WRL::ComPtr<ID3D12RootSignature> root_signature;
655
Microsoft::WRL::ComPtr<ID3D12RootSignatureDeserializer> root_signature_deserializer;
656
const D3D12_ROOT_SIGNATURE_DESC *root_signature_desc = nullptr; // Owned by the deserializer.
657
uint32_t root_signature_crc = 0;
658
};
659
660
bool _shader_apply_specialization_constants(
661
const ShaderInfo *p_shader_info,
662
VectorView<PipelineSpecializationConstant> p_specialization_constants,
663
HashMap<ShaderStage, Vector<uint8_t>> &r_final_stages_bytecode);
664
665
public:
666
virtual ShaderID shader_create_from_container(const Ref<RenderingShaderContainer> &p_shader_container, const Vector<ImmutableSampler> &p_immutable_samplers) override final;
667
virtual uint32_t shader_get_layout_hash(ShaderID p_shader) override final;
668
virtual void shader_free(ShaderID p_shader) override final;
669
virtual void shader_destroy_modules(ShaderID p_shader) override final;
670
671
/*********************/
672
/**** UNIFORM SET ****/
673
/*********************/
674
675
private:
676
struct UniformSetInfo {
677
DescriptorHeap::Allocation resource_descriptor_heap_alloc;
678
SamplerDescriptorHeapAllocation *sampler_descriptor_heap_alloc = nullptr;
679
680
struct DynamicBuffer {
681
BufferDynamicInfo const *info = nullptr;
682
uint32_t binding = UINT_MAX;
683
};
684
685
TightLocalVector<DynamicBuffer> dynamic_buffers;
686
687
struct StateRequirement {
688
ResourceInfo *resource = nullptr;
689
bool is_buffer = false;
690
D3D12_RESOURCE_STATES states = {};
691
uint64_t shader_uniform_idx_mask = 0;
692
};
693
694
TightLocalVector<StateRequirement> resource_states;
695
};
696
697
public:
698
virtual UniformSetID uniform_set_create(VectorView<BoundUniform> p_uniforms, ShaderID p_shader, uint32_t p_set_index, int p_linear_pool_index) override final;
699
virtual void uniform_set_free(UniformSetID p_uniform_set) override final;
700
virtual uint32_t uniform_sets_get_dynamic_offsets(VectorView<UniformSetID> p_uniform_sets, ShaderID p_shader, uint32_t p_first_set_index, uint32_t p_set_count) const override final;
701
702
// ----- COMMANDS -----
703
704
virtual void command_uniform_set_prepare_for_use(CommandBufferID p_cmd_buffer, UniformSetID p_uniform_set, ShaderID p_shader, uint32_t p_set_index) override final;
705
706
private:
707
void _command_check_descriptor_sets(CommandBufferID p_cmd_buffer);
708
DescriptorHeap::Allocation _command_allocate_per_frame_descriptor();
709
710
public:
711
/******************/
712
/**** TRANSFER ****/
713
/******************/
714
715
virtual void command_clear_buffer(CommandBufferID p_cmd_buffer, BufferID p_buffer, uint64_t p_offset, uint64_t p_size) override final;
716
virtual void command_copy_buffer(CommandBufferID p_cmd_buffer, BufferID p_src_buffer, BufferID p_dst_buffer, VectorView<BufferCopyRegion> p_regions) override final;
717
718
virtual void command_copy_texture(CommandBufferID p_cmd_buffer, TextureID p_src_texture, TextureLayout p_src_texture_layout, TextureID p_dst_texture, TextureLayout p_dst_texture_layout, VectorView<TextureCopyRegion> p_regions) override final;
719
virtual void command_resolve_texture(CommandBufferID p_cmd_buffer, TextureID p_src_texture, TextureLayout p_src_texture_layout, uint32_t p_src_layer, uint32_t p_src_mipmap, TextureID p_dst_texture, TextureLayout p_dst_texture_layout, uint32_t p_dst_layer, uint32_t p_dst_mipmap) override final;
720
virtual void command_clear_color_texture(CommandBufferID p_cmd_buffer, TextureID p_texture, TextureLayout p_texture_layout, const Color &p_color, const TextureSubresourceRange &p_subresources) override final;
721
virtual void command_clear_depth_stencil_texture(CommandBufferID p_cmd_buffer, TextureID p_texture, TextureLayout p_texture_layout, float p_depth, uint8_t p_stencil, const TextureSubresourceRange &p_subresources) override final;
722
723
public:
724
virtual void command_copy_buffer_to_texture(CommandBufferID p_cmd_buffer, BufferID p_src_buffer, TextureID p_dst_texture, TextureLayout p_dst_texture_layout, VectorView<BufferTextureCopyRegion> p_regions) override final;
725
virtual void command_copy_texture_to_buffer(CommandBufferID p_cmd_buffer, TextureID p_src_texture, TextureLayout p_src_texture_layout, BufferID p_dst_buffer, VectorView<BufferTextureCopyRegion> p_regions) override final;
726
727
/******************/
728
/**** PIPELINE ****/
729
/******************/
730
731
struct RenderPipelineInfo {
732
const VertexFormatInfo *vf_info = nullptr;
733
DynParams dyn_params;
734
};
735
736
struct PipelineInfo {
737
Microsoft::WRL::ComPtr<ID3D12PipelineState> pso;
738
const ShaderInfo *shader_info = nullptr;
739
RenderPipelineInfo render_info;
740
};
741
742
virtual void pipeline_free(PipelineID p_pipeline) override final;
743
744
public:
745
// ----- BINDING -----
746
747
virtual void command_bind_push_constants(CommandBufferID p_cmd_buffer, ShaderID p_shader, uint32_t p_dst_first_index, VectorView<uint32_t> p_data) override final;
748
749
// ----- CACHE -----
750
751
virtual bool pipeline_cache_create(const Vector<uint8_t> &p_data) override final;
752
virtual void pipeline_cache_free() override final;
753
virtual size_t pipeline_cache_query_size() override final;
754
virtual Vector<uint8_t> pipeline_cache_serialize() override final;
755
756
/*******************/
757
/**** RENDERING ****/
758
/*******************/
759
760
// ----- SUBPASS -----
761
762
private:
763
struct RenderPassInfo {
764
TightLocalVector<Attachment> attachments;
765
TightLocalVector<Subpass> subpasses;
766
uint32_t view_count = 0;
767
uint32_t max_supported_sample_count = 0;
768
};
769
770
public:
771
virtual RenderPassID render_pass_create(VectorView<Attachment> p_attachments, VectorView<Subpass> p_subpasses, VectorView<SubpassDependency> p_subpass_dependencies, uint32_t p_view_count, AttachmentReference p_fragment_density_map_attachment) override final;
772
virtual void render_pass_free(RenderPassID p_render_pass) override final;
773
774
// ----- COMMANDS -----
775
776
virtual void command_begin_render_pass(CommandBufferID p_cmd_buffer, RenderPassID p_render_pass, FramebufferID p_framebuffer, CommandBufferType p_cmd_buffer_type, const Rect2i &p_rect, VectorView<RenderPassClearValue> p_clear_values) override final;
777
778
private:
779
void _render_pass_enhanced_barriers_flush(CommandBufferID p_cmd_buffer);
780
void _end_render_pass(CommandBufferID p_cmd_buffer);
781
782
public:
783
virtual void command_end_render_pass(CommandBufferID p_cmd_buffer) override final;
784
virtual void command_next_render_subpass(CommandBufferID p_cmd_buffer, CommandBufferType p_cmd_buffer_type) override final;
785
virtual void command_render_set_viewport(CommandBufferID p_cmd_buffer, VectorView<Rect2i> p_viewports) override final;
786
virtual void command_render_set_scissor(CommandBufferID p_cmd_buffer, VectorView<Rect2i> p_scissors) override final;
787
788
virtual void command_render_clear_attachments(CommandBufferID p_cmd_buffer, VectorView<AttachmentClear> p_attachment_clears, VectorView<Rect2i> p_rects) override final;
789
790
// Binding.
791
virtual void command_bind_render_pipeline(CommandBufferID p_cmd_buffer, PipelineID p_pipeline) override final;
792
virtual void command_bind_render_uniform_sets(CommandBufferID p_cmd_buffer, VectorView<UniformSetID> p_uniform_sets, ShaderID p_shader, uint32_t p_first_set_index, uint32_t p_set_count, uint32_t p_dynamic_offsets) override final;
793
794
// Drawing.
795
virtual void command_render_draw(CommandBufferID p_cmd_buffer, uint32_t p_vertex_count, uint32_t p_instance_count, uint32_t p_base_vertex, uint32_t p_first_instance) override final;
796
virtual void command_render_draw_indexed(CommandBufferID p_cmd_buffer, uint32_t p_index_count, uint32_t p_instance_count, uint32_t p_first_index, int32_t p_vertex_offset, uint32_t p_first_instance) override final;
797
virtual void command_render_draw_indexed_indirect(CommandBufferID p_cmd_buffer, BufferID p_indirect_buffer, uint64_t p_offset, uint32_t p_draw_count, uint32_t p_stride) override final;
798
virtual void command_render_draw_indexed_indirect_count(CommandBufferID p_cmd_buffer, BufferID p_indirect_buffer, uint64_t p_offset, BufferID p_count_buffer, uint64_t p_count_buffer_offset, uint32_t p_max_draw_count, uint32_t p_stride) override final;
799
virtual void command_render_draw_indirect(CommandBufferID p_cmd_buffer, BufferID p_indirect_buffer, uint64_t p_offset, uint32_t p_draw_count, uint32_t p_stride) override final;
800
virtual void command_render_draw_indirect_count(CommandBufferID p_cmd_buffer, BufferID p_indirect_buffer, uint64_t p_offset, BufferID p_count_buffer, uint64_t p_count_buffer_offset, uint32_t p_max_draw_count, uint32_t p_stride) override final;
801
802
// Buffer binding.
803
virtual void command_render_bind_vertex_buffers(CommandBufferID p_cmd_buffer, uint32_t p_binding_count, const BufferID *p_buffers, const uint64_t *p_offsets, uint64_t p_dynamic_offsets) override final;
804
virtual void command_render_bind_index_buffer(CommandBufferID p_cmd_buffer, BufferID p_buffer, IndexBufferFormat p_format, uint64_t p_offset) override final;
805
806
private:
807
void _bind_vertex_buffers(CommandBufferInfo *p_cmd_buf_info);
808
809
public:
810
// Dynamic state.
811
virtual void command_render_set_blend_constants(CommandBufferID p_cmd_buffer, const Color &p_constants) override final;
812
virtual void command_render_set_line_width(CommandBufferID p_cmd_buffer, float p_width) override final;
813
814
// ----- PIPELINE -----
815
816
public:
817
virtual PipelineID render_pipeline_create(
818
ShaderID p_shader,
819
VertexFormatID p_vertex_format,
820
RenderPrimitive p_render_primitive,
821
PipelineRasterizationState p_rasterization_state,
822
PipelineMultisampleState p_multisample_state,
823
PipelineDepthStencilState p_depth_stencil_state,
824
PipelineColorBlendState p_blend_state,
825
VectorView<int32_t> p_color_attachments,
826
BitField<PipelineDynamicStateFlags> p_dynamic_state,
827
RenderPassID p_render_pass,
828
uint32_t p_render_subpass,
829
VectorView<PipelineSpecializationConstant> p_specialization_constants) override final;
830
831
/*****************/
832
/**** COMPUTE ****/
833
/*****************/
834
835
// ----- COMMANDS -----
836
837
// Binding.
838
virtual void command_bind_compute_pipeline(CommandBufferID p_cmd_buffer, PipelineID p_pipeline) override final;
839
virtual void command_bind_compute_uniform_sets(CommandBufferID p_cmd_buffer, VectorView<UniformSetID> p_uniform_sets, ShaderID p_shader, uint32_t p_first_set_index, uint32_t p_set_count, uint32_t p_dynamic_offsets) override final;
840
841
// Dispatching.
842
virtual void command_compute_dispatch(CommandBufferID p_cmd_buffer, uint32_t p_x_groups, uint32_t p_y_groups, uint32_t p_z_groups) override final;
843
virtual void command_compute_dispatch_indirect(CommandBufferID p_cmd_buffer, BufferID p_indirect_buffer, uint64_t p_offset) override final;
844
845
// ----- PIPELINE -----
846
847
virtual PipelineID compute_pipeline_create(ShaderID p_shader, VectorView<PipelineSpecializationConstant> p_specialization_constants) override final;
848
849
/********************/
850
/**** RAYTRACING ****/
851
/********************/
852
853
// ---- ACCELERATION STRUCTURES ----
854
855
virtual AccelerationStructureID blas_create(BufferID p_vertex_buffer, uint64_t p_vertex_offset, VertexFormatID p_vertex_format, uint32_t p_vertex_count, uint32_t p_position_attribute_location, BufferID p_index_buffer, IndexBufferFormat p_index_format, uint64_t p_index_offset, uint32_t p_index_count, BitField<AccelerationStructureGeometryBits> p_geometry_bits) override final;
856
virtual uint32_t tlas_instances_buffer_get_size_bytes(uint32_t p_instance_count) override final;
857
virtual void tlas_instances_buffer_fill(BufferID p_instances_buffer, VectorView<AccelerationStructureID> p_blases, VectorView<Transform3D> p_transforms) override final;
858
virtual AccelerationStructureID tlas_create(BufferID p_instances_buffer) override final;
859
virtual void acceleration_structure_free(AccelerationStructureID p_acceleration_structure) override final;
860
virtual uint32_t acceleration_structure_get_scratch_size_bytes(AccelerationStructureID p_acceleration_structure) override final;
861
862
// ----- PIPELINE -----
863
864
virtual RaytracingPipelineID raytracing_pipeline_create(ShaderID p_shader, VectorView<PipelineSpecializationConstant> p_specialization_constants) override final;
865
virtual void raytracing_pipeline_free(RaytracingPipelineID p_pipeline) override final;
866
867
// ----- COMMANDS -----
868
869
virtual void command_build_acceleration_structure(CommandBufferID p_cmd_buffer, AccelerationStructureID p_acceleration_structure, BufferID p_scratch_buffer) override final;
870
virtual void command_bind_raytracing_pipeline(CommandBufferID p_cmd_buffer, RaytracingPipelineID p_pipeline) override final;
871
virtual void command_bind_raytracing_uniform_set(CommandBufferID p_cmd_buffer, UniformSetID p_uniform_set, ShaderID p_shader, uint32_t p_set_index) override final;
872
virtual void command_trace_rays(CommandBufferID p_cmd_buffer, uint32_t p_width, uint32_t p_height) override final;
873
874
/*****************/
875
/**** QUERIES ****/
876
/*****************/
877
878
// ----- TIMESTAMP -----
879
880
private:
881
struct TimestampQueryPoolInfo {
882
Microsoft::WRL::ComPtr<ID3D12QueryHeap> query_heap;
883
uint32_t query_count = 0;
884
Microsoft::WRL::ComPtr<D3D12MA::Allocation> results_buffer_allocation;
885
};
886
887
public:
888
// Basic.
889
virtual QueryPoolID timestamp_query_pool_create(uint32_t p_query_count) override final;
890
virtual void timestamp_query_pool_free(QueryPoolID p_pool_id) override final;
891
virtual void timestamp_query_pool_get_results(QueryPoolID p_pool_id, uint32_t p_query_count, uint64_t *r_results) override final;
892
virtual uint64_t timestamp_query_result_to_time(uint64_t p_result) override final;
893
894
// Commands.
895
virtual void command_timestamp_query_pool_reset(CommandBufferID p_cmd_buffer, QueryPoolID p_pool_id, uint32_t p_query_count) override final;
896
virtual void command_timestamp_write(CommandBufferID p_cmd_buffer, QueryPoolID p_pool_id, uint32_t p_index) override final;
897
898
/****************/
899
/**** LABELS ****/
900
/****************/
901
902
virtual void command_begin_label(CommandBufferID p_cmd_buffer, const char *p_label_name, const Color &p_color) override final;
903
virtual void command_end_label(CommandBufferID p_cmd_buffer) override final;
904
905
/****************/
906
/**** DEBUG *****/
907
/****************/
908
virtual void command_insert_breadcrumb(CommandBufferID p_cmd_buffer, uint32_t p_data) override final;
909
910
/********************/
911
/**** SUBMISSION ****/
912
/********************/
913
private:
914
struct FrameInfo {
915
LocalVector<DescriptorHeap::Allocation> descriptor_allocations;
916
uint32_t descriptor_allocation_count = 0;
917
};
918
TightLocalVector<FrameInfo> frames;
919
uint32_t frame_idx = 0;
920
uint32_t frames_drawn = 0;
921
bool segment_begun = false;
922
HashMap<uint64_t, bool> has_comp_alpha;
923
924
public:
925
virtual void begin_segment(uint32_t p_frame_index, uint32_t p_frames_drawn) override final;
926
virtual void end_segment() override final;
927
928
/**************/
929
/**** MISC ****/
930
/**************/
931
932
virtual void set_object_name(ObjectType p_type, ID p_driver_id, const String &p_name) override final;
933
virtual uint64_t get_resource_native_handle(DriverResource p_type, ID p_driver_id) override final;
934
virtual uint64_t get_total_memory_used() override final;
935
virtual uint64_t get_lazily_memory_used() override final;
936
virtual uint64_t limit_get(Limit p_limit) override final;
937
virtual uint64_t api_trait_get(ApiTrait p_trait) override final;
938
virtual bool has_feature(Features p_feature) override final;
939
virtual const MultiviewCapabilities &get_multiview_capabilities() override final;
940
virtual const FragmentShadingRateCapabilities &get_fragment_shading_rate_capabilities() override final;
941
virtual const FragmentDensityMapCapabilities &get_fragment_density_map_capabilities() override final;
942
virtual String get_api_name() const override final;
943
virtual String get_api_version() const override final;
944
virtual String get_pipeline_cache_uuid() const override final;
945
virtual const Capabilities &get_capabilities() const override final;
946
virtual const RenderingShaderContainerFormat &get_shader_container_format() const override final;
947
948
virtual bool is_composite_alpha_supported(CommandQueueID p_queue) const override final;
949
950
static bool is_in_developer_mode();
951
952
private:
953
/*********************/
954
/**** BOOKKEEPING ****/
955
/*********************/
956
957
using VersatileResource = VersatileResourceTemplate<
958
BufferInfo,
959
TextureInfo,
960
TextureInfo,
961
TextureInfo,
962
VertexFormatInfo,
963
CommandBufferInfo,
964
FramebufferInfo,
965
ShaderInfo,
966
UniformSetInfo,
967
RenderPassInfo,
968
TimestampQueryPoolInfo>;
969
PagedAllocator<VersatileResource, true> resources_allocator;
970
971
/******************/
972
973
public:
974
RenderingDeviceDriverD3D12(RenderingContextDriverD3D12 *p_context_driver);
975
virtual ~RenderingDeviceDriverD3D12();
976
};
977
978