mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 13:11:00 +00:00
[qfcc] Create defs for instanced interface blocks
And allow unsized arrays (for in, uniform and buffer) to have deferred sizes.
This commit is contained in:
parent
f0eccc398e
commit
0385345d63
2 changed files with 30 additions and 4 deletions
|
@ -106,6 +106,15 @@ set_storage_bits (def_t *def, storage_class_t storage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
deferred_size (storage_class_t storage)
|
||||||
|
{
|
||||||
|
if (storage == sc_in || storage == sc_uniform || storage == sc_buffer) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
def_t *
|
def_t *
|
||||||
new_def (const char *name, const type_t *type, defspace_t *space,
|
new_def (const char *name, const type_t *type, defspace_t *space,
|
||||||
storage_class_t storage)
|
storage_class_t storage)
|
||||||
|
@ -151,7 +160,7 @@ new_def (const char *name, const type_t *type, defspace_t *space,
|
||||||
int size = type_size (type);
|
int size = type_size (type);
|
||||||
int alignment = type->alignment;
|
int alignment = type->alignment;
|
||||||
|
|
||||||
if (!size) {
|
if (!size && is_array (type) && !deferred_size (storage)) {
|
||||||
error (0, "%s has incomplete type", name);
|
error (0, "%s has incomplete type", name);
|
||||||
size = 1;
|
size = 1;
|
||||||
alignment = 1;
|
alignment = 1;
|
||||||
|
@ -160,7 +169,9 @@ new_def (const char *name, const type_t *type, defspace_t *space,
|
||||||
print_type (type);
|
print_type (type);
|
||||||
internal_error (0, "type has no alignment");
|
internal_error (0, "type has no alignment");
|
||||||
}
|
}
|
||||||
def->offset = defspace_alloc_aligned_loc (space, size, alignment);
|
if (size) {
|
||||||
|
def->offset = defspace_alloc_aligned_loc (space, size, alignment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return def;
|
return def;
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "tools/qfcc/include/shared.h"
|
#include "tools/qfcc/include/shared.h"
|
||||||
#include "tools/qfcc/include/strpool.h"
|
#include "tools/qfcc/include/strpool.h"
|
||||||
#include "tools/qfcc/include/symtab.h"
|
#include "tools/qfcc/include/symtab.h"
|
||||||
|
#include "tools/qfcc/include/type.h"
|
||||||
|
|
||||||
ALLOC_STATE (glsl_block_t, blocks);
|
ALLOC_STATE (glsl_block_t, blocks);
|
||||||
|
|
||||||
|
@ -109,7 +110,7 @@ glsl_declare_block (specifier_t spec, symbol_t *block_sym,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!block_tab) {
|
if (!block_tab) {
|
||||||
error (0, "invalid storage for block");
|
error (0, "invalid storage for block: %d", spec.storage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
glsl_block_t *block;
|
glsl_block_t *block;
|
||||||
|
@ -127,7 +128,21 @@ glsl_declare_block (specifier_t spec, symbol_t *block_sym,
|
||||||
sym->def = def;
|
sym->def = def;
|
||||||
}
|
}
|
||||||
if (instance_name) {
|
if (instance_name) {
|
||||||
//namespace_add (instance_name, block->members);
|
auto type = new_type ();
|
||||||
|
*type = (type_t) {
|
||||||
|
.type = ev_invalid,
|
||||||
|
.name = save_string (block_sym->name),
|
||||||
|
.alignment = 4,
|
||||||
|
.width = 1,
|
||||||
|
.columns = 1,
|
||||||
|
.meta = ty_struct,
|
||||||
|
.symtab = block->members,
|
||||||
|
};
|
||||||
|
instance_name->type = append_type (instance_name->type, type);
|
||||||
|
instance_name->type = find_type (instance_name->type);
|
||||||
|
auto space = current_symtab->space;// FIXME
|
||||||
|
initialize_def (instance_name, nullptr, space, spec.storage,
|
||||||
|
current_symtab);
|
||||||
} else {
|
} else {
|
||||||
for (auto sym = block->members->symbols; sym; sym = sym->next) {
|
for (auto sym = block->members->symbols; sym; sym = sym->next) {
|
||||||
auto new = new_symbol (sym->name);
|
auto new = new_symbol (sym->name);
|
||||||
|
|
Loading…
Reference in a new issue