LukasBanana / LLGL

Low Level Graphics Library (LLGL) is a thin abstraction layer for the modern graphics APIs OpenGL, Direct3D, Vulkan, and Metal
BSD 3-Clause "New" or "Revised" License
2.05k stars 139 forks source link

Metal | baseInstance is not taken into account when instanceCount is not greater than 1 #130

Closed st0rmbtw closed 1 month ago

st0rmbtw commented 1 month ago

It took me several hours to find out why my sprites are not rendered correctly and why debugger says that baseInstance is always zero.

After some investigation, I noticed that baseInstance is taken into account only when instanceCount > 1. And then I found in the source code this line that checks instanceCount to be > 1: https://github.com/LukasBanana/LLGL/blob/47feff890ddf3679c5c1defe457fe3688274a602/sources/Renderer/Metal/Command/MTCommandExecutor.mm#L307

Why?

I just completely removed that check and now everything is rendered perfectly fine.

LukasBanana commented 1 month ago

Good catch! There needs to be a second branch at MTCommandExecutor.mm:331 for this condition. The rationale behind these branches is to support older versions of Metal. baseInstance is supported in iOS 9.0 while the other versions are supported since iOS 8.0.