mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-14 00:40:55 +00:00
[vulkan] Clean up some tangled dependencies
Dependencies on vkparse.hinc were spreading through the code which I didn't want as that removes a lot of the automation from the automake files. This keeps all parser code internal to vkparse.c's scope, and any accesses required for enum and struct (not yet) definitions can be fetched by name.
This commit is contained in:
parent
a6a3d4c6b5
commit
e4f75791ce
11 changed files with 62 additions and 31 deletions
|
@ -15,8 +15,5 @@ VkShaderModule QFV_FindShaderModule (struct vulkan_ctx_s *ctx,
|
||||||
void QFV_RegisterShaderModule (struct vulkan_ctx_s *ctx, const char *name,
|
void QFV_RegisterShaderModule (struct vulkan_ctx_s *ctx, const char *name,
|
||||||
VkShaderModule module);
|
VkShaderModule module);
|
||||||
void QFV_DeregisterShaderModule (struct vulkan_ctx_s *ctx, const char *name);
|
void QFV_DeregisterShaderModule (struct vulkan_ctx_s *ctx, const char *name);
|
||||||
int parse_VkShaderModule (const struct plitem_s *item, void **data,
|
|
||||||
struct plitem_s *messages,
|
|
||||||
struct parsectx_s *context);
|
|
||||||
|
|
||||||
#endif//__QF_Vulkan_shader_h
|
#endif//__QF_Vulkan_shader_h
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
#include "QF/hash.h"
|
#include "QF/hash.h"
|
||||||
#include "QF/input.h"
|
#include "QF/input.h"
|
||||||
#include "QF/mathlib.h"
|
#include "QF/mathlib.h"
|
||||||
#include "QF/qargs.h"
|
|
||||||
#include "QF/quakefs.h"
|
#include "QF/quakefs.h"
|
||||||
#include "QF/sys.h"
|
#include "QF/sys.h"
|
||||||
#include "QF/va.h"
|
#include "QF/va.h"
|
||||||
|
|
|
@ -53,7 +53,6 @@
|
||||||
#include "QF/Vulkan/shader.h"
|
#include "QF/Vulkan/shader.h"
|
||||||
|
|
||||||
#include "vid_vulkan.h"
|
#include "vid_vulkan.h"
|
||||||
#include "vkparse.h"
|
|
||||||
|
|
||||||
static
|
static
|
||||||
#include "libs/video/renderer/vulkan/passthrough.vert.spvc"
|
#include "libs/video/renderer/vulkan/passthrough.vert.spvc"
|
||||||
|
@ -212,18 +211,3 @@ QFV_DeregisterShaderModule (vulkan_ctx_t *ctx, const char *name)
|
||||||
}
|
}
|
||||||
Hash_Free (ctx->shadermodules, Hash_Del (ctx->shadermodules, name));
|
Hash_Free (ctx->shadermodules, Hash_Del (ctx->shadermodules, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
parse_VkShaderModule (const plitem_t *item, void **data,
|
|
||||||
plitem_t *messages, parsectx_t *context)
|
|
||||||
{
|
|
||||||
vulkan_ctx_t *ctx = context->vctx;
|
|
||||||
const char *name = PL_String (item);
|
|
||||||
__auto_type mptr = (VkShaderModule *)data[0];
|
|
||||||
VkShaderModule module = QFV_FindShaderModule (ctx, name);
|
|
||||||
if (module) {
|
|
||||||
*mptr = module;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
}
|
}
|
||||||
-(void) writeTable;
|
-(void) writeTable;
|
||||||
-(void) writeSymtabInit;
|
-(void) writeSymtabInit;
|
||||||
|
-(void) writeSymtabEntry;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif//__renderer_vulkan_vkgen_vkenum_h
|
#endif//__renderer_vulkan_vkgen_vkenum_h
|
||||||
|
|
|
@ -147,6 +147,12 @@ skip_value(string name)
|
||||||
[self name]);
|
[self name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void) writeSymtabEntry
|
||||||
|
{
|
||||||
|
fprintf (output_file, "\tHash_Add (enum_symtab, &%s_enum);\n",
|
||||||
|
[self name]);
|
||||||
|
}
|
||||||
|
|
||||||
-(string) cexprType
|
-(string) cexprType
|
||||||
{
|
{
|
||||||
return [self name] + "_type";
|
return [self name] + "_type";
|
||||||
|
|
|
@ -251,6 +251,7 @@ main(int argc, string *argv)
|
||||||
}
|
}
|
||||||
arp_start ();
|
arp_start ();
|
||||||
[obj writeSymtabInit];
|
[obj writeSymtabInit];
|
||||||
|
[obj writeSymtabEntry];
|
||||||
arp_end ();
|
arp_end ();
|
||||||
}
|
}
|
||||||
fprintf (output_file, "}\n");
|
fprintf (output_file, "}\n");
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
-(qfot_var_t *)findField:(string) fieldName;
|
-(qfot_var_t *)findField:(string) fieldName;
|
||||||
-(void) writeTable;
|
-(void) writeTable;
|
||||||
-(void) writeSymtabInit;
|
-(void) writeSymtabInit;
|
||||||
|
-(void) writeSymtabEntry;
|
||||||
-(string) outname;
|
-(string) outname;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,10 @@
|
||||||
[self outname]);
|
[self outname]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void) writeSymtabEntry
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
-(string) outname
|
-(string) outname
|
||||||
{
|
{
|
||||||
if (outname) {
|
if (outname) {
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include "QF/cmem.h"
|
#include "QF/cmem.h"
|
||||||
#include "QF/cvar.h"
|
#include "QF/cvar.h"
|
||||||
#include "QF/dstring.h"
|
#include "QF/dstring.h"
|
||||||
|
#include "QF/hash.h"
|
||||||
#include "QF/input.h"
|
#include "QF/input.h"
|
||||||
#include "QF/mathlib.h"
|
#include "QF/mathlib.h"
|
||||||
#include "QF/qargs.h"
|
#include "QF/qargs.h"
|
||||||
|
@ -50,6 +51,7 @@
|
||||||
#include "QF/sys.h"
|
#include "QF/sys.h"
|
||||||
#include "QF/va.h"
|
#include "QF/va.h"
|
||||||
#include "QF/vid.h"
|
#include "QF/vid.h"
|
||||||
|
#include "QF/simd/vec4f.h"
|
||||||
#include "QF/Vulkan/qf_vid.h"
|
#include "QF/Vulkan/qf_vid.h"
|
||||||
#include "QF/Vulkan/device.h"
|
#include "QF/Vulkan/device.h"
|
||||||
#include "QF/Vulkan/command.h"
|
#include "QF/Vulkan/command.h"
|
||||||
|
@ -65,7 +67,10 @@
|
||||||
#include "vid_vulkan.h"
|
#include "vid_vulkan.h"
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
#define vkparse_internal
|
||||||
#include "vkparse.h"
|
#include "vkparse.h"
|
||||||
|
#undef vkparse_internal
|
||||||
|
|
||||||
static void flag_or (const exprval_t *val1, const exprval_t *val2,
|
static void flag_or (const exprval_t *val1, const exprval_t *val2,
|
||||||
exprval_t *result, exprctx_t *ctx)
|
exprval_t *result, exprctx_t *ctx)
|
||||||
|
@ -145,19 +150,16 @@ parse_basic (const plfield_t *field, const plitem_t *item,
|
||||||
ectx.symtab = 0;
|
ectx.symtab = 0;
|
||||||
ectx.result = &result;
|
ectx.result = &result;
|
||||||
const char *valstr = PL_String (item);
|
const char *valstr = PL_String (item);
|
||||||
//Sys_Printf ("parse_uint32_t: %s %zd %d %p %p: %s\n",
|
//Sys_Printf ("parse_basic: %s %zd %d %p %p: %s\n",
|
||||||
// field->name, field->offset, field->type, field->parser,
|
// field->name, field->offset, field->type, field->parser,
|
||||||
// field->data, valstr);
|
// field->data, valstr);
|
||||||
if (strcmp (valstr, "VK_SUBPASS_EXTERNAL") == 0) {
|
if (strcmp (valstr, "VK_SUBPASS_EXTERNAL") == 0) {
|
||||||
//FIXME handle subpass in a separate parser?
|
//FIXME handle subpass in a separate parser?
|
||||||
*(uint32_t *) data = VK_SUBPASS_EXTERNAL;
|
*(uint32_t *) data = VK_SUBPASS_EXTERNAL;
|
||||||
} else {
|
} else {
|
||||||
Sys_Printf ("parse_uint32_t: %s %zd %d %p %p %s\n",
|
|
||||||
field->name, field->offset, field->type, field->parser,
|
|
||||||
field->data, valstr);
|
|
||||||
ret = !cexpr_eval_string (valstr, &ectx);
|
ret = !cexpr_eval_string (valstr, &ectx);
|
||||||
Sys_Printf (" %x\n", *(uint32_t *)data);
|
|
||||||
}
|
}
|
||||||
|
//Sys_Printf (" %x\n", *(uint32_t *)data);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -179,11 +181,11 @@ parse_uint32_t (const plfield_t *field, const plitem_t *item,
|
||||||
//FIXME handle subpass in a separate parser?
|
//FIXME handle subpass in a separate parser?
|
||||||
*(uint32_t *) data = VK_SUBPASS_EXTERNAL;
|
*(uint32_t *) data = VK_SUBPASS_EXTERNAL;
|
||||||
} else {
|
} else {
|
||||||
Sys_Printf ("parse_uint32_t: %s %zd %d %p %p %s\n",
|
//Sys_Printf ("parse_uint32_t: %s %zd %d %p %p %s\n",
|
||||||
field->name, field->offset, field->type, field->parser,
|
// field->name, field->offset, field->type, field->parser,
|
||||||
field->data, valstr);
|
// field->data, valstr);
|
||||||
ret = !cexpr_eval_string (valstr, &ectx);
|
ret = !cexpr_eval_string (valstr, &ectx);
|
||||||
Sys_Printf (" %d\n", *(uint32_t *)data);
|
//Sys_Printf (" %d\n", *(uint32_t *)data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -327,6 +329,23 @@ parse_custom (const plfield_t *field, const plitem_t *item,
|
||||||
return custom->parse (item, offsets, messages, context);
|
return custom->parse (item, offsets, messages, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
parse_VkShaderModule (const plitem_t *item, void **data,
|
||||||
|
plitem_t *messages, parsectx_t *context)
|
||||||
|
{
|
||||||
|
vulkan_ctx_t *ctx = context->vctx;
|
||||||
|
const char *name = PL_String (item);
|
||||||
|
__auto_type mptr = (VkShaderModule *)data[0];
|
||||||
|
VkShaderModule module = QFV_FindShaderModule (ctx, name);
|
||||||
|
if (module) {
|
||||||
|
*mptr = module;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static hashtab_t *enum_symtab;
|
||||||
|
|
||||||
#include "libs/video/renderer/vulkan/vkparse.cinc"
|
#include "libs/video/renderer/vulkan/vkparse.cinc"
|
||||||
|
|
||||||
typedef struct qfv_renderpass_s {
|
typedef struct qfv_renderpass_s {
|
||||||
|
@ -421,9 +440,24 @@ QFV_ParseRenderPass (vulkan_ctx_t *ctx, plitem_t *plist)
|
||||||
return renderpass;
|
return renderpass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
enum_symtab_getkey (const void *e, void *unused)
|
||||||
|
{
|
||||||
|
__auto_type enm = (const exprenum_t *) e;
|
||||||
|
return enm->type->name;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QFV_InitParse (void)
|
QFV_InitParse (void)
|
||||||
{
|
{
|
||||||
exprctx_t context = {};
|
exprctx_t context = {};
|
||||||
|
enum_symtab = Hash_NewTable (61, enum_symtab_getkey, 0, 0,
|
||||||
|
&context.hashlinks);
|
||||||
vkgen_init_symtabs (&context);
|
vkgen_init_symtabs (&context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exprenum_t *
|
||||||
|
QFV_GetEnum (const char *name)
|
||||||
|
{
|
||||||
|
return Hash_Find (enum_symtab, name);
|
||||||
|
}
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
|
|
||||||
#include "QF/cexpr.h"
|
#include "QF/cexpr.h"
|
||||||
#include "QF/Vulkan/renderpass.h"
|
#include "QF/Vulkan/renderpass.h"
|
||||||
|
#ifdef vkparse_internal
|
||||||
#include "libs/video/renderer/vulkan/vkparse.hinc"
|
#include "libs/video/renderer/vulkan/vkparse.hinc"
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct parsectx_s {
|
typedef struct parsectx_s {
|
||||||
struct exprctx_s *ectx;
|
struct exprctx_s *ectx;
|
||||||
|
@ -12,5 +14,6 @@ typedef struct parsectx_s {
|
||||||
|
|
||||||
VkRenderPass QFV_ParseRenderPass (vulkan_ctx_t *ctx, plitem_t *plist);
|
VkRenderPass QFV_ParseRenderPass (vulkan_ctx_t *ctx, plitem_t *plist);
|
||||||
void QFV_InitParse (void);
|
void QFV_InitParse (void);
|
||||||
|
exprenum_t *QFV_GetEnum (const char *name);
|
||||||
|
|
||||||
#endif//__vkparse_h
|
#endif//__vkparse_h
|
||||||
|
|
|
@ -98,11 +98,12 @@ msaaSamples_f (cvar_t *var)
|
||||||
exprctx_t context = {};
|
exprctx_t context = {};
|
||||||
context.memsuper = new_memsuper();
|
context.memsuper = new_memsuper();
|
||||||
|
|
||||||
if (cexpr_parse_enum (&VkSampleCountFlagBits_enum, var->string, &context,
|
if (cexpr_parse_enum (QFV_GetEnum ("VkSampleCountFlagBits"), var->string,
|
||||||
&var->int_val)) {
|
&context, &var->int_val)) {
|
||||||
Sys_Printf ("Invalid MSAA samples, using 1\n");
|
Sys_Printf ("Invalid MSAA samples, using 1\n");
|
||||||
var->int_val = VK_SAMPLE_COUNT_1_BIT;
|
var->int_val = VK_SAMPLE_COUNT_1_BIT;
|
||||||
}
|
}
|
||||||
|
delete_memsuper (context.memsuper);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue