Setting up Objects in initView using PVRUtilsVk#

  1. Update the descriptor sets with the actual memory objects such as (buffers, images).

    This might sometimes need to be done in renderFrame() for streaming resources.

  2. Create command buffers, synchronisation objects and other app-specific objects.

    1. Usually, one command buffer is needed per swapchain (backbuffer) image. Use getSwapChainLength() and logicalDevice -> createCommandBufferOnDefaultPool() for this.

    2. In a multithreaded environment at least one command pool per thread should be used. Use context->createCommandPool() and then commandPool->allocateCommandBuffer() on that thread.

      Warning

      Do not use a command pool object from multiple threads – instead create one per thread. pvrvk::CommandBuffer objects track their command pools and are automatically reclaimed. Be careful to release them on the thread their pool belongs to, or to externally synchronise their release with their pool access.

  3. Use a loop to fill them up as follows:

    Note

    This is a very simple case.

    • For each swapChainImage, specifically for the CommandBuffer that corresponds to that swapchain image:

      Note

      The swapchain image index can be retrieved using getSwapchainIndex().

      • begin()

      • beginRenderPass() – pass the FBO that wraps the backbuffer image corresponding to this index to the index of this command buffer.

      • For each material/object type:

        • bindPipeline() - pass the pipeline object

        • bindDescriptorSets() – for any per-material descriptor sets such as textures

        • For each object:

          • bindDescriptorSets() – for any per-object descriptor sets, for example worldMatrix

          • bindVertexBuffer() - pass the VBO

          • bindIndexBuffer() - pass the IBO

          • drawXXXXXX() - for instance draw(), drawIndexed()

      • endRenderPass()

      • endRecording()