[qfcc] Ensure compute shaders set all local_size elements

The default value is 1, and the assumption in target_spirv is that if
the first one is set, all are set, but the source code doesn't need to
set any explicitly.
This commit is contained in:
Bill Currie 2025-01-21 12:14:06 +09:00
parent 622be33e4b
commit f4cbe3f220
4 changed files with 30 additions and 1 deletions

View file

@ -42,6 +42,7 @@ typedef struct defspace_s defspace_t;
typedef struct rua_ctx_s rua_ctx_t;
void glsl_init_comp (rua_ctx_t *ctx);
int glsl_finish_comp (const char *file, rua_ctx_t *ctx);
void glsl_init_vert (rua_ctx_t *ctx);
void glsl_init_tesc (rua_ctx_t *ctx);
void glsl_init_tese (rua_ctx_t *ctx);

View file

@ -1948,6 +1948,7 @@ language_t lang_glsl_comp = {
.default_float = true,
.init = glsl_init_comp,
.parse = glsl_yyparse,
.finish = glsl_finish_comp,
.extension = glsl_extension,
.version = glsl_version,
.on_include = glsl_on_include,

View file

@ -35,7 +35,9 @@
#include "tools/qfcc/include/def.h"
#include "tools/qfcc/include/diagnostic.h"
#include "tools/qfcc/include/glsl-lang.h"
#include "tools/qfcc/include/qfcc.h"
#include "tools/qfcc/include/shared.h"
#include "tools/qfcc/include/spirv.h"
#include "tools/qfcc/include/strpool.h"
#include "tools/qfcc/include/symtab.h"
#include "tools/qfcc/include/type.h"
@ -52,3 +54,27 @@ glsl_sublang_t glsl_comp_sublanguage = {
.interface_default_names = glsl_comp_interface_default_names,
.model_name = "GLCompute",
};
int
glsl_finish_comp (const char *file, rua_ctx_t *ctx)
{
if (!pr.module || !pr.module->entry_points) {
return 1;
}
const expr_t *size = nullptr;
for (int i = 0; i < 3; i++) {
if (!pr.module->entry_points->local_size[i]) {
size = new_int_expr (1, false);
break;
}
}
if (size) {
for (int i = 0; i < 3; i++) {
if (!pr.module->entry_points->local_size[i]) {
pr.module->entry_points->local_size[i] = size;
break;
}
}
}
return 1;
}

View file

@ -3261,7 +3261,8 @@ qc_parse_string (const char *str, rua_ctx_t *ctx)
return ret;
}
static int qc_finish (const char *file, rua_ctx_t *ctx)
static int
qc_finish (const char *file, rua_ctx_t *ctx)
{
if (options.frames_files) {
write_frame_macros (va (0, "%s.frame", file_basename (file, 0)));