diff --git a/include/vid_vulkan.h b/include/vid_vulkan.h index 2a1f8fd9a..556780fc0 100644 --- a/include/vid_vulkan.h +++ b/include/vid_vulkan.h @@ -99,6 +99,8 @@ typedef struct vulkan_ctx_s { struct qfv_tex_s *default_white; struct qfv_tex_s *default_magenta; + VkViewport viewport; + VkRect2D scissor; // projection and view matrices (model is push constant) vulkan_matrices_t matrices; diff --git a/libs/video/renderer/vulkan/instance.c b/libs/video/renderer/vulkan/instance.c index 35a478108..db6c6f502 100644 --- a/libs/video/renderer/vulkan/instance.c +++ b/libs/video/renderer/vulkan/instance.c @@ -208,7 +208,7 @@ QFV_CreateInstance (vulkan_ctx_t *ctx, VK_STRUCTURE_TYPE_APPLICATION_INFO, 0, appName, appVersion, PACKAGE_STRING, 0x000702ff, //FIXME version - VK_API_VERSION_1_0, + VK_API_VERSION_1_1, }; VkInstanceCreateInfo createInfo = { VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, 0, 0, diff --git a/libs/video/renderer/vulkan/vulkan_alias.c b/libs/video/renderer/vulkan/vulkan_alias.c index c2581e773..1e104fbef 100644 --- a/libs/video/renderer/vulkan/vulkan_alias.c +++ b/libs/video/renderer/vulkan/vulkan_alias.c @@ -201,10 +201,8 @@ alias_begin_subpass (QFV_AliasSubpass subpass, VkPipeline pipeline, dfunc->vkCmdPushDescriptorSetKHR (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, actx->layout, 0, 1, aframe->descriptors + 0); - VkViewport viewport = {0, 0, vid.width, vid.height, 0, 1}; - VkRect2D scissor = { {0, 0}, {vid.width, vid.height} }; - dfunc->vkCmdSetViewport (cmd, 0, 1, &viewport); - dfunc->vkCmdSetScissor (cmd, 0, 1, &scissor); + dfunc->vkCmdSetViewport (cmd, 0, 1, &ctx->viewport); + dfunc->vkCmdSetScissor (cmd, 0, 1, &ctx->scissor); //dfunc->vkUpdateDescriptorSets (device->dev, 2, aframe->descriptors, 0, 0); diff --git a/libs/video/renderer/vulkan/vulkan_bsp.c b/libs/video/renderer/vulkan/vulkan_bsp.c index 2c38cd65e..5e2d4dfd0 100644 --- a/libs/video/renderer/vulkan/vulkan_bsp.c +++ b/libs/video/renderer/vulkan/vulkan_bsp.c @@ -896,10 +896,8 @@ bsp_begin_subpass (QFV_BspSubpass subpass, VkPipeline pipeline, dfunc->vkCmdBindPipeline (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); - VkViewport viewport = {0, 0, vid.width, vid.height, 0, 1}; - VkRect2D scissor = { {0, 0}, {vid.width, vid.height} }; - dfunc->vkCmdSetViewport (cmd, 0, 1, &viewport); - dfunc->vkCmdSetScissor (cmd, 0, 1, &scissor); + dfunc->vkCmdSetViewport (cmd, 0, 1, &ctx->viewport); + dfunc->vkCmdSetScissor (cmd, 0, 1, &ctx->scissor); VkDeviceSize offsets[] = { 0 }; dfunc->vkCmdBindVertexBuffers (cmd, 0, 1, &bctx->vertex_buffer, offsets); diff --git a/libs/video/renderer/vulkan/vulkan_compose.c b/libs/video/renderer/vulkan/vulkan_compose.c index fc7316ede..66a9afc6d 100644 --- a/libs/video/renderer/vulkan/vulkan_compose.c +++ b/libs/video/renderer/vulkan/vulkan_compose.c @@ -94,10 +94,8 @@ Vulkan_Compose_Draw (vulkan_ctx_t *ctx) dfunc->vkCmdBindDescriptorSets (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, cctx->layout, 0, 1, sets, 0, 0); - VkViewport viewport = {0, 0, vid.width, vid.height, 0, 1}; - VkRect2D scissor = { {0, 0}, {vid.width, vid.height} }; - dfunc->vkCmdSetViewport (cmd, 0, 1, &viewport); - dfunc->vkCmdSetScissor (cmd, 0, 1, &scissor); + dfunc->vkCmdSetViewport (cmd, 0, 1, &ctx->viewport); + dfunc->vkCmdSetScissor (cmd, 0, 1, &ctx->scissor); VkDeviceSize offset = 0; dfunc->vkCmdBindVertexBuffers (cmd, 0, 1, &ctx->quad_buffer, &offset); diff --git a/libs/video/renderer/vulkan/vulkan_draw.c b/libs/video/renderer/vulkan/vulkan_draw.c index 879c79aba..f7aeabb97 100644 --- a/libs/video/renderer/vulkan/vulkan_draw.c +++ b/libs/video/renderer/vulkan/vulkan_draw.c @@ -732,10 +732,8 @@ Vulkan_FlushText (vulkan_ctx_t *ctx) dfunc->vkCmdBindPipeline (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, dctx->pipeline); - VkViewport viewport = {0, 0, vid.width, vid.height, 0, 1}; - VkRect2D scissor = { {0, 0}, {vid.width, vid.height} }; - dfunc->vkCmdSetViewport (cmd, 0, 1, &viewport); - dfunc->vkCmdSetScissor (cmd, 0, 1, &scissor); + dfunc->vkCmdSetViewport (cmd, 0, 1, &ctx->viewport); + dfunc->vkCmdSetScissor (cmd, 0, 1, &ctx->scissor); VkDeviceSize offsets[] = {dframe->vert_offset}; dfunc->vkCmdBindVertexBuffers (cmd, 0, 1, &dctx->vert_buffer, offsets); dfunc->vkCmdBindIndexBuffer (cmd, dctx->ind_buffer, 0, diff --git a/libs/video/renderer/vulkan/vulkan_lighting.c b/libs/video/renderer/vulkan/vulkan_lighting.c index 8563aafe1..9a4ab76a4 100644 --- a/libs/video/renderer/vulkan/vulkan_lighting.c +++ b/libs/video/renderer/vulkan/vulkan_lighting.c @@ -230,10 +230,8 @@ Vulkan_Lighting_Draw (vulkan_ctx_t *ctx) dfunc->vkCmdBindDescriptorSets (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, lctx->layout, 0, 2, sets, 0, 0); - VkViewport viewport = {0, 0, vid.width, vid.height, 0, 1}; - VkRect2D scissor = { {0, 0}, {vid.width, vid.height} }; - dfunc->vkCmdSetViewport (cmd, 0, 1, &viewport); - dfunc->vkCmdSetScissor (cmd, 0, 1, &scissor); + dfunc->vkCmdSetViewport (cmd, 0, 1, &ctx->viewport); + dfunc->vkCmdSetScissor (cmd, 0, 1, &ctx->scissor); VkDeviceSize offset = 0; dfunc->vkCmdBindVertexBuffers (cmd, 0, 1, &ctx->quad_buffer, &offset); diff --git a/libs/video/targets/vid_win_vulkan.c b/libs/video/targets/vid_win_vulkan.c index 027abed00..240fa2355 100644 --- a/libs/video/targets/vid_win_vulkan.c +++ b/libs/video/targets/vid_win_vulkan.c @@ -154,6 +154,12 @@ win_vulkan_create_surface (vulkan_ctx_t *ctx) .hinstance = pres->instance, .hwnd = 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} }; + if (pres->vkCreateWin32SurfaceKHR (inst, &createInfo, 0, &surface) != VK_SUCCESS) { return 0; diff --git a/libs/video/targets/vid_x11_vulkan.c b/libs/video/targets/vid_x11_vulkan.c index d64bed09f..a65cd65b0 100644 --- a/libs/video/targets/vid_x11_vulkan.c +++ b/libs/video/targets/vid_x11_vulkan.c @@ -194,6 +194,11 @@ 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} }; + if (pres->vkCreateXlibSurfaceKHR (inst, &createInfo, 0, &surface) != VK_SUCCESS) { return 0;