27#include <d3d12sdklayers.h>
31#include "D3D12MemAlloc.h"
39#ifdef __ID3D12Device2_INTERFACE_DEFINED__
40#define QRHI_D3D12_AVAILABLE
44static const int QD3D12_FRAMES_IN_FLIGHT = 2;
48struct QD3D12Descriptor
50 D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle = {};
51 D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle = {};
53 bool isValid()
const {
return cpuHandle.ptr != 0; }
56struct QD3D12ReleaseQueue;
58struct QD3D12DescriptorHeap
60 bool isValid()
const {
return heap &&
capacity; }
63 D3D12_DESCRIPTOR_HEAP_TYPE heapType,
64 D3D12_DESCRIPTOR_HEAP_FLAGS heapFlags);
65 void createWithExisting(
const QD3D12DescriptorHeap &
other,
69 void destroyWithDeferredRelease(QD3D12ReleaseQueue *releaseQueue);
75 QD3D12Descriptor incremented(
const QD3D12Descriptor &descriptor,
quint32 offsetInDescriptors)
const
77 D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle = descriptor.cpuHandle;
78 cpuHandle.ptr += offsetInDescriptors * descriptorByteSize;
79 D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle = descriptor.gpuHandle;
81 gpuHandle.ptr += offsetInDescriptors * descriptorByteSize;
82 return { cpuHandle, gpuHandle };
85 ID3D12DescriptorHeap *heap =
nullptr;
87 QD3D12Descriptor heapStart;
90 D3D12_DESCRIPTOR_HEAP_TYPE heapType;
91 D3D12_DESCRIPTOR_HEAP_FLAGS heapFlags;
94struct QD3D12CpuDescriptorPool
96 bool isValid()
const {
return !heaps.isEmpty(); }
97 bool create(ID3D12Device *
device, D3D12_DESCRIPTOR_HEAP_TYPE heapType,
const char *debugName =
"");
103 static const int DESCRIPTORS_PER_HEAP = 256;
106 QD3D12DescriptorHeap heap;
108 static HeapWithMap
init(
const QD3D12DescriptorHeap &heap,
quint32 descriptorCount) {
111 result.map.resize(descriptorCount);
119 const char *debugName;
122struct QD3D12StagingArea
124 static const quint32 ALIGNMENT = D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT;
128 D3D12_GPU_VIRTUAL_ADDRESS gpuAddr = 0;
129 ID3D12Resource *
buffer =
nullptr;
131 bool isValid()
const {
return p !=
nullptr; }
134 bool isValid()
const {
return allocation && mem.isValid(); }
137 void destroyWithDeferredRelease(QD3D12ReleaseQueue *releaseQueue);
141 quint32 remainingCapacity()
const
148 return count * ((
size + ALIGNMENT - 1) & ~(ALIGNMENT - 1));
152 ID3D12Resource *resource =
nullptr;
158struct QD3D12ObjectHandle
164 bool isNull()
const {
return index == 0 && generation == 0; }
167inline bool operator==(
const QD3D12ObjectHandle &
a,
const QD3D12ObjectHandle &
b)
noexcept
169 return a.index ==
b.index &&
a.generation ==
b.generation;
172inline bool operator!=(
const QD3D12ObjectHandle &
a,
const QD3D12ObjectHandle &
b)
noexcept
178struct QD3D12ObjectPool
180 void create(
const char *debugName =
"")
182 this->debugName = debugName;
190 if (
d.object.has_value()) {
192 d.object->releaseResources();
198 static bool leakCheck =
true;
205 qWarning(
"QD3D12ObjectPool::destroy(): Pool %p '%s' had %d unreleased objects",
206 this, debugName, leakCount);
211 bool isValid(
const QD3D12ObjectHandle &
handle)
const
220 T lookup(
const QD3D12ObjectHandle &
handle)
const
225 const T *lookupRef(
const QD3D12ObjectHandle &
handle)
const
230 T *lookupRef(
const QD3D12ObjectHandle &
handle)
235 QD3D12ObjectHandle
add(
const T &
object)
248 return {
index, generation };
257 if (T *
object = lookupRef(
handle)) {
258 object->releaseResources();
263 const char *debugName;
273 ID3D12Resource *resource;
274 D3D12_RESOURCE_STATES
state;
275 D3D12_RESOURCE_DESC
desc;
278 enum { UavUsageRead = 0x01, UavUsageWrite = 0x02 };
284 static QD3D12ObjectHandle addToPool(QD3D12ObjectPool<QD3D12Resource> *
pool,
285 ID3D12Resource *resource,
286 D3D12_RESOURCE_STATES
state,
288 void *cpuMapPtr =
nullptr)
291 return pool->add({ resource,
state, resource->GetDesc(),
allocation, cpuMapPtr, 0,
true });
295 static QD3D12ObjectHandle addNonOwningToPool(QD3D12ObjectPool<QD3D12Resource> *
pool,
296 ID3D12Resource *resource,
297 D3D12_RESOURCE_STATES
state)
300 return pool->add({ resource,
state, resource->GetDesc(),
nullptr,
nullptr, 0,
false });
303 void releaseResources()
321 ID3D12PipelineState *pso;
323 static QD3D12ObjectHandle addToPool(QD3D12ObjectPool<QD3D12Pipeline> *
pool,
325 ID3D12PipelineState *pso)
330 void releaseResources()
336struct QD3D12RootSignature
338 ID3D12RootSignature *rootSig;
340 static QD3D12ObjectHandle addToPool(QD3D12ObjectPool<QD3D12RootSignature> *
pool,
341 ID3D12RootSignature *rootSig)
343 return pool->add({ rootSig });
346 void releaseResources()
352struct QD3D12ReleaseQueue
354 void create(QD3D12ObjectPool<QD3D12Resource> *resourcePool,
355 QD3D12ObjectPool<QD3D12Pipeline> *pipelinePool,
356 QD3D12ObjectPool<QD3D12RootSignature> *rootSignaturePool)
358 this->resourcePool = resourcePool;
359 this->pipelinePool = pipelinePool;
360 this->rootSignaturePool = rootSignaturePool;
363 void deferredReleaseResource(
const QD3D12ObjectHandle &
handle);
364 void deferredReleaseResourceWithViews(
const QD3D12ObjectHandle &
handle,
365 QD3D12CpuDescriptorPool *
pool,
366 const QD3D12Descriptor &viewsStart,
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,
373 void deferredReleaseDescriptorHeap(ID3D12DescriptorHeap *heap);
374 void deferredReleaseViews(QD3D12CpuDescriptorPool *
pool,
375 const QD3D12Descriptor &viewsStart,
378 void activatePendingDeferredReleaseRequests(
int frameSlot);
379 void executeDeferredReleases(
int frameSlot,
bool forced =
false);
382 struct DeferredReleaseEntry {
388 ResourceAndAllocation,
393 std::optional<int> frameSlotToBeReleasedIn;
394 QD3D12ObjectHandle
handle;
395 QD3D12CpuDescriptorPool *poolForViews =
nullptr;
396 QD3D12Descriptor viewsStart;
398 std::function<
void(
void*)> callback =
nullptr;
399 void *callbackUserData =
nullptr;
401 ID3D12DescriptorHeap *descriptorHeap =
nullptr;
404 QD3D12ObjectPool<QD3D12Resource> *resourcePool =
nullptr;
405 QD3D12ObjectPool<QD3D12Pipeline> *pipelinePool =
nullptr;
406 QD3D12ObjectPool<QD3D12RootSignature> *rootSignaturePool =
nullptr;
409struct QD3D12CommandBuffer;
411struct QD3D12ResourceBarrierGenerator
413 static const int PREALLOC = 16;
415 void create(QD3D12ObjectPool<QD3D12Resource> *resourcePool)
417 this->resourcePool = resourcePool;
420 void addTransitionBarrier(
const QD3D12ObjectHandle &resourceHandle, D3D12_RESOURCE_STATES stateAfter);
421 void enqueueBufferedTransitionBarriers(QD3D12CommandBuffer *cbD);
422 void enqueueSubresourceTransitionBarrier(QD3D12CommandBuffer *cbD,
423 const QD3D12ObjectHandle &resourceHandle,
425 D3D12_RESOURCE_STATES stateBefore,
426 D3D12_RESOURCE_STATES stateAfter);
427 void enqueueUavBarrier(QD3D12CommandBuffer *cbD,
const QD3D12ObjectHandle &resourceHandle);
429 struct TransitionResourceBarrier {
430 QD3D12ObjectHandle resourceHandle;
431 D3D12_RESOURCE_STATES stateBefore;
432 D3D12_RESOURCE_STATES stateAfter;
435 QD3D12ObjectPool<QD3D12Resource> *resourcePool =
nullptr;
438struct QD3D12ShaderBytecodeCache
443 : bytecode(bytecode), nativeResourceBindingMap(rbm)
454struct QD3D12ShaderVisibleDescriptorHeap
458 void destroyWithDeferredRelease(QD3D12ReleaseQueue *releaseQueue);
460 QD3D12DescriptorHeap heap;
461 QD3D12DescriptorHeap perFrameHeapSlice[QD3D12_FRAMES_IN_FLIGHT];
465struct Q_D3D12_SAMPLER_DESC
467 D3D12_SAMPLER_DESC
desc;
469 friend bool operator==(
const Q_D3D12_SAMPLER_DESC &lhs,
const Q_D3D12_SAMPLER_DESC &rhs)
noexcept
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
479 && lhs.desc.MinLOD == rhs.desc.MinLOD
480 && lhs.desc.MaxLOD == rhs.desc.MaxLOD;
483 friend bool operator!=(
const Q_D3D12_SAMPLER_DESC &lhs,
const Q_D3D12_SAMPLER_DESC &rhs)
noexcept
485 return !(lhs == rhs);
488 friend size_t qHash(
const Q_D3D12_SAMPLER_DESC &
key,
size_t seed = 0) noexcept
505struct QD3D12SamplerManager
507 const quint32 MAX_SAMPLERS = 512;
512 QD3D12Descriptor getShaderVisibleDescriptor(
const D3D12_SAMPLER_DESC &
desc);
514 ID3D12Device *
device =
nullptr;
515 QD3D12ShaderVisibleDescriptorHeap shaderVisibleSamplerHeap;
519enum QD3D12Stage { VS = 0, HS, DS, GS, PS, CS };
537 Q_UNREACHABLE_RETURN(VS);
540static inline D3D12_SHADER_VISIBILITY qd3d12_stageToVisibility(QD3D12Stage
s)
544 return D3D12_SHADER_VISIBILITY_VERTEX;
546 return D3D12_SHADER_VISIBILITY_HULL;
548 return D3D12_SHADER_VISIBILITY_DOMAIN;
550 return D3D12_SHADER_VISIBILITY_GEOMETRY;
552 return D3D12_SHADER_VISIBILITY_PIXEL;
554 return D3D12_SHADER_VISIBILITY_ALL;
556 Q_UNREACHABLE_RETURN(D3D12_SHADER_VISIBILITY_ALL);
578struct QD3D12ShaderStageData
581 QD3D12Stage stage = VS;
585struct QD3D12ShaderResourceBindings;
587struct QD3D12ShaderResourceVisitor
589 enum StorageOp { Load = 0, Store, LoadStore };
591 QD3D12ShaderResourceVisitor(
const QD3D12ShaderResourceBindings *srb,
592 const QD3D12ShaderStageData *stageData,
595 stageData(stageData),
596 stageCount(stageCount)
608 const QD3D12ShaderResourceBindings *srb;
609 const QD3D12ShaderStageData *stageData;
618 QD3D12StagingArea staging;
627struct QD3D12MipmapGenerator
629 bool create(QRhiD3D12 *rhiD);
631 void generate(QD3D12CommandBuffer *cbD,
const QD3D12ObjectHandle &textureHandle);
634 QD3D12ObjectHandle rootSigHandle;
635 QD3D12ObjectHandle pipelineHandle;
638struct QD3D12MemoryAllocator
640 bool create(ID3D12Device *
device, IDXGIAdapter1 *adapter);
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,
651 void getBudget(D3D12MA::Budget *localBudget, D3D12MA::Budget *nonLocalBudget);
653 bool isUsingD3D12MA()
const {
return allocator !=
nullptr; }
655 ID3D12Device *
device =
nullptr;
656 D3D12MA::Allocator *allocator =
nullptr;
670 void executeHostWritesForFrameSlot(
int frameSlot);
672 QD3D12ObjectHandle handles[QD3D12_FRAMES_IN_FLIGHT] = {};
678 friend class QRhiD3D12;
685 const QSize &pixelSize,
689 ~QD3D12RenderBuffer();
694 static const DXGI_FORMAT DS_FORMAT = DXGI_FORMAT_D24_UNORM_S8_UINT;
696 QD3D12ObjectHandle
handle;
697 QD3D12Descriptor rtv;
698 QD3D12Descriptor dsv;
699 DXGI_FORMAT dxgiFormat;
700 DXGI_SAMPLE_DESC sampleDesc;
702 friend class QRhiD3D12;
716 bool prepareCreate(
QSize *adjustedSize =
nullptr);
719 QD3D12ObjectHandle
handle;
720 QD3D12Descriptor srv;
721 DXGI_FORMAT dxgiFormat;
723 DXGI_SAMPLE_DESC sampleDesc;
725 friend class QRhiD3D12;
730 QD3D12Sampler(
QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
731 AddressMode u, AddressMode
v, AddressMode
w);
736 QD3D12Descriptor lookupOrCreateShaderVisibleDescriptor();
738 D3D12_SAMPLER_DESC
desc = {};
739 QD3D12Descriptor shaderVisibleDescriptor;
745 ~QD3D12RenderPassDescriptor();
751 void updateSerializedFormat();
753 static const int MAX_COLOR_ATTACHMENTS = 8;
754 int colorAttachmentCount = 0;
755 bool hasDepthStencil =
false;
761struct QD3D12RenderTargetData
765 QD3D12RenderPassDescriptor *rp =
nullptr;
769 int colorAttCount = 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;
780 ~QD3D12SwapChainRenderTarget();
787 QD3D12RenderTargetData
d;
795 ~QD3D12TextureRenderTarget();
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;
816 ~QD3D12ShaderResourceBindings();
821 QD3D12ObjectHandle createRootSignature(
const QD3D12ShaderStageData *stageData,
int stageCount);
826 D3D12_ROOT_PARAMETER1 srvTables[6] = {};
828 quint32 currentSrvRangeOffset[6] = {};
831 std::array<D3D12_DESCRIPTOR_RANGE1, 16> samplerRanges[6] = {};
832 int samplerRangeHeads[6] = {};
834 D3D12_ROOT_PARAMETER1 uavTables[6] = {};
836 quint32 currentUavRangeOffset[6] = {};
840 void visitUniformBuffer(QD3D12Stage
s,
844 void visitTexture(QD3D12Stage
s,
847 void visitSampler(QD3D12Stage
s,
850 void visitStorageBuffer(QD3D12Stage
s,
852 QD3D12ShaderResourceVisitor::StorageOp op,
854 void visitStorageImage(QD3D12Stage
s,
856 QD3D12ShaderResourceVisitor::StorageOp op,
860 bool hasDynamicOffset =
false;
867 ~QD3D12GraphicsPipeline();
871 QD3D12ObjectHandle
handle;
872 QD3D12ObjectHandle rootSigHandle;
873 std::array<QD3D12ShaderStageData, 5> stageData;
875 UINT viewInstanceMask = 0;
877 friend class QRhiD3D12;
883 ~QD3D12ComputePipeline();
887 QD3D12ObjectHandle
handle;
888 QD3D12ObjectHandle rootSigHandle;
889 QD3D12ShaderStageData stageData;
891 friend class QRhiD3D12;
897 ~QD3D12CommandBuffer();
902 ID3D12GraphicsCommandList1 *cmdList =
nullptr;
903 QRhiD3D12CommandBufferNativeHandles nativeHandlesStruct;
913 recordingPass = NoPass;
914 currentTarget =
nullptr;
919 void resetPerPassState()
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 = {};
934 PassType recordingPass;
937 QD3D12GraphicsPipeline *currentGraphicsPipeline;
938 QD3D12ComputePipeline *currentComputePipeline;
939 uint currentPipelineGeneration;
942 uint currentSrbGeneration;
943 QD3D12ObjectHandle currentIndexBuffer;
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;
966 void releaseBuffers();
967 void waitCommandCompletionForFrameSlot(
int frameSlot);
968 void addCommandCompletionSignalForCurrentFrameSlot();
969 void chooseFormats();
972 IDXGISwapChain1 *sourceSwapChain1 =
nullptr;
973 IDXGISwapChain3 *swapChain =
nullptr;
975 UINT swapInterval = 1;
976 UINT swapChainFlags = 0;
978 DXGI_FORMAT srgbAdjustedColorFormat;
979 DXGI_COLOR_SPACE_TYPE hdrColorSpace;
980 IDCompositionTarget *dcompTarget =
nullptr;
981 IDCompositionVisual *dcompVisual =
nullptr;
985 DXGI_SAMPLE_DESC sampleDesc;
988 QD3D12RenderBuffer *ds =
nullptr;
989 UINT currentBackBufferIndex = 0;
990 QD3D12SwapChainRenderTarget rtWrapper;
991 QD3D12CommandBuffer cbWrapper;
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];
1000 int currentFrameSlot = 0;
1003template<
typename T, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE Type>
1004struct alignas(void*) QD3D12PipelineStateSubObject
1006 D3D12_PIPELINE_STATE_SUBOBJECT_TYPE
type =
Type;
1015 static const quint32 SMALL_STAGING_AREA_BYTES_PER_FRAME = 16 * 1024 * 1024;
1017 static const quint32 SHADER_VISIBLE_CBV_SRV_UAV_HEAP_PER_FRAME_START_SIZE = 16384;
1019 QRhiD3D12(QRhiD3D12InitParams *
params, QRhiD3D12NativeHandles *importDevice =
nullptr);
1028 QRhiBuffer::UsageFlags
usage,
1031 const QSize &pixelSize,
1033 QRhiRenderBuffer::Flags
flags,
1036 const QSize &pixelSize,
1040 QRhiTexture::Flags
flags)
override;
1049 QRhiTextureRenderTarget::Flags
flags)
override;
1062 const QColor &colorClearValue,
1065 QRhiCommandBuffer::BeginPassFlags
flags)
override;
1073 int dynamicOffsetCount,
1099 QRhiCommandBuffer::BeginPassFlags
flags)
override;
1129 DXGI_SAMPLE_DESC effectiveSampleCount(
int sampleCount, DXGI_FORMAT
format)
const;
1130 bool ensureDirectCompositionDevice();
1131 bool startCommandListForCurrentFrameSlot(ID3D12GraphicsCommandList1 **cmdList);
1133 void finishActiveReadbacks(
bool forced =
false);
1134 bool ensureShaderVisibleDescriptorHeapCapacity(QD3D12ShaderVisibleDescriptorHeap *
h,
1135 D3D12_DESCRIPTOR_HEAP_TYPE
type,
1137 quint32 neededDescriptorCount,
1139 void bindShaderVisibleHeaps(QD3D12CommandBuffer *cbD);
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;
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;
1175 QD3D12ShaderBytecodeCache shaderBytecodeCache;
1177 bool offscreenActive =
false;
1178 QD3D12CommandBuffer *offscreenCb[QD3D12_FRAMES_IN_FLIGHT] = {};
1180 struct VisitorData {
1187 void visitUniformBuffer(QD3D12Stage
s,
1191 int dynamicOffsetCount,
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);
1209 bool multiView =
false;
IOBluetoothDevice * device
The QColor class provides colors based on RGB, HSV or CMYK values.
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
virtual char * beginFullDynamicBufferUpdateForCurrentFrame()
Type
Specifies storage type of buffer resource.
virtual void endFullDynamicBufferUpdateForCurrentFrame()
To be called when the entire contents of the buffer data has been updated in the memory block returne...
virtual NativeBuffer nativeBuffer()
virtual bool create()=0
Creates the corresponding native graphics resources.
QPair< QRhiBuffer *, quint32 > VertexInput
Synonym for QPair<QRhiBuffer *, quint32>.
const QRhiNativeHandles * nativeHandles()
QPair< int, quint32 > DynamicOffset
Synonym for QPair<int, quint32>.
IndexFormat
Specifies the index data type.
virtual bool create()=0
Creates the corresponding native graphics resources.
Topology topology() const
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 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
virtual QRhiTexture::Format backingFormat() const =0
Type
Specifies the type of the renderbuffer.
virtual bool create()=0
Creates the corresponding native graphics resources.
virtual QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() const =0
virtual bool isCompatible(const QRhiRenderPassDescriptor *other) const =0
virtual QVector< quint32 > serializedFormat() const =0
virtual QSize pixelSize() const =0
virtual int sampleCount() const =0
virtual float devicePixelRatio() const =0
virtual void destroy()=0
Releases (or requests deferred releasing of) the underlying native graphics resources.
Filter
Specifies the minification, magnification, or mipmap filtering.
AddressMode
Specifies the addressing mode.
StageFlag
Flag values to indicate which stages the shader resource is visible in.
@ TessellationEvaluationStage
@ TessellationControlStage
virtual void updateResources(UpdateFlags flags={})=0
Type
Specifies the type of the shader stage.
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
virtual QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor()=0
virtual bool create()=0
Creates the corresponding native graphics resources.
virtual bool create()=0
Creates the corresponding native graphics resources.
Format
Specifies the texture format.
virtual void setNativeLayout(int layout)
With some graphics APIs, such as Vulkan, integrating custom rendering code that uses the graphics API...
virtual bool createFrom(NativeTexture src)
Similar to create(), except that no new native textures are created.
virtual NativeTexture nativeTexture()
ResourceLimit
Describes the resource limit to query.
Feature
Flag values to indicate what features are supported by the backend currently in use.
FrameOpResult
Describes the result of operations that can have a soft failure.
QHash< int, QWidget * > hash
[35multi]
QMap< QString, QString > map
[6]
Combined button and popup list for selecting options.
Q_ALWAYS_INLINE void fence()
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)
size_t qHash(const QFileSystemWatcherPathKey &key, size_t seed=0)
static QT_BEGIN_NAMESPACE const int BUFFER_COUNT
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
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
GLenum GLenum colorFormat
GLsizeiptr const void GLenum usage
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
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
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
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)
settings remove("monkey")
view viewport() -> scroll(dx, dy, deviceRect)
\variable QRhiReadbackResult::completed