Search code examples
iosgraphics3dgame-enginemetal

Textures With Indirect Command Buffer


I render with func drawIndexedPrimitives( type primitiveType: MTLPrimitiveType, indexType: MTLIndexType, indexBuffer: MTLBuffer, indexBufferOffset: Int, indirectBuffer: MTLBuffer, indirectBufferOffset: Int ), when I use Argument Buffer to set textures(e.g. to fragnent shader), everything is fine. But is there a way to set textures without Argument Buffer? Argument Buffer is the only way?
When used with Argument Buffer, things go well.


Solution

  • No, there's no other way. If you are using indirect command buffers, you have to get textures through argument buffers.

    If you look at the API on the CPU:

    • MTLIndirectRenderCommand only has setVertexBuffer and setFragmentBuffer.
    • MTLIndirectComputeCommand only has setKernelBuffer

    and on the GPU:

    • render_command only has set_vertex_bufer and set_fragment_buffer
    • compute_command only has set_kernel_bufer.