[qfcc] Implement many glsl qualifiers as attributes

Attributes seem appropriate as GLSL's qualifiers affect variables rather
than types (since there's no typedef).

Not much is done with the attributes yet other than some basic error
checking (duplicates of non-layout attributes) and debug output, but
most (if not all) declarations get to the declaration code with
attributes intact.
This commit is contained in:
Bill Currie 2024-09-09 11:52:47 +09:00
parent ad3ae1abec
commit c58748d640
20 changed files with 857 additions and 59 deletions

View file

@ -416,8 +416,9 @@ int list_count (const ex_list_t *list) __attribute__((pure));
void list_scatter (const ex_list_t *list, const expr_t **exprs); void list_scatter (const ex_list_t *list, const expr_t **exprs);
void list_scatter_rev (const ex_list_t *list, const expr_t **exprs); void list_scatter_rev (const ex_list_t *list, const expr_t **exprs);
void list_gather (ex_list_t *dst, const expr_t **exprs, int count); void list_gather (ex_list_t *dst, const expr_t **exprs, int count);
void list_append (ex_list_t *dst, const expr_t *exprs); void list_append (ex_list_t *dst, const expr_t *expr);
void list_prepend (ex_list_t *dst, const expr_t *exprs); void list_append_list (ex_list_t *dst, const ex_list_t *src);
void list_prepend (ex_list_t *dst, const expr_t *expr);
expr_t *new_list_expr (const expr_t *first); expr_t *new_list_expr (const expr_t *first);
expr_t *expr_append_expr (expr_t *list, const expr_t *expr); expr_t *expr_append_expr (expr_t *list, const expr_t *expr);
expr_t *expr_prepend_expr (expr_t *list, const expr_t *expr); expr_t *expr_prepend_expr (expr_t *list, const expr_t *expr);

View file

@ -28,6 +28,14 @@
#ifndef __glsl_lang_h #ifndef __glsl_lang_h
#define __glsl_lang_h #define __glsl_lang_h
typedef struct specifier_s specifier_t;
typedef struct attribute_s attribute_t;
typedef struct expr_s expr_t;
typedef struct type_s type_t;
typedef struct symbol_s symbol_t;
typedef struct symtab_s symtab_t;
typedef struct language_s language_t;
void glsl_init_comp (void); void glsl_init_comp (void);
void glsl_init_vert (void); void glsl_init_vert (void);
void glsl_init_tesc (void); void glsl_init_tesc (void);
@ -37,7 +45,6 @@ void glsl_init_frag (void);
int glsl_parse_string (const char *str); int glsl_parse_string (const char *str);
typedef struct language_s language_t;
extern language_t lang_glsl_comp; extern language_t lang_glsl_comp;
extern language_t lang_glsl_vert; extern language_t lang_glsl_vert;
extern language_t lang_glsl_tesc; extern language_t lang_glsl_tesc;
@ -57,18 +64,38 @@ typedef enum glsl_interface_e : unsigned {
#define glsl_iftype_from_sc(sc) ((glsl_interface_t)((sc) - sc_in)) #define glsl_iftype_from_sc(sc) ((glsl_interface_t)((sc) - sc_in))
#define glsl_sc_from_iftype(it) (((storage_class_t)(it)) + sc_in) #define glsl_sc_from_iftype(it) (((storage_class_t)(it)) + sc_in)
extern const char *glsl_interface_names[glsl_num_interfaces];
typedef struct glsl_block_s { typedef struct glsl_block_s {
struct glsl_block_s *next; struct glsl_block_s *next;
const char *name; const char *name;
struct symtab_s *members; attribute_t *attributes;
struct symbol_s *instance_name; symtab_t *members;
symbol_t *instance_name;
} glsl_block_t; } glsl_block_t;
struct specifier_s; typedef struct glsl_sublang_s {
const char *name;
const char **interface_default_names;
} glsl_sublang_t;
#define glsl_sublang (*(glsl_sublang_t *) current_language.sublanguage)
extern glsl_sublang_t glsl_comp_sublanguage;
extern glsl_sublang_t glsl_vert_sublanguage;
extern glsl_sublang_t glsl_tesc_sublanguage;
extern glsl_sublang_t glsl_tese_sublanguage;
extern glsl_sublang_t glsl_geom_sublanguage;
extern glsl_sublang_t glsl_frag_sublanguage;
void glsl_block_clear (void); void glsl_block_clear (void);
void glsl_declare_block (struct specifier_s spec, struct symbol_s *block_sym, void glsl_declare_block (specifier_t spec, symbol_t *block_sym,
struct symbol_s *instance_name); symbol_t *instance_name);
glsl_block_t *glsl_get_block (const char *name, glsl_interface_t interface);
symtab_t *glsl_optimize_attributes (attribute_t *attributes);
void glsl_parse_declaration (specifier_t spec,
symbol_t *sym, const type_t *array,
const expr_t *init, symtab_t *symtab);
void glsl_declare_field (specifier_t spec, symtab_t *symtab);
bool glsl_on_include (const char *name); bool glsl_on_include (const char *name);
void glsl_include (int behavior, void *scanner); void glsl_include (int behavior, void *scanner);

View file

@ -37,6 +37,7 @@
typedef struct keyword_s { typedef struct keyword_s {
const char *name; const char *name;
int value; int value;
bool use_name;
specifier_t spec; specifier_t spec;
} keyword_t; } keyword_t;
@ -88,6 +89,7 @@ typedef union rua_val_s {
unsigned size; unsigned size;
specifier_t spec; specifier_t spec;
void *pointer; // for ensuring pointer values are null void *pointer; // for ensuring pointer values are null
const char *string;
funcstate_t funcstate; funcstate_t funcstate;
const struct type_s *type; const struct type_s *type;
const struct expr_s *expr; const struct expr_s *expr;
@ -198,6 +200,7 @@ typedef struct language_s {
void (*extension) (const char *name, const char *value, void *scanner); void (*extension) (const char *name, const char *value, void *scanner);
void (*version) (int version, const char *profile); void (*version) (int version, const char *profile);
bool (*on_include) (const char *name); bool (*on_include) (const char *name);
void *sublanguage;
} language_t; } language_t;
extern language_t current_language; extern language_t current_language;

View file

@ -35,6 +35,8 @@ typedef struct type_s type_t;
typedef struct expr_s expr_t; typedef struct expr_s expr_t;
typedef struct symbol_s symbol_t; typedef struct symbol_s symbol_t;
typedef struct symtab_s symtab_t; typedef struct symtab_s symtab_t;
typedef struct param_s param_t;
typedef struct attribute_s attribute_t;
/** Specify the storage class of a def. /** Specify the storage class of a def.
*/ */
@ -59,7 +61,8 @@ extern const char *storage_class_names[sc_count];
typedef struct specifier_s { typedef struct specifier_s {
const type_t *type; const type_t *type;
const expr_t *type_expr; const expr_t *type_expr;
struct param_s *params; attribute_t *attributes;
param_t *params;
symbol_t *sym; symbol_t *sym;
symtab_t *symtab; symtab_t *symtab;
storage_class_t storage; storage_class_t storage;

View file

@ -60,6 +60,7 @@ typedef enum {
sy_convert, ///< symbol refers to a conversion function sy_convert, ///< symbol refers to a conversion function
sy_macro, ///< symbol refers to a macro definition sy_macro, ///< symbol refers to a macro definition
sy_namespace, ///< symbol refers to a namespace definition sy_namespace, ///< symbol refers to a namespace definition
sy_list,
} sy_type_e; } sy_type_e;
typedef struct symconv_s { typedef struct symconv_s {
@ -85,6 +86,7 @@ typedef struct symbol_s {
symconv_t convert; ///< sy_convert symconv_t convert; ///< sy_convert
struct rua_macro_s *macro; ///< sy_macro struct rua_macro_s *macro; ///< sy_macro
struct symtab_s *namespace; ///< sy_namespace struct symtab_s *namespace; ///< sy_namespace
ex_list_t list; ///< sy_list
}; };
} symbol_t; } symbol_t;

View file

@ -42,9 +42,17 @@ qfcc_SOURCES = \
tools/qfcc/source/evaluate_type.c \ tools/qfcc/source/evaluate_type.c \
tools/qfcc/source/flow.c \ tools/qfcc/source/flow.c \
tools/qfcc/source/function.c \ tools/qfcc/source/function.c \
tools/qfcc/source/glsl-attribute.c \
tools/qfcc/source/glsl-block.c \ tools/qfcc/source/glsl-block.c \
tools/qfcc/source/glsl-builtins.c \ tools/qfcc/source/glsl-builtins.c \
tools/qfcc/source/glsl-declaration.c \
tools/qfcc/source/glsl-parse.y \ tools/qfcc/source/glsl-parse.y \
tools/qfcc/source/glsl-sub_comp.c \
tools/qfcc/source/glsl-sub_frag.c \
tools/qfcc/source/glsl-sub_geom.c \
tools/qfcc/source/glsl-sub_tesc.c \
tools/qfcc/source/glsl-sub_tese.c \
tools/qfcc/source/glsl-sub_vert.c \
tools/qfcc/source/grab.c \ tools/qfcc/source/grab.c \
tools/qfcc/source/idstuff.c \ tools/qfcc/source/idstuff.c \
tools/qfcc/source/linker.c \ tools/qfcc/source/linker.c \

View file

@ -40,19 +40,32 @@
ALLOC_STATE (attribute_t, attributes); ALLOC_STATE (attribute_t, attributes);
attribute_t *new_attribute(const char *name, const expr_t *params) attribute_t *
new_attribute(const char *name, const expr_t *params)
{ {
if (params && params->type != ex_list) { if (params && params->type != ex_list) {
internal_error (params, "attribute params not a list"); internal_error (params, "attribute params not a list");
} }
bool err = false;
if (params) { if (params) {
for (auto p = params->list.head; p; p = p->next) { for (auto p = params->list.head; p; p = p->next) {
if (p->expr->type != ex_value) { auto e = p->expr;
error (p->expr, "not a literal constant"); if (e->type == ex_expr) {
return 0; if (e->expr.op != '='
|| !is_string_val (e->expr.e1)
|| e->expr.e2->type != ex_value) {
error (e, "not a key=literal constnat");
err = true;
}
} else if (e->type != ex_value) {
error (e, "not a literal constant");
err = true;
} }
} }
} }
if (err) {
return nullptr;
}
attribute_t *attr; attribute_t *attr;
ALLOC (16384, attribute_t, attributes, attr); ALLOC (16384, attribute_t, attributes, attr);

View file

@ -311,6 +311,20 @@ list_append (ex_list_t *list, const expr_t *expr)
list->tail = &li->next; list->tail = &li->next;
} }
void
list_append_list (ex_list_t *dst, const ex_list_t *src)
{
if (!dst->tail) {
dst->tail = &dst->head;
}
for (auto s = src->head; s; s = s->next) {
auto li = new_listitem (s->expr);
*dst->tail = li;
dst->tail = &li->next;
}
}
void void
list_prepend (ex_list_t *list, const expr_t *expr) list_prepend (ex_list_t *list, const expr_t *expr)
{ {

View file

@ -108,6 +108,7 @@ is_lvalue (const expr_t *expr)
break; break;
case sy_macro: case sy_macro:
case sy_namespace: case sy_namespace:
case sy_list:
break; break;
} }
break; break;

View file

@ -0,0 +1,213 @@
/*
glsl-declaration.c
GLSL declaration handling
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
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "QF/alloc.h"
#include "QF/hash.h"
#include "QF/va.h"
#include "tools/qfcc/include/attribute.h"
#include "tools/qfcc/include/def.h"
#include "tools/qfcc/include/diagnostic.h"
#include "tools/qfcc/include/glsl-lang.h"
#include "tools/qfcc/include/shared.h"
#include "tools/qfcc/include/strpool.h"
#include "tools/qfcc/include/symtab.h"
#include "tools/qfcc/include/type.h"
#include "tools/qfcc/include/value.h"
#if 0
typedef struct layout_qual_s {
const char *name;
bool (*valid) (symbol_t *sym, glsl_interface_t interface);
bool (*apply) ();
bool (*apply_expr) ();
} layout_qual_t;
// qual var block member iface
static layout_qual_t layout_qualifiers[] = {
{"shared", /* q _ b _ uniform/buffer */, ___, nullptr},
{"packed", /* q _ b _ uniform/buffer */, ___, nullptr},
{"std140", /* q _ b _ uniform/buffer */, ___, nullptr},
{"std430", /* q _ b _ uniform/buffer */, ___, nullptr},
{"row_major", /* q _ b m uniform/buffer */, ___, nullptr},
{"column_major", /* q _ b m uniform/buffer */, ___, nullptr},
{"binding", /* _ o b _ uniform/buffer */, nullptr, ___},
{"offset", /* _ a _ m uniform/buffer */, nullptr, ___},
{"align", /* _ o b _ uniform/buffer */, nullptr, ___},
{"set", /* _ o b _ uniform/buffer */, nullptr, ___},
{"push_constant", /* _ _ b _ uniform(vulkan) */, ___, nullptr},
{"input_attachment_index", /* _ s _ _ uniform(vulkan) */, nullptr, ___},
{"location", /* _ v _ _ uniform/buffer/subroutine */, nullptr, ___},
{"location", /* _ v b m all in/out except compute */, nullptr, ___},
{"component", /* _ v _ m all in/out except compute */, nullptr, ___},
{"index", /* _ v _ _ fragment out/subroutine */, nullptr, ___},
{"triangles", /* q _ _ _ tese in */, ___, nullptr},
{"quads", /* q _ _ _ tese in */, ___, nullptr},
{"isolines", /* q _ _ _ tese in */, ___, nullptr},
{"equal_spacing", /* q _ _ _ tese in */, ___, nullptr},
{"fractional_even_spacing", /* q _ _ _ tese in */, ___, nullptr},
{"fractional_odd_spacing", /* q _ _ _ tese in */, ___, nullptr},
{"cw", /* q _ _ _ tese in */, ___, nullptr},
{"ccw", /* q _ _ _ tese in */, ___, nullptr},
{"point_mode", /* q _ _ _ tese in */, ___, nullptr},
{"points", /* q _ _ _ geom in/out */, ___, nullptr},
//? [ points ] // q _ _ _ geom in
{"lines", /* q _ _ _ geom in */, ___, nullptr},
{"lines_adjacency", /* q _ _ _ geom in */, ___, nullptr},
{"triangles", /* q _ _ _ geom in */, ___, nullptr},
{"triangles_adjacency", /* q _ _ _ geom in */, ___, nullptr},
{"invocations", /* q _ _ _ geom in */, nullptr, ___},
{"origin_upper_left", /* _ f _ _ frag in */, ___, nullptr},
{"pixel_center_integer", /* _ f _ _ frag in */, ___, nullptr},
{"early_fragment_tests", /* q _ _ _ frag in */, ___, nullptr},
{"local_size_x", /* q _ _ _ comp in */, nullptr, ___},
{"local_size_y", /* q _ _ _ comp in */, nullptr, ___},
{"local_size_z", /* q _ _ _ comp in */, nullptr, ___},
{"local_size_x_id", /* q _ _ _ comp in */, nullptr, ___},
{"local_size_y_id", /* q _ _ _ comp in */, nullptr, ___},
{"local_size_z_id", /* q _ _ _ comp in */, nullptr, ___},
{"xfb_buffer", /* q v b m vert/tess/geom out */, nullptr, ___},
{"xfb_stride", /* q v b m vert/tess/geom out */, nullptr, ___},
{"xfb_offset", /* _ v b m vert/tess/geom out */, nullptr, ___},
{"vertices", /* q _ _ _ tesc out */, nullptr, ___},
//? [ points ] // q _ _ _ geom out
{"line_strip", /* q _ _ _ geom out */, ___, nullptr},
{"triangle_strip", /* q _ _ _ geom out */, ___, nullptr},
{"max_vertices", /* q _ _ _ geom out */, nullptr, ___},
{"stream", /* q v b m geom out */, nullptr, ___},
{"depth_any", /* _ v _ _ frag out */, ___, nullptr},
{"depth_greater", /* _ v _ _ frag out */, ___, nullptr},
{"depth_less", /* _ v _ _ frag out */, ___, nullptr},
{"depth_unchanged", /* _ v _ _ frag out */, ___, nullptr},
{"constant_id", /* _ s _ _ const */, nullptr, ___},
{"rgba32f", /* _ i _ _ uniform */, ___, nullptr},
{"rgba16f", /* _ i _ _ uniform */, ___, nullptr},
{"rg32f", /* _ i _ _ uniform */, ___, nullptr},
{"rg16f", /* _ i _ _ uniform */, ___, nullptr},
{"r11f_g11f_b10f", /* _ i _ _ uniform */, ___, nullptr},
{"r32f", /* _ i _ _ uniform */, ___, nullptr},
{"r16f", /* _ i _ _ uniform */, ___, nullptr},
{"rgba16", /* _ i _ _ uniform */, ___, nullptr},
{"rgb10_a2", /* _ i _ _ uniform */, ___, nullptr},
{"rgba8", /* _ i _ _ uniform */, ___, nullptr},
{"rg16", /* _ i _ _ uniform */, ___, nullptr},
{"rg8", /* _ i _ _ uniform */, ___, nullptr},
{"r16", /* _ i _ _ uniform */, ___, nullptr},
{"r8", /* _ i _ _ uniform */, ___, nullptr},
{"rgba16_snorm", /* _ i _ _ uniform */, ___, nullptr},
{"rgba8_snorm", /* _ i _ _ uniform */, ___, nullptr},
{"rg16_snorm", /* _ i _ _ uniform */, ___, nullptr},
{"rg8_snorm", /* _ i _ _ uniform */, ___, nullptr},
{"r16_snorm", /* _ i _ _ uniform */, ___, nullptr},
{"r8_snorm", /* _ i _ _ uniform */, ___, nullptr},
{"rgba32i", /* _ i _ _ uniform */, ___, nullptr},
{"rgba16i", /* _ i _ _ uniform */, ___, nullptr},
{"rgba8i", /* _ i _ _ uniform */, ___, nullptr},
{"rg32i", /* _ i _ _ uniform */, ___, nullptr},
{"rg16i", /* _ i _ _ uniform */, ___, nullptr},
{"rg8i", /* _ i _ _ uniform */, ___, nullptr},
{"r32i", /* _ i _ _ uniform */, ___, nullptr},
{"r16i", /* _ i _ _ uniform */, ___, nullptr},
{"r8i", /* _ i _ _ uniform */, ___, nullptr},
{"rgba32ui", /* _ i _ _ uniform */, ___, nullptr},
{"rgba16ui", /* _ i _ _ uniform */, ___, nullptr},
{"rgb10_a2ui", /* _ i _ _ uniform */, ___, nullptr},
{"rgba8ui", /* _ i _ _ uniform */, ___, nullptr},
{"rg32ui", /* _ i _ _ uniform */, ___, nullptr},
{"rg16ui", /* _ i _ _ uniform */, ___, nullptr},
{"rg8ui", /* _ i _ _ uniform */, ___, nullptr},
{"r32ui", /* _ i _ _ uniform */, ___, nullptr},
{"r16ui", /* _ i _ _ uniform */, ___, nullptr},
{"r8ui", /* _ i _ _ uniform */, ___, nullptr},
};
#endif
const char *glsl_interface_names[glsl_num_interfaces] = {
"in",
"out",
"uniform",
"buffer",
"shared",
};
symtab_t *
glsl_optimize_attributes (attribute_t *attributes)
{
auto attrtab = new_symtab (nullptr, stab_param);
for (auto attr = attributes; attr; attr = attr->next) {
auto attrsym = symtab_lookup (attrtab, attr->name);
if (attrsym) {
if (strcmp (attr->name, "layout") == 0) {
list_append_list (&attrsym->list, &attr->params->list);
} else {
error (attr->params, "duplicate %s", attr->name);
}
} else {
attrsym = new_symbol (attr->name);
if (strcmp (attr->name, "layout") == 0) {
attrsym->sy_type = sy_list;
list_append_list (&attrsym->list, &attr->params->list);
} else {
if (attr->params) {
notice (attr->params, "attribute params: %s", attr->name);
attrsym->sy_type = sy_expr;
attrsym->expr = attr->params;
}
}
symtab_addsymbol (attrtab, attrsym);
}
notice (0, "%s", attr->name);
if (!attr->params) continue;
for (auto p = attr->params->list.head; p; p = p->next) {
if (p->expr->type == ex_expr) {
notice (0, " %s = %s",
get_value_string (p->expr->expr.e1->value),
get_value_string (p->expr->expr.e2->value));
} else {
notice (0, " %s", get_value_string (p->expr->value));
}
}
}
return attrtab;
}

View file

@ -88,6 +88,7 @@ glsl_declare_block (specifier_t spec, symbol_t *block_sym,
ALLOC (64, glsl_block_t, blocks, block); ALLOC (64, glsl_block_t, blocks, block);
*block = (glsl_block_t) { *block = (glsl_block_t) {
.name = save_string (block_sym->name), .name = save_string (block_sym->name),
.attributes = spec.attributes,
.members = block_sym->namespace, .members = block_sym->namespace,
.instance_name = instance_name, .instance_name = instance_name,
}; };
@ -127,3 +128,12 @@ glsl_declare_block (specifier_t spec, symbol_t *block_sym,
} }
} }
} }
glsl_block_t *
glsl_get_block (const char *name, glsl_interface_t interface)
{
if (interface >= glsl_num_interfaces) {
internal_error (0, "invalid interface");
}
return Hash_Find (interfaces[interface], name);
}

View file

@ -820,13 +820,15 @@ int imageAtomicExchange(IMAGE_PARAMS, int data)
float imageAtomicExchange(IMAGE_PARAMS, float data) float imageAtomicExchange(IMAGE_PARAMS, float data)
uint imageAtomicCompSwap(IMAGE_PARAMS, uint compare, uint data) uint imageAtomicCompSwap(IMAGE_PARAMS, uint compare, uint data)
int imageAtomicCompSwap(IMAGE_PARAMS, int compare, int data) int imageAtomicCompSwap(IMAGE_PARAMS, int compare, int data)
#endif
//geometry shader functions //geometry shader functions
void EmitStreamVertex(int stream) static const char *glsl_geometry_functions =
void EndStreamPrimitive(int stream) SRC_LINE
void EmitVertex() "void EmitStreamVertex(int stream);" "\n"
void EndPrimitive() "void EndStreamPrimitive(int stream);" "\n"
"void EmitVertex();" "\n"
"void EndPrimitive();" "\n";
#if 0
//fragment processing functions //fragment processing functions
//derivative //derivative
genFType dFdx(genFType p) genFType dFdx(genFType p)
@ -952,6 +954,7 @@ glsl_init_geom (void)
{ {
glsl_init_common (); glsl_init_common ();
glsl_parse_vars (glsl_geometry_vars); glsl_parse_vars (glsl_geometry_vars);
qc_parse_string (glsl_geometry_functions);
} }
void void

View file

@ -0,0 +1,78 @@
/*
glsl-declaration.c
GLSL declaration handling
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
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "QF/alloc.h"
#include "QF/hash.h"
#include "QF/va.h"
#include "tools/qfcc/include/attribute.h"
#include "tools/qfcc/include/def.h"
#include "tools/qfcc/include/diagnostic.h"
#include "tools/qfcc/include/glsl-lang.h"
#include "tools/qfcc/include/shared.h"
#include "tools/qfcc/include/strpool.h"
#include "tools/qfcc/include/symtab.h"
#include "tools/qfcc/include/type.h"
void
glsl_parse_declaration (specifier_t spec, symbol_t *sym, const type_t *array,
const expr_t *init, symtab_t *symtab)
{
if (array) {
spec.type = append_type (array, spec.type);
spec.type = find_type (spec.type);
}
/*auto attributes =*/ glsl_optimize_attributes (spec.attributes);
if (sym && sym->sy_type == sy_expr) {
auto id_list = sym->expr;
if (id_list->type != ex_list) {
internal_error (id_list, "not a list");
}
for (auto id = id_list->list.head; id; id = id->next) {
if (id->expr->type != ex_symbol) {
internal_error (id_list, "not a symbol");
}
spec.sym = id->expr->symbol;
declare_symbol (spec, init, symtab);
}
} else {
spec.sym = sym;
if (spec.sym) {
declare_symbol (spec, init, symtab);
}
}
}
void
glsl_declare_field (specifier_t spec, symtab_t *symtab)
{
/*auto attributes =*/ glsl_optimize_attributes (spec.attributes);
declare_field (spec, symtab);
}

View file

@ -93,6 +93,7 @@ yyerror (YYLTYPE *yylloc, void *scanner, const char *s)
#else #else
error (0, "%s before %s", s, glsl_yytext); error (0, "%s before %s", s, glsl_yytext);
#endif #endif
exit(1);
} }
static void __attribute__((used)) static void __attribute__((used))
@ -157,18 +158,22 @@ int yylex (YYSTYPE *yylval, YYLTYPE *yylloc);
%token <op> STRUCT %token <op> STRUCT
%token <spec> TYPE_SPEC TYPE_NAME TYPE_QUAL VOID %token <spec> TYPE_SPEC TYPE_NAME TYPE_QUAL VOID
%token <spec> PRECISION INVARIANT SMOOTH FLAT NOPERSPECTIVE LAYOUT SHARED %token PRECISION
%token <spec> PRECISE CONST IN OUT INOUT CENTROID PATCH SAMPLE UNIFORM BUFFER VOLATILE %token <string> INVARIANT SMOOTH FLAT NOPERSPECTIVE PRECISE
%token <spec> RESTRICT READONLY WRITEONLY HIGH_PRECISION MEDIUM_PRECISION %token <string> HIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION
%token <spec> LOW_PRECISION DISCARD COHERENT %token <spec> LAYOUT SHARED
%token <spec> CONST IN OUT INOUT CENTROID PATCH SAMPLE UNIFORM BUFFER VOLATILE
%token <spec> RESTRICT READONLY WRITEONLY
%token <spec> DISCARD COHERENT
%type <symbol> variable_identifier %type <symbol> variable_identifier
%type <symbol> block_declaration %type <symbol> block_declaration
%type <expr> constant_expression
%type <expr> expression primary_exprsssion assignment_expression %type <expr> expression primary_exprsssion assignment_expression
%type <expr> for_init_statement conditionopt expressionopt else %type <expr> for_init_statement conditionopt expressionopt else
%type <expr> conditional_expression unary_expression postfix_expression %type <expr> conditional_expression unary_expression postfix_expression
%type <expr> function_call function_call_or_method function_call_generic %type <expr> function_call function_call_or_method function_call_generic
%type <mut_expr> function_call_header_with_parameters %type <mut_expr> function_call_header_with_parameters identifier_list
%type <expr> function_call_header_no_parameters %type <expr> function_call_header_no_parameters
%type <expr> function_call_header function_identifier %type <expr> function_call_header function_identifier
%type <expr> logical_or_expression logical_xor_expression %type <expr> logical_or_expression logical_xor_expression
@ -190,12 +195,17 @@ int yylex (YYSTYPE *yylval, YYLTYPE *yylloc);
%type <mut_expr> initializer_list %type <mut_expr> initializer_list
%type <op> unary_operator assignment_operator %type <op> unary_operator assignment_operator
%type <spec> single_declaration init_declarator_list
%type <spec> function_prototype function_declarator %type <spec> function_prototype function_declarator
%type <spec> function_header function_header_with_parameters %type <spec> function_header function_header_with_parameters
%type <spec> fully_specified_type type_specifier struct_specifier %type <spec> fully_specified_type type_specifier struct_specifier
%type <spec> type_qualifier single_type_qualifier type_specifier_nonarray %type <spec> type_qualifier single_type_qualifier type_specifier_nonarray
%type <spec> precision_qualifier interpolation_qualifier invariant_qualifier %type <string> precision_qualifier interpolation_qualifier invariant_qualifier
%type <spec> precise_qualifer storage_qualifier layout_qualifier %type <string> precise_qualifier
%type <spec> storage_qualifier layout_qualifier
%type <expr> layout_qualifier_id
%type <mut_expr> layout_qualifier_id_list
%type <size> array_size %type <size> array_size
%type <type> array_specifier %type <type> array_specifier
@ -235,6 +245,12 @@ spec_merge (specifier_t spec, specifier_t new)
if (!spec.storage) { if (!spec.storage) {
spec.storage = new.storage; spec.storage = new.storage;
} }
for (auto attr = &spec.attributes; *attr; attr = &(*attr)->next) {
if (!(*attr)->next) {
(*attr)->next = new.attributes;
break;
}
}
spec.sym = new.sym; spec.sym = new.sym;
spec.spec_bits |= new.spec_bits; spec.spec_bits |= new.spec_bits;
return spec; return spec;
@ -555,6 +571,9 @@ declaration
: function_prototype ';' : function_prototype ';'
| init_declarator_list ';' | init_declarator_list ';'
| PRECISION precision_qualifier type_specifier ';' | PRECISION precision_qualifier type_specifier ';'
{
notice (0, "PRECISION precision_qualifier");
}
| type_qualifier block_declaration ';' | type_qualifier block_declaration ';'
{ {
auto spec = $1; auto spec = $1;
@ -577,8 +596,26 @@ declaration
glsl_declare_block (spec, block, instance_name); glsl_declare_block (spec, block, instance_name);
} }
| type_qualifier ';' | type_qualifier ';'
{
glsl_parse_declaration ($type_qualifier, nullptr,
nullptr, nullptr, current_symtab);
}
| type_qualifier IDENTIFIER ';' | type_qualifier IDENTIFIER ';'
{
glsl_parse_declaration ($type_qualifier, $IDENTIFIER,
nullptr, nullptr, current_symtab);
}
| type_qualifier IDENTIFIER identifier_list ';' | type_qualifier IDENTIFIER identifier_list ';'
{
auto id_list = $identifier_list;
auto expr = new_symbol_expr ($IDENTIFIER);
expr_prepend_expr (id_list, expr);
auto sym = new_symbol (nullptr);
sym->sy_type = sy_expr;
sym->expr = id_list;
glsl_parse_declaration ($type_qualifier, sym,
nullptr, nullptr, current_symtab);
}
; ;
block_declaration block_declaration
@ -599,7 +636,15 @@ block_declaration
identifier_list identifier_list
: ',' IDENTIFIER : ',' IDENTIFIER
{
auto expr = new_symbol_expr ($2);
$$ = new_list_expr (expr);
}
| identifier_list ',' IDENTIFIER | identifier_list ',' IDENTIFIER
{
auto expr = new_symbol_expr ($3);
$$ = expr_append_expr ($1, expr);
}
; ;
function_prototype function_prototype
@ -673,6 +718,7 @@ init_declarator_list
: single_declaration : single_declaration
| init_declarator_list ',' IDENTIFIER | init_declarator_list ',' IDENTIFIER
{ {
$$ = $1;
auto symtab = current_symtab; auto symtab = current_symtab;
auto space = symtab->space; auto space = symtab->space;
auto storage = current_storage; auto storage = current_storage;
@ -682,6 +728,7 @@ init_declarator_list
| init_declarator_list ',' IDENTIFIER array_specifier '=' initializer | init_declarator_list ',' IDENTIFIER array_specifier '=' initializer
| init_declarator_list ',' IDENTIFIER '=' initializer | init_declarator_list ',' IDENTIFIER '=' initializer
{ {
$$ = $1;
auto symtab = current_symtab; auto symtab = current_symtab;
auto space = symtab->space; auto space = symtab->space;
auto storage = current_storage; auto storage = current_storage;
@ -694,29 +741,37 @@ init_declarator_list
single_declaration single_declaration
: fully_specified_type : fully_specified_type
{
glsl_parse_declaration ($$ = $fully_specified_type,
nullptr, nullptr,
nullptr, current_symtab);
}
| fully_specified_type IDENTIFIER | fully_specified_type IDENTIFIER
{ {
auto spec = $1; glsl_parse_declaration ($$ = $fully_specified_type,
spec.sym = $2; $IDENTIFIER, nullptr,
declare_symbol (spec, nullptr, current_symtab); nullptr, current_symtab);
} }
| fully_specified_type IDENTIFIER array_specifier | fully_specified_type IDENTIFIER array_specifier
{ {
auto spec = $1; glsl_parse_declaration ($$ = $fully_specified_type,
spec.type = append_type ($3, spec.type); $IDENTIFIER, $array_specifier,
spec.type = find_type (spec.type); nullptr, current_symtab);
spec.sym = $2;
declare_symbol (spec, nullptr, current_symtab);
} }
| fully_specified_type IDENTIFIER array_specifier '=' initializer | fully_specified_type IDENTIFIER array_specifier '=' initializer
{
glsl_parse_declaration ($$ = $fully_specified_type,
$IDENTIFIER, $array_specifier,
$initializer, current_symtab);
}
| fully_specified_type IDENTIFIER '=' initializer | fully_specified_type IDENTIFIER '=' initializer
{ {
auto spec = $1;
spec.sym = $2;
if (current_storage == sc_local && !local_expr) { if (current_storage == sc_local && !local_expr) {
local_expr = new_block_expr (nullptr); local_expr = new_block_expr (nullptr);
} }
declare_symbol (spec, $4, current_symtab); glsl_parse_declaration ($$ = $fully_specified_type,
$IDENTIFIER, nullptr,
$initializer, current_symtab);
} }
; ;
@ -736,21 +791,38 @@ interpolation_qualifier
; ;
layout_qualifier layout_qualifier
: LAYOUT '(' layout_qualifer_id_list ')' : LAYOUT '(' layout_qualifier_id_list ')'
{
auto attr = new_attribute ("layout", $3);
$$ = (specifier_t) { .attributes = attr };
}
; ;
layout_qualifer_id_list layout_qualifier_id_list
: layout_qualifer_id : layout_qualifier_id
| layout_qualifer_id_list ',' layout_qualifer_id {
$$ = new_list_expr ($1);
}
| layout_qualifier_id_list ',' layout_qualifier_id
{
$$ = expr_append_expr ($1, $3);
}
; ;
layout_qualifer_id layout_qualifier_id
: IDENTIFIER : IDENTIFIER { $$ = new_string_expr ($1->name); }
| IDENTIFIER '=' constant_expression | IDENTIFIER '=' constant_expression
{
auto id = new_string_expr ($1->name);
$$ = new_binary_expr ('=', id, $3);
}
| SHARED | SHARED
{
$$ = new_string_expr ("shared");
}
; ;
precise_qualifer precise_qualifier
: PRECISE : PRECISE
; ;
@ -766,9 +838,25 @@ single_type_qualifier
: storage_qualifier : storage_qualifier
| layout_qualifier | layout_qualifier
| precision_qualifier | precision_qualifier
{
auto attr = new_attribute ($1, nullptr);
$$ = (specifier_t) { .attributes = attr };
}
| interpolation_qualifier | interpolation_qualifier
{
auto attr = new_attribute ($1, nullptr);
$$ = (specifier_t) { .attributes = attr };
}
| invariant_qualifier | invariant_qualifier
| precise_qualifer {
auto attr = new_attribute ($1, nullptr);
$$ = (specifier_t) { .attributes = attr };
}
| precise_qualifier
{
auto attr = new_attribute ($1, nullptr);
$$ = (specifier_t) { .attributes = attr };
}
; ;
storage_qualifier storage_qualifier
@ -824,10 +912,10 @@ array_size
; ;
type_specifier_nonarray type_specifier_nonarray
: VOID : VOID { $$ = $1; $$.storage = current_storage; }
| TYPE_SPEC | TYPE_SPEC { $$ = $1; $$.storage = current_storage; }
| struct_specifier | struct_specifier { $$ = $1; $$.storage = current_storage; }
| TYPE_NAME | TYPE_NAME { $$ = $1; $$.storage = current_storage; }
; ;
precision_qualifier precision_qualifier
@ -839,6 +927,9 @@ precision_qualifier
struct_specifier struct_specifier
: STRUCT IDENTIFIER '{' : STRUCT IDENTIFIER '{'
{ {
if (current_symtab->type == stab_struct) {
error (0, "nested struct declaration");
}
int op = 's'; int op = 's';
current_symtab = start_struct (&op, $2, current_symtab); current_symtab = start_struct (&op, $2, current_symtab);
} }
@ -855,9 +946,13 @@ struct_specifier
s->sy_type = sy_type; s->sy_type = sy_type;
s->type = find_type (alias_type (sym->type, sym->type, s->name)); s->type = find_type (alias_type (sym->type, sym->type, s->name));
symtab_addsymbol (current_symtab, s); symtab_addsymbol (current_symtab, s);
$$ = (specifier_t) { .type = s->type };
} }
| STRUCT '{' | STRUCT '{'
{ {
if (current_symtab->type == stab_struct) {
error (0, "nested struct declaration");
}
int op = 's'; int op = 's';
current_symtab = start_struct (&op, nullptr, current_symtab); current_symtab = start_struct (&op, nullptr, current_symtab);
} }
@ -870,6 +965,7 @@ struct_specifier
if (!sym->table) { if (!sym->table) {
symtab_addsymbol (current_symtab, sym); symtab_addsymbol (current_symtab, sym);
} }
$$ = (specifier_t) { .type = sym->type };
} }
; ;
@ -895,7 +991,7 @@ struct_declarator
{ {
auto spec = $<spec>0; auto spec = $<spec>0;
spec.sym = $1; spec.sym = $1;
declare_field (spec, current_symtab); glsl_declare_field (spec, current_symtab);
} }
| IDENTIFIER array_specifier | IDENTIFIER array_specifier
{ {
@ -903,7 +999,7 @@ struct_declarator
spec.type = append_type ($2, spec.type); spec.type = append_type ($2, spec.type);
spec.type = find_type (spec.type); spec.type = find_type (spec.type);
spec.sym = $1; spec.sym = $1;
declare_field (spec, current_symtab); glsl_declare_field (spec, current_symtab);
} }
; ;
@ -1168,13 +1264,13 @@ static keyword_t glsl_keywords[] = {
{"atomic_uint", GLSL_RESERVED}, {"atomic_uint", GLSL_RESERVED},
{"layout", GLSL_LAYOUT}, {"layout", GLSL_LAYOUT},
{"centroid", GLSL_CENTROID}, {"centroid", GLSL_CENTROID},
{"flat", GLSL_FLAT}, {"flat", GLSL_FLAT, .use_name = true},
{"smooth", GLSL_SMOOTH}, {"smooth", GLSL_SMOOTH, .use_name = true},
{"noperspective", GLSL_NOPERSPECTIVE}, {"noperspective", GLSL_NOPERSPECTIVE, .use_name = true},
{"patch", GLSL_PATCH}, {"patch", GLSL_PATCH},
{"sample", GLSL_SAMPLE}, {"sample", GLSL_SAMPLE},
{"invariant", GLSL_INVARIANT}, {"invariant", GLSL_INVARIANT, .use_name = true},
{"precise", GLSL_PRECISE}, {"precise", GLSL_PRECISE, .use_name = true},
{"break", GLSL_BREAK}, {"break", GLSL_BREAK},
{"continue", GLSL_CONTINUE}, {"continue", GLSL_CONTINUE},
{"do", GLSL_DO}, {"do", GLSL_DO},
@ -1236,9 +1332,9 @@ static keyword_t glsl_keywords[] = {
{"dmat4x3", GLSL_TYPE_SPEC, .spec = {.type = &type_dmat4x3}}, {"dmat4x3", GLSL_TYPE_SPEC, .spec = {.type = &type_dmat4x3}},
{"dmat4x4", GLSL_TYPE_SPEC, .spec = {.type = &type_dmat4x4}}, {"dmat4x4", GLSL_TYPE_SPEC, .spec = {.type = &type_dmat4x4}},
{"lowp", GLSL_LOW_PRECISION}, {"lowp", GLSL_LOW_PRECISION, .use_name = true},
{"mediump", GLSL_MEDIUM_PRECISION}, {"mediump", GLSL_MEDIUM_PRECISION, .use_name = true},
{"highp", GLSL_HIGH_PRECISION}, {"highp", GLSL_HIGH_PRECISION, .use_name = true},
{"precision", GLSL_PRECISION}, {"precision", GLSL_PRECISION},
{"sampler1D", GLSL_TYPE_SPEC}, // spec init at runtime {"sampler1D", GLSL_TYPE_SPEC}, // spec init at runtime
{"sampler1DShadow", GLSL_TYPE_SPEC}, {"sampler1DShadow", GLSL_TYPE_SPEC},
@ -1441,6 +1537,8 @@ glsl_process_keyword (rua_val_t *lval, keyword_t *keyword, const char *token)
sym = find_handle (sym, &type_int); sym = find_handle (sym, &type_int);
keyword->spec.type = sym->type; keyword->spec.type = sym->type;
lval->spec = keyword->spec; lval->spec = keyword->spec;
} else if (keyword->use_name) {
lval->string = keyword->name;
} else { } else {
lval->spec = keyword->spec; lval->spec = keyword->spec;
} }
@ -1610,6 +1708,7 @@ language_t lang_glsl_comp = {
.extension = glsl_extension, .extension = glsl_extension,
.version = glsl_version, .version = glsl_version,
.on_include = glsl_on_include, .on_include = glsl_on_include,
.sublanguage = &glsl_comp_sublanguage,
}; };
language_t lang_glsl_vert = { language_t lang_glsl_vert = {
@ -1618,6 +1717,7 @@ language_t lang_glsl_vert = {
.extension = glsl_extension, .extension = glsl_extension,
.version = glsl_version, .version = glsl_version,
.on_include = glsl_on_include, .on_include = glsl_on_include,
.sublanguage = &glsl_vert_sublanguage,
}; };
language_t lang_glsl_tesc = { language_t lang_glsl_tesc = {
@ -1626,6 +1726,7 @@ language_t lang_glsl_tesc = {
.extension = glsl_extension, .extension = glsl_extension,
.version = glsl_version, .version = glsl_version,
.on_include = glsl_on_include, .on_include = glsl_on_include,
.sublanguage = &glsl_tesc_sublanguage,
}; };
language_t lang_glsl_tese = { language_t lang_glsl_tese = {
@ -1634,6 +1735,7 @@ language_t lang_glsl_tese = {
.extension = glsl_extension, .extension = glsl_extension,
.version = glsl_version, .version = glsl_version,
.on_include = glsl_on_include, .on_include = glsl_on_include,
.sublanguage = &glsl_tese_sublanguage,
}; };
language_t lang_glsl_geom = { language_t lang_glsl_geom = {
@ -1642,6 +1744,7 @@ language_t lang_glsl_geom = {
.extension = glsl_extension, .extension = glsl_extension,
.version = glsl_version, .version = glsl_version,
.on_include = glsl_on_include, .on_include = glsl_on_include,
.sublanguage = &glsl_geom_sublanguage,
}; };
language_t lang_glsl_frag = { language_t lang_glsl_frag = {
@ -1650,4 +1753,5 @@ language_t lang_glsl_frag = {
.extension = glsl_extension, .extension = glsl_extension,
.version = glsl_version, .version = glsl_version,
.on_include = glsl_on_include, .on_include = glsl_on_include,
.sublanguage = &glsl_frag_sublanguage,
}; };

View file

@ -0,0 +1,53 @@
/*
glsl-sub_comp.c
GLSL compute shader sublanguage
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
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "QF/alloc.h"
#include "QF/hash.h"
#include "QF/va.h"
#include "tools/qfcc/include/def.h"
#include "tools/qfcc/include/diagnostic.h"
#include "tools/qfcc/include/glsl-lang.h"
#include "tools/qfcc/include/shared.h"
#include "tools/qfcc/include/strpool.h"
#include "tools/qfcc/include/symtab.h"
#include "tools/qfcc/include/type.h"
static const char *glsl_comp_interface_default_names[glsl_num_interfaces] = {
[glsl_in] = ".control",
[glsl_uniform] = ".default",
[glsl_buffer] = ".default",
[glsl_shared] = ".default",
};
glsl_sublang_t glsl_comp_sublanguage = {
.name = "compute",
.interface_default_names = glsl_comp_interface_default_names,
};

View file

@ -0,0 +1,51 @@
/*
glsl-sub_frag.c
GLSL fragment shader sublanguage
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
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "QF/alloc.h"
#include "QF/hash.h"
#include "QF/va.h"
#include "tools/qfcc/include/def.h"
#include "tools/qfcc/include/diagnostic.h"
#include "tools/qfcc/include/glsl-lang.h"
#include "tools/qfcc/include/shared.h"
#include "tools/qfcc/include/strpool.h"
#include "tools/qfcc/include/symtab.h"
#include "tools/qfcc/include/type.h"
static const char *glsl_frag_interface_default_names[glsl_num_interfaces] = {
[glsl_uniform] = ".default",
[glsl_buffer] = ".default",
};
glsl_sublang_t glsl_frag_sublanguage = {
.name = "fragment",
.interface_default_names = glsl_frag_interface_default_names,
};

View file

@ -0,0 +1,55 @@
/*
glsl-sub_geom.c
GLSL geometry shader sublanguage
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
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "QF/alloc.h"
#include "QF/hash.h"
#include "QF/va.h"
#include "tools/qfcc/include/attribute.h"
#include "tools/qfcc/include/def.h"
#include "tools/qfcc/include/diagnostic.h"
#include "tools/qfcc/include/glsl-lang.h"
#include "tools/qfcc/include/shared.h"
#include "tools/qfcc/include/strpool.h"
#include "tools/qfcc/include/symtab.h"
#include "tools/qfcc/include/type.h"
#include "tools/qfcc/include/value.h"
static const char *glsl_geom_interface_default_names[glsl_num_interfaces] = {
[glsl_in] = "gl_PerVertex",
[glsl_out] = "gl_PerVertex",
[glsl_uniform] = ".default",
[glsl_buffer] = ".default",
};
glsl_sublang_t glsl_geom_sublanguage = {
.name = "geometry",
.interface_default_names = glsl_geom_interface_default_names,
};

View file

@ -0,0 +1,53 @@
/*
glsl-sub_tesc.c
GLSL tessellation control shader sublanguage
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
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "QF/alloc.h"
#include "QF/hash.h"
#include "QF/va.h"
#include "tools/qfcc/include/def.h"
#include "tools/qfcc/include/diagnostic.h"
#include "tools/qfcc/include/glsl-lang.h"
#include "tools/qfcc/include/shared.h"
#include "tools/qfcc/include/strpool.h"
#include "tools/qfcc/include/symtab.h"
#include "tools/qfcc/include/type.h"
static const char *glsl_tesc_interface_default_names[glsl_num_interfaces] = {
[glsl_in] = "gl_PerVertex",
[glsl_out] = "gl_PerVertex",
[glsl_uniform] = ".default",
[glsl_buffer] = ".default",
};
glsl_sublang_t glsl_tesc_sublanguage = {
.name = "tessellation control",
.interface_default_names = glsl_tesc_interface_default_names,
};

View file

@ -0,0 +1,53 @@
/*
glsl-sub_tese.c
GLSL tessellation evaluation shader sublanguage
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
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "QF/alloc.h"
#include "QF/hash.h"
#include "QF/va.h"
#include "tools/qfcc/include/def.h"
#include "tools/qfcc/include/diagnostic.h"
#include "tools/qfcc/include/glsl-lang.h"
#include "tools/qfcc/include/shared.h"
#include "tools/qfcc/include/strpool.h"
#include "tools/qfcc/include/symtab.h"
#include "tools/qfcc/include/type.h"
static const char *glsl_tese_interface_default_names[glsl_num_interfaces] = {
[glsl_in] = "gl_PerVertex",
[glsl_out] = "gl_PerVertex",
[glsl_uniform] = ".default",
[glsl_buffer] = ".default",
};
glsl_sublang_t glsl_tese_sublanguage = {
.name = "tessellation evaluation",
.interface_default_names = glsl_tese_interface_default_names,
};

View file

@ -0,0 +1,53 @@
/*
glsl-sub_vert.c
GLSL vertex shader sublanguage
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
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "QF/alloc.h"
#include "QF/hash.h"
#include "QF/va.h"
#include "tools/qfcc/include/def.h"
#include "tools/qfcc/include/diagnostic.h"
#include "tools/qfcc/include/glsl-lang.h"
#include "tools/qfcc/include/shared.h"
#include "tools/qfcc/include/strpool.h"
#include "tools/qfcc/include/symtab.h"
#include "tools/qfcc/include/type.h"
static const char *glsl_vert_interface_default_names[glsl_num_interfaces] = {
[glsl_in] = "gl_PerVertex",
[glsl_out] = "gl_PerVertex",
[glsl_uniform] = ".default",
[glsl_buffer] = ".default",
};
glsl_sublang_t glsl_vert_sublanguage = {
.name = "vertex",
.interface_default_names = glsl_vert_interface_default_names,
};