[vulkan] Generate handle get functions

Cleans up (hides) the casting when fetching a handle.
This commit is contained in:
Bill Currie 2021-01-12 14:56:02 +09:00
parent 8a85b5c610
commit 93aa038d9e
3 changed files with 18 additions and 9 deletions

View file

@ -56,10 +56,17 @@ output_handle (string name, PLItem *handle)
}
fprintf (output_file, "}\n");
fprintf (output_file, "%s QFV_Get%s (vulkan_ctx_t *ctx, const char *name)\n", name, str_mid (name, 2));
fprintf (output_file, "{\n");
fprintf (output_file, "\thandleref_t *handleref = Hash_Find (ctx->%s, name);\n", symtab);
fprintf (output_file, "\treturn handleref ? (%s) handleref->handle : 0;\n", name);
fprintf (output_file, "}\n");
if (!custom) {
fprintf (header_file, "static int parse_%s (const plitem_t *item, void **data, plitem_t *messages, parsectx_t *context);\n", name);
}
fprintf (header_file, "int parse_%s_handleref (const plfield_t *field, const plitem_t *item, void *data, plitem_t *messages, void *context);\n", name);
fprintf (output_file, "%s QFV_Get%s (vulkan_ctx_t *ctx, const char *name);\n", name, str_mid (name, 2));
str_free (custom);
str_free (symtab);
str_free (class);

View file

@ -24,6 +24,13 @@ typedef struct handleref_s {
uint64_t handle;
} handleref_t;
VkShaderModule QFV_GetShaderModule (vulkan_ctx_t *ctx, const char *name);
VkDescriptorPool QFV_GetDescriptorPool (vulkan_ctx_t *ctx, const char *name);
VkDescriptorSetLayout QFV_GetDescriptorSetLayout (vulkan_ctx_t *ctx,
const char *name);
VkPipelineLayout QFV_GetPipelineLayout (vulkan_ctx_t *ctx, const char *name);
VkSampler QFV_GetSampler (vulkan_ctx_t *ctx, const char *name);
void QFV_ParseResources (vulkan_ctx_t *ctx, plitem_t *plist);
void QFV_InitParse (vulkan_ctx_t *ctx);
exprenum_t *QFV_GetEnum (const char *name);

View file

@ -232,9 +232,7 @@ Vulkan_Draw_Init (vulkan_ctx_t *ctx)
VK_IMAGE_VIEW_TYPE_2D,
VK_FORMAT_A1R5G5B5_UNORM_PACK16,
VK_IMAGE_ASPECT_COLOR_BIT);
handleref_t *h;
h = Hash_Find (ctx->samplers, "quakepic");
conchars_sampler = (VkSampler) h->handle;
conchars_sampler = QFV_GetSampler (ctx, "quakepic");
uint16_t *chars_data = ctx->staging[0]->data;
size_t size = charspic->width * charspic->height;
@ -294,16 +292,13 @@ Vulkan_Draw_Init (vulkan_ctx_t *ctx)
twod_pipeline = Vulkan_CreatePipeline (ctx, "twod");
h = Hash_Find (ctx->pipelineLayouts, "twod");
twod_layout = (VkPipelineLayout) h->handle;
twod_layout = QFV_GetPipelineLayout (ctx, "twod");
__auto_type layouts = QFV_AllocDescriptorSetLayoutSet (ctx->framebuffers.size, alloca);
for (size_t i = 0; i < layouts->size; i++) {
h = Hash_Find (ctx->setLayouts, "twod");
layouts->a[i] = (VkDescriptorSetLayout) h->handle;
layouts->a[i] = QFV_GetDescriptorSetLayout (ctx, "twod");
}
h = Hash_Find (ctx->descriptorPools, "twod");
__auto_type pool = (VkDescriptorPool) h->handle;
__auto_type pool = QFV_GetDescriptorPool (ctx, "twod");
VkDescriptorBufferInfo bufferInfo = {
ctx->matrices.buffer_2d, 0, VK_WHOLE_SIZE