mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
[vulkan] Implement task function parsing
This just sets up the memory block and cexpr descriptors for the parameters, parameter parsing is separate (and next). The parameters are aligned to their size.
This commit is contained in:
parent
3fea31875c
commit
2c3b89f722
6 changed files with 98 additions and 17 deletions
|
@ -67,7 +67,8 @@ typedef struct qfv_attachmentinfo_s {
|
|||
|
||||
typedef struct qfv_taskinfo_s {
|
||||
struct exprfunc_s *func;
|
||||
void *params;
|
||||
const struct exprval_s **params;
|
||||
void *param_data;
|
||||
} qfv_taskinfo_t;
|
||||
|
||||
typedef struct qfv_attachmentrefinfo_s {
|
||||
|
@ -132,6 +133,10 @@ typedef struct qfv_renderinfo_s {
|
|||
qfv_renderpassinfo_t *renderpasses;
|
||||
} qfv_renderinfo_t;
|
||||
|
||||
typedef struct qfv_renderctx_s {
|
||||
struct exprtab_s *task_functions;
|
||||
} qfv_renderctx_t;
|
||||
|
||||
typedef struct qfv_label_s {
|
||||
vec4f_t color;
|
||||
const char *name;
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "QF/hash.h"
|
||||
#include "QF/Vulkan/command.h"
|
||||
#include "QF/Vulkan/debug.h"
|
||||
#include "QF/Vulkan/device.h"
|
||||
|
@ -124,10 +125,27 @@ QFV_RunRenderPass (qfv_renderpass_t_ *rp, vulkan_ctx_t *ctx)
|
|||
QFV_CmdEndLabel (device, cmd);
|
||||
}
|
||||
|
||||
static exprsym_t qfv_renderpass_task_symbols[] = {
|
||||
|
||||
{}
|
||||
};
|
||||
|
||||
void
|
||||
QFV_LoadRenderPass (vulkan_ctx_t *ctx)
|
||||
{
|
||||
|
||||
exprtab_t task_tab = { qfv_renderpass_task_symbols, 0 };
|
||||
exprctx_t ectx = {
|
||||
.symtab = &task_tab,
|
||||
.hashctx = &ctx->script_context->hashctx,
|
||||
};
|
||||
cexpr_init_symtab (&task_tab, &ectx);
|
||||
|
||||
qfv_renderctx_t rctx = { .task_functions = &task_tab };
|
||||
|
||||
plitem_t *item = Vulkan_GetConfig (ctx, "main_def");
|
||||
__auto_type ri = QFV_ParseRenderInfo (ctx, item);
|
||||
__auto_type ri = QFV_ParseRenderInfo (ctx, item, &rctx);
|
||||
printf ("%p\n", ri);
|
||||
|
||||
Hash_DelTable (task_tab.tab);
|
||||
}
|
||||
|
|
|
@ -366,19 +366,19 @@ renderpasses = {
|
|||
color = $color.compose;
|
||||
pipeline = compose;
|
||||
tasks = (
|
||||
{ func = "lights_draw"; },
|
||||
{ func = "compose_draw"; },
|
||||
);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
deferred_cube = {
|
||||
/* deferred_cube = {
|
||||
@inherit = $renderpasses.deferred;
|
||||
@next = (VkRenderPassMultiviewCreateInfo, {
|
||||
viewMasks = (0x3fu, 0x3fu, 0x3fu, 0x3fu, 0x3fu);
|
||||
viewOffsets = ( 0, 0, 0, 0, 0);
|
||||
});
|
||||
};
|
||||
};*/
|
||||
};
|
||||
};
|
||||
|
|
|
@ -520,7 +520,7 @@ parse_inherit (const plfield_t *field, const plitem_t *item,
|
|||
ectx.result = &result;
|
||||
ectx.item = item;
|
||||
const char *inheritstr = PL_String (item);
|
||||
Sys_MaskPrintf (SYS_vulkan_parse, "parse_inherit: %s\n", inheritstr);
|
||||
//Sys_MaskPrintf (SYS_vulkan_parse, "parse_inherit: %s\n", inheritstr);
|
||||
int ret = !cexpr_eval_string (inheritstr, &ectx);
|
||||
if (ret) {
|
||||
ret = PL_ParseStruct (field->data, inheritItem, data, messages,
|
||||
|
@ -566,10 +566,10 @@ parse_RGBA (const plitem_t *item, void **data,
|
|||
ectx.result = &result;
|
||||
ectx.item = item;
|
||||
const char *valstr = PL_String (item);
|
||||
Sys_MaskPrintf (SYS_vulkan_parse, "parse_RGBA: %s\n", valstr);
|
||||
//Sys_MaskPrintf (SYS_vulkan_parse, "parse_RGBA: %s\n", valstr);
|
||||
ret = !cexpr_eval_string (valstr, &ectx);
|
||||
Sys_MaskPrintf (SYS_vulkan_parse, " "VEC4F_FMT"\n",
|
||||
VEC4_EXP (*(vec4f_t *)data[0]));
|
||||
//Sys_MaskPrintf (SYS_vulkan_parse, " "VEC4F_FMT"\n",
|
||||
// VEC4_EXP (*(vec4f_t *)data[0]));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1085,8 +1085,58 @@ static int
|
|||
parse_task_function (const plitem_t *item, void **data,
|
||||
plitem_t *messages, parsectx_t *pctx)
|
||||
{
|
||||
PL_Message (messages, item, "parse_task_function: not implemented");
|
||||
qfv_renderctx_t *rctx = pctx->data;
|
||||
const char *fname = PL_String (item);
|
||||
exprsym_t *fsym = Hash_Find (rctx->task_functions->tab, fname);
|
||||
|
||||
if (!fsym) {
|
||||
PL_Message (messages, item, "undefined task function %s", fname);
|
||||
return 0;
|
||||
}
|
||||
if (fsym->type != &cexpr_function) {
|
||||
PL_Message (messages, item, "not a function type %s", fname);
|
||||
return 0;
|
||||
}
|
||||
exprfunc_t *func;
|
||||
for (func = fsym->value; func->func; func++) {
|
||||
if (!func->result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!func->func) {
|
||||
PL_Message (messages, item, "%s does not have a void implementation",
|
||||
fname);
|
||||
return 0;
|
||||
}
|
||||
size_t size = func->num_params * sizeof (exprval_t);
|
||||
size += func->num_params * sizeof (exprval_t *);
|
||||
size_t base = size;
|
||||
for (int i = 0; i < func->num_params; i++) {
|
||||
exprtype_t *type = func->param_types[i];
|
||||
size = ((size + type->size - 1) & ~(type->size - 1));
|
||||
if (i == 0) {
|
||||
base = size;
|
||||
}
|
||||
}
|
||||
exprval_t **param_ptrs = vkparse_alloc (pctx, size);
|
||||
exprval_t *params = (exprval_t *) ¶m_ptrs[func->num_params];
|
||||
byte *param_data = (byte *) param_ptrs + base;
|
||||
memset (params, 0, size);
|
||||
size_t offs = 0;
|
||||
for (int i = 0; i < func->num_params; i++) {
|
||||
exprtype_t *type = func->param_types[i];
|
||||
param_ptrs[i] = ¶ms[i];
|
||||
params[i] = (exprval_t) {
|
||||
.type = type,
|
||||
.value = param_data + offs,
|
||||
};
|
||||
offs = ((offs + type->size - 1) & ~(type->size - 1));
|
||||
offs += type->size;
|
||||
}
|
||||
*(exprfunc_t **) data[0] = func;
|
||||
*(exprval_t ***) data[1] = param_ptrs;
|
||||
*(void **) data[2] = param_data;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2127,7 +2177,7 @@ Vulkan_CreateDescriptorSetLayout(vulkan_ctx_t *ctx, const char *name)
|
|||
}
|
||||
|
||||
qfv_renderinfo_t *
|
||||
QFV_ParseRenderInfo (vulkan_ctx_t *ctx, plitem_t *item)
|
||||
QFV_ParseRenderInfo (vulkan_ctx_t *ctx, plitem_t *item, qfv_renderctx_t *rctx)
|
||||
{
|
||||
memsuper_t *memsuper = new_memsuper ();
|
||||
qfv_renderinfo_t *ri = cmemalloc (memsuper, sizeof (qfv_renderinfo_t));
|
||||
|
@ -2139,7 +2189,12 @@ QFV_ParseRenderInfo (vulkan_ctx_t *ctx, plitem_t *item)
|
|||
scriptctx_t *sctx = ctx->script_context;
|
||||
plitem_t *messages = PL_NewArray ();
|
||||
exprctx_t exprctx = { .symtab = &root_symtab };
|
||||
parsectx_t parsectx = { &exprctx, ctx, properties };
|
||||
parsectx_t parsectx = {
|
||||
.ectx = &exprctx,
|
||||
.vctx = ctx,
|
||||
.properties = properties,
|
||||
.data = rctx
|
||||
};
|
||||
plitem_t *pl_items[num_keys + 3];
|
||||
exprsym_t var_syms[num_keys + 7 + 1];
|
||||
exprtab_t vars_tab = { var_syms, 0 };
|
||||
|
@ -2208,8 +2263,9 @@ QFV_ParseRenderInfo (vulkan_ctx_t *ctx, plitem_t *item)
|
|||
}
|
||||
Hash_DelTable (vars_tab.tab);
|
||||
PL_Free (messages);
|
||||
if (!ri) {
|
||||
if (!ret) {
|
||||
delete_memsuper (memsuper);
|
||||
ri = 0;
|
||||
}
|
||||
|
||||
return ri;
|
||||
|
|
|
@ -77,6 +77,8 @@ int QFV_ParseRGBA (vulkan_ctx_t *ctx, float *rgba, plitem_t *plist,
|
|||
plitem_t *properties);
|
||||
int QFV_ParseOutput (vulkan_ctx_t *ctx, qfv_output_t *output, plitem_t *plist,
|
||||
plitem_t *properties);
|
||||
struct qfv_renderctx_s;
|
||||
struct qfv_renderinfo_s *QFV_ParseRenderInfo (vulkan_ctx_t *ctx,
|
||||
plitem_t *item);
|
||||
plitem_t *item,
|
||||
struct qfv_renderctx_s *rctx);
|
||||
#endif//__vkparse_h
|
||||
|
|
|
@ -427,11 +427,11 @@
|
|||
.name = qfv_taskinfo_t;
|
||||
func = {
|
||||
type = (custom, QFString, parse_task_function);
|
||||
fields = (func);
|
||||
fields = (func, params, param_data);
|
||||
};
|
||||
params = {
|
||||
type = (custom, QFArray, parse_task_params);
|
||||
fields = (params, func);
|
||||
fields = (func, params, param_data);
|
||||
};
|
||||
};
|
||||
qfv_attachmentrefinfo_s = {
|
||||
|
|
Loading…
Reference in a new issue