2021-01-26 11:58:24 +00:00
|
|
|
/*
|
|
|
|
vulkan_alias.c
|
|
|
|
|
|
|
|
Vulkan alias model pipeline
|
|
|
|
|
|
|
|
Copyright (C) 2012 Bill Currie <bill@taniwha.org>
|
|
|
|
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
|
|
|
|
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2012/1/7
|
|
|
|
Date: 2021/1/26
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2022-03-30 06:54:07 +00:00
|
|
|
#include <string.h>
|
2021-01-26 11:58:24 +00:00
|
|
|
|
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/va.h"
|
|
|
|
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
#include "QF/scene/component.h"
|
2021-07-24 05:19:52 +00:00
|
|
|
#include "QF/scene/entity.h"
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
#include "QF/scene/scene.h"
|
2021-07-24 05:19:52 +00:00
|
|
|
|
2021-01-26 11:58:24 +00:00
|
|
|
#include "QF/Vulkan/qf_alias.h"
|
2021-12-08 15:25:50 +00:00
|
|
|
#include "QF/Vulkan/qf_matrices.h"
|
2022-05-30 03:10:00 +00:00
|
|
|
#include "QF/Vulkan/qf_renderpass.h"
|
2021-01-26 11:58:24 +00:00
|
|
|
#include "QF/Vulkan/qf_texture.h"
|
2021-01-31 10:58:55 +00:00
|
|
|
#include "QF/Vulkan/debug.h"
|
2021-01-26 11:58:24 +00:00
|
|
|
#include "QF/Vulkan/device.h"
|
2021-12-02 13:48:50 +00:00
|
|
|
#include "QF/Vulkan/instance.h"
|
2021-01-26 11:58:24 +00:00
|
|
|
|
|
|
|
#include "r_internal.h"
|
|
|
|
#include "vid_vulkan.h"
|
|
|
|
|
2021-12-17 07:46:54 +00:00
|
|
|
typedef struct {
|
|
|
|
mat4f_t mat;
|
|
|
|
float blend;
|
|
|
|
byte colorA[4];
|
|
|
|
byte colorB[4];
|
|
|
|
vec4f_t base_color;
|
|
|
|
vec4f_t fog;
|
|
|
|
} alias_push_constants_t;
|
|
|
|
|
2021-04-01 23:48:11 +00:00
|
|
|
static const char * __attribute__((used)) alias_pass_names[] = {
|
2021-02-14 02:35:06 +00:00
|
|
|
"depth",
|
|
|
|
"g-buffer",
|
|
|
|
"translucent",
|
|
|
|
};
|
|
|
|
|
2021-03-23 02:26:24 +00:00
|
|
|
static QFV_Subpass subpass_map[] = {
|
|
|
|
QFV_passDepth, // QFV_aliasDepth
|
|
|
|
QFV_passGBuffer, // QFV_aliasGBuffer
|
|
|
|
QFV_passTranslucent, // QFV_aliasTranslucent
|
|
|
|
};
|
|
|
|
|
2021-02-14 02:35:06 +00:00
|
|
|
static void
|
|
|
|
emit_commands (VkCommandBuffer cmd, int pose1, int pose2,
|
|
|
|
qfv_alias_skin_t *skin,
|
2021-12-17 07:46:54 +00:00
|
|
|
uint32_t numPC, qfv_push_constants_t *constants,
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
aliashdr_t *hdr, qfv_renderframe_t *rFrame, entity_t ent)
|
2021-01-26 11:58:24 +00:00
|
|
|
{
|
2021-12-02 12:58:29 +00:00
|
|
|
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
|
2021-01-26 11:58:24 +00:00
|
|
|
qfv_device_t *device = ctx->device;
|
|
|
|
qfv_devfuncs_t *dfunc = device->funcs;
|
|
|
|
aliasctx_t *actx = ctx->alias_context;
|
2021-02-14 02:35:06 +00:00
|
|
|
|
|
|
|
__auto_type mesh = (qfv_alias_mesh_t *) ((byte *) hdr + hdr->commands);
|
|
|
|
|
|
|
|
VkDeviceSize offsets[] = {
|
|
|
|
pose1 * hdr->poseverts * sizeof (aliasvrt_t),
|
|
|
|
pose2 * hdr->poseverts * sizeof (aliasvrt_t),
|
|
|
|
0,
|
|
|
|
};
|
|
|
|
VkBuffer buffers[] = {
|
|
|
|
mesh->vertex_buffer,
|
|
|
|
mesh->vertex_buffer,
|
|
|
|
mesh->uv_buffer,
|
|
|
|
};
|
|
|
|
int bindingCount = skin ? 3 : 2;
|
|
|
|
|
2022-05-07 05:12:02 +00:00
|
|
|
Vulkan_BeginEntityLabel (ctx, cmd, ent);
|
|
|
|
|
2021-02-14 02:35:06 +00:00
|
|
|
dfunc->vkCmdBindVertexBuffers (cmd, 0, bindingCount, buffers, offsets);
|
|
|
|
dfunc->vkCmdBindIndexBuffer (cmd, mesh->index_buffer, 0,
|
|
|
|
VK_INDEX_TYPE_UINT32);
|
2021-12-17 07:46:54 +00:00
|
|
|
QFV_PushConstants (device, cmd, actx->layout, numPC, constants);
|
2021-02-14 02:35:06 +00:00
|
|
|
if (skin) {
|
2021-12-17 03:20:32 +00:00
|
|
|
VkDescriptorSet sets[] = {
|
|
|
|
skin->descriptor,
|
|
|
|
};
|
|
|
|
dfunc->vkCmdBindDescriptorSets (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS,
|
|
|
|
actx->layout, 1, 1, sets, 0, 0);
|
2021-02-14 02:35:06 +00:00
|
|
|
}
|
|
|
|
dfunc->vkCmdDrawIndexed (cmd, 3 * hdr->mdl.numtris, 1, 0, 0, 0);
|
2022-05-07 05:12:02 +00:00
|
|
|
|
|
|
|
QFV_CmdEndLabel (device, cmd);
|
2021-02-14 02:35:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
Vulkan_DrawAlias (entity_t ent, qfv_renderframe_t *rFrame)
|
2021-02-14 02:35:06 +00:00
|
|
|
{
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
transform_t transform = Entity_Transform (ent);
|
|
|
|
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
|
|
|
r_refdef.scene->reg);
|
|
|
|
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
|
|
|
r_refdef.scene->reg);
|
2021-12-02 12:58:29 +00:00
|
|
|
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
|
2021-02-14 02:35:06 +00:00
|
|
|
aliasctx_t *actx = ctx->alias_context;
|
|
|
|
aliasframe_t *aframe = &actx->frames.a[ctx->curFrame];
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
model_t *model = renderer->model;
|
2021-01-26 11:58:24 +00:00
|
|
|
aliashdr_t *hdr;
|
2021-02-02 10:53:36 +00:00
|
|
|
qfv_alias_skin_t *skin;
|
2021-12-17 07:46:54 +00:00
|
|
|
alias_push_constants_t constants = {};
|
2021-01-26 11:58:24 +00:00
|
|
|
|
|
|
|
if (!(hdr = model->aliashdr)) {
|
|
|
|
hdr = Cache_Get (&model->cache);
|
|
|
|
}
|
|
|
|
|
2021-12-17 07:46:54 +00:00
|
|
|
constants.blend = R_AliasGetLerpedFrames (animation, hdr);
|
|
|
|
|
|
|
|
qfv_push_constants_t push_constants[] = {
|
|
|
|
{ VK_SHADER_STAGE_VERTEX_BIT,
|
|
|
|
field_offset (alias_push_constants_t, mat),
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
sizeof (mat4f_t), Transform_GetWorldMatrixPtr (transform) },
|
2021-12-17 07:46:54 +00:00
|
|
|
{ VK_SHADER_STAGE_VERTEX_BIT,
|
|
|
|
field_offset (alias_push_constants_t, blend),
|
|
|
|
sizeof (float), &constants.blend },
|
|
|
|
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
|
|
|
field_offset (alias_push_constants_t, colorA),
|
|
|
|
sizeof (constants.colorA), constants.colorA },
|
|
|
|
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
|
|
|
field_offset (alias_push_constants_t, colorB),
|
|
|
|
sizeof (constants.colorB), constants.colorB },
|
|
|
|
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
|
|
|
field_offset (alias_push_constants_t, base_color),
|
|
|
|
sizeof (constants.base_color), &constants.base_color },
|
|
|
|
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
|
|
|
field_offset (alias_push_constants_t, fog),
|
|
|
|
sizeof (constants.fog), &constants.fog },
|
|
|
|
};
|
2021-01-26 11:58:24 +00:00
|
|
|
|
|
|
|
if (0/*XXX ent->skin && ent->skin->tex*/) {
|
|
|
|
//skin = ent->skin->tex;
|
|
|
|
} else {
|
|
|
|
maliasskindesc_t *skindesc;
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
skindesc = R_AliasGetSkindesc (animation, renderer->skinnum, hdr);
|
2021-02-02 10:53:36 +00:00
|
|
|
skin = (qfv_alias_skin_t *) ((byte *) hdr + skindesc->skin);
|
2021-01-26 11:58:24 +00:00
|
|
|
}
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
QuatCopy (renderer->colormod, constants.base_color);
|
2021-12-17 07:46:54 +00:00
|
|
|
QuatCopy (skin->colora, constants.colorA);
|
|
|
|
QuatCopy (skin->colorb, constants.colorB);
|
|
|
|
QuatZero (constants.fog);
|
2021-01-26 11:58:24 +00:00
|
|
|
|
2021-03-09 14:52:40 +00:00
|
|
|
emit_commands (aframe->cmdSet.a[QFV_aliasDepth],
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
animation->pose1, animation->pose2,
|
2022-05-07 05:12:02 +00:00
|
|
|
0, 2, push_constants, hdr, rFrame, ent);
|
2021-03-09 14:52:40 +00:00
|
|
|
emit_commands (aframe->cmdSet.a[QFV_aliasGBuffer],
|
[scene] Make entity_t just an entity id for ECS
This puts the hierarchy (transform) reference, animation, visibility,
renderer, active, and old_origin data in separate components. There are
a few bugs (crashes on grenade explosions in gl/glsl/vulkan, immediately
in sw, reasons known, missing brush models in vulkan).
While quake doesn't really need an ECS, the direction I want to take QF
does, and it does seem to have improved memory bandwidth a little
(uncertain). However, there's a lot more work to go (especially fixing
the above bugs), but this seems to be a good start.
2022-10-23 01:32:09 +00:00
|
|
|
animation->pose1, animation->pose2,
|
2022-05-07 05:12:02 +00:00
|
|
|
skin, 6, push_constants, hdr, rFrame, ent);
|
2021-01-26 11:58:24 +00:00
|
|
|
}
|
|
|
|
|
2021-01-28 10:17:40 +00:00
|
|
|
static void
|
2021-02-19 02:14:54 +00:00
|
|
|
alias_begin_subpass (QFV_AliasSubpass subpass, VkPipeline pipeline,
|
2021-12-02 12:58:29 +00:00
|
|
|
qfv_renderframe_t *rFrame)
|
2021-01-26 11:58:24 +00:00
|
|
|
{
|
2021-12-02 12:58:29 +00:00
|
|
|
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
|
2021-01-26 11:58:24 +00:00
|
|
|
qfv_device_t *device = ctx->device;
|
|
|
|
qfv_devfuncs_t *dfunc = device->funcs;
|
|
|
|
aliasctx_t *actx = ctx->alias_context;
|
2021-02-05 01:22:32 +00:00
|
|
|
__auto_type cframe = &ctx->frames.a[ctx->curFrame];
|
2021-01-26 11:58:24 +00:00
|
|
|
aliasframe_t *aframe = &actx->frames.a[ctx->curFrame];
|
2021-02-19 02:14:54 +00:00
|
|
|
VkCommandBuffer cmd = aframe->cmdSet.a[subpass];
|
2021-01-26 11:58:24 +00:00
|
|
|
|
|
|
|
dfunc->vkResetCommandBuffer (cmd, 0);
|
|
|
|
VkCommandBufferInheritanceInfo inherit = {
|
|
|
|
VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, 0,
|
2021-12-02 12:58:29 +00:00
|
|
|
rFrame->renderpass->renderpass, subpass_map[subpass],
|
2021-01-26 11:58:24 +00:00
|
|
|
cframe->framebuffer,
|
|
|
|
0, 0, 0,
|
|
|
|
};
|
|
|
|
VkCommandBufferBeginInfo beginInfo = {
|
|
|
|
VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, 0,
|
|
|
|
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
|
|
|
|
| VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, &inherit,
|
|
|
|
};
|
|
|
|
dfunc->vkBeginCommandBuffer (cmd, &beginInfo);
|
|
|
|
|
2021-04-18 11:40:43 +00:00
|
|
|
QFV_duCmdBeginLabel (device, cmd, va (ctx->va_ctx, "alias:%s",
|
|
|
|
alias_pass_names[subpass]),
|
|
|
|
{ 0.6, 0.5, 0, 1});
|
|
|
|
|
2021-02-24 10:58:31 +00:00
|
|
|
dfunc->vkCmdBindPipeline (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
2021-12-08 15:25:50 +00:00
|
|
|
VkDescriptorSet sets[] = {
|
2021-12-13 01:39:01 +00:00
|
|
|
Vulkan_Matrix_Descriptors (ctx, ctx->curFrame),
|
2021-12-08 15:25:50 +00:00
|
|
|
};
|
|
|
|
dfunc->vkCmdBindDescriptorSets (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS,
|
2021-12-17 03:20:32 +00:00
|
|
|
actx->layout, 0, 1, sets, 0, 0);
|
2022-04-01 11:34:41 +00:00
|
|
|
dfunc->vkCmdSetViewport (cmd, 0, 1, &rFrame->renderpass->viewport);
|
|
|
|
dfunc->vkCmdSetScissor (cmd, 0, 1, &rFrame->renderpass->scissor);
|
2021-01-26 11:58:24 +00:00
|
|
|
|
|
|
|
//XXX glsl_Fog_GetColor (fog);
|
|
|
|
//XXX fog[3] = glsl_Fog_GetDensity () / 64.0;
|
|
|
|
}
|
|
|
|
|
2021-02-14 02:35:06 +00:00
|
|
|
static void
|
|
|
|
alias_end_subpass (VkCommandBuffer cmd, vulkan_ctx_t *ctx)
|
2021-01-26 11:58:24 +00:00
|
|
|
{
|
|
|
|
qfv_device_t *device = ctx->device;
|
|
|
|
qfv_devfuncs_t *dfunc = device->funcs;
|
2021-02-14 02:35:06 +00:00
|
|
|
|
2021-04-18 11:40:43 +00:00
|
|
|
QFV_duCmdEndLabel (device, cmd);
|
2021-02-14 02:35:06 +00:00
|
|
|
dfunc->vkEndCommandBuffer (cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-02 12:58:29 +00:00
|
|
|
Vulkan_AliasBegin (qfv_renderframe_t *rFrame)
|
2021-02-14 02:35:06 +00:00
|
|
|
{
|
2021-12-02 12:58:29 +00:00
|
|
|
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
|
2021-01-26 11:58:24 +00:00
|
|
|
aliasctx_t *actx = ctx->alias_context;
|
2021-02-14 02:35:06 +00:00
|
|
|
aliasframe_t *aframe = &actx->frames.a[ctx->curFrame];
|
|
|
|
|
|
|
|
//XXX quat_t fog;
|
2021-12-02 12:58:29 +00:00
|
|
|
DARRAY_APPEND (&rFrame->subpassCmdSets[QFV_passDepth],
|
2021-02-14 02:35:06 +00:00
|
|
|
aframe->cmdSet.a[QFV_aliasDepth]);
|
2021-12-02 12:58:29 +00:00
|
|
|
DARRAY_APPEND (&rFrame->subpassCmdSets[QFV_passGBuffer],
|
2021-02-14 02:35:06 +00:00
|
|
|
aframe->cmdSet.a[QFV_aliasGBuffer]);
|
|
|
|
|
2021-12-02 12:58:29 +00:00
|
|
|
alias_begin_subpass (QFV_aliasDepth, actx->depth, rFrame);
|
|
|
|
alias_begin_subpass (QFV_aliasGBuffer, actx->gbuf, rFrame);
|
2021-02-14 02:35:06 +00:00
|
|
|
}
|
2021-01-26 11:58:24 +00:00
|
|
|
|
2021-02-14 02:35:06 +00:00
|
|
|
void
|
2021-12-02 12:58:29 +00:00
|
|
|
Vulkan_AliasEnd (qfv_renderframe_t *rFrame)
|
2021-02-14 02:35:06 +00:00
|
|
|
{
|
2021-12-02 12:58:29 +00:00
|
|
|
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
|
2021-02-14 02:35:06 +00:00
|
|
|
aliasctx_t *actx = ctx->alias_context;
|
2021-01-26 11:58:24 +00:00
|
|
|
aliasframe_t *aframe = &actx->frames.a[ctx->curFrame];
|
2021-02-14 02:35:06 +00:00
|
|
|
|
|
|
|
alias_end_subpass (aframe->cmdSet.a[QFV_aliasDepth], ctx);
|
|
|
|
alias_end_subpass (aframe->cmdSet.a[QFV_aliasGBuffer], ctx);
|
2021-01-26 11:58:24 +00:00
|
|
|
}
|
|
|
|
|
2021-07-25 05:03:25 +00:00
|
|
|
void
|
2021-12-02 12:58:29 +00:00
|
|
|
Vulkan_AliasDepthRange (qfv_renderframe_t *rFrame,
|
|
|
|
float minDepth, float maxDepth)
|
2021-07-25 05:03:25 +00:00
|
|
|
{
|
2021-12-02 12:58:29 +00:00
|
|
|
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
|
2021-07-25 05:03:25 +00:00
|
|
|
qfv_device_t *device = ctx->device;
|
|
|
|
qfv_devfuncs_t *dfunc = device->funcs;
|
|
|
|
aliasctx_t *actx = ctx->alias_context;
|
|
|
|
aliasframe_t *aframe = &actx->frames.a[ctx->curFrame];
|
|
|
|
|
2022-04-01 11:34:41 +00:00
|
|
|
VkViewport viewport = rFrame->renderpass->viewport;
|
2021-07-25 05:03:25 +00:00
|
|
|
viewport.minDepth = minDepth;
|
|
|
|
viewport.maxDepth = maxDepth;
|
|
|
|
|
|
|
|
dfunc->vkCmdSetViewport (aframe->cmdSet.a[QFV_aliasDepth], 0, 1,
|
|
|
|
&viewport);
|
|
|
|
dfunc->vkCmdSetViewport (aframe->cmdSet.a[QFV_aliasGBuffer], 0, 1,
|
|
|
|
&viewport);
|
|
|
|
}
|
|
|
|
|
2021-12-08 15:25:50 +00:00
|
|
|
void
|
|
|
|
Vulkan_AliasAddSkin (vulkan_ctx_t *ctx, qfv_alias_skin_t *skin)
|
|
|
|
{
|
|
|
|
aliasctx_t *actx = ctx->alias_context;
|
2021-12-17 03:20:32 +00:00
|
|
|
skin->descriptor = Vulkan_CreateCombinedImageSampler (ctx, skin->view,
|
|
|
|
actx->sampler);
|
2021-12-08 15:25:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Vulkan_AliasRemoveSkin (vulkan_ctx_t *ctx, qfv_alias_skin_t *skin)
|
|
|
|
{
|
2021-12-17 03:20:32 +00:00
|
|
|
Vulkan_FreeTexture (ctx, skin->descriptor);
|
|
|
|
skin->descriptor = 0;
|
2021-12-08 15:25:50 +00:00
|
|
|
}
|
|
|
|
|
2021-01-26 11:58:24 +00:00
|
|
|
void
|
|
|
|
Vulkan_Alias_Init (vulkan_ctx_t *ctx)
|
|
|
|
{
|
|
|
|
qfv_device_t *device = ctx->device;
|
|
|
|
|
2021-12-02 13:48:50 +00:00
|
|
|
qfvPushDebug (ctx, "alias init");
|
|
|
|
|
2021-01-26 11:58:24 +00:00
|
|
|
aliasctx_t *actx = calloc (1, sizeof (aliasctx_t));
|
|
|
|
ctx->alias_context = actx;
|
|
|
|
|
2021-02-05 01:22:32 +00:00
|
|
|
size_t frames = ctx->frames.size;
|
2021-01-26 11:58:24 +00:00
|
|
|
DARRAY_INIT (&actx->frames, frames);
|
|
|
|
DARRAY_RESIZE (&actx->frames, frames);
|
|
|
|
actx->frames.grow = 0;
|
|
|
|
|
2021-12-16 14:00:17 +00:00
|
|
|
actx->depth = Vulkan_CreateGraphicsPipeline (ctx, "alias_depth");
|
|
|
|
actx->gbuf = Vulkan_CreateGraphicsPipeline (ctx, "alias_gbuf");
|
2021-02-04 08:03:49 +00:00
|
|
|
actx->layout = Vulkan_CreatePipelineLayout (ctx, "alias_layout");
|
|
|
|
actx->sampler = Vulkan_CreateSampler (ctx, "alias_sampler");
|
2021-01-26 11:58:24 +00:00
|
|
|
|
|
|
|
for (size_t i = 0; i < frames; i++) {
|
|
|
|
__auto_type aframe = &actx->frames.a[i];
|
|
|
|
|
2021-02-14 02:35:06 +00:00
|
|
|
DARRAY_INIT (&aframe->cmdSet, QFV_aliasNumPasses);
|
|
|
|
DARRAY_RESIZE (&aframe->cmdSet, QFV_aliasNumPasses);
|
|
|
|
aframe->cmdSet.grow = 0;
|
|
|
|
|
|
|
|
QFV_AllocateCommandBuffers (device, ctx->cmdpool, 1, &aframe->cmdSet);
|
|
|
|
|
|
|
|
for (int j = 0; j < QFV_aliasNumPasses; j++) {
|
|
|
|
QFV_duSetObjectName (device, VK_OBJECT_TYPE_COMMAND_BUFFER,
|
|
|
|
aframe->cmdSet.a[j],
|
|
|
|
va (ctx->va_ctx, "cmd:alias:%zd:%s", i,
|
|
|
|
alias_pass_names[j]));
|
|
|
|
}
|
2021-01-26 11:58:24 +00:00
|
|
|
}
|
2021-12-02 13:48:50 +00:00
|
|
|
qfvPopDebug (ctx);
|
2021-01-26 11:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-02-14 02:35:06 +00:00
|
|
|
Vulkan_Alias_Shutdown (vulkan_ctx_t *ctx)
|
2021-01-26 11:58:24 +00:00
|
|
|
{
|
|
|
|
qfv_device_t *device = ctx->device;
|
|
|
|
qfv_devfuncs_t *dfunc = device->funcs;
|
|
|
|
aliasctx_t *actx = ctx->alias_context;
|
|
|
|
|
2021-01-27 08:59:09 +00:00
|
|
|
for (size_t i = 0; i < actx->frames.size; i++) {
|
|
|
|
__auto_type aframe = &actx->frames.a[i];
|
2021-02-14 02:35:06 +00:00
|
|
|
free (aframe->cmdSet.a);
|
2021-01-27 08:59:09 +00:00
|
|
|
}
|
|
|
|
|
2021-02-14 02:35:06 +00:00
|
|
|
dfunc->vkDestroyPipeline (device->dev, actx->depth, 0);
|
|
|
|
dfunc->vkDestroyPipeline (device->dev, actx->gbuf, 0);
|
|
|
|
free (actx->frames.a);
|
2021-01-26 11:58:24 +00:00
|
|
|
free (actx);
|
|
|
|
}
|