Merge pull request #1878 from billhollings/dyn-rend-separate-depth-stencil
Support separate depth and stencil attachments during dynamic rendering
This commit is contained in:
commit
e50cb32127
@ -21,6 +21,7 @@ Released TBD
|
|||||||
- Add support for extensions:
|
- Add support for extensions:
|
||||||
- `VK_KHR_map_memory2`
|
- `VK_KHR_map_memory2`
|
||||||
- Support BC compression on iOS/tvOS where available (iOS/tvOS 16.4 and above and supported by the GPU).
|
- Support BC compression on iOS/tvOS where available (iOS/tvOS 16.4 and above and supported by the GPU).
|
||||||
|
- Support separate depth and stencil attachments during dynamic rendering.
|
||||||
- Fix memory leak when waiting on timeline semaphores.
|
- Fix memory leak when waiting on timeline semaphores.
|
||||||
- Ensure shaders that use `PhysicalStorageBufferAddresses` encode the use of the associated `MTLBuffer`.
|
- Ensure shaders that use `PhysicalStorageBufferAddresses` encode the use of the associated `MTLBuffer`.
|
||||||
- Disable pipeline cache compression prior to macOS 10.15 and iOS/tvOS 13.0.
|
- Disable pipeline cache compression prior to macOS 10.15 and iOS/tvOS 13.0.
|
||||||
|
@ -262,7 +262,7 @@ protected:
|
|||||||
|
|
||||||
// Concrete template class implementations.
|
// Concrete template class implementations.
|
||||||
typedef MVKCmdSetViewport<1> MVKCmdSetViewport1;
|
typedef MVKCmdSetViewport<1> MVKCmdSetViewport1;
|
||||||
typedef MVKCmdSetViewport<kMVKCachedViewportScissorCount> MVKCmdSetViewportMulti;
|
typedef MVKCmdSetViewport<kMVKMaxViewportScissorCount> MVKCmdSetViewportMulti;
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
@ -292,7 +292,7 @@ protected:
|
|||||||
|
|
||||||
// Concrete template class implementations.
|
// Concrete template class implementations.
|
||||||
typedef MVKCmdSetScissor<1> MVKCmdSetScissor1;
|
typedef MVKCmdSetScissor<1> MVKCmdSetScissor1;
|
||||||
typedef MVKCmdSetScissor<kMVKCachedViewportScissorCount> MVKCmdSetScissorMulti;
|
typedef MVKCmdSetScissor<kMVKMaxViewportScissorCount> MVKCmdSetScissorMulti;
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
@ -282,7 +282,7 @@ void MVKCmdSetViewport<N>::encode(MVKCommandEncoder* cmdEncoder) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template class MVKCmdSetViewport<1>;
|
template class MVKCmdSetViewport<1>;
|
||||||
template class MVKCmdSetViewport<kMVKCachedViewportScissorCount>;
|
template class MVKCmdSetViewport<kMVKMaxViewportScissorCount>;
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
@ -309,7 +309,7 @@ void MVKCmdSetScissor<N>::encode(MVKCommandEncoder* cmdEncoder) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template class MVKCmdSetScissor<1>;
|
template class MVKCmdSetScissor<1>;
|
||||||
template class MVKCmdSetScissor<kMVKCachedViewportScissorCount>;
|
template class MVKCmdSetScissor<kMVKMaxViewportScissorCount>;
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
@ -284,8 +284,6 @@ protected:
|
|||||||
float _mtlDepthVal;
|
float _mtlDepthVal;
|
||||||
uint32_t _mtlStencilValue;
|
uint32_t _mtlStencilValue;
|
||||||
MVKCommandUse _commandUse;
|
MVKCommandUse _commandUse;
|
||||||
bool _isClearingDepth;
|
|
||||||
bool _isClearingStencil;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -326,7 +324,7 @@ protected:
|
|||||||
VkClearValue& getClearValue(uint32_t attIdx) override { return _vkClearValues[attIdx]; }
|
VkClearValue& getClearValue(uint32_t attIdx) override { return _vkClearValues[attIdx]; }
|
||||||
void setClearValue(uint32_t attIdx, const VkClearValue& clearValue) override { _vkClearValues[attIdx] = clearValue; }
|
void setClearValue(uint32_t attIdx, const VkClearValue& clearValue) override { _vkClearValues[attIdx] = clearValue; }
|
||||||
|
|
||||||
VkClearValue _vkClearValues[kMVKCachedColorAttachmentCount];
|
VkClearValue _vkClearValues[kMVKMaxColorAttachmentCount];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef MVKCmdClearMultiAttachments<1> MVKCmdClearMultiAttachments1;
|
typedef MVKCmdClearMultiAttachments<1> MVKCmdClearMultiAttachments1;
|
||||||
|
@ -1260,8 +1260,6 @@ VkResult MVKCmdClearAttachments<N>::setContent(MVKCommandBuffer* cmdBuff,
|
|||||||
_commandUse = cmdUse;
|
_commandUse = cmdUse;
|
||||||
_mtlDepthVal = 0.0;
|
_mtlDepthVal = 0.0;
|
||||||
_mtlStencilValue = 0;
|
_mtlStencilValue = 0;
|
||||||
_isClearingDepth = false;
|
|
||||||
_isClearingStencil = false;
|
|
||||||
MVKPixelFormats* pixFmts = cmdBuff->getPixelFormats();
|
MVKPixelFormats* pixFmts = cmdBuff->getPixelFormats();
|
||||||
|
|
||||||
// For each attachment to be cleared, mark it so in the render pipeline state
|
// For each attachment to be cleared, mark it so in the render pipeline state
|
||||||
@ -1279,14 +1277,12 @@ VkResult MVKCmdClearAttachments<N>::setContent(MVKCommandBuffer* cmdBuff,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mvkIsAnyFlagEnabled(clrAtt.aspectMask, VK_IMAGE_ASPECT_DEPTH_BIT)) {
|
if (mvkIsAnyFlagEnabled(clrAtt.aspectMask, VK_IMAGE_ASPECT_DEPTH_BIT)) {
|
||||||
_isClearingDepth = true;
|
_rpsKey.enableAttachment(kMVKClearAttachmentDepthIndex);
|
||||||
_rpsKey.enableAttachment(kMVKClearAttachmentDepthStencilIndex);
|
|
||||||
_mtlDepthVal = pixFmts->getMTLClearDepthValue(clrAtt.clearValue);
|
_mtlDepthVal = pixFmts->getMTLClearDepthValue(clrAtt.clearValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mvkIsAnyFlagEnabled(clrAtt.aspectMask, VK_IMAGE_ASPECT_STENCIL_BIT)) {
|
if (mvkIsAnyFlagEnabled(clrAtt.aspectMask, VK_IMAGE_ASPECT_STENCIL_BIT)) {
|
||||||
_isClearingStencil = true;
|
_rpsKey.enableAttachment(kMVKClearAttachmentStencilIndex);
|
||||||
_rpsKey.enableAttachment(kMVKClearAttachmentDepthStencilIndex);
|
|
||||||
_mtlStencilValue = pixFmts->getMTLClearStencilValue(clrAtt.clearValue);
|
_mtlStencilValue = pixFmts->getMTLClearStencilValue(clrAtt.clearValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1443,31 +1439,24 @@ void MVKCmdClearAttachments<N>::encode(MVKCommandEncoder* cmdEncoder) {
|
|||||||
clearColors[caIdx] = { (float)mtlCC.red, (float)mtlCC.green, (float)mtlCC.blue, (float)mtlCC.alpha};
|
clearColors[caIdx] = { (float)mtlCC.red, (float)mtlCC.green, (float)mtlCC.blue, (float)mtlCC.alpha};
|
||||||
}
|
}
|
||||||
|
|
||||||
// The depth value (including vertex position Z value) is held in the last index.
|
// The depth value is the vertex position Z value.
|
||||||
clearColors[kMVKClearAttachmentDepthStencilIndex] = { _mtlDepthVal, _mtlDepthVal, _mtlDepthVal, _mtlDepthVal };
|
clearColors[kMVKClearAttachmentDepthIndex] = { _mtlDepthVal, _mtlDepthVal, _mtlDepthVal, _mtlDepthVal };
|
||||||
|
|
||||||
VkFormat vkAttFmt = subpass->getDepthStencilFormat();
|
_rpsKey.attachmentMTLPixelFormats[kMVKClearAttachmentDepthIndex] = pixFmts->getMTLPixelFormat(subpass->getDepthFormat());
|
||||||
MTLPixelFormat mtlAttFmt = pixFmts->getMTLPixelFormat(vkAttFmt);
|
if ( !subpass->isDepthAttachmentUsed() ) { _rpsKey.disableAttachment(kMVKClearAttachmentDepthIndex); }
|
||||||
_rpsKey.attachmentMTLPixelFormats[kMVKClearAttachmentDepthStencilIndex] = mtlAttFmt;
|
|
||||||
|
|
||||||
bool isClearingDepth = _isClearingDepth && pixFmts->isDepthFormat(mtlAttFmt);
|
_rpsKey.attachmentMTLPixelFormats[kMVKClearAttachmentStencilIndex] = pixFmts->getMTLPixelFormat(subpass->getStencilFormat());
|
||||||
bool isClearingStencil = _isClearingStencil && pixFmts->isStencilFormat(mtlAttFmt);
|
if ( !subpass->isStencilAttachmentUsed() ) { _rpsKey.disableAttachment(kMVKClearAttachmentStencilIndex); }
|
||||||
if (!isClearingDepth && !isClearingStencil) {
|
|
||||||
// If the subpass attachment isn't actually used, don't try to clear it.
|
|
||||||
_rpsKey.disableAttachment(kMVKClearAttachmentDepthStencilIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_rpsKey.isAnyAttachmentEnabled()) {
|
if ( !_rpsKey.isAnyAttachmentEnabled() ) { return; }
|
||||||
// Nothing to do.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render the clear colors to the attachments
|
// Render the clear colors to the attachments
|
||||||
MVKCommandEncodingPool* cmdEncPool = cmdEncoder->getCommandEncodingPool();
|
MVKCommandEncodingPool* cmdEncPool = cmdEncoder->getCommandEncodingPool();
|
||||||
id<MTLRenderCommandEncoder> mtlRendEnc = cmdEncoder->_mtlRenderEncoder;
|
id<MTLRenderCommandEncoder> mtlRendEnc = cmdEncoder->_mtlRenderEncoder;
|
||||||
[mtlRendEnc pushDebugGroup: getMTLDebugGroupLabel()];
|
[mtlRendEnc pushDebugGroup: getMTLDebugGroupLabel()];
|
||||||
[mtlRendEnc setRenderPipelineState: cmdEncPool->getCmdClearMTLRenderPipelineState(_rpsKey)];
|
[mtlRendEnc setRenderPipelineState: cmdEncPool->getCmdClearMTLRenderPipelineState(_rpsKey)];
|
||||||
[mtlRendEnc setDepthStencilState: cmdEncPool->getMTLDepthStencilState(isClearingDepth, isClearingStencil)];
|
[mtlRendEnc setDepthStencilState: cmdEncPool->getMTLDepthStencilState(_rpsKey.isAttachmentUsed(kMVKClearAttachmentDepthIndex),
|
||||||
|
_rpsKey.isAttachmentUsed(kMVKClearAttachmentStencilIndex))];
|
||||||
[mtlRendEnc setStencilReferenceValue: _mtlStencilValue];
|
[mtlRendEnc setStencilReferenceValue: _mtlStencilValue];
|
||||||
[mtlRendEnc setCullMode: MTLCullModeNone];
|
[mtlRendEnc setCullMode: MTLCullModeNone];
|
||||||
[mtlRendEnc setTriangleFillMode: MTLTriangleFillModeFill];
|
[mtlRendEnc setTriangleFillMode: MTLTriangleFillModeFill];
|
||||||
|
@ -401,10 +401,17 @@ void MVKCommandEncoder::beginRendering(MVKCommand* rendCmd, const VkRenderingInf
|
|||||||
? VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS
|
? VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS
|
||||||
: VK_SUBPASS_CONTENTS_INLINE);
|
: VK_SUBPASS_CONTENTS_INLINE);
|
||||||
|
|
||||||
uint32_t maxAttCnt = (pRenderingInfo->colorAttachmentCount + 1) * 2;
|
uint32_t maxAttCnt = (pRenderingInfo->colorAttachmentCount + 2) * 2;
|
||||||
MVKImageView* attachments[maxAttCnt];
|
MVKImageView* imageViews[maxAttCnt];
|
||||||
VkClearValue clearValues[maxAttCnt];
|
VkClearValue clearValues[maxAttCnt];
|
||||||
uint32_t attCnt = mvkGetAttachments(pRenderingInfo, attachments, clearValues);
|
|
||||||
|
uint32_t attCnt = 0;
|
||||||
|
MVKRenderingAttachmentIterator attIter(pRenderingInfo);
|
||||||
|
attIter.iterate([&](const VkRenderingAttachmentInfo* pAttInfo, VkImageAspectFlagBits aspect, bool isResolveAttachment)->void {
|
||||||
|
imageViews[attCnt] = (MVKImageView*)(isResolveAttachment ? pAttInfo->resolveImageView : pAttInfo->imageView);
|
||||||
|
clearValues[attCnt] = pAttInfo->clearValue;
|
||||||
|
attCnt++;
|
||||||
|
});
|
||||||
|
|
||||||
// If we're resuming a suspended renderpass, continue to use the existing renderpass
|
// If we're resuming a suspended renderpass, continue to use the existing renderpass
|
||||||
// (with updated rendering flags) and framebuffer. Otherwise, create new transient
|
// (with updated rendering flags) and framebuffer. Otherwise, create new transient
|
||||||
@ -419,13 +426,14 @@ void MVKCommandEncoder::beginRendering(MVKCommand* rendCmd, const VkRenderingInf
|
|||||||
mvkRP->setRenderingFlags(pRenderingInfo->flags);
|
mvkRP->setRenderingFlags(pRenderingInfo->flags);
|
||||||
mvkFB = _pEncodingContext->getFramebuffer();
|
mvkFB = _pEncodingContext->getFramebuffer();
|
||||||
} else {
|
} else {
|
||||||
mvkRP = mvkCreateRenderPass(getDevice(), pRenderingInfo);
|
auto* mvkDev = getDevice();
|
||||||
mvkFB = mvkCreateFramebuffer(getDevice(), pRenderingInfo, mvkRP);
|
mvkRP = mvkDev->createRenderPass(pRenderingInfo, nullptr);
|
||||||
|
mvkFB = mvkDev->createFramebuffer(pRenderingInfo, nullptr);
|
||||||
}
|
}
|
||||||
beginRenderpass(rendCmd, contents, mvkRP, mvkFB,
|
beginRenderpass(rendCmd, contents, mvkRP, mvkFB,
|
||||||
pRenderingInfo->renderArea,
|
pRenderingInfo->renderArea,
|
||||||
MVKArrayRef(clearValues, attCnt),
|
MVKArrayRef(clearValues, attCnt),
|
||||||
MVKArrayRef(attachments, attCnt),
|
MVKArrayRef(imageViews, attCnt),
|
||||||
MVKArrayRef<MVKArrayRef<MTLSamplePosition>>(),
|
MVKArrayRef<MVKArrayRef<MTLSamplePosition>>(),
|
||||||
kMVKCommandUseBeginRendering);
|
kMVKCommandUseBeginRendering);
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void encodeImpl(uint32_t stage) override;
|
void encodeImpl(uint32_t stage) override;
|
||||||
|
|
||||||
MVKSmallVector<VkViewport, kMVKCachedViewportScissorCount> _viewports, _dynamicViewports;
|
MVKSmallVector<VkViewport, kMVKMaxViewportScissorCount> _viewports, _dynamicViewports;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void encodeImpl(uint32_t stage) override;
|
void encodeImpl(uint32_t stage) override;
|
||||||
|
|
||||||
MVKSmallVector<VkRect2D, kMVKCachedViewportScissorCount> _scissors, _dynamicScissors;
|
MVKSmallVector<VkRect2D, kMVKMaxViewportScissorCount> _scissors, _dynamicScissors;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -328,15 +328,12 @@ void MVKDepthStencilCommandEncoderState::beginMetalRenderPass() {
|
|||||||
MVKCommandEncoderState::beginMetalRenderPass();
|
MVKCommandEncoderState::beginMetalRenderPass();
|
||||||
|
|
||||||
MVKRenderSubpass* mvkSubpass = _cmdEncoder->getSubpass();
|
MVKRenderSubpass* mvkSubpass = _cmdEncoder->getSubpass();
|
||||||
MVKPixelFormats* pixFmts = _cmdEncoder->getPixelFormats();
|
|
||||||
MTLPixelFormat mtlDSFormat = pixFmts->getMTLPixelFormat(mvkSubpass->getDepthStencilFormat());
|
|
||||||
|
|
||||||
bool prevHasDepthAttachment = _hasDepthAttachment;
|
bool prevHasDepthAttachment = _hasDepthAttachment;
|
||||||
_hasDepthAttachment = pixFmts->isDepthFormat(mtlDSFormat);
|
_hasDepthAttachment = mvkSubpass->isDepthAttachmentUsed();
|
||||||
if (_hasDepthAttachment != prevHasDepthAttachment) { markDirty(); }
|
if (_hasDepthAttachment != prevHasDepthAttachment) { markDirty(); }
|
||||||
|
|
||||||
bool prevHasStencilAttachment = _hasStencilAttachment;
|
bool prevHasStencilAttachment = _hasStencilAttachment;
|
||||||
_hasStencilAttachment = pixFmts->isStencilFormat(mtlDSFormat);
|
_hasStencilAttachment = mvkSubpass->isStencilAttachmentUsed();
|
||||||
if (_hasStencilAttachment != prevHasStencilAttachment) { markDirty(); }
|
if (_hasStencilAttachment != prevHasStencilAttachment) { markDirty(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,9 +107,11 @@ namespace std {
|
|||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark MVKRPSKeyClearAtt
|
#pragma mark MVKRPSKeyClearAtt
|
||||||
|
|
||||||
#define kMVKClearAttachmentCount (kMVKCachedColorAttachmentCount + 1)
|
const static uint32_t kMVKClearColorAttachmentCount = kMVKMaxColorAttachmentCount;
|
||||||
#define kMVKClearAttachmentDepthStencilIndex (kMVKClearAttachmentCount - 1)
|
const static uint32_t kMVKClearAttachmentDepthIndex = kMVKClearColorAttachmentCount;
|
||||||
#define kMVKClearAttachmentLayeredRenderingBitIndex kMVKClearAttachmentCount
|
const static uint32_t kMVKClearAttachmentStencilIndex = kMVKClearAttachmentDepthIndex + 1;
|
||||||
|
const static uint32_t kMVKClearAttachmentCount = kMVKClearAttachmentStencilIndex + 1;
|
||||||
|
const static uint32_t kMVKClearAttachmentLayeredRenderingBitIndex = kMVKClearAttachmentStencilIndex + 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key to use for looking up cached MTLRenderPipelineState instances.
|
* Key to use for looking up cached MTLRenderPipelineState instances.
|
||||||
|
@ -113,6 +113,8 @@ id<MTLSamplerState> MVKCommandResourceFactory::newCmdBlitImageMTLSamplerState(MT
|
|||||||
|
|
||||||
id<MTLRenderPipelineState> MVKCommandResourceFactory::newCmdClearMTLRenderPipelineState(MVKRPSKeyClearAtt& attKey,
|
id<MTLRenderPipelineState> MVKCommandResourceFactory::newCmdClearMTLRenderPipelineState(MVKRPSKeyClearAtt& attKey,
|
||||||
MVKVulkanAPIDeviceObject* owner) {
|
MVKVulkanAPIDeviceObject* owner) {
|
||||||
|
MVKPixelFormats* pixFmts = getPixelFormats();
|
||||||
|
|
||||||
id<MTLFunction> vtxFunc = newClearVertFunction(attKey); // temp retain
|
id<MTLFunction> vtxFunc = newClearVertFunction(attKey); // temp retain
|
||||||
id<MTLFunction> fragFunc = newClearFragFunction(attKey); // temp retain
|
id<MTLFunction> fragFunc = newClearFragFunction(attKey); // temp retain
|
||||||
MTLRenderPipelineDescriptor* plDesc = [MTLRenderPipelineDescriptor new]; // temp retain
|
MTLRenderPipelineDescriptor* plDesc = [MTLRenderPipelineDescriptor new]; // temp retain
|
||||||
@ -122,15 +124,17 @@ id<MTLRenderPipelineState> MVKCommandResourceFactory::newCmdClearMTLRenderPipeli
|
|||||||
plDesc.sampleCount = attKey.mtlSampleCount;
|
plDesc.sampleCount = attKey.mtlSampleCount;
|
||||||
plDesc.inputPrimitiveTopologyMVK = MTLPrimitiveTopologyClassTriangle;
|
plDesc.inputPrimitiveTopologyMVK = MTLPrimitiveTopologyClassTriangle;
|
||||||
|
|
||||||
for (uint32_t caIdx = 0; caIdx < kMVKClearAttachmentDepthStencilIndex; caIdx++) {
|
for (uint32_t caIdx = 0; caIdx < kMVKClearColorAttachmentCount; caIdx++) {
|
||||||
MTLRenderPipelineColorAttachmentDescriptor* colorDesc = plDesc.colorAttachments[caIdx];
|
MTLRenderPipelineColorAttachmentDescriptor* colorDesc = plDesc.colorAttachments[caIdx];
|
||||||
colorDesc.pixelFormat = (MTLPixelFormat)attKey.attachmentMTLPixelFormats[caIdx];
|
colorDesc.pixelFormat = (MTLPixelFormat)attKey.attachmentMTLPixelFormats[caIdx];
|
||||||
colorDesc.writeMask = attKey.isAttachmentEnabled(caIdx) ? MTLColorWriteMaskAll : MTLColorWriteMaskNone;
|
colorDesc.writeMask = attKey.isAttachmentEnabled(caIdx) ? MTLColorWriteMaskAll : MTLColorWriteMaskNone;
|
||||||
}
|
}
|
||||||
MVKPixelFormats* pixFmts = getPixelFormats();
|
|
||||||
MTLPixelFormat mtlDSFormat = (MTLPixelFormat)attKey.attachmentMTLPixelFormats[kMVKClearAttachmentDepthStencilIndex];
|
MTLPixelFormat mtlDepthFormat = (MTLPixelFormat)attKey.attachmentMTLPixelFormats[kMVKClearAttachmentDepthIndex];
|
||||||
if (pixFmts->isDepthFormat(mtlDSFormat)) { plDesc.depthAttachmentPixelFormat = mtlDSFormat; }
|
if (pixFmts->isDepthFormat(mtlDepthFormat)) { plDesc.depthAttachmentPixelFormat = mtlDepthFormat; }
|
||||||
if (pixFmts->isStencilFormat(mtlDSFormat)) { plDesc.stencilAttachmentPixelFormat = mtlDSFormat; }
|
|
||||||
|
MTLPixelFormat mtlStencilFormat = (MTLPixelFormat)attKey.attachmentMTLPixelFormats[kMVKClearAttachmentStencilIndex];
|
||||||
|
if (pixFmts->isStencilFormat(mtlStencilFormat)) { plDesc.stencilAttachmentPixelFormat = mtlStencilFormat; }
|
||||||
|
|
||||||
MTLVertexDescriptor* vtxDesc = plDesc.vertexDescriptor;
|
MTLVertexDescriptor* vtxDesc = plDesc.vertexDescriptor;
|
||||||
|
|
||||||
@ -273,7 +277,7 @@ id<MTLFunction> MVKCommandResourceFactory::newBlitFragFunction(MVKRPSKeyBlitImg&
|
|||||||
[msl appendLineMVK: @" return out;"];
|
[msl appendLineMVK: @" return out;"];
|
||||||
[msl appendLineMVK: @"}"];
|
[msl appendLineMVK: @"}"];
|
||||||
|
|
||||||
// MVKLogDebug("\n%s", msl.UTF8String);
|
// MVKLogInfo("\n%s", msl.UTF8String);
|
||||||
|
|
||||||
return newMTLFunction(msl, funcName);
|
return newMTLFunction(msl, funcName);
|
||||||
}
|
}
|
||||||
@ -300,15 +304,16 @@ id<MTLFunction> MVKCommandResourceFactory::newClearVertFunction(MVKRPSKeyClearAt
|
|||||||
[msl appendLineMVK];
|
[msl appendLineMVK];
|
||||||
|
|
||||||
NSString* funcName = @"vertClear";
|
NSString* funcName = @"vertClear";
|
||||||
[msl appendFormat: @"vertex VaryingsPos %@(AttributesPos attributes [[stage_in]], constant ClearColorsIn& ccIn [[buffer(0)]]) {", funcName];
|
[msl appendFormat: @"vertex VaryingsPos %@(AttributesPos attributes [[stage_in]], constant ClearColorsIn& ccIn [[buffer(0)]]) {", funcName];
|
||||||
[msl appendLineMVK];
|
[msl appendLineMVK];
|
||||||
[msl appendLineMVK: @" VaryingsPos varyings;"];
|
[msl appendLineMVK: @" VaryingsPos varyings;"];
|
||||||
[msl appendLineMVK: @" varyings.v_position = float4(attributes.a_position.x, -attributes.a_position.y, ccIn.colors[8].r, 1.0);"];
|
[msl appendFormat: @" varyings.v_position = float4(attributes.a_position.x, -attributes.a_position.y, ccIn.colors[%d].r, 1.0);", kMVKClearAttachmentDepthIndex];
|
||||||
|
[msl appendLineMVK];
|
||||||
[msl appendLineMVK: @" varyings.layer = uint(attributes.a_position.w);"];
|
[msl appendLineMVK: @" varyings.layer = uint(attributes.a_position.w);"];
|
||||||
[msl appendLineMVK: @" return varyings;"];
|
[msl appendLineMVK: @" return varyings;"];
|
||||||
[msl appendLineMVK: @"}"];
|
[msl appendLineMVK: @"}"];
|
||||||
|
|
||||||
// MVKLogDebug("\n%s", msl.UTF8String);
|
// MVKLogInfo("\n%s", msl.UTF8String);
|
||||||
|
|
||||||
return newMTLFunction(msl, funcName);
|
return newMTLFunction(msl, funcName);
|
||||||
}
|
}
|
||||||
@ -329,7 +334,7 @@ id<MTLFunction> MVKCommandResourceFactory::newClearFragFunction(MVKRPSKeyClearAt
|
|||||||
[msl appendLineMVK: @"} ClearColorsIn;"];
|
[msl appendLineMVK: @"} ClearColorsIn;"];
|
||||||
[msl appendLineMVK];
|
[msl appendLineMVK];
|
||||||
[msl appendLineMVK: @"typedef struct {"];
|
[msl appendLineMVK: @"typedef struct {"];
|
||||||
for (uint32_t caIdx = 0; caIdx < kMVKClearAttachmentDepthStencilIndex; caIdx++) {
|
for (uint32_t caIdx = 0; caIdx < kMVKClearColorAttachmentCount; caIdx++) {
|
||||||
if (attKey.isAttachmentUsed(caIdx)) {
|
if (attKey.isAttachmentUsed(caIdx)) {
|
||||||
NSString* typeStr = getMTLFormatTypeString((MTLPixelFormat)attKey.attachmentMTLPixelFormats[caIdx]);
|
NSString* typeStr = getMTLFormatTypeString((MTLPixelFormat)attKey.attachmentMTLPixelFormats[caIdx]);
|
||||||
[msl appendFormat: @" %@4 color%u [[color(%u)]];", typeStr, caIdx, caIdx];
|
[msl appendFormat: @" %@4 color%u [[color(%u)]];", typeStr, caIdx, caIdx];
|
||||||
@ -343,7 +348,7 @@ id<MTLFunction> MVKCommandResourceFactory::newClearFragFunction(MVKRPSKeyClearAt
|
|||||||
[msl appendFormat: @"fragment ClearColorsOut %@(VaryingsPos varyings [[stage_in]], constant ClearColorsIn& ccIn [[buffer(0)]]) {", funcName];
|
[msl appendFormat: @"fragment ClearColorsOut %@(VaryingsPos varyings [[stage_in]], constant ClearColorsIn& ccIn [[buffer(0)]]) {", funcName];
|
||||||
[msl appendLineMVK];
|
[msl appendLineMVK];
|
||||||
[msl appendLineMVK: @" ClearColorsOut ccOut;"];
|
[msl appendLineMVK: @" ClearColorsOut ccOut;"];
|
||||||
for (uint32_t caIdx = 0; caIdx < kMVKClearAttachmentDepthStencilIndex; caIdx++) {
|
for (uint32_t caIdx = 0; caIdx < kMVKClearColorAttachmentCount; caIdx++) {
|
||||||
if (attKey.isAttachmentUsed(caIdx)) {
|
if (attKey.isAttachmentUsed(caIdx)) {
|
||||||
NSString* typeStr = getMTLFormatTypeString((MTLPixelFormat)attKey.attachmentMTLPixelFormats[caIdx]);
|
NSString* typeStr = getMTLFormatTypeString((MTLPixelFormat)attKey.attachmentMTLPixelFormats[caIdx]);
|
||||||
[msl appendFormat: @" ccOut.color%u = %@4(ccIn.colors[%u]);", caIdx, typeStr, caIdx];
|
[msl appendFormat: @" ccOut.color%u = %@4(ccIn.colors[%u]);", caIdx, typeStr, caIdx];
|
||||||
@ -353,7 +358,7 @@ id<MTLFunction> MVKCommandResourceFactory::newClearFragFunction(MVKRPSKeyClearAt
|
|||||||
[msl appendLineMVK: @" return ccOut;"];
|
[msl appendLineMVK: @" return ccOut;"];
|
||||||
[msl appendLineMVK: @"}"];
|
[msl appendLineMVK: @"}"];
|
||||||
|
|
||||||
// MVKLogDebug("\n%s", msl.UTF8String);
|
// MVKLogInfo("\n%s", msl.UTF8String);
|
||||||
|
|
||||||
return newMTLFunction(msl, funcName);
|
return newMTLFunction(msl, funcName);
|
||||||
}
|
}
|
||||||
|
@ -80,8 +80,8 @@ const static uint32_t kMVKQueueFamilyCount = 4;
|
|||||||
const static uint32_t kMVKQueueCountPerQueueFamily = 1; // Must be 1. See comments in MVKPhysicalDevice::getQueueFamilies()
|
const static uint32_t kMVKQueueCountPerQueueFamily = 1; // Must be 1. See comments in MVKPhysicalDevice::getQueueFamilies()
|
||||||
const static uint32_t kMVKMinSwapchainImageCount = 2;
|
const static uint32_t kMVKMinSwapchainImageCount = 2;
|
||||||
const static uint32_t kMVKMaxSwapchainImageCount = 3;
|
const static uint32_t kMVKMaxSwapchainImageCount = 3;
|
||||||
const static uint32_t kMVKCachedViewportScissorCount = 16;
|
const static uint32_t kMVKMaxColorAttachmentCount = 8;
|
||||||
const static uint32_t kMVKCachedColorAttachmentCount = 8;
|
const static uint32_t kMVKMaxViewportScissorCount = 16;
|
||||||
const static uint32_t kMVKMaxDescriptorSetCount = SPIRV_CROSS_NAMESPACE::kMaxArgumentBuffers;
|
const static uint32_t kMVKMaxDescriptorSetCount = SPIRV_CROSS_NAMESPACE::kMaxArgumentBuffers;
|
||||||
|
|
||||||
#if !MVK_XCODE_12
|
#if !MVK_XCODE_12
|
||||||
@ -631,6 +631,8 @@ public:
|
|||||||
|
|
||||||
MVKFramebuffer* createFramebuffer(const VkFramebufferCreateInfo* pCreateInfo,
|
MVKFramebuffer* createFramebuffer(const VkFramebufferCreateInfo* pCreateInfo,
|
||||||
const VkAllocationCallbacks* pAllocator);
|
const VkAllocationCallbacks* pAllocator);
|
||||||
|
MVKFramebuffer* createFramebuffer(const VkRenderingInfo* pRenderingInfo,
|
||||||
|
const VkAllocationCallbacks* pAllocator);
|
||||||
void destroyFramebuffer(MVKFramebuffer* mvkFB,
|
void destroyFramebuffer(MVKFramebuffer* mvkFB,
|
||||||
const VkAllocationCallbacks* pAllocator);
|
const VkAllocationCallbacks* pAllocator);
|
||||||
|
|
||||||
@ -638,6 +640,8 @@ public:
|
|||||||
const VkAllocationCallbacks* pAllocator);
|
const VkAllocationCallbacks* pAllocator);
|
||||||
MVKRenderPass* createRenderPass(const VkRenderPassCreateInfo2* pCreateInfo,
|
MVKRenderPass* createRenderPass(const VkRenderPassCreateInfo2* pCreateInfo,
|
||||||
const VkAllocationCallbacks* pAllocator);
|
const VkAllocationCallbacks* pAllocator);
|
||||||
|
MVKRenderPass* createRenderPass(const VkRenderingInfo* pRenderingInfo,
|
||||||
|
const VkAllocationCallbacks* pAllocator);
|
||||||
void destroyRenderPass(MVKRenderPass* mvkRP,
|
void destroyRenderPass(MVKRenderPass* mvkRP,
|
||||||
const VkAllocationCallbacks* pAllocator);
|
const VkAllocationCallbacks* pAllocator);
|
||||||
|
|
||||||
|
@ -2269,17 +2269,17 @@ void MVKPhysicalDevice::initFeatures() {
|
|||||||
void MVKPhysicalDevice::initLimits() {
|
void MVKPhysicalDevice::initLimits() {
|
||||||
|
|
||||||
#if MVK_TVOS
|
#if MVK_TVOS
|
||||||
_properties.limits.maxColorAttachments = kMVKCachedColorAttachmentCount;
|
_properties.limits.maxColorAttachments = kMVKMaxColorAttachmentCount;
|
||||||
#endif
|
#endif
|
||||||
#if MVK_IOS
|
#if MVK_IOS
|
||||||
if (supportsMTLFeatureSet(iOS_GPUFamily2_v1)) {
|
if (supportsMTLFeatureSet(iOS_GPUFamily2_v1)) {
|
||||||
_properties.limits.maxColorAttachments = kMVKCachedColorAttachmentCount;
|
_properties.limits.maxColorAttachments = kMVKMaxColorAttachmentCount;
|
||||||
} else {
|
} else {
|
||||||
_properties.limits.maxColorAttachments = 4; // < kMVKCachedColorAttachmentCount
|
_properties.limits.maxColorAttachments = 4; // < kMVKMaxColorAttachmentCount
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if MVK_MACOS
|
#if MVK_MACOS
|
||||||
_properties.limits.maxColorAttachments = kMVKCachedColorAttachmentCount;
|
_properties.limits.maxColorAttachments = kMVKMaxColorAttachmentCount;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_properties.limits.maxFragmentOutputAttachments = _properties.limits.maxColorAttachments;
|
_properties.limits.maxFragmentOutputAttachments = _properties.limits.maxColorAttachments;
|
||||||
@ -2309,7 +2309,7 @@ void MVKPhysicalDevice::initLimits() {
|
|||||||
float maxVPDim = max(_properties.limits.maxViewportDimensions[0], _properties.limits.maxViewportDimensions[1]);
|
float maxVPDim = max(_properties.limits.maxViewportDimensions[0], _properties.limits.maxViewportDimensions[1]);
|
||||||
_properties.limits.viewportBoundsRange[0] = (-2.0 * maxVPDim);
|
_properties.limits.viewportBoundsRange[0] = (-2.0 * maxVPDim);
|
||||||
_properties.limits.viewportBoundsRange[1] = (2.0 * maxVPDim) - 1;
|
_properties.limits.viewportBoundsRange[1] = (2.0 * maxVPDim) - 1;
|
||||||
_properties.limits.maxViewports = _features.multiViewport ? kMVKCachedViewportScissorCount : 1;
|
_properties.limits.maxViewports = _features.multiViewport ? kMVKMaxViewportScissorCount : 1;
|
||||||
|
|
||||||
_properties.limits.maxImageDimension3D = _metalFeatures.maxTextureLayers;
|
_properties.limits.maxImageDimension3D = _metalFeatures.maxTextureLayers;
|
||||||
_properties.limits.maxImageArrayLayers = _metalFeatures.maxTextureLayers;
|
_properties.limits.maxImageArrayLayers = _metalFeatures.maxTextureLayers;
|
||||||
@ -3893,6 +3893,11 @@ MVKFramebuffer* MVKDevice::createFramebuffer(const VkFramebufferCreateInfo* pCre
|
|||||||
return new MVKFramebuffer(this, pCreateInfo);
|
return new MVKFramebuffer(this, pCreateInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MVKFramebuffer* MVKDevice::createFramebuffer(const VkRenderingInfo* pRenderingInfo,
|
||||||
|
const VkAllocationCallbacks* pAllocator) {
|
||||||
|
return new MVKFramebuffer(this, pRenderingInfo);
|
||||||
|
}
|
||||||
|
|
||||||
void MVKDevice::destroyFramebuffer(MVKFramebuffer* mvkFB,
|
void MVKDevice::destroyFramebuffer(MVKFramebuffer* mvkFB,
|
||||||
const VkAllocationCallbacks* pAllocator) {
|
const VkAllocationCallbacks* pAllocator) {
|
||||||
if (mvkFB) { mvkFB->destroy(); }
|
if (mvkFB) { mvkFB->destroy(); }
|
||||||
@ -3908,6 +3913,11 @@ MVKRenderPass* MVKDevice::createRenderPass(const VkRenderPassCreateInfo2* pCreat
|
|||||||
return new MVKRenderPass(this, pCreateInfo);
|
return new MVKRenderPass(this, pCreateInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MVKRenderPass* MVKDevice::createRenderPass(const VkRenderingInfo* pRenderingInfo,
|
||||||
|
const VkAllocationCallbacks* pAllocator) {
|
||||||
|
return new MVKRenderPass(this, pRenderingInfo);
|
||||||
|
}
|
||||||
|
|
||||||
void MVKDevice::destroyRenderPass(MVKRenderPass* mvkRP,
|
void MVKDevice::destroyRenderPass(MVKRenderPass* mvkRP,
|
||||||
const VkAllocationCallbacks* pAllocator) {
|
const VkAllocationCallbacks* pAllocator) {
|
||||||
if (mvkRP) { mvkRP->destroy(); }
|
if (mvkRP) { mvkRP->destroy(); }
|
||||||
|
@ -58,6 +58,8 @@ public:
|
|||||||
|
|
||||||
MVKFramebuffer(MVKDevice* device, const VkFramebufferCreateInfo* pCreateInfo);
|
MVKFramebuffer(MVKDevice* device, const VkFramebufferCreateInfo* pCreateInfo);
|
||||||
|
|
||||||
|
MVKFramebuffer(MVKDevice* device, const VkRenderingInfo* pRenderingInfo);
|
||||||
|
|
||||||
~MVKFramebuffer() override;
|
~MVKFramebuffer() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -69,12 +71,3 @@ protected:
|
|||||||
VkExtent2D _extent;
|
VkExtent2D _extent;
|
||||||
uint32_t _layerCount;
|
uint32_t _layerCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
|
||||||
#pragma mark Support functions
|
|
||||||
|
|
||||||
/** Returns an image-less MVKFramebuffer object created from the rendering info. */
|
|
||||||
MVKFramebuffer* mvkCreateFramebuffer(MVKDevice* device,
|
|
||||||
const VkRenderingInfo* pRenderingInfo,
|
|
||||||
MVKRenderPass* mvkRenderPass);
|
|
||||||
|
@ -82,8 +82,8 @@ id<MTLTexture> MVKFramebuffer::getDummyAttachmentMTLTexture(MVKRenderSubpass* su
|
|||||||
|
|
||||||
MVKFramebuffer::MVKFramebuffer(MVKDevice* device,
|
MVKFramebuffer::MVKFramebuffer(MVKDevice* device,
|
||||||
const VkFramebufferCreateInfo* pCreateInfo) : MVKVulkanAPIDeviceObject(device) {
|
const VkFramebufferCreateInfo* pCreateInfo) : MVKVulkanAPIDeviceObject(device) {
|
||||||
_extent = { .width = pCreateInfo->width, .height = pCreateInfo->height };
|
|
||||||
_layerCount = pCreateInfo->layers;
|
_layerCount = pCreateInfo->layers;
|
||||||
|
_extent = { .width = pCreateInfo->width, .height = pCreateInfo->height };
|
||||||
|
|
||||||
// If this is not an image-less framebuffer, add the attachments
|
// If this is not an image-less framebuffer, add the attachments
|
||||||
if ( !mvkIsAnyFlagEnabled(pCreateInfo->flags, VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) ) {
|
if ( !mvkIsAnyFlagEnabled(pCreateInfo->flags, VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) ) {
|
||||||
@ -94,51 +94,25 @@ MVKFramebuffer::MVKFramebuffer(MVKDevice* device,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MVKFramebuffer::~MVKFramebuffer() {
|
MVKFramebuffer::MVKFramebuffer(MVKDevice* device,
|
||||||
[_mtlDummyTex release];
|
const VkRenderingInfo* pRenderingInfo) : MVKVulkanAPIDeviceObject(device) {
|
||||||
}
|
_layerCount = pRenderingInfo->layerCount;
|
||||||
|
|
||||||
|
_extent = {};
|
||||||
#pragma mark -
|
|
||||||
#pragma mark Support functions
|
|
||||||
|
|
||||||
MVKFramebuffer* mvkCreateFramebuffer(MVKDevice* device,
|
|
||||||
const VkRenderingInfo* pRenderingInfo,
|
|
||||||
MVKRenderPass* mvkRenderPass) {
|
|
||||||
uint32_t attCnt = 0;
|
|
||||||
VkExtent3D fbExtent = {};
|
|
||||||
for (uint32_t caIdx = 0; caIdx < pRenderingInfo->colorAttachmentCount; caIdx++) {
|
for (uint32_t caIdx = 0; caIdx < pRenderingInfo->colorAttachmentCount; caIdx++) {
|
||||||
auto& clrAtt = pRenderingInfo->pColorAttachments[caIdx];
|
auto& clrAtt = pRenderingInfo->pColorAttachments[caIdx];
|
||||||
if (clrAtt.imageView) {
|
if (clrAtt.imageView) {
|
||||||
fbExtent = ((MVKImageView*)clrAtt.imageView)->getExtent3D();
|
_extent = mvkVkExtent2DFromVkExtent3D(((MVKImageView*)clrAtt.imageView)->getExtent3D());
|
||||||
attCnt++;
|
|
||||||
if (clrAtt.resolveImageView && clrAtt.resolveMode != VK_RESOLVE_MODE_NONE) {
|
|
||||||
attCnt++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto* pDSAtt = pRenderingInfo->pDepthAttachment ? pRenderingInfo->pDepthAttachment : pRenderingInfo->pStencilAttachment;
|
if (pRenderingInfo->pDepthAttachment && pRenderingInfo->pDepthAttachment->imageView) {
|
||||||
if (pDSAtt) {
|
_extent = mvkVkExtent2DFromVkExtent3D(((MVKImageView*)pRenderingInfo->pDepthAttachment->imageView)->getExtent3D());
|
||||||
if (pDSAtt->imageView) {
|
}
|
||||||
fbExtent = ((MVKImageView*)pDSAtt->imageView)->getExtent3D();
|
if (pRenderingInfo->pStencilAttachment && pRenderingInfo->pStencilAttachment->imageView) {
|
||||||
attCnt++;
|
_extent = mvkVkExtent2DFromVkExtent3D(((MVKImageView*)pRenderingInfo->pStencilAttachment->imageView)->getExtent3D());
|
||||||
}
|
|
||||||
if (pDSAtt->resolveImageView && pDSAtt->resolveMode != VK_RESOLVE_MODE_NONE) {
|
|
||||||
attCnt++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VkFramebufferCreateInfo fbCreateInfo;
|
|
||||||
fbCreateInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
|
||||||
fbCreateInfo.pNext = nullptr;
|
|
||||||
fbCreateInfo.flags = VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT;
|
|
||||||
fbCreateInfo.renderPass = (VkRenderPass)mvkRenderPass;
|
|
||||||
fbCreateInfo.attachmentCount = attCnt;
|
|
||||||
fbCreateInfo.pAttachments = nullptr;
|
|
||||||
fbCreateInfo.width = fbExtent.width;
|
|
||||||
fbCreateInfo.height = fbExtent.height;
|
|
||||||
fbCreateInfo.layers = pRenderingInfo->layerCount;
|
|
||||||
|
|
||||||
return device->createFramebuffer(&fbCreateInfo, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MVKFramebuffer::~MVKFramebuffer() {
|
||||||
|
[_mtlDummyTex release];
|
||||||
|
}
|
||||||
|
@ -560,6 +560,9 @@ public:
|
|||||||
/** Returns the 3D extent of this image at the specified mipmap level. */
|
/** Returns the 3D extent of this image at the specified mipmap level. */
|
||||||
VkExtent3D getExtent3D(uint8_t planeIndex = 0, uint32_t mipLevel = 0) { return _image->getExtent3D(planeIndex, mipLevel); }
|
VkExtent3D getExtent3D(uint8_t planeIndex = 0, uint32_t mipLevel = 0) { return _image->getExtent3D(planeIndex, mipLevel); }
|
||||||
|
|
||||||
|
/** Return the underlying image. */
|
||||||
|
MVKImage* getImage() { return _image; }
|
||||||
|
|
||||||
#pragma mark Metal
|
#pragma mark Metal
|
||||||
|
|
||||||
/** Returns the Metal texture underlying this image view. */
|
/** Returns the Metal texture underlying this image view. */
|
||||||
|
@ -346,17 +346,12 @@ protected:
|
|||||||
void markIfUsingPhysicalStorageBufferAddressesCapability(SPIRVToMSLConversionResultInfo& resultsInfo,
|
void markIfUsingPhysicalStorageBufferAddressesCapability(SPIRVToMSLConversionResultInfo& resultsInfo,
|
||||||
MVKShaderStage stage);
|
MVKShaderStage stage);
|
||||||
|
|
||||||
const VkPipelineShaderStageCreateInfo* _pVertexSS = nullptr;
|
|
||||||
const VkPipelineShaderStageCreateInfo* _pTessCtlSS = nullptr;
|
|
||||||
const VkPipelineShaderStageCreateInfo* _pTessEvalSS = nullptr;
|
|
||||||
const VkPipelineShaderStageCreateInfo* _pFragmentSS = nullptr;
|
|
||||||
|
|
||||||
VkPipelineTessellationStateCreateInfo _tessInfo;
|
VkPipelineTessellationStateCreateInfo _tessInfo;
|
||||||
VkPipelineRasterizationStateCreateInfo _rasterInfo;
|
VkPipelineRasterizationStateCreateInfo _rasterInfo;
|
||||||
VkPipelineDepthStencilStateCreateInfo _depthStencilInfo;
|
VkPipelineDepthStencilStateCreateInfo _depthStencilInfo;
|
||||||
|
|
||||||
MVKSmallVector<VkViewport, kMVKCachedViewportScissorCount> _viewports;
|
MVKSmallVector<VkViewport, kMVKMaxViewportScissorCount> _viewports;
|
||||||
MVKSmallVector<VkRect2D, kMVKCachedViewportScissorCount> _scissors;
|
MVKSmallVector<VkRect2D, kMVKMaxViewportScissorCount> _scissors;
|
||||||
MVKSmallVector<VkDynamicState> _dynamicState;
|
MVKSmallVector<VkDynamicState> _dynamicState;
|
||||||
MVKSmallVector<MTLSamplePosition> _customSamplePositions;
|
MVKSmallVector<MTLSamplePosition> _customSamplePositions;
|
||||||
MVKSmallVector<MVKTranslatedVertexBinding> _translatedVertexBindings;
|
MVKSmallVector<MVKTranslatedVertexBinding> _translatedVertexBindings;
|
||||||
@ -364,7 +359,12 @@ protected:
|
|||||||
MVKSmallVector<MVKStagedMTLArgumentEncoders> _mtlArgumentEncoders;
|
MVKSmallVector<MVKStagedMTLArgumentEncoders> _mtlArgumentEncoders;
|
||||||
MVKSmallVector<MVKStagedDescriptorBindingUse> _descriptorBindingUse;
|
MVKSmallVector<MVKStagedDescriptorBindingUse> _descriptorBindingUse;
|
||||||
MVKSmallVector<MVKShaderStage> _stagesUsingPhysicalStorageBufferAddressesCapability;
|
MVKSmallVector<MVKShaderStage> _stagesUsingPhysicalStorageBufferAddressesCapability;
|
||||||
|
std::unordered_map<uint32_t, id<MTLRenderPipelineState>> _multiviewMTLPipelineStates;
|
||||||
|
|
||||||
|
const VkPipelineShaderStageCreateInfo* _pVertexSS = nullptr;
|
||||||
|
const VkPipelineShaderStageCreateInfo* _pTessCtlSS = nullptr;
|
||||||
|
const VkPipelineShaderStageCreateInfo* _pTessEvalSS = nullptr;
|
||||||
|
const VkPipelineShaderStageCreateInfo* _pFragmentSS = nullptr;
|
||||||
MTLComputePipelineDescriptor* _mtlTessVertexStageDesc = nil;
|
MTLComputePipelineDescriptor* _mtlTessVertexStageDesc = nil;
|
||||||
id<MTLFunction> _mtlTessVertexFunctions[3] = {nil, nil, nil};
|
id<MTLFunction> _mtlTessVertexFunctions[3] = {nil, nil, nil};
|
||||||
|
|
||||||
@ -373,18 +373,17 @@ protected:
|
|||||||
id<MTLComputePipelineState> _mtlTessVertexStageIndex32State = nil;
|
id<MTLComputePipelineState> _mtlTessVertexStageIndex32State = nil;
|
||||||
id<MTLComputePipelineState> _mtlTessControlStageState = nil;
|
id<MTLComputePipelineState> _mtlTessControlStageState = nil;
|
||||||
id<MTLRenderPipelineState> _mtlPipelineState = nil;
|
id<MTLRenderPipelineState> _mtlPipelineState = nil;
|
||||||
std::unordered_map<uint32_t, id<MTLRenderPipelineState>> _multiviewMTLPipelineStates;
|
|
||||||
|
float _blendConstants[4] = { 0.0, 0.0, 0.0, 1.0 };
|
||||||
MTLCullMode _mtlCullMode;
|
MTLCullMode _mtlCullMode;
|
||||||
MTLWinding _mtlFrontWinding;
|
MTLWinding _mtlFrontWinding;
|
||||||
MTLTriangleFillMode _mtlFillMode;
|
MTLTriangleFillMode _mtlFillMode;
|
||||||
MTLDepthClipMode _mtlDepthClipMode;
|
MTLDepthClipMode _mtlDepthClipMode;
|
||||||
MTLPrimitiveType _mtlPrimitiveType;
|
MTLPrimitiveType _mtlPrimitiveType;
|
||||||
|
|
||||||
float _blendConstants[4] = { 0.0, 0.0, 0.0, 1.0 };
|
|
||||||
uint32_t _outputControlPointCount;
|
|
||||||
MVKShaderImplicitRezBinding _reservedVertexAttributeBufferCount;
|
MVKShaderImplicitRezBinding _reservedVertexAttributeBufferCount;
|
||||||
MVKShaderImplicitRezBinding _viewRangeBufferIndex;
|
MVKShaderImplicitRezBinding _viewRangeBufferIndex;
|
||||||
MVKShaderImplicitRezBinding _outputBufferIndex;
|
MVKShaderImplicitRezBinding _outputBufferIndex;
|
||||||
|
uint32_t _outputControlPointCount;
|
||||||
uint32_t _tessCtlPatchOutputBufferIndex = 0;
|
uint32_t _tessCtlPatchOutputBufferIndex = 0;
|
||||||
uint32_t _tessCtlLevelBufferIndex = 0;
|
uint32_t _tessCtlLevelBufferIndex = 0;
|
||||||
|
|
||||||
@ -408,7 +407,6 @@ protected:
|
|||||||
bool _needsFragmentViewRangeBuffer = false;
|
bool _needsFragmentViewRangeBuffer = false;
|
||||||
bool _isRasterizing = false;
|
bool _isRasterizing = false;
|
||||||
bool _isRasterizingColor = false;
|
bool _isRasterizingColor = false;
|
||||||
bool _isRasterizingDepthStencil = false;
|
|
||||||
bool _isUsingCustomSamplePositions = false;
|
bool _isUsingCustomSamplePositions = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -401,7 +401,6 @@ MVKGraphicsPipeline::MVKGraphicsPipeline(MVKDevice* device,
|
|||||||
const VkPipelineRenderingCreateInfo* pRendInfo = getRenderingCreateInfo(pCreateInfo);
|
const VkPipelineRenderingCreateInfo* pRendInfo = getRenderingCreateInfo(pCreateInfo);
|
||||||
_isRasterizing = !isRasterizationDisabled(pCreateInfo);
|
_isRasterizing = !isRasterizationDisabled(pCreateInfo);
|
||||||
_isRasterizingColor = _isRasterizing && mvkHasColorAttachments(pRendInfo);
|
_isRasterizingColor = _isRasterizing && mvkHasColorAttachments(pRendInfo);
|
||||||
_isRasterizingDepthStencil = _isRasterizing && mvkGetDepthStencilFormat(pRendInfo) != VK_FORMAT_UNDEFINED;
|
|
||||||
|
|
||||||
// Get the tessellation shaders, if present. Do this now, because we need to extract
|
// Get the tessellation shaders, if present. Do this now, because we need to extract
|
||||||
// reflection data from them that informs everything else.
|
// reflection data from them that informs everything else.
|
||||||
@ -488,8 +487,9 @@ MVKGraphicsPipeline::MVKGraphicsPipeline(MVKDevice* device,
|
|||||||
initCustomSamplePositions(pCreateInfo);
|
initCustomSamplePositions(pCreateInfo);
|
||||||
|
|
||||||
// Depth stencil content - clearing will disable depth and stencil testing
|
// Depth stencil content - clearing will disable depth and stencil testing
|
||||||
// Must ignore allowed bad pDepthStencilState pointer if rasterization disabled or no depth attachment
|
// Must ignore allowed bad pDepthStencilState pointer if rasterization disabled or no depth or stencil attachment format
|
||||||
mvkSetOrClear(&_depthStencilInfo, _isRasterizingDepthStencil ? pCreateInfo->pDepthStencilState : nullptr);
|
bool isRasterizingDepthStencil = _isRasterizing && (pRendInfo->depthAttachmentFormat || pRendInfo->stencilAttachmentFormat);
|
||||||
|
mvkSetOrClear(&_depthStencilInfo, isRasterizingDepthStencil ? pCreateInfo->pDepthStencilState : nullptr);
|
||||||
|
|
||||||
// Viewports and scissors - must ignore allowed bad pViewportState pointer if rasterization is disabled
|
// Viewports and scissors - must ignore allowed bad pViewportState pointer if rasterization is disabled
|
||||||
auto pVPState = _isRasterizing ? pCreateInfo->pViewportState : nullptr;
|
auto pVPState = _isRasterizing ? pCreateInfo->pViewportState : nullptr;
|
||||||
@ -1469,16 +1469,19 @@ void MVKGraphicsPipeline::addFragmentOutputToPipeline(MTLRenderPipelineDescripto
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Depth & stencil attachments
|
// Depth & stencil attachment formats
|
||||||
MVKPixelFormats* pixFmts = getPixelFormats();
|
MVKPixelFormats* pixFmts = getPixelFormats();
|
||||||
MTLPixelFormat mtlDSFormat = pixFmts->getMTLPixelFormat(mvkGetDepthStencilFormat(pRendInfo));
|
|
||||||
if (pixFmts->isDepthFormat(mtlDSFormat)) { plDesc.depthAttachmentPixelFormat = mtlDSFormat; }
|
|
||||||
if (pixFmts->isStencilFormat(mtlDSFormat)) { plDesc.stencilAttachmentPixelFormat = mtlDSFormat; }
|
|
||||||
|
|
||||||
// In Vulkan, it's perfectly valid to render with no attachments. In Metal we need to check for
|
MTLPixelFormat mtlDepthPixFmt = pixFmts->getMTLPixelFormat(pRendInfo->depthAttachmentFormat);
|
||||||
// support for it. If we have no attachments, then we may have to add a dummy attachment.
|
if (pixFmts->isDepthFormat(mtlDepthPixFmt)) { plDesc.depthAttachmentPixelFormat = mtlDepthPixFmt; }
|
||||||
if (!caCnt && !pixFmts->isDepthFormat(mtlDSFormat) && !pixFmts->isStencilFormat(mtlDSFormat) &&
|
|
||||||
!getDevice()->_pMetalFeatures->renderWithoutAttachments) {
|
MTLPixelFormat mtlStencilPixFmt = pixFmts->getMTLPixelFormat(pRendInfo->stencilAttachmentFormat);
|
||||||
|
if (pixFmts->isStencilFormat(mtlStencilPixFmt)) { plDesc.stencilAttachmentPixelFormat = mtlStencilPixFmt; }
|
||||||
|
|
||||||
|
// In Vulkan, it's perfectly valid to render without any attachments. In Metal, if that
|
||||||
|
// isn't supported, and we have no attachments, then we have to add a dummy attachment.
|
||||||
|
if (!getDevice()->_pMetalFeatures->renderWithoutAttachments &&
|
||||||
|
!caCnt && !pRendInfo->depthAttachmentFormat && !pRendInfo->stencilAttachmentFormat) {
|
||||||
|
|
||||||
MTLRenderPipelineColorAttachmentDescriptor* colorDesc = plDesc.colorAttachments[0];
|
MTLRenderPipelineColorAttachmentDescriptor* colorDesc = plDesc.colorAttachments[0];
|
||||||
colorDesc.pixelFormat = MTLPixelFormatR8Unorm;
|
colorDesc.pixelFormat = MTLPixelFormatR8Unorm;
|
||||||
@ -1554,7 +1557,6 @@ void MVKGraphicsPipeline::initShaderConversionConfig(SPIRVToMSLConversionConfigu
|
|||||||
|
|
||||||
const VkPipelineRenderingCreateInfo* pRendInfo = getRenderingCreateInfo(pCreateInfo);
|
const VkPipelineRenderingCreateInfo* pRendInfo = getRenderingCreateInfo(pCreateInfo);
|
||||||
MVKPixelFormats* pixFmts = getPixelFormats();
|
MVKPixelFormats* pixFmts = getPixelFormats();
|
||||||
MTLPixelFormat mtlDSFormat = pixFmts->getMTLPixelFormat(mvkGetDepthStencilFormat(pRendInfo));
|
|
||||||
|
|
||||||
// Disable any unused color attachments, because Metal validation can complain if the
|
// Disable any unused color attachments, because Metal validation can complain if the
|
||||||
// fragment shader outputs a color value without a corresponding color attachment.
|
// fragment shader outputs a color value without a corresponding color attachment.
|
||||||
@ -1574,8 +1576,8 @@ void MVKGraphicsPipeline::initShaderConversionConfig(SPIRVToMSLConversionConfigu
|
|||||||
shaderConfig.options.mslOptions.ios_support_base_vertex_instance = getDevice()->_pMetalFeatures->baseVertexInstanceDrawing;
|
shaderConfig.options.mslOptions.ios_support_base_vertex_instance = getDevice()->_pMetalFeatures->baseVertexInstanceDrawing;
|
||||||
shaderConfig.options.mslOptions.texture_1D_as_2D = mvkConfig().texture1DAs2D;
|
shaderConfig.options.mslOptions.texture_1D_as_2D = mvkConfig().texture1DAs2D;
|
||||||
shaderConfig.options.mslOptions.enable_point_size_builtin = isRenderingPoints(pCreateInfo) || reflectData.pointMode;
|
shaderConfig.options.mslOptions.enable_point_size_builtin = isRenderingPoints(pCreateInfo) || reflectData.pointMode;
|
||||||
shaderConfig.options.mslOptions.enable_frag_depth_builtin = pixFmts->isDepthFormat(mtlDSFormat);
|
shaderConfig.options.mslOptions.enable_frag_depth_builtin = pixFmts->isDepthFormat(pixFmts->getMTLPixelFormat(pRendInfo->depthAttachmentFormat));
|
||||||
shaderConfig.options.mslOptions.enable_frag_stencil_ref_builtin = pixFmts->isStencilFormat(mtlDSFormat);
|
shaderConfig.options.mslOptions.enable_frag_stencil_ref_builtin = pixFmts->isStencilFormat(pixFmts->getMTLPixelFormat(pRendInfo->stencilAttachmentFormat));
|
||||||
shaderConfig.options.shouldFlipVertexY = mvkConfig().shaderConversionFlipVertexY;
|
shaderConfig.options.shouldFlipVertexY = mvkConfig().shaderConversionFlipVertexY;
|
||||||
shaderConfig.options.mslOptions.swizzle_texture_samples = _fullImageViewSwizzle && !getDevice()->_pMetalFeatures->nativeTextureSwizzle;
|
shaderConfig.options.mslOptions.swizzle_texture_samples = _fullImageViewSwizzle && !getDevice()->_pMetalFeatures->nativeTextureSwizzle;
|
||||||
shaderConfig.options.mslOptions.tess_domain_origin_lower_left = pTessDomainOriginState && pTessDomainOriginState->domainOrigin == VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT;
|
shaderConfig.options.mslOptions.tess_domain_origin_lower_left = pTessDomainOriginState && pTessDomainOriginState->domainOrigin == VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT;
|
||||||
|
@ -54,9 +54,6 @@ public:
|
|||||||
/** Returns whether this subpass has any color attachments. */
|
/** Returns whether this subpass has any color attachments. */
|
||||||
bool hasColorAttachments();
|
bool hasColorAttachments();
|
||||||
|
|
||||||
/** Returns whether this subpass has a depth/stencil attachment. */
|
|
||||||
bool hasDepthStencilAttachment() { return _depthStencilAttachment.attachment != VK_ATTACHMENT_UNUSED; }
|
|
||||||
|
|
||||||
/** Returns the number of color attachments, which may be zero for depth-only rendering. */
|
/** Returns the number of color attachments, which may be zero for depth-only rendering. */
|
||||||
uint32_t getColorAttachmentCount() { return uint32_t(_colorAttachments.size()); }
|
uint32_t getColorAttachmentCount() { return uint32_t(_colorAttachments.size()); }
|
||||||
|
|
||||||
@ -69,8 +66,17 @@ public:
|
|||||||
/** Returns whether or not the color attachment is used as both a color attachment and an input attachment. */
|
/** Returns whether or not the color attachment is used as both a color attachment and an input attachment. */
|
||||||
bool isColorAttachmentAlsoInputAttachment(uint32_t colorAttIdx);
|
bool isColorAttachmentAlsoInputAttachment(uint32_t colorAttIdx);
|
||||||
|
|
||||||
/** Returns the format of the depth/stencil attachment. */
|
/** Returns whether or not the depth attachment is being used. */
|
||||||
VkFormat getDepthStencilFormat();
|
bool isDepthAttachmentUsed() { return _depthAttachment.attachment != VK_ATTACHMENT_UNUSED; }
|
||||||
|
|
||||||
|
/** Returns whether or not the stencil attachment is being used. */
|
||||||
|
bool isStencilAttachmentUsed() { return _stencilAttachment.attachment != VK_ATTACHMENT_UNUSED; }
|
||||||
|
|
||||||
|
/** Return the depth attachment format. */
|
||||||
|
VkFormat getDepthFormat();
|
||||||
|
|
||||||
|
/** Return the stencil attachment format. */
|
||||||
|
VkFormat getStencilFormat();
|
||||||
|
|
||||||
/** Returns the Vulkan sample count of the attachments used in this subpass. */
|
/** Returns the Vulkan sample count of the attachments used in this subpass. */
|
||||||
VkSampleCountFlagBits getSampleCount();
|
VkSampleCountFlagBits getSampleCount();
|
||||||
@ -146,10 +152,11 @@ public:
|
|||||||
|
|
||||||
MVKRenderSubpass(MVKRenderPass* renderPass, const VkSubpassDescription2* pCreateInfo);
|
MVKRenderSubpass(MVKRenderPass* renderPass, const VkSubpassDescription2* pCreateInfo);
|
||||||
|
|
||||||
private:
|
MVKRenderSubpass(MVKRenderPass* renderPass, const VkRenderingInfo* pRenderingInfo);
|
||||||
|
|
||||||
|
protected:
|
||||||
friend class MVKRenderPass;
|
friend class MVKRenderPass;
|
||||||
friend class MVKRenderPassAttachment;
|
friend class MVKAttachmentDescription;
|
||||||
|
|
||||||
uint32_t getViewMaskGroupForMetalPass(uint32_t passIdx);
|
uint32_t getViewMaskGroupForMetalPass(uint32_t passIdx);
|
||||||
MVKMTLFmtCaps getRequiredFormatCapabilitiesForAttachmentAt(uint32_t rpAttIdx);
|
MVKMTLFmtCaps getRequiredFormatCapabilitiesForAttachmentAt(uint32_t rpAttIdx);
|
||||||
@ -162,8 +169,10 @@ private:
|
|||||||
MVKSmallVector<uint32_t, kMVKDefaultAttachmentCount> _preserveAttachments;
|
MVKSmallVector<uint32_t, kMVKDefaultAttachmentCount> _preserveAttachments;
|
||||||
MVKSmallVector<VkFormat, kMVKDefaultAttachmentCount> _colorAttachmentFormats;
|
MVKSmallVector<VkFormat, kMVKDefaultAttachmentCount> _colorAttachmentFormats;
|
||||||
VkPipelineRenderingCreateInfo _pipelineRenderingCreateInfo;
|
VkPipelineRenderingCreateInfo _pipelineRenderingCreateInfo;
|
||||||
VkAttachmentReference2 _depthStencilAttachment;
|
VkAttachmentReference2 _depthAttachment;
|
||||||
VkAttachmentReference2 _depthStencilResolveAttachment;
|
VkAttachmentReference2 _stencilAttachment;
|
||||||
|
VkAttachmentReference2 _depthResolveAttachment;
|
||||||
|
VkAttachmentReference2 _stencilResolveAttachment;
|
||||||
VkResolveModeFlagBits _depthResolveMode = VK_RESOLVE_MODE_NONE;
|
VkResolveModeFlagBits _depthResolveMode = VK_RESOLVE_MODE_NONE;
|
||||||
VkResolveModeFlagBits _stencilResolveMode = VK_RESOLVE_MODE_NONE;
|
VkResolveModeFlagBits _stencilResolveMode = VK_RESOLVE_MODE_NONE;
|
||||||
VkSampleCountFlagBits _defaultSampleCount = VK_SAMPLE_COUNT_1_BIT;
|
VkSampleCountFlagBits _defaultSampleCount = VK_SAMPLE_COUNT_1_BIT;
|
||||||
@ -172,10 +181,10 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark MVKRenderPassAttachment
|
#pragma mark MVKAttachmentDescription
|
||||||
|
|
||||||
/** Represents an attachment within a Vulkan render pass. */
|
/** Represents an attachment within a Vulkan render pass. */
|
||||||
class MVKRenderPassAttachment : public MVKBaseObject {
|
class MVKAttachmentDescription : public MVKBaseObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -218,13 +227,20 @@ public:
|
|||||||
/** Returns whether this attachment should be cleared in the subpass. */
|
/** Returns whether this attachment should be cleared in the subpass. */
|
||||||
bool shouldClearAttachment(MVKRenderSubpass* subpass, bool isStencil);
|
bool shouldClearAttachment(MVKRenderSubpass* subpass, bool isStencil);
|
||||||
|
|
||||||
MVKRenderPassAttachment(MVKRenderPass* renderPass,
|
MVKAttachmentDescription(MVKRenderPass* renderPass,
|
||||||
const VkAttachmentDescription* pCreateInfo);
|
const VkAttachmentDescription* pCreateInfo);
|
||||||
|
|
||||||
MVKRenderPassAttachment(MVKRenderPass* renderPass,
|
MVKAttachmentDescription(MVKRenderPass* renderPass,
|
||||||
const VkAttachmentDescription2* pCreateInfo);
|
const VkAttachmentDescription2* pCreateInfo);
|
||||||
|
|
||||||
|
MVKAttachmentDescription(MVKRenderPass* renderPass,
|
||||||
|
const VkRenderingAttachmentInfo* pAttInfo,
|
||||||
|
bool isResolveAttachment);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
friend class MVKRenderPass;
|
||||||
|
friend class MVKRenderSubpass;
|
||||||
|
|
||||||
bool isFirstUseOfAttachment(MVKRenderSubpass* subpass);
|
bool isFirstUseOfAttachment(MVKRenderSubpass* subpass);
|
||||||
bool isLastUseOfAttachment(MVKRenderSubpass* subpass);
|
bool isLastUseOfAttachment(MVKRenderSubpass* subpass);
|
||||||
MTLStoreAction getMTLStoreAction(MVKRenderSubpass* subpass,
|
MTLStoreAction getMTLStoreAction(MVKRenderSubpass* subpass,
|
||||||
@ -234,7 +250,7 @@ protected:
|
|||||||
bool canResolveFormat,
|
bool canResolveFormat,
|
||||||
bool isStencil,
|
bool isStencil,
|
||||||
bool storeOverride);
|
bool storeOverride);
|
||||||
void validateFormat();
|
void linkToSubpasses();
|
||||||
|
|
||||||
VkAttachmentDescription2 _info;
|
VkAttachmentDescription2 _info;
|
||||||
MVKRenderPass* _renderPass;
|
MVKRenderPass* _renderPass;
|
||||||
@ -282,13 +298,15 @@ public:
|
|||||||
|
|
||||||
MVKRenderPass(MVKDevice* device, const VkRenderPassCreateInfo2* pCreateInfo);
|
MVKRenderPass(MVKDevice* device, const VkRenderPassCreateInfo2* pCreateInfo);
|
||||||
|
|
||||||
|
MVKRenderPass(MVKDevice* device, const VkRenderingInfo* pRenderingInfo);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class MVKRenderSubpass;
|
friend class MVKRenderSubpass;
|
||||||
friend class MVKRenderPassAttachment;
|
friend class MVKAttachmentDescription;
|
||||||
|
|
||||||
void propagateDebugName() override {}
|
void propagateDebugName() override {}
|
||||||
|
|
||||||
MVKSmallVector<MVKRenderPassAttachment> _attachments;
|
MVKSmallVector<MVKAttachmentDescription> _attachments;
|
||||||
MVKSmallVector<MVKRenderSubpass> _subpasses;
|
MVKSmallVector<MVKRenderSubpass> _subpasses;
|
||||||
MVKSmallVector<VkSubpassDependency2> _subpassDependencies;
|
MVKSmallVector<VkSubpassDependency2> _subpassDependencies;
|
||||||
VkRenderingFlags _renderingFlags = 0;
|
VkRenderingFlags _renderingFlags = 0;
|
||||||
@ -297,21 +315,47 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark Support functions
|
#pragma mark MVKRenderingAttachmentIterator
|
||||||
|
|
||||||
/** Returns a MVKRenderPass object created from the rendering info. */
|
typedef std::function<void(const VkRenderingAttachmentInfo* pAttInfo,
|
||||||
MVKRenderPass* mvkCreateRenderPass(MVKDevice* device, const VkRenderingInfo* pRenderingInfo);
|
VkImageAspectFlagBits aspect,
|
||||||
|
bool isResolveAttachment)> MVKRenderingAttachmentInfoOperation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the usable attachments and their clear values from the rendering info,
|
* Iterates the attachments in a VkRenderingInfo, and processes an operation
|
||||||
* and sets them in the corresponding arrays, which must be large enough to hold
|
* on each attachment, once for the imageView, and once for the resolveImageView.
|
||||||
* all of the extracted values, and returns the number of attachments extracted.
|
*
|
||||||
* For consistency, the clear value of any resolve attachments are populated,
|
* Attachments are sequentially processed in this order:
|
||||||
* even though they are ignored.
|
* [color, color-resolve], ...,
|
||||||
|
* depth, depth-resolve,
|
||||||
|
* stencil, stencil-resolve
|
||||||
|
* skipping any attachments that do not have a VkImageView
|
||||||
*/
|
*/
|
||||||
uint32_t mvkGetAttachments(const VkRenderingInfo* pRenderingInfo,
|
class MVKRenderingAttachmentIterator : public MVKBaseObject {
|
||||||
MVKImageView* attachments[],
|
|
||||||
VkClearValue clearValues[]);
|
public:
|
||||||
|
|
||||||
|
MVKVulkanAPIObject* getVulkanAPIObject() override { return nullptr; }
|
||||||
|
|
||||||
|
/** Iterates the attachments with the specified lambda function. */
|
||||||
|
void iterate(MVKRenderingAttachmentInfoOperation attOperation);
|
||||||
|
|
||||||
|
MVKRenderingAttachmentIterator(const VkRenderingInfo* pRenderingInfo);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void handleAttachment(const VkRenderingAttachmentInfo* pAttInfo,
|
||||||
|
VkImageAspectFlagBits aspect,
|
||||||
|
MVKRenderingAttachmentInfoOperation attOperation);
|
||||||
|
const VkRenderingAttachmentInfo* getAttachmentInfo(const VkRenderingAttachmentInfo* pAtt,
|
||||||
|
const VkRenderingAttachmentInfo* pAltAtt,
|
||||||
|
bool isStencil);
|
||||||
|
|
||||||
|
VkRenderingInfo _renderingInfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark Support functions
|
||||||
|
|
||||||
/** Returns whether the view mask uses multiview. */
|
/** Returns whether the view mask uses multiview. */
|
||||||
static constexpr bool mvkIsMultiview(uint32_t viewMask) { return viewMask != 0; }
|
static constexpr bool mvkIsMultiview(uint32_t viewMask) { return viewMask != 0; }
|
||||||
@ -322,9 +366,6 @@ bool mvkIsColorAttachmentUsed(const VkPipelineRenderingCreateInfo* pRendInfo, ui
|
|||||||
/** Returns whether any attachment is being used. */
|
/** Returns whether any attachment is being used. */
|
||||||
bool mvkHasColorAttachments(const VkPipelineRenderingCreateInfo* pRendInfo);
|
bool mvkHasColorAttachments(const VkPipelineRenderingCreateInfo* pRendInfo);
|
||||||
|
|
||||||
/** Extracts and returns the combined depth/stencil format . */
|
|
||||||
VkFormat mvkGetDepthStencilFormat(const VkPipelineRenderingCreateInfo* pRendInfo);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the first view, number of views, and the portion of the mask
|
* Extracts the first view, number of views, and the portion of the mask
|
||||||
* to be rendered from the lowest clump of set bits in a view mask.
|
* to be rendered from the lowest clump of set bits in a view mask.
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -70,7 +70,7 @@ MVK_EXTENSION(KHR_image_format_list, KHR_IMAGE_FORMAT_LIST,
|
|||||||
MVK_EXTENSION(KHR_maintenance1, KHR_MAINTENANCE1, DEVICE, 10.11, 8.0)
|
MVK_EXTENSION(KHR_maintenance1, KHR_MAINTENANCE1, DEVICE, 10.11, 8.0)
|
||||||
MVK_EXTENSION(KHR_maintenance2, KHR_MAINTENANCE2, DEVICE, 10.11, 8.0)
|
MVK_EXTENSION(KHR_maintenance2, KHR_MAINTENANCE2, DEVICE, 10.11, 8.0)
|
||||||
MVK_EXTENSION(KHR_maintenance3, KHR_MAINTENANCE3, DEVICE, 10.11, 8.0)
|
MVK_EXTENSION(KHR_maintenance3, KHR_MAINTENANCE3, DEVICE, 10.11, 8.0)
|
||||||
MVK_EXTENSION(KHR_map_memory2, KHR_MAP_MEMORY_2, DEVICE, 10.11, 8.0)
|
MVK_EXTENSION(KHR_map_memory2, KHR_MAP_MEMORY_2, DEVICE, 10.11, 8.0)
|
||||||
MVK_EXTENSION(KHR_multiview, KHR_MULTIVIEW, DEVICE, 10.11, 8.0)
|
MVK_EXTENSION(KHR_multiview, KHR_MULTIVIEW, DEVICE, 10.11, 8.0)
|
||||||
MVK_EXTENSION(KHR_portability_subset, KHR_PORTABILITY_SUBSET, DEVICE, 10.11, 8.0)
|
MVK_EXTENSION(KHR_portability_subset, KHR_PORTABILITY_SUBSET, DEVICE, 10.11, 8.0)
|
||||||
MVK_EXTENSION(KHR_push_descriptor, KHR_PUSH_DESCRIPTOR, DEVICE, 10.11, 8.0)
|
MVK_EXTENSION(KHR_push_descriptor, KHR_PUSH_DESCRIPTOR, DEVICE, 10.11, 8.0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user