Move the viewport clamping back to rendermanager to avoid a struct copy in the common case.

This commit is contained in:
Henrik Rydgård 2019-10-13 20:43:26 +02:00
parent 7c0470e061
commit 5adb61a5f2
2 changed files with 11 additions and 6 deletions

View File

@ -1018,11 +1018,8 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c
final_vp.y = rc.y;
final_vp.width = rc.w;
final_vp.height = rc.h;
// We can't allow values outside this range unless we use VK_EXT_depth_range_unrestricted.
// Sometimes state mapping produces 65536/65535 which is slightly outside.
// TODO: This should be fixed at the source.
final_vp.maxDepth = clamp_value(vp.maxDepth, 0.0f, 1.0f);
final_vp.minDepth = clamp_value(vp.minDepth, 0.0f, 1.0f);
final_vp.maxDepth = vp.maxDepth;
final_vp.minDepth = vp.minDepth;
vkCmdSetViewport(cmd, 0, 1, &final_vp);
}
break;

View File

@ -122,7 +122,15 @@ public:
_dbg_assert_(G3D, (int)vp.width >= 0);
_dbg_assert_(G3D, (int)vp.height >= 0);
VkRenderData data{ VKRRenderCommand::VIEWPORT };
data.viewport.vp = vp;
data.viewport.vp.x = vp.x;
data.viewport.vp.y = vp.y;
data.viewport.vp.width = vp.width;
data.viewport.vp.height = vp.height;
// We can't allow values outside this range unless we use VK_EXT_depth_range_unrestricted.
// Sometimes state mapping produces 65536/65535 which is slightly outside.
// TODO: This should be fixed at the source.
data.viewport.vp.minDepth = clamp_value(vp.minDepth, 0.0f, 1.0f);
data.viewport.vp.maxDepth = clamp_value(vp.maxDepth, 0.0f, 1.0f);
curRenderStep_->commands.push_back(data);
}