mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 21:21:14 +00:00
I really don't like the way they're included (I'm really looking forward to #embed, but gotta wait for gcc 15), and I'm a tad grumpy that the documentation for them (https://registry.khronos.org/SPIR-V/specs/unified1/MachineReadableGrammar.html) is wrong (missing fields), but I think I like the result. The grammars (core and glsl.std.450) are parsed into structs that should be fairly easy to interpret: the instructions, kinds, and enumerant values are sorted by name for search with bsearch. Having the data parsed in means source code can refer to the items by name rather than magic numbers, which will be very nice for intrinsics and image types (and probably a few other things).
80 lines
2.2 KiB
C
80 lines
2.2 KiB
C
/*
|
|
spirv.c
|
|
|
|
qfcc spir-v file support
|
|
|
|
Copyright (C) 2024 Bill Currie <bill@taniwha.org>
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; either version 2
|
|
of the License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to:
|
|
|
|
Free Software Foundation, Inc.
|
|
59 Temple Place - Suite 330
|
|
Boston, MA 02111-1307, USA
|
|
|
|
*/
|
|
|
|
#ifndef __spirv_h
|
|
#define __spirv_h
|
|
|
|
#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;
|
|
const char *name;
|
|
attribute_t *modes;
|
|
ex_list_t interface; ///< list of symbols forming interface
|
|
} entrypoint_t;
|
|
|
|
typedef struct module_s {
|
|
ex_list_t capabilities;
|
|
ex_list_t extensions;
|
|
symtab_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;
|
|
// debug
|
|
defspace_t *strings;
|
|
defspace_t *names;
|
|
defspace_t *module_processed;
|
|
// annotations
|
|
defspace_t *decorations;
|
|
// types, non-function variables, undefs
|
|
defspace_t *globals;
|
|
// functions
|
|
defspace_t *func_declarations;
|
|
defspace_t *func_definitions;
|
|
} module_t;
|
|
|
|
void spirv_add_capability (module_t *module, SpvCapability capability);
|
|
void spirv_add_extension (module_t *module, const char *extension);
|
|
void spirv_add_extinst_import (module_t *module, const char *import);
|
|
void spirv_set_addressing_model (module_t *module, SpvAddressingModel model);
|
|
void spirv_set_memory_model (module_t *module, SpvMemoryModel model);
|
|
bool spirv_write (struct pr_info_s *pr, const char *filename);
|
|
|
|
const struct plitem_s *spirv_operand_kind (const char *set, const char *kind);
|
|
|
|
#endif//__spirv_h
|