gl_InstanceID does not work correctly with Vulkan
Steps to reproduce the bug:
Apply the attached resource pack with Vulkan
Enable the “Improved transparency” setting
Check the water rendering
Do the same thing with OpenGL
Expected behavior:
The water should be rendered like OpenGL
Code analysis:
@Override
public void draw(final int firstVertex, final int vertexCount) {
if (this.pipeline != null && this.pipeline.isValid()) {
this.pushDescriptors();
VK12.vkCmdDraw(this.secondaryCommandBuffer(), vertexCount, 1, firstVertex, vertexCount);
}
}The Vulkan signature is vkCmdDraw(cmd, vertexCount, instanceCount, firstVertex, firstInstance). The 5th argument firstInstance is set to vertexCount instead of 0.
Consequence: gl_InstanceIndex in any vertex shader will equal vertexCount instead of 0 for non-indexed draw() calls. Any shader that reads gl_InstanceIndex (for instancing, per-instance SSBO lookups, etc.) will have a shifted index.
Thank you for helping us improve Minecraft! We saved your files: