mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-02-27 10:04:56 +01:00
gpu2: preserve aspect ratio on flip
This commit is contained in:
parent
70c015683a
commit
8d1e4f59d1
|
|
@ -566,12 +566,22 @@ void amdgpu::flip(Cache::Tag &cacheTag, VkCommandBuffer commandBuffer,
|
|||
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
||||
}};
|
||||
|
||||
VkViewport viewPorts[1]{
|
||||
{
|
||||
.width = float(targetExtent.width),
|
||||
.height = float(targetExtent.height),
|
||||
},
|
||||
};
|
||||
VkViewport viewPort{};
|
||||
viewPort.width = targetExtent.width;
|
||||
viewPort.height = targetExtent.height;
|
||||
|
||||
float imageAspectRatio = float(imageExtent.width) / imageExtent.height;
|
||||
float targetAspectRatio = float(targetExtent.width) / targetExtent.height;
|
||||
|
||||
auto aspectDiff = imageAspectRatio / targetAspectRatio;
|
||||
|
||||
if (aspectDiff > 1) {
|
||||
viewPort.height = targetExtent.height / aspectDiff;
|
||||
viewPort.y = (targetExtent.height - viewPort.height) / 2;
|
||||
} else if (aspectDiff < 1) {
|
||||
viewPort.width = targetExtent.width * aspectDiff;
|
||||
viewPort.x = (targetExtent.width - viewPort.width) / 2;
|
||||
}
|
||||
|
||||
VkRect2D viewPortScissors[1]{{
|
||||
{},
|
||||
|
|
@ -597,7 +607,7 @@ void amdgpu::flip(Cache::Tag &cacheTag, VkCommandBuffer commandBuffer,
|
|||
cacheTag.getDevice()->flipPipeline.bind(cacheTag.getScheduler(), type,
|
||||
imageView.handle, sampler.handle);
|
||||
|
||||
vkCmdSetViewportWithCount(commandBuffer, 1, viewPorts);
|
||||
vkCmdSetViewportWithCount(commandBuffer, 1, &viewPort);
|
||||
vkCmdSetScissorWithCount(commandBuffer, 1, viewPortScissors);
|
||||
|
||||
vkCmdDraw(commandBuffer, 6, 1, 0, 0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue