From 759e3455c3de8e985ee5b4916427d808eb0472d3 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 23 Jan 2023 13:03:07 +0900 Subject: [PATCH] [vulkan] Hook up fisheye rendering in the output pass It turns out that my laptop doesn't do multiview properly (or I've misconfigured something, later), but the biggest issue I had on my desktop seems to be that I had the push constants wrong: fov in aspect, time in fov, and I had degrees instead of radians (half angle) anyway. --- libs/video/renderer/vulkan/vulkan_output.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/libs/video/renderer/vulkan/vulkan_output.c b/libs/video/renderer/vulkan/vulkan_output.c index f344865d9..3e19f9a77 100644 --- a/libs/video/renderer/vulkan/vulkan_output.c +++ b/libs/video/renderer/vulkan/vulkan_output.c @@ -165,8 +165,15 @@ process_input (qfv_renderframe_t *rFrame) QFV_duCmdBeginLabel (device, cmd, "output:output"); - __auto_type pipeline = r_dowarp ? octx->waterwarp : octx->output; - __auto_type layout = r_dowarp ? octx->warp_layout : octx->output_layout; + __auto_type pipeline = octx->output; + __auto_type layout = octx->output_layout; + if (scr_fisheye) { + pipeline = octx->fisheye; + layout = octx->fish_layout; + } else if (r_dowarp) { + pipeline = octx->waterwarp; + layout = octx->warp_layout; + } dfunc->vkCmdBindPipeline (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); dfunc->vkCmdSetViewport (cmd, 0, 1, &rFrame->renderpass->viewport); dfunc->vkCmdSetScissor (cmd, 0, 1, &rFrame->renderpass->scissor); @@ -183,6 +190,17 @@ process_input (qfv_renderframe_t *rFrame) { VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof (float), &time }, }; QFV_PushConstants (device, cmd, layout, 1, push_constants); + } else if (scr_fisheye) { + float width = r_refdef.vrect.width; + float height = r_refdef.vrect.height; + + float ffov = scr_ffov * M_PI / 360; + float aspect = height / width; + qfv_push_constants_t push_constants[] = { + { VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof (float), &ffov }, + { VK_SHADER_STAGE_FRAGMENT_BIT, 4, sizeof (float), &aspect }, + }; + QFV_PushConstants (device, cmd, layout, 2, push_constants); } dfunc->vkCmdDraw (cmd, 3, 1, 0, 0);