-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose Graphics.Vulkan.Marshal.Create.Union? #13
Comments
I did not expose Maybe another solution would be to add an automatic sorting of fields before comparing them?.. Let's keep this issue open, I want to explore the options. [I am about to finish my thesis now, but I want to work on the bindings after that] |
Ah nice; congrats! |
Ran into an abstraction limitation related to this. I currently have this helper function: setSharingQueueFamilyIndices ::
(
CanWriteField "sharingMode" a,
CanWriteField "queueFamilyIndexCount" a,
CanWriteField "pQueueFamilyIndices" a,
FieldType "sharingMode" a ~ VkSharingMode,
FieldType "queueFamilyIndexCount" a ~ Word32,
FieldType "pQueueFamilyIndices" a ~ Ptr Word32
) =>
[Word32] ->
CreateVkStruct a '["sharingMode", "queueFamilyIndexCount", "pQueueFamilyIndices"] ()
setSharingQueueFamilyIndices qfis =
set @"sharingMode" (if null qfis' then VK_SHARING_MODE_EXCLUSIVE else VK_SHARING_MODE_CONCURRENT) &*
setListCountAndRef @"queueFamilyIndexCount" @"pQueueFamilyIndices" qfis'
where
-- If just one QFI is provided, it's the same as providing none; both are exclusive mode,
-- and the QFI list is ignored in that case.
qfis' = if length qfis > 1 then qfis else [] I then noticed that different structs have these fields named differently. For example, while setSharingQFIs ::
forall (sm :: GHC.Symbol) (qfic :: GHC.Symbol) (pqfis :: GHC.Symbol) a.
(
CanWriteField sm a,
CanWriteField qfic a,
CanWriteField pqfis a,
FieldType sm a ~ VkSharingMode,
FieldType qfic a ~ Word32,
FieldType pqfis a ~ Ptr Word32
) =>
[Word32] ->
CreateVkStruct a '[sm, qfic, pqfis] ()
setSharingQFIs qfis =
set @sm (if null qfis' then VK_SHARING_MODE_EXCLUSIVE else VK_SHARING_MODE_CONCURRENT) &*
setListCountAndRef @qfic @pqfis qfis'
where
-- If just one QFI is provided, it's the same as providing none; both are exclusive mode,
-- and the QFI list is ignored in that case.
qfis' = if length qfis > 1 then qfis else [] Unfortunately, this gives the following error:
I suspect this is because it cannot prove that |
Hm, yes, you are right, I have to expose |
I wonder if the Create stuff could be redesigned such that the requirement that all the expected fields be set exactly once is enforced later than it is now... For example, in my In other words, |
So, you mean all writing functions would just append the list of written fields and the check for duplicates happens only in the final function |
Yeah, exactly. BTW, the name Union made sense for the existing data structure, but for a constraint on a list, would |
I'm trying to create some helper functions to eliminate some of the monotony of creating structures, for instance:
However, with this implementation, I have to supply the fields in the order specified in the type signature. Is there some way to resolve this? Would exposing the Union type family help?
Also, it seems like it might be more flexible in this context if there were a way to specify "a CreateVkStruct that has all the fields set except these", and then have the type signature list sType and pNext rather than the ones that the caller must provide.
The text was updated successfully, but these errors were encountered: