Commit b6eb196a authored by Laszlo Agocs's avatar Laszlo Agocs
Browse files

Fix off by one in viewport/scissor

parent 81676270
......@@ -397,8 +397,7 @@ void QRhiD3D11::setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport)
cmd.cmd = QD3D11CommandBuffer::Command::Viewport;
cmd.args.viewport.x = viewport.r.x();
// d3d expects top-left, QRhiViewport is bottom-left
cmd.args.viewport.y = cbD->currentTarget->sizeInPixels().height() - (viewport.r.y() + viewport.r.w() - 1);
cmd.args.viewport.y = viewport.r.y();
cmd.args.viewport.y = cbD->currentTarget->sizeInPixels().height() - (viewport.r.y() + viewport.r.w());
cmd.args.viewport.w = viewport.r.z();
cmd.args.viewport.h = viewport.r.w();
cmd.args.viewport.d0 = viewport.minDepth;
......@@ -415,7 +414,7 @@ void QRhiD3D11::setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor)
cmd.cmd = QD3D11CommandBuffer::Command::Scissor;
cmd.args.scissor.x = scissor.r.x();
// d3d expects top-left, QRhiScissor is bottom-left
cmd.args.scissor.y = cbD->currentTarget->sizeInPixels().height() - (scissor.r.y() + scissor.r.w() - 1);
cmd.args.scissor.y = cbD->currentTarget->sizeInPixels().height() - (scissor.r.y() + scissor.r.w());
cmd.args.scissor.w = scissor.r.z();
cmd.args.scissor.h = scissor.r.w();
cbD->commands.append(cmd);
......
......@@ -485,7 +485,7 @@ static inline MTLViewport toMetalViewport(const QRhiViewport &viewport, const QS
// x,y is top-left in MTLViewport but bottom-left in QRhiViewport
MTLViewport vp;
vp.originX = viewport.r.x();
vp.originY = outputSize.height() - (viewport.r.y() + viewport.r.w() - 1);
vp.originY = outputSize.height() - (viewport.r.y() + viewport.r.w());
vp.width = viewport.r.z();
vp.height = viewport.r.w();
vp.znear = viewport.minDepth;
......@@ -508,7 +508,7 @@ static inline MTLScissorRect toMetalScissor(const QRhiScissor &scissor, const QS
// x,y is top-left in MTLScissorRect but bottom-left in QRhiScissor
MTLScissorRect s;
s.x = scissor.r.x();
s.y = outputSize.height() - (scissor.r.y() + scissor.r.w() - 1);
s.y = outputSize.height() - (scissor.r.y() + scissor.r.w());
s.width = scissor.r.z();
s.height = scissor.r.w();
return s;
......
......@@ -2745,7 +2745,7 @@ static inline VkViewport toVkViewport(const QRhiViewport &viewport, const QSize
// x,y is top-left in VkViewport but bottom-left in QRhiViewport
VkViewport vp;
vp.x = viewport.r.x();
vp.y = outputSize.height() - (viewport.r.y() + viewport.r.w() - 1);
vp.y = outputSize.height() - (viewport.r.y() + viewport.r.w());
vp.width = viewport.r.z();
vp.height = viewport.r.w();
vp.minDepth = viewport.minDepth;
......@@ -2758,7 +2758,7 @@ static inline VkRect2D toVkScissor(const QRhiScissor &scissor, const QSize &outp
// x,y is top-left in VkRect2D but bottom-left in QRhiScissor
VkRect2D s;
s.offset.x = scissor.r.x();
s.offset.y = outputSize.height() - (scissor.r.y() + scissor.r.w() - 1);
s.offset.y = outputSize.height() - (scissor.r.y() + scissor.r.w());
s.extent.width = scissor.r.z();
s.extent.height = scissor.r.w();
return s;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment