Closed jamsch0 closed 8 years ago
After some digging, I found this to be the culprit (in the GenPreproc.types hashmap):
"VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT": ApiConst {
name: Some("VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT"),
value: Some("VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT")
}
which is generated from this (in the VkRegistry.extns hashmap):
"VK_EXT_debug_report": VkExtn {
name: Some("VK_EXT_debug_report"),
num: 12,
require: [
...
ExtnEnum {
extends: Some("VkStructureType"),
profile: None,
variant: Value {
name: Some("VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT"),
value: 1000011000
}
},
...
ConstDef {
name: Some("VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT"),
value: Some("VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT"),
profile: None
},
...
],
remove: []
}
In the generated vulkan.h C header, this turns into:
#define VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT
but with the way the generator currently works, VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT
is not a valid type and defaults to Unknown
, and henceforth the backtrace above.
The generator's default behavior when encountering this type of constant definition is to ignore it, although that clearly isn't happening with this. I tried to do some fixes on the legacy-enum-patch
branch through the GitHub editor, but those are making even the basic tests fail. I'll look into this more when I get access to an actual computer, but if you can make a proper fix for this I'll gladly pull it. The relevant code is in here, where the generator resolves the type of API constants (constants like VK_TRUE
, VK_MAX_EXTENSION_NAME_SIZE
, etc.). This code also detects whether or not the enum is a renamed enum (dubbed ConstType::LegacyEnum
in the code), in which case the constant should get ignored and shouldn't have anything get generated.
I got as far as finding the relevant code you linked, but haven't looked at it enough to determine a proper fix. I quickly tried commenting out this line which seems to solve the problem, but then I get a bunch of errors about function pointers (I assume the debug_report extension function pointers aren't being parsed properly either). I'll take another look tomorrow and see about a fix.
I've fixed the issue with legacy enums here, and have tracked the function pointer issue to this (in the VkRegistry.types):
"PFN_vkDebugReportCallbackEXT": FuncPointer {
name: Some("PFN_vkDebugReportCallbackEXT"),
ret: Var(Some("VkBool32")),
params: [
Var(Some("VkDebugReportFlagsEXT")),
Var(Some("VkDebugReportObjectTypeEXT")),
Var(Some("uint64_t")),
Var(Some("size_t")),
Const(Some("int32_t")),
Const(Some("c_char")),
MutPtr(Some("c_char"), 1),
MutPtr(Some("c_void"), 1)
]
}
with the relevant lines here and here. Basically, the generator doesn't know what to do with const params.
Edit: I'm not sure that those param types above have been inferred properly, since this is what the generated vulkan.h C header has:
typedef VkBool32 (VKAPI_PTR *PFN_vkDebugReportCallbackEXT)(
VkDebugReportFlagsEXT flags,
VkDebugReportObjectTypeEXT objectType,
uint64_t object,
size_t location,
int32_t messageCode,
const char* pLayerPrefix,
const char* pMessage,
void* pUserData);
To me it looks like the Const(Some("int32_t"))
should be Var(..)
, the Const(Some("c_char"))
should be ConstPtr(.., 1)
and the MutPtr(Some("c_char"), 1)
should be ConstPtr(..)
.
Edit 2: I think the issue is with the crawler here, at a glance it looks like the "const"
is being attached to the tag before it, rather than the tag after (relevant xml).
I've set up vk_generator to generate some vulkan bindings for both core and some surface extensions. However when I attempt to add the
VK_EXT_debug_report
extension to the list of extension bindings to generate, the generator fails.The prelude is outputted (panic function, macro definitions etc.), but nothing else. I tried purposely spelling the extension name wrong just to triple check that I hadn't typed it wrong initially and the generator outputs nothing at all, so I definitely spelt it correctly.
Am I doing something wrong, or is this an issue? Thanks.
Edit: Just run my build script manually and found that vk_generator is panicking. Here's the error and backtrace: