I am trying to create a pointer to an array of of two (2) VkClearValues using Java's Project Panama (JEP 434, JDK 20). One clear value is for the color attachment, one is for the depth buffer.
My attempt at that is the following:
var pClearValue = VkClearValue.allocate(arena);
VkClearValue.color$slice(pClearValue).setAtIndex(C_FLOAT, 0, 0.0f);
VkClearValue.color$slice(pClearValue).setAtIndex(C_FLOAT, 1, 1.0f);
VkClearValue.color$slice(pClearValue).setAtIndex(C_FLOAT, 2, 0.0f);
VkClearValue.color$slice(pClearValue).setAtIndex(C_FLOAT, 3, 0.0f);
var pDepthClearValue = VkClearValue.allocate(arena);
VkClearDepthStencilValue.depth$set(VkClearValue.depthStencil$slice(pDepthClearValue), 1f);
VkClearDepthStencilValue.stencil$set(VkClearValue.depthStencil$slice(pDepthClearValue), 0);
var pClearValues = arena.allocateArray(VkClearValue.$LAYOUT(), 2);
pClearValues.setAtIndex(C_POINTER, 0, pClearValue.get(C_POINTER, 0));
pClearValues.setAtIndex(C_POINTER, 1, pDepthClearValue.get(C_POINTER, 0));
VkRenderPassBeginInfo.pClearValues$set(pRenderPassBeginInfo, 0, pClearValues);
Using Renderdoc I see garbage clear values being sent to Vulkan.
If I just try and pass in the one color clear value:
VkRenderPassBeginInfo.pClearValues$set(pRenderPassBeginInfo, 0, pClearValue);
The data is sent correctly (but with no depth clear value (only color)).
I have tried many permutations to try and set up this Pointer array, but I can never succeed in sending two valid depth adjustments.
Thanks!