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
qrhivulkan_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 QRHIVULKAN_P_H
6#define QRHIVULKAN_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
21#include <QtCore/private/qflatmap_p.h>
22
23#ifdef Q_OS_WIN
24#include "qdxgihdrinfo_p.h"
25#endif
26
28
29class QVulkanFunctions;
30class QVulkanDeviceFunctions;
31
32static const int QVK_FRAMES_IN_FLIGHT = 2;
33
34static const int QVK_DESC_SETS_PER_POOL = 128;
35static const int QVK_UNIFORM_BUFFERS_PER_POOL = 256;
37static const int QVK_SAMPLED_IMAGES_PER_POOL = 256;
38static const int QVK_SAMPLERS_PER_POOL = 256;
39static const int QVK_STORAGE_BUFFERS_PER_POOL = 128;
40static const int QVK_STORAGE_IMAGES_PER_POOL = 128;
41
42static const int QVK_MAX_ACTIVE_TIMESTAMP_PAIRS = 16;
43
44// no vk_mem_alloc.h available here, void* is good enough
45typedef void * QVkAlloc;
46typedef void * QVkAllocator;
47
76
78
79struct QVkTexture;
80
82{
83 QVkRenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize,
84 int sampleCount, Flags flags,
85 QRhiTexture::Format backingFormatHint);
87 void destroy() override;
88 bool create() override;
89 QRhiTexture::Format backingFormat() const override;
90
98 uint generation = 0;
99 friend class QRhiVulkan;
100};
101
102struct QVkTexture : public QRhiTexture
103{
104 QVkTexture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth,
105 int arraySize, int sampleCount, Flags flags);
106 ~QVkTexture();
107 void destroy() override;
108 bool create() override;
109 bool createFrom(NativeTexture src) override;
110 NativeTexture nativeTexture() override;
111 void setNativeLayout(int layout) override;
112
113 bool prepareCreate(QSize *adjustedSize = nullptr);
114 bool finishCreate();
116
123 bool owns = true;
124 struct UsageState {
125 // no tracking of subresource layouts (some operations can keep
126 // subresources in different layouts for some time, but that does not
127 // need to be kept track of)
131 };
139 uint generation = 0;
140 friend class QRhiVulkan;
141};
142
143struct QVkSampler : public QRhiSampler
144{
145 QVkSampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
146 AddressMode u, AddressMode v, AddressMode w);
147 ~QVkSampler();
148 void destroy() override;
149 bool create() override;
150
153 uint generation = 0;
154 friend class QRhiVulkan;
155};
156
158{
159 QVkShadingRateMap(QRhiImplementation *rhi);
161 void destroy() override;
162 bool createFrom(QRhiTexture *src) override;
163
164 QVkTexture *texture = nullptr; // not owned
165 friend class QRhiVulkan;
166};
167
197
214
216{
217 QVkSwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain);
219 void destroy() override;
220
221 QSize pixelSize() const override;
222 float devicePixelRatio() const override;
223 int sampleCount() const override;
224
226};
227
250
252{
253 QVkShaderResourceBindings(QRhiImplementation *rhi);
255 void destroy() override;
256 bool create() override;
257 void updateResources(UpdateFlags flags) override;
258
261 int poolIndex = -1;
263 VkDescriptorSet descSets[QVK_FRAMES_IN_FLIGHT]; // multiple sets to support dynamic buffers
265 uint generation = 0;
266
267 // Keep track of the generation number of each referenced QRhi* to be able
268 // to detect that the underlying descriptor set became out of date and they
269 // need to be written again with the up-to-date VkBuffer etc. objects.
298
299 friend class QRhiVulkan;
300};
301
302
317
332
334{
335 QVkCommandBuffer(QRhiImplementation *rhi);
337 void destroy() override;
338
340
343
349
350 void resetState() {
352 passUsesSecondaryCb = false;
353 lastGpuTime = 0;
354 currentTarget = nullptr;
355 activeSecondaryCbStack.clear();
358 }
359
361 currentGraphicsPipeline = nullptr;
362 currentComputePipeline = nullptr;
364 currentGraphicsSrb = nullptr;
365 currentComputeSrb = nullptr;
368 currentIndexBuffer = VK_NULL_HANDLE;
369 currentIndexOffset = 0;
370 currentIndexFormat = VK_INDEX_TYPE_UINT16;
371 memset(currentVertexBuffers, 0, sizeof(currentVertexBuffers));
372 memset(currentVertexOffsets, 0, sizeof(currentVertexOffsets));
373 inExternal = false;
374 hasShadingRateSet = false;
375 hasCustomScissorSet = false;
376 currentViewport = {};
377 currentStencilRef = 0;
378 stencilRefValid = false;
379 }
380
383 double lastGpuTime = 0;
395 static const int VERTEX_INPUT_RESOURCE_SLOT_COUNT = 32;
405
412 void reset() {
413 writtenResources.clear();
414 }
415 } computePassState;
416
417 struct Command {
456
457 union Args {
458 struct {
459 VkBuffer src;
460 VkBuffer dst;
461 VkBufferCopy desc;
462 } copyBuffer;
463 struct {
464 VkBuffer dst;
465 VkDeviceSize offset;
466 VkDeviceSize size;
467 uint32_t data;
468 } fillBuffer;
469 struct {
470 VkBuffer src;
471 VkImage dst;
472 VkImageLayout dstLayout;
473 int count;
474 int bufferImageCopyIndex;
475 } copyBufferToImage;
476 struct {
477 VkImage src;
478 VkImageLayout srcLayout;
479 VkImage dst;
480 VkImageLayout dstLayout;
481 VkImageCopy desc;
482 } copyImage;
483 struct {
484 VkImage src;
485 VkImageLayout srcLayout;
486 VkBuffer dst;
487 int count;
488 int bufferImageCopyIndex;
489 } copyImageToBuffer;
490 struct {
491 VkPipelineStageFlags srcStageMask;
492 VkPipelineStageFlags dstStageMask;
493 int count;
494 int index;
495 } imageBarrier;
496 struct {
497 VkPipelineStageFlags srcStageMask;
498 VkPipelineStageFlags dstStageMask;
499 VkAccessFlags srcAccessMask;
500 VkAccessFlags dstAccessMask;
501 VkDependencyFlags dependencyFlags;
502 } memoryBarrier;
503 struct {
504 VkPipelineStageFlags srcStageMask;
505 VkPipelineStageFlags dstStageMask;
506 int count;
507 int index;
508 } bufferBarrier;
509 struct {
510 VkPipelineStageFlags srcStageMask;
511 VkPipelineStageFlags dstStageMask;
512 int imageCount;
513 int imageIndex;
514 int bufferCount;
515 int bufferIndex;
516 } imageAndBufferBarrier;
517 struct {
518 VkImage src;
519 VkImageLayout srcLayout;
520 VkImage dst;
521 VkImageLayout dstLayout;
522 VkFilter filter;
523 VkImageBlit desc;
524 } blitImage;
525 struct {
526 VkRenderPassBeginInfo desc;
527 int clearValueIndex;
528 bool useSecondaryCb;
529 } beginRenderPass;
530 struct {
531 } endRenderPass;
532 struct {
533 VkPipelineBindPoint bindPoint;
534 VkPipeline pipeline;
535 } bindPipeline;
536 struct {
537 VkPipelineBindPoint bindPoint;
538 VkPipelineLayout pipelineLayout;
539 VkDescriptorSet descSet;
540 int dynamicOffsetCount;
541 int dynamicOffsetIndex;
542 } bindDescriptorSet;
543 struct {
544 int startBinding;
545 int count;
546 int vertexBufferIndex;
547 int vertexBufferOffsetIndex;
548 } bindVertexBuffer;
549 struct {
550 VkBuffer buf;
551 VkDeviceSize ofs;
552 VkIndexType type;
553 } bindIndexBuffer;
554 struct {
555 VkViewport viewport;
556 } setViewport;
557 struct {
558 VkRect2D scissor;
559 } setScissor;
560 struct {
561 float c[4];
562 } setBlendConstants;
563 struct {
564 uint32_t ref;
565 } setStencilRef;
566 struct {
567 uint32_t vertexCount;
568 uint32_t instanceCount;
569 uint32_t firstVertex;
570 uint32_t firstInstance;
571 } draw;
572 struct {
573 uint32_t indexCount;
574 uint32_t instanceCount;
575 uint32_t firstIndex;
576 int32_t vertexOffset;
577 uint32_t firstInstance;
578 } drawIndexed;
579 struct {
580 VkBuffer indirectBuffer;
581 VkDeviceSize indirectBufferOffset;
582 uint32_t drawCount;
583 uint32_t stride;
584 } drawIndirect;
585 struct {
586 VkBuffer indirectBuffer;
587 VkDeviceSize indirectBufferOffset;
588 uint32_t drawCount;
589 uint32_t stride;
590 } drawIndexedIndirect;
591 struct {
592 VkBuffer indirectBuffer;
593 VkDeviceSize indirectBufferOffset;
594 VkBuffer countBuffer;
595 VkDeviceSize countBufferOffset;
596 uint32_t maxDrawCount;
597 uint32_t stride;
598 } drawIndirectCount;
599 struct {
600 VkBuffer indirectBuffer;
601 VkDeviceSize indirectBufferOffset;
602 VkBuffer countBuffer;
603 VkDeviceSize countBufferOffset;
604 uint32_t maxDrawCount;
605 uint32_t stride;
606 } drawIndexedIndirectCount;
607 struct {
608#ifdef VK_EXT_debug_utils
609 VkDebugUtilsLabelEXT label;
610 int labelNameIndex;
611#endif
612 } debugMarkerBegin;
613 struct {
614 } debugMarkerEnd;
615 struct {
616#ifdef VK_EXT_debug_utils
617 VkDebugUtilsLabelEXT label;
618 int labelNameIndex;
619#endif
620 } debugMarkerInsert;
621 struct {
622 int trackerIndex;
623 } transitionResources;
624 struct {
625 int x, y, z;
626 } dispatch;
627 struct {
628 VkBuffer indirectBuffer;
629 VkDeviceSize indirectBufferOffset;
630 } dispatchIndirect;
631 struct {
632 VkCommandBuffer cb;
633 } executeSecondary;
634 struct {
635 uint32_t w;
636 uint32_t h;
637 } setShadingRate;
638 struct {
639 VkPipelineLayout layout;
640 VkShaderStageFlags stages;
641 uint32_t offset;
642 uint32_t size;
643 int dataIndex;
644 } setPushConstants;
645 } args;
646 };
647
651
653 commands.reset();
655
656 passResTrackers.clear();
658 }
659
660 void resetPools() {
661 pools.clearValue.clear();
662 pools.bufferImageCopy.clear();
663 pools.dynamicOffset.clear();
664 pools.vertexBuffer.clear();
665 pools.vertexBufferOffset.clear();
666 pools.debugMarkerData.clear();
667 pools.imageBarrier.clear();
668 pools.bufferBarrier.clear();
669 pools.pushConstantData.clear();
670 }
671
672 struct {
673 QVarLengthArray<VkClearValue, 4> clearValue;
674 QVarLengthArray<VkBufferImageCopy, 16> bufferImageCopy;
675 QVarLengthArray<uint32_t, 4> dynamicOffset;
676 QVarLengthArray<VkBuffer, 4> vertexBuffer;
677 QVarLengthArray<VkDeviceSize, 4> vertexBufferOffset;
678 QVarLengthArray<QByteArray, 4> debugMarkerData;
679 QVarLengthArray<VkImageMemoryBarrier, 8> imageBarrier;
680 QVarLengthArray<VkBufferMemoryBarrier, 8> bufferBarrier;
681 QVarLengthArray<char, 256> pushConstantData;
682 } pools;
683
684 friend class QRhiVulkan;
685};
686
688
690{
691 QVkSwapChain(QRhiImplementation *rhi);
692 ~QVkSwapChain();
693 void destroy() override;
694
695 QRhiCommandBuffer *currentFrameCommandBuffer() override;
697 QRhiRenderTarget *currentFrameRenderTarget(StereoTargetBuffer targetBuffer) override;
698
699 QSize surfacePixelSize() override;
700 bool isFormatSupported(Format f) override;
702
705
706 bool ensureSurface();
707
709
710 QWindow *window = nullptr;
712 bool supportsReadback = false;
713 bool stereo = false;
715 int bufferCount = 0;
722 QVkRenderBuffer *ds = nullptr;
730
746
756
757 quint32 currentImageIndex = 0; // index in imageRes
758 int frameCount = 0;
759
760 friend class QRhiVulkan;
761};
762
764{
765public:
766 QRhiDriverInfo info() const override;
767
770};
771
773{
774public:
775 QRhiVulkan(QRhiVulkanInitParams *params, QRhiVulkanNativeHandles *importParams = 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;
845 void setShadingRate(QRhiCommandBuffer *cb, const QSize &coarsePixelSize) override;
846
847 void draw(QRhiCommandBuffer *cb, quint32 vertexCount,
848 quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override;
849
850 void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
851 quint32 instanceCount, quint32 firstIndex,
852 qint32 vertexOffset, quint32 firstInstance) override;
853
854 void drawIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer,
855 quint32 indirectBufferOffset, quint32 drawCount, quint32 stride) override;
856
857 void drawIndexedIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer,
858 quint32 indirectBufferOffset, quint32 drawCount, quint32 stride) override;
859
860 void drawIndirectCount(QRhiCommandBuffer *cb,
861 QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset,
862 QRhiBuffer *countBuffer, quint32 countBufferOffset,
863 quint32 maxDrawCount, quint32 stride) override;
864 void drawIndexedIndirectCount(QRhiCommandBuffer *cb,
865 QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset,
866 QRhiBuffer *countBuffer, quint32 countBufferOffset,
867 quint32 maxDrawCount, quint32 stride) override;
868
869 void dispatchIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer,
870 quint32 indirectBufferOffset) override;
871
872 void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override;
873 void debugMarkEnd(QRhiCommandBuffer *cb) override;
874 void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override;
875
876 void beginComputePass(QRhiCommandBuffer *cb,
877 QRhiResourceUpdateBatch *resourceUpdates,
878 QRhiCommandBuffer::BeginPassFlags flags) override;
879 void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
880 void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) override;
881 void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) 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
909 VkResult createDescriptorPool(VkDescriptorPool *pool);
910 bool allocateDescriptorSet(VkDescriptorSetAllocateInfo *allocInfo, VkDescriptorSet *result, int *resultPoolIndex);
911 uint32_t chooseTransientImageMemType(VkImage img, uint32_t startIndex);
912 bool createTransientImage(VkFormat format, const QSize &pixelSize, VkImageUsageFlags usage,
913 VkImageAspectFlags aspectMask, VkSampleCountFlagBits samples,
914 VkDeviceMemory *mem, VkImage *images, VkImageView *views, int count);
915
916 bool recreateSwapChain(QRhiSwapChain *swapChain);
917 void releaseSwapChainResources(QRhiSwapChain *swapChain);
918
922 bool hasDepthStencil,
923 VkSampleCountFlagBits samples,
924 VkFormat colorFormat,
925 QRhiShadingRateMap *shadingRateMap);
927 const QRhiColorAttachment *colorAttachmentsBegin,
928 const QRhiColorAttachment *colorAttachmentsEnd,
929 bool preserveColor,
930 bool preserveDs,
931 bool storeDs,
932 QRhiRenderBuffer *depthStencilBuffer,
933 QRhiTexture *depthTexture,
934 QRhiTexture *depthResolveTexture,
935 int depthLayer,
936 QRhiShadingRateMap *shadingRateMap);
937 bool ensurePipelineCache(const void *initialData = nullptr, size_t initialDataSize = 0);
938 VkShaderModule createShader(const QByteArray &spirv);
939
940 void prepareNewFrame(QRhiCommandBuffer *cb);
942 void endAndEnqueueSecondaryCommandBuffer(VkCommandBuffer cb, QVkCommandBuffer *cbD);
943 QRhi::FrameOpResult startPrimaryCommandBuffer(VkCommandBuffer *cb);
944 QRhi::FrameOpResult endAndSubmitPrimaryCommandBuffer(VkCommandBuffer cb, VkFence cmdFence,
945 VkSemaphore *waitSem, VkSemaphore *signalSem);
947 VkDeviceSize subresUploadByteSize(const QRhiTextureSubresourceUploadDescription &subresDesc) const;
949 void prepareUploadSubres(QVkTexture *texD, int layer, int level,
950 const QRhiTextureSubresourceUploadDescription &subresDesc,
951 size_t *curOfs, void *mp,
952 BufferImageCopyList *copyInfos);
953 void enqueueResourceUpdates(QVkCommandBuffer *cbD, QRhiResourceUpdateBatch *resourceUpdates);
954 void executeBufferHostWritesForSlot(QVkBuffer *bufD, int slot);
958 QVkBuffer *bufD,
959 int slot,
963 QVkTexture *texD,
967 QVarLengthArray<VkImageMemoryBarrier, 8> *imageBarriers,
968 QVarLengthArray<VkBufferMemoryBarrier, 8> *bufferBarriers);
971 void executeDeferredReleases(bool forced = false);
972 void finishActiveReadbacks(bool forced = false);
973
974 void setAllocationName(QVkAlloc allocation, const QByteArray &name, int slot = -1);
975 void setObjectName(uint64_t object, VkObjectType type, const QByteArray &name, int slot = -1);
976 void trackedBufferBarrier(QVkCommandBuffer *cbD, QVkBuffer *bufD, int slot,
977 VkAccessFlags access, VkPipelineStageFlags stage);
979 VkImageLayout layout, VkAccessFlags access, VkPipelineStageFlags stage);
981 void subresourceBarrier(QVkCommandBuffer *cbD, VkImage image,
982 VkImageLayout oldLayout, VkImageLayout newLayout,
983 VkAccessFlags srcAccess, VkAccessFlags dstAccess,
984 VkPipelineStageFlags srcStage, VkPipelineStageFlags dstStage,
985 int startLayer, int layerCount,
986 int startLevel, int levelCount);
987 void updateShaderResourceBindings(QRhiShaderResourceBindings *srb);
989 double elapsedSecondsFromTimestamp(quint64 timestamp[2], bool *ok);
990 void printExtraErrorInfo(VkResult err);
992 void printDeviceLossErrorInfo() const;
994 void recordStencilRef(QVkCommandBuffer *cbD, quint32 refValue);
995
997 QWindow *maybeWindow = nullptr;
999 bool importedDevice = false;
1008 bool importedAllocator = false;
1010 QVulkanFunctions *f = nullptr;
1011 QVulkanDeviceFunctions *df = nullptr;
1014#ifdef VK_VERSION_1_1
1017#endif
1018#ifdef VK_VERSION_1_2
1021#endif
1022#ifdef VK_VERSION_1_3
1024#endif
1025#ifdef VK_VERSION_1_4
1027#endif
1031 bool deviceLost = false;
1033
1034#ifdef Q_OS_WIN
1035 bool adapterLuidValid = false;
1037 QDxgiHdrInfo *dxgiHdrInfo = nullptr;
1038#endif
1039
1040#ifdef VK_EXT_debug_utils
1045#endif
1046
1055
1056#ifdef VK_KHR_create_renderpass2
1058#endif
1059
1060#ifdef VK_VERSION_1_2
1061 // Vulkan 1.2 core, not in QVulkanDeviceFunctions, so resolved manually.
1064#endif
1065
1066#ifdef VK_EXT_device_fault
1068#endif
1069
1070 struct {
1071 bool compute = false;
1072 bool depthClamp = false;
1073 bool wideLines = false;
1074 bool debugUtils = false;
1075 bool deviceFault = false;
1076 bool vertexAttribDivisor = false;
1077 bool texture3DSliceAs2D = false;
1078 bool tessellation = false;
1079 bool geometryShader = false;
1080 bool nonFillPolygonMode = false;
1081 bool multiView = false;
1082 bool renderPass2KHR = false;
1083 bool depthStencilResolveKHR = false;
1084 bool perDrawShadingRate = false;
1085 bool imageBasedShadingRate = false;
1086 QVersionNumber apiVersion;
1087 int imageBasedShadingRateTileSize = 0;
1088 bool drawIndirectMulti = false;
1089 bool shaderDrawParameters = false;
1090 bool drawIndirectCount = false;
1091 } caps;
1092
1105
1108
1111
1116
1118 OffscreenFrame(QRhiImplementation *rhi)
1119 {
1120 for (int i = 0; i < QVK_FRAMES_IN_FLIGHT; ++i) {
1121 cbWrapper[i] = new QVkCommandBuffer(rhi);
1122 cmdFence[i] = VK_NULL_HANDLE;
1123 cmdFenceWaitable[i] = false;
1124 timestampQueryIndex[i] = -1;
1125 }
1126 }
1128 {
1129 for (int i = 0; i < QVK_FRAMES_IN_FLIGHT; ++i)
1130 delete cbWrapper[i];
1131 }
1132 bool active = false;
1137 } ofr;
1138
1158
1173 int lastActiveFrameSlot; // -1 if not used otherwise 0..FRAMES_IN_FLIGHT-1
1174 union {
1175 struct {
1176 VkPipeline pipeline;
1177 VkPipelineLayout layout;
1178 } pipelineState;
1179 struct {
1180 int poolIndex;
1181 VkDescriptorSetLayout layout;
1182 } shaderResourceBindings;
1183 struct {
1184 VkBuffer buffers[QVK_FRAMES_IN_FLIGHT];
1185 QVkAlloc allocations[QVK_FRAMES_IN_FLIGHT];
1186 VkBuffer stagingBuffers[QVK_FRAMES_IN_FLIGHT];
1187 QVkAlloc stagingAllocations[QVK_FRAMES_IN_FLIGHT];
1188 } buffer;
1189 struct {
1190 VkDeviceMemory memory;
1191 VkImage image;
1192 VkImageView imageView;
1193 } renderBuffer;
1194 struct {
1195 VkImage image;
1196 VkImageView imageView;
1197 QVkAlloc allocation;
1198 VkBuffer stagingBuffers[QVK_FRAMES_IN_FLIGHT];
1199 QVkAlloc stagingAllocations[QVK_FRAMES_IN_FLIGHT];
1200 VkImageView extraImageViews[QRhi::MAX_MIP_LEVELS];
1201 } texture;
1202 struct {
1203 VkSampler sampler;
1204 } sampler;
1205 struct {
1206 VkFramebuffer fb;
1209 VkImageView dsv;
1210 VkImageView resdsv;
1211 VkImageView shadingRateMapView;
1212 } textureRenderTarget;
1213 struct {
1214 VkRenderPass rp;
1215 } renderPass;
1216 struct {
1217 VkBuffer stagingBuffer;
1218 QVkAlloc stagingAllocation;
1219 } stagingBuffer;
1220 struct {
1221 VkCommandBuffer cb;
1222 } secondaryCommandBuffer;
1223 };
1224 };
1226
1227#ifdef VK_KHR_fragment_shading_rate
1230#endif
1231
1236};
1237
1242
1243QT_END_NAMESPACE
1244
1245#endif
bool isEmpty() const
Definition qrhi.cpp:13657
const QRhiPassResourceMap< QRhiTexture *, Texture, 12 > & textures() const
Definition qrhi_p.h:976
void registerBuffer(QRhiBuffer *buf, int slot, BufferAccess *access, BufferStage *stage, const UsageState &state)
Definition qrhi.cpp:13674
void registerTexture(QRhiTexture *tex, TextureAccess *access, TextureStage *stage, const UsageState &state)
Definition qrhi.cpp:13714
const QRhiPassResourceMap< QRhiBuffer *, Buffer, 12 > & buffers() const
Definition qrhi_p.h:968
static QRhiResourceUpdateBatchPrivate * get(QRhiResourceUpdateBatch *b)
Definition qrhi_p.h:754
QVarLengthArray< DescriptorPoolData, 8 > descriptorPools
void recordTransitionPassResources(QVkCommandBuffer *cbD, const QRhiPassResourceTracker &tracker)
QVulkanFunctions * f
quint32 gfxQueueFamilyIdx
VkCommandBuffer startSecondaryCommandBuffer(QVkRenderTargetData *rtD=nullptr)
QRhiSwapChain * createSwapChain() override
PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR
void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override
int resourceLimit(QRhi::ResourceLimit limit) const override
bool isDeviceLost() const override
void prepareUploadSubres(QVkTexture *texD, int layer, int level, const QRhiTextureSubresourceUploadDescription &subresDesc, size_t *curOfs, void *mp, BufferImageCopyList *copyInfos)
VkPhysicalDeviceProperties physDevProperties
void executeDeferredReleases(bool forced=false)
uint32_t chooseTransientImageMemType(VkImage img, uint32_t startIndex)
QRhi::FrameOpResult finish() override
quint32 timestampValidBits
QRhiTextureRenderTarget * createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags) override
bool createTransientImage(VkFormat format, const QSize &pixelSize, VkImageUsageFlags usage, VkImageAspectFlags aspectMask, VkSampleCountFlagBits samples, VkDeviceMemory *mem, VkImage *images, VkImageView *views, int count)
void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override
void releaseCachedResources() override
QVkSwapChain * currentSwapChain
void collectComputeBarriers(QVkCommandBuffer *cbD, QVarLengthArray< VkImageMemoryBarrier, 8 > *imageBarriers, QVarLengthArray< VkBufferMemoryBarrier, 8 > *bufferBarriers)
bool importedDevice
QByteArrayList requestedDeviceExtensions
QRhiVulkan(QRhiVulkanInitParams *params, QRhiVulkanNativeHandles *importParams=nullptr)
void draw(QRhiCommandBuffer *cb, quint32 vertexCount, quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override
void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override
void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override
QList< int > supportedSampleCounts() const override
void destroy() override
QRhiRenderBuffer * createRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount, QRhiRenderBuffer::Flags flags, QRhiTexture::Format backingFormatHint) override
QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) override
QBitArray timestampQueryPoolMap
void updateShaderResourceBindings(QRhiShaderResourceBindings *srb)
void setPushConstants(QRhiCommandBuffer *cb, quint32 offset, quint32 size, const void *data) override
void dispatchIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset) override
double elapsedSecondsFromTimestamp(quint64 timestamp[2], bool *ok)
VkFormat optimalDsFormat
QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) override
VkDeviceQueueCreateFlags gfxQueueFlags
QVarLengthArray< VkSemaphore, 4 > waitSemaphoresForPresent
void drawIndexedIndirectCount(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset, QRhiBuffer *countBuffer, quint32 countBufferOffset, quint32 maxDrawCount, quint32 stride) override
void trackedBufferBarrier(QVkCommandBuffer *cbD, QVkBuffer *bufD, int slot, VkAccessFlags access, VkPipelineStageFlags stage)
QRhi::FrameOpResult waitCommandCompletion(int frameSlot)
void endExternal(QRhiCommandBuffer *cb) override
QWindow * maybeWindow
void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) override
VkPhysicalDeviceFeatures physDevFeatures
QRhiVulkanNativeHandles nativeHandlesStruct
bool allocateDescriptorSet(VkDescriptorSetAllocateInfo *allocInfo, VkDescriptorSet *result, int *resultPoolIndex)
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override
VkDevice dev
void drawIndexedIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset, quint32 drawCount, quint32 stride) override
VkResult createDescriptorPool(VkDescriptorPool *pool)
void prepareNewFrame(QRhiCommandBuffer *cb)
void subresourceBarrier(QVkCommandBuffer *cbD, VkImage image, VkImageLayout oldLayout, VkImageLayout newLayout, VkAccessFlags srcAccess, VkAccessFlags dstAccess, VkPipelineStageFlags srcStage, VkPipelineStageFlags dstStage, int startLayer, int layerCount, int startLevel, int levelCount)
QList< QSize > supportedShadingRates(int sampleCount) const override
void printExtraErrorInfo(VkResult err)
void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) override
QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) override
QRhi::FrameOpResult startPrimaryCommandBuffer(VkCommandBuffer *cb)
double lastCompletedGpuTime(QRhiCommandBuffer *cb) override
void recordStencilRef(QVkCommandBuffer *cbD, quint32 refValue)
void trackedRegisterTexture(QRhiPassResourceTracker *passResTracker, QVkTexture *texD, QRhiPassResourceTracker::TextureAccess access, QRhiPassResourceTracker::TextureStage stage)
bool releaseCachedResourcesCalledBeforeFrameStart
QRhi::Flags rhiFlags
PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR
QRhiGraphicsPipeline * createGraphicsPipeline() override
QRhiComputePipeline * createComputePipeline() override
void setAllocationName(QVkAlloc allocation, const QByteArray &name, int slot=-1)
QRhiTexture * createTexture(QRhiTexture::Format format, const QSize &pixelSize, int depth, int arraySize, int sampleCount, QRhiTexture::Flags flags) override
void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override
const QRhiNativeHandles * nativeHandles(QRhiCommandBuffer *cb) override
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR
bool recreateSwapChain(QRhiSwapChain *swapChain)
PFN_vkQueuePresentKHR vkQueuePresentKHR
Q_DECL_COLD_FUNCTION void printDeviceLossErrorInfo() const
bool ensurePipelineCache(const void *initialData=nullptr, size_t initialDataSize=0)
QRhiDriverInfo driverInfoStruct
void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override
QVarLengthArray< TextureReadback, 2 > activeTextureReadbacks
void depthStencilExplicitBarrier(QVkCommandBuffer *cbD, QVkRenderBuffer *rbD)
void trackedImageBarrier(QVkCommandBuffer *cbD, QVkTexture *texD, VkImageLayout layout, VkAccessFlags access, VkPipelineStageFlags stage)
VkCommandPool cmdPool[QVK_FRAMES_IN_FLIGHT]
VkShaderModule createShader(const QByteArray &spirv)
void enqueueTransitionPassResources(QVkCommandBuffer *cbD)
void beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags) override
bool create(QRhi::Flags flags) override
QVulkanDeviceFunctions * df
void setObjectName(uint64_t object, VkObjectType type, const QByteArray &name, int slot=-1)
bool isFeatureSupported(QRhi::Feature feature) const override
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR
QVarLengthArray< BufferReadback, 2 > activeBufferReadbacks
void recordPrimaryCommandBuffer(QVkCommandBuffer *cbD)
bool isYUpInFramebuffer() const override
void setShadingRate(QRhiCommandBuffer *cb, const QSize &coarsePixelSize) override
void debugMarkEnd(QRhiCommandBuffer *cb) override
QVulkanInstance * inst
QRhiSampler * createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter, QRhiSampler::Filter mipmapMode, QRhiSampler::AddressMode u, QRhiSampler::AddressMode v, QRhiSampler::AddressMode w) override
PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR
void releaseSwapChainResources(QRhiSwapChain *swapChain)
bool createOffscreenRenderPass(QVkRenderPassDescriptor *rpD, const QRhiColorAttachment *colorAttachmentsBegin, const QRhiColorAttachment *colorAttachmentsEnd, bool preserveColor, bool preserveDs, bool storeDs, QRhiRenderBuffer *depthStencilBuffer, QRhiTexture *depthTexture, QRhiTexture *depthResolveTexture, int depthLayer, QRhiShadingRateMap *shadingRateMap)
QVarLengthArray< VkSemaphore, 4 > signalSemaphoresForQueueSubmit
void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, quint32 instanceCount, quint32 firstIndex, qint32 vertexOffset, quint32 firstInstance) override
VkDeviceSize subresUploadByteSize(const QRhiTextureSubresourceUploadDescription &subresDesc) const
void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override
VkQueryPool timestampQueryPool
void trackedRegisterBuffer(QRhiPassResourceTracker *passResTracker, QVkBuffer *bufD, int slot, QRhiPassResourceTracker::BufferAccess access, QRhiPassResourceTracker::BufferStage stage)
VkFormat optimalDepthStencilFormat()
QRhiStats statistics() override
void setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline *ps) override
void drawIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset, quint32 drawCount, quint32 stride) override
void activateTextureRenderTarget(QVkCommandBuffer *cbD, QVkTextureRenderTarget *rtD)
PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR
QRhi::AdapterList enumerateAdaptersBeforeCreate(QRhiNativeHandles *nativeHandles) const override
QMatrix4x4 clipCorrectMatrix
void executeBufferHostWritesForSlot(QVkBuffer *bufD, int slot)
void setQueueSubmitParams(QRhiNativeHandles *params) override
void setDefaultScissor(QVkCommandBuffer *cbD)
bool isYUpInNDC() const override
const QRhiNativeHandles * nativeHandles() override
QVarLengthArray< VkPipelineStageFlags, 4 > semaphoresWaitMasksForQueueSubmit
QRhiShadingRateMap * createShadingRateMap() override
void setPipelineCacheData(const QByteArray &data) override
void setVertexInput(QRhiCommandBuffer *cb, int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings, QRhiBuffer *indexBuf, quint32 indexOffset, QRhiCommandBuffer::IndexFormat indexFormat) override
QRhiShaderResourceBindings * createShaderResourceBindings() override
VkPipelineCache pipelineCache
VkDeviceSize ubufAlign
void finishActiveReadbacks(bool forced=false)
void ensureCommandPoolForNewFrame()
QByteArray pipelineCacheData() override
quint32 gfxQueueIdx
VkDeviceSize texbufAlign
QList< DeferredReleaseEntry > releaseQueue
void endAndEnqueueSecondaryCommandBuffer(VkCommandBuffer cb, QVkCommandBuffer *cbD)
QVarLengthArray< VkSemaphore, 4 > waitSemaphoresForQueueSubmit
void beginPass(QRhiCommandBuffer *cb, QRhiRenderTarget *rt, const QColor &colorClearValue, const QRhiDepthStencilClearValue &depthStencilClearValue, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags) override
void drawIndirectCount(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset, QRhiBuffer *countBuffer, quint32 countBufferOffset, quint32 maxDrawCount, quint32 stride) override
void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) override
QRhiBuffer * createBuffer(QRhiBuffer::Type type, QRhiBuffer::UsageFlags usage, quint32 size) override
bool isClipDepthZeroToOne() const override
void enqueueResourceUpdates(QVkCommandBuffer *cbD, QRhiResourceUpdateBatch *resourceUpdates)
QVarLengthArray< VkCommandBuffer, 4 > freeSecondaryCbs[QVK_FRAMES_IN_FLIGHT]
void setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBindings *srb, int dynamicOffsetCount, const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) override
QVkAllocator allocator
bool importedAllocator
VkQueue gfxQueue
PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR
QMatrix4x4 clipSpaceCorrMatrix() const override
QSet< QVkSwapChain * > swapchains
int ubufAlignment() const override
QRhiDriverInfo driverInfo() const override
void beginExternal(QRhiCommandBuffer *cb) override
void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override
bool createDefaultRenderPass(QVkRenderPassDescriptor *rpD, bool hasDepthStencil, VkSampleCountFlagBits samples, VkFormat colorFormat, QRhiShadingRateMap *shadingRateMap)
QRhi::FrameOpResult endAndSubmitPrimaryCommandBuffer(VkCommandBuffer cb, VkFence cmdFence, VkSemaphore *waitSem, VkSemaphore *signalSem)
QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) override
VkSampleCountFlagBits effectiveSampleCountBits(int sampleCount)
VkPhysicalDevice physDev
bool makeThreadLocalNativeContextCurrent() override
QRhiDriverInfo adapterInfo
QRhiDriverInfo info() const override
VkPhysicalDevice physDev
Combined button and popup list for selecting options.
@ 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 VkPolygonMode toVkPolygonMode(QRhiGraphicsPipeline::PolygonMode mode)
static VkCullModeFlags toVkCullMode(QRhiGraphicsPipeline::CullMode c)
static bool accessIsWrite(VkAccessFlags access)
static VkCompareOp toVkTextureCompareOp(QRhiSampler::CompareOp op)
static QVulkanInstance * globalVulkanInstance
static VkBufferUsageFlagBits toVkBufferUsage(QRhiBuffer::UsageFlags usage)
static QRhiTexture::Format swapchainReadbackTextureFormat(VkFormat format, QRhiTexture::Flags *flags)
static VkStencilOp toVkStencilOp(QRhiGraphicsPipeline::StencilOp op)
static bool qvk_debug_filter(QVulkanInstance::DebugMessageSeverityFlags severity, QVulkanInstance::DebugMessageTypeFlags type, const void *callbackData)
static QVkBuffer::UsageState toVkBufferUsageState(QRhiPassResourceTracker::UsageState usage)
static bool attachmentDescriptionEquals(const VkAttachmentDescription &a, const VkAttachmentDescription &b)
static VkPipelineStageFlags toVkPipelineStage(QRhiPassResourceTracker::TextureStage stage)
static VkAccessFlags toVkAccess(QRhiPassResourceTracker::BufferAccess access)
static VkImageLayout toVkLayout(QRhiPassResourceTracker::TextureAccess access)
static VkFormat toVkAttributeFormat(QRhiVertexInputAttribute::Format format)
static QVkTexture::UsageState toVkTextureUsageState(QRhiPassResourceTracker::UsageState usage)
static VkPipelineStageFlags toVkPipelineStage(QRhiPassResourceTracker::BufferStage stage)
static QRhiDriverInfo::DeviceType toRhiDeviceType(VkPhysicalDeviceType type)
static QRhiPassResourceTracker::UsageState toPassTrackerUsageState(const QVkBuffer::UsageState &bufUsage)
static VkColorComponentFlags toVkColorComponents(QRhiGraphicsPipeline::ColorMask c)
static VkFilter toVkFilter(QRhiSampler::Filter f)
static VkPrimitiveTopology toVkTopology(QRhiGraphicsPipeline::Topology t)
static void qrhivk_releaseTexture(const QRhiVulkan::DeferredReleaseEntry &e, VkDevice dev, QVulkanDeviceFunctions *df, void *allocator)
static void qrhivk_releaseBuffer(const QRhiVulkan::DeferredReleaseEntry &e, void *allocator)
static VkAccessFlags toVkAccess(QRhiPassResourceTracker::TextureAccess access)
static VmaAllocator toVmaAllocator(QVkAllocator a)
static VkSamplerAddressMode toVkAddressMode(QRhiSampler::AddressMode m)
static constexpr bool isDepthTextureFormat(QRhiTexture::Format format)
static void fillVkStencilOpState(VkStencilOpState *dst, const QRhiGraphicsPipeline::StencilOpState &src)
static VkShaderStageFlags toVkShaderStageFlags(QRhiShaderResourceBinding::StageFlags stage)
static constexpr VkImageAspectFlags aspectMaskForTextureFormat(QRhiTexture::Format format)
static VkDescriptorType toVkDescriptorType(const QRhiShaderResourceBinding::Data *b)
static VkBlendFactor toVkBlendFactor(QRhiGraphicsPipeline::BlendFactor f)
static void fillDriverInfo(QRhiDriverInfo *info, const VkPhysicalDeviceProperties &physDevProperties)
static VkBlendOp toVkBlendOp(QRhiGraphicsPipeline::BlendOp op)
static void qrhivk_releaseRenderBuffer(const QRhiVulkan::DeferredReleaseEntry &e, VkDevice dev, QVulkanDeviceFunctions *df)
static VkFrontFace toVkFrontFace(QRhiGraphicsPipeline::FrontFace f)
void qrhivk_accumulateComputeResource(T *writtenResources, QRhiResource *resource, QRhiShaderResourceBinding::Type bindingType, int loadTypeVal, int storeTypeVal, int loadStoreTypeVal)
static VkFormat toVkTextureFormat(QRhiTexture::Format format, QRhiTexture::Flags flags)
static VkCompareOp toVkCompareOp(QRhiGraphicsPipeline::CompareOp op)
static void fillRenderPassCreateInfo(VkRenderPassCreateInfo *rpInfo, VkSubpassDescription *subpassDesc, QVkRenderPassDescriptor *rpD)
static VkSamplerMipmapMode toVkMipmapMode(QRhiSampler::Filter f)
static void qrhivk_releaseSampler(const QRhiVulkan::DeferredReleaseEntry &e, VkDevice dev, QVulkanDeviceFunctions *df)
static constexpr bool isStencilTextureFormat(QRhiTexture::Format format)
static QVkRenderTargetData * maybeRenderTargetData(QVkCommandBuffer *cbD)
static QRhiPassResourceTracker::UsageState toPassTrackerUsageState(const QVkTexture::UsageState &texUsage)
static VmaAllocation toVmaAllocation(QVkAlloc a)
static void addToChain(T *head, void *entry)
static void addSelfDependency(QVkRenderPassDescriptor *rpD)
static VkShaderStageFlagBits toVkShaderStage(QRhiShaderStage::Type type)
static const int QVK_UNIFORM_BUFFERS_PER_POOL
static const int QVK_COMBINED_IMAGE_SAMPLERS_PER_POOL
Q_DECLARE_TYPEINFO(QVkCommandBuffer::ComputePassState::AccessFlagsAndIsNew, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(QRhiVulkan::TextureReadback, Q_RELOCATABLE_TYPE)
static const int QVK_STORAGE_BUFFERS_PER_POOL
static const int QVK_STORAGE_IMAGES_PER_POOL
static const int QVK_SAMPLED_IMAGES_PER_POOL
void * QVkAllocator
Q_DECLARE_TYPEINFO(QRhiVulkan::DescriptorPoolData, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(QVkBuffer::DynamicUpdate, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(QRhiVulkan::DeferredReleaseEntry, Q_RELOCATABLE_TYPE)
static const int QVK_MAX_ACTIVE_TIMESTAMP_PAIRS
Q_DECLARE_TYPEINFO(QRhiVulkan::BufferReadback, Q_RELOCATABLE_TYPE)
static const int QVK_SAMPLERS_PER_POOL
static const int QVK_DESC_SETS_PER_POOL
void * QVkAlloc
static const int QVK_FRAMES_IN_FLIGHT
bool prepare(VkRenderPassCreateInfo *rpInfo, int multiViewCount, bool multiViewCap)
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:2016
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1616
QRhiReadbackResult * result
DescriptorPoolData(VkDescriptorPool pool_)
bool cmdFenceWaitable[QVK_FRAMES_IN_FLIGHT]
QVkCommandBuffer * cbWrapper[QVK_FRAMES_IN_FLIGHT]
int timestampQueryIndex[QVK_FRAMES_IN_FLIGHT]
VkFence cmdFence[QVK_FRAMES_IN_FLIGHT]
OffscreenFrame(QRhiImplementation *rhi)
QRhiTexture::Format format
QRhiReadbackDescription desc
QRhiReadbackResult * result
VkPipelineStageFlags stage
VkAccessFlags access
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
VkBuffer buffers[QVK_FRAMES_IN_FLIGHT]
QVkBuffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size)
UsageState usageState[QVK_FRAMES_IN_FLIGHT]
uint generation
VkBuffer stagingBuffers[QVK_FRAMES_IN_FLIGHT]
QVkAlloc allocations[QVK_FRAMES_IN_FLIGHT]
QVkAlloc stagingAllocations[QVK_FRAMES_IN_FLIGHT]
void endFullDynamicBufferUpdateForCurrentFrame() override
To be called when the entire contents of the buffer data has been updated in the memory block returne...
QRhiBuffer::NativeBuffer nativeBuffer() override
bool create() override
Creates the corresponding native graphics resources.
QVarLengthArray< DynamicUpdate, 16 > pendingDynamicUpdates[QVK_FRAMES_IN_FLIGHT]
char * beginFullDynamicBufferUpdateForCurrentFrame() override
int lastActiveFrameSlot
QVarLengthFlatMap< QRhiResource *, AccessFlagsAndIsNew, 12 > writtenResources
VkBuffer currentVertexBuffers[VERTEX_INPUT_RESOURCE_SLOT_COUNT]
QVkCommandBuffer(QRhiImplementation *rhi)
QVector< QRhiPassResourceTracker > passResTrackers
QVarLengthArray< VkCommandBuffer, 4 > activeSecondaryCbStack
QRhiBackendCommandList< Command > commands
QRhiRenderTarget * currentTarget
QRhiVulkanCommandBufferNativeHandles nativeHandlesStruct
quint32 currentVertexOffsets[VERTEX_INPUT_RESOURCE_SLOT_COUNT]
QRhiComputePipeline * currentComputePipeline
static const int VERTEX_INPUT_RESOURCE_SLOT_COUNT
const QRhiNativeHandles * nativeHandles()
QRhiShaderResourceBindings * currentComputeSrb
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QRhiShaderResourceBindings * currentGraphicsSrb
QRhiViewport currentViewport
PassType recordingPass
VkBuffer currentIndexBuffer
VkCommandBuffer cb
quint32 currentStencilRef
QRhiGraphicsPipeline * currentGraphicsPipeline
uint currentPipelineGeneration
quint32 currentIndexOffset
VkIndexType currentIndexFormat
VkShaderStageFlags pushConstantStages
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QVkComputePipeline(QRhiImplementation *rhi)
bool create() override
VkPipelineLayout layout
QVkGraphicsPipeline(QRhiImplementation *rhi)
VkShaderStageFlags pushConstantStages
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
VkPipelineLayout layout
bool create() override
Creates the corresponding native graphics resources.
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QVkRenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize, int sampleCount, Flags flags, QRhiTexture::Format backingFormatHint)
VkFormat vkformat
VkSampleCountFlagBits samples
QRhiTexture::Format backingFormat() const override
bool create() override
Creates the corresponding native graphics resources.
VkDeviceMemory memory
QVkTexture * backingTexture
VkImageView imageView
QVarLengthArray< VkSubpassDependency, 2 > subpassDeps
const QRhiNativeHandles * nativeHandles() override
QVector< quint32 > serializedFormatData
QVarLengthArray< VkAttachmentReference, 8 > colorRefs
QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() const override
VkAttachmentReference dsRef
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QVarLengthArray< VkAttachmentReference, 8 > resolveRefs
QVarLengthArray< VkAttachmentDescription, 8 > attDescs
VkAttachmentReference shadingRateRef
QRhiVulkanRenderPassNativeHandles nativeHandlesStruct
VkAttachmentReference dsResolveRef
QVector< quint32 > serializedFormat() const override
QVkRenderPassDescriptor(QRhiImplementation *rhi)
bool isCompatible(const QRhiRenderPassDescriptor *other) const override
QVkRenderPassDescriptor * rp
QRhiRenderTargetAttachmentTracker::ResIdList currentResIdList
static const int MAX_COLOR_ATTACHMENTS
int lastActiveFrameSlot
bool create() override
VkSampler sampler
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QVkSampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, AddressMode u, AddressMode v, AddressMode w)
VkDescriptorSetLayout layout
void updateResources(UpdateFlags flags) override
QVkShaderResourceBindings(QRhiImplementation *rhi)
bool create() override
Creates the corresponding resource binding set.
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QVarLengthArray< QRhiShaderResourceBinding, BINDING_PREALLOC > sortedBindings
QVarLengthArray< BoundResourceData, BINDING_PREALLOC > boundResourceData[QVK_FRAMES_IN_FLIGHT]
QVarLengthArray< int, BINDING_PREALLOC > sortedDynamicOffsetBindingNumbers
VkDescriptorSet descSets[QVK_FRAMES_IN_FLIGHT]
bool createFrom(QRhiTexture *src) override
Sets up the shading rate map to use the texture src as the image containing the per-tile shading rate...
QVkShadingRateMap(QRhiImplementation *rhi)
QVkTexture * texture
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QSize pixelSize() const override
int sampleCount() const override
float devicePixelRatio() const override
QVkRenderTargetData d
QVkSwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain)
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
VkColorSpaceKHR colorSpace
VkSurfaceKHR lastConnectedSurface
bool createOrResize() override
Creates the swapchain if not already done and resizes the swapchain buffers to match the current size...
VkSwapchainKHR sc
QRhiRenderTarget * currentFrameRenderTarget(StereoTargetBuffer targetBuffer) override
VkFormat colorFormat
bool isFormatSupported(Format f) override
QVkCommandBuffer cbWrapper
static const quint32 EXPECTED_MAX_BUFFER_COUNT
const VkFormat defaultSrgbColorFormat
QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() override
VkSampleCountFlagBits samples
bool supportsReadback
QVkSwapChain(QRhiImplementation *rhi)
QVkRenderBuffer * ds
QSize surfacePixelSize() override
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
VkDeviceMemory msaaImageMem
QRhiRenderTarget * currentFrameRenderTarget() override
quint32 currentImageIndex
QVarLengthArray< ImageResources, EXPECTED_MAX_BUFFER_COUNT > imageRes
VkSurfaceKHR surface
QVarLengthArray< VkPresentModeKHR, 8 > supportedPresentationModes
QWindow * window
QVkSwapChainRenderTarget rtWrapperRight
VkImageView shadingRateMapView
bool ensureSurface()
QVkSwapChainRenderTarget rtWrapper
QRhiSwapChainHdrInfo hdrInfo() override
\variable QRhiSwapChainHdrInfo::limitsType
QRhiCommandBuffer * currentFrameCommandBuffer() override
const VkFormat defaultColorFormat
VkImageView shadingRateMapView
QVkTextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc, Flags flags)
float devicePixelRatio() const override
VkImageView rtv[QVkRenderTargetData::MAX_COLOR_ATTACHMENTS]
bool create() override
Creates the corresponding native graphics resources.
int sampleCount() const override
QSize pixelSize() const override
QVkRenderTargetData d
VkImageView resrtv[QVkRenderTargetData::MAX_COLOR_ATTACHMENTS]
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() override
VkPipelineStageFlags stage
bool create() override
Creates the corresponding native graphics resources.
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
VkBuffer stagingBuffers[QVK_FRAMES_IN_FLIGHT]
VkFormat vkformat
bool finishCreate()
VkImageView perLevelImageViewForLoadStore(int level)
VkSampleCountFlagBits samples
int lastActiveFrameSlot
QVkAlloc stagingAllocations[QVK_FRAMES_IN_FLIGHT]
bool createFrom(NativeTexture src) override
Similar to create(), except that no new native textures are created.
VkFormat viewFormat
QVkAlloc imageAlloc
VkImage image
void setNativeLayout(int layout) override
With some graphics APIs, such as Vulkan, integrating custom rendering code that uses the graphics API...
VkFormat viewFormatForSampling
QVkTexture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth, int arraySize, int sampleCount, Flags flags)
VkImageView perLevelImageViews[QRhi::MAX_MIP_LEVELS]
NativeTexture nativeTexture() override
UsageState usageState
bool prepareCreate(QSize *adjustedSize=nullptr)
uint mipLevelCount
VkImageView imageView