[vulkan] Move viewport and scissor into qfv_renderpass_t

This makes much more sense as they are intimately tied to the frame
buffer on which a render pass is working. Now, just the window width
and height are stored in vulkan_ctx_t. As a side benefit,
QFV_CreateSwapchain no long references viddef (now just palette and
conview in vulkan_draw.c to go).
This commit is contained in:
Bill Currie 2022-04-01 20:34:41 +09:00
parent 11e30583cf
commit 9892e571ce
11 changed files with 26 additions and 20 deletions

View file

@ -70,6 +70,8 @@ typedef struct qfv_renderpass_s {
VkDeviceMemory attachmentMemory;
qfv_framebufferset_t *framebuffers;
VkViewport viewport;
VkRect2D scissor;
qfv_renderframeset_t frames;

View file

@ -85,8 +85,9 @@ typedef struct vulkan_ctx_s {
struct qfv_tex_s *default_magenta;
struct qfv_tex_s *default_magenta_array;
VkViewport viewport;
VkRect2D scissor;
// size of window
int window_width;
int window_height;
#define EXPORTED_VULKAN_FUNCTION(fname) PFN_##fname fname;
#define GLOBAL_LEVEL_VULKAN_FUNCTION(fname) PFN_##fname fname;

View file

@ -62,7 +62,7 @@ QFV_CreateSwapchain (vulkan_ctx_t *ctx, VkSwapchainKHR old_swapchain)
numImages = surfCaps.maxImageCount;
}
VkExtent2D imageSize = {viddef.width, viddef.height};
VkExtent2D imageSize = {ctx->window_width, ctx->window_height};
if (surfCaps.currentExtent.width == ~0u) {
imageSize.width = bound (surfCaps.minImageExtent.width,
imageSize.width,

View file

@ -206,8 +206,8 @@ alias_begin_subpass (QFV_AliasSubpass subpass, VkPipeline pipeline,
};
dfunc->vkCmdBindDescriptorSets (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS,
actx->layout, 0, 1, sets, 0, 0);
dfunc->vkCmdSetViewport (cmd, 0, 1, &ctx->viewport);
dfunc->vkCmdSetScissor (cmd, 0, 1, &ctx->scissor);
dfunc->vkCmdSetViewport (cmd, 0, 1, &rFrame->renderpass->viewport);
dfunc->vkCmdSetScissor (cmd, 0, 1, &rFrame->renderpass->scissor);
//XXX glsl_Fog_GetColor (fog);
//XXX fog[3] = glsl_Fog_GetDensity () / 64.0;
@ -261,7 +261,7 @@ Vulkan_AliasDepthRange (qfv_renderframe_t *rFrame,
aliasctx_t *actx = ctx->alias_context;
aliasframe_t *aframe = &actx->frames.a[ctx->curFrame];
VkViewport viewport = ctx->viewport;
VkViewport viewport = rFrame->renderpass->viewport;
viewport.minDepth = minDepth;
viewport.maxDepth = maxDepth;

View file

@ -853,8 +853,8 @@ bsp_begin_subpass (QFV_BspSubpass subpass, VkPipeline pipeline,
dfunc->vkCmdBindPipeline (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS,
pipeline);
dfunc->vkCmdSetViewport (cmd, 0, 1, &ctx->viewport);
dfunc->vkCmdSetScissor (cmd, 0, 1, &ctx->scissor);
dfunc->vkCmdSetViewport (cmd, 0, 1, &rFrame->renderpass->viewport);
dfunc->vkCmdSetScissor (cmd, 0, 1, &rFrame->renderpass->scissor);
VkDeviceSize offsets[] = { 0 };
dfunc->vkCmdBindVertexBuffers (cmd, 0, 1, &bctx->vertex_buffer, offsets);

View file

@ -102,8 +102,8 @@ Vulkan_Compose_Draw (qfv_renderframe_t *rFrame)
dfunc->vkCmdBindDescriptorSets (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS,
cctx->layout, 0, 1, sets, 0, 0);
dfunc->vkCmdSetViewport (cmd, 0, 1, &ctx->viewport);
dfunc->vkCmdSetScissor (cmd, 0, 1, &ctx->scissor);
dfunc->vkCmdSetViewport (cmd, 0, 1, &rFrame->renderpass->viewport);
dfunc->vkCmdSetScissor (cmd, 0, 1, &rFrame->renderpass->scissor);
dfunc->vkCmdDraw (cmd, 3, 1, 0, 0);

View file

@ -840,8 +840,8 @@ Vulkan_FlushText (qfv_renderframe_t *rFrame)
dfunc->vkCmdBindPipeline (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS,
dctx->pipeline);
dfunc->vkCmdSetViewport (cmd, 0, 1, &ctx->viewport);
dfunc->vkCmdSetScissor (cmd, 0, 1, &ctx->scissor);
dfunc->vkCmdSetViewport (cmd, 0, 1, &rFrame->renderpass->viewport);
dfunc->vkCmdSetScissor (cmd, 0, 1, &rFrame->renderpass->scissor);
VkDeviceSize offsets[] = {dframe->vert_offset};
dfunc->vkCmdBindVertexBuffers (cmd, 0, 1, &dctx->vert_buffer, offsets);
dfunc->vkCmdBindIndexBuffer (cmd, dctx->ind_buffer, 0,

View file

@ -257,8 +257,8 @@ Vulkan_Lighting_Draw (qfv_renderframe_t *rFrame)
dfunc->vkCmdBindDescriptorSets (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS,
lctx->layout, 0, 3, sets, 0, 0);
dfunc->vkCmdSetViewport (cmd, 0, 1, &ctx->viewport);
dfunc->vkCmdSetScissor (cmd, 0, 1, &ctx->scissor);
dfunc->vkCmdSetViewport (cmd, 0, 1, &rFrame->renderpass->viewport);
dfunc->vkCmdSetScissor (cmd, 0, 1, &rFrame->renderpass->scissor);
dfunc->vkCmdDraw (cmd, 3, 1, 0, 0);

View file

@ -168,8 +168,8 @@ sprite_begin_subpass (QFV_SpriteSubpass subpass, VkPipeline pipeline,
};
dfunc->vkCmdBindDescriptorSets (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS,
sctx->layout, 0, 1, sets, 0, 0);
dfunc->vkCmdSetViewport (cmd, 0, 1, &ctx->viewport);
dfunc->vkCmdSetScissor (cmd, 0, 1, &ctx->scissor);
dfunc->vkCmdSetViewport (cmd, 0, 1, &rFrame->renderpass->viewport);
dfunc->vkCmdSetScissor (cmd, 0, 1, &rFrame->renderpass->scissor);
//XXX glsl_Fog_GetColor (fog);
//XXX fog[3] = glsl_Fog_GetDensity () / 64.0;

View file

@ -432,6 +432,11 @@ Vulkan_CreateRenderPass (vulkan_ctx_t *ctx)
name));
}
int width = ctx->window_width;
int height = ctx->window_height;
rp->viewport = (VkViewport) { 0, 0, width, height, 0, 1 };
rp->scissor = (VkRect2D) { {0, 0}, {width, height} };
DARRAY_INIT (&rp->frames, 4);
DARRAY_RESIZE (&rp->frames, ctx->frames.size);
for (size_t i = 0; i < rp->frames.size; i++) {

View file

@ -194,10 +194,8 @@ x11_vulkan_create_surface (vulkan_ctx_t *ctx)
.window = pres->window
};
int width = viddef.width;
int height = viddef.height;
ctx->viewport = (VkViewport) { 0, 0, width, height, 0, 1 };
ctx->scissor = (VkRect2D) { {0, 0}, {width, height} };
ctx->window_width = viddef.width;
ctx->window_height = viddef.height;
if (pres->vkCreateXlibSurfaceKHR (inst, &createInfo, 0, &surface)
!= VK_SUCCESS) {