1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

C#ゲームエンジンのMultiDrawIndirect対応状況

Posted at

2026年1月8日の対応

Godot

多分対応してます。

if (p_use_indices) {
    ERR_FAIL_COND_MSG(p_offset + 20 > buffer->size, "Offset provided (+20) is past the end of buffer.");

    draw_graph.add_draw_list_draw_indexed_indirect(buffer->driver_id, p_offset, p_draw_count, p_stride);
} else {
    ERR_FAIL_COND_MSG(p_offset + 16 > buffer->size, "Offset provided (+16) is past the end of buffer.");

    draw_graph.add_draw_list_draw_indirect(buffer->driver_id, p_offset, p_draw_count, p_stride);
}

void RenderingDeviceGraph::add_draw_list_draw_indirect(RDD::BufferID p_buffer, uint32_t p_offset, uint32_t p_draw_count, uint32_t p_stride) {
	DrawListDrawIndirectInstruction *instruction = reinterpret_cast<DrawListDrawIndirectInstruction *>(_allocate_draw_list_instruction(sizeof(DrawListDrawIndirectInstruction)));
	instruction->type = DrawListInstruction::TYPE_DRAW_INDIRECT;
	instruction->buffer = p_buffer;
	instruction->offset = p_offset;
	instruction->draw_count = p_draw_count;
	instruction->stride = p_stride;
	draw_instruction_list.stages.set_flag(RDD::PIPELINE_STAGE_DRAW_INDIRECT_BIT);
}

void RenderingDeviceGraph::add_draw_list_draw_indexed_indirect(RDD::BufferID p_buffer, uint32_t p_offset, uint32_t p_draw_count, uint32_t p_stride) {
	DrawListDrawIndexedIndirectInstruction *instruction = reinterpret_cast<DrawListDrawIndexedIndirectInstruction *>(_allocate_draw_list_instruction(sizeof(DrawListDrawIndexedIndirectInstruction)));
	instruction->type = DrawListInstruction::TYPE_DRAW_INDEXED_INDIRECT;
	instruction->buffer = p_buffer;
	instruction->offset = p_offset;
	instruction->draw_count = p_draw_count;
	instruction->stride = p_stride;
	draw_instruction_list.stages.set_flag(RDD::PIPELINE_STAGE_DRAW_INDIRECT_BIT);
}

未対応

Unity

内部的に複数の命令に分割(https://issuetracker.unity3d.com/issues/graphics-dot-rendermeshindirect-does-not-issue-multi-draw-rendering-commands-when-using-a-graphics-api-capable-of-multi-draw-commands)

Stride3D

Vulkan OpenGLなど未対応(他のは調べてません)
https://github.com/stride3d/stride/blob/7a98919729393d89ef1cca170020e2b4c2006872/sources/engine/Stride.Graphics/Vulkan/CommandList.Vulkan.cs#L635

public void DrawIndexedInstanced(int indexCountPerInstance, int instanceCount, int startIndexLocation = 0, int baseVertexLocation = 0, int startInstanceLocation = 0)
{
    PrepareDraw();

    vkCmdDrawIndexed(currentCommandList.NativeCommandBuffer, (uint) indexCountPerInstance, (uint) instanceCount, (uint) startIndexLocation, baseVertexLocation, (uint) startInstanceLocation);
    //NativeCommandList.DrawIndexedInstanced(indexCountPerInstance, instanceCount, startIndexLocation, baseVertexLocation, startInstanceLocation);

    GraphicsDevice.FrameDrawCalls++;
    GraphicsDevice.FrameTriangleCount += (uint) (indexCountPerInstance * instanceCount);
}

public void DrawIndexedInstanced(Buffer argumentsBuffer, int alignedByteOffsetForArgs = 0)
{
    if (argumentsBuffer == null) throw new ArgumentNullException("argumentsBuffer");

    PrepareDraw();

    throw new NotImplementedException();
    //NativeCommandBuffer.DrawIndirect(argumentsBuffer.NativeBuffer, (ulong) alignedByteOffsetForArgs, );
    //NativeDeviceContext.DrawIndexedInstancedIndirect(argumentsBuffer.NativeBuffer, alignedByteOffsetForArgs);

    GraphicsDevice.FrameDrawCalls++;
}

public void DrawInstanced(int vertexCountPerInstance, int instanceCount, int startVertexLocation = 0, int startInstanceLocation = 0)
{
    PrepareDraw();

    vkCmdDraw(currentCommandList.NativeCommandBuffer, (uint) vertexCountPerInstance, (uint) instanceCount, (uint) startVertexLocation, (uint) startVertexLocation);
    //NativeCommandList.DrawInstanced(vertexCountPerInstance, instanceCount, startVertexLocation, startInstanceLocation);

    GraphicsDevice.FrameDrawCalls++;
    GraphicsDevice.FrameTriangleCount += (uint) (vertexCountPerInstance * instanceCount);
}

public void DrawInstanced(Buffer argumentsBuffer, int alignedByteOffsetForArgs = 0)
{
    if (argumentsBuffer == null) throw new ArgumentNullException("argumentsBuffer");

    PrepareDraw();

    throw new NotImplementedException();
    //NativeDeviceContext.DrawIndexedInstancedIndirect(argumentsBuffer.NativeBuffer, alignedByteOffsetForArgs);

    GraphicsDevice.FrameDrawCalls++;
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?