Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qrhid3d12_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QRHID3D12_P_H
5#define QRHID3D12_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qrhi_p.h"
20#include <QWindow>
21#include <QBitArray>
22
23#include <optional>
24#include <array>
25
26#include <d3d12.h>
27#include <d3d12sdklayers.h>
28#include <dxgi1_6.h>
29#include <dcomp.h>
30
31#include "D3D12MemAlloc.h"
32
33// ID3D12Device2 and ID3D12GraphicsCommandList1 and types and enums introduced
34// with those are hard requirements now. These should be declared in any
35// moderately recent d3d12.h, but if it is an SDK from before Windows 10
36// version 1703 then these types could be missing. In the absence of other
37// options, handle this by skipping all the code and making QRhi::create() fail
38// in such builds.
39#ifdef __ID3D12Device2_INTERFACE_DEFINED__
40#define QRHI_D3D12_AVAILABLE
41
43
44static const int QD3D12_FRAMES_IN_FLIGHT = 2;
45
46class QRhiD3D12;
47
48struct QD3D12Descriptor
49{
50 D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle = {};
51 D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle = {};
52
53 bool isValid() const { return cpuHandle.ptr != 0; }
54};
55
56struct QD3D12ReleaseQueue;
57
58struct QD3D12DescriptorHeap
59{
60 bool isValid() const { return heap && capacity; }
61 bool create(ID3D12Device *device,
62 quint32 descriptorCount,
63 D3D12_DESCRIPTOR_HEAP_TYPE heapType,
64 D3D12_DESCRIPTOR_HEAP_FLAGS heapFlags);
65 void createWithExisting(const QD3D12DescriptorHeap &other,
66 quint32 offsetInDescriptors,
67 quint32 descriptorCount);
68 void destroy();
69 void destroyWithDeferredRelease(QD3D12ReleaseQueue *releaseQueue);
70
71 QD3D12Descriptor get(quint32 count);
72 QD3D12Descriptor at(quint32 index) const;
73 quint32 remainingCapacity() const { return capacity - head; }
74
75 QD3D12Descriptor incremented(const QD3D12Descriptor &descriptor, quint32 offsetInDescriptors) const
76 {
77 D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle = descriptor.cpuHandle;
78 cpuHandle.ptr += offsetInDescriptors * descriptorByteSize;
79 D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle = descriptor.gpuHandle;
80 if (gpuHandle.ptr)
81 gpuHandle.ptr += offsetInDescriptors * descriptorByteSize;
82 return { cpuHandle, gpuHandle };
83 }
84
85 ID3D12DescriptorHeap *heap = nullptr;
86 quint32 capacity = 0;
87 QD3D12Descriptor heapStart;
88 quint32 head = 0;
89 quint32 descriptorByteSize = 0;
90 D3D12_DESCRIPTOR_HEAP_TYPE heapType;
91 D3D12_DESCRIPTOR_HEAP_FLAGS heapFlags;
92};
93
94struct QD3D12CpuDescriptorPool
95{
96 bool isValid() const { return !heaps.isEmpty(); }
97 bool create(ID3D12Device *device, D3D12_DESCRIPTOR_HEAP_TYPE heapType, const char *debugName = "");
98 void destroy();
99
100 QD3D12Descriptor allocate(quint32 count);
101 void release(const QD3D12Descriptor &descriptor, quint32 count);
102
103 static const int DESCRIPTORS_PER_HEAP = 256;
104
105 struct HeapWithMap {
106 QD3D12DescriptorHeap heap;
108 static HeapWithMap init(const QD3D12DescriptorHeap &heap, quint32 descriptorCount) {
109 HeapWithMap result;
110 result.heap = heap;
111 result.map.resize(descriptorCount);
112 return result;
113 }
114 };
115
116 ID3D12Device *device;
117 quint32 descriptorByteSize;
119 const char *debugName;
120};
121
122struct QD3D12StagingArea
123{
124 static const quint32 ALIGNMENT = D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT; // 512 so good enough both for cb and texdata
125
126 struct Allocation {
127 quint8 *p = nullptr;
128 D3D12_GPU_VIRTUAL_ADDRESS gpuAddr = 0;
129 ID3D12Resource *buffer = nullptr;
130 quint32 bufferOffset = 0;
131 bool isValid() const { return p != nullptr; }
132 };
133
134 bool isValid() const { return allocation && mem.isValid(); }
135 bool create(QRhiD3D12 *rhi, quint32 capacity, D3D12_HEAP_TYPE heapType);
136 void destroy();
137 void destroyWithDeferredRelease(QD3D12ReleaseQueue *releaseQueue);
138
139 Allocation get(quint32 byteSize);
140
141 quint32 remainingCapacity() const
142 {
143 return capacity - head;
144 }
145
146 static quint32 allocSizeForArray(quint32 size, int count = 1)
147 {
148 return count * ((size + ALIGNMENT - 1) & ~(ALIGNMENT - 1));
149 }
150
151 Allocation mem;
152 ID3D12Resource *resource = nullptr;
153 D3D12MA::Allocation *allocation = nullptr;
154 quint32 head;
156};
157
158struct QD3D12ObjectHandle
159{
160 quint32 index = 0;
161 quint32 generation = 0;
162
163 // the default, null handle is guaranteed to give ObjectPool::isValid() == false
164 bool isNull() const { return index == 0 && generation == 0; }
165};
166
167inline bool operator==(const QD3D12ObjectHandle &a, const QD3D12ObjectHandle &b) noexcept
168{
169 return a.index == b.index && a.generation == b.generation;
170}
171
172inline bool operator!=(const QD3D12ObjectHandle &a, const QD3D12ObjectHandle &b) noexcept
173{
174 return !(a == b);
175}
176
177template<typename T>
178struct QD3D12ObjectPool
179{
180 void create(const char *debugName = "")
181 {
182 this->debugName = debugName;
183 Q_ASSERT(data.isEmpty());
184 data.append(Data()); // index 0 is always invalid
185 }
186
187 void destroy() {
188 int leakCount = 0; // will nicely destroy everything here, but warn about it if enabled
189 for (Data &d : data) {
190 if (d.object.has_value()) {
191 leakCount += 1;
192 d.object->releaseResources();
193 }
194 }
195 data.clear();
196#ifndef QT_NO_DEBUG
197 // debug builds: just do it always
198 static bool leakCheck = true;
199#else
200 // release builds: opt-in
201 static bool leakCheck = qEnvironmentVariableIntValue("QT_RHI_LEAK_CHECK");
202#endif
203 if (leakCheck) {
204 if (leakCount > 0) {
205 qWarning("QD3D12ObjectPool::destroy(): Pool %p '%s' had %d unreleased objects",
206 this, debugName, leakCount);
207 }
208 }
209 }
210
211 bool isValid(const QD3D12ObjectHandle &handle) const
212 {
213 return handle.index > 0
214 && handle.index < quint32(data.count())
215 && handle.generation > 0
216 && handle.generation == data[handle.index].generation
217 && data[handle.index].object.has_value();
218 }
219
220 T lookup(const QD3D12ObjectHandle &handle) const
221 {
222 return isValid(handle) ? *data[handle.index].object : T();
223 }
224
225 const T *lookupRef(const QD3D12ObjectHandle &handle) const
226 {
227 return isValid(handle) ? &*data[handle.index].object : nullptr;
228 }
229
230 T *lookupRef(const QD3D12ObjectHandle &handle)
231 {
232 return isValid(handle) ? &*data[handle.index].object : nullptr;
233 }
234
235 QD3D12ObjectHandle add(const T &object)
236 {
237 Q_ASSERT(!data.isEmpty());
238 const quint32 count = quint32(data.count());
239 quint32 index = 1; // index 0 is always invalid
240 for (; index < count; ++index) {
241 if (!data[index].object.has_value())
242 break;
243 }
244 if (index < count) {
245 data[index].object = object;
246 quint32 &generation = data[index].generation;
247 generation += 1u;
248 return { index, generation };
249 } else {
250 data.append({ object, 1 });
251 return { count, 1 };
252 }
253 }
254
255 void remove(const QD3D12ObjectHandle &handle)
256 {
257 if (T *object = lookupRef(handle)) {
258 object->releaseResources();
259 data[handle.index].object.reset();
260 }
261 }
262
263 const char *debugName;
264 struct Data {
265 std::optional<T> object;
266 quint32 generation = 0;
267 };
269};
270
271struct QD3D12Resource
272{
273 ID3D12Resource *resource;
274 D3D12_RESOURCE_STATES state;
275 D3D12_RESOURCE_DESC desc;
276 D3D12MA::Allocation *allocation;
277 void *cpuMapPtr;
278 enum { UavUsageRead = 0x01, UavUsageWrite = 0x02 };
279 int uavUsage;
280 bool owns;
281
282 // note that this assumes the allocation (if there is one) and the resource
283 // are separately releaseable, see D3D12MemAlloc docs
284 static QD3D12ObjectHandle addToPool(QD3D12ObjectPool<QD3D12Resource> *pool,
285 ID3D12Resource *resource,
286 D3D12_RESOURCE_STATES state,
287 D3D12MA::Allocation *allocation = nullptr,
288 void *cpuMapPtr = nullptr)
289 {
290 Q_ASSERT(resource);
291 return pool->add({ resource, state, resource->GetDesc(), allocation, cpuMapPtr, 0, true });
292 }
293
294 // for QRhiTexture::createFrom() where the ID3D12Resource is not owned by us
295 static QD3D12ObjectHandle addNonOwningToPool(QD3D12ObjectPool<QD3D12Resource> *pool,
296 ID3D12Resource *resource,
297 D3D12_RESOURCE_STATES state)
298 {
299 Q_ASSERT(resource);
300 return pool->add({ resource, state, resource->GetDesc(), nullptr, nullptr, 0, false });
301 }
302
303 void releaseResources()
304 {
305 if (owns) {
306 // order matters: resource first, then the allocation
307 resource->Release();
308 if (allocation)
309 allocation->Release();
310 }
311 }
312};
313
314struct QD3D12Pipeline
315{
316 enum Type {
317 Graphics,
318 Compute
319 };
320 Type type;
321 ID3D12PipelineState *pso;
322
323 static QD3D12ObjectHandle addToPool(QD3D12ObjectPool<QD3D12Pipeline> *pool,
324 Type type,
325 ID3D12PipelineState *pso)
326 {
327 return pool->add({ type, pso });
328 }
329
330 void releaseResources()
331 {
332 pso->Release();
333 }
334};
335
336struct QD3D12RootSignature
337{
338 ID3D12RootSignature *rootSig;
339
340 static QD3D12ObjectHandle addToPool(QD3D12ObjectPool<QD3D12RootSignature> *pool,
341 ID3D12RootSignature *rootSig)
342 {
343 return pool->add({ rootSig });
344 }
345
346 void releaseResources()
347 {
348 rootSig->Release();
349 }
350};
351
352struct QD3D12ReleaseQueue
353{
354 void create(QD3D12ObjectPool<QD3D12Resource> *resourcePool,
355 QD3D12ObjectPool<QD3D12Pipeline> *pipelinePool,
356 QD3D12ObjectPool<QD3D12RootSignature> *rootSignaturePool)
357 {
358 this->resourcePool = resourcePool;
359 this->pipelinePool = pipelinePool;
360 this->rootSignaturePool = rootSignaturePool;
361 }
362
363 void deferredReleaseResource(const QD3D12ObjectHandle &handle);
364 void deferredReleaseResourceWithViews(const QD3D12ObjectHandle &handle,
365 QD3D12CpuDescriptorPool *pool,
366 const QD3D12Descriptor &viewsStart,
367 int viewCount);
368 void deferredReleasePipeline(const QD3D12ObjectHandle &handle);
369 void deferredReleaseRootSignature(const QD3D12ObjectHandle &handle);
370 void deferredReleaseCallback(std::function<void(void*)> callback, void *userData);
371 void deferredReleaseResourceAndAllocation(ID3D12Resource *resource,
372 D3D12MA::Allocation *allocation);
373 void deferredReleaseDescriptorHeap(ID3D12DescriptorHeap *heap);
374 void deferredReleaseViews(QD3D12CpuDescriptorPool *pool,
375 const QD3D12Descriptor &viewsStart,
376 int viewCount);
377
378 void activatePendingDeferredReleaseRequests(int frameSlot);
379 void executeDeferredReleases(int frameSlot, bool forced = false);
380 void releaseAll();
381
382 struct DeferredReleaseEntry {
383 enum Type {
384 Resource,
385 Pipeline,
386 RootSignature,
387 Callback,
388 ResourceAndAllocation,
389 DescriptorHeap,
390 Views
391 };
392 Type type = Resource;
393 std::optional<int> frameSlotToBeReleasedIn;
394 QD3D12ObjectHandle handle;
395 QD3D12CpuDescriptorPool *poolForViews = nullptr;
396 QD3D12Descriptor viewsStart;
397 int viewCount = 0;
398 std::function<void(void*)> callback = nullptr;
399 void *callbackUserData = nullptr;
400 QPair<ID3D12Resource *, D3D12MA::Allocation *> resourceAndAllocation = {};
401 ID3D12DescriptorHeap *descriptorHeap = nullptr;
402 };
404 QD3D12ObjectPool<QD3D12Resource> *resourcePool = nullptr;
405 QD3D12ObjectPool<QD3D12Pipeline> *pipelinePool = nullptr;
406 QD3D12ObjectPool<QD3D12RootSignature> *rootSignaturePool = nullptr;
407};
408
409struct QD3D12CommandBuffer;
410
411struct QD3D12ResourceBarrierGenerator
412{
413 static const int PREALLOC = 16;
414
415 void create(QD3D12ObjectPool<QD3D12Resource> *resourcePool)
416 {
417 this->resourcePool = resourcePool;
418 }
419
420 void addTransitionBarrier(const QD3D12ObjectHandle &resourceHandle, D3D12_RESOURCE_STATES stateAfter);
421 void enqueueBufferedTransitionBarriers(QD3D12CommandBuffer *cbD);
422 void enqueueSubresourceTransitionBarrier(QD3D12CommandBuffer *cbD,
423 const QD3D12ObjectHandle &resourceHandle,
424 UINT subresource,
425 D3D12_RESOURCE_STATES stateBefore,
426 D3D12_RESOURCE_STATES stateAfter);
427 void enqueueUavBarrier(QD3D12CommandBuffer *cbD, const QD3D12ObjectHandle &resourceHandle);
428
429 struct TransitionResourceBarrier {
430 QD3D12ObjectHandle resourceHandle;
431 D3D12_RESOURCE_STATES stateBefore;
432 D3D12_RESOURCE_STATES stateAfter;
433 };
435 QD3D12ObjectPool<QD3D12Resource> *resourcePool = nullptr;
436};
437
438struct QD3D12ShaderBytecodeCache
439{
440 struct Shader {
441 Shader() = default;
442 Shader(const QByteArray &bytecode, const QShader::NativeResourceBindingMap &rbm)
443 : bytecode(bytecode), nativeResourceBindingMap(rbm)
444 { }
445 QByteArray bytecode;
446 QShader::NativeResourceBindingMap nativeResourceBindingMap;
447 };
448
450
451 void insertWithCapacityLimit(const QRhiShaderStage &key, const Shader &s);
452};
453
454struct QD3D12ShaderVisibleDescriptorHeap
455{
456 bool create(ID3D12Device *device, D3D12_DESCRIPTOR_HEAP_TYPE type, quint32 perFrameDescriptorCount);
457 void destroy();
458 void destroyWithDeferredRelease(QD3D12ReleaseQueue *releaseQueue);
459
460 QD3D12DescriptorHeap heap;
461 QD3D12DescriptorHeap perFrameHeapSlice[QD3D12_FRAMES_IN_FLIGHT];
462};
463
464// wrap foreign struct so we can legally supply equality operators and qHash:
465struct Q_D3D12_SAMPLER_DESC
466{
467 D3D12_SAMPLER_DESC desc;
468
469 friend bool operator==(const Q_D3D12_SAMPLER_DESC &lhs, const Q_D3D12_SAMPLER_DESC &rhs) noexcept
470 {
471 return lhs.desc.Filter == rhs.desc.Filter
472 && lhs.desc.AddressU == rhs.desc.AddressU
473 && lhs.desc.AddressV == rhs.desc.AddressV
474 && lhs.desc.AddressW == rhs.desc.AddressW
475 && lhs.desc.MipLODBias == rhs.desc.MipLODBias
476 && lhs.desc.MaxAnisotropy == rhs.desc.MaxAnisotropy
477 && lhs.desc.ComparisonFunc == rhs.desc.ComparisonFunc
478 // BorderColor is never used, skip it
479 && lhs.desc.MinLOD == rhs.desc.MinLOD
480 && lhs.desc.MaxLOD == rhs.desc.MaxLOD;
481 }
482
483 friend bool operator!=(const Q_D3D12_SAMPLER_DESC &lhs, const Q_D3D12_SAMPLER_DESC &rhs) noexcept
484 {
485 return !(lhs == rhs);
486 }
487
488 friend size_t qHash(const Q_D3D12_SAMPLER_DESC &key, size_t seed = 0) noexcept
489 {
491 seed = hash(seed, key.desc.Filter);
492 seed = hash(seed, key.desc.AddressU);
493 seed = hash(seed, key.desc.AddressV);
494 seed = hash(seed, key.desc.AddressW);
495 seed = hash(seed, key.desc.MipLODBias);
496 seed = hash(seed, key.desc.MaxAnisotropy);
497 seed = hash(seed, key.desc.ComparisonFunc);
498 // BorderColor is never used, skip it
499 seed = hash(seed, key.desc.MinLOD);
500 seed = hash(seed, key.desc.MaxLOD);
501 return seed;
502 }
503};
504
505struct QD3D12SamplerManager
506{
507 const quint32 MAX_SAMPLERS = 512;
508
509 bool create(ID3D12Device *device);
510 void destroy();
511
512 QD3D12Descriptor getShaderVisibleDescriptor(const D3D12_SAMPLER_DESC &desc);
513
514 ID3D12Device *device = nullptr;
515 QD3D12ShaderVisibleDescriptorHeap shaderVisibleSamplerHeap;
517};
518
519enum QD3D12Stage { VS = 0, HS, DS, GS, PS, CS };
520
521static inline QD3D12Stage qd3d12_stage(QRhiShaderStage::Type type)
522{
523 switch (type) {
525 return VS;
527 return HS;
529 return DS;
531 return GS;
533 return PS;
535 return CS;
536 }
537 Q_UNREACHABLE_RETURN(VS);
538}
539
540static inline D3D12_SHADER_VISIBILITY qd3d12_stageToVisibility(QD3D12Stage s)
541{
542 switch (s) {
543 case VS:
544 return D3D12_SHADER_VISIBILITY_VERTEX;
545 case HS:
546 return D3D12_SHADER_VISIBILITY_HULL;
547 case DS:
548 return D3D12_SHADER_VISIBILITY_DOMAIN;
549 case GS:
550 return D3D12_SHADER_VISIBILITY_GEOMETRY;
551 case PS:
552 return D3D12_SHADER_VISIBILITY_PIXEL;
553 case CS:
554 return D3D12_SHADER_VISIBILITY_ALL;
555 }
556 Q_UNREACHABLE_RETURN(D3D12_SHADER_VISIBILITY_ALL);
557}
558
559static inline QRhiShaderResourceBinding::StageFlag qd3d12_stageToSrb(QD3D12Stage s)
560{
561 switch (s) {
562 case VS:
564 case HS:
566 case DS:
568 case GS:
570 case PS:
572 case CS:
574 }
575 Q_UNREACHABLE_RETURN(QRhiShaderResourceBinding::VertexStage);
576}
577
578struct QD3D12ShaderStageData
579{
580 bool valid = false; // to allow simple arrays where unused stages are indicated by !valid
581 QD3D12Stage stage = VS;
582 QShader::NativeResourceBindingMap nativeResourceBindingMap;
583};
584
585struct QD3D12ShaderResourceBindings;
586
587struct QD3D12ShaderResourceVisitor
588{
589 enum StorageOp { Load = 0, Store, LoadStore };
590
591 QD3D12ShaderResourceVisitor(const QD3D12ShaderResourceBindings *srb,
592 const QD3D12ShaderStageData *stageData,
593 int stageCount)
594 : srb(srb),
595 stageData(stageData),
596 stageCount(stageCount)
597 {
598 }
599
600 std::function<void(QD3D12Stage, const QRhiShaderResourceBinding::Data::UniformBufferData &, int, int)> uniformBuffer = nullptr;
601 std::function<void(QD3D12Stage, const QRhiShaderResourceBinding::TextureAndSampler &, int)> texture = nullptr;
602 std::function<void(QD3D12Stage, const QRhiShaderResourceBinding::TextureAndSampler &, int)> sampler = nullptr;
603 std::function<void(QD3D12Stage, const QRhiShaderResourceBinding::Data::StorageImageData &, StorageOp, int)> storageImage = nullptr;
604 std::function<void(QD3D12Stage, const QRhiShaderResourceBinding::Data::StorageBufferData &, StorageOp, int)> storageBuffer = nullptr;
605
606 void visit();
607
608 const QD3D12ShaderResourceBindings *srb;
609 const QD3D12ShaderStageData *stageData;
610 int stageCount;
611};
612
613struct QD3D12Readback
614{
615 // common
616 int frameSlot = -1;
617 QRhiReadbackResult *result = nullptr;
618 QD3D12StagingArea staging;
619 quint32 byteSize = 0;
620 // textures
621 quint32 bytesPerLine = 0;
622 QSize pixelSize;
624 quint32 stagingRowPitch = 0;
625};
626
627struct QD3D12MipmapGenerator
628{
629 bool create(QRhiD3D12 *rhiD);
630 void destroy();
631 void generate(QD3D12CommandBuffer *cbD, const QD3D12ObjectHandle &textureHandle);
632
633 QRhiD3D12 *rhiD;
634 QD3D12ObjectHandle rootSigHandle;
635 QD3D12ObjectHandle pipelineHandle;
636};
637
638struct QD3D12MemoryAllocator
639{
640 bool create(ID3D12Device *device, IDXGIAdapter1 *adapter);
641 void destroy();
642
643 HRESULT createResource(D3D12_HEAP_TYPE heapType,
644 const D3D12_RESOURCE_DESC *resourceDesc,
645 D3D12_RESOURCE_STATES initialState,
646 const D3D12_CLEAR_VALUE *optimizedClearValue,
647 D3D12MA::Allocation **maybeAllocation,
648 REFIID riidResource,
649 void **ppvResource);
650
651 void getBudget(D3D12MA::Budget *localBudget, D3D12MA::Budget *nonLocalBudget);
652
653 bool isUsingD3D12MA() const { return allocator != nullptr; }
654
655 ID3D12Device *device = nullptr;
656 D3D12MA::Allocator *allocator = nullptr;
657};
658
659struct QD3D12Buffer : public QRhiBuffer
660{
661 QD3D12Buffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size);
662 ~QD3D12Buffer();
663
664 void destroy() override;
665 bool create() override;
669
670 void executeHostWritesForFrameSlot(int frameSlot);
671
672 QD3D12ObjectHandle handles[QD3D12_FRAMES_IN_FLIGHT] = {};
673 struct HostWrite {
676 };
677 QVarLengthArray<HostWrite, 16> pendingHostWrites[QD3D12_FRAMES_IN_FLIGHT];
678 friend class QRhiD3D12;
679};
680
681struct QD3D12RenderBuffer : public QRhiRenderBuffer
682{
683 QD3D12RenderBuffer(QRhiImplementation *rhi,
684 Type type,
685 const QSize &pixelSize,
686 int sampleCount,
687 Flags flags,
688 QRhiTexture::Format backingFormatHint);
689 ~QD3D12RenderBuffer();
690 void destroy() override;
691 bool create() override;
692 QRhiTexture::Format backingFormat() const override;
693
694 static const DXGI_FORMAT DS_FORMAT = DXGI_FORMAT_D24_UNORM_S8_UINT;
695
696 QD3D12ObjectHandle handle;
697 QD3D12Descriptor rtv;
698 QD3D12Descriptor dsv;
699 DXGI_FORMAT dxgiFormat;
700 DXGI_SAMPLE_DESC sampleDesc;
701 uint generation = 0;
702 friend class QRhiD3D12;
703};
704
705struct QD3D12Texture : public QRhiTexture
706{
707 QD3D12Texture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth,
708 int arraySize, int sampleCount, Flags flags);
709 ~QD3D12Texture();
710 void destroy() override;
711 bool create() override;
712 bool createFrom(NativeTexture src) override;
713 NativeTexture nativeTexture() override;
714 void setNativeLayout(int layout) override;
715
716 bool prepareCreate(QSize *adjustedSize = nullptr);
717 bool finishCreate();
718
719 QD3D12ObjectHandle handle;
720 QD3D12Descriptor srv;
721 DXGI_FORMAT dxgiFormat;
722 uint mipLevelCount;
723 DXGI_SAMPLE_DESC sampleDesc;
724 uint generation = 0;
725 friend class QRhiD3D12;
726};
727
728struct QD3D12Sampler : public QRhiSampler
729{
730 QD3D12Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
731 AddressMode u, AddressMode v, AddressMode w);
732 ~QD3D12Sampler();
733 void destroy() override;
734 bool create() override;
735
736 QD3D12Descriptor lookupOrCreateShaderVisibleDescriptor();
737
738 D3D12_SAMPLER_DESC desc = {};
739 QD3D12Descriptor shaderVisibleDescriptor;
740};
741
742struct QD3D12RenderPassDescriptor : public QRhiRenderPassDescriptor
743{
744 QD3D12RenderPassDescriptor(QRhiImplementation *rhi);
745 ~QD3D12RenderPassDescriptor();
746 void destroy() override;
747 bool isCompatible(const QRhiRenderPassDescriptor *other) const override;
749 QVector<quint32> serializedFormat() const override;
750
751 void updateSerializedFormat();
752
753 static const int MAX_COLOR_ATTACHMENTS = 8;
754 int colorAttachmentCount = 0;
755 bool hasDepthStencil = false;
756 int colorFormat[MAX_COLOR_ATTACHMENTS];
757 int dsFormat;
758 QVector<quint32> serializedFormatData;
759};
760
761struct QD3D12RenderTargetData
762{
763 QD3D12RenderTargetData(QRhiImplementation *) { }
764
765 QD3D12RenderPassDescriptor *rp = nullptr;
766 QSize pixelSize;
767 float dpr = 1;
768 int sampleCount = 1;
769 int colorAttCount = 0;
770 int dsAttCount = 0;
772 static const int MAX_COLOR_ATTACHMENTS = QD3D12RenderPassDescriptor::MAX_COLOR_ATTACHMENTS;
773 D3D12_CPU_DESCRIPTOR_HANDLE rtv[MAX_COLOR_ATTACHMENTS];
774 D3D12_CPU_DESCRIPTOR_HANDLE dsv;
775};
776
777struct QD3D12SwapChainRenderTarget : public QRhiSwapChainRenderTarget
778{
779 QD3D12SwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain);
780 ~QD3D12SwapChainRenderTarget();
781 void destroy() override;
782
783 QSize pixelSize() const override;
784 float devicePixelRatio() const override;
785 int sampleCount() const override;
786
787 QD3D12RenderTargetData d;
788};
789
790struct QD3D12TextureRenderTarget : public QRhiTextureRenderTarget
791{
792 QD3D12TextureRenderTarget(QRhiImplementation *rhi,
794 Flags flags);
795 ~QD3D12TextureRenderTarget();
796 void destroy() override;
797
798 QSize pixelSize() const override;
799 float devicePixelRatio() const override;
800 int sampleCount() const override;
801
803 bool create() override;
804
805 QD3D12RenderTargetData d;
806 bool ownsRtv[QD3D12RenderTargetData::MAX_COLOR_ATTACHMENTS];
807 QD3D12Descriptor rtv[QD3D12RenderTargetData::MAX_COLOR_ATTACHMENTS];
808 bool ownsDsv = false;
809 QD3D12Descriptor dsv;
810 friend class QRhiD3D12;
811};
812
813struct QD3D12ShaderResourceBindings : public QRhiShaderResourceBindings
814{
815 QD3D12ShaderResourceBindings(QRhiImplementation *rhi);
816 ~QD3D12ShaderResourceBindings();
817 void destroy() override;
818 bool create() override;
819 void updateResources(UpdateFlags flags) override;
820
821 QD3D12ObjectHandle createRootSignature(const QD3D12ShaderStageData *stageData, int stageCount);
822
823 struct VisitorData {
825
826 D3D12_ROOT_PARAMETER1 srvTables[6] = {};
828 quint32 currentSrvRangeOffset[6] = {};
829
831 std::array<D3D12_DESCRIPTOR_RANGE1, 16> samplerRanges[6] = {};
832 int samplerRangeHeads[6] = {};
833
834 D3D12_ROOT_PARAMETER1 uavTables[6] = {};
836 quint32 currentUavRangeOffset[6] = {};
837 } visitorData;
838
839
840 void visitUniformBuffer(QD3D12Stage s,
842 int shaderRegister,
843 int binding);
844 void visitTexture(QD3D12Stage s,
846 int shaderRegister);
847 void visitSampler(QD3D12Stage s,
849 int shaderRegister);
850 void visitStorageBuffer(QD3D12Stage s,
852 QD3D12ShaderResourceVisitor::StorageOp op,
853 int shaderRegister);
854 void visitStorageImage(QD3D12Stage s,
856 QD3D12ShaderResourceVisitor::StorageOp op,
857 int shaderRegister);
858
860 bool hasDynamicOffset = false;
861 uint generation = 0;
862};
863
864struct QD3D12GraphicsPipeline : public QRhiGraphicsPipeline
865{
866 QD3D12GraphicsPipeline(QRhiImplementation *rhi);
867 ~QD3D12GraphicsPipeline();
868 void destroy() override;
869 bool create() override;
870
871 QD3D12ObjectHandle handle;
872 QD3D12ObjectHandle rootSigHandle;
873 std::array<QD3D12ShaderStageData, 5> stageData;
874 D3D12_PRIMITIVE_TOPOLOGY topology;
875 UINT viewInstanceMask = 0;
876 uint generation = 0;
877 friend class QRhiD3D12;
878};
879
880struct QD3D12ComputePipeline : public QRhiComputePipeline
881{
882 QD3D12ComputePipeline(QRhiImplementation *rhi);
883 ~QD3D12ComputePipeline();
884 void destroy() override;
885 bool create() override;
886
887 QD3D12ObjectHandle handle;
888 QD3D12ObjectHandle rootSigHandle;
889 QD3D12ShaderStageData stageData;
890 uint generation = 0;
891 friend class QRhiD3D12;
892};
893
894struct QD3D12CommandBuffer : public QRhiCommandBuffer
895{
896 QD3D12CommandBuffer(QRhiImplementation *rhi);
897 ~QD3D12CommandBuffer();
898 void destroy() override;
899
901
902 ID3D12GraphicsCommandList1 *cmdList = nullptr; // not owned
903 QRhiD3D12CommandBufferNativeHandles nativeHandlesStruct;
904
905 enum PassType {
906 NoPass,
907 RenderPass,
908 ComputePass
909 };
910
911 void resetState()
912 {
913 recordingPass = NoPass;
914 currentTarget = nullptr;
915
916 resetPerPassState();
917 }
918
919 void resetPerPassState()
920 {
921 currentGraphicsPipeline = nullptr;
922 currentComputePipeline = nullptr;
923 currentPipelineGeneration = 0;
924 currentGraphicsSrb = nullptr;
925 currentComputeSrb = nullptr;
926 currentSrbGeneration = 0;
927 currentIndexBuffer = {};
928 currentIndexOffset = 0;
929 currentIndexFormat = DXGI_FORMAT_R16_UINT;
930 currentVertexBuffers = {};
931 currentVertexOffsets = {};
932 }
933
934 PassType recordingPass;
935 QRhiRenderTarget *currentTarget;
936
937 QD3D12GraphicsPipeline *currentGraphicsPipeline;
938 QD3D12ComputePipeline *currentComputePipeline;
939 uint currentPipelineGeneration;
940 QRhiShaderResourceBindings *currentGraphicsSrb;
941 QRhiShaderResourceBindings *currentComputeSrb;
942 uint currentSrbGeneration;
943 QD3D12ObjectHandle currentIndexBuffer;
944 quint32 currentIndexOffset;
945 DXGI_FORMAT currentIndexFormat;
946 std::array<QD3D12ObjectHandle, D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT> currentVertexBuffers;
947 std::array<quint32, D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT> currentVertexOffsets;
948};
949
950struct QD3D12SwapChain : public QRhiSwapChain
951{
952 QD3D12SwapChain(QRhiImplementation *rhi);
953 ~QD3D12SwapChain();
954 void destroy() override;
955
958
959 QSize surfacePixelSize() override;
960 bool isFormatSupported(Format f) override;
961 QRhiSwapChainHdrInfo hdrInfo() override;
962
964 bool createOrResize() override;
965
966 void releaseBuffers();
967 void waitCommandCompletionForFrameSlot(int frameSlot);
968 void addCommandCompletionSignalForCurrentFrameSlot();
969 void chooseFormats();
970
971 QWindow *window = nullptr;
972 IDXGISwapChain1 *sourceSwapChain1 = nullptr;
973 IDXGISwapChain3 *swapChain = nullptr;
974 QSize pixelSize;
975 UINT swapInterval = 1;
976 UINT swapChainFlags = 0;
977 DXGI_FORMAT colorFormat;
978 DXGI_FORMAT srgbAdjustedColorFormat;
979 DXGI_COLOR_SPACE_TYPE hdrColorSpace;
980 IDCompositionTarget *dcompTarget = nullptr;
981 IDCompositionVisual *dcompVisual = nullptr;
982 static const UINT BUFFER_COUNT = 3;
983 QD3D12ObjectHandle colorBuffers[BUFFER_COUNT];
984 QD3D12Descriptor rtvs[BUFFER_COUNT];
985 DXGI_SAMPLE_DESC sampleDesc;
986 QD3D12ObjectHandle msaaBuffers[BUFFER_COUNT];
987 QD3D12Descriptor msaaRtvs[BUFFER_COUNT];
988 QD3D12RenderBuffer *ds = nullptr;
989 UINT currentBackBufferIndex = 0;
990 QD3D12SwapChainRenderTarget rtWrapper;
991 QD3D12CommandBuffer cbWrapper;
992
993 struct FrameResources {
994 ID3D12Fence *fence = nullptr;
995 HANDLE fenceEvent = nullptr;
996 UINT64 fenceCounter = 0;
997 ID3D12GraphicsCommandList1 *cmdList = nullptr;
998 } frameRes[QD3D12_FRAMES_IN_FLIGHT];
999
1000 int currentFrameSlot = 0; // index in frameRes
1001};
1002
1003template<typename T, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE Type>
1004struct alignas(void*) QD3D12PipelineStateSubObject
1005{
1006 D3D12_PIPELINE_STATE_SUBOBJECT_TYPE type = Type;
1007 T object = {};
1008};
1009
1010class QRhiD3D12 : public QRhiImplementation
1011{
1012public:
1013 // 16MB * QD3D12_FRAMES_IN_FLIGHT; buffer and texture upload staging data that
1014 // gets no space from this will get their own temporary staging areas.
1015 static const quint32 SMALL_STAGING_AREA_BYTES_PER_FRAME = 16 * 1024 * 1024;
1016
1017 static const quint32 SHADER_VISIBLE_CBV_SRV_UAV_HEAP_PER_FRAME_START_SIZE = 16384;
1018
1019 QRhiD3D12(QRhiD3D12InitParams *params, QRhiD3D12NativeHandles *importDevice = nullptr);
1020
1021 bool create(QRhi::Flags flags) override;
1022 void destroy() override;
1023
1028 QRhiBuffer::UsageFlags usage,
1029 quint32 size) override;
1031 const QSize &pixelSize,
1032 int sampleCount,
1033 QRhiRenderBuffer::Flags flags,
1034 QRhiTexture::Format backingFormatHint) override;
1036 const QSize &pixelSize,
1037 int depth,
1038 int arraySize,
1039 int sampleCount,
1040 QRhiTexture::Flags flags) override;
1042 QRhiSampler::Filter minFilter,
1043 QRhiSampler::Filter mipmapMode,
1046 QRhiSampler::AddressMode w) override;
1047
1049 QRhiTextureRenderTarget::Flags flags) override;
1050
1051 QRhiSwapChain *createSwapChain() override;
1052 QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) override;
1053 QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) override;
1054 QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) override;
1055 QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) override;
1056 QRhi::FrameOpResult finish() override;
1057
1058 void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
1059
1061 QRhiRenderTarget *rt,
1062 const QColor &colorClearValue,
1063 const QRhiDepthStencilClearValue &depthStencilClearValue,
1064 QRhiResourceUpdateBatch *resourceUpdates,
1065 QRhiCommandBuffer::BeginPassFlags flags) override;
1066 void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
1067
1069 QRhiGraphicsPipeline *ps) override;
1070
1073 int dynamicOffsetCount,
1074 const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) override;
1075
1077 int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings,
1078 QRhiBuffer *indexBuf, quint32 indexOffset,
1079 QRhiCommandBuffer::IndexFormat indexFormat) override;
1080
1081 void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override;
1082 void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override;
1083 void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) override;
1084 void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override;
1085
1086 void draw(QRhiCommandBuffer *cb, quint32 vertexCount,
1087 quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override;
1088
1089 void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
1090 quint32 instanceCount, quint32 firstIndex,
1091 qint32 vertexOffset, quint32 firstInstance) override;
1092
1093 void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override;
1094 void debugMarkEnd(QRhiCommandBuffer *cb) override;
1095 void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override;
1096
1098 QRhiResourceUpdateBatch *resourceUpdates,
1099 QRhiCommandBuffer::BeginPassFlags flags) override;
1100 void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
1102 void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) override;
1103
1105 void beginExternal(QRhiCommandBuffer *cb) override;
1106 void endExternal(QRhiCommandBuffer *cb) override;
1107 double lastCompletedGpuTime(QRhiCommandBuffer *cb) override;
1108
1109 QList<int> supportedSampleCounts() const override;
1110 int ubufAlignment() const override;
1111 bool isYUpInFramebuffer() const override;
1112 bool isYUpInNDC() const override;
1113 bool isClipDepthZeroToOne() const override;
1114 QMatrix4x4 clipSpaceCorrMatrix() const override;
1115 bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override;
1116 bool isFeatureSupported(QRhi::Feature feature) const override;
1117 int resourceLimit(QRhi::ResourceLimit limit) const override;
1118 const QRhiNativeHandles *nativeHandles() override;
1119 QRhiDriverInfo driverInfo() const override;
1120 QRhiStats statistics() override;
1122 void releaseCachedResources() override;
1123 bool isDeviceLost() const override;
1124
1125 QByteArray pipelineCacheData() override;
1126 void setPipelineCacheData(const QByteArray &data) override;
1127
1128 void waitGpu();
1129 DXGI_SAMPLE_DESC effectiveSampleCount(int sampleCount, DXGI_FORMAT format) const;
1130 bool ensureDirectCompositionDevice();
1131 bool startCommandListForCurrentFrameSlot(ID3D12GraphicsCommandList1 **cmdList);
1132 void enqueueResourceUpdates(QD3D12CommandBuffer *cbD, QRhiResourceUpdateBatch *resourceUpdates);
1133 void finishActiveReadbacks(bool forced = false);
1134 bool ensureShaderVisibleDescriptorHeapCapacity(QD3D12ShaderVisibleDescriptorHeap *h,
1135 D3D12_DESCRIPTOR_HEAP_TYPE type,
1136 int frameSlot,
1137 quint32 neededDescriptorCount,
1138 bool *gotNew);
1139 void bindShaderVisibleHeaps(QD3D12CommandBuffer *cbD);
1140
1141 bool debugLayer = false;
1142 ID3D12Device2 *dev = nullptr;
1143 D3D_FEATURE_LEVEL minimumFeatureLevel = D3D_FEATURE_LEVEL(0);
1144 LUID adapterLuid = {};
1145 bool importedDevice = false;
1146 bool importedCommandQueue = false;
1147 QRhi::Flags rhiFlags;
1148 IDXGIFactory2 *dxgiFactory = nullptr;
1149 bool supportsAllowTearing = false;
1150 IDXGIAdapter1 *activeAdapter = nullptr;
1151 QRhiDriverInfo driverInfoStruct;
1152 QRhiD3D12NativeHandles nativeHandlesStruct;
1153 bool deviceLost = false;
1154 ID3D12CommandQueue *cmdQueue = nullptr;
1155 ID3D12Fence *fullFence = nullptr;
1156 HANDLE fullFenceEvent = nullptr;
1157 UINT64 fullFenceCounter = 0;
1158 ID3D12CommandAllocator *cmdAllocators[QD3D12_FRAMES_IN_FLIGHT] = {};
1159 QD3D12MemoryAllocator vma;
1160 QD3D12CpuDescriptorPool rtvPool;
1161 QD3D12CpuDescriptorPool dsvPool;
1162 QD3D12CpuDescriptorPool cbvSrvUavPool;
1163 QD3D12ObjectPool<QD3D12Resource> resourcePool;
1164 QD3D12ObjectPool<QD3D12Pipeline> pipelinePool;
1165 QD3D12ObjectPool<QD3D12RootSignature> rootSignaturePool;
1166 QD3D12ReleaseQueue releaseQueue;
1167 QD3D12ResourceBarrierGenerator barrierGen;
1168 QD3D12SamplerManager samplerMgr;
1169 QD3D12MipmapGenerator mipmapGen;
1170 QD3D12StagingArea smallStagingAreas[QD3D12_FRAMES_IN_FLIGHT];
1171 QD3D12ShaderVisibleDescriptorHeap shaderVisibleCbvSrvUavHeap;
1172 IDCompositionDevice *dcompDevice = nullptr;
1173 QD3D12SwapChain *currentSwapChain = nullptr;
1174 QSet<QD3D12SwapChain *> swapchains;
1175 QD3D12ShaderBytecodeCache shaderBytecodeCache;
1176 QVarLengthArray<QD3D12Readback, 4> activeReadbacks;
1177 bool offscreenActive = false;
1178 QD3D12CommandBuffer *offscreenCb[QD3D12_FRAMES_IN_FLIGHT] = {};
1179
1180 struct VisitorData {
1185 } visitorData;
1186
1187 void visitUniformBuffer(QD3D12Stage s,
1189 int shaderRegister,
1190 int binding,
1191 int dynamicOffsetCount,
1192 const QRhiCommandBuffer::DynamicOffset *dynamicOffsets);
1193 void visitTexture(QD3D12Stage s,
1195 int shaderRegister);
1196 void visitSampler(QD3D12Stage s,
1198 int shaderRegister);
1199 void visitStorageBuffer(QD3D12Stage s,
1201 QD3D12ShaderResourceVisitor::StorageOp op,
1202 int shaderRegister);
1203 void visitStorageImage(QD3D12Stage s,
1205 QD3D12ShaderResourceVisitor::StorageOp op,
1206 int shaderRegister);
1207
1208 struct {
1209 bool multiView = false;
1210 } caps;
1211};
1212
1214
1215#endif // __ID3D12Device2_INTERFACE_DEFINED__
1216
1217#endif
IOBluetoothDevice * device
\inmodule QtCore
Definition qbitarray.h:13
\inmodule QtCore
Definition qbytearray.h:57
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
Definition qhash.h:818
Definition qlist.h:74
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
\inmodule QtGui
Definition qrhi.h:834
virtual char * beginFullDynamicBufferUpdateForCurrentFrame()
Definition qrhi.cpp:3844
Type
Specifies storage type of buffer resource.
Definition qrhi.h:836
virtual void endFullDynamicBufferUpdateForCurrentFrame()
To be called when the entire contents of the buffer data has been updated in the memory block returne...
Definition qrhi.cpp:3854
virtual NativeBuffer nativeBuffer()
Definition qrhi.cpp:3805
virtual bool create()=0
Creates the corresponding native graphics resources.
\inmodule QtGui
Definition qrhi.h:1614
QPair< QRhiBuffer *, quint32 > VertexInput
Synonym for QPair<QRhiBuffer *, quint32>.
Definition qrhi.h:1643
const QRhiNativeHandles * nativeHandles()
Definition qrhi.cpp:9467
QPair< int, quint32 > DynamicOffset
Synonym for QPair<int, quint32>.
Definition qrhi.h:1639
IndexFormat
Specifies the index data type.
Definition qrhi.h:1616
\inmodule QtGui
Definition qrhi.h:1585
virtual bool create()=0
\inmodule QtGui
Definition qrhi.h:44
\inmodule QtGui
Definition qrhi.h:1241
virtual bool create()=0
Creates the corresponding native graphics resources.
Topology topology() const
Definition qrhi.h:1360
virtual bool isClipDepthZeroToOne() const =0
virtual void endExternal(QRhiCommandBuffer *cb)=0
virtual QRhiTextureRenderTarget * createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags)=0
virtual QRhiComputePipeline * createComputePipeline()=0
virtual QRhiGraphicsPipeline * createGraphicsPipeline()=0
virtual void beginPass(QRhiCommandBuffer *cb, QRhiRenderTarget *rt, const QColor &colorClearValue, const QRhiDepthStencilClearValue &depthStencilClearValue, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags)=0
virtual void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps)=0
virtual void releaseCachedResources()=0
virtual bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const =0
virtual QRhiDriverInfo driverInfo() const =0
virtual QRhiSampler * createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter, QRhiSampler::Filter mipmapMode, QRhiSampler::AddressMode u, QRhiSampler::AddressMode v, QRhiSampler::AddressMode w)=0
virtual QRhiTexture * createTexture(QRhiTexture::Format format, const QSize &pixelSize, int depth, int arraySize, int sampleCount, QRhiTexture::Flags flags)=0
virtual bool isYUpInFramebuffer() const =0
virtual QList< int > supportedSampleCounts() const =0
virtual void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)=0
virtual void debugMarkEnd(QRhiCommandBuffer *cb)=0
virtual QRhi::FrameOpResult finish()=0
virtual QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags)=0
virtual void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)=0
virtual int ubufAlignment() const =0
virtual QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags)=0
virtual void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)=0
virtual void beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags)=0
virtual void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c)=0
virtual void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name)=0
virtual int resourceLimit(QRhi::ResourceLimit limit) const =0
virtual void setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBindings *srb, int dynamicOffsetCount, const QRhiCommandBuffer::DynamicOffset *dynamicOffsets)=0
virtual void setPipelineCacheData(const QByteArray &data)=0
virtual QRhiBuffer * createBuffer(QRhiBuffer::Type type, QRhiBuffer::UsageFlags usage, quint32 size)=0
virtual bool isDeviceLost() const =0
virtual void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport)=0
virtual void beginExternal(QRhiCommandBuffer *cb)=0
virtual QMatrix4x4 clipSpaceCorrMatrix() const =0
virtual void dispatch(QRhiCommandBuffer *cb, int x, int y, int z)=0
virtual bool makeThreadLocalNativeContextCurrent()=0
virtual void setVertexInput(QRhiCommandBuffer *cb, int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings, QRhiBuffer *indexBuf, quint32 indexOffset, QRhiCommandBuffer::IndexFormat indexFormat)=0
virtual QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags)=0
virtual void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue)=0
virtual void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg)=0
virtual double lastCompletedGpuTime(QRhiCommandBuffer *cb)=0
virtual QRhiRenderBuffer * createRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount, QRhiRenderBuffer::Flags flags, QRhiTexture::Format backingFormatHint)=0
virtual bool isYUpInNDC() const =0
virtual void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, quint32 instanceCount, quint32 firstIndex, qint32 vertexOffset, quint32 firstInstance)=0
virtual QRhiShaderResourceBindings * createShaderResourceBindings()=0
virtual bool isFeatureSupported(QRhi::Feature feature) const =0
virtual void setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline *ps)=0
virtual void draw(QRhiCommandBuffer *cb, quint32 vertexCount, quint32 instanceCount, quint32 firstVertex, quint32 firstInstance)=0
virtual void destroy()=0
virtual QByteArray pipelineCacheData()=0
virtual QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags)=0
virtual QRhiStats statistics()=0
virtual void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor)=0
virtual QRhiSwapChain * createSwapChain()=0
virtual const QRhiNativeHandles * nativeHandles()=0
\inmodule QtGui
Definition qrhi.h:1071
virtual QRhiTexture::Format backingFormat() const =0
Type
Specifies the type of the renderbuffer.
Definition qrhi.h:1073
virtual bool create()=0
Creates the corresponding native graphics resources.
\inmodule QtGui
Definition qrhi.h:1119
virtual QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() const =0
virtual bool isCompatible(const QRhiRenderPassDescriptor *other) const =0
virtual QVector< quint32 > serializedFormat() const =0
\inmodule QtGui
Definition qrhi.h:1135
virtual QSize pixelSize() const =0
virtual int sampleCount() const =0
virtual float devicePixelRatio() const =0
\inmodule QtGui
Definition qrhi.h:1694
virtual void destroy()=0
Releases (or requests deferred releasing of) the underlying native graphics resources.
\inmodule QtGui
Definition qrhi.h:1007
virtual bool create()=0
Filter
Specifies the minification, magnification, or mipmap filtering.
Definition qrhi.h:1009
AddressMode
Specifies the addressing mode.
Definition qrhi.h:1015
\inmodule QtGui
Definition qrhi.h:138
StageFlag
Flag values to indicate which stages the shader resource is visible in.
Definition qrhi.h:446
\inmodule QtGui
Definition qrhi.h:1190
virtual void updateResources(UpdateFlags flags={})=0
virtual bool create()=0
\inmodule QtGui
Definition qrhi.h:371
Type
Specifies the type of the shader stage.
Definition qrhi.h:373
@ TessellationControl
Definition qrhi.h:375
@ TessellationEvaluation
Definition qrhi.h:376
\inmodule QtGui
Definition qrhi.h:1150
\inmodule QtGui
Definition qrhi.h:1513
virtual QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor()=0
virtual bool createOrResize()=0
Creates the swapchain if not already done and resizes the swapchain buffers to match the current size...
virtual QRhiRenderTarget * currentFrameRenderTarget()=0
virtual QSize surfacePixelSize()=0
virtual bool isFormatSupported(Format f)=0
virtual QRhiCommandBuffer * currentFrameCommandBuffer()=0
virtual QRhiSwapChainHdrInfo hdrInfo()
\variable QRhiSwapChainHdrInfo::isHardCodedDefaults
Definition qrhi.cpp:7479
\inmodule QtGui
Definition qrhi.h:1161
virtual QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor()=0
virtual bool create()=0
Creates the corresponding native graphics resources.
\inmodule QtGui
Definition qrhi.h:883
virtual bool create()=0
Creates the corresponding native graphics resources.
Format
Specifies the texture format.
Definition qrhi.h:902
@ UnknownFormat
Definition qrhi.h:903
virtual void setNativeLayout(int layout)
With some graphics APIs, such as Vulkan, integrating custom rendering code that uses the graphics API...
Definition qrhi.cpp:4390
virtual bool createFrom(NativeTexture src)
Similar to create(), except that no new native textures are created.
Definition qrhi.cpp:4361
virtual NativeTexture nativeTexture()
Definition qrhi.cpp:4328
\inmodule QtGui
Definition qrhi.h:85
ResourceLimit
Describes the resource limit to query.
Definition qrhi.h:1846
Feature
Flag values to indicate what features are supported by the backend currently in use.
Definition qrhi.h:1793
FrameOpResult
Describes the result of operations that can have a soft failure.
Definition qrhi.h:1786
Definition qset.h:18
\inmodule QtCore
Definition qsize.h:25
\inmodule QtGui
Definition qwindow.h:63
Format
Definition ddsheader.h:14
QHash< int, QWidget * > hash
[35multi]
QMap< QString, QString > map
[6]
else opt state
[0]
@ Views
Definition qtsqlglobal.h:39
Combined button and popup list for selecting options.
Q_ALWAYS_INLINE void fence()
bool isNull(const T &t)
void * HANDLE
std::pair< T1, T2 > QPair
constexpr bool operator!=(const timespec &t1, const timespec &t2)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
static QDBusError::ErrorType get(const char *name)
static int instanceCount
size_t qHash(const QFileSystemWatcherPathKey &key, size_t seed=0)
Flags
NSUInteger capacity
static QT_BEGIN_NAMESPACE const int BUFFER_COUNT
#define qWarning
Definition qlogging.h:162
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLuint64 GLenum void * handle
GLint GLint GLint GLint GLint x
[0]
GLint GLenum GLsizei GLsizei GLsizei depth
GLuint64 key
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLuint sampler
GLenum GLenum GLsizei count
GLuint object
[3]
GLfloat GLfloat f
GLenum src
GLenum GLuint buffer
GLenum type
GLbitfield flags
GLenum GLuint texture
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLuint name
GLint GLsizei GLsizei GLenum format
GLint y
GLfloat GLfloat GLfloat GLfloat h
void ** params
const GLubyte * c
GLint limit
GLuint * samplers
GLuint64EXT * result
[6]
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
GLenum GLenum colorFormat
GLsizeiptr const void GLenum usage
Definition qopenglext.h:543
static void add(QPainterPath &path, const QWingedEdge &list, int edge, QPathEdge::Traversal traversal)
QT_BEGIN_NAMESPACE typedef void(* Callback)(QQmlNotifierEndpoint *, void **)
static QT_BEGIN_NAMESPACE qreal dpr(const QWindow *w)
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1219
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
std::unique_ptr< ThunkPool::ThunkAllocation > allocation
Definition qstdweb.cpp:271
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
@ desc
unsigned int quint32
Definition qtypes.h:45
int qint32
Definition qtypes.h:44
unsigned int uint
Definition qtypes.h:29
unsigned char quint8
Definition qtypes.h:41
long HRESULT
settings remove("monkey")
QVBoxLayout * layout
sem release()
QQueue< int > queue
[0]
QSharedPointer< T > other(t)
[5]
view viewport() -> scroll(dx, dy, deviceRect)
aWidget window() -> setWindowTitle("New Window Title")
[2]
QAction * at
view create()
\inmodule QtGui
Definition qrhi.h:850
\inmodule QtGui
Definition qrhi.h:1722
\variable QRhiReadbackResult::completed
Definition qrhi.h:788
\inmodule QtGui
Definition qrhi.h:1686
\inmodule QtGui
Definition qrhi.h:1745
\inmodule QtGui
Definition qrhi.h:1482
Definition moc.h:24