Set MTLRenderPassDescriptor renderTargetWidth & renderTargetHeight

only when layered rendering supported, to avoid GPU crashes on older devices.
This commit is contained in:
Bill Hollings 2019-04-03 14:58:57 -04:00
parent 07771c965c
commit cf13ab08a2
2 changed files with 9 additions and 5 deletions

View File

@ -39,7 +39,8 @@ Released TBD
- Fix wrong offset for `vkCmdFillBuffer()` on `VK_WHOLE_SIZE`.
- Fixed crash within `MVKPushConstantsCommandEncoderState` when accessing absent
graphics pipeline during a compute stage.
- Renderpass width/height clamped to the `renderArea` includes offset, not just the extent.
- Renderpass width/height clamped to the `renderArea` includes `offset`, not just `extent`,
and are set only when layered rendering is supported on device.
- Set options properly on a buffer view's `MTLTextureDescriptor`.
- Don't set `MTLSamplerDescriptor.compareFunction` on devices that don't support it.
- Debug build mode includes `dSYM` file for each `dylib` file.

View File

@ -246,13 +246,16 @@ void MVKCommandEncoder::beginMetalRenderPass() {
endCurrentMetalEncoding();
auto pMTLFeats = _device->_pMetalFeatures;
MTLRenderPassDescriptor* mtlRPDesc = [MTLRenderPassDescriptor renderPassDescriptor];
getSubpass()->populateMTLRenderPassDescriptor(mtlRPDesc, _framebuffer, _clearValues, _isRenderingEntireAttachment);
mtlRPDesc.visibilityResultBuffer = _occlusionQueryState.getVisibilityResultMTLBuffer();
mtlRPDesc.renderTargetArrayLengthMVK = pMTLFeats->layeredRendering ? _framebuffer->getLayerCount() : 0;
mtlRPDesc.renderTargetWidthMVK = min(_framebuffer->getExtent2D().width, _renderArea.offset.x + _renderArea.extent.width);
mtlRPDesc.renderTargetHeightMVK = min(_framebuffer->getExtent2D().height, _renderArea.offset.y + _renderArea.extent.height);
if (_device->_pMetalFeatures->layeredRendering) {
VkExtent2D fbExtent = _framebuffer->getExtent2D();
mtlRPDesc.renderTargetWidthMVK = min(_renderArea.offset.x + _renderArea.extent.width, fbExtent.width);
mtlRPDesc.renderTargetHeightMVK = min(_renderArea.offset.y + _renderArea.extent.height, fbExtent.height);
mtlRPDesc.renderTargetArrayLengthMVK = _framebuffer->getLayerCount();
}
_mtlRenderEncoder = [_mtlCmdBuffer renderCommandEncoderWithDescriptor: mtlRPDesc]; // not retained
_mtlRenderEncoder.label = getMTLRenderCommandEncoderName();