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>
|
|
|
|
|
|
|
|
//#define NH_DEFINE
|
|
|
|
//#include "vulkan/namehack.h"
|
2019-07-06 05:42:53 +00:00
|
|
|
|
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"
|
|
|
|
|
|
|
|
#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"
|
|
|
|
#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
|
|
|
|
|
|
|
#include "vulkan/namehack.h"
|
|
|
|
|
2019-07-09 02:54:23 +00:00
|
|
|
static vulkan_ctx_t *vulkan_ctx;
|
2019-07-08 16:00:47 +00:00
|
|
|
|
2019-07-10 04:16:46 +00:00
|
|
|
static void
|
|
|
|
vulkan_R_Init (void)
|
|
|
|
{
|
2020-02-17 11:29:35 +00:00
|
|
|
qfv_device_t *device = vulkan_ctx->device;
|
|
|
|
qfv_devfuncs_t *dfunc = device->funcs;
|
2020-02-16 15:50:39 +00:00
|
|
|
qfv_cmdbufferset_t *cmdBuffers;
|
2020-02-17 11:29:35 +00:00
|
|
|
|
2020-02-16 13:45:27 +00:00
|
|
|
Vulkan_CreateSwapchain (vulkan_ctx);
|
2020-02-18 05:28:28 +00:00
|
|
|
Vulkan_CreateRenderPass (vulkan_ctx);
|
2020-02-17 11:29:35 +00:00
|
|
|
cmdBuffers = QFV_AllocateCommandBuffers (device, vulkan_ctx->cmdpool, 0,
|
2020-02-16 15:50:39 +00:00
|
|
|
vulkan_ctx->swapchain->numImages);
|
|
|
|
vulkan_ctx->frameset.cmdBuffers = cmdBuffers;
|
2020-02-17 11:29:35 +00:00
|
|
|
VkCommandBufferBeginInfo beginInfo
|
|
|
|
= { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO };
|
2020-02-17 16:03:36 +00:00
|
|
|
VkClearColorValue clearColor = { {0.7294, 0.8549, 0.3333, 1.0} };
|
|
|
|
VkImageSubresourceRange image_subresource_range = {
|
|
|
|
VK_IMAGE_ASPECT_COLOR_BIT,
|
|
|
|
0, 1, 0, 1,
|
|
|
|
};
|
|
|
|
VkImageMemoryBarrier pc_barrier = {
|
|
|
|
VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, 0,
|
|
|
|
VK_ACCESS_TRANSFER_WRITE_BIT,
|
|
|
|
VK_ACCESS_MEMORY_READ_BIT,
|
|
|
|
VK_IMAGE_LAYOUT_UNDEFINED,
|
|
|
|
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
|
|
|
device->queue.queueFamily,
|
|
|
|
device->queue.queueFamily,
|
|
|
|
0, // filled in later
|
|
|
|
image_subresource_range
|
|
|
|
};
|
|
|
|
VkImageMemoryBarrier cp_barrier = {
|
|
|
|
VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, 0,
|
|
|
|
VK_ACCESS_TRANSFER_WRITE_BIT,
|
|
|
|
VK_ACCESS_MEMORY_READ_BIT,
|
|
|
|
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
|
|
|
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
|
|
|
|
device->queue.queueFamily,
|
|
|
|
device->queue.queueFamily,
|
|
|
|
0, // filled in later
|
|
|
|
image_subresource_range
|
|
|
|
};
|
2020-02-17 11:29:35 +00:00
|
|
|
for (size_t i = 0; i < cmdBuffers->size; i++) {
|
2020-02-17 16:03:36 +00:00
|
|
|
pc_barrier.image = vulkan_ctx->swapchain->images->a[i];
|
|
|
|
cp_barrier.image = vulkan_ctx->swapchain->images->a[i];
|
2020-02-17 11:29:35 +00:00
|
|
|
dfunc->vkBeginCommandBuffer (cmdBuffers->a[i], &beginInfo);
|
2020-02-17 16:03:36 +00:00
|
|
|
dfunc->vkCmdPipelineBarrier (cmdBuffers->a[i],
|
|
|
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
|
|
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
|
|
|
0,
|
|
|
|
0, 0, // memory barriers
|
|
|
|
0, 0, // buffer barriers
|
|
|
|
1, &pc_barrier);
|
|
|
|
dfunc->vkCmdClearColorImage (cmdBuffers->a[i], pc_barrier.image,
|
|
|
|
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
|
|
|
&clearColor, 1,
|
|
|
|
&image_subresource_range);
|
|
|
|
dfunc->vkCmdPipelineBarrier (cmdBuffers->a[i],
|
|
|
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
|
|
|
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
|
|
|
0,
|
|
|
|
0, 0,
|
|
|
|
0, 0,
|
|
|
|
1, &cp_barrier);
|
2020-02-17 11:29:35 +00:00
|
|
|
dfunc->vkEndCommandBuffer (cmdBuffers->a[i]);
|
2020-02-16 15:50:39 +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");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vulkan_SCR_UpdateScreen (double time, void (*f)(void), void (**g)(void))
|
|
|
|
{
|
|
|
|
static int count = 0;
|
|
|
|
static double startTime;
|
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;
|
|
|
|
vulkan_frameset_t *frameset = &vulkan_ctx->frameset;
|
|
|
|
|
2020-02-18 05:28:28 +00:00
|
|
|
dfunc->vkWaitForFences (dev, 1, &frameset->fences->a[frameset->curFrame],
|
2020-02-17 11:29:35 +00:00
|
|
|
VK_TRUE, 2000000000);
|
2020-02-16 15:50:39 +00:00
|
|
|
QFV_AcquireNextImage (vulkan_ctx->swapchain,
|
2020-02-17 11:29:35 +00:00
|
|
|
frameset->imageSemaphores->a[frameset->curFrame],
|
2020-02-16 15:50:39 +00:00
|
|
|
0, &imageIndex);
|
|
|
|
|
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,
|
|
|
|
1,
|
2020-02-17 11:29:35 +00:00
|
|
|
&frameset->imageSemaphores->a[frameset->curFrame],
|
2020-02-16 15:50:39 +00:00
|
|
|
&waitStage,
|
2020-02-17 11:29:35 +00:00
|
|
|
1, &frameset->cmdBuffers->a[imageIndex],
|
|
|
|
1, &frameset->renderDoneSemaphores->a[frameset->curFrame],
|
2020-02-16 15:50:39 +00:00
|
|
|
};
|
2020-02-17 11:29:35 +00:00
|
|
|
dfunc->vkResetFences (dev, 1, &frameset->fences->a[frameset->curFrame]);
|
2020-02-16 15:50:39 +00:00
|
|
|
dfunc->vkQueueSubmit (queue->queue, 1, &submitInfo,
|
2020-02-17 11:29:35 +00:00
|
|
|
frameset->fences->a[frameset->curFrame]);
|
2020-02-16 15:50:39 +00:00
|
|
|
|
|
|
|
VkPresentInfoKHR presentInfo = {
|
|
|
|
VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, 0,
|
2020-02-17 11:29:35 +00:00
|
|
|
1, &frameset->renderDoneSemaphores->a[frameset->curFrame],
|
2020-02-16 15:50:39 +00:00
|
|
|
1, &vulkan_ctx->swapchain->swapchain, &imageIndex,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
dfunc->vkQueuePresentKHR (queue->queue, &presentInfo);
|
|
|
|
|
|
|
|
frameset->curFrame++;
|
2020-02-17 11:29:35 +00:00
|
|
|
frameset->curFrame %= frameset->fences->size;
|
2020-02-16 13:45:27 +00:00
|
|
|
|
|
|
|
if (++count >= 100) {
|
|
|
|
double currenTime = Sys_DoubleTime ();
|
|
|
|
double time = currenTime - startTime;
|
|
|
|
startTime = currenTime;
|
2020-02-18 05:28:28 +00:00
|
|
|
printf ("%d frames in %g s: %g fps \r",
|
|
|
|
count, time, count / time);
|
2020-02-16 13:45:27 +00:00
|
|
|
fflush (stdout);
|
|
|
|
count = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static qpic_t *
|
|
|
|
vulkan_Draw_CachePic (const char *path, qboolean alpha)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static qpic_t qpic = { 1, 1, {0} };
|
|
|
|
|
|
|
|
static qpic_t *
|
|
|
|
vulkan_Draw_MakePic (int width, int height, const byte *data)
|
|
|
|
{
|
|
|
|
return &qpic;
|
2019-07-10 04:16:46 +00:00
|
|
|
}
|
|
|
|
|
2019-07-06 05:42:53 +00:00
|
|
|
static vid_model_funcs_t model_funcs = {
|
2019-07-09 12:07:59 +00:00
|
|
|
0,//vulkan_Mod_LoadExternalTextures,
|
|
|
|
0,//vulkan_Mod_LoadLighting,
|
|
|
|
0,//vulkan_Mod_SubdivideSurface,
|
|
|
|
0,//vulkan_Mod_ProcessTexture,
|
2019-07-06 05:42:53 +00:00
|
|
|
|
|
|
|
Mod_LoadIQM,
|
|
|
|
Mod_LoadAliasModel,
|
|
|
|
Mod_LoadSpriteModel,
|
|
|
|
|
2019-07-09 12:07:59 +00:00
|
|
|
0,//vulkan_Mod_MakeAliasModelDisplayLists,
|
|
|
|
0,//vulkan_Mod_LoadSkin,
|
|
|
|
0,//vulkan_Mod_FinalizeAliasModel,
|
|
|
|
0,//vulkan_Mod_LoadExternalSkins,
|
|
|
|
0,//vulkan_Mod_IQMFinish,
|
2019-07-06 05:42:53 +00:00
|
|
|
0,
|
2019-07-09 12:07:59 +00:00
|
|
|
0,//vulkan_Mod_SpriteLoadTexture,
|
2019-07-06 05:42:53 +00:00
|
|
|
|
|
|
|
Skin_SetColormap,
|
|
|
|
Skin_SetSkin,
|
2019-07-09 12:07:59 +00:00
|
|
|
0,//vulkan_Skin_SetupSkin,
|
2019-07-06 05:42:53 +00:00
|
|
|
Skin_SetTranslation,
|
2019-07-09 12:07:59 +00:00
|
|
|
0,//vulkan_Skin_ProcessTranslation,
|
|
|
|
0,//vulkan_Skin_InitTranslations,
|
2019-07-06 05:42:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
vid_render_funcs_t vulkan_vid_render_funcs = {
|
2020-02-16 13:45:27 +00:00
|
|
|
0,//vulkan_Draw_Init,
|
|
|
|
0,//vulkan_Draw_Character,
|
|
|
|
0,//vulkan_Draw_String,
|
|
|
|
0,//vulkan_Draw_nString,
|
|
|
|
0,//vulkan_Draw_AltString,
|
|
|
|
0,//vulkan_Draw_ConsoleBackground,
|
|
|
|
0,//vulkan_Draw_Crosshair,
|
|
|
|
0,//vulkan_Draw_CrosshairAt,
|
|
|
|
0,//vulkan_Draw_TileClear,
|
|
|
|
0,//vulkan_Draw_Fill,
|
|
|
|
0,//vulkan_Draw_TextBox,
|
|
|
|
0,//vulkan_Draw_FadeScreen,
|
|
|
|
0,//vulkan_Draw_BlendScreen,
|
2019-07-06 05:42:53 +00:00
|
|
|
vulkan_Draw_CachePic,
|
2020-02-16 13:45:27 +00:00
|
|
|
0,//vulkan_Draw_UncachePic,
|
2019-07-06 05:42:53 +00:00
|
|
|
vulkan_Draw_MakePic,
|
2020-02-16 13:45:27 +00:00
|
|
|
0,//vulkan_Draw_DestroyPic,
|
|
|
|
0,//vulkan_Draw_PicFromWad,
|
|
|
|
0,//vulkan_Draw_Pic,
|
|
|
|
0,//vulkan_Draw_Picf,
|
|
|
|
0,//vulkan_Draw_SubPic,
|
2019-07-06 05:42:53 +00:00
|
|
|
|
2020-02-16 13:45:27 +00:00
|
|
|
vulkan_SCR_UpdateScreen,
|
2019-07-06 05:42:53 +00:00
|
|
|
SCR_DrawRam,
|
|
|
|
SCR_DrawTurtle,
|
|
|
|
SCR_DrawPause,
|
2019-07-09 12:07:59 +00:00
|
|
|
0,//vulkan_SCR_CaptureBGR,
|
|
|
|
0,//vulkan_SCR_ScreenShot,
|
2019-07-06 05:42:53 +00:00
|
|
|
SCR_DrawStringToSnap,
|
|
|
|
|
2019-07-09 12:07:59 +00:00
|
|
|
0,//vulkan_Fog_Update,
|
|
|
|
0,//vulkan_Fog_ParseWorldspawn,
|
2019-07-06 05:42:53 +00:00
|
|
|
|
2019-07-10 04:16:46 +00:00
|
|
|
vulkan_R_Init,
|
2019-07-09 12:07:59 +00:00
|
|
|
0,//vulkan_R_ClearState,
|
|
|
|
0,//vulkan_R_LoadSkys,
|
|
|
|
0,//vulkan_R_NewMap,
|
2019-07-06 05:42:53 +00:00
|
|
|
R_AddEfrags,
|
|
|
|
R_RemoveEfrags,
|
|
|
|
R_EnqueueEntity,
|
2019-07-09 12:07:59 +00:00
|
|
|
0,//vulkan_R_LineGraph,
|
2019-07-06 05:42:53 +00:00
|
|
|
R_AllocDlight,
|
|
|
|
R_AllocEntity,
|
2019-07-09 12:07:59 +00:00
|
|
|
0,//vulkan_R_RenderView,
|
2019-07-06 05:42:53 +00:00
|
|
|
R_DecayLights,
|
2019-07-09 12:07:59 +00:00
|
|
|
0,//vulkan_R_ViewChanged,
|
|
|
|
0,//vulkan_R_ClearParticles,
|
|
|
|
0,//vulkan_R_InitParticles,
|
|
|
|
0,//vulkan_SCR_ScreenShot_f,
|
|
|
|
0,//vulkan_r_easter_eggs_f,
|
|
|
|
0,//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);
|
|
|
|
__auto_type cmdset = QFV_AllocateCommandBuffers (vulkan_ctx->device,
|
|
|
|
vulkan_ctx->cmdpool,
|
|
|
|
0, 1);
|
|
|
|
vulkan_ctx->cmdbuffer = cmdset->a[0];
|
|
|
|
free (cmdset);
|
|
|
|
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
|
|
|
vulkan_ctx->frameset.curFrame = 0;
|
2020-02-17 11:29:35 +00:00
|
|
|
qfv_fenceset_t *fences = DARRAY_ALLOCFIXED (*fences, 2, malloc);
|
|
|
|
qfv_semaphoreset_t *imageSems = DARRAY_ALLOCFIXED (*imageSems, 2, malloc);
|
|
|
|
qfv_semaphoreset_t *renderDoneSems = DARRAY_ALLOCFIXED (*renderDoneSems, 2,
|
|
|
|
malloc);
|
2020-02-16 13:45:27 +00:00
|
|
|
for (int i = 0; i < 2; i++) {
|
2020-02-18 05:28:28 +00:00
|
|
|
fences->a[i] = QFV_CreateFence (vulkan_ctx->device, 1);
|
2020-02-17 11:29:35 +00:00
|
|
|
imageSems->a[i] = QFV_CreateSemaphore (vulkan_ctx->device);
|
|
|
|
renderDoneSems->a[i] = QFV_CreateSemaphore (vulkan_ctx->device);
|
2019-07-10 15:58:14 +00:00
|
|
|
}
|
2020-02-17 11:29:35 +00:00
|
|
|
vulkan_ctx->frameset.fences = fences;
|
|
|
|
vulkan_ctx->frameset.imageSemaphores = imageSems;
|
|
|
|
vulkan_ctx->frameset.renderDoneSemaphores = renderDoneSems;
|
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-16 15:50:39 +00:00
|
|
|
vulkan_frameset_t *frameset = &vulkan_ctx->frameset;
|
2020-02-17 11:29:35 +00:00
|
|
|
for (size_t i = 0; i < frameset->fences->size; i++) {
|
|
|
|
df->vkDestroyFence (dev, frameset->fences->a[i], 0);
|
|
|
|
df->vkDestroySemaphore (dev, frameset->imageSemaphores->a[i], 0);
|
|
|
|
df->vkDestroySemaphore (dev, frameset->renderDoneSemaphores->a[i], 0);
|
2020-02-16 13:45:27 +00:00
|
|
|
}
|
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);
|
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;
|
|
|
|
}
|