How To Create Array of Structs?
Michael Ennen
mike.ennen at gmail.com
Thu Sep 2 05:35:12 UTC 2021
I have been doing more exploring with the panama-foreign, ffi, and jextract
branches - this time messing around with seeing if I can get a rainbow
triangle to be rendered on the screen with Vulkan.
I am really close. There is one problem I am having which is how to create
an array of structs?
See this, for example:
https://github.com/brcolow/java-vulkan/blob/master/src/main/java/com/brcolow/game/Vulkan.java#L581
If I set the stageCount to 2, then I get a validation exception about the
second shader module having bogus values. I believe this is caused by me
creating the array of structs incorrectly.
I am trying to set the pStages element of this struct:
https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkGraphicsPipelineCreateInfo.html
to an array containing pVertShaderStageInfo and pFragShaderStageInfo.
My attempt (I have tried other ways that also fail) to do that is:
MemorySegment pStages = SegmentAllocator.ofScope(scope).allocateArray(
C_POINTER, new Addressable[]{
pVertShaderStageInfo, pFragShaderStageInfo});
VkGraphicsPipelineCreateInfo.pStages$set(pPipelineCreateInfo,
MemoryAccess.getAddress(pStages));
If anyone could assist me with the proper way to create the
VkPipelineShaderStageCreateInfo* array containing pVertShaderStageInfoand
pFragShaderStageInfo - it would be greatly appreciated!
--
Michael Ennen
More information about the panama-dev
mailing list