mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-04-07 01:42:04 +00:00
[qfcc] Specify entry-point interface variables
Yet another step closer to having a working glsl compiler.
This commit is contained in:
parent
c5613ba1e4
commit
dc85a4df4b
2 changed files with 14 additions and 1 deletions
|
@ -30,9 +30,13 @@
|
|||
|
||||
#include <spirv/unified1/spirv.h>
|
||||
|
||||
#include "QF/darray.h"
|
||||
|
||||
#include "tools/qfcc/include/defspace.h"
|
||||
#include "tools/qfcc/include/expr.h"
|
||||
|
||||
typedef struct symbol_s symbol_t;
|
||||
|
||||
typedef struct entrypoint_s {
|
||||
struct entrypoint_s *next;
|
||||
SpvExecutionModel model;
|
||||
|
@ -47,6 +51,7 @@ typedef struct module_s {
|
|||
ex_list_t extinst_imports;
|
||||
const expr_t *addressing_model;
|
||||
const expr_t *memory_model;
|
||||
struct DARRAY_TYPE (symbol_t *) interface_syms;
|
||||
//entrypoint_t *entry_points;
|
||||
defspace_t *entry_points;
|
||||
defspace_t *exec_modes;
|
||||
|
|
|
@ -470,6 +470,8 @@ spirv_variable (symbol_t *sym, spirvctx_t *ctx)
|
|||
auto storage = spirv_storage_class (sym->var.storage);
|
||||
if (storage == SpvStorageClassFunction) {
|
||||
space = ctx->decl_space;
|
||||
} else {
|
||||
DARRAY_APPEND (&ctx->module->interface_syms, sym);
|
||||
}
|
||||
auto type = sym->type;
|
||||
unsigned tid = type_id (type, ctx);
|
||||
|
@ -584,11 +586,16 @@ spirv_EntryPoint (unsigned func_id, const char *func_name,
|
|||
SpvExecutionModel model, spirvctx_t *ctx)
|
||||
{
|
||||
int len = strlen (func_name) + 1;
|
||||
int iface_start = 3 + RUP(len, 4) / 4;
|
||||
auto linkage = ctx->module->entry_points;
|
||||
auto insn = spirv_new_insn (SpvOpEntryPoint, 3 + RUP(len, 4) / 4, linkage);
|
||||
int count = ctx->module->interface_syms.size;
|
||||
auto insn = spirv_new_insn (SpvOpEntryPoint, iface_start + count, linkage);
|
||||
INSN (insn, 1) = model;
|
||||
INSN (insn, 2) = func_id;
|
||||
memcpy (&INSN (insn, 3), func_name, len);
|
||||
for (int i = 0; i < count; i++) {
|
||||
INSN (insn, iface_start + i) = ctx->module->interface_syms.a[i]->id;
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
@ -1169,6 +1176,7 @@ spirv_write (struct pr_info_s *pr, const char *filename)
|
|||
pr->module->globals = defspace_new (ds_backed);
|
||||
pr->module->func_declarations = defspace_new (ds_backed);
|
||||
pr->module->func_definitions = defspace_new (ds_backed);
|
||||
DARRAY_INIT (&pr->module->interface_syms, 16);
|
||||
|
||||
spirvctx_t ctx = {
|
||||
.module = pr->module,
|
||||
|
|
Loading…
Reference in a new issue