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
qrhimetal_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 QRHIMETAL_P_H
6#define QRHIMETAL_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 <QWindow>
21
22#include <optional>
23
25
26static const int QMTL_FRAMES_IN_FLIGHT = 2;
27
28// have to hide the ObjC stuff, this header cannot contain MTL* at all
29struct QMetalBufferData;
30
31struct QMetalBuffer : public QRhiBuffer
32{
33 QMetalBuffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size);
34 ~QMetalBuffer();
35 void destroy() override;
36 bool create() override;
40
42 uint generation = 0;
44 friend class QRhiMetal;
46
47 // Internal usage flags. Buffers created with any of these are not visible
48 // to the application and bypass QRhi::newBuffer(), so they are free to use
49 // bits outside of QRhiBuffer::UsageFlag.
50 static constexpr int WorkBufPoolUsage = 1 << 8;
51 // Marks internal buffers that must keep being written by the CPU, and so
52 // can never be backed by device private memory.
53 static constexpr int InternalHostWritable = 1 << 9;
55};
56
58
60{
61 QMetalRenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize,
62 int sampleCount, QRhiRenderBuffer::Flags flags,
63 QRhiTexture::Format backingFormatHint);
65 void destroy() override;
66 bool create() override;
67 QRhiTexture::Format backingFormat() const override;
68
70 int samples = 1;
71 uint generation = 0;
73 friend class QRhiMetal;
74};
75
77
79{
80 QMetalTexture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth,
81 int arraySize, int sampleCount, Flags flags);
83 void destroy() override;
84 bool create() override;
85 bool createFrom(NativeTexture src) override;
87
88 bool prepareCreate(QSize *adjustedSize = nullptr);
89
92 int samples = 1;
93 uint generation = 0;
95 friend class QRhiMetal;
97 friend struct QMetalTextureData;
98};
99
100struct QMetalSamplerData;
101
103{
104 QMetalSampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
105 AddressMode u, AddressMode v, AddressMode w);
106 ~QMetalSampler();
107 void destroy() override;
108 bool create() override;
109
111 uint generation = 0;
113 friend class QRhiMetal;
115};
116
118
120{
121 QMetalShadingRateMap(QRhiImplementation *rhi);
123 void destroy() override;
124 bool createFrom(NativeShadingRateMap src) override;
125 QSize logicalSize() const override;
126
128 uint generation = 0;
130 friend class QRhiMetal;
131};
132
134
136{
137 QMetalIndirectCommandBuffer(QRhiImplementation *rhi, Type type, quint32 maxCommandCount);
139 void destroy() override;
140 bool create() override;
141
143 {
144 return reinterpret_cast<const QRhiIndirectDrawCommand *>(m_data.constData());
145 }
147 {
148 return reinterpret_cast<const QRhiIndexedIndirectDrawCommand *>(m_data.constData());
149 }
150 quint64 contentsGeneration() const { return m_generation; }
151
154 friend class QRhiMetal;
155};
156
158{
159 QMetalRenderPassDescriptor(QRhiImplementation *rhi);
161 void destroy() override;
162 bool isCompatible(const QRhiRenderPassDescriptor *other) const override;
164 QVector<quint32> serializedFormat() const override;
165
167
168 // there is no MTLRenderPassDescriptor here as one will be created for each pass in beginPass()
169
170 // but the things needed for the render pipeline descriptor have to be provided
171 static const int MAX_COLOR_ATTACHMENTS = 8;
173 bool hasDepthStencil = false;
176 bool hasShadingRateMap = false;
178};
179
181
183{
184 QMetalSwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain);
186 void destroy() override;
187
188 QSize pixelSize() const override;
189 float devicePixelRatio() const override;
190 int sampleCount() const override;
191
193};
194
196{
197 QMetalTextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc, Flags flags);
199 void destroy() override;
200
201 QSize pixelSize() const override;
202 float devicePixelRatio() const override;
203 int sampleCount() const override;
204
206 bool create() override;
207
209 friend class QRhiMetal;
210};
211
214
260
263struct QMetalShader;
264
266{
267 QMetalGraphicsPipeline(QRhiImplementation *rhi);
269 void destroy() override;
270 bool create() override;
271
274 void setupMetalDepthStencilDescriptor(void *metalDsDesc);
275 void mapStates();
277 bool createTessellationPipelines(const QShader &tessVert, const QShader &tesc, const QShader &tese, const QShader &tessFrag);
278
280 uint generation = 0;
282 friend class QRhiMetal;
283};
284
286
288{
289 QMetalComputePipeline(QRhiImplementation *rhi);
291 void destroy() override;
292 bool create() override;
293
295 uint generation = 0;
297 friend class QRhiMetal;
298};
299
301struct QMetalSwapChain;
302
304{
305 QMetalCommandBuffer(QRhiImplementation *rhi);
307 void destroy() override;
308
311
317
318 // per-pass (render or compute command encoder) persistent state
321
322 // per-pass (render or compute command encoder) volatile (cached) state
337 std::pair<float, float> currentDepthBiasValues;
347
349 void resetState(double lastGpuTime = 0);
350 void resetPerPassState();
352};
353
355
357{
358 QMetalSwapChain(QRhiImplementation *rhi);
360 void destroy() override;
361
362 QRhiCommandBuffer *currentFrameCommandBuffer() override;
364 QSize surfacePixelSize() override;
365 bool isFormatSupported(Format f) override;
366
368
370
371 virtual QRhiSwapChainHdrInfo hdrInfo() override;
372
373 void chooseFormats();
374 void waitUntilCompleted(int slot);
375
376 QWindow *window = nullptr;
378 int currentFrameSlot = 0; // 0..QMTL_FRAMES_IN_FLIGHT-1
379 int frameCount = 0;
380 int samples = 1;
385};
386
387struct QRhiMetalData;
388
390{
391public:
392 QRhiMetal(QRhiMetalInitParams *params, QRhiMetalNativeHandles *importDevice = nullptr);
393 ~QRhiMetal();
394
395 static bool probe(QRhiMetalInitParams *params);
396 static QRhiSwapChainProxyData updateSwapChainProxyData(QWindow *window);
397
398 bool create(QRhi::Flags flags) override;
399 void destroy() override;
400
404 QRhiBuffer *createBuffer(QRhiBuffer::Type type,
405 QRhiBuffer::UsageFlags usage,
406 quint32 size) override;
407 QRhiRenderBuffer *createRenderBuffer(QRhiRenderBuffer::Type type,
408 const QSize &pixelSize,
409 int sampleCount,
410 QRhiRenderBuffer::Flags flags,
411 QRhiTexture::Format backingFormatHint) override;
412 QRhiTexture *createTexture(QRhiTexture::Format format,
413 const QSize &pixelSize,
414 int depth,
415 int arraySize,
416 int sampleCount,
417 QRhiTexture::Flags flags) override;
418 QRhiSampler *createSampler(QRhiSampler::Filter magFilter,
419 QRhiSampler::Filter minFilter,
420 QRhiSampler::Filter mipmapMode,
421 QRhiSampler:: AddressMode u,
422 QRhiSampler::AddressMode v,
423 QRhiSampler::AddressMode w) override;
424
425 QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
426 QRhiTextureRenderTarget::Flags flags) override;
427
428 QRhiShadingRateMap *createShadingRateMap() override;
429
430 QRhiIndirectCommandBuffer *createIndirectCommandBuffer(QRhiIndirectCommandBuffer::Type type,
431 quint32 maxCommandCount) override;
432 void buildIndirect(QRhiCommandBuffer *cb, QRhiIndirectCommandBuffer *icb,
433 const QRhiIndirectCommandBufferBuildInfo &info) override;
434 void executeIndirect(QRhiCommandBuffer *cb, QRhiIndirectCommandBuffer *icb,
435 quint32 firstCommand, quint32 commandCount) override;
436 void commitIndirectCommandBuffer(QRhiResourceUpdateBatch *u,
437 QRhiIndirectCommandBuffer *icb) override;
438
439 QRhiSwapChain *createSwapChain() override;
440 QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) override;
441 QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) override;
442 QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) override;
443 QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) override;
444 QRhi::FrameOpResult finish() override;
445
446 void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
447
448 void beginPass(QRhiCommandBuffer *cb,
449 QRhiRenderTarget *rt,
450 const QColor &colorClearValue,
451 const QRhiDepthStencilClearValue &depthStencilClearValue,
452 QRhiResourceUpdateBatch *resourceUpdates,
453 QRhiCommandBuffer::BeginPassFlags flags) override;
454 void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
455
456 void setGraphicsPipeline(QRhiCommandBuffer *cb,
457 QRhiGraphicsPipeline *ps) override;
458
459 void setShaderResources(QRhiCommandBuffer *cb,
460 QRhiShaderResourceBindings *srb,
461 int dynamicOffsetCount,
462 const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) override;
463
464 void setVertexInput(QRhiCommandBuffer *cb,
465 int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings,
466 QRhiBuffer *indexBuf, quint32 indexOffset,
467 QRhiCommandBuffer::IndexFormat indexFormat) override;
468
469 void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override;
470 void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override;
471 void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) override;
472 void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override;
473 void setPushConstants(QRhiCommandBuffer *cb, quint32 offset, quint32 size, const void *data) override;
474 void setShadingRate(QRhiCommandBuffer *cb, const QSize &coarsePixelSize) override;
475
476 void draw(QRhiCommandBuffer *cb, quint32 vertexCount,
477 quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override;
478
479 void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
480 quint32 instanceCount, quint32 firstIndex,
481 qint32 vertexOffset, quint32 firstInstance) override;
482
483 void drawIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer,
484 quint32 indirectBufferOffset, quint32 drawCount, quint32 stride) override;
485
486 void drawIndexedIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer,
487 quint32 indirectBufferOffset, quint32 drawCount, quint32 stride) override;
488
489 void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override;
490 void debugMarkEnd(QRhiCommandBuffer *cb) override;
491 void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override;
492
493 void beginComputePass(QRhiCommandBuffer *cb,
494 QRhiResourceUpdateBatch *resourceUpdates,
495 QRhiCommandBuffer::BeginPassFlags flags) override;
496 void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
497 void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) override;
498 void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) override;
499 void dispatchIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer,
500 quint32 indirectBufferOffset) override;
501
502 void drawIndirectCount(QRhiCommandBuffer *cb,
503 QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset,
504 QRhiBuffer *countBuffer, quint32 countBufferOffset,
505 quint32 maxDrawCount, quint32 stride) override;
506 void drawIndexedIndirectCount(QRhiCommandBuffer *cb,
507 QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset,
508 QRhiBuffer *countBuffer, quint32 countBufferOffset,
509 quint32 maxDrawCount, quint32 stride) override;
510
511 const char *icbUnavailableReason(QMetalCommandBuffer *cbD) const;
512 bool prepareIcbKernels();
513 bool prepareIcb(quint32 maxDrawCount);
514 bool icbDraw(QMetalCommandBuffer *cbD, bool indexed,
515 QMetalBuffer *indirectBufD, quint32 indirectBufferOffset,
516 QMetalBuffer *countBufD, quint32 countBufferOffset,
517 quint32 maxDrawCount, quint32 stride);
518
519 const QRhiNativeHandles *nativeHandles(QRhiCommandBuffer *cb) override;
520 void beginExternal(QRhiCommandBuffer *cb) override;
521 void endExternal(QRhiCommandBuffer *cb) override;
522 double lastCompletedGpuTime(QRhiCommandBuffer *cb) override;
523
524 QList<int> supportedSampleCounts() const override;
525 QList<QSize> supportedShadingRates(int sampleCount) const override;
526 int ubufAlignment() const override;
527 bool isYUpInFramebuffer() const override;
528 bool isYUpInNDC() const override;
529 bool isClipDepthZeroToOne() const override;
530 QMatrix4x4 clipSpaceCorrMatrix() const override;
531 bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override;
532 bool isFeatureSupported(QRhi::Feature feature) const override;
533 int resourceLimit(QRhi::ResourceLimit limit) const override;
534 const QRhiNativeHandles *nativeHandles() override;
535 QRhiDriverInfo driverInfo() const override;
536 QRhiStats statistics() override;
538 void setQueueSubmitParams(QRhiNativeHandles *params) override;
540 bool isDeviceLost() const override;
541
542 QByteArray pipelineCacheData() override;
543 void setPipelineCacheData(const QByteArray &data) override;
544
545 void executeDeferredReleases(bool forced = false);
546 void finishActiveReadbacks(bool forced = false);
547 qsizetype subresUploadByteSize(const QRhiTextureSubresourceUploadDescription &subresDesc) const;
548 void enqueueSubresUpload(QMetalTexture *texD, void *mp, void *blitEncPtr,
549 int layer, int level, const QRhiTextureSubresourceUploadDescription &subresDesc,
550 qsizetype *curOfs);
551 void enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates);
552 void executeBufferHostWritesForSlot(QMetalBuffer *bufD, int slot);
554 void finalizeDeferredStoreActions(QMetalCommandBuffer *cbD, bool passIsEnding);
556 static const int SUPPORTED_STAGES = 5;
559 int dynamicOffsetCount,
560 const QRhiCommandBuffer::DynamicOffset *dynamicOffsets,
561 bool offsetOnlyChange,
562 const QShader::NativeResourceBindingMap *nativeResourceBindingMaps[SUPPORTED_STAGES],
563 const QMetalShader *shaders[SUPPORTED_STAGES]);
565 static QSize outputSizeForTarget(QRhiRenderTarget *target);
566
593 void tessellatedDraw(const TessDrawArgs &args);
594 void adjustForMultiViewDraw(quint32 *instanceCount, QRhiCommandBuffer *cb);
595
597 bool importedDevice = false;
598 bool importedCmdQueue = false;
605
606 struct {
607 int maxTextureSize = 4096;
608 bool baseVertexAndInstance = true;
609 QVector<int> supportedSampleCounts;
610 bool isAppleGPU = false;
611 // Immutable and Static buffers are backed by a single, device private
612 // MTLBuffer, with uploads going through a staging buffer and a blit.
613 // Requires an Apple GPU because MTLBlitCommandEncoder's
614 // buffer-to-buffer copy has a 4 byte alignment requirement on
615 // non-Apple GPUs, whereas uploadStaticBuffer() allows any offset and
616 // size.
617 bool usePrivateStaticBuffers = false;
618 int maxThreadGroupSize = 512;
619 bool multiView = false;
620 bool indirectCommandBuffers = false;
621 bool shadingRateMap = false;
622 bool depthClamp = true;
623 bool fragmentStoresAndAtomics = false;
624 } caps;
625
626 QRhiMetalData *d = nullptr;
627};
628
629QT_END_NAMESPACE
630
631#endif
void buildIndirect(QRhiCommandBuffer *cb, QRhiIndirectCommandBuffer *icb, const QRhiIndirectCommandBufferBuildInfo &info) override
void drawIndirectCount(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset, QRhiBuffer *countBuffer, quint32 countBufferOffset, quint32 maxDrawCount, quint32 stride) override
static QRhiSwapChainProxyData updateSwapChainProxyData(QWindow *window)
QMetalSwapChain * currentSwapChain
bool isDeviceLost() const override
QRhiMetalNativeHandles nativeHandlesStruct
void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) override
QRhiStats statistics() override
void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, quint32 instanceCount, quint32 firstIndex, qint32 vertexOffset, quint32 firstInstance) override
void executeBufferHostWritesForCurrentFrame(QMetalBuffer *bufD)
int ubufAlignment() const override
Definition qrhimetal.mm:868
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override
Definition qrhimetal.mm:899
void endExternal(QRhiCommandBuffer *cb) override
QRhiMetalData * d
void drawIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset, quint32 drawCount, quint32 stride) override
QRhiMetal(QRhiMetalInitParams *params, QRhiMetalNativeHandles *importDevice=nullptr)
Definition qrhimetal.mm:577
void beginPass(QRhiCommandBuffer *cb, QRhiRenderTarget *rt, const QColor &colorClearValue, const QRhiDepthStencilClearValue &depthStencilClearValue, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags) override
qsizetype subresUploadByteSize(const QRhiTextureSubresourceUploadDescription &subresDesc) const
void beginExternal(QRhiCommandBuffer *cb) override
quint32 osMajor
void adjustForMultiViewDraw(quint32 *instanceCount, QRhiCommandBuffer *cb)
void setDefaultScissor(QMetalCommandBuffer *cbD)
void enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD, QMetalCommandBuffer *cbD, int dynamicOffsetCount, const QRhiCommandBuffer::DynamicOffset *dynamicOffsets, bool offsetOnlyChange, const QShader::NativeResourceBindingMap *nativeResourceBindingMaps[SUPPORTED_STAGES], const QMetalShader *shaders[SUPPORTED_STAGES])
QRhiSwapChain * createSwapChain() override
Definition qrhimetal.mm:858
QRhiGraphicsPipeline * createGraphicsPipeline() override
QRhiIndirectCommandBuffer * createIndirectCommandBuffer(QRhiIndirectCommandBuffer::Type type, quint32 maxCommandCount) override
const char * icbUnavailableReason(QMetalCommandBuffer *cbD) const
bool create(QRhi::Flags flags) override
Definition qrhimetal.mm:653
QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) override
QRhi::Flags rhiFlags
void dispatchIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset) override
void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) override
void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override
QRhiSampler * createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter, QRhiSampler::Filter mipmapMode, QRhiSampler::AddressMode u, QRhiSampler::AddressMode v, QRhiSampler::AddressMode w) override
void setPushConstants(QRhiCommandBuffer *cb, quint32 offset, quint32 size, const void *data) override
static const int SUPPORTED_STAGES
QRhiRenderBuffer * createRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount, QRhiRenderBuffer::Flags flags, QRhiTexture::Format backingFormatHint) override
void setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline *ps) override
bool isYUpInNDC() const override
Definition qrhimetal.mm:878
void commitIndirectCommandBuffer(QRhiResourceUpdateBatch *u, QRhiIndirectCommandBuffer *icb) override
int resourceLimit(QRhi::ResourceLimit limit) const override
QRhiShaderResourceBindings * createShaderResourceBindings() override
void executeBufferHostWritesForSlot(QMetalBuffer *bufD, int slot)
QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) override
QMatrix4x4 clipSpaceCorrMatrix() const override
Definition qrhimetal.mm:888
void drawIndexedIndirectCount(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset, QRhiBuffer *countBuffer, quint32 countBufferOffset, quint32 maxDrawCount, quint32 stride) override
void setQueueSubmitParams(QRhiNativeHandles *params) override
const QRhiNativeHandles * nativeHandles() override
void interruptRenderPass(QMetalCommandBuffer *cbD)
void executeDeferredReleases(bool forced=false)
void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override
QRhiComputePipeline * createComputePipeline() override
void drawIndexedIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset, quint32 drawCount, quint32 stride) override
bool isClipDepthZeroToOne() const override
Definition qrhimetal.mm:883
static QSize outputSizeForTarget(QRhiRenderTarget *target)
QList< int > supportedSampleCounts() const override
Definition qrhimetal.mm:847
QRhiTextureRenderTarget * createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags) override
bool isYUpInFramebuffer() const override
Definition qrhimetal.mm:873
bool prepareIcbKernels()
QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) override
quint32 osMinor
const QRhiNativeHandles * nativeHandles(QRhiCommandBuffer *cb) override
void enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)
void setPipelineCacheData(const QByteArray &data) override
void finalizeDeferredStoreActions(QMetalCommandBuffer *cbD, bool passIsEnding)
QByteArray pipelineCacheData() override
void setShadingRate(QRhiCommandBuffer *cb, const QSize &coarsePixelSize) override
void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override
void setVertexInput(QRhiCommandBuffer *cb, int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings, QRhiBuffer *indexBuf, quint32 indexOffset, QRhiCommandBuffer::IndexFormat indexFormat) override
void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) override
bool importedDevice
void tessellatedDraw(const TessDrawArgs &args)
void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override
void debugMarkEnd(QRhiCommandBuffer *cb) override
QRhi::FrameOpResult finish() override
QSet< QMetalSwapChain * > swapchains
QRhiShadingRateMap * createShadingRateMap() override
bool importedCmdQueue
QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) override
bool makeThreadLocalNativeContextCurrent() override
QRhiTexture * createTexture(QRhiTexture::Format format, const QSize &pixelSize, int depth, int arraySize, int sampleCount, QRhiTexture::Flags flags) override
QRhiBuffer * createBuffer(QRhiBuffer::Type type, QRhiBuffer::UsageFlags usage, quint32 size) override
Definition qrhimetal.mm:863
void setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBindings *srb, int dynamicOffsetCount, const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) override
void releaseCachedResources() override
bool icbDraw(QMetalCommandBuffer *cbD, bool indexed, QMetalBuffer *indirectBufD, quint32 indirectBufferOffset, QMetalBuffer *countBufD, quint32 countBufferOffset, quint32 maxDrawCount, quint32 stride)
QRhiDriverInfo driverInfoStruct
void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override
void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override
void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override
QRhiDriverInfo driverInfo() const override
double lastCompletedGpuTime(QRhiCommandBuffer *cb) override
void draw(QRhiCommandBuffer *cb, quint32 vertexCount, quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override
void executeIndirect(QRhiCommandBuffer *cb, QRhiIndirectCommandBuffer *icb, quint32 firstCommand, quint32 commandCount) override
bool prepareIcb(quint32 maxDrawCount)
void finishActiveReadbacks(bool forced=false)
static bool probe(QRhiMetalInitParams *params)
Definition qrhimetal.mm:608
void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override
bool isFeatureSupported(QRhi::Feature feature) const override
Definition qrhimetal.mm:932
void enqueueSubresUpload(QMetalTexture *texD, void *mp, void *blitEncPtr, int layer, int level, const QRhiTextureSubresourceUploadDescription &subresDesc, qsizetype *curOfs)
void destroy() override
Definition qrhimetal.mm:781
QList< QSize > supportedShadingRates(int sampleCount) const override
Definition qrhimetal.mm:852
void beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags) override
static QRhiResourceUpdateBatchPrivate * get(QRhiResourceUpdateBatch *b)
Definition qrhi_p.h:754
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:326
\inmodule QtGui
Definition qshader.h:81
Combined button and popup list for selecting options.
#define __has_feature(x)
@ 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
Int aligned(Int v, Int byteAlign)
\variable QRhiVulkanQueueSubmitParams::waitSemaphoreCount
static int mtlPushConstantBufferIndex(const QMetalShader &s)
static bool usesTextures(const QShaderDescription &desc)
static MTLStencilOperation toMetalStencilOp(QRhiGraphicsPipeline::StencilOp op)
static void qrhimtl_releaseIcbSlots(QRhiMetal *rhiD, QMetalIndirectCommandBuffer *icbD)
static MTLLanguageVersion toMetalLanguageVersion(const QShaderVersion &version)
static MTLPrimitiveTopologyClass toMetalPrimitiveTopologyClass(QRhiGraphicsPipeline::Topology t)
static CAMetalLayer * layerForWindow(QWindow *window)
static void addVertexAttribute(const T &variable, int binding, QRhiMetal *rhiD, int &index, quint32 &offset, MTLVertexAttributeDescriptorArray *attributes, quint64 &indices, quint32 &vertexAlignment)
static void qrhimtl_releaseRenderBuffer(const QRhiMetalData::DeferredReleaseEntry &e)
static void qrhimtl_encodeIcbFromCpu(QMetalIndirectCommandBuffer *icbD, QMetalIndirectCommandBufferData::Slot &slot, MTLPrimitiveType primitiveType, id< MTLBuffer > indexBufMtl, quint32 indexOffset, QRhiCommandBuffer::IndexFormat indexFormat)
static bool hasArgumentBufferVariant(const QShader &shader)
static bool matches(const QList< QShaderDescription::BlockVariable > &a, const QList< QShaderDescription::BlockVariable > &b)
Q_DECLARE_TYPEINFO(QRhiMetalData::TextureReadback, Q_RELOCATABLE_TYPE)
static MTLBlendOperation toMetalBlendOp(QRhiGraphicsPipeline::BlendOp op)
static QMetalRenderTargetData * currentRenderTargetData(QMetalCommandBuffer *cbD)
static MTLBlendFactor toMetalBlendFactor(QRhiGraphicsPipeline::BlendFactor f)
static MTLWinding toMetalTessellationWindingOrder(QShaderDescription::TessellationWindingOrder w)
static MTLPrimitiveType toMetalPrimitiveType(QRhiGraphicsPipeline::Topology t)
static MTLCompareFunction toMetalCompareOp(QRhiGraphicsPipeline::CompareOp op)
static MTLVertexFormat toMetalAttributeFormat(QRhiVertexInputAttribute::Format format)
static constexpr quint32 ICB_DRAW_COUNT_THRESHOLD
BindingType
static MTLTriangleFillMode toMetalTriangleFillMode(QRhiGraphicsPipeline::PolygonMode mode)
static quint32 mtlPushConstantBlockSize(const QMetalShader &s)
static MTLSamplerMinMagFilter toMetalFilter(QRhiSampler::Filter f)
static MTLCullMode toMetalCullMode(QRhiGraphicsPipeline::CullMode c)
static void qrhimtl_releaseBuffer(const QRhiMetalData::DeferredReleaseEntry &e)
static void endTempComputeEncoding(QRhiMetal *rhiD, QMetalCommandBuffer *cbD, id< MTLComputeCommandEncoder > computeEncoder)
static void takeIndex(quint32 index, quint64 &indices)
static int mapBinding(int binding, int stageIndex, const QShader::NativeResourceBindingMap *nativeResourceBindingMaps[], BindingType type)
static id< MTLComputeCommandEncoder > tempComputeEncoder(QRhiMetal *rhiD, QMetalCommandBuffer *cbD, id< MTLComputeCommandEncoder > maybeComputeEncoder)
static void rebindShaderResources(QMetalCommandBuffer *cbD, int resourceStage, int encoderStage, const QMetalShaderResourceBindingsData *customBindingState=nullptr)
static void qrhimtl_releaseSampler(const QRhiMetalData::DeferredReleaseEntry &e)
static MTLPixelFormat toMetalTextureFormat(QRhiTexture::Format format, QRhiTexture::Flags flags, const QRhiMetal *d)
static QRhiShaderResourceBinding::StageFlag toRhiSrbStage(int stage)
static void setupArgumentBufferEncoder(QMetalShader *shader)
static void addUnusedVertexAttribute(const T &variable, QRhiMetal *rhiD, quint32 &offset, quint32 &vertexAlignment)
static uint toMetalColorWriteMask(QRhiGraphicsPipeline::ColorMask c)
static MTLStoreAction interruptionStoreAction(MTLStoreAction finalAction, bool passIsEnding)
#define QRHI_METAL_COMMAND_BUFFERS_WITH_UNRETAINED_REFERENCES
Definition qrhimetal.mm:62
static void qrhimtl_replayIcbOnCpu(QMetalCommandBuffer *cbD, QMetalIndirectCommandBuffer *icbD, quint32 firstCommand, quint32 count, int currentFrameSlot)
static bool qrhimtl_ensureIcbSlots(QRhiMetal *rhiD, QMetalIndirectCommandBuffer *icbD, QMetalIndirectCommandBufferData::Fill fill)
static MTLSamplerMipFilter toMetalMipmapMode(QRhiSampler::Filter f)
static MTLTessellationPartitionMode toMetalTessellationPartitionMode(QShaderDescription::TessellationPartitioning p)
static MTLCompareFunction toMetalTextureCompareFunction(QRhiSampler::CompareOp op)
static int aligned(quint32 offset, quint32 alignment)
static void declareStageArgumentBufferResources(QMetalCommandBuffer *cbD, int encoderStage, const QMetalShaderResourceBindingsData::Stage &res)
static bool canStoreAttachment(id< MTLTexture > tex)
Q_DECLARE_TYPEINFO(QRhiMetalData::DeferredReleaseEntry, Q_RELOCATABLE_TYPE)
static MTLResourceUsage storageImageUsage(QRhiShaderResourceBinding::Type type)
static bool qrhimtl_icbSlotMatches(const QMetalIndirectCommandBuffer *icbD, const QMetalIndirectCommandBufferData::Slot &slot, MTLPrimitiveType primitiveType, id< MTLBuffer > indexBufMtl, quint32 indexOffset, QRhiCommandBuffer::IndexFormat indexFormat)
static MTLSamplerAddressMode toMetalAddressMode(QRhiSampler::AddressMode m)
static void bindStageBuffers(QMetalCommandBuffer *cbD, int stage, const QRhiBatchedBindings< id< MTLBuffer > >::Batch &bufferBatch, const QRhiBatchedBindings< NSUInteger >::Batch &offsetBatch)
static void qrhimtl_releaseTexture(const QRhiMetalData::DeferredReleaseEntry &e)
static void encodeIcbWithCompute(QRhiMetalData *d, id< MTLComputeCommandEncoder > computeEncoder, id< MTLIndirectCommandBuffer > targetIcb, id< MTLBuffer > targetArgBuffer, id< MTLBuffer > targetRangeBuffer, bool indexed, QRhiCommandBuffer::IndexFormat indexFormat, MTLPrimitiveType primitiveType, id< MTLBuffer > indirectBufMtl, quint32 indirectBufferOffset, id< MTLBuffer > indexBufMtl, quint32 indexBufferOffset, id< MTLBuffer > countBufMtl, quint32 countBufferOffset, quint32 maxDrawCount, quint32 stride)
static bool indexTaken(quint32 index, quint64 indices)
static void bindStageTextures(QMetalCommandBuffer *cbD, int stage, const QRhiBatchedBindings< id< MTLTexture > >::Batch &textureBatch)
#define QRHI_METAL_DISABLE_BINARY_ARCHIVE
Definition qrhimetal.mm:57
static void bindStageSamplers(QMetalCommandBuffer *cbD, int encoderStage, const QRhiBatchedBindings< id< MTLSamplerState > >::Batch &samplerBatch)
static int nextAttributeIndex(quint64 indices)
static QT_BEGIN_NAMESPACE const int QMTL_FRAMES_IN_FLIGHT
Definition qrhimetal_p.h:26
void f(int c)
[26]
QVarLengthArray< BufferUpdate, 16 > pendingUpdates[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:365
id< MTLBuffer > buf[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:360
char * beginFullDynamicBufferUpdateForCurrentFrame() override
QMetalBufferData * d
Definition qrhimetal_p.h:41
QMetalBuffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size)
static constexpr int WorkBufPoolUsage
Definition qrhimetal_p.h:50
int lastActiveFrameSlot
Definition qrhimetal_p.h:43
static constexpr int InternalHostWritable
Definition qrhimetal_p.h:53
QRhiBuffer::NativeBuffer nativeBuffer() override
void endFullDynamicBufferUpdateForCurrentFrame() override
To be called when the entire contents of the buffer data has been updated in the memory block returne...
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
bool create() override
Creates the corresponding native graphics resources.
MTLRenderPassDescriptor * currentPassRpDesc
Definition qrhimetal.mm:441
id< MTLDepthStencilState > currentDepthStencilState
Definition qrhimetal.mm:445
QMetalShaderResourceBindingsData currentShaderResourceBindingState
Definition qrhimetal.mm:446
MTLStoreAction deferredStencilStoreAction
Definition qrhimetal.mm:454
QVarLengthArray< std::pair< uint, MTLStoreAction >, 4 > deferredColorStoreActions
Definition qrhimetal.mm:452
MTLStoreAction deferredDepthStoreAction
Definition qrhimetal.mm:453
id< MTLComputeCommandEncoder > tessellationComputeEncoder
Definition qrhimetal.mm:440
QRhiBatchedBindings< id< MTLBuffer > > currentVertexInputsBuffers
Definition qrhimetal.mm:443
id< MTLRenderCommandEncoder > currentRenderPassEncoder
Definition qrhimetal.mm:438
id< MTLCommandBuffer > cb
Definition qrhimetal.mm:436
QRhiBatchedBindings< NSUInteger > currentVertexInputOffsets
Definition qrhimetal.mm:444
QVarLengthArray< QByteArray, 4 > openDebugGroups
Definition qrhimetal.mm:447
id< MTLComputeCommandEncoder > currentComputePassEncoder
Definition qrhimetal.mm:439
QMetalBuffer * currentIndexBuffer
std::pair< float, float > currentDepthBiasValues
QRhiCommandBuffer::IndexFormat currentIndexFormat
QRhiMetalCommandBufferNativeHandles nativeHandlesStruct
QRhiScissor currentScissor
std::optional< quint32 > appliedStencilRef
QVarLengthArray< char, 128 > pushConstantData
QRhiViewport currentViewport
const QRhiNativeHandles * nativeHandles()
QMetalShaderResourceBindings * currentComputeSrb
QMetalComputePipeline * currentComputePipeline
QMetalShaderResourceBindings * currentGraphicsSrb
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QMetalCommandBuffer(QRhiImplementation *rhi)
void resetPerPassCachedState()
QMetalCommandBufferData * d
QRhiRenderTarget * currentTarget
QMetalGraphicsPipeline * currentGraphicsPipeline
void resetState(double lastGpuTime=0)
id< MTLComputePipelineState > ps
Definition qrhimetal.mm:557
QMetalBuffer * bufferSizeBuffer
Definition qrhimetal.mm:562
QMetalComputePipeline(QRhiImplementation *rhi)
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QMetalComputePipelineData * d
bool create() override
QVector< QMetalBuffer * > deviceLocalWorkBuffers
Definition qrhimetal.mm:511
QMetalBuffer * acquireWorkBuffer(QRhiMetal *rhiD, quint32 size, WorkBufType type=WorkBufType::DeviceLocal)
QVector< QMetalBuffer * > hostVisibleWorkBuffers
Definition qrhimetal.mm:512
quint32 tescCompOutputBufferSize(quint32 patchCount) const
Definition qrhimetal.mm:530
std::array< id< MTLComputePipelineState >, 3 > vertexComputeState
Definition qrhimetal.mm:521
quint32 tescCompPatchOutputBufferSize(quint32 patchCount) const
Definition qrhimetal.mm:534
static int vsCompVariantToIndex(QShader::Variant vertexCompVariant)
id< MTLComputePipelineState > tescCompPipeline(QRhiMetal *rhiD)
id< MTLRenderPipelineState > teseFragRenderPipeline(QRhiMetal *rhiD, QMetalGraphicsPipeline *pipeline)
QMetalGraphicsPipelineData * q
Definition qrhimetal.mm:515
id< MTLComputePipelineState > vsCompPipeline(QRhiMetal *rhiD, QShader::Variant vertexCompVariant)
quint32 patchCountForDrawCall(quint32 vertexOrIndexCount, quint32 instanceCount) const
Definition qrhimetal.mm:539
quint32 vsCompOutputBufferSize(quint32 vertexOrIndexCount, quint32 instanceCount) const
Definition qrhimetal.mm:525
id< MTLComputePipelineState > tessControlComputeState
Definition qrhimetal.mm:522
QMetalGraphicsPipeline * q
Definition qrhimetal.mm:492
MTLDepthClipMode depthClipMode
Definition qrhimetal.mm:500
MTLPrimitiveType primitiveType
Definition qrhimetal.mm:496
id< MTLRenderPipelineState > ps
Definition qrhimetal.mm:493
QMetalBuffer * bufferSizeBuffer
Definition qrhimetal.mm:552
void setupVertexInputDescriptor(MTLVertexDescriptor *desc)
void setupStageInputDescriptor(MTLStageInputOutputDescriptor *desc)
id< MTLDepthStencilState > ds
Definition qrhimetal.mm:494
MTLTriangleFillMode triangleFillMode
Definition qrhimetal.mm:499
QMetalGraphicsPipelineData * d
bool createVertexFragmentPipeline()
QMetalGraphicsPipeline(QRhiImplementation *rhi)
void setupAttachmentsInMetalRenderPassDescriptor(void *metalRpDesc, QMetalRenderPassDescriptor *rpD)
void makeActiveForCurrentRenderPassEncoder(QMetalCommandBuffer *cbD)
bool create() override
Creates the corresponding native graphics resources.
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
void setupMetalDepthStencilDescriptor(void *metalDsDesc)
bool createTessellationPipelines(const QShader &tessVert, const QShader &tesc, const QShader &tese, const QShader &tessFrag)
QRhiCommandBuffer::IndexFormat indexFormat
id< MTLIndirectCommandBuffer > icb
QRhiIndirectCommandBufferBuildInfo buildInfo
Slot frameSlots[QMTL_FRAMES_IN_FLIGHT]
QMetalIndirectCommandBuffer(QRhiImplementation *rhi, Type type, quint32 maxCommandCount)
const QRhiIndirectDrawCommand * drawCommands() const
quint64 contentsGeneration() const
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QMetalIndirectCommandBufferData * d
const QRhiIndexedIndirectDrawCommand * indexedDrawCommands() const
bool create() override
Creates the corresponding native objects.
id< MTLTexture > tex
Definition qrhimetal.mm:371
MTLPixelFormat format
Definition qrhimetal.mm:370
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QMetalRenderBufferData * d
Definition qrhimetal_p.h:69
QRhiTexture::Format backingFormat() const override
bool create() override
Creates the corresponding native graphics resources.
QMetalRenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize, int sampleCount, QRhiRenderBuffer::Flags flags, QRhiTexture::Format backingFormatHint)
QMetalRenderPassDescriptor(QRhiImplementation *rhi)
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QVector< quint32 > serializedFormatData
QVector< quint32 > serializedFormat() const override
bool isCompatible(const QRhiRenderPassDescriptor *other) const override
int colorFormat[MAX_COLOR_ATTACHMENTS]
static const int MAX_COLOR_ATTACHMENTS
QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() const override
QRhiRenderTargetAttachmentTracker::ResIdList currentResIdList
Definition qrhimetal.mm:487
id< MTLSamplerState > samplerState
Definition qrhimetal.mm:398
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QMetalSampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, AddressMode u, AddressMode v, AddressMode w)
QMetalSamplerData * d
int lastActiveFrameSlot
bool create() override
QVarLengthArray< Buffer, 8 > buffers
Definition qrhimetal.mm:422
QVarLengthArray< Sampler, 8 > samplers
Definition qrhimetal.mm:424
QRhiBatchedBindings< NSUInteger > bufferOffsetBatches
Definition qrhimetal.mm:426
QVarLengthArray< Texture, 8 > textures
Definition qrhimetal.mm:423
QRhiBatchedBindings< id< MTLSamplerState > > samplerBatches
Definition qrhimetal.mm:428
QRhiBatchedBindings< id< MTLTexture > > textureBatches
Definition qrhimetal.mm:427
QRhiBatchedBindings< id< MTLBuffer > > bufferBatches
Definition qrhimetal.mm:425
bool create() override
Creates the corresponding resource binding set.
QMetalComputePipeline * lastUsedComputePipeline
QMetalShaderResourceBindings(QRhiImplementation *rhi)
QMetalGraphicsPipeline * lastUsedGraphicsPipeline
QVarLengthArray< QRhiShaderResourceBinding, 8 > sortedBindings
QVarLengthArray< BoundResourceData, 8 > boundResourceData
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
void updateResources(UpdateFlags flags) override
\variable QRhiMetalCommandBufferNativeHandles::commandBuffer
Definition qrhimetal.mm:157
void destroy()
Definition qrhimetal.mm:168
id< MTLLibrary > lib
Definition qrhimetal.mm:158
uint outputVertexCount
Definition qrhimetal.mm:161
std::array< uint, 3 > localSize
Definition qrhimetal.mm:160
QShaderDescription desc
Definition qrhimetal.mm:162
id< MTLFunction > func
Definition qrhimetal.mm:159
int argumentBufferIndex
Definition qrhimetal.mm:166
id< MTLArgumentEncoder > argumentEncoder
Definition qrhimetal.mm:165
id< MTLRasterizationRateMap > rateMap
Definition qrhimetal.mm:403
QMetalShadingRateMapData * d
QMetalShadingRateMap(QRhiImplementation *rhi)
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QSize logicalSize() const override
bool createFrom(NativeShadingRateMap src) override
Sets up the shading rate map to use a native 3D API shading rate object src.
id< CAMetalDrawable > curDrawable
Definition qrhimetal.mm:568
dispatch_semaphore_t sem[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:569
MTLPixelFormat colorFormat
Definition qrhimetal.mm:574
MTLRenderPassDescriptor * rp
Definition qrhimetal.mm:571
CAMetalLayer * layer
Definition qrhimetal.mm:567
double lastGpuTime[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:570
id< MTLTexture > msaaTex[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:572
QRhiTexture::Format rhiColorFormat
Definition qrhimetal.mm:573
QMetalRenderTargetData * d
QMetalSwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain)
QSize pixelSize() const override
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
float devicePixelRatio() const override
int sampleCount() const override
QWindow * window
void waitUntilCompleted(int slot)
bool createOrResize() override
Creates the swapchain if not already done and resizes the swapchain buffers to match the current size...
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QRhiCommandBuffer * currentFrameCommandBuffer() override
QMetalSwapChain(QRhiImplementation *rhi)
QMetalCommandBuffer cbWrapper
virtual QRhiSwapChainHdrInfo hdrInfo() override
\variable QRhiSwapChainHdrInfo::limitsType
QMetalRenderBuffer * ds
QMetalSwapChainRenderTarget rtWrapper
QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() override
QMetalSwapChainData * d
bool isFormatSupported(Format f) override
QSize surfacePixelSize() override
QRhiRenderTarget * currentFrameRenderTarget() override
MTLPixelFormat viewFormat
Definition qrhimetal.mm:380
id< MTLTexture > tex
Definition qrhimetal.mm:382
MTLPixelFormat viewFormatForSampling
Definition qrhimetal.mm:381
id< MTLTexture > viewForLevel(int level)
QMetalTexture * q
Definition qrhimetal.mm:378
id< MTLTexture > perLevelViews[QRhi::MAX_MIP_LEVELS]
Definition qrhimetal.mm:387
id< MTLBuffer > stagingBuf[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:385
id< MTLTexture > writeView
Definition qrhimetal.mm:384
QMetalTextureData(QMetalTexture *t)
Definition qrhimetal.mm:376
id< MTLTexture > samplingView
Definition qrhimetal.mm:383
id< MTLTexture > textureForWrite() const
Definition qrhimetal.mm:390
MTLPixelFormat format
Definition qrhimetal.mm:379
id< MTLTexture > textureForSampling() const
Definition qrhimetal.mm:389
float devicePixelRatio() const override
QMetalRenderTargetData * d
QMetalTextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc, Flags flags)
bool create() override
Creates the corresponding native graphics resources.
QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() override
int sampleCount() const override
QSize pixelSize() const override
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QMetalTexture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth, int arraySize, int sampleCount, Flags flags)
bool prepareCreate(QSize *adjustedSize=nullptr)
NativeTexture nativeTexture() override
QMetalTextureData * d
Definition qrhimetal_p.h:90
bool create() override
Creates the corresponding native graphics resources.
int lastActiveFrameSlot
Definition qrhimetal_p.h:94
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.
\variable QRhiIndirectDrawCommand::vertexCount
Definition qrhi.h:1768
QRhiReadbackResult * result
Definition qrhimetal.mm:290
QMetalCommandBuffer cbWrapper
Definition qrhimetal.mm:263
OffscreenFrame(QRhiImplementation *rhi)
Definition qrhimetal.mm:260
QRhiReadbackDescription desc
Definition qrhimetal.mm:268
QRhiReadbackResult * result
Definition qrhimetal.mm:269
QRhiTexture::Format format
Definition qrhimetal.mm:273
void trySeedingRenderPipelineFromBinaryArchive(MTLRenderPipelineDescriptor *rpDesc)
id< MTLComputePipelineState > icbEncodePipelineU32
Definition qrhimetal.mm:304
static constexpr quint32 STAGING_AREA_MIN
Definition qrhimetal.mm:342
QRhiMetalData(QRhiMetal *rhi)
Definition qrhimetal.mm:182
QVarLengthArray< BufferReadback, 2 > activeBufferReadbacks
Definition qrhimetal.mm:295
QHash< ShaderCacheKey, QMetalShader > shaderCache
Definition qrhimetal.mm:319
bool setupBinaryArchive(NSURL *sourceFileUrl=nil)
Definition qrhimetal.mm:633
bool icbSetupFailed
Definition qrhimetal.mm:314
id< MTLFunction > icbEncodeFunctionU16
Definition qrhimetal.mm:308
void addRenderPipelineToBinaryArchive(MTLRenderPipelineDescriptor *rpDesc)
id< MTLFunction > icbEncodeFunctionU32
Definition qrhimetal.mm:307
MTLCaptureManager * captureMgr
Definition qrhimetal.mm:297
id< MTLBuffer > icbArgumentBuffer
Definition qrhimetal.mm:309
static constexpr quint32 LARGE_STAGING_ALLOC
Definition qrhimetal.mm:341
NSUInteger icbCapacity
Definition qrhimetal.mm:302
void trySeedingComputePipelineFromBinaryArchive(MTLComputePipelineDescriptor *cpDesc)
id< MTLIndirectCommandBuffer > icb
Definition qrhimetal.mm:301
QVector< DeferredReleaseEntry > releaseQueue
Definition qrhimetal.mm:257
id< MTLBuffer > allocArgumentBuffer(quint32 size, quint32 alignment, int frameSlot, quint32 *offset)
static constexpr quint32 STAGING_AREA_MAX
Definition qrhimetal.mm:343
id< MTLLibrary > createMetalLib(const QShader &shader, QShader::Variant shaderVariant, bool preferArgumentBuffers, QString *error, QByteArray *entryPoint, QShaderKey *activeKey)
id< MTLFunction > createMSLShaderFunction(id< MTLLibrary > lib, const QByteArray &entryPoint)
id< MTLBuffer > allocBufferStaging(quint32 size, int frameSlot, quint32 *offset)
id< MTLCaptureScope > captureScope
Definition qrhimetal.mm:298
void resetAndResizeBufferStagingArea(int frameSlot)
MTLRenderPassDescriptor * createDefaultRenderPass(bool hasDepthStencil, const QColor &colorClearValue, const QRhiDepthStencilClearValue &depthStencilClearValue, int colorAttCount, QRhiShadingRateMap *shadingRateMap)
id< MTLBuffer > newOneShotStagingBuffer(quint32 size, int frameSlot)
QRhiMetal * q
Definition qrhimetal.mm:184
id< MTLComputePipelineState > icbEncodePipeline
Definition qrhimetal.mm:303
static constexpr int STAGING_AREA_HIGH_DEMAND_FRAMES
Definition qrhimetal.mm:345
id< MTLFunction > icbEncodeFunction
Definition qrhimetal.mm:306
id< MTLComputePipelineState > icbEncodePipelineU16
Definition qrhimetal.mm:305
static const int TEXBUF_ALIGN
Definition qrhimetal.mm:316
id< MTLBuffer > icbRangeBuffer
Definition qrhimetal.mm:311
id< MTLBuffer > allocFromStagingArea(StagingArea *area, quint32 size, quint32 alignment, int frameSlot, quint32 minBlockSize, quint32 *offset)
StagingArea bufStagingPool[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:330
id< MTLBinaryArchive > binArch
Definition qrhimetal.mm:187
id< MTLCommandBuffer > newCommandBuffer()
Definition qrhimetal.mm:621
QVarLengthArray< TextureReadback, 2 > activeTextureReadbacks
Definition qrhimetal.mm:285
StagingArea argBufPool[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:329
id< MTLDevice > dev
Definition qrhimetal.mm:185
quint64 globalFrameId
Definition qrhimetal.mm:349
static constexpr int STAGING_AREA_LOW_DEMAND_FRAMES
Definition qrhimetal.mm:344
void addComputePipelineToBinaryArchive(MTLComputePipelineDescriptor *cpDesc)
id< MTLCommandQueue > cmdQueue
Definition qrhimetal.mm:186
id< MTLBuffer > icbNoCountBuffer
Definition qrhimetal.mm:313
QMetalCommandBuffer * cbD
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:2016
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1616
LimitsType limitsType
Definition qrhi.h:1627
LuminanceBehavior luminanceBehavior
Definition qrhi.h:1638
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1649
void * reserved[2]
Definition qrhi.h:1650