2019-07-06 05:42:53 +00:00
|
|
|
/*
|
|
|
|
vid_render_vulkan.c
|
|
|
|
|
|
|
|
Vulkan version of the renderer
|
|
|
|
|
|
|
|
Copyright (C) 2019 Bill Currie <bill@taniwha.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2020-02-16 13:45:27 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2020-02-17 11:29:35 +00:00
|
|
|
#include "QF/darray.h"
|
2019-07-09 07:33:44 +00:00
|
|
|
#include "QF/sys.h"
|
|
|
|
|
2019-07-06 05:42:53 +00:00
|
|
|
#include "QF/plugin/general.h"
|
|
|
|
#include "QF/plugin/vid_render.h"
|
|
|
|
|
2021-01-25 15:55:45 +00:00
|
|
|
#include "QF/Vulkan/qf_alias.h"
|
2021-01-19 16:25:54 +00:00
|
|
|
#include "QF/Vulkan/qf_bsp.h"
|
2021-02-24 10:58:31 +00:00
|
|
|
#include "QF/Vulkan/qf_compose.h"
|
2021-01-10 06:52:27 +00:00
|
|
|
#include "QF/Vulkan/qf_draw.h"
|
2021-02-24 10:58:31 +00:00
|
|
|
#include "QF/Vulkan/qf_lighting.h"
|
2021-01-19 16:25:54 +00:00
|
|
|
#include "QF/Vulkan/qf_lightmap.h"
|
|
|
|
#include "QF/Vulkan/qf_main.h"
|
2021-01-18 03:46:06 +00:00
|
|
|
#include "QF/Vulkan/qf_particles.h"
|
2021-01-20 06:11:50 +00:00
|
|
|
#include "QF/Vulkan/qf_texture.h"
|
2019-07-06 05:42:53 +00:00
|
|
|
#include "QF/Vulkan/qf_vid.h"
|
2020-02-16 13:45:27 +00:00
|
|
|
#include "QF/Vulkan/command.h"
|
2019-07-12 04:15:25 +00:00
|
|
|
#include "QF/Vulkan/device.h"
|
2020-02-17 11:29:35 +00:00
|
|
|
#include "QF/Vulkan/image.h"
|
2019-07-12 04:15:25 +00:00
|
|
|
#include "QF/Vulkan/instance.h"
|
2021-01-16 12:24:42 +00:00
|
|
|
#include "QF/Vulkan/renderpass.h"
|
2019-07-12 04:15:25 +00:00
|
|
|
#include "QF/Vulkan/swapchain.h"
|
2019-07-06 05:42:53 +00:00
|
|
|
|
|
|
|
#include "mod_internal.h"
|
|
|
|
#include "r_internal.h"
|
2019-07-08 04:40:29 +00:00
|
|
|
#include "vid_internal.h"
|
2019-07-08 16:00:47 +00:00
|
|
|
#include "vid_vulkan.h"
|
2019-07-06 05:42:53 +00:00
|
|
|
|
2019-07-09 02:54:23 +00:00
|
|
|
static vulkan_ctx_t *vulkan_ctx;
|
2019-07-08 16:00:47 +00:00
|
|
|
|
2021-01-18 03:46:06 +00:00
|
|
|
static tex_t *
|
|
|
|
vulkan_SCR_CaptureBGR (void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static tex_t *
|
|
|
|
vulkan_SCR_ScreenShot (int width, int height)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Fog_Update (float density, float red, float green, float blue,
|
|
|
|
float time)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Fog_ParseWorldspawn (struct plitem_s *worldspawn)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-07-10 04:16:46 +00:00
|
|
|
static void
|
|
|
|
vulkan_R_Init (void)
|
|
|
|
{
|
2021-01-10 16:24:15 +00:00
|
|
|
Vulkan_CreateStagingBuffers (vulkan_ctx);
|
2021-01-12 02:26:20 +00:00
|
|
|
Vulkan_CreateMatrices (vulkan_ctx);
|
2020-02-16 13:45:27 +00:00
|
|
|
Vulkan_CreateSwapchain (vulkan_ctx);
|
2021-02-14 02:35:06 +00:00
|
|
|
Vulkan_CreateFrames (vulkan_ctx);
|
2021-01-16 12:24:42 +00:00
|
|
|
Vulkan_CreateRenderPass (vulkan_ctx);
|
2021-02-14 02:35:06 +00:00
|
|
|
Vulkan_CreateFramebuffers (vulkan_ctx);
|
2020-12-23 16:36:17 +00:00
|
|
|
// FIXME this should be staged so screen updates can begin while pipelines
|
|
|
|
// are being built
|
2021-01-10 06:52:27 +00:00
|
|
|
vulkan_ctx->pipeline = Vulkan_CreatePipeline (vulkan_ctx, "pipeline");
|
2021-01-23 06:40:31 +00:00
|
|
|
Vulkan_Texture_Init (vulkan_ctx);
|
2021-01-26 11:58:24 +00:00
|
|
|
Vulkan_Alias_Init (vulkan_ctx);
|
2021-01-19 16:25:54 +00:00
|
|
|
Vulkan_Bsp_Init (vulkan_ctx);
|
2021-01-10 06:52:27 +00:00
|
|
|
Vulkan_Draw_Init (vulkan_ctx);
|
2021-01-18 03:46:06 +00:00
|
|
|
Vulkan_Particles_Init (vulkan_ctx);
|
2021-02-24 10:58:31 +00:00
|
|
|
Vulkan_Lighting_Init (vulkan_ctx);
|
|
|
|
Vulkan_Compose_Init (vulkan_ctx);
|
2020-02-18 08:18:37 +00:00
|
|
|
|
2020-02-16 13:45:27 +00:00
|
|
|
Sys_Printf ("R_Init %p %d", vulkan_ctx->swapchain->swapchain,
|
|
|
|
vulkan_ctx->swapchain->numImages);
|
|
|
|
for (int32_t i = 0; i < vulkan_ctx->swapchain->numImages; i++) {
|
2020-02-17 11:29:35 +00:00
|
|
|
Sys_Printf (" %p", vulkan_ctx->swapchain->images->a[i]);
|
2020-02-16 13:45:27 +00:00
|
|
|
}
|
|
|
|
Sys_Printf ("\n");
|
2021-01-12 02:27:41 +00:00
|
|
|
|
|
|
|
SCR_Init ();
|
2020-02-16 13:45:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-01-12 02:27:41 +00:00
|
|
|
vulkan_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
2020-02-16 13:45:27 +00:00
|
|
|
{
|
2021-02-14 02:35:06 +00:00
|
|
|
const VkSubpassContents subpassContents
|
|
|
|
= VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS;
|
2020-02-16 15:50:39 +00:00
|
|
|
uint32_t imageIndex = 0;
|
2020-02-17 11:29:35 +00:00
|
|
|
qfv_device_t *device = vulkan_ctx->device;
|
|
|
|
qfv_devfuncs_t *dfunc = device->funcs;
|
|
|
|
VkDevice dev = device->dev;
|
2020-02-16 15:50:39 +00:00
|
|
|
qfv_queue_t *queue = &vulkan_ctx->device->queue;
|
|
|
|
|
2021-02-05 01:22:32 +00:00
|
|
|
__auto_type frame = &vulkan_ctx->frames.a[vulkan_ctx->curFrame];
|
2020-02-18 08:18:37 +00:00
|
|
|
|
2021-02-05 01:22:32 +00:00
|
|
|
dfunc->vkWaitForFences (dev, 1, &frame->fence, VK_TRUE, 2000000000);
|
2020-02-16 15:50:39 +00:00
|
|
|
QFV_AcquireNextImage (vulkan_ctx->swapchain,
|
2021-02-05 01:22:32 +00:00
|
|
|
frame->imageAvailableSemaphore,
|
2020-02-18 08:18:37 +00:00
|
|
|
0, &imageIndex);
|
2021-02-14 02:35:06 +00:00
|
|
|
vulkan_ctx->swapImageIndex = imageIndex;
|
2020-02-16 15:50:39 +00:00
|
|
|
|
2021-02-14 02:35:06 +00:00
|
|
|
frame->framebuffer = vulkan_ctx->framebuffers->a[imageIndex];
|
2021-01-16 12:24:42 +00:00
|
|
|
|
2021-01-19 16:25:54 +00:00
|
|
|
scr_3dfunc ();
|
|
|
|
while (*scr_funcs) {
|
|
|
|
(*scr_funcs) ();
|
|
|
|
scr_funcs++;
|
|
|
|
}
|
|
|
|
|
2021-01-12 02:27:41 +00:00
|
|
|
Vulkan_FlushText (vulkan_ctx);
|
|
|
|
|
2021-02-24 10:58:31 +00:00
|
|
|
Vulkan_Lighting_Draw (vulkan_ctx);
|
|
|
|
Vulkan_Compose_Draw (vulkan_ctx);
|
|
|
|
|
2021-01-12 02:27:41 +00:00
|
|
|
VkCommandBufferBeginInfo beginInfo
|
|
|
|
= { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO };
|
|
|
|
VkRenderPassBeginInfo renderPassInfo = {
|
|
|
|
VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, 0,
|
2021-02-14 02:35:06 +00:00
|
|
|
vulkan_ctx->renderpass, 0,
|
|
|
|
{ {0, 0}, vulkan_ctx->swapchain->extent },
|
2021-02-23 05:37:48 +00:00
|
|
|
vulkan_ctx->clearValues->size, vulkan_ctx->clearValues->a
|
2021-01-12 02:27:41 +00:00
|
|
|
};
|
|
|
|
|
2021-02-05 01:22:32 +00:00
|
|
|
dfunc->vkBeginCommandBuffer (frame->cmdBuffer, &beginInfo);
|
|
|
|
renderPassInfo.framebuffer = frame->framebuffer;
|
|
|
|
dfunc->vkCmdBeginRenderPass (frame->cmdBuffer, &renderPassInfo,
|
2021-02-14 02:35:06 +00:00
|
|
|
subpassContents);
|
|
|
|
|
|
|
|
for (int i = 0; i < frame->cmdSetCount; i++) {
|
2021-02-23 05:37:48 +00:00
|
|
|
if (frame->cmdSets[i].size) {
|
|
|
|
dfunc->vkCmdExecuteCommands (frame->cmdBuffer,
|
|
|
|
frame->cmdSets[i].size,
|
|
|
|
frame->cmdSets[i].a);
|
|
|
|
}
|
2021-02-14 02:35:06 +00:00
|
|
|
// reset for next time around
|
|
|
|
frame->cmdSets[i].size = 0;
|
2021-01-12 02:27:41 +00:00
|
|
|
|
2021-02-23 05:37:48 +00:00
|
|
|
if (i < frame->cmdSetCount - 1) {
|
2021-02-14 02:35:06 +00:00
|
|
|
dfunc->vkCmdNextSubpass (frame->cmdBuffer, subpassContents);
|
|
|
|
}
|
|
|
|
}
|
2021-01-12 02:27:41 +00:00
|
|
|
|
2021-02-05 01:22:32 +00:00
|
|
|
dfunc->vkCmdEndRenderPass (frame->cmdBuffer);
|
|
|
|
dfunc->vkEndCommandBuffer (frame->cmdBuffer);
|
2021-01-12 02:27:41 +00:00
|
|
|
|
2020-02-17 11:29:35 +00:00
|
|
|
VkPipelineStageFlags waitStage
|
|
|
|
= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
2020-02-16 15:50:39 +00:00
|
|
|
VkSubmitInfo submitInfo = {
|
|
|
|
VK_STRUCTURE_TYPE_SUBMIT_INFO, 0,
|
2021-02-05 01:22:32 +00:00
|
|
|
1, &frame->imageAvailableSemaphore, &waitStage,
|
|
|
|
1, &frame->cmdBuffer,
|
|
|
|
1, &frame->renderDoneSemaphore,
|
2020-02-16 15:50:39 +00:00
|
|
|
};
|
2021-02-05 01:22:32 +00:00
|
|
|
dfunc->vkResetFences (dev, 1, &frame->fence);
|
|
|
|
dfunc->vkQueueSubmit (queue->queue, 1, &submitInfo, frame->fence);
|
2020-02-16 15:50:39 +00:00
|
|
|
|
|
|
|
VkPresentInfoKHR presentInfo = {
|
|
|
|
VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, 0,
|
2021-02-05 01:22:32 +00:00
|
|
|
1, &frame->renderDoneSemaphore,
|
2020-02-16 15:50:39 +00:00
|
|
|
1, &vulkan_ctx->swapchain->swapchain, &imageIndex,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
dfunc->vkQueuePresentKHR (queue->queue, &presentInfo);
|
|
|
|
|
2020-02-18 08:18:37 +00:00
|
|
|
vulkan_ctx->curFrame++;
|
2021-02-05 01:22:32 +00:00
|
|
|
vulkan_ctx->curFrame %= vulkan_ctx->frames.size;
|
2020-02-16 13:45:27 +00:00
|
|
|
}
|
|
|
|
|
2021-01-18 03:46:06 +00:00
|
|
|
static void
|
|
|
|
vulkan_R_ClearState (void)
|
|
|
|
{
|
2021-01-19 16:25:54 +00:00
|
|
|
R_ClearEfrags ();
|
|
|
|
R_ClearDlights ();
|
|
|
|
Vulkan_ClearParticles (vulkan_ctx);
|
2021-01-18 03:46:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_R_LoadSkys (const char *skyname)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_R_NewMap (model_t *worldmodel, model_t **models, int num_models)
|
|
|
|
{
|
2021-01-19 16:25:54 +00:00
|
|
|
Vulkan_NewMap (worldmodel, models, num_models, vulkan_ctx);
|
2021-01-18 03:46:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_R_LineGraph (int x, int y, int *h_vals, int count)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_R_RenderView (void)
|
|
|
|
{
|
2021-01-19 16:25:54 +00:00
|
|
|
Vulkan_RenderView (vulkan_ctx);
|
2021-01-18 03:46:06 +00:00
|
|
|
}
|
|
|
|
|
2021-01-10 06:52:27 +00:00
|
|
|
static void
|
|
|
|
vulkan_Draw_Character (int x, int y, unsigned ch)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_Character (x, y, ch, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Draw_String (int x, int y, const char *str)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_String (x, y, str, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Draw_nString (int x, int y, const char *str, int count)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_nString (x, y, str, count, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Draw_AltString (int x, int y, const char *str)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_AltString (x, y, str, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Draw_ConsoleBackground (int lines, byte alpha)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_ConsoleBackground (lines, alpha, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Draw_Crosshair (void)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_Crosshair (vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Draw_CrosshairAt (int ch, int x, int y)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_CrosshairAt (ch, x, y, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Draw_TileClear (int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_TileClear (x, y, w, h, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Draw_Fill (int x, int y, int w, int h, int c)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_Fill (x, y, w, h, c, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Draw_TextBox (int x, int y, int width, int lines, byte alpha)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_TextBox (x, y, width, lines, alpha, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Draw_FadeScreen (void)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_FadeScreen (vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Draw_BlendScreen (quat_t color)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_BlendScreen (color, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
2020-02-16 13:45:27 +00:00
|
|
|
static qpic_t *
|
|
|
|
vulkan_Draw_CachePic (const char *path, qboolean alpha)
|
|
|
|
{
|
2021-01-10 06:52:27 +00:00
|
|
|
return Vulkan_Draw_CachePic (path, alpha, vulkan_ctx);
|
2020-02-16 13:45:27 +00:00
|
|
|
}
|
|
|
|
|
2021-01-10 06:52:27 +00:00
|
|
|
static void
|
|
|
|
vulkan_Draw_UncachePic (const char *path)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_UncachePic (path, vulkan_ctx);
|
|
|
|
}
|
2020-02-16 13:45:27 +00:00
|
|
|
|
|
|
|
static qpic_t *
|
|
|
|
vulkan_Draw_MakePic (int width, int height, const byte *data)
|
|
|
|
{
|
2021-01-10 06:52:27 +00:00
|
|
|
return Vulkan_Draw_MakePic (width, height, data, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Draw_DestroyPic (qpic_t *pic)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_DestroyPic (pic, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static qpic_t *
|
|
|
|
vulkan_Draw_PicFromWad (const char *name)
|
|
|
|
{
|
|
|
|
return Vulkan_Draw_PicFromWad (name, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Draw_Pic (int x, int y, qpic_t *pic)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_Pic (x, y, pic, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Draw_Picf (float x, float y, qpic_t *pic)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_Picf (x, y, pic, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height)
|
|
|
|
{
|
|
|
|
Vulkan_Draw_SubPic (x, y, pic, srcx, srcy, width, height, vulkan_ctx);
|
2019-07-10 04:16:46 +00:00
|
|
|
}
|
|
|
|
|
2021-01-12 02:26:20 +00:00
|
|
|
static void
|
|
|
|
vulkan_R_ViewChanged (float aspect)
|
|
|
|
{
|
|
|
|
Vulkan_CalcProjectionMatrices (vulkan_ctx, aspect);
|
|
|
|
}
|
|
|
|
|
2021-01-18 03:46:06 +00:00
|
|
|
static void
|
|
|
|
vulkan_R_ClearParticles (void)
|
|
|
|
{
|
2021-01-19 16:25:54 +00:00
|
|
|
Vulkan_ClearParticles (vulkan_ctx);
|
2021-01-18 03:46:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_R_InitParticles (void)
|
|
|
|
{
|
2021-01-19 16:25:54 +00:00
|
|
|
Vulkan_InitParticles (vulkan_ctx);
|
2021-01-18 03:46:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_SCR_ScreenShot_f (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_r_easter_eggs_f (struct cvar_s *var)
|
|
|
|
{
|
|
|
|
Vulkan_r_easter_eggs_f (var, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_r_particles_style_f (struct cvar_s *var)
|
|
|
|
{
|
|
|
|
Vulkan_r_particles_style_f (var, vulkan_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-02-01 05:39:00 +00:00
|
|
|
vulkan_Mod_LoadLighting (model_t *mod, bsp_t *bsp)
|
2021-01-18 03:46:06 +00:00
|
|
|
{
|
2021-02-01 05:39:00 +00:00
|
|
|
Vulkan_Mod_LoadLighting (mod, bsp, vulkan_ctx);
|
2021-01-18 03:46:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-02-01 05:39:00 +00:00
|
|
|
vulkan_Mod_SubdivideSurface (model_t *mod, msurface_t *fa)
|
2021-01-18 03:46:06 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-02-01 05:39:00 +00:00
|
|
|
vulkan_Mod_ProcessTexture (model_t *mod, texture_t *tx)
|
2021-01-18 03:46:06 +00:00
|
|
|
{
|
2021-02-01 05:39:00 +00:00
|
|
|
Vulkan_Mod_ProcessTexture (mod, tx, vulkan_ctx);
|
2021-01-18 03:46:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-02-01 12:11:45 +00:00
|
|
|
vulkan_Mod_MakeAliasModelDisplayLists (mod_alias_ctx_t *alias_ctx,
|
2021-01-18 03:46:06 +00:00
|
|
|
void *_m, int _s, int extra)
|
|
|
|
{
|
2021-02-01 12:11:45 +00:00
|
|
|
Vulkan_Mod_MakeAliasModelDisplayLists (alias_ctx, _m, _s, extra,
|
|
|
|
vulkan_ctx);
|
2021-01-18 03:46:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
2021-02-01 12:11:45 +00:00
|
|
|
vulkan_Mod_LoadSkin (mod_alias_ctx_t *alias_ctx, byte *skin, int skinsize,
|
|
|
|
int snum, int gnum, qboolean group,
|
|
|
|
maliasskindesc_t *skindesc)
|
2021-01-18 03:46:06 +00:00
|
|
|
{
|
2021-02-01 12:11:45 +00:00
|
|
|
return Vulkan_Mod_LoadSkin (alias_ctx, skin, skinsize, snum, gnum, group,
|
2021-02-01 05:39:00 +00:00
|
|
|
skindesc, vulkan_ctx);
|
2021-01-18 03:46:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-02-01 12:11:45 +00:00
|
|
|
vulkan_Mod_FinalizeAliasModel (mod_alias_ctx_t *alias_ctx)
|
2021-01-18 03:46:06 +00:00
|
|
|
{
|
2021-02-01 12:11:45 +00:00
|
|
|
Vulkan_Mod_FinalizeAliasModel (alias_ctx, vulkan_ctx);
|
2021-01-18 03:46:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-02-01 12:11:45 +00:00
|
|
|
vulkan_Mod_LoadExternalSkins (mod_alias_ctx_t *alias_ctx)
|
2021-01-18 03:46:06 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Mod_IQMFinish (model_t *mod)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-02-01 05:39:00 +00:00
|
|
|
vulkan_Mod_SpriteLoadTexture (model_t *mod, mspriteframe_t *pspriteframe,
|
|
|
|
int framenum)
|
2021-01-18 03:46:06 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Skin_SetupSkin (struct skin_s *skin, int cmap)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Skin_ProcessTranslation (int cmap, const byte *translation)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_Skin_InitTranslations (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-07-06 05:42:53 +00:00
|
|
|
static vid_model_funcs_t model_funcs = {
|
2021-01-20 06:11:50 +00:00
|
|
|
sizeof (vulktex_t) + 2 * sizeof (qfv_tex_t),
|
2021-01-18 03:46:06 +00:00
|
|
|
vulkan_Mod_LoadLighting,
|
|
|
|
vulkan_Mod_SubdivideSurface,
|
|
|
|
vulkan_Mod_ProcessTexture,
|
2019-07-06 05:42:53 +00:00
|
|
|
|
|
|
|
Mod_LoadIQM,
|
|
|
|
Mod_LoadAliasModel,
|
|
|
|
Mod_LoadSpriteModel,
|
|
|
|
|
2021-01-18 03:46:06 +00:00
|
|
|
vulkan_Mod_MakeAliasModelDisplayLists,
|
|
|
|
vulkan_Mod_LoadSkin,
|
|
|
|
vulkan_Mod_FinalizeAliasModel,
|
|
|
|
vulkan_Mod_LoadExternalSkins,
|
|
|
|
vulkan_Mod_IQMFinish,
|
2019-07-06 05:42:53 +00:00
|
|
|
0,
|
2021-01-18 03:46:06 +00:00
|
|
|
vulkan_Mod_SpriteLoadTexture,
|
2019-07-06 05:42:53 +00:00
|
|
|
|
|
|
|
Skin_SetColormap,
|
|
|
|
Skin_SetSkin,
|
2021-01-18 03:46:06 +00:00
|
|
|
vulkan_Skin_SetupSkin,
|
2019-07-06 05:42:53 +00:00
|
|
|
Skin_SetTranslation,
|
2021-01-18 03:46:06 +00:00
|
|
|
vulkan_Skin_ProcessTranslation,
|
|
|
|
vulkan_Skin_InitTranslations,
|
2019-07-06 05:42:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
vid_render_funcs_t vulkan_vid_render_funcs = {
|
2021-01-10 06:52:27 +00:00
|
|
|
vulkan_Draw_Character,
|
|
|
|
vulkan_Draw_String,
|
|
|
|
vulkan_Draw_nString,
|
|
|
|
vulkan_Draw_AltString,
|
|
|
|
vulkan_Draw_ConsoleBackground,
|
|
|
|
vulkan_Draw_Crosshair,
|
|
|
|
vulkan_Draw_CrosshairAt,
|
|
|
|
vulkan_Draw_TileClear,
|
|
|
|
vulkan_Draw_Fill,
|
|
|
|
vulkan_Draw_TextBox,
|
|
|
|
vulkan_Draw_FadeScreen,
|
|
|
|
vulkan_Draw_BlendScreen,
|
2019-07-06 05:42:53 +00:00
|
|
|
vulkan_Draw_CachePic,
|
2021-01-10 06:52:27 +00:00
|
|
|
vulkan_Draw_UncachePic,
|
2019-07-06 05:42:53 +00:00
|
|
|
vulkan_Draw_MakePic,
|
2021-01-10 06:52:27 +00:00
|
|
|
vulkan_Draw_DestroyPic,
|
|
|
|
vulkan_Draw_PicFromWad,
|
|
|
|
vulkan_Draw_Pic,
|
|
|
|
vulkan_Draw_Picf,
|
|
|
|
vulkan_Draw_SubPic,
|
2019-07-06 05:42:53 +00:00
|
|
|
|
|
|
|
SCR_DrawRam,
|
|
|
|
SCR_DrawTurtle,
|
|
|
|
SCR_DrawPause,
|
2021-01-18 03:46:06 +00:00
|
|
|
vulkan_SCR_CaptureBGR,
|
|
|
|
vulkan_SCR_ScreenShot,
|
2019-07-06 05:42:53 +00:00
|
|
|
SCR_DrawStringToSnap,
|
|
|
|
|
2021-01-18 03:46:06 +00:00
|
|
|
vulkan_Fog_Update,
|
|
|
|
vulkan_Fog_ParseWorldspawn,
|
2019-07-06 05:42:53 +00:00
|
|
|
|
2019-07-10 04:16:46 +00:00
|
|
|
vulkan_R_Init,
|
2021-01-11 07:57:31 +00:00
|
|
|
vulkan_R_RenderFrame,
|
2021-01-18 03:46:06 +00:00
|
|
|
vulkan_R_ClearState,
|
|
|
|
vulkan_R_LoadSkys,
|
|
|
|
vulkan_R_NewMap,
|
2019-07-06 05:42:53 +00:00
|
|
|
R_AddEfrags,
|
|
|
|
R_RemoveEfrags,
|
|
|
|
R_EnqueueEntity,
|
2021-01-18 03:46:06 +00:00
|
|
|
vulkan_R_LineGraph,
|
2019-07-06 05:42:53 +00:00
|
|
|
R_AllocDlight,
|
|
|
|
R_AllocEntity,
|
2021-01-12 07:14:46 +00:00
|
|
|
R_MaxDlightsCheck,
|
2021-01-18 03:46:06 +00:00
|
|
|
vulkan_R_RenderView,
|
2019-07-06 05:42:53 +00:00
|
|
|
R_DecayLights,
|
2021-01-12 02:26:20 +00:00
|
|
|
vulkan_R_ViewChanged,
|
2021-01-18 03:46:06 +00:00
|
|
|
vulkan_R_ClearParticles,
|
|
|
|
vulkan_R_InitParticles,
|
|
|
|
vulkan_SCR_ScreenShot_f,
|
|
|
|
vulkan_r_easter_eggs_f,
|
|
|
|
vulkan_r_particles_style_f,
|
2019-07-06 05:42:53 +00:00
|
|
|
0,
|
2019-07-09 12:07:59 +00:00
|
|
|
&model_funcs
|
2019-07-06 05:42:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_palette (const byte *palette)
|
|
|
|
{
|
|
|
|
//FIXME really don't want this here: need an application domain
|
|
|
|
//so Quake can be separated from QuakeForge (ie, Quake itself becomes
|
|
|
|
//an app using the QuakeForge engine)
|
|
|
|
}
|
|
|
|
|
2019-07-09 00:06:35 +00:00
|
|
|
static void
|
|
|
|
vulkan_vid_render_choose_visual (void)
|
|
|
|
{
|
2019-07-09 07:33:44 +00:00
|
|
|
Vulkan_CreateDevice (vulkan_ctx);
|
|
|
|
vulkan_ctx->choose_visual (vulkan_ctx);
|
2020-02-16 13:45:27 +00:00
|
|
|
vulkan_ctx->cmdpool = QFV_CreateCommandPool (vulkan_ctx->device,
|
|
|
|
vulkan_ctx->device->queue.queueFamily,
|
2020-02-18 05:28:28 +00:00
|
|
|
0, 1);
|
2021-01-15 13:45:49 +00:00
|
|
|
__auto_type cmdset = QFV_AllocCommandBufferSet (1, alloca);
|
|
|
|
QFV_AllocateCommandBuffers (vulkan_ctx->device, vulkan_ctx->cmdpool, 0,
|
|
|
|
cmdset);
|
2020-02-18 05:28:28 +00:00
|
|
|
vulkan_ctx->cmdbuffer = cmdset->a[0];
|
|
|
|
vulkan_ctx->fence = QFV_CreateFence (vulkan_ctx->device, 1);
|
2020-02-16 13:45:27 +00:00
|
|
|
Sys_Printf ("vk choose visual %p %p %d %p\n", vulkan_ctx->device->dev,
|
|
|
|
vulkan_ctx->device->queue.queue,
|
|
|
|
vulkan_ctx->device->queue.queueFamily,
|
2020-02-17 11:29:35 +00:00
|
|
|
vulkan_ctx->cmdpool);
|
2019-07-09 00:06:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_vid_render_create_context (void)
|
|
|
|
{
|
2019-07-09 07:33:44 +00:00
|
|
|
vulkan_ctx->create_window (vulkan_ctx);
|
2019-07-12 04:15:25 +00:00
|
|
|
vulkan_ctx->surface = vulkan_ctx->create_surface (vulkan_ctx);
|
2020-02-16 13:45:27 +00:00
|
|
|
Sys_Printf ("vk create context %p\n", vulkan_ctx->surface);
|
2019-07-09 00:06:35 +00:00
|
|
|
}
|
|
|
|
|
2019-07-06 05:42:53 +00:00
|
|
|
static void
|
|
|
|
vulkan_vid_render_init (void)
|
|
|
|
{
|
2019-07-08 16:00:47 +00:00
|
|
|
vulkan_ctx = vr_data.vid->vid_internal->vulkan_context ();
|
|
|
|
vulkan_ctx->load_vulkan (vulkan_ctx);
|
|
|
|
|
2019-07-09 02:54:23 +00:00
|
|
|
Vulkan_Init_Common (vulkan_ctx);
|
2019-07-09 00:06:35 +00:00
|
|
|
|
2019-07-08 04:40:29 +00:00
|
|
|
vr_data.vid->vid_internal->set_palette = set_palette;
|
2019-07-09 00:06:35 +00:00
|
|
|
vr_data.vid->vid_internal->choose_visual = vulkan_vid_render_choose_visual;
|
|
|
|
vr_data.vid->vid_internal->create_context = vulkan_vid_render_create_context;
|
|
|
|
|
2019-07-06 05:42:53 +00:00
|
|
|
vr_funcs = &vulkan_vid_render_funcs;
|
|
|
|
m_funcs = &model_funcs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_vid_render_shutdown (void)
|
|
|
|
{
|
2020-02-17 11:29:35 +00:00
|
|
|
qfv_device_t *device = vulkan_ctx->device;
|
|
|
|
qfv_devfuncs_t *df = device->funcs;
|
|
|
|
VkDevice dev = device->dev;
|
|
|
|
QFV_DeviceWaitIdle (device);
|
2020-02-18 05:28:28 +00:00
|
|
|
df->vkDestroyFence (dev, vulkan_ctx->fence, 0);
|
2020-02-17 11:29:35 +00:00
|
|
|
df->vkDestroyCommandPool (dev, vulkan_ctx->cmdpool, 0);
|
2021-02-24 10:58:31 +00:00
|
|
|
Vulkan_Compose_Shutdown (vulkan_ctx);
|
|
|
|
Vulkan_Lighting_Shutdown (vulkan_ctx);
|
2021-01-12 02:27:41 +00:00
|
|
|
Vulkan_Draw_Shutdown (vulkan_ctx);
|
2021-01-19 16:25:54 +00:00
|
|
|
Vulkan_Bsp_Shutdown (vulkan_ctx);
|
2021-01-26 11:58:24 +00:00
|
|
|
Vulkan_Alias_Shutdown (vulkan_ctx);
|
2021-01-20 17:13:40 +00:00
|
|
|
Mod_ClearAll ();
|
2021-01-23 06:40:31 +00:00
|
|
|
Vulkan_Texture_Shutdown (vulkan_ctx);
|
2021-02-24 07:27:56 +00:00
|
|
|
Vulkan_DestroyFramebuffers (vulkan_ctx);
|
|
|
|
Vulkan_DestroyRenderPass (vulkan_ctx);
|
2019-07-09 02:54:23 +00:00
|
|
|
Vulkan_Shutdown_Common (vulkan_ctx);
|
2019-07-06 05:42:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static general_funcs_t plugin_info_general_funcs = {
|
|
|
|
vulkan_vid_render_init,
|
|
|
|
vulkan_vid_render_shutdown,
|
|
|
|
};
|
|
|
|
|
|
|
|
static general_data_t plugin_info_general_data;
|
|
|
|
|
|
|
|
static plugin_funcs_t plugin_info_funcs = {
|
|
|
|
&plugin_info_general_funcs,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
&vulkan_vid_render_funcs,
|
|
|
|
};
|
|
|
|
|
|
|
|
static plugin_data_t plugin_info_data = {
|
|
|
|
&plugin_info_general_data,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
&vid_render_data,
|
|
|
|
};
|
|
|
|
|
|
|
|
static plugin_t plugin_info = {
|
2019-07-07 05:57:56 +00:00
|
|
|
qfp_vid_render,
|
2019-07-06 05:42:53 +00:00
|
|
|
0,
|
|
|
|
QFPLUGIN_VERSION,
|
|
|
|
"0.1",
|
2019-07-07 05:59:20 +00:00
|
|
|
"Vulkan Renderer",
|
2019-07-06 05:42:53 +00:00
|
|
|
"Copyright (C) 1996-1997 Id Software, Inc.\n"
|
2019-07-07 05:59:20 +00:00
|
|
|
"Copyright (C) 1999-2019 contributors of the QuakeForge project\n"
|
2019-07-06 05:42:53 +00:00
|
|
|
"Please see the file \"AUTHORS\" for a list of contributors",
|
|
|
|
&plugin_info_funcs,
|
|
|
|
&plugin_info_data,
|
|
|
|
};
|
|
|
|
|
|
|
|
PLUGIN_INFO(vid_render, vulkan)
|
|
|
|
{
|
|
|
|
return &plugin_info;
|
|
|
|
}
|