Results 1 to 2 of 2

Thread: Variable vertex count

  1. #1
    Newbie
    Join Date
    Jun 2018
    Location
    UK
    Posts
    2

    Question Variable vertex count

    Hi, Iím trying to adapt Googleís spinning cube.cpp to use drawIndirect instead of draw, so I can specify a variable number of triangles each frame.

    Mirroring the uniform buffer code, Iíve:

    • Added a Buffer and DeviceMemory to SwapchainImageResources for the indirect draw params.
    • Created a struct to represent VkDrawIndirectCommand containing four unsigned shorts.
    • Mirrored prepare_cube_data_buffers, using eIndirectBuffer instead of eUniformBuffer.
    • Mirrored update_data_buffer to set the draw params data.
      • vertex_count = 12 * 3, instance_count = 1

    • Replaced the call to draw with
      • commandBuffer.drawIndirect(mSwapchainImageResource s[mCurrentImageIndex].draw_params_buffer, 0, 1, 0);


    I havenít mirrored prepare_descriptor_set, because I donít think the shader needs access (assuming thatís what itís for).

    The problem is, when I switch from calling draw to drawIndirect, nothing gets drawn. I see no error messages, although Iím not entirely sure where to look. Iíve included --validate in the debug params and checked the code goes into the VK_LAYER_LUNARG_standard_validation bit, but Iím not sure how to tell if itís detecting a problem.

    Any advice would be greatly appreciated as Iíve spent a long time struggling to find useful resources on this specific use case. This is for a planetary terrain hobby project, evolved from this old terrain project, which I hope to use in a game.

  2. #2
    Newbie
    Join Date
    Jun 2018
    Location
    UK
    Posts
    2
    Oh I'm so sorry to have wasted anyone's time, I didn't need to make a struct to represent VkDrawIndirectCommand and in my embarassing C++ rustiness I shouldn't have used shorts, but ints!
    It's drawing now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean