From 1e58ca394b184fad6e3ecb8bd9a57cb4e39b8fe2 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 24 Jan 2025 14:49:51 +0900 Subject: [PATCH] [qfcc] Emit the MultiView capability when enabled Yet another validation error bites the dust. --- tools/qfcc/include/target.h | 1 + tools/qfcc/source/glsl-builtins.c | 4 +--- tools/qfcc/source/qc-parse.y | 3 --- tools/qfcc/source/qfcc.c | 5 +++++ tools/qfcc/source/target_spirv.c | 8 ++++++++ 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tools/qfcc/include/target.h b/tools/qfcc/include/target.h index 532d1bf3b..7f8d9aee2 100644 --- a/tools/qfcc/include/target.h +++ b/tools/qfcc/include/target.h @@ -37,6 +37,7 @@ typedef struct specifier_s specifier_t; typedef struct rua_ctx_s rua_ctx_t; typedef struct { + void (*init) (void); bool (*value_too_large) (const type_t *val_type); void (*build_scope) (symbol_t *fsym); void (*build_code) (function_t *func, const expr_t *statements); diff --git a/tools/qfcc/source/glsl-builtins.c b/tools/qfcc/source/glsl-builtins.c index 6c7dbed40..cf149fffd 100644 --- a/tools/qfcc/source/glsl-builtins.c +++ b/tools/qfcc/source/glsl-builtins.c @@ -1405,6 +1405,7 @@ void glsl_multiview (int behavior, void *scanner) { if (behavior) { + spirv_add_capability (pr.module, SpvCapabilityMultiView); rua_parse_define ("GL_EXT_multiview 1\n"); } else { rua_undefine ("GL_EXT_multiview", scanner); @@ -1441,9 +1442,6 @@ glsl_parse_vars (const char *var_src, rua_ctx_t *ctx) static void glsl_init_common (rua_ctx_t *ctx) { - static module_t module; //FIXME probably not what I want - pr.module = &module; - spirv_set_addressing_model (pr.module, SpvAddressingModelLogical); spirv_set_memory_model (pr.module, SpvMemoryModelGLSL450); diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index 2a9c877d2..9fec93d69 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -3281,9 +3281,6 @@ rua_init (rua_ctx_t *ctx) { ctx->language->initialized = true; if (options.code.spirv && !pr.module) { - static module_t module; //FIXME probably not what I want - pr.module = &module; - //FIXME unhardcode spirv_add_extension (pr.module, "SPV_KHR_multiview"); spirv_add_extinst_import (pr.module, "GLSL.std.450"); diff --git a/tools/qfcc/source/qfcc.c b/tools/qfcc/source/qfcc.c index 31f631f52..d51c7b1d7 100644 --- a/tools/qfcc/source/qfcc.c +++ b/tools/qfcc/source/qfcc.c @@ -90,6 +90,7 @@ #include "tools/qfcc/include/strpool.h" #include "tools/qfcc/include/struct.h" #include "tools/qfcc/include/symtab.h" +#include "tools/qfcc/include/target.h" #include "tools/qfcc/include/type.h" #include "tools/qfcc/include/value.h" @@ -194,6 +195,10 @@ InitData (void) clear_classes (); clear_immediates (); clear_selectors (); + + if (current_target.init) { + current_target.init (); + } } static int diff --git a/tools/qfcc/source/target_spirv.c b/tools/qfcc/source/target_spirv.c index 5f880acf6..814aa87ab 100644 --- a/tools/qfcc/source/target_spirv.c +++ b/tools/qfcc/source/target_spirv.c @@ -2422,7 +2422,15 @@ spirv_shift_op (int op, const expr_t *e1, const expr_t *e2) return fold_constants (e); } +static void +spirv_init (void) +{ + static module_t module; //FIXME probably not what I want + pr.module = &module; +} + target_t spirv_target = { + .init = spirv_init, .value_too_large = spirv_value_too_large, .build_scope = spirv_build_scope, .build_code = spirv_build_code,