LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: bcbradle on May 19, 2017, 02:35:09

Title: How do you use cmdExecuteCommands PointerBuffer argument?
Post by: bcbradle on May 19, 2017, 02:35:09
Its a PointerBuffer, and yet the idiomatic way to use vulkan's VkCommandBuffer is with a VkCommandBuffer object. How do I derive a PointerBuffer from a collection of VkCommandBuffer objects?
Title: Re: How do you use cmdExecuteCommands PointerBuffer argument?
Post by: darkyellow on May 19, 2017, 03:27:24
Have a look at the demo suite for some examples

https://github.com/LWJGL/lwjgl3-demos/blob/master/src/org/lwjgl/demo/vulkan/ColoredRotatingQuadDemo.java

Title: Re: How do you use cmdExecuteCommands PointerBuffer argument?
Post by: spasi on May 19, 2017, 07:18:55
First of all, vkCmdExecuteCommands is used to record secondary command buffers to execute as part of a primary command buffer. This is fairly advanced functionality, but if it's indeed what you want to do:

try (MemoryStack stack = stackPush()) {
    PointerBuffer secondaryCmdBuffers = stack.mallocPointer(count);

    // Fill secondaryCmdBuffers with command buffer handles.
    // You can simply use secondaryCmdBuffers.put(i, cmd_buffer_instance);

    vkCmdExecuteCommands(primaryCmdBuffer, secondaryCmdBuffers);
}