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// Qt-Security score:significant reason:default
4
5#ifndef QRHID3D11_P_H
6#define QRHID3D11_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include "qrhi_p.h"
20#include <rhi/qshaderdescription.h>
21#include <QWindow>
22
23#include <d3d11_1.h>
24#include <dxgi1_6.h>
25#include <dcomp.h>
26
27#include <memory>
28
29QT_BEGIN_NAMESPACE
30
31class QRhiD3D11;
32
33struct QD3D11Buffer : public QRhiBuffer
34{
35 QD3D11Buffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size);
36 ~QD3D11Buffer();
37 void destroy() override;
38 bool create() override;
42
44 ID3D11UnorderedAccessView *createClearUnorderedAccessView(quint32 offset, quint32 size);
45
46 ID3D11Buffer *buffer = nullptr;
47 char *dynBuf = nullptr;
50 uint generation = 0;
51 friend class QRhiD3D11;
52};
53
55{
56 QD3D11RenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize,
57 int sampleCount, QRhiRenderBuffer::Flags flags,
58 QRhiTexture::Format backingFormatHint);
60 void destroy() override;
61 bool create() override;
62 QRhiTexture::Format backingFormat() const override;
63
64 ID3D11Texture2D *tex = nullptr;
69 uint generation = 0;
70 friend class QRhiD3D11;
71};
72
74{
75 QD3D11Texture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth,
76 int arraySize, int sampleCount, Flags flags);
78 void destroy() override;
79 bool create() override;
80 bool createFrom(NativeTexture src) override;
82
83 bool prepareCreate(QSize *adjustedSize = nullptr);
84 bool finishCreate();
87 {
88 if (tex)
89 return tex;
90 else if (tex1D)
91 return tex1D;
92 return tex3D;
93 }
94
95 ID3D11Texture2D *tex = nullptr;
98 bool owns = true;
104 uint generation = 0;
105 friend class QRhiD3D11;
106};
107
109{
110 QD3D11Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
111 AddressMode u, AddressMode v, AddressMode w);
112 ~QD3D11Sampler();
113 void destroy() override;
114 bool create() override;
115
117 uint generation = 0;
118 friend class QRhiD3D11;
119};
120
122{
123 QD3D11RenderPassDescriptor(QRhiImplementation *rhi);
125 void destroy() override;
126 bool isCompatible(const QRhiRenderPassDescriptor *other) const override;
128 QVector<quint32> serializedFormat() const override;
129};
130
132{
133 static const int MAX_COLOR_ATTACHMENTS = 8;
134
135 struct Views
136 {
140
141 void setFrom(int colorAttCount, ID3D11RenderTargetView * const *rtv, ID3D11DepthStencilView *dsv)
142 {
143 this->colorAttCount = colorAttCount;
144 for (int i = 0; i < colorAttCount; ++i)
145 this->rtv[i] = rtv[i];
146 for (int i = colorAttCount; i < MAX_COLOR_ATTACHMENTS; ++i)
147 this->rtv[i] = nullptr;
148 this->dsv = dsv;
149 }
150
151 void reset()
152 {
153 colorAttCount = 0;
154 for (int i = 0; i < MAX_COLOR_ATTACHMENTS; ++i)
155 rtv[i] = nullptr;
156 dsv = nullptr;
157 }
158 };
159
160 QD3D11RenderTargetData(QRhiImplementation *)
161 {
162 views.reset();
163 }
164
167 float dpr = 1;
168 int sampleCount = 1;
171};
172
174{
177 QD3D11RenderTargetUavUpdateState() { rtViews.reset(); uav.fill(nullptr); }
178 bool update(const QD3D11RenderTargetData::Views &currentRtViews, ID3D11UnorderedAccessView * const *uavs = nullptr, int count = 0);
179};
180
182{
183 QD3D11SwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain);
185 void destroy() override;
186
187 QSize pixelSize() const override;
188 float devicePixelRatio() const override;
189 int sampleCount() const override;
190
192};
193
195{
196 QD3D11TextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc, Flags flags);
198 void destroy() override;
199
200 QSize pixelSize() const override;
201 float devicePixelRatio() const override;
202 int sampleCount() const override;
203
205 bool create() override;
206
210 bool ownsDsv = false;
212 friend class QRhiD3D11;
213};
214
217
219{
220 QD3D11ShaderResourceBindings(QRhiImplementation *rhi);
222 void destroy() override;
223 bool create() override;
224 void updateResources(UpdateFlags flags) override;
225
226 bool hasDynamicOffset = false;
228 uint generation = 0;
231
232 // Keep track of the generation number of each referenced QRhi* to be able
233 // to detect that the batched bindings are out of date.
262
264 bool present = false;
269 void finish() {
270 present = ubufs.finish();
271 ubuforigbindings.finish();
272 ubufoffsets.finish();
273 ubufsizes.finish();
274 }
275 void clear() {
276 ubufs.clear();
277 ubuforigbindings.clear();
278 ubufoffsets.clear();
279 ubufsizes.clear();
280 }
281 };
282
284 bool present = false;
287 void finish() {
288 present = samplers.finish();
289 shaderresources.finish();
290 }
291 void clear() {
292 samplers.clear();
293 shaderresources.clear();
294 }
295 };
296
298 bool present = false;
300 void finish() {
301 present = uavs.finish();
302 }
303 void clear() {
304 uavs.clear();
305 }
306 };
307
315
322
325
326 void clear() {
327 vsUniformBufferBatches.clear();
328 hsUniformBufferBatches.clear();
329 dsUniformBufferBatches.clear();
330 gsUniformBufferBatches.clear();
331 fsUniformBufferBatches.clear();
332 csUniformBufferBatches.clear();
333
334 vsSamplerBatches.clear();
335 hsSamplerBatches.clear();
336 dsSamplerBatches.clear();
337 gsSamplerBatches.clear();
338 fsSamplerBatches.clear();
339 csSamplerBatches.clear();
340
341 csUavBatches.clear();
342 fsUavBatches.clear();
343 }
344 };
346
347 friend class QRhiD3D11;
348};
349
350
352{
353 QD3D11GraphicsPipeline(QRhiImplementation *rhi);
355 void destroy() override;
356 bool create() override;
357
360 struct {
361 ID3D11VertexShader *shader = nullptr;
362 QShader::NativeResourceBindingMap nativeResourceBindingMap;
363 } vs;
364 struct {
365 ID3D11HullShader *shader = nullptr;
366 QShader::NativeResourceBindingMap nativeResourceBindingMap;
367 } hs;
368 struct {
369 ID3D11DomainShader *shader = nullptr;
370 QShader::NativeResourceBindingMap nativeResourceBindingMap;
371 } ds;
372 struct {
373 ID3D11GeometryShader *shader = nullptr;
374 QShader::NativeResourceBindingMap nativeResourceBindingMap;
375 } gs;
376 struct {
377 ID3D11PixelShader *shader = nullptr;
378 QShader::NativeResourceBindingMap nativeResourceBindingMap;
379 } fs;
380 struct {
381 int reg = -1;
382 quint32 size = 0;
383 uint stages = 0;
384 } pushConstants;
388 uint generation = 0;
389 friend class QRhiD3D11;
390};
391
393{
394 QD3D11ComputePipeline(QRhiImplementation *rhi);
396 void destroy() override;
397 bool create() override;
398
399 struct {
400 ID3D11ComputeShader *shader = nullptr;
401 QShader::NativeResourceBindingMap nativeResourceBindingMap;
402 } cs;
403 struct {
404 int reg = -1;
405 quint32 size = 0;
406 } pushConstants;
407 uint generation = 0;
408 friend class QRhiD3D11;
409};
410
411struct QD3D11SwapChain;
412
414{
415 QD3D11CommandBuffer(QRhiImplementation *rhi);
417 void destroy() override;
418
419 // these must be kept at a reasonably low value otherwise sizeof Command explodes
420 static const int MAX_DYNAMIC_OFFSET_COUNT = 8;
422
423 struct Command {
455 enum ClearFlag { Color = 1, Depth = 2, Stencil = 4 };
457
458 // QRhi*/QD3D11* references should be kept at minimum, and avoided, if
459 // possible. So no QRhiTexture/Buffer/etc. pointers (or pointers to the
460 // internal d). Store D3D resource refs instead so there is no
461 // dependency on the QRhi* resource objects themselves anymore in the
462 // command list.
463 union Args {
464 struct {
465 ID3D11Query *tsQuery;
466 ID3D11Query *tsDisjointQuery;
467 ID3D11RenderTargetView *swapchainRtv;
468 ID3D11DepthStencilView *swapchainDsv;
469 } beginFrame;
470 struct {
471 ID3D11Query *tsQuery;
472 ID3D11Query *tsDisjointQuery;
473 } endFrame;
474 struct {
476 } setRenderTarget;
477 struct {
479 int mask;
480 float c[4];
481 float d;
482 quint32 s;
483 } clear;
484 struct {
485 float x, y, w, h;
486 float d0, d1;
487 } viewport;
488 struct {
489 int x, y, w, h;
490 } scissor;
491 struct {
492 int startSlot;
493 int slotCount;
494 ID3D11Buffer *buffers[MAX_VERTEX_BUFFER_BINDING_COUNT];
497 } bindVertexBuffers;
498 struct {
499 ID3D11Buffer *buffer;
500 quint32 offset;
501 DXGI_FORMAT format;
502 } bindIndexBuffer;
503 struct {
504 D3D11_PRIMITIVE_TOPOLOGY topology;
505 ID3D11InputLayout *inputLayout;
506 ID3D11DepthStencilState *dsState;
507 quint32 stencilRef;
508 ID3D11BlendState *blendState;
509 ID3D11RasterizerState *rastState;
510 ID3D11VertexShader *vs;
511 ID3D11HullShader *hs;
512 ID3D11DomainShader *ds;
513 ID3D11GeometryShader *gs;
514 ID3D11PixelShader *fs;
515 } bindGraphicsPipeline;
516 struct {
517 int resourceBatchesIndex;
518 bool offsetOnlyChange;
519 int dynamicOffsetCount;
520 uint dynamicOffsetPairs[MAX_DYNAMIC_OFFSET_COUNT * 2]; // binding, offsetInConstants
521 } bindShaderResources;
522 struct {
523 ID3D11Buffer *buffer;
524 quint32 dataOffset; // into pushConstantPool
525 quint32 size;
526 uint startSlot;
527 uint stages; // mask of RBM_* stage indices
528 } setPushConstants;
529 struct {
530 ID3D11DepthStencilState *dsState;
531 quint32 ref;
532 } stencilRef;
533 struct {
534 ID3D11BlendState *blendState;
535 float c[4];
536 } blendConstants;
537 struct {
538 quint32 vertexCount;
539 quint32 instanceCount;
540 quint32 firstVertex;
541 quint32 firstInstance;
542 } draw;
543 struct {
544 quint32 indexCount;
545 quint32 instanceCount;
546 quint32 firstIndex;
547 qint32 vertexOffset;
548 quint32 firstInstance;
549 } drawIndexed;
550 struct {
551 ID3D11Buffer *indirectBuffer;
552 quint32 indirectBufferOffset;
553 quint32 drawCount;
554 quint32 stride;
555 } drawIndirect;
556 struct {
557 ID3D11Buffer *indirectBuffer;
558 quint32 indirectBufferOffset;
559 quint32 drawCount;
560 quint32 stride;
561 } drawIndexedIndirect;
562 struct {
563 ID3D11Resource *dst;
564 UINT dstSubRes;
565 bool hasDstBox;
566 D3D11_BOX dstBox;
567 const void *src; // must come from retain*()
568 UINT srcRowPitch;
569 } updateSubRes;
570 struct {
571 ID3D11Resource *dst;
572 UINT dstSubRes;
573 UINT dstX;
574 UINT dstY;
575 UINT dstZ;
576 ID3D11Resource *src;
577 UINT srcSubRes;
578 bool hasSrcBox;
579 D3D11_BOX srcBox;
580 } copySubRes;
581 struct {
582 ID3D11UnorderedAccessView *uav;
583 UINT values[4];
584 } clearUav;
585 struct {
586 ID3D11Resource *dst;
587 UINT dstSubRes;
588 ID3D11Resource *src;
589 UINT srcSubRes;
590 DXGI_FORMAT format;
591 } resolveSubRes;
592 struct {
593 ID3D11ShaderResourceView *srv;
594 } genMip;
595 struct {
596 char s[64];
597 } debugMark;
598 struct {
599 ID3D11ComputeShader *cs;
600 } bindComputePipeline;
601 struct {
602 UINT x;
603 UINT y;
604 UINT z;
605 } dispatch;
606 struct {
607 ID3D11Buffer *indirectBuffer;
608 quint32 indirectBufferOffset;
609 } dispatchIndirect;
610 } args;
611 };
612
618
621 double lastGpuTime = 0;
637
644
645 // relies heavily on implicit sharing (no copies of the actual data will be made)
646 const uchar *retainData(const QByteArray &data) {
647 dataRetainPool.append(data);
648 return reinterpret_cast<const uchar *>(dataRetainPool.last().constData());
649 }
651 bufferDataRetainPool.append(data);
652 return reinterpret_cast<const uchar *>(bufferDataRetainPool.last().constData());
653 }
654 const uchar *retainImage(const QImage &image) {
655 imageRetainPool.append(image);
656 return imageRetainPool.last().constBits();
657 }
658 int retainResourceBatches(const std::shared_ptr<QD3D11ShaderResourceBindings::ResourceBatches> &resourceBatches) {
659 resourceBatchRetainPool.append(resourceBatches);
660 return resourceBatchRetainPool.count() - 1;
661 }
663 for (ID3D11UnorderedAccessView *uav : std::as_const(ownedUavs))
664 uav->Release();
665 ownedUavs.clear();
666 }
668 commands.reset();
669 pushConstantPool.clear();
670 dataRetainPool.clear();
671 bufferDataRetainPool.clear();
672 imageRetainPool.clear();
673 resourceBatchRetainPool.clear();
675 }
676 void resetState() {
678 // do not zero lastGpuTime
679 currentTarget = nullptr;
680 currentRenderTargetViews.reset();
683 }
685 currentGraphicsPipeline = nullptr;
686 currentComputePipeline = nullptr;
688 currentGraphicsSrb = nullptr;
689 currentComputeSrb = nullptr;
691 currentIndexBuffer = nullptr;
692 currentIndexOffset = 0;
693 currentIndexFormat = DXGI_FORMAT_R16_UINT;
694 pushConstantData.clear();
695 memset(currentVertexBuffers, 0, sizeof(currentVertexBuffers));
696 memset(currentVertexOffsets, 0, sizeof(currentVertexOffsets));
697 currentStencilRef = 0;
698 }
699};
700
702{
703 static const int TIMESTAMP_PAIRS = 2;
704
708
709 bool prepare(QRhiD3D11 *rhiD);
710 void destroy();
711 bool tryQueryTimestamps(int idx, ID3D11DeviceContext *context, double *elapsedSec);
712};
713
715{
716 QD3D11SwapChain(QRhiImplementation *rhi);
718 void destroy() override;
719
720 QRhiCommandBuffer *currentFrameCommandBuffer() override;
722 QRhiRenderTarget *currentFrameRenderTarget(StereoTargetBuffer targetBuffer) override;
723
724 QSize surfacePixelSize() override;
725 bool isFormatSupported(Format f) override;
727
730
731 void releaseBuffers();
732 bool newColorBuffer(const QSize &size, DXGI_FORMAT format, DXGI_SAMPLE_DESC sampleDesc,
733 ID3D11Texture2D **tex, ID3D11RenderTargetView **rtv) const;
734
735 QWindow *window = nullptr;
747 static const int BUFFER_COUNT = 2;
752 int frameCount = 0;
761};
762
764{
765public:
766 QRhiDriverInfo info() const override;
767
770};
771
773{
774public:
775 QRhiD3D11(QRhiD3D11InitParams *params, QRhiD3D11NativeHandles *importDevice = nullptr);
776
777 bool create(QRhi::Flags flags) override;
778 void destroy() override;
779 QRhi::AdapterList enumerateAdaptersBeforeCreate(QRhiNativeHandles *nativeHandles) const override;
780
784 QRhiBuffer *createBuffer(QRhiBuffer::Type type,
785 QRhiBuffer::UsageFlags usage,
786 quint32 size) override;
787 QRhiRenderBuffer *createRenderBuffer(QRhiRenderBuffer::Type type,
788 const QSize &pixelSize,
789 int sampleCount,
790 QRhiRenderBuffer::Flags flags,
791 QRhiTexture::Format backingFormatHint) override;
792 QRhiTexture *createTexture(QRhiTexture::Format format,
793 const QSize &pixelSize,
794 int depth,
795 int arraySize,
796 int sampleCount,
797 QRhiTexture::Flags flags) override;
798 QRhiSampler *createSampler(QRhiSampler::Filter magFilter,
799 QRhiSampler::Filter minFilter,
800 QRhiSampler::Filter mipmapMode,
801 QRhiSampler:: AddressMode u,
802 QRhiSampler::AddressMode v,
803 QRhiSampler::AddressMode w) override;
804
805 QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
806 QRhiTextureRenderTarget::Flags flags) override;
807
808 QRhiShadingRateMap *createShadingRateMap() override;
809
810 QRhiSwapChain *createSwapChain() override;
811 QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) override;
812 QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) override;
813 QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) override;
814 QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) override;
815 QRhi::FrameOpResult finish() override;
816
817 void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
818
819 void beginPass(QRhiCommandBuffer *cb,
820 QRhiRenderTarget *rt,
821 const QColor &colorClearValue,
822 const QRhiDepthStencilClearValue &depthStencilClearValue,
823 QRhiResourceUpdateBatch *resourceUpdates,
824 QRhiCommandBuffer::BeginPassFlags flags) override;
825 void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
826
827 void setGraphicsPipeline(QRhiCommandBuffer *cb,
828 QRhiGraphicsPipeline *ps) override;
829
830 void setShaderResources(QRhiCommandBuffer *cb,
831 QRhiShaderResourceBindings *srb,
832 int dynamicOffsetCount,
833 const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) override;
834
835 void setVertexInput(QRhiCommandBuffer *cb,
836 int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings,
837 QRhiBuffer *indexBuf, quint32 indexOffset,
838 QRhiCommandBuffer::IndexFormat indexFormat) override;
839
840 void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override;
841 void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override;
842 void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) override;
843 void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override;
844 void setPushConstants(QRhiCommandBuffer *cb, quint32 offset, quint32 size, const void *data) override;
846 void setShadingRate(QRhiCommandBuffer *cb, const QSize &coarsePixelSize) override;
847
848 void draw(QRhiCommandBuffer *cb, quint32 vertexCount,
849 quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override;
850
851 void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
852 quint32 instanceCount, quint32 firstIndex,
853 qint32 vertexOffset, quint32 firstInstance) override;
854
855 void drawIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer,
856 quint32 indirectBufferOffset, quint32 drawCount, quint32 stride) override;
857
858 void drawIndexedIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer,
859 quint32 indirectBufferOffset, quint32 drawCount, quint32 stride) override;
860
861 void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override;
862 void debugMarkEnd(QRhiCommandBuffer *cb) override;
863 void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override;
864
865 void beginComputePass(QRhiCommandBuffer *cb,
866 QRhiResourceUpdateBatch *resourceUpdates,
867 QRhiCommandBuffer::BeginPassFlags flags) override;
868 void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
869 void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) override;
870 void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) override;
871 void dispatchIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer,
872 quint32 indirectBufferOffset) override;
873
874 void drawIndirectCount(QRhiCommandBuffer *cb,
875 QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset,
876 QRhiBuffer *countBuffer, quint32 countBufferOffset,
877 quint32 maxDrawCount, quint32 stride) override;
878 void drawIndexedIndirectCount(QRhiCommandBuffer *cb,
879 QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset,
880 QRhiBuffer *countBuffer, quint32 countBufferOffset,
881 quint32 maxDrawCount, quint32 stride) override;
882
883 const QRhiNativeHandles *nativeHandles(QRhiCommandBuffer *cb) override;
884 void beginExternal(QRhiCommandBuffer *cb) override;
885 void endExternal(QRhiCommandBuffer *cb) override;
886 double lastCompletedGpuTime(QRhiCommandBuffer *cb) override;
887
888 QList<int> supportedSampleCounts() const override;
889 QList<QSize> supportedShadingRates(int sampleCount) const override;
890 int ubufAlignment() const override;
891 bool isYUpInFramebuffer() const override;
892 bool isYUpInNDC() const override;
893 bool isClipDepthZeroToOne() const override;
894 QMatrix4x4 clipSpaceCorrMatrix() const override;
895 bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override;
896 bool isFeatureSupported(QRhi::Feature feature) const override;
897 int resourceLimit(QRhi::ResourceLimit limit) const override;
898 const QRhiNativeHandles *nativeHandles() override;
899 QRhiDriverInfo driverInfo() const override;
900 QRhiStats statistics() override;
902 void setQueueSubmitParams(QRhiNativeHandles *params) override;
904 bool isDeviceLost() const override;
905
906 QByteArray pipelineCacheData() override;
907 void setPipelineCacheData(const QByteArray &data) override;
908
910 int layer, int level, const QRhiTextureSubresourceUploadDescription &subresDesc);
911 void enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates);
913 const QShader::NativeResourceBindingMap *nativeResourceBindingMaps[],
914 uint pushConstantStages);
916
918 const QD3D11ShaderResourceBindings::ResourceBatches &allResourceBatches,
919 const uint *dynOfsPairs, int dynOfsPairCount,
920 bool offsetOnlyChange,
924 DXGI_SAMPLE_DESC effectiveSampleDesc(int sampleCount) const;
926 void reportLiveObjects(ID3D11Device *device);
927 void clearShaderCache();
928 QByteArray compileHlslShaderSource(const QShader &shader, QShader::Variant shaderVariant, uint flags,
929 QString *error, QShaderKey *usedShaderKey);
931
933 bool debugLayer = false;
934 UINT maxFrameLatency = 2; // 1-3, use 2 to keep CPU-GPU parallelism while reducing lag compared to tripple buffering
936 ID3D11Device *dev = nullptr;
946 bool deviceLost = false;
949
950 struct {
951 int vsHighestActiveVertexBufferBinding = -1;
952 bool vsHasIndexBufferBound = false;
953 int vsHighestActiveSrvBinding = -1;
954 int hsHighestActiveSrvBinding = -1;
955 int dsHighestActiveSrvBinding = -1;
956 int gsHighestActiveSrvBinding = -1;
957 int fsHighestActiveSrvBinding = -1;
958 int csHighestActiveSrvBinding = -1;
959 int csHighestActiveUavBinding = -1;
960 int fsHighestActiveUavBinding = -1;
961 QD3D11SwapChain *currentSwapChain = nullptr;
962 } contextState;
963
964 static constexpr quint32 MAX_PUSH_CONSTANTS_SIZE = 128;
966
974
983 // The staging texture can be larger than the result, in which case
984 // the result starts at this position in it.
987 };
995
1009
1010 // This is what gets exposed as the "pipeline cache", not that that concept
1011 // applies anyway. Here we are just storing the DX bytecode for a shader so
1012 // we can skip the HLSL->DXBC compilation when the QShader has HLSL source
1013 // code and the same shader source has already been compiled before.
1014 // m_shaderCache seemingly does the same, but this here does not care about
1015 // the ID3D11*Shader, this is just about the bytecode and about allowing
1016 // the data to be serialized to persistent storage and then reloaded in
1017 // future runs of the app, or when creating another QRhi, etc.
1025};
1026
1029
1030inline bool operator==(const QRhiD3D11::BytecodeCacheKey &a, const QRhiD3D11::BytecodeCacheKey &b) noexcept
1031{
1032 return a.sourceHash == b.sourceHash
1033 && a.target == b.target
1034 && a.entryPoint == b.entryPoint
1036}
1037
1038inline bool operator!=(const QRhiD3D11::BytecodeCacheKey &a, const QRhiD3D11::BytecodeCacheKey &b) noexcept
1039{
1040 return !(a == b);
1041}
1042
1043inline size_t qHash(const QRhiD3D11::BytecodeCacheKey &k, size_t seed = 0) noexcept
1044{
1045 return qHashMulti(seed, k.sourceHash, k.target, k.entryPoint, k.compileFlags);
1046}
1047
1048QT_END_NAMESPACE
1049
1050#endif
QRhiDriverInfo info() const override
QRhiDriverInfo adapterInfo
void updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD, const QShader::NativeResourceBindingMap *nativeResourceBindingMaps[], uint pushConstantStages)
void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override
bool deviceLost
void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override
static constexpr quint32 MAX_PUSH_CONSTANTS_SIZE
QRhiD3D11NativeHandles nativeHandlesStruct
bool isYUpInNDC() const override
void drawIndexedIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset, quint32 drawCount, quint32 stride) 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
void executeBufferHostWrites(QD3D11Buffer *bufD)
QRhiStats statistics() override
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
void dispatchIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset) override
IDXGIAdapter1 * activeAdapter
QRhiGraphicsPipeline * createGraphicsPipeline() override
void drawIndirectCount(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset, QRhiBuffer *countBuffer, quint32 countBufferOffset, quint32 maxDrawCount, quint32 stride) 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
bool isClipDepthZeroToOne() const override
IDCompositionDevice * dcompDevice
QRhiDriverInfo driverInfoStruct
QHash< QRhiShaderStage, Shader > m_shaderCache
void resetShaderResources(QD3D11CommandBuffer *cbD, QD3D11RenderTargetUavUpdateState *rtUavState)
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)
void reportLiveObjects(ID3D11Device *device)
void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override
void destroy() override
QMatrix4x4 clipSpaceCorrMatrix() const override
void setPushConstants(QRhiCommandBuffer *cb, quint32 offset, quint32 size, const void *data) 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
ID3D11Buffer * pushConstantBuffer
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
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
bool ensurePushConstantBuffer()
void drawIndexedIndirectCount(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset, QRhiBuffer *countBuffer, quint32 countBufferOffset, quint32 maxDrawCount, quint32 stride) 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 finishActiveReadbacks()
IDXGIFactory1 * dxgiFactory
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 bindShaderResources(QD3D11CommandBuffer *cbD, const QD3D11ShaderResourceBindings::ResourceBatches &allResourceBatches, const uint *dynOfsPairs, int dynOfsPairCount, bool offsetOnlyChange, QD3D11RenderTargetUavUpdateState *rtUavState)
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
QRhiRenderBuffer * createRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount, QRhiRenderBuffer::Flags flags, QRhiTexture::Format backingFormatHint) override
void setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline *ps) override
QRhiD3D11(QRhiD3D11InitParams *params, QRhiD3D11NativeHandles *importDevice=nullptr)
DXGI_SAMPLE_DESC effectiveSampleDesc(int sampleCount) const
void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override
void drawIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset, quint32 drawCount, quint32 stride) override
QRhiBinaryCache< BytecodeCacheKey, QByteArray > m_bytecodeCache
static QRhiResourceUpdateBatchPrivate * get(QRhiResourceUpdateBatch *b)
Definition qrhi_p.h:754
void fillDriverInfo(QRhiDriverInfo *info, const DXGI_ADAPTER_DESC1 &desc)
@ UnBounded
Definition qrhi_p.h:390
@ Bounded
Definition qrhi_p.h:391
#define QRHI_RES_RHI(t)
Definition qrhi_p.h:33
#define QRHI_RES(t, x)
Definition qrhi_p.h:32
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 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 std::pair< int, int > mapBinding(int binding, int stageIndex, const QShader::NativeResourceBindingMap *nativeResourceBindingMaps[], uint pushConstantStages)
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 int rbmStageIndex(QRhiShaderStage::Type type)
static DXGI_FORMAT toD3DAttributeFormat(QRhiVertexInputAttribute::Format format)
static void getPushConstantInfo(const QShader &shader, const QShaderKey &key, int *reg, quint32 *size)
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)
bool operator==(const QRhiD3D11::BytecodeCacheKey &a, const QRhiD3D11::BytecodeCacheKey &b) noexcept
bool hasPendingDynamicUpdates
Definition qrhid3d11_p.h:48
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:47
ID3D11Buffer * buffer
Definition qrhid3d11_p.h:46
QD3D11Buffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size)
char * beginFullDynamicBufferUpdateForCurrentFrame() override
bool create() override
Creates the corresponding native graphics resources.
ID3D11UnorderedAccessView * createClearUnorderedAccessView(quint32 offset, quint32 size)
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QHash< quint32, ID3D11UnorderedAccessView * > uavs
Definition qrhid3d11_p.h:49
QRhiBuffer::NativeBuffer nativeBuffer() override
ID3D11UnorderedAccessView * unorderedAccessView(quint32 offset)
QRhiRenderTarget * currentTarget
QVarLengthArray< char, 1024 > pushConstantPool
QVarLengthArray< char, 128 > pushConstantData
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
QVarLengthArray< std::shared_ptr< const QD3D11ShaderResourceBindings::ResourceBatches >, 4 > resourceBatchRetainPool
static const int MAX_VERTEX_BUFFER_BINDING_COUNT
int retainResourceBatches(const std::shared_ptr< QD3D11ShaderResourceBindings::ResourceBatches > &resourceBatches)
QRhiShaderResourceBindings * currentGraphicsSrb
QVarLengthArray< ID3D11UnorderedAccessView *, 4 > ownedUavs
const uchar * retainImage(const QImage &image)
QD3D11CommandBuffer(QRhiImplementation *rhi)
QD3D11RenderTargetData::Views currentRenderTargetViews
const uchar * retainData(const QByteArray &data)
QRhiShaderResourceBindings * currentComputeSrb
QRhiBackendCommandList< Command > commands
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
QD3D11ComputePipeline(QRhiImplementation *rhi)
bool create() override
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QD3D11GraphicsPipeline(QRhiImplementation *rhi)
ID3D11InputLayout * inputLayout
ID3D11BlendState * blendState
ID3D11RasterizerState * rastState
D3D11_PRIMITIVE_TOPOLOGY d3dTopology
bool create() override
Creates the corresponding native graphics resources.
ID3D11DepthStencilState * dsState
QD3D11RenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize, int sampleCount, QRhiRenderBuffer::Flags flags, QRhiTexture::Format backingFormatHint)
ID3D11RenderTargetView * rtv
Definition qrhid3d11_p.h:66
DXGI_FORMAT dxgiFormat
Definition qrhid3d11_p.h:67
ID3D11DepthStencilView * dsv
Definition qrhid3d11_p.h:65
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
DXGI_SAMPLE_DESC sampleDesc
Definition qrhid3d11_p.h:68
bool create() override
Creates the corresponding native graphics resources.
QRhiTexture::Format backingFormat() const override
ID3D11Texture2D * tex
Definition qrhid3d11_p.h:64
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
ID3D11RenderTargetView * rtv[MAX_COLOR_ATTACHMENTS]
ID3D11DepthStencilView * dsv
void setFrom(int colorAttCount, ID3D11RenderTargetView *const *rtv, ID3D11DepthStencilView *dsv)
static const int MAX_COLOR_ATTACHMENTS
QD3D11RenderTargetData(QRhiImplementation *)
QD3D11RenderPassDescriptor * rp
QRhiRenderTargetAttachmentTracker::ResIdList currentResIdList
std::array< ID3D11UnorderedAccessView *, QD3D11RenderTargetData::MAX_COLOR_ATTACHMENTS > uav
bool update(const QD3D11RenderTargetData::Views &currentRtViews, ID3D11UnorderedAccessView *const *uavs=nullptr, int count=0)
QD3D11RenderTargetData::Views rtViews
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
std::shared_ptr< ResourceBatches > resourceBatches
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:97
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]
ID3D11Texture2D * tex
Definition qrhid3d11_p.h:95
bool prepareCreate(QSize *adjustedSize=nullptr)
DXGI_FORMAT dxgiFormat
QD3D11Texture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth, int arraySize, int sampleCount, Flags flags)
ID3D11UnorderedAccessView * unorderedAccessViewForLevel(int level)
DXGI_SAMPLE_DESC sampleDesc
bool finishCreate()
ID3D11ShaderResourceView * srv
Definition qrhid3d11_p.h:99
ID3D11Texture3D * tex3D
Definition qrhid3d11_p.h:96
ID3D11Resource * textureResource() const
Definition qrhid3d11_p.h:86
ID3D11Buffer * stagingBuf
QRhiReadbackResult * result
OffscreenFrame(QRhiImplementation *rhi)
ID3D11Query * tsDisjointQuery
ID3D11Query * tsQueries[2]
QD3D11CommandBuffer cbWrapper
QByteArray bytecode
Shader(IUnknown *s, const QByteArray &bytecode, const QShader::NativeResourceBindingMap &rbm, int pushConstantRegister=-1, quint32 pushConstantSize=0)
QRhiReadbackResult * result
QRhiTexture::Format format
QRhiReadbackDescription desc
ID3D11Texture2D * stagingTex
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:2016
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1616