mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 14:20:59 +00:00
[vulkan] Label renderpass and subpass sections
This makes finding the relevant commands in render doc much much easier.
This commit is contained in:
parent
8204e8a8c1
commit
c59ab8882d
6 changed files with 116 additions and 0 deletions
|
@ -1,6 +1,13 @@
|
||||||
#ifndef __QF_Vulkan_debug_h
|
#ifndef __QF_Vulkan_debug_h
|
||||||
#define __QF_Vulkan_debug_h
|
#define __QF_Vulkan_debug_h
|
||||||
|
|
||||||
|
#ifndef VK_NO_PROTOTYPES
|
||||||
|
#define VK_NO_PROTOTYPES
|
||||||
|
#endif
|
||||||
|
#include <vulkan/vulkan.h>
|
||||||
|
|
||||||
|
#include "QF/simd/types.h"
|
||||||
|
|
||||||
#if (defined(_WIN32) && !defined(_WIN64)) || (__WORDSIZE < 64)
|
#if (defined(_WIN32) && !defined(_WIN64)) || (__WORDSIZE < 64)
|
||||||
#define QFV_duCmdBeginLabel(device, cmd, name...)
|
#define QFV_duCmdBeginLabel(device, cmd, name...)
|
||||||
#define QFV_duCmdEndLabel(device, cmd)
|
#define QFV_duCmdEndLabel(device, cmd)
|
||||||
|
@ -126,4 +133,12 @@
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct qfv_device_s;
|
||||||
|
|
||||||
|
void QFV_CmdBeginLabel (struct qfv_device_s *device, VkCommandBuffer cmd,
|
||||||
|
const char *name, vec4f_t color);
|
||||||
|
void QFV_CmdEndLabel (struct qfv_device_s *device, VkCommandBuffer cmd);
|
||||||
|
void QFV_CmdInsertLabel (struct qfv_device_s *device, VkCommandBuffer cmd,
|
||||||
|
const char *name, vec4f_t color);
|
||||||
|
|
||||||
#endif//__QF_Vulkan_debug_h
|
#endif//__QF_Vulkan_debug_h
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __QF_Vulkan_renderpass_h
|
#define __QF_Vulkan_renderpass_h
|
||||||
|
|
||||||
#include "QF/darray.h"
|
#include "QF/darray.h"
|
||||||
|
#include "QF/simd/types.h"
|
||||||
|
|
||||||
typedef struct qfv_attachmentdescription_s
|
typedef struct qfv_attachmentdescription_s
|
||||||
DARRAY_TYPE (VkAttachmentDescription) qfv_attachmentdescription_t;
|
DARRAY_TYPE (VkAttachmentDescription) qfv_attachmentdescription_t;
|
||||||
|
@ -47,11 +48,17 @@ QFV_CreateFramebuffer (struct qfv_device_s *device,
|
||||||
struct qfv_imageviewset_s *attachments,
|
struct qfv_imageviewset_s *attachments,
|
||||||
VkExtent2D, uint32_t layers);
|
VkExtent2D, uint32_t layers);
|
||||||
|
|
||||||
|
typedef struct qfv_subpass_s {
|
||||||
|
vec4f_t color;
|
||||||
|
const char *name;
|
||||||
|
} qfv_subpass_t;
|
||||||
|
|
||||||
typedef struct qfv_renderframe_s {
|
typedef struct qfv_renderframe_s {
|
||||||
struct vulkan_ctx_s *vulkan_ctx;
|
struct vulkan_ctx_s *vulkan_ctx;
|
||||||
struct qfv_renderpass_s *renderpass;
|
struct qfv_renderpass_s *renderpass;
|
||||||
VkSubpassContents subpassContents;
|
VkSubpassContents subpassContents;
|
||||||
int subpassCount;
|
int subpassCount;
|
||||||
|
qfv_subpass_t *subpassInfo;
|
||||||
struct qfv_cmdbufferset_s *subpassCmdSets;
|
struct qfv_cmdbufferset_s *subpassCmdSets;
|
||||||
} qfv_renderframe_t;
|
} qfv_renderframe_t;
|
||||||
|
|
||||||
|
@ -62,6 +69,8 @@ typedef struct clearvalueset_s
|
||||||
DARRAY_TYPE (VkClearValue) clearvalueset_t;
|
DARRAY_TYPE (VkClearValue) clearvalueset_t;
|
||||||
|
|
||||||
typedef struct qfv_renderpass_s {
|
typedef struct qfv_renderpass_s {
|
||||||
|
vec4f_t color; // for bebugging
|
||||||
|
const char *name; // for bebugging
|
||||||
struct plitem_s *renderpassDef;
|
struct plitem_s *renderpassDef;
|
||||||
VkRenderPass renderpass;
|
VkRenderPass renderpass;
|
||||||
clearvalueset_t *clearValues;
|
clearvalueset_t *clearValues;
|
||||||
|
|
|
@ -201,6 +201,7 @@ libs_video_renderer_librender_vulkan_la_SOURCES = \
|
||||||
libs/video/renderer/vulkan/buffer.c \
|
libs/video/renderer/vulkan/buffer.c \
|
||||||
libs/video/renderer/vulkan/command.c \
|
libs/video/renderer/vulkan/command.c \
|
||||||
libs/video/renderer/vulkan/capture.c \
|
libs/video/renderer/vulkan/capture.c \
|
||||||
|
libs/video/renderer/vulkan/debug.c \
|
||||||
libs/video/renderer/vulkan/descriptor.c \
|
libs/video/renderer/vulkan/descriptor.c \
|
||||||
libs/video/renderer/vulkan/device.c \
|
libs/video/renderer/vulkan/device.c \
|
||||||
libs/video/renderer/vulkan/image.c \
|
libs/video/renderer/vulkan/image.c \
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
#include "QF/Vulkan/qf_vid.h"
|
#include "QF/Vulkan/qf_vid.h"
|
||||||
#include "QF/Vulkan/capture.h"
|
#include "QF/Vulkan/capture.h"
|
||||||
#include "QF/Vulkan/command.h"
|
#include "QF/Vulkan/command.h"
|
||||||
|
#include "QF/Vulkan/debug.h"
|
||||||
#include "QF/Vulkan/device.h"
|
#include "QF/Vulkan/device.h"
|
||||||
#include "QF/Vulkan/image.h"
|
#include "QF/Vulkan/image.h"
|
||||||
#include "QF/Vulkan/instance.h"
|
#include "QF/Vulkan/instance.h"
|
||||||
|
@ -348,6 +349,7 @@ vulkan_end_frame (void)
|
||||||
__auto_type rp = vulkan_ctx->renderPasses.a[i];
|
__auto_type rp = vulkan_ctx->renderPasses.a[i];
|
||||||
__auto_type rpFrame = &rp->frames.a[vulkan_ctx->curFrame];
|
__auto_type rpFrame = &rp->frames.a[vulkan_ctx->curFrame];
|
||||||
|
|
||||||
|
QFV_CmdBeginLabel (device, frame->cmdBuffer, rp->name, rp->color);
|
||||||
if (rpFrame->renderpass) {
|
if (rpFrame->renderpass) {
|
||||||
renderPassInfo.framebuffer = frame->framebuffer,
|
renderPassInfo.framebuffer = frame->framebuffer,
|
||||||
renderPassInfo.renderPass = rp->renderpass;
|
renderPassInfo.renderPass = rp->renderpass;
|
||||||
|
@ -360,8 +362,12 @@ vulkan_end_frame (void)
|
||||||
for (int j = 0; j < rpFrame->subpassCount; j++) {
|
for (int j = 0; j < rpFrame->subpassCount; j++) {
|
||||||
__auto_type cmdSet = &rpFrame->subpassCmdSets[j];
|
__auto_type cmdSet = &rpFrame->subpassCmdSets[j];
|
||||||
if (cmdSet->size) {
|
if (cmdSet->size) {
|
||||||
|
QFV_CmdBeginLabel (device, frame->cmdBuffer,
|
||||||
|
rpFrame->subpassInfo[j].name,
|
||||||
|
rpFrame->subpassInfo[j].color);
|
||||||
dfunc->vkCmdExecuteCommands (frame->cmdBuffer,
|
dfunc->vkCmdExecuteCommands (frame->cmdBuffer,
|
||||||
cmdSet->size, cmdSet->a);
|
cmdSet->size, cmdSet->a);
|
||||||
|
QFV_CmdEndLabel (device, frame->cmdBuffer);
|
||||||
}
|
}
|
||||||
// reset for next time around
|
// reset for next time around
|
||||||
cmdSet->size = 0;
|
cmdSet->size = 0;
|
||||||
|
@ -386,6 +392,7 @@ vulkan_end_frame (void)
|
||||||
cmdSet->size = 0;
|
cmdSet->size = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
QFV_CmdEndLabel (device, frame->cmdBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vulkan_ctx->capture_callback) {
|
if (vulkan_ctx->capture_callback) {
|
||||||
|
|
71
libs/video/renderer/vulkan/debug.c
Normal file
71
libs/video/renderer/vulkan/debug.c
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
debug.c
|
||||||
|
|
||||||
|
Vulkan debug support
|
||||||
|
|
||||||
|
Copyright (C) 2022 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
|
||||||
|
|
||||||
|
#include "QF/Vulkan/debug.h"
|
||||||
|
#include "QF/Vulkan/device.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
QFV_CmdBeginLabel (qfv_device_t *device, VkCommandBuffer cmd,
|
||||||
|
const char *name, vec4f_t color)
|
||||||
|
{
|
||||||
|
qfv_devfuncs_t *dfunc = device->funcs;
|
||||||
|
if (dfunc->vkCmdBeginDebugUtilsLabelEXT) {
|
||||||
|
VkDebugUtilsLabelEXT label = {
|
||||||
|
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, 0,
|
||||||
|
.pLabelName = name,
|
||||||
|
.color = { color[0], color[1], color[2], color[3] },
|
||||||
|
};
|
||||||
|
dfunc->vkCmdBeginDebugUtilsLabelEXT (cmd, &label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
QFV_CmdEndLabel (qfv_device_t *device, VkCommandBuffer cmd)
|
||||||
|
{
|
||||||
|
qfv_devfuncs_t *dfunc = device->funcs;
|
||||||
|
if (dfunc->vkCmdEndDebugUtilsLabelEXT) {
|
||||||
|
dfunc->vkCmdEndDebugUtilsLabelEXT (cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
QFV_CmdInsertLabel (qfv_device_t *device, VkCommandBuffer cmd,
|
||||||
|
const char *name, vec4f_t color)
|
||||||
|
{
|
||||||
|
qfv_devfuncs_t *dfunc = device->funcs;
|
||||||
|
if (dfunc->vkCmdBeginDebugUtilsLabelEXT) {
|
||||||
|
VkDebugUtilsLabelEXT label = {
|
||||||
|
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, 0,
|
||||||
|
.pLabelName = name,
|
||||||
|
.color = { color[0], color[1], color[2], color[3] },
|
||||||
|
};
|
||||||
|
dfunc->vkCmdInsertDebugUtilsLabelEXT (cmd, &label);
|
||||||
|
}
|
||||||
|
}
|
|
@ -480,10 +480,20 @@ static void
|
||||||
init_renderframe (vulkan_ctx_t *ctx, qfv_renderpass_t *rp,
|
init_renderframe (vulkan_ctx_t *ctx, qfv_renderpass_t *rp,
|
||||||
qfv_renderframe_t *rFrame)
|
qfv_renderframe_t *rFrame)
|
||||||
{
|
{
|
||||||
|
// FIXME should not be hard-coded
|
||||||
|
static qfv_subpass_t subpass_info[] = {
|
||||||
|
{ .name = "depth", .color = { 0.5, 0.5, 0.5, 1} },
|
||||||
|
{ .name = "translucent", .color = { 0.25, 0.25, 0.6, 1} },
|
||||||
|
{ .name = "g-buffef", .color = { 0.3, 0.7, 0.3, 1} },
|
||||||
|
{ .name = "lighting", .color = { 0.8, 0.8, 0.8, 1} },
|
||||||
|
{ .name = "compose", .color = { 0.7, 0.3, 0.3, 1} },
|
||||||
|
};
|
||||||
|
|
||||||
rFrame->subpassContents = VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS;
|
rFrame->subpassContents = VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS;
|
||||||
rFrame->vulkan_ctx = ctx;
|
rFrame->vulkan_ctx = ctx;
|
||||||
rFrame->renderpass = rp;
|
rFrame->renderpass = rp;
|
||||||
rFrame->subpassCount = QFV_NumPasses;
|
rFrame->subpassCount = QFV_NumPasses;
|
||||||
|
rFrame->subpassInfo = subpass_info; //FIXME
|
||||||
rFrame->subpassCmdSets = malloc (QFV_NumPasses
|
rFrame->subpassCmdSets = malloc (QFV_NumPasses
|
||||||
* sizeof (qfv_cmdbufferset_t));
|
* sizeof (qfv_cmdbufferset_t));
|
||||||
for (int j = 0; j < QFV_NumPasses; j++) {
|
for (int j = 0; j < QFV_NumPasses; j++) {
|
||||||
|
@ -499,6 +509,9 @@ Vulkan_CreateRenderPass (vulkan_ctx_t *ctx)
|
||||||
|
|
||||||
qfv_renderpass_t *rp = calloc (1, sizeof (qfv_renderpass_t));
|
qfv_renderpass_t *rp = calloc (1, sizeof (qfv_renderpass_t));
|
||||||
|
|
||||||
|
rp->name = name;
|
||||||
|
rp->color = (vec4f_t) { 0, 1, 0, 1 }; //FIXME
|
||||||
|
|
||||||
hashtab_t *tab = ctx->renderpasses;
|
hashtab_t *tab = ctx->renderpasses;
|
||||||
const char *path;
|
const char *path;
|
||||||
path = va (ctx->va_ctx, "$"QFV_PROPERTIES".%s", name);
|
path = va (ctx->va_ctx, "$"QFV_PROPERTIES".%s", name);
|
||||||
|
|
Loading…
Reference in a new issue