mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-04-07 01:42:04 +00:00
[qfcc] Emit struct member decorations
They're not enough yet as offsets and strides need to be emitted.
This commit is contained in:
parent
96375e870a
commit
dcd2c565c1
1 changed files with 55 additions and 0 deletions
|
@ -270,6 +270,36 @@ spirv_DecorateLiteral (unsigned id, SpvDecoration decoration, void *literal,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
spirv_MemberDecorate (unsigned id, unsigned member,
|
||||
SpvDecoration decoration, spirvctx_t *ctx)
|
||||
{
|
||||
auto decorations = ctx->module->decorations;
|
||||
auto insn = spirv_new_insn (SpvOpMemberDecorate, 4, decorations);
|
||||
INSN (insn, 1) = id;
|
||||
INSN (insn, 2) = member;
|
||||
INSN (insn, 3) = decoration;
|
||||
}
|
||||
|
||||
static void
|
||||
spirv_MemberDecorateLiteral (unsigned id, unsigned member,
|
||||
SpvDecoration decoration,
|
||||
void *literal, etype_t type, spirvctx_t *ctx)
|
||||
{
|
||||
if (type != ev_int) {
|
||||
internal_error (0, "unexpected type");
|
||||
}
|
||||
int size = pr_type_size[type];
|
||||
auto decorations = ctx->module->decorations;
|
||||
auto insn = spirv_new_insn (SpvOpMemberDecorate, 4 + size, decorations);
|
||||
INSN (insn, 1) = id;
|
||||
INSN (insn, 2) = member;
|
||||
INSN (insn, 3) = decoration;
|
||||
if (type == ev_int) {
|
||||
INSN (insn, 4) = *(int *)literal;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
spirv_decorate_id (unsigned id, attribute_t *attributes, spirvctx_t *ctx)
|
||||
{
|
||||
|
@ -292,6 +322,30 @@ spirv_decorate_id (unsigned id, attribute_t *attributes, spirvctx_t *ctx)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
spirv_member_decorate_id (unsigned id, int member, attribute_t *attributes,
|
||||
spirvctx_t *ctx)
|
||||
{
|
||||
for (auto attr = attributes; attr; attr = attr->next) {
|
||||
unsigned decoration = spirv_enum_val ("Decoration", attr->name);
|
||||
if (attr->params) {
|
||||
//FIXME some decorations have more than one parameter (rare)
|
||||
int val;
|
||||
if (is_string_val (attr->params)) {
|
||||
//FIXME should get kind from decoration
|
||||
const char *name = expr_string (attr->params);
|
||||
val = spirv_enum_val (attr->name, name);
|
||||
} else {
|
||||
val = expr_integral (attr->params);
|
||||
}
|
||||
spirv_MemberDecorateLiteral (id, member, decoration,
|
||||
&val, ev_int, ctx);
|
||||
} else {
|
||||
spirv_MemberDecorate (id, member, decoration, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
spirv_MemberName (unsigned id, unsigned member, const char *name,
|
||||
spirvctx_t *ctx)
|
||||
|
@ -408,6 +462,7 @@ spirv_TypeStruct (const type_t *type, spirvctx_t *ctx)
|
|||
for (auto s = symtab->symbols; s; s = s->next) {
|
||||
int m = num_members++;
|
||||
spirv_MemberName (id, m, s->name, ctx);
|
||||
spirv_member_decorate_id (id, m, s->attributes, ctx);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue