[vkgen] Add support for read-only values

This makes it possible to use the parser to read in certain fields, but
skip over others. The read-only is for cexpr parsing of the read-only
fields.
This commit is contained in:
Bill Currie 2022-11-26 22:15:15 +09:00
parent 0dab26ce8f
commit 7829ec3adb
7 changed files with 93 additions and 0 deletions

View file

@ -11,6 +11,7 @@ vkgen_dat_src= \
libs/video/renderer/vulkan/vkgen/vkfieldcustom.r \
libs/video/renderer/vulkan/vkgen/vkfielddata.r \
libs/video/renderer/vulkan/vkgen/vkfielddef.r \
libs/video/renderer/vulkan/vkgen/vkfieldreadonly.r \
libs/video/renderer/vulkan/vkgen/vkfieldsingle.r \
libs/video/renderer/vulkan/vkgen/vkfieldstring.r \
libs/video/renderer/vulkan/vkgen/vkfieldtype.r \
@ -53,6 +54,7 @@ EXTRA_DIST += \
libs/video/renderer/vulkan/vkgen/vkfieldcustom.h \
libs/video/renderer/vulkan/vkgen/vkfielddata.h \
libs/video/renderer/vulkan/vkgen/vkfielddef.h \
libs/video/renderer/vulkan/vkgen/vkfieldreadonly.h \
libs/video/renderer/vulkan/vkgen/vkfieldsingle.h \
libs/video/renderer/vulkan/vkgen/vkfieldstring.h \
libs/video/renderer/vulkan/vkgen/vkfieldtype.h \

View file

@ -6,6 +6,7 @@
#include "vkfieldcustom.h"
#include "vkfielddata.h"
#include "vkfielddef.h"
#include "vkfieldreadonly.h"
#include "vkfieldsingle.h"
#include "vkfieldstring.h"
#include "vkstruct.h"
@ -42,6 +43,8 @@
return [[[SingleField alloc] init:item struct:strct field:fname] autorelease];
case "array":
return [[[ArrayField alloc] init:item struct:strct field:fname] autorelease];
case "readonly":
return [[[ReadOnlyField alloc] init:item struct:strct field:fname] autorelease];
}
return nil;
}

View file

@ -0,0 +1,14 @@
#ifndef __renderer_vulkan_vkgen_vkfieldreadonly_h
#define __renderer_vulkan_vkgen_vkfieldreadonly_h
#include "vkfielddef.h"
@class FieldType;
@interface ReadOnlyField: FieldDef
{
FieldType *type;
}
@end
#endif//__renderer_vulkan_vkgen_vkfieldreadonly_h

View file

@ -0,0 +1,45 @@
#include <PropertyList.h>
#include "vkfieldreadonly.h"
#include "vkfieldtype.h"
#include "vkgen.h"
#include "vktype.h"
@implementation ReadOnlyField
-init:(PLItem *) item struct:(Struct *)strct field:(string)fname
{
self = [super init:item struct:strct field:fname];
if (!self) {
return self;
}
PLItem *desc = [item getObjectForKey:"type"];
type = [[FieldType fieldType:[desc getObjectAtIndex:1]] retain];
value_field = [[item getObjectForKey:"value"] string];
return self;
}
-writeParseData
{
return self;
}
-writeField
{
string parse_type = [FieldType anyType];
fprintf (output_file, "\t{\"%s\", 0, %s, parse_%s, 0},\n",
field_name, parse_type, "ignore");
return self;
}
-writeSymbol
{
fprintf (output_file,
"\t{\"%s\", %s, (void *) field_offset (%s, %s)},\n",
field_name, [type exprType], struct_name, value_field);
return self;
}
@end

View file

@ -14,7 +14,9 @@
+fieldType:(PLItem *)item;
-initWithItem:(PLItem *)item;
-writeParseData;
-(string)exprType;
-(string)parseType;
+(string)anyType;
@end
string parseItemType (PLItem *item);

View file

@ -65,9 +65,24 @@ parseItemType (PLItem *item)
return self;
}
-(string) exprType
{
return "&" + type + "_type";
}
-(string) parseType
{
return parse_type;
}
+(string) anyType
{
string mask = "QFMultiType"
" | (1 << QFString)"
" | (1 << QFBinary)"
" | (1 << QFArray)"
" | (1 << QFDictionary)";
return mask;
}
@end

View file

@ -7,3 +7,15 @@ typedef struct qfv_subpass_s {
vec4 color;
string name;
} qfv_subpass_t;
//FIXME copy of qfv_output_t in qf_renderpass.h
//except it doesn't really matter because a custom spec is used
typedef struct qfv_output_s {
VkExtent2D extent;
VkImage image;
VkImageView view;
VkFormat format;
uint32_t frames;
VkImageView *view_list;
VkImageLayout finalLayout;
} qfv_output_t;