From 03f614ccb90bd99243c83674c7a05fb7ff7fd129 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 12 Jan 2021 13:07:51 +0900 Subject: [PATCH] [vulkan] Parse VkBool32 correctly as bool type This makes it much clearer whether something is just a flag or an index of some sort. --- libs/video/renderer/vulkan/qfpipeline.plist | 32 ++++++++++----------- libs/video/renderer/vulkan/vkgen/vkalias.r | 22 ++++++++++++-- libs/video/renderer/vulkan/vkgen/vkenum.r | 6 ++++ libs/video/renderer/vulkan/vkgen/vkgen.r | 5 +++- 4 files changed, 46 insertions(+), 19 deletions(-) diff --git a/libs/video/renderer/vulkan/qfpipeline.plist b/libs/video/renderer/vulkan/qfpipeline.plist index 3d7ec1f10..437ab5854 100644 --- a/libs/video/renderer/vulkan/qfpipeline.plist +++ b/libs/video/renderer/vulkan/qfpipeline.plist @@ -19,14 +19,14 @@ addressModeV = clamp_to_edge; addressModeW = clamp_to_edge; mipLodBias = 0; - anisotropyEnable = 0;//FIXME false!!! + anisotropyEnable = false; maxAnisotropy = 0; - compareEnable = 0;//FIXME false!!! + compareEnable = false; compareOp = always; minLod = 0; maxLod = 0; borderColor = float_transparent_black; - unnormalizedCoordinates = 1;//FIXME true!!! + unnormalizedCoordinates = true; }; }; descriptorPools = { @@ -132,7 +132,7 @@ }; inputAssembly = { topology = triangle_strip; - primitiveRestartEnable = 1; + primitiveRestartEnable = true; }; viewport = { viewports = ( @@ -150,32 +150,32 @@ ); }; rasterization = { - depthClampEnable = 0; - rasterizerDiscardEnable = 0; + depthClampEnable = false; + rasterizerDiscardEnable = false; polygonMode = fill; cullMode = back; frontFace = counter_clockwise; - depthBiasEnable = 0; + depthBiasEnable = false; lineWidth = 1; }; multisample = { rasterizationSamples = $msaaSamples; - sampleShadingEnable = 0; + sampleShadingEnable = false; minSampleShading = 0.5f; - alphaToCoverageEnable = 0; - alphaToOneEnable = 0; + alphaToCoverageEnable = false; + alphaToOneEnable = false; }; depthStencil = { - depthTestEnable = 1; - depthWriteEnable = 1; + depthTestEnable = true; + depthWriteEnable = true; depthCompareOp = less; - depthBoundsTestEnable = 0; - stencilTestEnable = 0; + depthBoundsTestEnable = false; + stencilTestEnable = false; }; colorBlend = { - logicOpEnable = 0; + logicOpEnable = false; attachments = ({ - blendEnable = 0; + blendEnable = false; srcColorBlendFactor = src_color; dstColorBlendFactor = zero; colorBlendOp = add; diff --git a/libs/video/renderer/vulkan/vkgen/vkalias.r b/libs/video/renderer/vulkan/vkgen/vkalias.r index be783b207..cde6eb270 100644 --- a/libs/video/renderer/vulkan/vkgen/vkalias.r +++ b/libs/video/renderer/vulkan/vkgen/vkalias.r @@ -28,14 +28,16 @@ [enumObj addToQueue]; } } else if (name == "VkBool32") { - // drop + id enumObj = [(id) Hash_Find (available_types, name) resolveType]; + [enumObj addToQueue]; } else if ([alias class] == [Enum class] || [alias class] == [Struct class]) { [alias addToQueue]; } else if (alias.type.meta == ty_basic && alias.type.type == ev_pointer) { Type *type = [Type findType:alias.type.fldptr.aux_type]; if (!type) { - // pointer to opaque struct. Probably VK_DEFINE_NON_DISPATCHABLE_HANDLE or VK_DEFINE_HANDLE + // pointer to opaque struct. Probably + // VK_DEFINE_NON_DISPATCHABLE_HANDLE or VK_DEFINE_HANDLE string createInfo = name + "CreateInfo"; id structObj = (id) Hash_Find (available_types, createInfo); if (structObj) { @@ -62,6 +64,10 @@ return [enumObj cexprType]; } } + if (name == "VkBool32") { + id enumObj = [(id) Hash_Find (available_types, name) resolveType]; + return [enumObj cexprType]; + } if (name == "uint32_t") { return "cexpr_uint"; } @@ -83,6 +89,10 @@ return [enumObj parseType]; } } + if (name == "VkBool32") { + id enumObj = [(id) Hash_Find (available_types, name) resolveType]; + return [enumObj parseType]; + } if (name == "uint32_t" || name == "size_t") { return "QFString"; } @@ -101,6 +111,10 @@ return [enumObj parseFunc]; } } + if (name == "VkBool32") { + id enumObj = [(id) Hash_Find (available_types, name) resolveType]; + return [enumObj parseFunc]; + } if (name == "uint32_t") { return "parse_uint32_t"; } @@ -119,6 +133,10 @@ return [enumObj parseData]; } } + if (name == "VkBool32") { + id enumObj = [(id) Hash_Find (available_types, name) resolveType]; + return [enumObj parseData]; + } if (name == "uint32_t" || name == "size_t") { return "0"; } diff --git a/libs/video/renderer/vulkan/vkgen/vkenum.r b/libs/video/renderer/vulkan/vkgen/vkenum.r index 537916800..7c974f6fb 100644 --- a/libs/video/renderer/vulkan/vkgen/vkenum.r +++ b/libs/video/renderer/vulkan/vkgen/vkenum.r @@ -3,6 +3,12 @@ #include "vkenum.h" #include "vkgen.h" +typedef enum VkBool32 { + VK_FALSE, + VK_TRUE, + VK_MAX_ENUM = VK_TRUE +} VkBool32; + @implementation Enum -(void)process { diff --git a/libs/video/renderer/vulkan/vkgen/vkgen.r b/libs/video/renderer/vulkan/vkgen/vkgen.r index 4636df52f..01637c54a 100644 --- a/libs/video/renderer/vulkan/vkgen/vkgen.r +++ b/libs/video/renderer/vulkan/vkgen/vkgen.r @@ -117,7 +117,10 @@ scan_types (void) string tag = str_mid(type.strct.tag, 4); Type *avail_type = [Type fromType: type]; if (avail_type) { - Hash_Add (available_types, avail_type); + if (!Hash_Find (available_types, [avail_type name])) { + printf ("scan: %s %s\n", tag, [avail_type name]); + Hash_Add (available_types, avail_type); + } } } }