Merge pull request #1060 from cdavis5e/layered-clears
MVKCmdClearImage: Use layered rendering when possible.
This commit is contained in:
commit
6cfe8cdd36
@ -1345,6 +1345,26 @@ void MVKCmdClearImage<N>::encode(MVKCommandEncoder* cmdEncoder) {
|
||||
layerEnd = layerStart + layerCnt;
|
||||
}
|
||||
|
||||
// If we can do layered rendering, I can clear all the layers at once.
|
||||
if (cmdEncoder->getDevice()->_pMetalFeatures->layeredRendering &&
|
||||
(_image->getSampleCount() == VK_SAMPLE_COUNT_1_BIT || cmdEncoder->getDevice()->_pMetalFeatures->multisampleLayeredRendering)) {
|
||||
if (is3D) {
|
||||
mtlRPCADesc.depthPlane = layerStart;
|
||||
mtlRPDADesc.depthPlane = layerStart;
|
||||
mtlRPSADesc.depthPlane = layerStart;
|
||||
} else {
|
||||
mtlRPCADesc.slice = layerStart;
|
||||
mtlRPDADesc.slice = layerStart;
|
||||
mtlRPSADesc.slice = layerStart;
|
||||
}
|
||||
mtlRPDesc.renderTargetArrayLength = (layerCnt == VK_REMAINING_ARRAY_LAYERS
|
||||
? (_image->getLayerCount() - layerStart)
|
||||
: layerCnt);
|
||||
|
||||
id<MTLRenderCommandEncoder> mtlRendEnc = [cmdEncoder->_mtlCmdBuffer renderCommandEncoderWithDescriptor: mtlRPDesc];
|
||||
setLabelIfNotNil(mtlRendEnc, mtlRendEncName);
|
||||
[mtlRendEnc endEncoding];
|
||||
} else {
|
||||
for (uint32_t layer = layerStart; layer < layerEnd; layer++) {
|
||||
if (is3D) {
|
||||
mtlRPCADesc.depthPlane = layer;
|
||||
@ -1362,6 +1382,7 @@ void MVKCmdClearImage<N>::encode(MVKCommandEncoder* cmdEncoder) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template class MVKCmdClearImage<1>;
|
||||
|
Loading…
x
Reference in New Issue
Block a user