mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 06:03:09 +00:00
Metal: bind index buffer with offset
This commit is contained in:
parent
a5830f6eb9
commit
f381cee82f
@ -227,6 +227,7 @@ public:
|
||||
id<MTLRenderCommandEncoder> encoder = nil;
|
||||
id<MTLBuffer> __unsafe_unretained index_buffer = nil; // Buffer is owned by RDD.
|
||||
MTLIndexType index_type = MTLIndexTypeUInt16;
|
||||
uint32_t index_offset = 0;
|
||||
LocalVector<id<MTLBuffer> __unsafe_unretained> vertex_buffers;
|
||||
LocalVector<NSUInteger> vertex_offsets;
|
||||
// clang-format off
|
||||
|
@ -717,6 +717,7 @@ void MDCommandBuffer::render_bind_index_buffer(RDD::BufferID p_buffer, RDD::Inde
|
||||
|
||||
render.index_buffer = rid::get(p_buffer);
|
||||
render.index_type = p_format == RDD::IndexBufferFormat::INDEX_BUFFER_FORMAT_UINT16 ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32;
|
||||
render.index_offset = p_offset;
|
||||
}
|
||||
|
||||
void MDCommandBuffer::render_draw_indexed(uint32_t p_index_count,
|
||||
@ -729,13 +730,16 @@ void MDCommandBuffer::render_draw_indexed(uint32_t p_index_count,
|
||||
|
||||
id<MTLRenderCommandEncoder> enc = render.encoder;
|
||||
|
||||
uint32_t index_offset = render.index_offset;
|
||||
index_offset += p_first_index * (render.index_type == MTLIndexTypeUInt16 ? sizeof(uint16_t) : sizeof(uint32_t));
|
||||
|
||||
[enc drawIndexedPrimitives:render.pipeline->raster_state.render_primitive
|
||||
indexCount:p_index_count
|
||||
indexType:render.index_type
|
||||
indexBuffer:render.index_buffer
|
||||
indexBufferOffset:p_vertex_offset
|
||||
indexBufferOffset:index_offset
|
||||
instanceCount:p_instance_count
|
||||
baseVertex:p_first_index
|
||||
baseVertex:p_vertex_offset
|
||||
baseInstance:p_first_instance];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user