RHI: Align setViewport behavior on Metal/Vulkan with OpenGL/D3D

Fixes to prevent crash on Metal/Vulkan when setViewport is called with no current graphics pipeline is set. This normalizes behavior across Metal/Vulkan/OpenGL/D3D.

Change-Id: I8057e01005cfe89ea02a8415f06eaee0f27865fc
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
bb10
Ben Fletcher 2022-10-16 10:40:29 -07:00
parent f50f6a456a
commit fda5061abd
2 changed files with 5 additions and 2 deletions

View File

@ -1656,7 +1656,8 @@ void QRhiMetal::setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport)
[cbD->d->currentRenderPassEncoder setViewport: vp];
if (!cbD->currentGraphicsPipeline->m_flags.testFlag(QRhiGraphicsPipeline::UsesScissor)) {
if (cbD->currentGraphicsPipeline
&& !cbD->currentGraphicsPipeline->m_flags.testFlag(QRhiGraphicsPipeline::UsesScissor)) {
MTLScissorRect s;
s.x = NSUInteger(x);
s.y = NSUInteger(y);

View File

@ -4946,7 +4946,9 @@ void QRhiVulkan::setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport
cmd.cmd = QVkCommandBuffer::Command::SetViewport;
}
if (!QRHI_RES(QVkGraphicsPipeline, cbD->currentGraphicsPipeline)->m_flags.testFlag(QRhiGraphicsPipeline::UsesScissor)) {
if (cbD->currentGraphicsPipeline
&& !QRHI_RES(QVkGraphicsPipeline, cbD->currentGraphicsPipeline)
->m_flags.testFlag(QRhiGraphicsPipeline::UsesScissor)) {
QVkCommandBuffer::Command &cmd(cbD->commands.get());
VkRect2D *s = &cmd.args.setScissor.scissor;
s->offset.x = int32_t(x);