[vulkan] Name most resources

This makes debugging with renderdoc and validation messages much easier
(no more "what buffer is that?").
This commit is contained in:
Bill Currie 2021-01-31 19:58:55 +09:00
parent 7970525ef4
commit eeda04e3c9
16 changed files with 310 additions and 27 deletions

115
include/QF/Vulkan/debug.h Normal file
View file

@ -0,0 +1,115 @@
#ifndef __QF_Vulkan_debug_h
#define __QF_Vulkan_debug_h
#define QFV_duCmdBeginLabel(device, cmd, name...)\
do { \
qfv_devfuncs_t *dfunc = device->funcs; \
if (dfunc->vkCmdBeginDebugUtilsLabelEXT) { \
VkDebugUtilsLabelEXT label = { \
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, 0, name \
}; \
dfunc->vkCmdBeginDebugUtilsLabelEXT (cmd, &label); \
} \
} while (0)
#define QFV_duCmdEndLabel(device, cmd) \
do { \
qfv_devfuncs_t *dfunc = device->funcs; \
if (dfunc->vkCmdEndDebugUtilsLabelEXT) { \
dfunc->vkCmdEndDebugUtilsLabelEXT (cmd); \
} \
} while (0)
#define QFV_duCmdInsertLabel(device, cmd, name...) \
do { \
qfv_devfuncs_t *dfunc = device->funcs; \
if (dfunc->vkCmdInsertDebugUtilsLabelEXT) { \
VkDebugUtilsLabelEXT label = { \
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, 0, name \
}; \
dfunc->vkCmdInsertDebugUtilsLabelEXT (cmd, &label); \
} \
} while (0)
#define QFV_duCreateMessenger(inst, severity, type, callback, data, messenger)\
do { \
if (inst->funcs->vkCreateDebugUtilsMessengerEXT) { \
VkDebugUtilsMessengerCreateInfoEXT createInfo = { \
VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT, 0, 0,\
severity, type, callback, data \
}; \
inst->funcs->vkCreateDebugUtilsMessengerEXT (inst, &createInfo, 0,\
messenger); \
} \
} while (0)
#define QFV_duDestroyMessenger(inst, messenger) \
do { \
if (inst->funcs->vkDestroyDebugUtilsMessengerEXT) { \
inst->funcs->vkDestroyDebugUtilsMessengerEXT (inst, messenger, 0);\
} \
} while (0)
#define QFV_duQueueBeginLabel(device, queue, name...) \
do { \
qfv_devfuncs_t *dfunc = device->funcs; \
if (dfunc->vkQueueBeginDebugUtilsLabelEXT) { \
VkDebugUtilsLabelEXT label = { \
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, 0, name \
}; \
dfunc->vkQueueBeginDebugUtilsLabelEXT (queue, &label); \
} \
} while (0)
#define QFV_duQueueEndLabel(device, queue) \
do { \
qfv_devfuncs_t *dfunc = device->funcs; \
if (dfunc->vkQueueEndDebugUtilsLabelEXT) { \
dfunc->vkQueueEndDebugUtilsLabelEXT (queue); \
} \
} while (0)
#define QFV_duQueueInsertLabel(device, queue, name...) \
do { \
qfv_devfuncs_t *dfunc = device->funcs; \
if (dfunc->vkQueueInsertDebugUtilsLabelEXT) { \
VkDebugUtilsLabelEXT label = { \
VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, 0, name \
}; \
dfunc->vkQueueInsertDebugUtilsLabelEXT (queue, &label); \
} \
} while (0)
#define QFV_duSetObjectName(device, type, handle, name) \
do { \
qfv_devfuncs_t *dfunc = device->funcs; \
if (dfunc->vkSetDebugUtilsObjectNameEXT) { \
VkDebugUtilsObjectNameInfoEXT nameInfo = { \
VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT, 0, \
type, (uint64_t) handle, name \
}; \
dfunc->vkSetDebugUtilsObjectNameEXT (device->dev, &nameInfo); \
} \
} while (0)
#define QFV_duSetObjectTag(device, type, handle, name, size, tag) \
do { \
qfv_devfuncs_t *dfunc = device->funcs; \
if (dfunc->vkSetDebugUtilsObjectTagEXT) { \
VkDebugUtilsObjectTagInfoEXT tagInfo = { \
VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_TAG_INFO_EXT, 0, \
type, handle, name, size, tag \
}; \
dfunc->vkSetDebugUtilsObjectTagEXT (device->dev, &tagInfo); \
} \
} while (0)
#define QFV_duSubmitMessage(inst, severity, types, data) \
do { \
if (inst->funcs->vkSubmitDebugUtilsMessageEXT) { \
inst->funcs->vkSubmitDebugUtilsMessageEXT (inst, severity, types, \
data); \
} \
} while (0)
#endif//__QF_Vulkan_debug_h

View file

@ -43,6 +43,8 @@ INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkCreateDebugUtilsMessengerEXT, VK_EXT_DEBUG_UTILS_EXTENSION_NAME)
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkDestroyDebugUtilsMessengerEXT, VK_EXT_DEBUG_UTILS_EXTENSION_NAME)
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkSubmitDebugUtilsMessageEXT, VK_EXT_DEBUG_UTILS_EXTENSION_NAME)
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkGetPhysicalDeviceSurfaceSupportKHR, VK_KHR_SURFACE_EXTENSION_NAME)
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
@ -196,4 +198,21 @@ DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkQueuePresentKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkCmdBeginDebugUtilsLabelEXT, 0)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkCmdEndDebugUtilsLabelEXT, 0)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkCmdInsertDebugUtilsLabelEXT, 0)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkQueueBeginDebugUtilsLabelEXT, 0)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkQueueEndDebugUtilsLabelEXT, 0)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkQueueInsertDebugUtilsLabelEXT, 0)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkSetDebugUtilsObjectNameEXT, 0)
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
(vkSetDebugUtilsObjectTagEXT, 0)
#undef DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION

View file

@ -13,7 +13,8 @@ typedef struct qfv_tex_s {
void Vulkan_ExpandPalette (byte *dst, const byte *src, const byte *palette,
int alpha, int count);
qfv_tex_t *Vulkan_LoadTex (struct vulkan_ctx_s *ctx, tex_t *tex, int mip);
qfv_tex_t *Vulkan_LoadTex (struct vulkan_ctx_s *ctx, tex_t *tex, int mip,
const char *name);
VkImageView Vulkan_TexImageView (qfv_tex_t *tex) __attribute__((pure));
void Vulkan_UnloadTex (struct vulkan_ctx_s *ctx, qfv_tex_t *tex);
void Vulkan_Texture_Init (struct vulkan_ctx_s *ctx);

View file

@ -8,8 +8,9 @@ typedef struct scrap_s scrap_t;
struct qfv_stagebuf_s;
struct qfv_device_s;
scrap_t *QFV_CreateScrap (struct qfv_device_s *device, int size,
QFFormat format, struct qfv_stagebuf_s *stage);
scrap_t *QFV_CreateScrap (struct qfv_device_s *device, const char *name,
int size, QFFormat format,
struct qfv_stagebuf_s *stage);
size_t QFV_ScrapSize (scrap_t *scrap) __attribute__((pure));
void QFV_ScrapClear (scrap_t *scrap);
void QFV_DestroyScrap (scrap_t *scrap);

View file

@ -26,7 +26,8 @@ typedef struct qfv_stagebuf_s {
qfv_stagebuf_t *QFV_CreateStagingBuffer (struct qfv_device_s *device,
size_t size, VkCommandPool cmdPool);
const char *name, size_t size,
VkCommandPool cmdPool);
void QFV_DestroyStagingBuffer (qfv_stagebuf_t *stage);
void QFV_FlushStagingBuffer (qfv_stagebuf_t *stage, size_t offset, size_t size);
qfv_packet_t *QFV_PacketAcquire (qfv_stagebuf_t *stage);

View file

@ -48,6 +48,7 @@
#include "QF/Vulkan/qf_texture.h"
#include "QF/Vulkan/buffer.h"
#include "QF/Vulkan/device.h"
#include "QF/Vulkan/debug.h"
#include "QF/Vulkan/instance.h"
#include "QF/Vulkan/staging.h"
@ -252,6 +253,15 @@ Vulkan_Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
VkBuffer ibuff = QFV_CreateBuffer (device, ind_size,
VK_BUFFER_USAGE_TRANSFER_DST_BIT
| VK_BUFFER_USAGE_INDEX_BUFFER_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_BUFFER, vbuff,
va (ctx->va_ctx, "buffer:alias:vertex:%s",
loadmodel->name));
QFV_duSetObjectName (device, VK_OBJECT_TYPE_BUFFER, uvbuff,
va (ctx->va_ctx, "buffer:alias:uv:%s",
loadmodel->name));
QFV_duSetObjectName (device, VK_OBJECT_TYPE_BUFFER, ibuff,
va (ctx->va_ctx, "buffer:alias:index:%s",
loadmodel->name));
size_t voffs = 0;
size_t uvoffs = voffs + get_buffer_size (device, vbuff);
size_t ioffs = uvoffs + get_buffer_size (device, uvbuff);
@ -260,12 +270,18 @@ Vulkan_Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
mem = QFV_AllocBufferMemory (device, vbuff,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
buff_size, 0);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_DEVICE_MEMORY, mem,
va (ctx->va_ctx, "memory:alias:vuvi:%s",
loadmodel->name));
QFV_BindBufferMemory (device, vbuff, mem, voffs);
QFV_BindBufferMemory (device, uvbuff, mem, uvoffs);
QFV_BindBufferMemory (device, ibuff, mem, ioffs);
qfv_stagebuf_t *stage = QFV_CreateStagingBuffer (device, buff_size,
ctx->cmdpool);
qfv_stagebuf_t *stage = QFV_CreateStagingBuffer (device,
va (ctx->va_ctx,
"alias:%s",
loadmodel->name),
buff_size, ctx->cmdpool);
qfv_packet_t *packet = QFV_PacketAcquire (stage);
verts = QFV_PacketExtend (packet, vert_size);
uv = QFV_PacketExtend (packet, uv_size);

View file

@ -50,6 +50,7 @@
#include "QF/Vulkan/qf_texture.h"
#include "QF/Vulkan/barrier.h"
#include "QF/Vulkan/command.h"
#include "QF/Vulkan/debug.h"
#include "QF/Vulkan/device.h"
#include "QF/Vulkan/image.h"
#include "QF/Vulkan/staging.h"
@ -209,10 +210,16 @@ load_textures (model_t *model, vulkan_ctx_t *ctx)
mem = QFV_AllocImageMemory (device, image,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
memsize, 0);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_DEVICE_MEMORY,
mem, va (ctx->va_ctx, "memory:%s:texture",
loadmodel->name));
mctx->texture_memory = mem;
qfv_stagebuf_t *stage = QFV_CreateStagingBuffer (device, memsize,
ctx->cmdpool);
qfv_stagebuf_t *stage = QFV_CreateStagingBuffer (device,
va (ctx->va_ctx,
"brush:%s",
loadmodel->name),
memsize, ctx->cmdpool);
qfv_packet_t *packet = QFV_PacketAcquire (stage);
buffer = QFV_PacketExtend (packet, memsize);
@ -239,6 +246,10 @@ load_textures (model_t *model, vulkan_ctx_t *ctx)
tex->tex->view = QFV_CreateImageView (device, tex->tex->image,
type, VK_FORMAT_R8G8B8A8_UNORM,
VK_IMAGE_ASPECT_COLOR_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_IMAGE_VIEW,
tex->tex->view,
va (ctx->va_ctx, "iview:%s:%s:tex",
loadmodel->name, tx->name));
transfer_mips (buffer + tex->tex->offset, tx + 1, tx, palette);
if (tex->glow) {
dfunc->vkBindImageMemory (device->dev, tex->glow->image, mem,
@ -249,6 +260,11 @@ load_textures (model_t *model, vulkan_ctx_t *ctx)
VK_IMAGE_VIEW_TYPE_2D,
VK_FORMAT_R8G8B8A8_UNORM,
VK_IMAGE_ASPECT_COLOR_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_IMAGE_VIEW,
tex->glow->view,
va (ctx->va_ctx, "iview:%s:%s:glow",
loadmodel->name,
tx->name));
transfer_mips (buffer + tex->glow->offset, tex->glow->memory, tx,
palette);
}
@ -351,6 +367,10 @@ Vulkan_Mod_ProcessTexture (texture_t *tx, vulkan_ctx_t *ctx)
VK_SAMPLE_COUNT_1_BIT,
VK_IMAGE_USAGE_TRANSFER_DST_BIT
| VK_IMAGE_USAGE_SAMPLED_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_IMAGE,
tex->tex->image,
va (ctx->va_ctx, "image:%s:%s:tex", loadmodel->name,
tx->name));
if (layers > 1) {
// skys are unlit, so no fullbrights
return;
@ -372,6 +392,10 @@ Vulkan_Mod_ProcessTexture (texture_t *tx, vulkan_ctx_t *ctx)
VK_SAMPLE_COUNT_1_BIT,
VK_IMAGE_USAGE_TRANSFER_DST_BIT
| VK_IMAGE_USAGE_SAMPLED_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_IMAGE,
tex->glow->image,
va (ctx->va_ctx, "image:%s:%s:glow", loadmodel->name,
tx->name));
// store the pointer to the fullbright data: memory will never be set to
// actual device memory because all of the textures will be loaded in one
// big buffer

View file

@ -112,10 +112,12 @@ load_device_funcs (qfv_instance_t *inst, qfv_device_t *dev)
}
#define DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION(name, ext) \
if (dev->extension_enabled (dev, ext)) { \
if (!ext || dev->extension_enabled (dev, ext)) { \
dfunc->name = (PFN_##name) ifunc->vkGetDeviceProcAddr (device, #name); \
if (!dfunc->name) { \
Sys_Printf ("Couldn't find device level function %s", #name); \
} else { \
Sys_Printf ("Found device level function %s\n", #name); \
} \
}

View file

@ -51,6 +51,7 @@
#include "QF/Vulkan/barrier.h"
#include "QF/Vulkan/buffer.h"
#include "QF/Vulkan/command.h"
#include "QF/Vulkan/debug.h"
#include "QF/Vulkan/device.h"
#include "QF/Vulkan/image.h"
#include "QF/Vulkan/instance.h"
@ -76,12 +77,13 @@ struct scrap_s {
};
scrap_t *
QFV_CreateScrap (qfv_device_t *device, int size, QFFormat format,
qfv_stagebuf_t *stage)
QFV_CreateScrap (qfv_device_t *device, const char *name, int size,
QFFormat format, qfv_stagebuf_t *stage)
{
qfv_devfuncs_t *dfunc = device->funcs;
int bpp = 0;
VkFormat fmt = VK_FORMAT_UNDEFINED;
dstring_t *str = dstring_new ();
switch (format) {
case tex_l:
@ -119,13 +121,20 @@ QFV_CreateScrap (qfv_device_t *device, int size, QFFormat format,
extent, 1, 1, VK_SAMPLE_COUNT_1_BIT,
VK_IMAGE_USAGE_TRANSFER_DST_BIT
| VK_IMAGE_USAGE_SAMPLED_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_IMAGE, scrap->image,
dsprintf (str, "image:scrap:%s", name));
scrap->memory = QFV_AllocImageMemory (device, scrap->image,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
0, 0);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_DEVICE_MEMORY, scrap->memory,
dsprintf (str, "memory:scrap:%s", name));
QFV_BindImageMemory (device, scrap->image, scrap->memory, 0);
scrap->view = QFV_CreateImageView (device, scrap->image,
VK_IMAGE_VIEW_TYPE_2D, fmt,
VK_IMAGE_ASPECT_COLOR_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_IMAGE_VIEW, scrap->view,
dsprintf (str, "iview:scrap:%s", name));
dstring_delete (str);
scrap->bpp = bpp;
scrap->subpics = 0;
scrap->device = device;

View file

@ -48,6 +48,7 @@
#include "QF/Vulkan/qf_vid.h"
#include "QF/Vulkan/buffer.h"
#include "QF/Vulkan/command.h"
#include "QF/Vulkan/debug.h"
#include "QF/Vulkan/device.h"
#include "QF/Vulkan/instance.h"
#include "QF/Vulkan/staging.h"
@ -55,11 +56,12 @@
#include "vid_vulkan.h"
qfv_stagebuf_t *
QFV_CreateStagingBuffer (qfv_device_t *device, size_t size,
QFV_CreateStagingBuffer (qfv_device_t *device, const char * name, size_t size,
VkCommandPool cmdPool)
{
size_t atom = device->physDev->properties.limits.nonCoherentAtomSize;
qfv_devfuncs_t *dfunc = device->funcs;
dstring_t *str = dstring_new ();
qfv_stagebuf_t *stage = calloc (1, sizeof (qfv_stagebuf_t));
stage->atom_mask = atom - 1;
@ -67,9 +69,13 @@ QFV_CreateStagingBuffer (qfv_device_t *device, size_t size,
stage->device = device;
stage->buffer = QFV_CreateBuffer (device, size,
VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_BUFFER, stage->buffer,
dsprintf (str, "staging:buffer:%s", name));
stage->memory = QFV_AllocBufferMemory (device, stage->buffer,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
size, 0);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_DEVICE_MEMORY, stage->memory,
dsprintf (str, "staging:memory:%s", name));
stage->size = size;
stage->end = size;
@ -85,9 +91,18 @@ QFV_CreateStagingBuffer (qfv_device_t *device, size_t size,
packet->stage = stage;
packet->cmd = bufferset->a[i];
packet->fence = QFV_CreateFence (device, 1);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_COMMAND_BUFFER,
packet->cmd,
dsprintf (str, "staging:packet:cmd:%s:%d",
name, i));
QFV_duSetObjectName (device, VK_OBJECT_TYPE_FENCE,
packet->fence,
dsprintf (str, "staging:packet:fence:%s:%d",
name, i));
packet->offset = 0;
packet->length = 0;
}
dstring_delete (str);
return stage;
}

View file

@ -54,6 +54,7 @@
#include "QF/simd/vec4f.h"
#include "QF/Vulkan/qf_vid.h"
#include "QF/Vulkan/descriptor.h"
#include "QF/Vulkan/debug.h"
#include "QF/Vulkan/device.h"
#include "QF/Vulkan/command.h"
#include "QF/Vulkan/instance.h"
@ -391,6 +392,8 @@ parse_VkShaderModule_resource (const plitem_t *item, void **data,
PL_Message (messages, item, "could not find shader %s", shader_path);
return 0;
}
QFV_duSetObjectName (device, VK_OBJECT_TYPE_SHADER_MODULE, *handle,
va (ctx->va_ctx, "shader:%s", shader_path));
return 1;
}

View file

@ -57,6 +57,7 @@
#include "QF/Vulkan/qf_texture.h"
#include "QF/Vulkan/buffer.h"
#include "QF/Vulkan/command.h"
#include "QF/Vulkan/debug.h"
#include "QF/Vulkan/descriptor.h"
#include "QF/Vulkan/device.h"
@ -270,15 +271,25 @@ Vulkan_Alias_Init (vulkan_ctx_t *ctx)
actx->pipeline = Vulkan_CreatePipeline (ctx, "alias");
actx->layout = QFV_GetPipelineLayout (ctx, "alias.layout");
QFV_duSetObjectName (device, VK_OBJECT_TYPE_PIPELINE_LAYOUT, actx->layout,
va (ctx->va_ctx, "layout:%s", "alias.layout"));
actx->sampler = QFV_GetSampler (ctx, "alias.sampler");
QFV_duSetObjectName (device, VK_OBJECT_TYPE_SAMPLER, actx->sampler,
va (ctx->va_ctx, "sampler:%s", "alias.sampler"));
__auto_type layouts = QFV_AllocDescriptorSetLayoutSet (2 * frames, alloca);
/*__auto_type layouts = QFV_AllocDescriptorSetLayoutSet (2 * frames, alloca);
for (size_t i = 0; i < layouts->size / 2; i++) {
__auto_type mats = QFV_GetDescriptorSetLayout (ctx, "alias.matrices");
__auto_type lights = QFV_GetDescriptorSetLayout (ctx, "alias.lights");
QFV_duSetObjectName (device, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT,
mats, va (ctx->va_ctx, "set_layout:%s:%d",
"alias.matrices", i));
QFV_duSetObjectName (device, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT,
lights, va (ctx->va_ctx, "set_layout:%s:%d",
"alias.lights", i));
layouts->a[2 * i + 0] = mats;
layouts->a[2 * i + 1] = lights;
}
}*/
//__auto_type pool = QFV_GetDescriptorPool (ctx, "alias.pool");
__auto_type cmdBuffers = QFV_AllocCommandBufferSet (frames, alloca);
@ -288,6 +299,10 @@ Vulkan_Alias_Init (vulkan_ctx_t *ctx)
for (size_t i = 0; i < frames; i++) {
lbuffers->a[i] = QFV_CreateBuffer (device, sizeof (qfv_light_buffer_t),
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_BUFFER,
lbuffers->a[i],
va (ctx->va_ctx, "buffer:alias:%s:%zd",
"lights", i));
}
VkMemoryRequirements requirements;
dfunc->vkGetBufferMemoryRequirements (device->dev, lbuffers->a[0],
@ -295,6 +310,9 @@ Vulkan_Alias_Init (vulkan_ctx_t *ctx)
actx->light_memory = QFV_AllocBufferMemory (device, lbuffers->a[0],
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
frames * requirements.size, 0);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_DEVICE_MEMORY,
actx->light_memory, va (ctx->va_ctx,
"memory:alias:%s", "lights"));
byte *light_data;
dfunc->vkMapMemory (device->dev, actx->light_memory, 0,
frames * requirements.size, 0, (void **) &light_data);
@ -303,6 +321,9 @@ Vulkan_Alias_Init (vulkan_ctx_t *ctx)
for (size_t i = 0; i < frames; i++) {
__auto_type aframe = &actx->frames.a[i];
aframe->cmd = cmdBuffers->a[i];
QFV_duSetObjectName (device, VK_OBJECT_TYPE_COMMAND_BUFFER,
aframe->cmd,
va (ctx->va_ctx, "cmd:alias:%zd", i));
aframe->light_buffer = lbuffers->a[i];
aframe->lights = (qfv_light_buffer_t *) (light_data + i * requirements.size);
QFV_BindBufferMemory (device, lbuffers->a[i], actx->light_memory,

View file

@ -58,6 +58,7 @@
#include "QF/Vulkan/buffer.h"
#include "QF/Vulkan/barrier.h"
#include "QF/Vulkan/command.h"
#include "QF/Vulkan/debug.h"
#include "QF/Vulkan/descriptor.h"
#include "QF/Vulkan/device.h"
#include "QF/Vulkan/image.h"
@ -467,7 +468,8 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx)
size_t vertex_buffer_size = vertex_count * sizeof (bspvert_t);
index_buffer_size = (index_buffer_size + atom_mask) & ~atom_mask;
stage = QFV_CreateStagingBuffer (device, vertex_buffer_size, ctx->cmdpool);
stage = QFV_CreateStagingBuffer (device, "bsp", vertex_buffer_size,
ctx->cmdpool);
qfv_packet_t *packet = QFV_PacketAcquire (stage);
vertices = QFV_PacketExtend (packet, vertex_buffer_size);
vertex_index_base = 0;
@ -518,10 +520,14 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx)
= QFV_CreateBuffer (device, index_buffer_size,
VK_BUFFER_USAGE_TRANSFER_DST_BIT
| VK_BUFFER_USAGE_INDEX_BUFFER_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_BUFFER, bctx->index_buffer,
"buffer:bsp:index");
bctx->index_memory
= QFV_AllocBufferMemory (device, bctx->index_buffer,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
index_buffer_size, 0);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_DEVICE_MEMORY,
bctx->index_memory, "memory:bsp:index");
QFV_BindBufferMemory (device,
bctx->index_buffer, bctx->index_memory, 0);
bctx->index_buffer_size = index_buffer_size;
@ -545,10 +551,14 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx)
= QFV_CreateBuffer (device, vertex_buffer_size,
VK_BUFFER_USAGE_TRANSFER_DST_BIT
| VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_BUFFER,
bctx->vertex_buffer, "buffer:bsp:vertex");
bctx->vertex_memory
= QFV_AllocBufferMemory (device, bctx->vertex_buffer,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
vertex_buffer_size, 0);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_DEVICE_MEMORY,
bctx->vertex_memory, "memory:bsp:vertex");
QFV_BindBufferMemory (device,
bctx->vertex_buffer, bctx->vertex_memory, 0);
bctx->vertex_buffer_size = vertex_buffer_size;
@ -1290,12 +1300,17 @@ create_default_skys (vulkan_ctx_t *ctx)
VK_SAMPLE_COUNT_1_BIT,
VK_IMAGE_USAGE_SAMPLED_BIT
| VK_IMAGE_USAGE_TRANSFER_DST_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_IMAGE, skybox,
"bsp:image:default_skybox");
skysheet = QFV_CreateImage (device, 0, VK_IMAGE_TYPE_2D,
VK_FORMAT_B8G8R8A8_UNORM, extents, 1, 2,
VK_SAMPLE_COUNT_1_BIT,
VK_IMAGE_USAGE_SAMPLED_BIT
| VK_IMAGE_USAGE_TRANSFER_DST_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_IMAGE, skysheet,
"bsp:image:default_skysheet");
VkMemoryRequirements requirements;
dfunc->vkGetImageMemoryRequirements (device->dev, skybox, &requirements);
size_t boxsize = requirements.size;
@ -1307,6 +1322,8 @@ create_default_skys (vulkan_ctx_t *ctx)
boxsize + sheetsize,
VK_IMAGE_USAGE_TRANSFER_DST_BIT
| VK_IMAGE_USAGE_SAMPLED_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_DEVICE_MEMORY, memory,
"bsp:memory:default_skys");
QFV_BindImageMemory (device, skybox, memory, 0);
QFV_BindImageMemory (device, skysheet, memory, boxsize);
@ -1314,11 +1331,15 @@ create_default_skys (vulkan_ctx_t *ctx)
boxview = QFV_CreateImageView (device, skybox, VK_IMAGE_VIEW_TYPE_CUBE,
VK_FORMAT_B8G8R8A8_UNORM,
VK_IMAGE_ASPECT_COLOR_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_IMAGE_VIEW, boxview,
"bsp:iview:default_skysheet");
sheetview = QFV_CreateImageView (device, skysheet,
VK_IMAGE_VIEW_TYPE_2D_ARRAY,
VK_FORMAT_B8G8R8A8_UNORM,
VK_IMAGE_ASPECT_COLOR_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_IMAGE_VIEW, sheetview,
"bsp:iview:default_skysheet");
bctx->default_skybox->image = skybox;
bctx->default_skybox->view = boxview;
@ -1405,9 +1426,11 @@ Vulkan_Bsp_Init (vulkan_ctx_t *ctx)
bctx->elementss_tail = &bctx->elementss;
bctx->instsurfs_tail = &bctx->instsurfs;
bctx->light_scrap = QFV_CreateScrap (device, 2048, tex_frgba, ctx->staging);
bctx->light_scrap = QFV_CreateScrap (device, "lightmap_atlas", 2048,
tex_frgba, ctx->staging);
size_t size = QFV_ScrapSize (bctx->light_scrap);
bctx->light_stage = QFV_CreateStagingBuffer (device, size, ctx->cmdpool);
bctx->light_stage = QFV_CreateStagingBuffer (device, "lightmap", size,
ctx->cmdpool);
create_default_skys (ctx);
@ -1421,7 +1444,11 @@ Vulkan_Bsp_Init (vulkan_ctx_t *ctx)
bctx->main = Vulkan_CreatePipeline (ctx, "quakebsp.main");
bctx->sky = Vulkan_CreatePipeline (ctx, "quakebsp.skysheet");
bctx->layout = QFV_GetPipelineLayout (ctx, "quakebsp.layout");
QFV_duSetObjectName (device, VK_OBJECT_TYPE_PIPELINE_LAYOUT, bctx->layout,
va (ctx->va_ctx, "layout:%s", "quakebsp.layout"));
bctx->sampler = QFV_GetSampler (ctx, "quakebsp.sampler");
QFV_duSetObjectName (device, VK_OBJECT_TYPE_SAMPLER, bctx->sampler,
va (ctx->va_ctx, "sampler:%s", "quakebsp.sampler"));
__auto_type cmdBuffers = QFV_AllocCommandBufferSet (3 * frames, alloca);
QFV_AllocateCommandBuffers (device, ctx->cmdpool, 1, cmdBuffers);
@ -1431,6 +1458,15 @@ Vulkan_Bsp_Init (vulkan_ctx_t *ctx)
bframe->bsp_cmd = cmdBuffers->a[i * 3 + 0];
bframe->turb_cmd = cmdBuffers->a[i * 3 + 1];
bframe->sky_cmd = cmdBuffers->a[i * 3 + 2];
QFV_duSetObjectName (device, VK_OBJECT_TYPE_COMMAND_BUFFER,
bframe->bsp_cmd,
va (ctx->va_ctx, "cmd:bsp:%zd", i));
QFV_duSetObjectName (device, VK_OBJECT_TYPE_COMMAND_BUFFER,
bframe->turb_cmd,
va (ctx->va_ctx, "cmd:turb:%zd", i));
QFV_duSetObjectName (device, VK_OBJECT_TYPE_COMMAND_BUFFER,
bframe->sky_cmd,
va (ctx->va_ctx, "cmd:sky:%zd", i));
for (int j = 0; j < BSP_BUFFER_INFOS; j++) {
bframe->bufferInfo[j] = base_buffer_info;

View file

@ -367,9 +367,10 @@ Vulkan_Draw_Init (vulkan_ctx_t *ctx)
0, 0);
create_quad_buffers (ctx);
dctx->stage = QFV_CreateStagingBuffer (device, 4 * 1024 * 1024,
dctx->stage = QFV_CreateStagingBuffer (device, "draw", 4 * 1024 * 1024,
ctx->cmdpool);
dctx->scrap = QFV_CreateScrap (device, 2048, tex_rgba, dctx->stage);
dctx->scrap = QFV_CreateScrap (device, "draw_atlas", 2048, tex_rgba,
dctx->stage);
dctx->sampler = QFV_GetSampler (ctx, "quakepic");
qpic_t *charspic = Draw_Font8x8Pic ();

View file

@ -48,11 +48,13 @@
#include "QF/quakefs.h"
#include "QF/render.h"
#include "QF/sys.h"
#include "QF/va.h"
#include "QF/Vulkan/qf_vid.h"
#include "QF/Vulkan/qf_texture.h"
#include "QF/Vulkan/barrier.h"
#include "QF/Vulkan/buffer.h"
#include "QF/Vulkan/command.h"
#include "QF/Vulkan/debug.h"
#include "QF/Vulkan/device.h"
#include "QF/Vulkan/image.h"
#include "QF/Vulkan/instance.h"
@ -199,7 +201,7 @@ blit_mips (int mips, VkImage image, tex_t *tex,
}
qfv_tex_t *
Vulkan_LoadTex (vulkan_ctx_t *ctx, tex_t *tex, int mip)
Vulkan_LoadTex (vulkan_ctx_t *ctx, tex_t *tex, int mip, const char *name)
{
qfv_device_t *device = ctx->device;
qfv_devfuncs_t *dfunc = device->funcs;
@ -256,14 +258,20 @@ Vulkan_LoadTex (vulkan_ctx_t *ctx, tex_t *tex, int mip)
VK_IMAGE_USAGE_TRANSFER_DST_BIT
| VK_IMAGE_USAGE_TRANSFER_SRC_BIT
| VK_IMAGE_USAGE_SAMPLED_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_IMAGE, qtex->image,
va (ctx->va_ctx, "image:%s", name));
qtex->memory = QFV_AllocImageMemory (device, qtex->image,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
0, 0);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_DEVICE_MEMORY, qtex->memory,
va (ctx->va_ctx, "memory:%s", name));
QFV_BindImageMemory (device, qtex->image, qtex->memory, 0);
qtex->view = QFV_CreateImageView (device, qtex->image,
VK_IMAGE_VIEW_TYPE_2D,
VK_FORMAT_R8G8B8A8_UNORM,
VK_IMAGE_ASPECT_COLOR_BIT);
QFV_duSetObjectName (device, VK_OBJECT_TYPE_IMAGE_VIEW, qtex->view,
va (ctx->va_ctx, "iview:%s", name));
size_t bytes = bpp * tex->width * tex->height;
qfv_packet_t *packet = QFV_PacketAcquire (ctx->staging);
@ -337,9 +345,12 @@ static tex_t default_magenta_tex = {1, 1, tex_rgba, 1, 0, magenta_data};
void
Vulkan_Texture_Init (vulkan_ctx_t *ctx)
{
ctx->default_black = Vulkan_LoadTex (ctx, &default_black_tex, 1);
ctx->default_white = Vulkan_LoadTex (ctx, &default_white_tex, 1);
ctx->default_magenta = Vulkan_LoadTex (ctx, &default_magenta_tex, 1);
ctx->default_black = Vulkan_LoadTex (ctx, &default_black_tex, 1,
"default_black");
ctx->default_white = Vulkan_LoadTex (ctx, &default_white_tex, 1,
"default_white");
ctx->default_magenta = Vulkan_LoadTex (ctx, &default_magenta_tex, 1,
"default_magenta");
}
void

View file

@ -54,6 +54,7 @@
#include "QF/Vulkan/qf_vid.h"
#include "QF/Vulkan/barrier.h"
#include "QF/Vulkan/buffer.h"
#include "QF/Vulkan/debug.h"
#include "QF/Vulkan/descriptor.h"
#include "QF/Vulkan/device.h"
#include "QF/Vulkan/command.h"
@ -204,8 +205,8 @@ Vulkan_CreateDevice (vulkan_ctx_t *ctx)
void
Vulkan_CreateStagingBuffers (vulkan_ctx_t *ctx)
{
ctx->staging = QFV_CreateStagingBuffer (ctx->device, 4*1024*1024,
ctx->cmdpool);
ctx->staging = QFV_CreateStagingBuffer (ctx->device, "vulkan_ctx",
4*1024*1024, ctx->cmdpool);
}
void
@ -238,9 +239,10 @@ void
Vulkan_CreateRenderPass (vulkan_ctx_t *ctx)
{
qfv_load_pipeline (ctx);
const char *name = "renderpass";//FIXME
plitem_t *item = ctx->pipelineDef;
if (!item || !(item = PL_ObjectForKey (item, "renderpass"))) {
if (!item || !(item = PL_ObjectForKey (item, name))) {
Sys_Printf ("error loading renderpass\n");
return;
} else {
@ -340,6 +342,9 @@ Vulkan_CreateRenderPass (vulkan_ctx_t *ctx)
ctx->renderpass.colorImage = colorImage;
ctx->renderpass.depthImage = depthImage;
ctx->renderpass.renderpass = QFV_ParseRenderPass (ctx, item);
QFV_duSetObjectName (ctx->device, VK_OBJECT_TYPE_RENDER_PASS,
ctx->renderpass.renderpass,
va (ctx->va_ctx, "pipeline:%s", name));
}
void
@ -382,7 +387,10 @@ Vulkan_CreatePipeline (vulkan_ctx_t *ctx, const char *name)
} else {
Sys_Printf ("Found pipeline def %s\n", name);
}
return QFV_ParsePipeline (ctx, item);
VkPipeline pipeline = QFV_ParsePipeline (ctx, item);
QFV_duSetObjectName (ctx->device, VK_OBJECT_TYPE_PIPELINE, pipeline,
va (ctx->va_ctx, "pipeline:%s", name));
return pipeline;
}
void