mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[vulkan] Add support for parsing binary data
This commit is contained in:
parent
5864b553ef
commit
f1848bb5b7
2 changed files with 56 additions and 7 deletions
|
@ -80,14 +80,17 @@
|
|||
field_type = [[Type lookup: type_type] dereference];
|
||||
fprintf (output_file, "static parse_%s_t parse_%s_%s_data = {\n",
|
||||
type_record, name, field_name);
|
||||
fprintf (output_file, "\t%s,\n", [field_type parseType]);
|
||||
fprintf (output_file, "\tsizeof (%s),\n", type_type);
|
||||
fprintf (output_file, "\tparse_%s,\n", type_type);
|
||||
if (type_record == "single") {
|
||||
fprintf (output_file, "\t%s,\n", [field_type parseType]);
|
||||
fprintf (output_file, "\tsizeof (%s),\n", type_type);
|
||||
fprintf (output_file, "\tparse_%s,\n", type_type);
|
||||
value_field = [[field_def getObjectForKey:"value"] string];
|
||||
fprintf (output_file, "\tfield_offset (%s, %s),\n",
|
||||
name, value_field);
|
||||
} else {
|
||||
} else if (type_record == "array") {
|
||||
fprintf (output_file, "\t%s,\n", [field_type parseType]);
|
||||
fprintf (output_file, "\tsizeof (%s),\n", type_type);
|
||||
fprintf (output_file, "\tparse_%s,\n", type_type);
|
||||
value_field = [[field_def getObjectForKey:"values"] string];
|
||||
size_field = [[field_def getObjectForKey:"size"] string];
|
||||
fprintf (output_file, "\tfield_offset (%s, %s),\n",
|
||||
|
@ -98,6 +101,19 @@
|
|||
} else {
|
||||
fprintf (output_file, "\t-1,\n");
|
||||
}
|
||||
} else if (type_record == "data") {
|
||||
value_field = [[field_def getObjectForKey:"data"] string];
|
||||
size_field = [[field_def getObjectForKey:"size"] string];
|
||||
fprintf (output_file, "\tfield_offset (%s, %s),\n",
|
||||
name, value_field);
|
||||
if (size_field) {
|
||||
fprintf (output_file, "\tfield_offset (%s, %s),\n",
|
||||
name, size_field);
|
||||
} else {
|
||||
fprintf (output_file, "\t-1,\n");
|
||||
}
|
||||
} else {
|
||||
fprintf (output_file, "\tno type,\n");
|
||||
}
|
||||
fprintf (output_file, "};\n");
|
||||
}
|
||||
|
@ -128,7 +144,7 @@
|
|||
PLItem *type_desc = [field_def getObjectForKey:"type"];
|
||||
string type_record;
|
||||
string type_type;
|
||||
string parseType;
|
||||
string parseType = "no type";
|
||||
|
||||
type_record = [[type_desc getObjectAtIndex:0] string];
|
||||
type_type = [[type_desc getObjectAtIndex:1] string];
|
||||
|
@ -136,8 +152,10 @@
|
|||
field_type = [[Type lookup: type_type] dereference];
|
||||
if (type_record == "single") {
|
||||
parseType = [field_type parseType];
|
||||
} else {
|
||||
} else if (type_record == "array") {
|
||||
parseType = "QFArray";
|
||||
} else if (type_record == "data") {
|
||||
parseType = "QFBinary";
|
||||
}
|
||||
fprintf (output_file,
|
||||
"\t{\"%s\", 0, %s, parse_%s, &parse_%s_%s_data},\n",
|
||||
|
@ -208,8 +226,10 @@
|
|||
type_record = [[type_desc getObjectAtIndex:0] string];
|
||||
if (type_record == "single") {
|
||||
value_field = [[field_def getObjectForKey:"value"] string];
|
||||
} else {
|
||||
} else if (type_record == "array") {
|
||||
value_field = [[field_def getObjectForKey:"values"] string];
|
||||
} else if (type_record == "data") {
|
||||
value_field = [[field_def getObjectForKey:"data"] string];
|
||||
}
|
||||
if (!value_field) {
|
||||
value_field = field_name;
|
||||
|
|
|
@ -117,6 +117,11 @@ typedef struct parse_array_s {
|
|||
size_t size_offset;
|
||||
} parse_array_t;
|
||||
|
||||
typedef struct parse_data_s {
|
||||
size_t value_offset;
|
||||
size_t size_offset;
|
||||
} parse_data_t;
|
||||
|
||||
static int parse_uint32_t (const plfield_t *field, const plitem_t *item,
|
||||
void *data, plitem_t *messages, void *context)
|
||||
{
|
||||
|
@ -224,6 +229,30 @@ static int parse_array (const plfield_t *field, const plitem_t *item,
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int parse_data (const plfield_t *field, const plitem_t *item,
|
||||
void *data, plitem_t *messages, void *context)
|
||||
{
|
||||
__auto_type datad = (parse_data_t *) field->data;
|
||||
__auto_type value = (void **) ((byte *)data + datad->value_offset);
|
||||
__auto_type size = (size_t *) ((byte *)data + datad->size_offset);
|
||||
|
||||
const void *bindata = PL_BinaryData (item);
|
||||
size_t binsize = PL_BinarySize (item);
|
||||
|
||||
Sys_Printf ("parse_array: %s %zd %d %p %p %p\n",
|
||||
field->name, field->offset, field->type, field->parser,
|
||||
field->data, data);
|
||||
Sys_Printf (" %zd %zd\n", datad->value_offset, datad->size_offset);
|
||||
Sys_Printf (" %zd %p\n", binsize, bindata);
|
||||
|
||||
*value = malloc (binsize);
|
||||
memcpy (*value, bindata, binsize);
|
||||
if ((void *) size > data) {
|
||||
*size = binsize;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#include "libs/video/renderer/vulkan/vkparse.cinc"
|
||||
|
||||
typedef struct qfv_renderpass_s {
|
||||
|
|
Loading…
Reference in a new issue