mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 06:03:09 +00:00
Merge pull request #96349 from pkdawson/metal-idx-offset
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
🔗 GHA / 🪲 Godot CPP (push) Has been cancelled
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
🔗 GHA / 🪲 Godot CPP (push) Has been cancelled
Metal: Bind index buffer with offset
This commit is contained in:
commit
61598c5c88
@ -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