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
23
24static const int QMTL_FRAMES_IN_FLIGHT = 2;
25
26// have to hide the ObjC stuff, this header cannot contain MTL* at all
27struct QMetalBufferData;
28
29struct QMetalBuffer : public QRhiBuffer
30{
31 QMetalBuffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size);
32 ~QMetalBuffer();
33 void destroy() override;
34 bool create() override;
38
40 uint generation = 0;
42 friend class QRhiMetal;
44
45 // Internal usage flags. Buffers created with any of these are not visible
46 // to the application and bypass QRhi::newBuffer(), so they are free to use
47 // bits outside of QRhiBuffer::UsageFlag.
48 static constexpr int WorkBufPoolUsage = 1 << 8;
49 // Marks internal buffers that must keep being written by the CPU, and so
50 // can never be backed by device private memory.
51 static constexpr int InternalHostWritable = 1 << 9;
53};
54
56
58{
59 QMetalRenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize,
60 int sampleCount, QRhiRenderBuffer::Flags flags,
61 QRhiTexture::Format backingFormatHint);
63 void destroy() override;
64 bool create() override;
65 QRhiTexture::Format backingFormat() const override;
66
68 int samples = 1;
69 uint generation = 0;
71 friend class QRhiMetal;
72};
73
75
77{
78 QMetalTexture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth,
79 int arraySize, int sampleCount, Flags flags);
81 void destroy() override;
82 bool create() override;
83 bool createFrom(NativeTexture src) override;
85
86 bool prepareCreate(QSize *adjustedSize = nullptr);
87
90 int samples = 1;
91 uint generation = 0;
93 friend class QRhiMetal;
95 friend struct QMetalTextureData;
96};
97
99
101{
102 QMetalSampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
103 AddressMode u, AddressMode v, AddressMode w);
104 ~QMetalSampler();
105 void destroy() override;
106 bool create() override;
107
109 uint generation = 0;
111 friend class QRhiMetal;
113};
114
116
118{
119 QMetalShadingRateMap(QRhiImplementation *rhi);
121 void destroy() override;
122 bool createFrom(NativeShadingRateMap src) override;
123 QSize logicalSize() const override;
124
126 uint generation = 0;
128 friend class QRhiMetal;
129};
130
132
134{
135 QMetalIndirectCommandBuffer(QRhiImplementation *rhi, Type type, quint32 maxCommandCount);
137 void destroy() override;
138 bool create() override;
139
141 {
142 return reinterpret_cast<const QRhiIndirectDrawCommand *>(m_data.constData());
143 }
145 {
146 return reinterpret_cast<const QRhiIndexedIndirectDrawCommand *>(m_data.constData());
147 }
148 quint64 contentsGeneration() const { return m_generation; }
149
152 friend class QRhiMetal;
153};
154
156{
157 QMetalRenderPassDescriptor(QRhiImplementation *rhi);
159 void destroy() override;
160 bool isCompatible(const QRhiRenderPassDescriptor *other) const override;
162 QVector<quint32> serializedFormat() const override;
163
165
166 // there is no MTLRenderPassDescriptor here as one will be created for each pass in beginPass()
167
168 // but the things needed for the render pipeline descriptor have to be provided
169 static const int MAX_COLOR_ATTACHMENTS = 8;
171 bool hasDepthStencil = false;
174 bool hasShadingRateMap = false;
176};
177
179
181{
182 QMetalSwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain);
184 void destroy() override;
185
186 QSize pixelSize() const override;
187 float devicePixelRatio() const override;
188 int sampleCount() const override;
189
191};
192
194{
195 QMetalTextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc, Flags flags);
197 void destroy() override;
198
199 QSize pixelSize() const override;
200 float devicePixelRatio() const override;
201 int sampleCount() const override;
202
204 bool create() override;
205
207 friend class QRhiMetal;
208};
209
212
258
261struct QMetalShader;
262
264{
265 QMetalGraphicsPipeline(QRhiImplementation *rhi);
267 void destroy() override;
268 bool create() override;
269
272 void setupMetalDepthStencilDescriptor(void *metalDsDesc);
273 void mapStates();
275 bool createTessellationPipelines(const QShader &tessVert, const QShader &tesc, const QShader &tese, const QShader &tessFrag);
276
278 uint generation = 0;
280 friend class QRhiMetal;
281};
282
284
286{
287 QMetalComputePipeline(QRhiImplementation *rhi);
289 void destroy() override;
290 bool create() override;
291
293 uint generation = 0;
295 friend class QRhiMetal;
296};
297
299struct QMetalSwapChain;
300
302{
303 QMetalCommandBuffer(QRhiImplementation *rhi);
305 void destroy() override;
306
309
315
316 // per-pass (render or compute command encoder) persistent state
319
320 // per-pass (render or compute command encoder) volatile (cached) state
335 std::pair<float, float> currentDepthBiasValues;
345
347 void resetState(double lastGpuTime = 0);
348 void resetPerPassState();
350};
351
353
355{
356 QMetalSwapChain(QRhiImplementation *rhi);
358 void destroy() override;
359
360 QRhiCommandBuffer *currentFrameCommandBuffer() override;
362 QSize surfacePixelSize() override;
363 bool isFormatSupported(Format f) override;
364
366
368
369 virtual QRhiSwapChainHdrInfo hdrInfo() override;
370
371 void chooseFormats();
372 void waitUntilCompleted(int slot);
373
374 QWindow *window = nullptr;
376 int currentFrameSlot = 0; // 0..QMTL_FRAMES_IN_FLIGHT-1
377 int frameCount = 0;
378 int samples = 1;
383};
384
385struct QRhiMetalData;
386
388{
389public:
390 QRhiMetal(QRhiMetalInitParams *params, QRhiMetalNativeHandles *importDevice = nullptr);
391 ~QRhiMetal();
392
393 static bool probe(QRhiMetalInitParams *params);
394 static QRhiSwapChainProxyData updateSwapChainProxyData(QWindow *window);
395
396 bool create(QRhi::Flags flags) override;
397 void destroy() override;
398
402 QRhiBuffer *createBuffer(QRhiBuffer::Type type,
403 QRhiBuffer::UsageFlags usage,
404 quint32 size) override;
405 QRhiRenderBuffer *createRenderBuffer(QRhiRenderBuffer::Type type,
406 const QSize &pixelSize,
407 int sampleCount,
408 QRhiRenderBuffer::Flags flags,
409 QRhiTexture::Format backingFormatHint) override;
410 QRhiTexture *createTexture(QRhiTexture::Format format,
411 const QSize &pixelSize,
412 int depth,
413 int arraySize,
414 int sampleCount,
415 QRhiTexture::Flags flags) override;
416 QRhiSampler *createSampler(QRhiSampler::Filter magFilter,
417 QRhiSampler::Filter minFilter,
418 QRhiSampler::Filter mipmapMode,
419 QRhiSampler:: AddressMode u,
420 QRhiSampler::AddressMode v,
421 QRhiSampler::AddressMode w) override;
422
423 QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
424 QRhiTextureRenderTarget::Flags flags) override;
425
426 QRhiShadingRateMap *createShadingRateMap() override;
427
428 QRhiIndirectCommandBuffer *createIndirectCommandBuffer(QRhiIndirectCommandBuffer::Type type,
429 quint32 maxCommandCount) override;
430 void buildIndirect(QRhiCommandBuffer *cb, QRhiIndirectCommandBuffer *icb,
431 const QRhiIndirectCommandBufferBuildInfo &info) override;
432 void executeIndirect(QRhiCommandBuffer *cb, QRhiIndirectCommandBuffer *icb,
433 quint32 firstCommand, quint32 commandCount) override;
434 void commitIndirectCommandBuffer(QRhiResourceUpdateBatch *u,
435 QRhiIndirectCommandBuffer *icb) override;
436
437 QRhiSwapChain *createSwapChain() override;
438 QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) override;
439 QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) override;
440 QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) override;
441 QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) override;
442 QRhi::FrameOpResult finish() override;
443
444 void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
445
446 void beginPass(QRhiCommandBuffer *cb,
447 QRhiRenderTarget *rt,
448 const QColor &colorClearValue,
449 const QRhiDepthStencilClearValue &depthStencilClearValue,
450 QRhiResourceUpdateBatch *resourceUpdates,
451 QRhiCommandBuffer::BeginPassFlags flags) override;
452 void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
453
454 void setGraphicsPipeline(QRhiCommandBuffer *cb,
455 QRhiGraphicsPipeline *ps) override;
456
457 void setShaderResources(QRhiCommandBuffer *cb,
458 QRhiShaderResourceBindings *srb,
459 int dynamicOffsetCount,
460 const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) override;
461
462 void setVertexInput(QRhiCommandBuffer *cb,
463 int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings,
464 QRhiBuffer *indexBuf, quint32 indexOffset,
465 QRhiCommandBuffer::IndexFormat indexFormat) override;
466
467 void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override;
468 void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override;
469 void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) override;
470 void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override;
471 void setPushConstants(QRhiCommandBuffer *cb, quint32 offset, quint32 size, const void *data) override;
472 void setShadingRate(QRhiCommandBuffer *cb, const QSize &coarsePixelSize) override;
473
474 void draw(QRhiCommandBuffer *cb, quint32 vertexCount,
475 quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override;
476
477 void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
478 quint32 instanceCount, quint32 firstIndex,
479 qint32 vertexOffset, quint32 firstInstance) override;
480
481 void drawIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer,
482 quint32 indirectBufferOffset, quint32 drawCount, quint32 stride) override;
483
484 void drawIndexedIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer,
485 quint32 indirectBufferOffset, quint32 drawCount, quint32 stride) override;
486
487 void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override;
488 void debugMarkEnd(QRhiCommandBuffer *cb) override;
489 void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override;
490
491 void beginComputePass(QRhiCommandBuffer *cb,
492 QRhiResourceUpdateBatch *resourceUpdates,
493 QRhiCommandBuffer::BeginPassFlags flags) override;
494 void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override;
495 void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) override;
496 void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) override;
497 void dispatchIndirect(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer,
498 quint32 indirectBufferOffset) override;
499
500 void drawIndirectCount(QRhiCommandBuffer *cb,
501 QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset,
502 QRhiBuffer *countBuffer, quint32 countBufferOffset,
503 quint32 maxDrawCount, quint32 stride) override;
504 void drawIndexedIndirectCount(QRhiCommandBuffer *cb,
505 QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset,
506 QRhiBuffer *countBuffer, quint32 countBufferOffset,
507 quint32 maxDrawCount, quint32 stride) override;
508
509 const char *icbUnavailableReason(QMetalCommandBuffer *cbD) const;
510 bool prepareIcbKernels();
511 bool prepareIcb(quint32 maxDrawCount);
512 bool icbDraw(QMetalCommandBuffer *cbD, bool indexed,
513 QMetalBuffer *indirectBufD, quint32 indirectBufferOffset,
514 QMetalBuffer *countBufD, quint32 countBufferOffset,
515 quint32 maxDrawCount, quint32 stride);
516
517 const QRhiNativeHandles *nativeHandles(QRhiCommandBuffer *cb) override;
518 void beginExternal(QRhiCommandBuffer *cb) override;
519 void endExternal(QRhiCommandBuffer *cb) override;
520 double lastCompletedGpuTime(QRhiCommandBuffer *cb) override;
521
522 QList<int> supportedSampleCounts() const override;
523 QList<QSize> supportedShadingRates(int sampleCount) const override;
524 int ubufAlignment() const override;
525 bool isYUpInFramebuffer() const override;
526 bool isYUpInNDC() const override;
527 bool isClipDepthZeroToOne() const override;
528 QMatrix4x4 clipSpaceCorrMatrix() const override;
529 bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override;
530 bool isFeatureSupported(QRhi::Feature feature) const override;
531 int resourceLimit(QRhi::ResourceLimit limit) const override;
532 const QRhiNativeHandles *nativeHandles() override;
533 QRhiDriverInfo driverInfo() const override;
534 QRhiStats statistics() override;
536 void setQueueSubmitParams(QRhiNativeHandles *params) override;
538 bool isDeviceLost() const override;
539
540 QByteArray pipelineCacheData() override;
541 void setPipelineCacheData(const QByteArray &data) override;
542
543 void executeDeferredReleases(bool forced = false);
544 void finishActiveReadbacks(bool forced = false);
545 qsizetype subresUploadByteSize(const QRhiTextureSubresourceUploadDescription &subresDesc) const;
546 void enqueueSubresUpload(QMetalTexture *texD, void *mp, void *blitEncPtr,
547 int layer, int level, const QRhiTextureSubresourceUploadDescription &subresDesc,
548 qsizetype *curOfs);
549 void enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates);
550 void executeBufferHostWritesForSlot(QMetalBuffer *bufD, int slot);
552 void finalizeDeferredStoreActions(QMetalCommandBuffer *cbD, bool passIsEnding);
554 static const int SUPPORTED_STAGES = 5;
557 int dynamicOffsetCount,
558 const QRhiCommandBuffer::DynamicOffset *dynamicOffsets,
559 bool offsetOnlyChange,
560 const QShader::NativeResourceBindingMap *nativeResourceBindingMaps[SUPPORTED_STAGES],
561 const QMetalShader *shaders[SUPPORTED_STAGES]);
563 static QSize outputSizeForTarget(QRhiRenderTarget *target);
564
591 void tessellatedDraw(const TessDrawArgs &args);
592 void adjustForMultiViewDraw(quint32 *instanceCount, QRhiCommandBuffer *cb);
593
595 bool importedDevice = false;
596 bool importedCmdQueue = false;
603
604 struct {
605 int maxTextureSize = 4096;
608 bool isAppleGPU = false;
609 // Immutable and Static buffers are backed by a single, device private
610 // MTLBuffer, with uploads going through a staging buffer and a blit.
611 // Requires an Apple GPU because MTLBlitCommandEncoder's
612 // buffer-to-buffer copy has a 4 byte alignment requirement on
613 // non-Apple GPUs, whereas uploadStaticBuffer() allows any offset and
614 // size.
617 bool multiView = false;
619 bool shadingRateMap = false;
620 bool depthClamp = true;
621 } caps;
622
623 QRhiMetalData *d = nullptr;
624};
625
626QT_END_NAMESPACE
627
628#endif
const char * constData() const
Definition qrhi_p.h:477
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
bool shadingRateMap
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:851
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override
Definition qrhimetal.mm:882
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:566
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])
bool indirectCommandBuffers
QRhiSwapChain * createSwapChain() override
Definition qrhimetal.mm:841
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:642
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
bool multiView
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:861
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:871
void drawIndexedIndirectCount(QRhiCommandBuffer *cb, QRhiBuffer *indirectBuffer, quint32 indirectBufferOffset, QRhiBuffer *countBuffer, quint32 countBufferOffset, quint32 maxDrawCount, quint32 stride) override
int maxTextureSize
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:866
static QSize outputSizeForTarget(QRhiRenderTarget *target)
QVector< int > supportedSampleCounts
QRhiTextureRenderTarget * createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags) override
int maxThreadGroupSize
bool isYUpInFramebuffer() const override
Definition qrhimetal.mm:856
bool usePrivateStaticBuffers
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
bool isAppleGPU
void finalizeDeferredStoreActions(QMetalCommandBuffer *cbD, bool passIsEnding)
QByteArray pipelineCacheData() override
void setShadingRate(QRhiCommandBuffer *cb, const QSize &coarsePixelSize) override
bool depthClamp
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
bool baseVertexAndInstance
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:846
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
QList< int > supportedSampleCounts() const 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:597
void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override
bool isFeatureSupported(QRhi::Feature feature) const override
Definition qrhimetal.mm:915
void enqueueSubresUpload(QMetalTexture *texD, void *mp, void *blitEncPtr, int layer, int level, const QRhiTextureSubresourceUploadDescription &subresDesc, qsizetype *curOfs)
void destroy() override
Definition qrhimetal.mm:764
QList< QSize > supportedShadingRates(int sampleCount) const override
Definition qrhimetal.mm:835
void beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags) override
static QRhiResourceUpdateBatchPrivate * get(QRhiResourceUpdateBatch *b)
Definition qrhi_p.h:745
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:325
\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:61
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:56
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:24
void f(int c)
[26]
QVarLengthArray< BufferUpdate, 16 > pendingUpdates[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:354
id< MTLBuffer > buf[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:349
char * beginFullDynamicBufferUpdateForCurrentFrame() override
QMetalBufferData * d
Definition qrhimetal_p.h:39
QMetalBuffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size)
static constexpr int WorkBufPoolUsage
Definition qrhimetal_p.h:48
int lastActiveFrameSlot
Definition qrhimetal_p.h:41
static constexpr int InternalHostWritable
Definition qrhimetal_p.h:51
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:430
id< MTLDepthStencilState > currentDepthStencilState
Definition qrhimetal.mm:434
QMetalShaderResourceBindingsData currentShaderResourceBindingState
Definition qrhimetal.mm:435
MTLStoreAction deferredStencilStoreAction
Definition qrhimetal.mm:443
QVarLengthArray< std::pair< uint, MTLStoreAction >, 4 > deferredColorStoreActions
Definition qrhimetal.mm:441
MTLStoreAction deferredDepthStoreAction
Definition qrhimetal.mm:442
id< MTLComputeCommandEncoder > tessellationComputeEncoder
Definition qrhimetal.mm:429
QRhiBatchedBindings< id< MTLBuffer > > currentVertexInputsBuffers
Definition qrhimetal.mm:432
id< MTLRenderCommandEncoder > currentRenderPassEncoder
Definition qrhimetal.mm:427
id< MTLCommandBuffer > cb
Definition qrhimetal.mm:425
QRhiBatchedBindings< NSUInteger > currentVertexInputOffsets
Definition qrhimetal.mm:433
QVarLengthArray< QByteArray, 4 > openDebugGroups
Definition qrhimetal.mm:436
id< MTLComputeCommandEncoder > currentComputePassEncoder
Definition qrhimetal.mm:428
QMetalBuffer * currentIndexBuffer
std::pair< float, float > currentDepthBiasValues
QRhiCommandBuffer::IndexFormat currentIndexFormat
QRhiMetalCommandBufferNativeHandles nativeHandlesStruct
QRhiScissor currentScissor
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:546
QMetalBuffer * bufferSizeBuffer
Definition qrhimetal.mm:551
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:500
QMetalBuffer * acquireWorkBuffer(QRhiMetal *rhiD, quint32 size, WorkBufType type=WorkBufType::DeviceLocal)
QVector< QMetalBuffer * > hostVisibleWorkBuffers
Definition qrhimetal.mm:501
quint32 tescCompOutputBufferSize(quint32 patchCount) const
Definition qrhimetal.mm:519
std::array< id< MTLComputePipelineState >, 3 > vertexComputeState
Definition qrhimetal.mm:510
quint32 tescCompPatchOutputBufferSize(quint32 patchCount) const
Definition qrhimetal.mm:523
static int vsCompVariantToIndex(QShader::Variant vertexCompVariant)
id< MTLComputePipelineState > tescCompPipeline(QRhiMetal *rhiD)
id< MTLRenderPipelineState > teseFragRenderPipeline(QRhiMetal *rhiD, QMetalGraphicsPipeline *pipeline)
QMetalGraphicsPipelineData * q
Definition qrhimetal.mm:504
id< MTLComputePipelineState > vsCompPipeline(QRhiMetal *rhiD, QShader::Variant vertexCompVariant)
quint32 patchCountForDrawCall(quint32 vertexOrIndexCount, quint32 instanceCount) const
Definition qrhimetal.mm:528
quint32 vsCompOutputBufferSize(quint32 vertexOrIndexCount, quint32 instanceCount) const
Definition qrhimetal.mm:514
id< MTLComputePipelineState > tessControlComputeState
Definition qrhimetal.mm:511
QMetalGraphicsPipeline * q
Definition qrhimetal.mm:481
MTLDepthClipMode depthClipMode
Definition qrhimetal.mm:489
MTLPrimitiveType primitiveType
Definition qrhimetal.mm:485
id< MTLRenderPipelineState > ps
Definition qrhimetal.mm:482
QMetalBuffer * bufferSizeBuffer
Definition qrhimetal.mm:541
void setupVertexInputDescriptor(MTLVertexDescriptor *desc)
void setupStageInputDescriptor(MTLStageInputOutputDescriptor *desc)
id< MTLDepthStencilState > ds
Definition qrhimetal.mm:483
MTLTriangleFillMode triangleFillMode
Definition qrhimetal.mm:488
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:360
MTLPixelFormat format
Definition qrhimetal.mm:359
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QMetalRenderBufferData * d
Definition qrhimetal_p.h:67
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
ColorAtt colorAtt[QMetalRenderPassDescriptor::MAX_COLOR_ATTACHMENTS]
Definition qrhimetal.mm:467
id< MTLTexture > dsResolveTex
Definition qrhimetal.mm:469
QRhiRenderTargetAttachmentTracker::ResIdList currentResIdList
Definition qrhimetal.mm:476
id< MTLTexture > dsTex
Definition qrhimetal.mm:468
id< MTLSamplerState > samplerState
Definition qrhimetal.mm:387
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:411
QVarLengthArray< Sampler, 8 > samplers
Definition qrhimetal.mm:413
QRhiBatchedBindings< NSUInteger > bufferOffsetBatches
Definition qrhimetal.mm:415
QVarLengthArray< Texture, 8 > textures
Definition qrhimetal.mm:412
QRhiBatchedBindings< id< MTLSamplerState > > samplerBatches
Definition qrhimetal.mm:417
QRhiBatchedBindings< id< MTLTexture > > textureBatches
Definition qrhimetal.mm:416
QRhiBatchedBindings< id< MTLBuffer > > bufferBatches
Definition qrhimetal.mm:414
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:156
void destroy()
Definition qrhimetal.mm:167
id< MTLLibrary > lib
Definition qrhimetal.mm:157
uint outputVertexCount
Definition qrhimetal.mm:160
std::array< uint, 3 > localSize
Definition qrhimetal.mm:159
QShaderDescription desc
Definition qrhimetal.mm:161
id< MTLFunction > func
Definition qrhimetal.mm:158
int argumentBufferIndex
Definition qrhimetal.mm:165
id< MTLArgumentEncoder > argumentEncoder
Definition qrhimetal.mm:164
id< MTLRasterizationRateMap > rateMap
Definition qrhimetal.mm:392
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:557
dispatch_semaphore_t sem[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:558
MTLPixelFormat colorFormat
Definition qrhimetal.mm:563
MTLRenderPassDescriptor * rp
Definition qrhimetal.mm:560
CAMetalLayer * layer
Definition qrhimetal.mm:556
double lastGpuTime[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:559
id< MTLTexture > msaaTex[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:561
QRhiTexture::Format rhiColorFormat
Definition qrhimetal.mm:562
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:369
id< MTLTexture > tex
Definition qrhimetal.mm:371
MTLPixelFormat viewFormatForSampling
Definition qrhimetal.mm:370
id< MTLTexture > viewForLevel(int level)
QMetalTexture * q
Definition qrhimetal.mm:367
id< MTLTexture > perLevelViews[QRhi::MAX_MIP_LEVELS]
Definition qrhimetal.mm:376
id< MTLBuffer > stagingBuf[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:374
id< MTLTexture > writeView
Definition qrhimetal.mm:373
QMetalTextureData(QMetalTexture *t)
Definition qrhimetal.mm:365
id< MTLTexture > samplingView
Definition qrhimetal.mm:372
id< MTLTexture > textureForWrite() const
Definition qrhimetal.mm:379
MTLPixelFormat format
Definition qrhimetal.mm:368
id< MTLTexture > textureForSampling() const
Definition qrhimetal.mm:378
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:88
bool create() override
Creates the corresponding native graphics resources.
int lastActiveFrameSlot
Definition qrhimetal_p.h:92
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:1740
QRhiReadbackResult * result
Definition qrhimetal.mm:279
id< MTLComputePipelineState > pipelineState
Definition qrhimetal.mm:245
id< MTLDepthStencilState > depthStencilState
Definition qrhimetal.mm:240
std::array< id< MTLComputePipelineState >, 3 > tessVertexComputeState
Definition qrhimetal.mm:241
id< MTLRasterizationRateMap > rateMap
Definition qrhimetal.mm:248
id< MTLSamplerState > samplerState
Definition qrhimetal.mm:233
id< MTLBuffer > stagingBuffers[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:227
id< MTLComputePipelineState > tessTessControlComputeState
Definition qrhimetal.mm:242
id< MTLIndirectCommandBuffer > icb
Definition qrhimetal.mm:251
id< MTLRenderPipelineState > pipelineState
Definition qrhimetal.mm:239
id< MTLBuffer > buffers[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:220
id< MTLTexture > views[QRhi::MAX_MIP_LEVELS]
Definition qrhimetal.mm:228
QMetalCommandBuffer cbWrapper
Definition qrhimetal.mm:262
OffscreenFrame(QRhiImplementation *rhi)
Definition qrhimetal.mm:259
QRhiReadbackDescription desc
Definition qrhimetal.mm:267
QRhiReadbackResult * result
Definition qrhimetal.mm:268
QRhiTexture::Format format
Definition qrhimetal.mm:272
void trySeedingRenderPipelineFromBinaryArchive(MTLRenderPipelineDescriptor *rpDesc)
id< MTLComputePipelineState > icbEncodePipelineU32
Definition qrhimetal.mm:293
static constexpr quint32 STAGING_AREA_MIN
Definition qrhimetal.mm:331
QRhiMetalData(QRhiMetal *rhi)
Definition qrhimetal.mm:181
QVarLengthArray< BufferReadback, 2 > activeBufferReadbacks
Definition qrhimetal.mm:284
QHash< ShaderCacheKey, QMetalShader > shaderCache
Definition qrhimetal.mm:308
bool setupBinaryArchive(NSURL *sourceFileUrl=nil)
Definition qrhimetal.mm:622
bool icbSetupFailed
Definition qrhimetal.mm:303
id< MTLFunction > icbEncodeFunctionU16
Definition qrhimetal.mm:297
void addRenderPipelineToBinaryArchive(MTLRenderPipelineDescriptor *rpDesc)
id< MTLFunction > icbEncodeFunctionU32
Definition qrhimetal.mm:296
MTLCaptureManager * captureMgr
Definition qrhimetal.mm:286
id< MTLBuffer > icbArgumentBuffer
Definition qrhimetal.mm:298
static constexpr quint32 LARGE_STAGING_ALLOC
Definition qrhimetal.mm:330
NSUInteger icbCapacity
Definition qrhimetal.mm:291
void trySeedingComputePipelineFromBinaryArchive(MTLComputePipelineDescriptor *cpDesc)
id< MTLIndirectCommandBuffer > icb
Definition qrhimetal.mm:290
QVector< DeferredReleaseEntry > releaseQueue
Definition qrhimetal.mm:256
id< MTLBuffer > allocArgumentBuffer(quint32 size, quint32 alignment, int frameSlot, quint32 *offset)
static constexpr quint32 STAGING_AREA_MAX
Definition qrhimetal.mm:332
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:287
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:183
id< MTLComputePipelineState > icbEncodePipeline
Definition qrhimetal.mm:292
static constexpr int STAGING_AREA_HIGH_DEMAND_FRAMES
Definition qrhimetal.mm:334
id< MTLFunction > icbEncodeFunction
Definition qrhimetal.mm:295
id< MTLComputePipelineState > icbEncodePipelineU16
Definition qrhimetal.mm:294
static const int TEXBUF_ALIGN
Definition qrhimetal.mm:305
id< MTLBuffer > icbRangeBuffer
Definition qrhimetal.mm:300
id< MTLBuffer > allocFromStagingArea(StagingArea *area, quint32 size, quint32 alignment, int frameSlot, quint32 minBlockSize, quint32 *offset)
StagingArea bufStagingPool[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:319
id< MTLBinaryArchive > binArch
Definition qrhimetal.mm:186
id< MTLCommandBuffer > newCommandBuffer()
Definition qrhimetal.mm:610
QVarLengthArray< TextureReadback, 2 > activeTextureReadbacks
Definition qrhimetal.mm:274
StagingArea argBufPool[QMTL_FRAMES_IN_FLIGHT]
Definition qrhimetal.mm:318
id< MTLDevice > dev
Definition qrhimetal.mm:184
quint64 globalFrameId
Definition qrhimetal.mm:338
static constexpr int STAGING_AREA_LOW_DEMAND_FRAMES
Definition qrhimetal.mm:333
void addComputePipelineToBinaryArchive(MTLComputePipelineDescriptor *cpDesc)
id< MTLCommandQueue > cmdQueue
Definition qrhimetal.mm:185
id< MTLBuffer > icbNoCountBuffer
Definition qrhimetal.mm:302
QMetalCommandBuffer * cbD
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1988
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1588
LimitsType limitsType
Definition qrhi.h:1599
float maxPotentialColorComponentValue
Definition qrhi.h:1607
LuminanceBehavior luminanceBehavior
Definition qrhi.h:1610
float maxColorComponentValue
Definition qrhi.h:1606
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1621