Skip to content

Structure extensions don't seem to work #16

@talex5

Description

@talex5

I'm trying to work out how to use the pNext fields. Specifically, I want to convert this C code:

VkPhysicalDeviceDrmPropertiesEXT ext_drm = {
	.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRM_PROPERTIES_EXT,
};
VkPhysicalDeviceProperties2 props2 = {
	.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
	.pNext = &ext_drm,
};
vkGetPhysicalDeviceProperties2(physicalDevices[i], &props2);

(I first had to update Olivine to v1.2.183 to get the DRM extension, which is needed to work on Wayland. That's on my fork at https://github.com/talex5/olivine)

The generated code for VkPhysicalDeviceProperties2 doesn't have any listed extensions, and isn't mentioned in any other file:

type physical_device_properties_2_eXt = ..
type physical_device_properties_2_eXt +=  
  | No_extension 

It looks like Record_extension.merge is expecting a list of cases, but it's always empty. I tried adding assert (List.length cases = 2); to

let merge (name,exts) ~tag ~data =
let case ext = Exp.case (strp ext)
C.(constr.e ext @@ (!@) @@ coerce ~from:(ptr void) ~to':(ptr @@ typext ext) data ) in
let noext = Exp.case (strp name) [%expr No_extension] in
let exn = Exp.case [%pat? _] [%expr raise Unknown_record_extension ] in
let cases = noext :: (List.map case exts) @ [exn] in
Exp.match_ tag cases
and that doesn't trigger, so it looks like nothing supports extensions at the moment.

The TODO says:

Done:

  • Structure_type handling:
    The (s_type, p_next) vulkan idiom should be mapped to
    Stype(p_next) and made optional in smart record constructor when there is
    only one possible `Stype. The possible values need to be extracted from the vulkan
    spec.

But I'm not sure whether to believe that, as #8 says:

However, the TODO is mostly still accurate, except for the handling of structure extension.

Did this ever work? I can have a go at implementing it if not, but I'm not sure what the plan is.

The ext field has an open type, suggesting it was supposed to be extended in other files. But the code generation seems to assume that all the extensions would get collected together in the main file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions