mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-22 02:11:19 +00:00
[vulkan] Take care of the duplicate handles
This commit is contained in:
parent
8179c44042
commit
a54de63fee
3 changed files with 69 additions and 21 deletions
|
@ -362,8 +362,18 @@ parse_RGBA (const plitem_t *item, void **data,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
add_handle (hashtab_t *tab, const char *name, uint64_t handle)
|
||||
uint64_t
|
||||
QFV_GetHandle (hashtab_t *tab, const char *name)
|
||||
{
|
||||
handleref_t *hr = Hash_Find (tab, name);
|
||||
if (hr) {
|
||||
return hr->handle;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
QFV_AddHandle (hashtab_t *tab, const char *name, uint64_t handle)
|
||||
{
|
||||
handleref_t *hr = malloc (sizeof (handleref_t));
|
||||
hr->name = strdup (name);
|
||||
|
@ -380,16 +390,15 @@ parse_VkShaderModule (const plitem_t *item, void **data,
|
|||
qfv_device_t *device = ctx->device;
|
||||
|
||||
const char *name = PL_String (item);
|
||||
handleref_t *hr = Hash_Find (ctx->shaderModules, name);
|
||||
if (hr) {
|
||||
*handle = (VkShaderModule) hr->handle;
|
||||
*handle = (VkShaderModule) QFV_GetHandle (ctx->shaderModules, name);
|
||||
if (*handle) {
|
||||
return 1;
|
||||
}
|
||||
if (!(*handle = QFV_CreateShaderModule (device, name))) {
|
||||
PL_Message (messages, item, "could not find shader %s", name);
|
||||
return 0;
|
||||
}
|
||||
add_handle (ctx->shaderModules, name, (uint64_t) *handle);
|
||||
QFV_AddHandle (ctx->shaderModules, name, (uint64_t) *handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -404,11 +413,10 @@ parse_VkDescriptorSetLayout (const plfield_t *field, const plitem_t *item,
|
|||
|
||||
const char *name = PL_String (item);
|
||||
Sys_Printf ("parse_VkDescriptorSetLayout: %s\n", name);
|
||||
name = va (ctx->va_ctx, "$properties.setLayouts.%s", name);
|
||||
name = va (ctx->va_ctx, "$"QFV_PROPERTIES".setLayouts.%s", name);
|
||||
|
||||
handleref_t *hr = Hash_Find (ctx->setLayouts, name);
|
||||
if (hr) {
|
||||
*handle = (VkDescriptorSetLayout) hr->handle;
|
||||
*handle = (VkDescriptorSetLayout) QFV_GetHandle (ctx->setLayouts, name);
|
||||
if (*handle) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -422,7 +430,7 @@ parse_VkDescriptorSetLayout (const plfield_t *field, const plitem_t *item,
|
|||
setLayout = QFV_ParseDescriptorSetLayout (ctx, setItem);
|
||||
*handle = (VkDescriptorSetLayout) setLayout;
|
||||
|
||||
add_handle (ctx->setLayouts, name, (uint64_t) setLayout);
|
||||
QFV_AddHandle (ctx->setLayouts, name, (uint64_t) setLayout);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -438,11 +446,10 @@ parse_VkPipelineLayout (const plitem_t *item, void **data,
|
|||
|
||||
const char *name = PL_String (item);
|
||||
Sys_Printf ("parse_VkPipelineLayout: %s\n", name);
|
||||
name = va (ctx->va_ctx, "$properties.pipelineLayouts.%s", name);
|
||||
name = va (ctx->va_ctx, "$"QFV_PROPERTIES".pipelineLayouts.%s", name);
|
||||
|
||||
handleref_t *hr = Hash_Find (ctx->pipelineLayouts, name);
|
||||
if (hr) {
|
||||
*handle = (VkPipelineLayout) hr->handle;
|
||||
*handle = (VkPipelineLayout) QFV_GetHandle (ctx->pipelineLayouts, name);
|
||||
if (*handle) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -456,7 +463,7 @@ parse_VkPipelineLayout (const plitem_t *item, void **data,
|
|||
layout = QFV_ParsePipelineLayout (ctx, setItem);
|
||||
*handle = (VkPipelineLayout) layout;
|
||||
|
||||
add_handle (ctx->pipelineLayouts, name, (uint64_t) layout);
|
||||
QFV_AddHandle (ctx->pipelineLayouts, name, (uint64_t) layout);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -700,7 +707,7 @@ parse_object (vulkan_ctx_t *ctx, plitem_t *plist,
|
|||
{"swapchain", &qfv_swapchain_t_type, ctx->swapchain},
|
||||
{"framebuffers", &vulkan_framebufferset_t_type, &ctx->framebuffers},
|
||||
{"msaaSamples", &VkSampleCountFlagBits_type, &ctx->msaaSamples},
|
||||
{"properties", &cexpr_plitem, &ctx->pipelineDef},
|
||||
{QFV_PROPERTIES, &cexpr_plitem, &ctx->pipelineDef},
|
||||
{}
|
||||
};
|
||||
exprtab_t vars_tab = { var_syms, 0 };
|
||||
|
|
|
@ -13,6 +13,8 @@ typedef struct parsectx_s {
|
|||
#include "libs/video/renderer/vulkan/vkparse.hinc"
|
||||
#endif
|
||||
|
||||
#define QFV_PROPERTIES "properties"
|
||||
|
||||
typedef struct parseres_s {
|
||||
const char *name;
|
||||
plfield_t *field;
|
||||
|
@ -27,6 +29,9 @@ typedef struct handleref_s {
|
|||
void QFV_InitParse (vulkan_ctx_t *ctx);
|
||||
exprenum_t *QFV_GetEnum (const char *name);
|
||||
|
||||
uint64_t QFV_GetHandle (struct hashtab_s *tab, const char *name);
|
||||
void QFV_AddHandle (struct hashtab_s *tab, const char *name, uint64_t handle);
|
||||
|
||||
VkRenderPass QFV_ParseRenderPass (vulkan_ctx_t *ctx, plitem_t *plist);
|
||||
VkPipeline QFV_ParsePipeline (vulkan_ctx_t *ctx, plitem_t *plist);
|
||||
VkDescriptorPool QFV_ParseDescriptorPool (vulkan_ctx_t *ctx, plitem_t *plist);
|
||||
|
|
|
@ -393,6 +393,14 @@ Vulkan_CreatePipeline (vulkan_ctx_t *ctx, const char *name)
|
|||
VkDescriptorPool
|
||||
Vulkan_CreateDescriptorPool (vulkan_ctx_t *ctx, const char *name)
|
||||
{
|
||||
hashtab_t *tab = ctx->descriptorPools;
|
||||
const char *path;
|
||||
path = va (ctx->va_ctx, "$"QFV_PROPERTIES".descriptorPools.%s", name);
|
||||
__auto_type pool = (VkDescriptorPool) QFV_GetHandle (tab, path);
|
||||
if (pool) {
|
||||
return pool;
|
||||
}
|
||||
|
||||
plitem_t *item = qfv_load_pipeline (ctx, "descriptorPools");
|
||||
if (!(item = PL_ObjectForKey (item, name))) {
|
||||
Sys_Printf ("error loading descriptor pool %s\n", name);
|
||||
|
@ -400,7 +408,8 @@ Vulkan_CreateDescriptorPool (vulkan_ctx_t *ctx, const char *name)
|
|||
} else {
|
||||
Sys_Printf ("Found descriptor pool def %s\n", name);
|
||||
}
|
||||
VkDescriptorPool pool = QFV_ParseDescriptorPool (ctx, item);
|
||||
pool = QFV_ParseDescriptorPool (ctx, item);
|
||||
QFV_AddHandle (tab, path, (uint64_t) pool);
|
||||
QFV_duSetObjectName (ctx->device, VK_OBJECT_TYPE_DESCRIPTOR_POOL, pool,
|
||||
va (ctx->va_ctx, "descriptor_pool:%s", name));
|
||||
return pool;
|
||||
|
@ -409,6 +418,14 @@ Vulkan_CreateDescriptorPool (vulkan_ctx_t *ctx, const char *name)
|
|||
VkPipelineLayout
|
||||
Vulkan_CreatePipelineLayout (vulkan_ctx_t *ctx, const char *name)
|
||||
{
|
||||
hashtab_t *tab = ctx->pipelineLayouts;
|
||||
const char *path;
|
||||
path = va (ctx->va_ctx, "$"QFV_PROPERTIES".pipelineLayouts.%s", name);
|
||||
__auto_type layout = (VkPipelineLayout) QFV_GetHandle (tab, path);
|
||||
if (layout) {
|
||||
return layout;
|
||||
}
|
||||
|
||||
plitem_t *item = qfv_load_pipeline (ctx, "pipelineLayouts");
|
||||
if (!(item = PL_ObjectForKey (item, name))) {
|
||||
Sys_Printf ("error loading pipeline layout %s\n", name);
|
||||
|
@ -416,7 +433,8 @@ Vulkan_CreatePipelineLayout (vulkan_ctx_t *ctx, const char *name)
|
|||
} else {
|
||||
Sys_Printf ("Found pipeline layout def %s\n", name);
|
||||
}
|
||||
VkPipelineLayout layout = QFV_ParsePipelineLayout (ctx, item);
|
||||
layout = QFV_ParsePipelineLayout (ctx, item);
|
||||
QFV_AddHandle (tab, path, (uint64_t) layout);
|
||||
QFV_duSetObjectName (ctx->device, VK_OBJECT_TYPE_PIPELINE_LAYOUT, layout,
|
||||
va (ctx->va_ctx, "pipeline_layout:%s", name));
|
||||
return layout;
|
||||
|
@ -425,6 +443,14 @@ Vulkan_CreatePipelineLayout (vulkan_ctx_t *ctx, const char *name)
|
|||
VkSampler
|
||||
Vulkan_CreateSampler (vulkan_ctx_t *ctx, const char *name)
|
||||
{
|
||||
hashtab_t *tab = ctx->samplers;
|
||||
const char *path;
|
||||
path = va (ctx->va_ctx, "$"QFV_PROPERTIES".samplers.%s", name);
|
||||
__auto_type sampler = (VkSampler) QFV_GetHandle (tab, path);
|
||||
if (sampler) {
|
||||
return sampler;
|
||||
}
|
||||
|
||||
plitem_t *item = qfv_load_pipeline (ctx, "samplers");
|
||||
if (!(item = PL_ObjectForKey (item, name))) {
|
||||
Sys_Printf ("error loading sampler %s\n", name);
|
||||
|
@ -432,7 +458,8 @@ Vulkan_CreateSampler (vulkan_ctx_t *ctx, const char *name)
|
|||
} else {
|
||||
Sys_Printf ("Found sampler def %s\n", name);
|
||||
}
|
||||
VkSampler sampler = QFV_ParseSampler (ctx, item);
|
||||
sampler = QFV_ParseSampler (ctx, item);
|
||||
QFV_AddHandle (tab, path, (uint64_t) sampler);
|
||||
QFV_duSetObjectName (ctx->device, VK_OBJECT_TYPE_SAMPLER, sampler,
|
||||
va (ctx->va_ctx, "sampler:%s", name));
|
||||
return sampler;
|
||||
|
@ -441,6 +468,14 @@ Vulkan_CreateSampler (vulkan_ctx_t *ctx, const char *name)
|
|||
VkDescriptorSetLayout
|
||||
Vulkan_CreateDescriptorSetLayout(vulkan_ctx_t *ctx, const char *name)
|
||||
{
|
||||
hashtab_t *tab = ctx->setLayouts;
|
||||
const char *path;
|
||||
path = va (ctx->va_ctx, "$"QFV_PROPERTIES".setLayouts.%s", name);
|
||||
__auto_type set = (VkDescriptorSetLayout) QFV_GetHandle (tab, path);
|
||||
if (set) {
|
||||
return set;
|
||||
}
|
||||
|
||||
plitem_t *item = qfv_load_pipeline (ctx, "setLayouts");
|
||||
if (!(item = PL_ObjectForKey (item, name))) {
|
||||
Sys_Printf ("error loading descriptor set %s\n", name);
|
||||
|
@ -448,7 +483,8 @@ Vulkan_CreateDescriptorSetLayout(vulkan_ctx_t *ctx, const char *name)
|
|||
} else {
|
||||
Sys_Printf ("Found descriptor set def %s\n", name);
|
||||
}
|
||||
VkDescriptorSetLayout set = QFV_ParseDescriptorSetLayout (ctx, item);
|
||||
set = QFV_ParseDescriptorSetLayout (ctx, item);
|
||||
QFV_AddHandle (tab, path, (uint64_t) set);
|
||||
QFV_duSetObjectName (ctx->device, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT,
|
||||
set, va (ctx->va_ctx, "descriptor_set:%s", name));
|
||||
return set;
|
||||
|
|
Loading…
Reference in a new issue