[vulkan] Move frames from vulkan_ctx to renderctx

Part of the command buffer fix, but also a step towards cleaning up
vulkan_ctx.
This commit is contained in:
Bill Currie 2023-06-22 16:44:05 +09:00
parent 6deeed1829
commit bba82d3da1
32 changed files with 166 additions and 179 deletions

View File

@ -89,7 +89,7 @@ typedef struct aliasctx_s {
} aliasctx_t;
struct vulkan_ctx_s;
struct qfv_renderframe_s;
struct qfv_orenderframe_s;
struct entity_s;
struct mod_alias_ctx_s;
@ -106,13 +106,13 @@ void Vulkan_Mod_MakeAliasModelDisplayLists (struct mod_alias_ctx_s *alias_ctx,
void Vulkan_AliasAddSkin (struct vulkan_ctx_s *ctx, qfv_alias_skin_t *skin);
void Vulkan_AliasRemoveSkin (struct vulkan_ctx_s *ctx, qfv_alias_skin_t *skin);
void Vulkan_AliasBegin (struct qfv_renderframe_s *rFrame);
void Vulkan_DrawAlias (struct entity_s ent, struct qfv_renderframe_s *rFrame);
void Vulkan_AliasEnd (struct qfv_renderframe_s *rFrame);
void Vulkan_AliasBegin (struct qfv_orenderframe_s *rFrame);
void Vulkan_DrawAlias (struct entity_s ent, struct qfv_orenderframe_s *rFrame);
void Vulkan_AliasEnd (struct qfv_orenderframe_s *rFrame);
void Vulkan_Alias_Init (struct vulkan_ctx_s *ctx);
void Vulkan_Alias_Shutdown (struct vulkan_ctx_s *ctx);
void Vulkan_AliasDepthRange (struct qfv_renderframe_s *rFrame, float n, float f);
void Vulkan_AliasDepthRange (struct qfv_orenderframe_s *rFrame, float n, float f);
#endif//__QF_Vulkan_qf_alias_h

View File

@ -386,10 +386,10 @@ typedef struct bspctx_s {
} bspctx_t;
struct vulkan_ctx_s;
struct qfv_renderframe_s;
void Vulkan_DrawWorld (struct qfv_renderframe_s *rFrame);
void Vulkan_DrawSky (struct qfv_renderframe_s *rFrame);
void Vulkan_DrawWaterSurfaces (struct qfv_renderframe_s *rFrame);
struct qfv_orenderframe_s;
void Vulkan_DrawWorld (struct qfv_orenderframe_s *rFrame);
void Vulkan_DrawSky (struct qfv_orenderframe_s *rFrame);
void Vulkan_DrawWaterSurfaces (struct qfv_orenderframe_s *rFrame);
void Vulkan_Bsp_Flush (struct vulkan_ctx_s *ctx);
void Vulkan_LoadSkys (const char *sky, struct vulkan_ctx_s *ctx);
void Vulkan_RegisterTextures (model_t **models, int num_models,

View File

@ -54,10 +54,10 @@ typedef struct composectx_s {
} composectx_t;
struct vulkan_ctx_s;
struct qfv_renderframe_s;
struct qfv_orenderframe_s;
void Vulkan_Compose_Init (struct vulkan_ctx_s *ctx);
void Vulkan_Compose_Shutdown (struct vulkan_ctx_s *ctx);
void Vulkan_Compose_Draw (struct qfv_renderframe_s *rFrame);
void Vulkan_Compose_Draw (struct qfv_orenderframe_s *rFrame);
#endif//__QF_Vulkan_qf_compose_h

View File

@ -98,7 +98,7 @@ typedef struct iqmctx_s {
} iqmctx_t;
struct vulkan_ctx_s;
struct qfv_renderframe_s;
struct qfv_orenderframe_s;
struct entity_s;
struct mod_iqm_ctx_s;
struct iqm_s;
@ -111,9 +111,9 @@ void Vulkan_IQMRemoveBones (struct vulkan_ctx_s *ctx, struct iqm_s *iqm);
void Vulkan_IQMAddSkin (struct vulkan_ctx_s *ctx, qfv_iqm_skin_t *skin);
void Vulkan_IQMRemoveSkin (struct vulkan_ctx_s *ctx, qfv_iqm_skin_t *skin);
void Vulkan_IQMBegin (struct qfv_renderframe_s *rFrame);
void Vulkan_DrawIQM (struct entity_s ent, struct qfv_renderframe_s *rFrame);
void Vulkan_IQMEnd (struct qfv_renderframe_s *rFrame);
void Vulkan_IQMBegin (struct qfv_orenderframe_s *rFrame);
void Vulkan_DrawIQM (struct entity_s ent, struct qfv_orenderframe_s *rFrame);
void Vulkan_IQMEnd (struct qfv_orenderframe_s *rFrame);
void Vulkan_IQM_Init (struct vulkan_ctx_s *ctx);
void Vulkan_IQM_Shutdown (struct vulkan_ctx_s *ctx);

View File

@ -117,12 +117,12 @@ typedef struct lightingctx_s {
} lightingctx_t;
struct vulkan_ctx_s;
struct qfv_renderframe_s;
struct qfv_orenderframe_s;
void Vulkan_Lighting_CreateRenderPasses (struct vulkan_ctx_s *ctx);
void Vulkan_Lighting_Init (struct vulkan_ctx_s *ctx);
void Vulkan_Lighting_Shutdown (struct vulkan_ctx_s *ctx);
void Vulkan_Lighting_Draw (struct qfv_renderframe_s *rFrame);
void Vulkan_Lighting_Draw (struct qfv_orenderframe_s *rFrame);
void Vulkan_LoadLights (struct scene_s *scene, struct vulkan_ctx_s *ctx);
#endif//__QF_Vulkan_qf_lighting_h

View File

@ -29,14 +29,14 @@
#define __QF_Vulkan_qf_main_h
struct vulkan_ctx_s;
struct qfv_renderframe_s;
struct qfv_orenderframe_s;
struct entqueue_s;
struct scene_s;
void Vulkan_Main_CreateRenderPasses (struct vulkan_ctx_s *ctx);
void Vulkan_NewScene (struct scene_s *scene, struct vulkan_ctx_s *ctx);
void Vulkan_RenderView (struct qfv_renderframe_s *rFrame);
void Vulkan_RenderView (struct qfv_orenderframe_s *rFrame);
void Vulkan_RenderEntities (struct entqueue_s *queue,
struct qfv_renderframe_s *rFrame);
struct qfv_orenderframe_s *rFrame);
#endif//__QF_Vulkan_qf_main_h

View File

@ -74,12 +74,12 @@ typedef struct particlectx_s {
struct cvar_s;
struct vulkan_ctx_s;
struct qfv_renderframe_s;
struct qfv_orenderframe_s;
struct psystem_s *Vulkan_ParticleSystem (struct vulkan_ctx_s *ctx);
void Vulkan_Particles_Init (struct vulkan_ctx_s *ctx);
void Vulkan_Particles_Shutdown (struct vulkan_ctx_s *ctx);
void Vulkan_DrawParticles (struct qfv_renderframe_s *rFrame);
void Vulkan_DrawParticles (struct qfv_orenderframe_s *rFrame);
void Vulkan_Particles_CreateRenderPasses (struct vulkan_ctx_s *ctx);
#endif//__QF_Vulkan_qf_particles_h

View File

@ -25,7 +25,7 @@ typedef struct qfv_osubpass_s {
typedef struct qfv_subpassset_s
DARRAY_TYPE (qfv_osubpass_t) qfv_subpassset_t;
typedef struct qfv_renderframe_s {
typedef struct qfv_orenderframe_s {
struct vulkan_ctx_s *vulkan_ctx;
struct qfv_orenderpass_s *renderpass;
VkSubpassContents subpassContents;
@ -33,15 +33,15 @@ typedef struct qfv_renderframe_s {
int subpassCount;
qfv_osubpass_t *subpassInfo;
struct qfv_cmdbufferset_s *subpassCmdSets;
} qfv_renderframe_t;
} qfv_orenderframe_t;
typedef struct qfv_renderframeset_s
DARRAY_TYPE (qfv_renderframe_t) qfv_renderframeset_t;
typedef struct qfv_orenderframeset_s
DARRAY_TYPE (qfv_orenderframe_t) qfv_orenderframeset_t;
typedef struct clearvalueset_s
DARRAY_TYPE (VkClearValue) clearvalueset_t;
typedef void (*qfv_draw_t) (qfv_renderframe_t *rFrame);
typedef void (*qfv_draw_t) (qfv_orenderframe_t *rFrame);
typedef struct qfv_orenderpass_s {
struct vulkan_ctx_s *vulkan_ctx;
@ -64,7 +64,7 @@ typedef struct qfv_orenderpass_s {
int primary_commands;
size_t subpassCount;
qfv_subpassset_t *subpass_info;
qfv_renderframeset_t frames;
qfv_orenderframeset_t frames;
qfv_draw_t draw;
} qfv_orenderpass_t;

View File

@ -77,7 +77,7 @@ typedef struct spritectx_s {
} spritectx_t;
struct vulkan_ctx_s;
struct qfv_renderframe_s;
struct qfv_orenderframe_s;
struct entity_s;
struct mod_sprite_ctx_s;
@ -88,9 +88,9 @@ void Vulkan_Sprite_DescriptorSet (struct vulkan_ctx_s *ctx,
void Vulkan_Mod_SpriteLoadFrames (struct mod_sprite_ctx_s *sprite_ctx,
struct vulkan_ctx_s *ctx);
void Vulkan_SpriteBegin (struct qfv_renderframe_s *rFrame);
void Vulkan_DrawSprite (struct entity_s ent, struct qfv_renderframe_s *rFrame);
void Vulkan_SpriteEnd (struct qfv_renderframe_s *rFrame);
void Vulkan_SpriteBegin (struct qfv_orenderframe_s *rFrame);
void Vulkan_DrawSprite (struct entity_s ent, struct qfv_orenderframe_s *rFrame);
void Vulkan_SpriteEnd (struct qfv_orenderframe_s *rFrame);
void Vulkan_Sprite_Init (struct vulkan_ctx_s *ctx);
void Vulkan_Sprite_Shutdown (struct vulkan_ctx_s *ctx);

View File

@ -46,11 +46,11 @@ typedef struct translucentctx_s {
} translucentctx_t;
struct vulkan_ctx_s;
struct qfv_renderframe_s;
struct qfv_orenderframe_s;
void Vulkan_Translucent_Init (struct vulkan_ctx_s *ctx);
void Vulkan_Translucent_Shutdown (struct vulkan_ctx_s *ctx);
void Vulkan_Translucent_Draw (struct qfv_renderframe_s *rFrame);
void Vulkan_Translucent_Draw (struct qfv_orenderframe_s *rFrame);
VkDescriptorSet Vulkan_Translucent_Descriptors (struct vulkan_ctx_s *ctx,
int frame)__attribute__((pure));
void Vulkan_Translucent_CreateBuffers (struct vulkan_ctx_s *ctx,

View File

@ -69,8 +69,6 @@ enum {
};
struct vulkan_ctx_s;
void Vulkan_DestroyFrames (struct vulkan_ctx_s *ctx);
void Vulkan_CreateFrames (struct vulkan_ctx_s *ctx);
void Vulkan_CreateCapture (struct vulkan_ctx_s *ctx);
void Vulkan_CreateRenderPasses (struct vulkan_ctx_s *ctx);
void Vulkan_DestroyRenderPasses (struct vulkan_ctx_s *ctx);

View File

@ -358,11 +358,22 @@ typedef struct qfv_job_s {
VkCommandPool command_pool;
} qfv_job_t;
typedef struct qfv_renderframe_s {
VkFence fence;
VkSemaphore imageAvailableSemaphore;
VkSemaphore renderDoneSemaphore;
VkCommandPool command_pool;
} qfv_renderframe_t;
typedef struct qfv_renderframeset_s
DARRAY_TYPE (qfv_renderframe_t) qfv_renderframeset_t;
typedef struct qfv_renderctx_s {
struct hashctx_s *hashctx;
exprtab_t task_functions;
qfv_jobinfo_t *jobinfo;
qfv_job_t *job;
qfv_renderframeset_t frames;
} qfv_renderctx_t;
typedef struct qfv_taskctx_s {

View File

@ -10,17 +10,6 @@
#include "QF/qtypes.h"
#include "QF/simd/types.h"
typedef struct vulkan_frame_s {
VkFence fence;
VkSemaphore imageAvailableSemaphore;
VkSemaphore renderDoneSemaphore;
VkCommandBuffer cmdBuffer;
VkCommandPool command_pool;
} vulkan_frame_t;
typedef struct vulkan_frameset_s
DARRAY_TYPE (vulkan_frame_t) vulkan_frameset_t;
typedef struct qfv_renderpassset_s
DARRAY_TYPE (struct qfv_orenderpass_s *) qfv_renderpassset_t;
@ -66,7 +55,6 @@ typedef struct vulkan_ctx_s {
VkCommandPool cmdpool;
struct qfv_stagebuf_s *staging;
uint32_t curFrame;
vulkan_frameset_t frames;
qfv_renderpassset_t renderPasses;
struct qfv_orenderpass_s *output_renderpass;

View File

@ -94,7 +94,6 @@ vulkan_R_Init (void)
QFV_Render_Init (vulkan_ctx);
Vulkan_CreateStagingBuffers (vulkan_ctx);
Vulkan_CreateFrames (vulkan_ctx);
Vulkan_Texture_Init (vulkan_ctx);
Vulkan_Palette_Init (vulkan_ctx, vid.palette);

View File

@ -257,7 +257,7 @@ QFV_RunRenderJob (vulkan_ctx_t *ctx)
auto device = ctx->device;
auto dfunc = device->funcs;
auto queue = &device->queue;
auto frame = &ctx->frames.a[ctx->curFrame];
auto frame = &rctx->frames.a[ctx->curFrame];
VkPipelineStageFlags waitStage
= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo submitInfo = {
@ -354,7 +354,8 @@ wait_on_fence (const exprval_t **params, exprval_t *result, exprctx_t *ectx)
auto dfunc = device->funcs;
auto dev = device->dev;
__auto_type frame = &ctx->frames.a[ctx->curFrame];
auto rctx = ctx->render_context;
auto frame = &rctx->frames.a[ctx->curFrame];
dfunc->vkWaitForFences (dev, 1, &frame->fence, VK_TRUE, 2000000000);
@ -443,6 +444,28 @@ QFV_Render_Init (vulkan_ctx_t *ctx)
rctx->task_functions.symbols = 0;
QFV_Render_AddTasks (ctx, render_task_syms);
auto device = ctx->device;
size_t frames = vulkan_frame_count;
DARRAY_INIT (&rctx->frames, frames);
DARRAY_RESIZE (&rctx->frames, frames);
for (size_t i = 0; i < rctx->frames.size; i++) {
auto frame = &rctx->frames.a[i];
frame->fence = QFV_CreateFence (device, 1);
frame->imageAvailableSemaphore = QFV_CreateSemaphore (device);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_SEMAPHORE,
frame->imageAvailableSemaphore,
va (ctx->va_ctx, "sc image:%zd", i));
frame->renderDoneSemaphore = QFV_CreateSemaphore (device);
VkCommandPoolCreateInfo poolCInfo = {
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT,
.queueFamilyIndex = device->queue.queueFamily,
};
auto dfunc = device->funcs;
dfunc->vkCreateCommandPool (device->dev, &poolCInfo, 0,
&frame->command_pool);
}
}
void
@ -483,10 +506,18 @@ QFV_Render_Shutdown (vulkan_ctx_t *ctx)
DARRAY_CLEAR (&job->commands);
free (rctx->job);
}
for (uint32_t i = 0; i < ctx->frames.size; i++) {
auto frame = &ctx->frames.a[i];
dfunc->vkDestroyCommandPool (device->dev, frame->command_pool, 0);
for (uint32_t i = 0; i < rctx->frames.size; i++) {
auto dev = device->dev;
auto df = dfunc;
auto frame = &rctx->frames.a[i];
df->vkDestroyFence (dev, frame->fence, 0);
df->vkDestroySemaphore (dev, frame->imageAvailableSemaphore, 0);
df->vkDestroySemaphore (dev, frame->renderDoneSemaphore, 0);
df->vkDestroyCommandPool (dev, frame->command_pool, 0);
}
DARRAY_CLEAR (&rctx->frames);
if (rctx->jobinfo) {
__auto_type jinfo = rctx->jobinfo;
for (uint32_t i = 0; i < jinfo->num_descriptorsetlayouts; i++) {

View File

@ -1125,17 +1125,6 @@ create_objects (vulkan_ctx_t *ctx, objcount_t *counts)
counts->num_descriptorsets = s.inds.num_descriptorsets;
init_job (ctx, counts, s);
for (uint32_t i = 0; i < ctx->frames.size; i++) {
VkCommandPoolCreateInfo poolCInfo = {
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT,
.queueFamilyIndex = device->queue.queueFamily,
};
auto frame = &ctx->frames.a[i];
dfunc->vkCreateCommandPool (device->dev, &poolCInfo, 0,
&frame->command_pool);
}
}
void

View File

@ -1187,19 +1187,19 @@ parse_task_params (const plitem_t *item, void **data,
#include "libs/video/renderer/vulkan/vkparse.cinc"
static exprsym_t vulkan_frameset_t_symbols[] = {
{"size", &cexpr_size_t, (void *)field_offset (vulkan_frameset_t, size)},
static exprsym_t qfv_renderframeset_t_symbols[] = {
{"size", &cexpr_size_t, (void *)field_offset (qfv_renderframeset_t, size)},
{ }
};
static exprtab_t vulkan_frameset_t_symtab = {
vulkan_frameset_t_symbols,
static exprtab_t qfv_renderframeset_t_symtab = {
qfv_renderframeset_t_symbols,
};
exprtype_t vulkan_frameset_t_type = {
exprtype_t qfv_renderframeset_t_type = {
.name = "frameset",
.size = sizeof (vulkan_frameset_t *),
.size = sizeof (qfv_renderframeset_t *),
.binops = cexpr_struct_binops,
.unops = 0,
.data = &vulkan_frameset_t_symtab,
.data = &qfv_renderframeset_t_symtab,
};
static hashtab_t *
@ -1257,9 +1257,10 @@ parse_object (vulkan_ctx_t *ctx, memsuper_t *memsuper, plitem_t *plist,
plitem_t *messages = PL_NewArray ();
exprctx_t exprctx = { .symtab = &root_symtab };
parsectx_t parsectx = { &exprctx, ctx, properties };
auto rctx = ctx->render_context;
exprsym_t var_syms[] = {
{"output", &qfv_output_t_type, &sctx->output},
{"frames", &vulkan_frameset_t_type, &ctx->frames},
{"frames", &qfv_renderframeset_t_type, &rctx->frames},
{"msaaSamples", &VkSampleCountFlagBits_type, &ctx->msaaSamples},
{"physDevLimits", &VkPhysicalDeviceLimits_type,
&ctx->device->physDev->properties->limits },
@ -2050,7 +2051,7 @@ void Vulkan_Script_Init (vulkan_ctx_t *ctx)
ectx.hashctx = 0;//&sctx->hashctx;
vkgen_init_symtabs (&ectx);
cexpr_init_symtab (&qfv_output_t_symtab, &ectx);
cexpr_init_symtab (&vulkan_frameset_t_symtab, &ectx);
cexpr_init_symtab (&qfv_renderframeset_t_symtab, &ectx);
cexpr_init_symtab (&data_array_symtab, &ectx);
sctx->shaderModules = handlref_symtab (shaderModule_free, sctx);
@ -2336,7 +2337,7 @@ QFV_ParseJobInfo (vulkan_ctx_t *ctx, plitem_t *item, qfv_renderctx_t *rctx)
};
exprsym_t var_syms[] = {
{"render_output", &qfv_output_t_type, &sctx->output},
{"frames", &vulkan_frameset_t_type, &ctx->frames},
{"frames", &qfv_renderframeset_t_type, &rctx->frames},
{"msaaSamples", &VkSampleCountFlagBits_type, &ctx->msaaSamples},
{"physDevLimits", &VkPhysicalDeviceLimits_type,
&ctx->device->physDev->properties->limits },

View File

@ -77,7 +77,7 @@ static void
emit_commands (VkCommandBuffer cmd, int pose1, int pose2,
qfv_alias_skin_t *skin,
uint32_t numPC, qfv_push_constants_t *constants,
aliashdr_t *hdr, qfv_renderframe_t *rFrame, entity_t ent)
aliashdr_t *hdr, qfv_orenderframe_t *rFrame, entity_t ent)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;
@ -117,7 +117,7 @@ emit_commands (VkCommandBuffer cmd, int pose1, int pose2,
}
void
Vulkan_DrawAlias (entity_t ent, qfv_renderframe_t *rFrame)
Vulkan_DrawAlias (entity_t ent, qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
aliasctx_t *actx = ctx->alias_context;
@ -181,7 +181,7 @@ Vulkan_DrawAlias (entity_t ent, qfv_renderframe_t *rFrame)
static void
alias_begin_subpass (QFV_AliasSubpass subpass, VkPipeline pipeline,
qfv_renderframe_t *rFrame)
qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;
@ -234,7 +234,7 @@ alias_end_subpass (VkCommandBuffer cmd, vulkan_ctx_t *ctx)
}
void
Vulkan_AliasBegin (qfv_renderframe_t *rFrame)
Vulkan_AliasBegin (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
aliasctx_t *actx = ctx->alias_context;
@ -251,7 +251,7 @@ Vulkan_AliasBegin (qfv_renderframe_t *rFrame)
}
void
Vulkan_AliasEnd (qfv_renderframe_t *rFrame)
Vulkan_AliasEnd (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
aliasctx_t *actx = ctx->alias_context;
@ -262,7 +262,7 @@ Vulkan_AliasEnd (qfv_renderframe_t *rFrame)
}
void
Vulkan_AliasDepthRange (qfv_renderframe_t *rFrame,
Vulkan_AliasDepthRange (qfv_orenderframe_t *rFrame,
float minDepth, float maxDepth)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
@ -321,7 +321,8 @@ Vulkan_Alias_Init (vulkan_ctx_t *ctx)
aliasctx_t *actx = calloc (1, sizeof (aliasctx_t));
ctx->alias_context = actx;
size_t frames = ctx->frames.size;
auto rctx = ctx->render_context;
size_t frames = rctx->frames.size;
DARRAY_INIT (&actx->frames, frames);
DARRAY_RESIZE (&actx->frames, frames);
actx->frames.grow = 0;

View File

@ -773,7 +773,7 @@ push_fragconst (bsp_push_constants_t *constants, VkPipelineLayout layout,
static void
bsp_begin_subpass (QFV_BspSubpass subpass, VkPipeline pipeline,
VkPipelineLayout layout, qfv_renderframe_t *rFrame)
VkPipelineLayout layout, qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;
@ -834,7 +834,7 @@ bsp_end_subpass (VkCommandBuffer cmd, vulkan_ctx_t *ctx)
}
static void
bsp_begin (qfv_renderframe_t *rFrame)
bsp_begin (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
bspctx_t *bctx = ctx->bsp_context;
@ -864,7 +864,7 @@ bsp_end (vulkan_ctx_t *ctx)
}
static void
turb_begin (qfv_renderframe_t *rFrame)
turb_begin (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
bspctx_t *bctx = ctx->bsp_context;
@ -889,7 +889,7 @@ turb_end (vulkan_ctx_t *ctx)
}
static void
sky_begin (qfv_renderframe_t *rFrame)
sky_begin (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
bspctx_t *bctx = ctx->bsp_context;
@ -1025,7 +1025,7 @@ ent_model_cmp (const void *_a, const void *_b)
}
void
Vulkan_DrawWorld (qfv_renderframe_t *rFrame)
Vulkan_DrawWorld (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;
@ -1127,7 +1127,7 @@ Vulkan_Bsp_Flush (vulkan_ctx_t *ctx)
}
void
Vulkan_DrawWaterSurfaces (qfv_renderframe_t *rFrame)
Vulkan_DrawWaterSurfaces (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;
@ -1163,7 +1163,7 @@ Vulkan_DrawWaterSurfaces (qfv_renderframe_t *rFrame)
}
void
Vulkan_DrawSky (qfv_renderframe_t *rFrame)
Vulkan_DrawSky (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;
@ -1450,7 +1450,8 @@ Vulkan_Bsp_Init (vulkan_ctx_t *ctx)
DARRAY_INIT (&bctx->main_pass.draw_queues[i], 64);
}
size_t frames = ctx->frames.size;
auto rctx = ctx->render_context;
size_t frames = rctx->frames.size;
DARRAY_INIT (&bctx->frames, frames);
DARRAY_RESIZE (&bctx->frames, frames);
bctx->frames.grow = 0;

View File

@ -58,7 +58,7 @@
#include "vid_vulkan.h"
void
Vulkan_Compose_Draw (qfv_renderframe_t *rFrame)
Vulkan_Compose_Draw (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;
@ -146,7 +146,8 @@ Vulkan_Compose_Init (vulkan_ctx_t *ctx)
composectx_t *cctx = calloc (1, sizeof (composectx_t));
ctx->compose_context = cctx;
size_t frames = ctx->frames.size;
auto rctx = ctx->render_context;
size_t frames = rctx->frames.size;
DARRAY_INIT (&cctx->frames, frames);
DARRAY_RESIZE (&cctx->frames, frames);
cctx->frames.grow = 0;

View File

@ -285,7 +285,8 @@ create_buffers (vulkan_ctx_t *ctx)
qfv_device_t *device = ctx->device;
qfv_devfuncs_t *dfunc = device->funcs;
drawctx_t *dctx = ctx->draw_context;
size_t frames = ctx->frames.size;
auto rctx = ctx->render_context;
size_t frames = rctx->frames.size;
dctx->draw_resource = malloc (2 * sizeof (qfv_resource_t)
// index buffer
@ -1030,7 +1031,8 @@ Vulkan_Draw_Init (vulkan_ctx_t *ctx)
drawctx_t *dctx = calloc (1, sizeof (drawctx_t));
ctx->draw_context = dctx;
size_t frames = ctx->frames.size;
auto rctx = ctx->render_context;
size_t frames = rctx->frames.size;
DARRAY_INIT (&dctx->frames, frames);
DARRAY_RESIZE (&dctx->frames, frames);
dctx->frames.grow = 0;

View File

@ -78,7 +78,7 @@ static void
emit_commands (VkCommandBuffer cmd, int pose1, int pose2,
qfv_iqm_skin_t *skins,
uint32_t numPC, qfv_push_constants_t *constants,
iqm_t *iqm, qfv_renderframe_t *rFrame, entity_t ent)
iqm_t *iqm, qfv_orenderframe_t *rFrame, entity_t ent)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;
@ -127,7 +127,7 @@ emit_commands (VkCommandBuffer cmd, int pose1, int pose2,
#define a(x) ((x) & ~0x3f)
void
Vulkan_DrawIQM (entity_t ent, qfv_renderframe_t *rFrame)
Vulkan_DrawIQM (entity_t ent, qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;
@ -207,7 +207,7 @@ Vulkan_DrawIQM (entity_t ent, qfv_renderframe_t *rFrame)
static void
iqm_begin_subpass (QFV_IQMSubpass subpass, VkPipeline pipeline,
qfv_renderframe_t *rFrame)
qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;
@ -258,7 +258,7 @@ iqm_end_subpass (VkCommandBuffer cmd, vulkan_ctx_t *ctx)
}
void
Vulkan_IQMBegin (qfv_renderframe_t *rFrame)
Vulkan_IQMBegin (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
iqmctx_t *ictx = ctx->iqm_context;
@ -275,7 +275,7 @@ Vulkan_IQMBegin (qfv_renderframe_t *rFrame)
}
void
Vulkan_IQMEnd (qfv_renderframe_t *rFrame)
Vulkan_IQMEnd (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
iqmctx_t *ictx = ctx->iqm_context;
@ -386,7 +386,8 @@ Vulkan_IQM_Init (vulkan_ctx_t *ctx)
iqmctx_t *ictx = calloc (1, sizeof (iqmctx_t));
ctx->iqm_context = ictx;
size_t frames = ctx->frames.size;
auto rctx = ctx->render_context;
size_t frames = rctx->frames.size;
DARRAY_INIT (&ictx->frames, frames);
DARRAY_RESIZE (&ictx->frames, frames);
ictx->frames.grow = 0;

View File

@ -148,7 +148,7 @@ update_lights (vulkan_ctx_t *ctx)
}
void
Vulkan_Lighting_Draw (qfv_renderframe_t *rFrame)
Vulkan_Lighting_Draw (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;
@ -220,7 +220,7 @@ Vulkan_Lighting_Draw (qfv_renderframe_t *rFrame)
}
static void
lighting_draw_maps (qfv_renderframe_t *rFrame)
lighting_draw_maps (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;
@ -361,7 +361,8 @@ Vulkan_Lighting_Init (vulkan_ctx_t *ctx)
DARRAY_INIT (&lctx->light_images, 16);
DARRAY_INIT (&lctx->light_renderers, 16);
size_t frames = ctx->frames.size;
auto rctx = ctx->render_context;
size_t frames = rctx->frames.size;
DARRAY_INIT (&lctx->frames, frames);
DARRAY_RESIZE (&lctx->frames, frames);
lctx->frames.grow = 0;

View File

@ -69,7 +69,7 @@
#include "vid_vulkan.h"
void
Vulkan_RenderEntities (entqueue_t *queue, qfv_renderframe_t *rFrame)
Vulkan_RenderEntities (entqueue_t *queue, qfv_orenderframe_t *rFrame)
{
if (!r_drawentities)
return;
@ -123,7 +123,7 @@ Vulkan_DrawViewModel (vulkan_ctx_t *ctx)
}
void
Vulkan_RenderView (qfv_renderframe_t *rFrame)
Vulkan_RenderView (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
@ -165,7 +165,7 @@ Vulkan_NewScene (scene_t *scene, vulkan_ctx_t *ctx)
}
static void
main_draw (qfv_renderframe_t *rFrame)
main_draw (qfv_orenderframe_t *rFrame)
{
Vulkan_RenderView (rFrame);
Vulkan_Lighting_Draw (rFrame);

View File

@ -238,7 +238,8 @@ Vulkan_Matrix_Init (vulkan_ctx_t *ctx)
matrixctx_t *mctx = calloc (1, sizeof (matrixctx_t));
ctx->matrix_context = mctx;
size_t frames = ctx->frames.size;
auto rctx = ctx->render_context;
size_t frames = rctx->frames.size;
DARRAY_INIT (&mctx->frames, frames);
DARRAY_RESIZE (&mctx->frames, frames);
mctx->frames.grow = 0;

View File

@ -63,12 +63,12 @@
#include "vkparse.h"//FIXME
static void
preoutput_draw (qfv_renderframe_t *rFrame)
preoutput_draw (qfv_orenderframe_t *rFrame)
{
}
static void
process_input (qfv_renderframe_t *rFrame)
process_input (qfv_orenderframe_t *rFrame)
{
return;
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
@ -143,7 +143,7 @@ process_input (qfv_renderframe_t *rFrame)
}
static void
draw_output (qfv_renderframe_t *rFrame)
draw_output (qfv_orenderframe_t *rFrame)
{
process_input (rFrame);
}
@ -181,7 +181,8 @@ acquire_output (const exprval_t **params, exprval_t *result, exprctx_t *ectx)
auto ctx = taskctx->ctx;
auto device = ctx->device;
auto dfunc = device->funcs;
auto frame = &ctx->frames.a[ctx->curFrame];
auto rctx = ctx->render_context;
auto frame = &rctx->frames.a[ctx->curFrame];
auto octx = ctx->output_context;
auto sc = ctx->swapchain;
@ -321,7 +322,8 @@ Vulkan_Output_Init (vulkan_ctx_t *ctx)
outputctx_t *octx = ctx->output_context;
size_t frames = ctx->frames.size;
auto rctx = ctx->render_context;
size_t frames = rctx->frames.size;
DARRAY_INIT (&octx->frames, frames);
DARRAY_RESIZE (&octx->frames, frames);
octx->frames.grow = 0;

View File

@ -72,7 +72,7 @@ static const char * __attribute__((used)) particle_pass_names[] = {
};
static void
particle_begin_subpass (VkPipeline pipeline, qfv_renderframe_t *rFrame)
particle_begin_subpass (VkPipeline pipeline, qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;
@ -121,7 +121,7 @@ particle_end_subpass (VkCommandBuffer cmd, vulkan_ctx_t *ctx)
}
void
Vulkan_DrawParticles (qfv_renderframe_t *rFrame)
Vulkan_DrawParticles (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;
@ -187,7 +187,8 @@ create_buffers (vulkan_ctx_t *ctx)
qfv_devfuncs_t *dfunc = device->funcs;
particlectx_t *pctx = ctx->particle_context;
size_t mp = MaxParticles;
size_t frames = ctx->frames.size;
auto rctx = ctx->render_context;
size_t frames = rctx->frames.size;
pctx->resources = malloc (sizeof (qfv_resource_t)
// states buffer
@ -417,7 +418,8 @@ Vulkan_Particles_Init (vulkan_ctx_t *ctx)
ctx->particle_context = pctx;
pctx->psystem = &r_psystem;
size_t frames = ctx->frames.size;
auto rctx = ctx->render_context;
size_t frames = rctx->frames.size;
DARRAY_INIT (&pctx->frames, frames);
DARRAY_RESIZE (&pctx->frames, frames);
pctx->frames.grow = 0;
@ -481,7 +483,7 @@ Vulkan_Particles_Shutdown (vulkan_ctx_t *ctx)
qfv_device_t *device = ctx->device;
qfv_devfuncs_t *dfunc = device->funcs;
particlectx_t *pctx = ctx->particle_context;
size_t frames = ctx->frames.size;
size_t frames = pctx->frames.size;
for (size_t i = 0; i < frames; i++) {
__auto_type pframe = &pctx->frames.a[i];
@ -507,7 +509,7 @@ Vulkan_ParticleSystem (vulkan_ctx_t *ctx)
}
static void
particles_update (qfv_renderframe_t *rFrame)
particles_update (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;

View File

@ -257,7 +257,7 @@ QFV_RenderPass_CreateFramebuffer (qfv_orenderpass_t *renderpass)
static void
init_renderframe (vulkan_ctx_t *ctx, qfv_orenderpass_t *rp,
qfv_renderframe_t *rFrame)
qfv_orenderframe_t *rFrame)
{
rFrame->vulkan_ctx = ctx;
rFrame->renderpass = rp;
@ -353,7 +353,7 @@ QFV_RenderPass_New (vulkan_ctx_t *ctx, const char *name, qfv_draw_t function)
}
DARRAY_INIT (&rp->frames, 4);
DARRAY_RESIZE (&rp->frames, ctx->frames.size);
//DARRAY_RESIZE (&rp->frames, ctx->frames.size);
for (size_t i = 0; i < rp->frames.size; i++) {
init_renderframe (ctx, rp, &rp->frames.a[i]);
}

View File

@ -44,6 +44,7 @@
#include "QF/Vulkan/descriptor.h"
#include "QF/Vulkan/device.h"
#include "QF/Vulkan/instance.h"
#include "QF/Vulkan/render.h"
#include "QF/Vulkan/resource.h"
#include "r_internal.h"
@ -143,7 +144,8 @@ Vulkan_Scene_Init (vulkan_ctx_t *ctx)
ctx->scene_context = sctx;
sctx->max_entities = qfv_max_entities;
size_t frames = ctx->frames.size;
auto rctx = ctx->render_context;
size_t frames = rctx->frames.size;
DARRAY_INIT (&sctx->frames, frames);
DARRAY_RESIZE (&sctx->frames, frames);
sctx->frames.grow = 0;

View File

@ -83,7 +83,7 @@ static QFV_Subpass subpass_map[] = {
static void
emit_commands (VkCommandBuffer cmd, qfv_sprite_t *sprite,
int numPC, qfv_push_constants_t *constants,
qfv_renderframe_t *rFrame, entity_t ent)
qfv_orenderframe_t *rFrame, entity_t ent)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;
@ -104,7 +104,7 @@ emit_commands (VkCommandBuffer cmd, qfv_sprite_t *sprite,
}
void
Vulkan_DrawSprite (entity_t ent, qfv_renderframe_t *rFrame)
Vulkan_DrawSprite (entity_t ent, qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
spritectx_t *sctx = ctx->sprite_context;
@ -142,7 +142,7 @@ Vulkan_DrawSprite (entity_t ent, qfv_renderframe_t *rFrame)
static void
sprite_begin_subpass (QFV_SpriteSubpass subpass, VkPipeline pipeline,
qfv_renderframe_t *rFrame)
qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;
@ -193,7 +193,7 @@ sprite_end_subpass (VkCommandBuffer cmd, vulkan_ctx_t *ctx)
}
void
Vulkan_SpriteBegin (qfv_renderframe_t *rFrame)
Vulkan_SpriteBegin (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
spritectx_t *sctx = ctx->sprite_context;
@ -210,7 +210,7 @@ Vulkan_SpriteBegin (qfv_renderframe_t *rFrame)
}
void
Vulkan_SpriteEnd (qfv_renderframe_t *rFrame)
Vulkan_SpriteEnd (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
spritectx_t *sctx = ctx->sprite_context;
@ -310,7 +310,8 @@ Vulkan_Sprite_Init (vulkan_ctx_t *ctx)
spritectx_t *sctx = calloc (1, sizeof (spritectx_t));
ctx->sprite_context = sctx;
size_t frames = ctx->frames.size;
auto rctx = ctx->render_context;
size_t frames = rctx->frames.size;
DARRAY_INIT (&sctx->frames, frames);
DARRAY_RESIZE (&sctx->frames, frames);
sctx->frames.grow = 0;

View File

@ -143,7 +143,8 @@ Vulkan_Translucent_Init (vulkan_ctx_t *ctx)
translucentctx_t *tctx = calloc (1, sizeof (translucentctx_t));
ctx->translucent_context = tctx;
size_t frames = ctx->frames.size;
auto rctx = ctx->render_context;
size_t frames = rctx->frames.size;
DARRAY_INIT (&tctx->frames, frames);
DARRAY_RESIZE (&tctx->frames, frames);
tctx->frames.grow = 0;
@ -211,7 +212,7 @@ Vulkan_Translucent_CreateBuffers (vulkan_ctx_t *ctx, VkExtent2D extent)
qfv_device_t *device = ctx->device;
qfv_devfuncs_t *dfunc = device->funcs;
__auto_type tctx = ctx->translucent_context;
size_t frames = ctx->frames.size;
size_t frames = tctx->frames.size;
if (tctx->resources) {
QFV_DestroyResource (device, tctx->resources);
@ -314,7 +315,7 @@ Vulkan_Translucent_CreateBuffers (vulkan_ctx_t *ctx, VkExtent2D extent)
}
static void
translucent_clear (qfv_renderframe_t *rFrame)
translucent_clear (qfv_orenderframe_t *rFrame)
{
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
qfv_device_t *device = ctx->device;

View File

@ -125,9 +125,6 @@ Vulkan_Shutdown_Common (vulkan_ctx_t *ctx)
if (ctx->capture) {
QFV_DestroyCapture (ctx->capture);
}
if (ctx->frames.size) {
Vulkan_DestroyFrames (ctx);
}
if (ctx->swapchain) {
QFV_DestroySwapchain (ctx->swapchain);
}
@ -216,58 +213,15 @@ Vulkan_DestroyRenderPasses (vulkan_ctx_t *ctx)
}
}
void
Vulkan_CreateFrames (vulkan_ctx_t *ctx)
{
qfv_device_t *device = ctx->device;
VkCommandPool cmdpool = ctx->cmdpool;
if (!ctx->frames.grow) {
DARRAY_INIT (&ctx->frames, 4);
}
DARRAY_RESIZE (&ctx->frames, vulkan_frame_count);
__auto_type cmdBuffers = QFV_AllocCommandBufferSet (ctx->frames.size,
alloca);
QFV_AllocateCommandBuffers (device, cmdpool, 0, cmdBuffers);
for (size_t i = 0; i < ctx->frames.size; i++) {
__auto_type frame = &ctx->frames.a[i];
frame->fence = QFV_CreateFence (device, 1);
frame->imageAvailableSemaphore = QFV_CreateSemaphore (device);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_SEMAPHORE,
frame->imageAvailableSemaphore,
va (ctx->va_ctx, "sc image:%zd", i));
frame->renderDoneSemaphore = QFV_CreateSemaphore (device);
frame->cmdBuffer = cmdBuffers->a[i];
}
}
void
Vulkan_CreateCapture (vulkan_ctx_t *ctx)
{
ctx->capture = QFV_CreateCapture (ctx->device, ctx->frames.size,
//FIXME this should be in render
auto rctx = ctx->render_context;
ctx->capture = QFV_CreateCapture (ctx->device, rctx->frames.size,
ctx->swapchain, ctx->cmdpool);
}
void
Vulkan_DestroyFrames (vulkan_ctx_t *ctx)
{
qfv_device_t *device = ctx->device;
qfv_devfuncs_t *df = device->funcs;
VkDevice dev = device->dev;
for (size_t i = 0; i < ctx->frames.size; i++) {
__auto_type frame = &ctx->frames.a[i];
df->vkDestroyFence (dev, frame->fence, 0);
df->vkDestroySemaphore (dev, frame->imageAvailableSemaphore, 0);
df->vkDestroySemaphore (dev, frame->renderDoneSemaphore, 0);
}
DARRAY_CLEAR (&ctx->frames);
}
void
Vulkan_BeginEntityLabel (vulkan_ctx_t *ctx, VkCommandBuffer cmd, entity_t ent)
{