Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qrhid3d11_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 QRHID3D11_P_H
5#define QRHID3D11_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"
19#include <rhi/qshaderdescription.h>
20#include <QWindow>
21
22#include <d3d11_1.h>
23#include <dxgi1_6.h>
24#include <dcomp.h>
25
27
28class QRhiD3D11;
29
30struct QD3D11Buffer : public QRhiBuffer
31{
32 QD3D11Buffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size);
33 ~QD3D11Buffer();
34 void destroy() override;
35 bool create() override;
39
41
42 ID3D11Buffer *buffer = nullptr;
43 char *dynBuf = nullptr;
47 friend class QRhiD3D11;
48};
49
51{
52 QD3D11RenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize,
53 int sampleCount, QRhiRenderBuffer::Flags flags,
54 QRhiTexture::Format backingFormatHint);
56 void destroy() override;
57 bool create() override;
58 QRhiTexture::Format backingFormat() const override;
59
60 ID3D11Texture2D *tex = nullptr;
66 friend class QRhiD3D11;
67};
68
70{
71 QD3D11Texture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth,
72 int arraySize, int sampleCount, Flags flags);
74 void destroy() override;
75 bool create() override;
76 bool createFrom(NativeTexture src) override;
78
79 bool prepareCreate(QSize *adjustedSize = nullptr);
80 bool finishCreate();
83 {
84 if (tex)
85 return tex;
86 else if (tex1D)
87 return tex1D;
88 return tex3D;
89 }
90
91 ID3D11Texture2D *tex = nullptr;
94 bool owns = true;
101 friend class QRhiD3D11;
102};
103
105{
106 QD3D11Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
107 AddressMode u, AddressMode v, AddressMode w);
108 ~QD3D11Sampler();
109 void destroy() override;
110 bool create() override;
111
114 friend class QRhiD3D11;
115};
116
118{
119 QD3D11RenderPassDescriptor(QRhiImplementation *rhi);
121 void destroy() override;
122 bool isCompatible(const QRhiRenderPassDescriptor *other) const override;
124 QVector<quint32> serializedFormat() const override;
125};
126
128{
129 QD3D11RenderTargetData(QRhiImplementation *)
130 {
131 for (int i = 0; i < MAX_COLOR_ATTACHMENTS; ++i)
132 rtv[i] = nullptr;
133 }
134
137 float dpr = 1;
138 int sampleCount = 1;
140 int dsAttCount = 0;
141
142 static const int MAX_COLOR_ATTACHMENTS = 8;
145
147};
148
150{
151 QD3D11SwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain);
153 void destroy() override;
154
155 QSize pixelSize() const override;
156 float devicePixelRatio() const override;
157 int sampleCount() const override;
158
160};
161
163{
164 QD3D11TextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc, Flags flags);
166 void destroy() override;
167
168 QSize pixelSize() const override;
169 float devicePixelRatio() const override;
170 int sampleCount() const override;
171
173 bool create() override;
174
178 bool ownsDsv = false;
180 friend class QRhiD3D11;
181};
182
190
193
195{
196 QD3D11ShaderResourceBindings(QRhiImplementation *rhi);
198 void destroy() override;
199 bool create() override;
200 void updateResources(UpdateFlags flags) override;
201
202 bool hasDynamicOffset = false;
207
208 // Keep track of the generation number of each referenced QRhi* to be able
209 // to detect that the batched bindings are out of date.
215 int count;
216 struct {
221 } d[QRhiShaderResourceBinding::Data::MAX_TEX_SAMPLER_ARRAY_SIZE];
222 };
240
242 bool present = false;
247 void finish() {
248 present = ubufs.finish();
249 ubuforigbindings.finish();
250 ubufoffsets.finish();
251 ubufsizes.finish();
252 }
253 void clear() {
254 ubufs.clear();
255 ubuforigbindings.clear();
256 ubufoffsets.clear();
257 ubufsizes.clear();
258 }
259 };
260
262 bool present = false;
265 void finish() {
266 present = samplers.finish();
267 shaderresources.finish();
268 }
269 void clear() {
270 samplers.clear();
271 shaderresources.clear();
272 }
273 };
274
276 bool present = false;
278 void finish() {
279 present = uavs.finish();
280 }
281 void clear() {
282 uavs.clear();
283 }
284 };
285
293
300
303
304 void clear() {
305 vsUniformBufferBatches.clear();
306 hsUniformBufferBatches.clear();
307 dsUniformBufferBatches.clear();
308 gsUniformBufferBatches.clear();
309 fsUniformBufferBatches.clear();
310 csUniformBufferBatches.clear();
311
312 vsSamplerBatches.clear();
313 hsSamplerBatches.clear();
314 dsSamplerBatches.clear();
315 gsSamplerBatches.clear();
316 fsSamplerBatches.clear();
317 csSamplerBatches.clear();
318
319 csUavBatches.clear();
320 fsUavBatches.clear();
321 }
322 } resourceBatches;
323
324 friend class QRhiD3D11;
325};
326
328
330{
331 QD3D11GraphicsPipeline(QRhiImplementation *rhi);
333 void destroy() override;
334 bool create() override;
335
338 struct {
341 } vs;
342 struct {
344 QShader::NativeResourceBindingMap nativeResourceBindingMap;
345 } hs;
346 struct {
348 QShader::NativeResourceBindingMap nativeResourceBindingMap;
349 } ds;
350 struct {
352 QShader::NativeResourceBindingMap nativeResourceBindingMap;
353 } gs;
354 struct {
356 QShader::NativeResourceBindingMap nativeResourceBindingMap;
357 } fs;
362 friend class QRhiD3D11;
363};
364
366{
367 QD3D11ComputePipeline(QRhiImplementation *rhi);
369 void destroy() override;
370 bool create() override;
371
372 struct {
375 } cs;
377 friend class QRhiD3D11;
378};
379
380struct QD3D11SwapChain;
381
383{
384 QD3D11CommandBuffer(QRhiImplementation *rhi);
386 void destroy() override;
387
388 // these must be kept at a reasonably low value otherwise sizeof Command explodes
389 static const int MAX_DYNAMIC_OFFSET_COUNT = 8;
391
392 struct Command {
419 enum ClearFlag { Color = 1, Depth = 2, Stencil = 4 };
421
422 // QRhi*/QD3D11* references should be kept at minimum (so no
423 // QRhiTexture/Buffer/etc. pointers).
424 union Args {
425 struct {
429 } beginFrame;
430 struct {
431 ID3D11Query *tsQuery;
432 ID3D11Query *tsDisjointQuery;
433 } endFrame;
434 struct {
436 } setRenderTarget;
437 struct {
438 QRhiRenderTarget *rt;
439 int mask;
440 float c[4];
441 float d;
443 } clear;
444 struct {
445 float x, y, w, h;
446 float d0, d1;
447 } viewport;
448 struct {
449 int x, y, w, h;
450 } scissor;
451 struct {
457 } bindVertexBuffers;
458 struct {
462 } bindIndexBuffer;
463 struct {
465 } bindGraphicsPipeline;
466 struct {
470 uint dynamicOffsetPairs[MAX_DYNAMIC_OFFSET_COUNT * 2]; // binding, offsetInConstants
471 } bindShaderResources;
472 struct {
475 } stencilRef;
476 struct {
478 float c[4];
479 } blendConstants;
480 struct {
486 } draw;
487 struct {
490 quint32 instanceCount;
493 quint32 firstInstance;
494 } drawIndexed;
495 struct {
500 const void *src; // must come from retain*()
502 } updateSubRes;
503 struct {
504 ID3D11Resource *dst;
505 UINT dstSubRes;
513 } copySubRes;
514 struct {
515 ID3D11Resource *dst;
516 UINT dstSubRes;
517 ID3D11Resource *src;
518 UINT srcSubRes;
519 DXGI_FORMAT format;
520 } resolveSubRes;
521 struct {
523 } genMip;
524 struct {
525 char s[64];
526 } debugMark;
527 struct {
529 } bindComputePipeline;
530 struct {
534 } dispatch;
535 } args;
536 };
537
543
546 double lastGpuTime = 0;
560
565
566 // relies heavily on implicit sharing (no copies of the actual data will be made)
567 const uchar *retainData(const QByteArray &data) {
568 dataRetainPool.append(data);
569 return reinterpret_cast<const uchar *>(dataRetainPool.last().constData());
570 }
572 bufferDataRetainPool.append(data);
573 return reinterpret_cast<const uchar *>(bufferDataRetainPool.last().constData());
574 }
575 const uchar *retainImage(const QImage &image) {
576 imageRetainPool.append(image);
577 return imageRetainPool.last().constBits();
578 }
579 // except this one
581 resourceBatchRetainPool.append(resourceBatches);
582 return resourceBatchRetainPool.count() - 1;
583 }
585 commands.reset();
586 dataRetainPool.clear();
587 bufferDataRetainPool.clear();
588 imageRetainPool.clear();
589 resourceBatchRetainPool.clear();
590 }
591 void resetState() {
593 // do not zero lastGpuTime
594 currentTarget = nullptr;
595 prevRtD = nullptr;
598 }
600 currentGraphicsPipeline = nullptr;
601 currentComputePipeline = nullptr;
602 currentPipelineGeneration = 0;
603 currentGraphicsSrb = nullptr;
604 currentComputeSrb = nullptr;
605 currentSrbGeneration = 0;
606 currentIndexBuffer = nullptr;
607 currentIndexOffset = 0;
608 currentIndexFormat = DXGI_FORMAT_R16_UINT;
609 memset(currentVertexBuffers, 0, sizeof(currentVertexBuffers));
610 memset(currentVertexOffsets, 0, sizeof(currentVertexOffsets));
611 }
612};
613
615{
616 static const int TIMESTAMP_PAIRS = 2;
617
621
622 bool prepare(QRhiD3D11 *rhiD);
623 void destroy();
624 bool tryQueryTimestamps(int idx, ID3D11DeviceContext *context, double *elapsedSec);
625};
626
628{
629 QD3D11SwapChain(QRhiImplementation *rhi);
631 void destroy() override;
632
633 QRhiCommandBuffer *currentFrameCommandBuffer() override;
635 QRhiRenderTarget *currentFrameRenderTarget(StereoTargetBuffer targetBuffer) override;
636
637 QSize surfacePixelSize() override;
638 bool isFormatSupported(Format f) override;
640
643
644 void releaseBuffers();
645 bool newColorBuffer(const QSize &size, DXGI_FORMAT format, DXGI_SAMPLE_DESC sampleDesc,
646 ID3D11Texture2D **tex, ID3D11RenderTargetView **rtv) const;
647
648 QWindow *window = nullptr;
660 static const int BUFFER_COUNT = 2;
665 int frameCount = 0;
674};
675
677{
678public:
679 QRhiDriverInfo info() const override;
680
683};
684
686{
687public:
688 QRhiD3D11(QRhiD3D11InitParams *params, QRhiD3D11NativeHandles *importDevice = nullptr);
689
690 bool create(QRhi::Flags flags) override;
691 void destroy() override;
692 QRhi::AdapterList enumerateAdaptersBeforeCreate(QRhiNativeHandles *nativeHandles) const override;
693
697 QRhiBuffer *createBuffer(QRhiBuffer::Type type,
698 QRhiBuffer::UsageFlags usage,
699 quint32 size) override;
700 QRhiRenderBuffer *createRenderBuffer(QRhiRenderBuffer::Type type,
701 const QSize &pixelSize,
702 int sampleCount,
703 QRhiRenderBuffer::Flags flags,
704 QRhiTexture::Format backingFormatHint) override;
705 QRhiTexture *createTexture(QRhiTexture::Format format,
706 const QSize &pixelSize,
707 int depth,
708 int arraySize,
709 int sampleCount,
710 QRhiTexture::Flags flags) override;
711 QRhiSampler *createSampler(QRhiSampler::Filter magFilter,
712 QRhiSampler::Filter minFilter,
713 QRhiSampler::Filter mipmapMode,
714 QRhiSampler:: AddressMode u,
715 QRhiSampler::AddressMode v,
716 QRhiSampler::AddressMode w) override;
717
718 QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
719 QRhiTextureRenderTarget::Flags flags) override;
720
721 QRhiShadingRateMap *createShadingRateMap() override;
722
723 QRhiSwapChain *createSwapChain() override;
724 QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) override;
725 QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) override;
726 QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) override;
727 QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) override;
728 QRhi::FrameOpResult finish() override;
729
730 void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
731
732 void beginPass(QRhiCommandBuffer *cb,
733 QRhiRenderTarget *rt,
734 const QColor &colorClearValue,
735 const QRhiDepthStencilClearValue &depthStencilClearValue,
736 QRhiResourceUpdateBatch *resourceUpdates,
737 QRhiCommandBuffer::BeginPassFlags flags) override;
738 void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
739
740 void setGraphicsPipeline(QRhiCommandBuffer *cb,
741 QRhiGraphicsPipeline *ps) override;
742
743 void setShaderResources(QRhiCommandBuffer *cb,
744 QRhiShaderResourceBindings *srb,
745 int dynamicOffsetCount,
746 const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) override;
747
748 void setVertexInput(QRhiCommandBuffer *cb,
749 int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings,
750 QRhiBuffer *indexBuf, quint32 indexOffset,
751 QRhiCommandBuffer::IndexFormat indexFormat) override;
752
753 void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override;
754 void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override;
755 void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) override;
756 void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override;
757 void setShadingRate(QRhiCommandBuffer *cb, const QSize &coarsePixelSize) override;
758
759 void draw(QRhiCommandBuffer *cb, quint32 vertexCount,
760 quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override;
761
762 void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
763 quint32 instanceCount, quint32 firstIndex,
764 qint32 vertexOffset, quint32 firstInstance) override;
765
766 void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override;
767 void debugMarkEnd(QRhiCommandBuffer *cb) override;
768 void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override;
769
770 void beginComputePass(QRhiCommandBuffer *cb,
771 QRhiResourceUpdateBatch *resourceUpdates,
772 QRhiCommandBuffer::BeginPassFlags flags) override;
773 void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
774 void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) override;
775 void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) override;
776
777 const QRhiNativeHandles *nativeHandles(QRhiCommandBuffer *cb) override;
778 void beginExternal(QRhiCommandBuffer *cb) override;
779 void endExternal(QRhiCommandBuffer *cb) override;
780 double lastCompletedGpuTime(QRhiCommandBuffer *cb) override;
781
782 QList<int> supportedSampleCounts() const override;
783 QList<QSize> supportedShadingRates(int sampleCount) const override;
784 int ubufAlignment() const override;
785 bool isYUpInFramebuffer() const override;
786 bool isYUpInNDC() const override;
787 bool isClipDepthZeroToOne() const override;
788 QMatrix4x4 clipSpaceCorrMatrix() const override;
789 bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override;
790 bool isFeatureSupported(QRhi::Feature feature) const override;
791 int resourceLimit(QRhi::ResourceLimit limit) const override;
792 const QRhiNativeHandles *nativeHandles() override;
793 QRhiDriverInfo driverInfo() const override;
794 QRhiStats statistics() override;
796 void setQueueSubmitParams(QRhiNativeHandles *params) override;
798 bool isDeviceLost() const override;
799
800 QByteArray pipelineCacheData() override;
801 void setPipelineCacheData(const QByteArray &data) override;
802
804 int layer, int level, const QRhiTextureSubresourceUploadDescription &subresDesc);
805 void enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates);
807 const QShader::NativeResourceBindingMap *nativeResourceBindingMaps[]);
809
811 const uint *dynOfsPairs, int dynOfsPairCount,
812 bool offsetOnlyChange, QD3D11RenderTargetData *rtD, RenderTargetUavUpdateState &rtUavState);
815 DXGI_SAMPLE_DESC effectiveSampleDesc(int sampleCount) const;
817 void reportLiveObjects(ID3D11Device *device);
818 void clearShaderCache();
819 QByteArray compileHlslShaderSource(const QShader &shader, QShader::Variant shaderVariant, uint flags,
820 QString *error, QShaderKey *usedShaderKey);
822
824 bool debugLayer = false;
825 UINT maxFrameLatency = 2; // 1-3, use 2 to keep CPU-GPU parallelism while reducing lag compared to tripple buffering
827 ID3D11Device *dev = nullptr;
837 bool deviceLost = false;
840
841 struct {
853 } contextState;
854
862
879
889
890 // This is what gets exposed as the "pipeline cache", not that that concept
891 // applies anyway. Here we are just storing the DX bytecode for a shader so
892 // we can skip the HLSL->DXBC compilation when the QShader has HLSL source
893 // code and the same shader source has already been compiled before.
894 // m_shaderCache seemingly does the same, but this here does not care about
895 // the ID3D11*Shader, this is just about the bytecode and about allowing
896 // the data to be serialized to persistent storage and then reloaded in
897 // future runs of the app, or when creating another QRhi, etc.
905};
906
909
910inline bool operator==(const QRhiD3D11::BytecodeCacheKey &a, const QRhiD3D11::BytecodeCacheKey &b) noexcept
911{
912 return a.sourceHash == b.sourceHash
913 && a.target == b.target
914 && a.entryPoint == b.entryPoint
915 && a.compileFlags == b.compileFlags;
916}
917
918inline bool operator!=(const QRhiD3D11::BytecodeCacheKey &a, const QRhiD3D11::BytecodeCacheKey &b) noexcept
919{
920 return !(a == b);
921}
922
923inline size_t qHash(const QRhiD3D11::BytecodeCacheKey &k, size_t seed = 0) noexcept
924{
925 return qHashMulti(seed, k.sourceHash, k.target, k.entryPoint, k.compileFlags);
926}
927
928QT_END_NAMESPACE
929
930#endif
QRhiDriverInfo info() const override
QRhiDriverInfo adapterInfo
const char * constData() const
Definition qrhi_p.h:365
int gsHighestActiveSrvBinding
void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override
bool deviceLost
void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override
int dsHighestActiveSrvBinding
QRhiD3D11NativeHandles nativeHandlesStruct
bool isYUpInNDC() const override
ID3D11Device * dev
QRhiSwapChain * createSwapChain() override
void enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)
bool isFeatureSupported(QRhi::Feature feature) const override
QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) override
bool isDeviceLost() const override
bool vsHasIndexBufferBound
void executeBufferHostWrites(QD3D11Buffer *bufD)
void updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD, const QShader::NativeResourceBindingMap *nativeResourceBindingMaps[])
QRhiStats statistics() override
QHash< BytecodeCacheKey, QByteArray > m_bytecodeCache
QList< QSize > supportedShadingRates(int sampleCount) const override
QRhiComputePipeline * createComputePipeline() override
void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override
bool debugLayer
QRhi::FrameOpResult finish() override
void setVertexInput(QRhiCommandBuffer *cb, int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings, QRhiBuffer *indexBuf, quint32 indexOffset, QRhiCommandBuffer::IndexFormat indexFormat) override
IDXGIAdapter1 * activeAdapter
QRhiGraphicsPipeline * createGraphicsPipeline() override
QRhiShaderResourceBindings * createShaderResourceBindings() override
QVarLengthArray< BufferReadback, 2 > activeBufferReadbacks
QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) override
ID3D11DeviceContext1 * context
QList< int > supportedSampleCounts() const override
QRhiTextureRenderTarget * createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags) override
QRhi::Flags rhiFlags
QByteArray compileHlslShaderSource(const QShader &shader, QShader::Variant shaderVariant, uint flags, QString *error, QShaderKey *usedShaderKey)
void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) override
int csHighestActiveSrvBinding
bool isClipDepthZeroToOne() const override
IDCompositionDevice * dcompDevice
QRhiDriverInfo driverInfoStruct
QHash< QRhiShaderStage, Shader > m_shaderCache
bool ensureDirectCompositionDevice()
const QRhiNativeHandles * nativeHandles(QRhiCommandBuffer *cb) override
void beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags) override
void draw(QRhiCommandBuffer *cb, quint32 vertexCount, quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override
void enqueueSubresUpload(QD3D11Texture *texD, QD3D11CommandBuffer *cbD, int layer, int level, const QRhiTextureSubresourceUploadDescription &subresDesc)
QD3D11SwapChain * currentSwapChain
void reportLiveObjects(ID3D11Device *device)
void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override
void destroy() override
QMatrix4x4 clipSpaceCorrMatrix() const override
bool isYUpInFramebuffer() const override
int resourceLimit(QRhi::ResourceLimit limit) const override
void beginExternal(QRhiCommandBuffer *cb) override
QRhiTexture * createTexture(QRhiTexture::Format format, const QSize &pixelSize, int depth, int arraySize, int sampleCount, QRhiTexture::Flags flags) override
void setPipelineCacheData(const QByteArray &data) override
LUID adapterLuid
void executeCommandBuffer(QD3D11CommandBuffer *cbD)
void debugMarkEnd(QRhiCommandBuffer *cb) override
void releaseCachedResources() override
double lastCompletedGpuTime(QRhiCommandBuffer *cb) override
ID3DUserDefinedAnnotation * annotations
bool importedDeviceAndContext
void resetShaderResources(QD3D11RenderTargetData *rtD, RenderTargetUavUpdateState &rtUavState)
QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) override
QRhiBuffer * createBuffer(QRhiBuffer::Type type, QRhiBuffer::UsageFlags usage, quint32 size) override
bool supportsAllowTearing
void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) override
void endExternal(QRhiCommandBuffer *cb) override
void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override
QVarLengthArray< TextureReadback, 2 > activeTextureReadbacks
QRhi::AdapterList enumerateAdaptersBeforeCreate(QRhiNativeHandles *nativeHandles) const override
UINT maxFrameLatency
void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) override
QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) override
QRhiShadingRateMap * createShadingRateMap() override
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override
void setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBindings *srb, int dynamicOffsetCount, const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) override
void clearShaderCache()
D3D_FEATURE_LEVEL featureLevel
bool useLegacySwapchainModel
void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override
bool makeThreadLocalNativeContextCurrent() override
bool create(QRhi::Flags flags) override
void bindShaderResources(const QD3D11ShaderResourceBindings::ResourceBatches &allResourceBatches, const uint *dynOfsPairs, int dynOfsPairCount, bool offsetOnlyChange, QD3D11RenderTargetData *rtD, RenderTargetUavUpdateState &rtUavState)
int csHighestActiveUavBinding
void finishActiveReadbacks()
IDXGIFactory1 * dxgiFactory
int fsHighestActiveSrvBinding
void setShadingRate(QRhiCommandBuffer *cb, const QSize &coarsePixelSize) override
QByteArray pipelineCacheData() override
const QRhiNativeHandles * nativeHandles() override
QRhiDriverInfo driverInfo() const override
void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override
int ubufAlignment() const override
void beginPass(QRhiCommandBuffer *cb, QRhiRenderTarget *rt, const QColor &colorClearValue, const QRhiDepthStencilClearValue &depthStencilClearValue, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags) override
void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, quint32 instanceCount, quint32 firstIndex, qint32 vertexOffset, quint32 firstInstance) override
void setQueueSubmitParams(QRhiNativeHandles *params) override
QRhiSampler * createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter, QRhiSampler::Filter mipmapMode, QRhiSampler::AddressMode u, QRhiSampler::AddressMode v, QRhiSampler::AddressMode w) override
int vsHighestActiveSrvBinding
QRhiRenderBuffer * createRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount, QRhiRenderBuffer::Flags flags, QRhiTexture::Format backingFormatHint) override
int hsHighestActiveSrvBinding
void setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline *ps) override
QRhiD3D11(QRhiD3D11InitParams *params, QRhiD3D11NativeHandles *importDevice=nullptr)
DXGI_SAMPLE_DESC effectiveSampleDesc(int sampleCount) const
int fsHighestActiveUavBinding
void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override
int vsHighestActiveVertexBufferBinding
static QRhiResourceUpdateBatchPrivate * get(QRhiResourceUpdateBatch *b)
Definition qrhi_p.h:590
@ UnBounded
Definition qrhi_p.h:278
@ Bounded
Definition qrhi_p.h:279
#define QRHI_RES_RHI(t)
Definition qrhi_p.h:30
#define QRHI_RES(t, x)
Definition qrhi_p.h:29
static const DXGI_FORMAT DEFAULT_SRGB_FORMAT
static void applyDynamicOffsets(UINT *offsets, int batchIndex, const QRhiBatchedBindings< UINT > *originalBindings, const QRhiBatchedBindings< UINT > *staticOffsets, const uint *dynOfsPairs, int dynOfsPairCount)
static D3D11_TEXTURE_ADDRESS_MODE toD3DAddressMode(QRhiSampler::AddressMode m)
#define SETUAVBATCH(stagePrefixL, stagePrefixU)
static QByteArray sourceHash(const QByteArray &source)
#define SETSAMPLERBATCH(stagePrefixL, stagePrefixU)
static const int RBM_HULL
static uint toD3DBufferUsage(QRhiBuffer::UsageFlags usage)
static std::pair< int, int > mapBinding(int binding, int stageIndex, const QShader::NativeResourceBindingMap *nativeResourceBindingMaps[])
static const int RBM_FRAGMENT
#define SETUBUFBATCH(stagePrefixL, stagePrefixU)
Int aligned(Int v, Int byteAlign)
\variable QRhiVulkanQueueSubmitParams::waitSemaphoreCount
static DXGI_FORMAT toD3DDepthTextureDSVFormat(QRhiTexture::Format format)
static D3D11_BLEND toD3DBlendFactor(QRhiGraphicsPipeline::BlendFactor f, bool rgb)
static const int RBM_VERTEX
static D3D11_BLEND_OP toD3DBlendOp(QRhiGraphicsPipeline::BlendOp op)
#define D3D11_1_UAV_SLOT_COUNT
static const int RBM_DOMAIN
static D3D11_FILTER toD3DFilter(QRhiSampler::Filter minFilter, QRhiSampler::Filter magFilter, QRhiSampler::Filter mipFilter)
static QD3D11RenderTargetData * rtData(QRhiRenderTarget *rt)
static UINT8 toD3DColorWriteMask(QRhiGraphicsPipeline::ColorMask c)
static D3D11_STENCIL_OP toD3DStencilOp(QRhiGraphicsPipeline::StencilOp op)
void releasePipelineShader(T &s)
static D3D11_COMPARISON_FUNC toD3DTextureComparisonFunc(QRhiSampler::CompareOp op)
static DXGI_FORMAT toD3DAttributeFormat(QRhiVertexInputAttribute::Format format)
static const int RBM_GEOMETRY
static D3D11_PRIMITIVE_TOPOLOGY toD3DTopology(QRhiGraphicsPipeline::Topology t, int patchControlPointCount)
static IDXGIFactory1 * createDXGIFactory2()
static D3D11_FILL_MODE toD3DFillMode(QRhiGraphicsPipeline::PolygonMode mode)
static bool isDepthTextureFormat(QRhiTexture::Format format)
static const int RBM_COMPUTE
static D3D11_CULL_MODE toD3DCullMode(QRhiGraphicsPipeline::CullMode c)
#define SETSHADER(StageL, StageU)
static DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTexture::Flags flags)
static const DXGI_FORMAT DEFAULT_FORMAT
static uint clampedResourceCount(uint startSlot, int countSlots, uint maxSlots, const char *resType)
#define D3D11_VS_INPUT_REGISTER_COUNT
#define DXGI_ADAPTER_FLAG_SOFTWARE
\variable QRhiD3D11NativeHandles::dev
static QRhiTexture::Format swapchainReadbackTextureFormat(DXGI_FORMAT format, QRhiTexture::Flags *flags)
static D3D11_COMPARISON_FUNC toD3DCompareOp(QRhiGraphicsPipeline::CompareOp op)
static DXGI_FORMAT toD3DDepthTextureSRVFormat(QRhiTexture::Format format)
static const int RBM_SUPPORTED_STAGES
size_t qHash(const QRhiD3D11::BytecodeCacheKey &k, size_t seed=0) noexcept
Q_DECLARE_TYPEINFO(QRhiD3D11::TextureReadback, Q_RELOCATABLE_TYPE)
bool operator!=(const QRhiD3D11::BytecodeCacheKey &a, const QRhiD3D11::BytecodeCacheKey &b) noexcept
Q_DECLARE_TYPEINFO(QRhiD3D11::BufferReadback, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(QD3D11ShaderResourceBindings::BoundResourceData, Q_RELOCATABLE_TYPE)
bool operator==(const QRhiD3D11::BytecodeCacheKey &a, const QRhiD3D11::BytecodeCacheKey &b) noexcept
bool hasPendingDynamicUpdates
Definition qrhid3d11_p.h:44
void endFullDynamicBufferUpdateForCurrentFrame() override
To be called when the entire contents of the buffer data has been updated in the memory block returne...
char * dynBuf
Definition qrhid3d11_p.h:43
ID3D11Buffer * buffer
Definition qrhid3d11_p.h:42
QD3D11Buffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size)
char * beginFullDynamicBufferUpdateForCurrentFrame() override
bool create() override
Creates the corresponding native graphics resources.
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QHash< quint32, ID3D11UnorderedAccessView * > uavs
Definition qrhid3d11_p.h:45
QRhiBuffer::NativeBuffer nativeBuffer() override
ID3D11UnorderedAccessView * unorderedAccessView(quint32 offset)
QRhiRenderTarget * currentTarget
QD3D11RenderTargetData * prevRtD
static const int MAX_DYNAMIC_OFFSET_COUNT
QVarLengthArray< QRhiBufferData, 4 > bufferDataRetainPool
const uchar * retainBufferData(const QRhiBufferData &data)
ID3D11Buffer * currentVertexBuffers[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]
QVarLengthArray< QImage, 4 > imageRetainPool
static const int MAX_VERTEX_BUFFER_BINDING_COUNT
int retainResourceBatches(const QD3D11ShaderResourceBindings::ResourceBatches &resourceBatches)
QRhiShaderResourceBindings * currentGraphicsSrb
const uchar * retainImage(const QImage &image)
QD3D11CommandBuffer(QRhiImplementation *rhi)
const uchar * retainData(const QByteArray &data)
QRhiShaderResourceBindings * currentComputeSrb
QRhiBackendCommandList< Command > commands
QVarLengthArray< QD3D11ShaderResourceBindings::ResourceBatches, 4 > resourceBatchRetainPool
QVarLengthArray< QByteArray, 4 > dataRetainPool
QRhiComputePipeline * currentComputePipeline
ID3D11Buffer * currentIndexBuffer
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
DXGI_FORMAT currentIndexFormat
quint32 currentVertexOffsets[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]
QRhiGraphicsPipeline * currentGraphicsPipeline
ID3D11ComputeShader * shader
QD3D11ComputePipeline(QRhiImplementation *rhi)
bool create() override
QShader::NativeResourceBindingMap nativeResourceBindingMap
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
ID3D11DomainShader * shader
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QD3D11GraphicsPipeline(QRhiImplementation *rhi)
ID3D11VertexShader * shader
ID3D11PixelShader * shader
ID3D11InputLayout * inputLayout
ID3D11BlendState * blendState
ID3D11RasterizerState * rastState
ID3D11GeometryShader * shader
D3D11_PRIMITIVE_TOPOLOGY d3dTopology
bool create() override
Creates the corresponding native graphics resources.
ID3D11DepthStencilState * dsState
QShader::NativeResourceBindingMap nativeResourceBindingMap
ID3D11HullShader * shader
QD3D11RenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize, int sampleCount, QRhiRenderBuffer::Flags flags, QRhiTexture::Format backingFormatHint)
ID3D11RenderTargetView * rtv
Definition qrhid3d11_p.h:62
DXGI_FORMAT dxgiFormat
Definition qrhid3d11_p.h:63
ID3D11DepthStencilView * dsv
Definition qrhid3d11_p.h:61
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
DXGI_SAMPLE_DESC sampleDesc
Definition qrhid3d11_p.h:64
bool create() override
Creates the corresponding native graphics resources.
QRhiTexture::Format backingFormat() const override
ID3D11Texture2D * tex
Definition qrhid3d11_p.h:60
QD3D11RenderPassDescriptor(QRhiImplementation *rhi)
QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() const override
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
bool isCompatible(const QRhiRenderPassDescriptor *other) const override
QVector< quint32 > serializedFormat() const override
static const int MAX_COLOR_ATTACHMENTS
ID3D11RenderTargetView * rtv[MAX_COLOR_ATTACHMENTS]
QD3D11RenderTargetData(QRhiImplementation *)
ID3D11DepthStencilView * dsv
QD3D11RenderPassDescriptor * rp
QRhiRenderTargetAttachmentTracker::ResIdList currentResIdList
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QD3D11Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, AddressMode u, AddressMode v, AddressMode w)
ID3D11SamplerState * samplerState
bool create() override
StageUniformBufferBatches dsUniformBufferBatches
StageUniformBufferBatches hsUniformBufferBatches
StageUniformBufferBatches csUniformBufferBatches
StageUniformBufferBatches gsUniformBufferBatches
StageUniformBufferBatches vsUniformBufferBatches
StageUniformBufferBatches fsUniformBufferBatches
QRhiBatchedBindings< ID3D11SamplerState * > samplers
QRhiBatchedBindings< ID3D11ShaderResourceView * > shaderresources
QRhiBatchedBindings< ID3D11UnorderedAccessView * > uavs
QRhiBatchedBindings< ID3D11Buffer * > ubufs
QD3D11GraphicsPipeline * lastUsedGraphicsPipeline
bool create() override
Creates the corresponding resource binding set.
QVarLengthArray< BoundResourceData, 8 > boundResourceData
QVarLengthArray< QRhiShaderResourceBinding, 8 > sortedBindings
void updateResources(UpdateFlags flags) override
QD3D11ComputePipeline * lastUsedComputePipeline
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QD3D11ShaderResourceBindings(QRhiImplementation *rhi)
int sampleCount() const override
QD3D11SwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain)
float devicePixelRatio() const override
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QD3D11RenderTargetData d
QSize pixelSize() const override
bool prepare(QRhiD3D11 *rhiD)
bool tryQueryTimestamps(int idx, ID3D11DeviceContext *context, double *elapsedSec)
bool active[TIMESTAMP_PAIRS]
ID3D11Query * query[TIMESTAMP_PAIRS *2]
ID3D11Query * disjointQuery[TIMESTAMP_PAIRS]
static const int TIMESTAMP_PAIRS
QRhiSwapChainHdrInfo hdrInfo() override
\variable QRhiSwapChainHdrInfo::limitsType
HANDLE frameLatencyWaitableObject
QD3D11SwapChainTimestamps timestamps
QD3D11CommandBuffer cb
ID3D11RenderTargetView * backBufferRtv
int lastFrameLatencyWaitSlot
QWindow * window
QD3D11RenderBuffer * ds
QRhiRenderTarget * currentFrameRenderTarget() override
QD3D11SwapChainRenderTarget rtRight
ID3D11RenderTargetView * backBufferRtvRight
ID3D11Texture2D * msaaTex[BUFFER_COUNT]
DXGI_FORMAT colorFormat
QD3D11SwapChain(QRhiImplementation *rhi)
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
IDCompositionTarget * dcompTarget
QRhiRenderTarget * currentFrameRenderTarget(StereoTargetBuffer targetBuffer) override
ID3D11RenderTargetView * msaaRtv[BUFFER_COUNT]
bool createOrResize() override
Creates the swapchain if not already done and resizes the swapchain buffers to match the current size...
QSize surfacePixelSize() override
bool newColorBuffer(const QSize &size, DXGI_FORMAT format, DXGI_SAMPLE_DESC sampleDesc, ID3D11Texture2D **tex, ID3D11RenderTargetView **rtv) const
static const int BUFFER_COUNT
QD3D11SwapChainRenderTarget rt
bool isFormatSupported(Format f) override
DXGI_SAMPLE_DESC sampleDesc
IDCompositionVisual * dcompVisual
QRhiCommandBuffer * currentFrameCommandBuffer() override
int currentTimestampPairIndex
QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() override
IDXGISwapChain * swapChain
DXGI_FORMAT srgbAdjustedColorFormat
ID3D11Texture2D * backBufferTex
QSize pixelSize() const override
QD3D11TextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc, Flags flags)
ID3D11DepthStencilView * dsv
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
float devicePixelRatio() const override
QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() override
int sampleCount() const override
bool ownsRtv[QD3D11RenderTargetData::MAX_COLOR_ATTACHMENTS]
ID3D11RenderTargetView * rtv[QD3D11RenderTargetData::MAX_COLOR_ATTACHMENTS]
bool create() override
Creates the corresponding native graphics resources.
QD3D11RenderTargetData d
ID3D11Texture1D * tex1D
Definition qrhid3d11_p.h:93
bool create() override
Creates the corresponding native graphics resources.
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
bool createFrom(NativeTexture src) override
Similar to create(), except that no new native textures are created.
NativeTexture nativeTexture() override
ID3D11UnorderedAccessView * perLevelViews[QRhi::MAX_MIP_LEVELS]
Definition qrhid3d11_p.h:99
ID3D11Texture2D * tex
Definition qrhid3d11_p.h:91
bool prepareCreate(QSize *adjustedSize=nullptr)
DXGI_FORMAT dxgiFormat
Definition qrhid3d11_p.h:96
QD3D11Texture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth, int arraySize, int sampleCount, Flags flags)
ID3D11UnorderedAccessView * unorderedAccessViewForLevel(int level)
DXGI_SAMPLE_DESC sampleDesc
Definition qrhid3d11_p.h:98
bool finishCreate()
ID3D11ShaderResourceView * srv
Definition qrhid3d11_p.h:95
ID3D11Texture3D * tex3D
Definition qrhid3d11_p.h:92
ID3D11Resource * textureResource() const
Definition qrhid3d11_p.h:82
ID3D11Buffer * stagingBuf
QRhiReadbackResult * result
OffscreenFrame(QRhiImplementation *rhi)
ID3D11Query * tsDisjointQuery
ID3D11Query * tsQueries[2]
QD3D11CommandBuffer cbWrapper
Shader(IUnknown *s, const QByteArray &bytecode, const QShader::NativeResourceBindingMap &rbm)
QByteArray bytecode
QRhiReadbackResult * result
QRhiTexture::Format format
QRhiReadbackDescription desc
ID3D11Texture2D * stagingTex
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1830
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1551
ID3D11DepthStencilView * dsv
bool update(QD3D11RenderTargetData *data, ID3D11UnorderedAccessView *const *uavs=nullptr, int count=0)
ID3D11RenderTargetView * rtv[QD3D11RenderTargetData::MAX_COLOR_ATTACHMENTS]
std::array< ID3D11UnorderedAccessView *, QD3D11RenderTargetData::MAX_COLOR_ATTACHMENTS > uav
ID3D11Buffer * buffers[MAX_VERTEX_BUFFER_BINDING_COUNT]
QD3D11RenderTargetData * swapchainData
ID3D11ShaderResourceView * srv
UINT offsets[MAX_VERTEX_BUFFER_BINDING_COUNT]
uint dynamicOffsetPairs[MAX_DYNAMIC_OFFSET_COUNT *2]
QD3D11ComputePipeline * ps
QD3D11GraphicsPipeline * ps
UINT strides[MAX_VERTEX_BUFFER_BINDING_COUNT]