mojira.dev
MC-311519

A missing sampler uniform is silently ignored by the OpenGL backend

GlCommandEncoder.setupDraw skips a COMBINED_IMAGE_SAMPLER uniform whose value has not been set, and the draw proceeds with whatever texture and sampler were last bound to that texture unit.

https://mcsrc.dev/2/26.3-snapshot-10/com/mojang/renderpearl/backend/opengl/GlCommandEncoder#L531-619

The null branch does nothing, so GL_TEXTURE0 + samplerIndex keeps the binding left by the previous render pass. The result is a wrong image with no GL error, no exception and no log entry.

Vulkan raises an error for the same state:

https://mcsrc.dev/1/26.3-snapshot-10/com/mojang/renderpearl/backend/vulkan/VulkanRenderPass#L279-340

if (value == null) {
  throw new IllegalStateException("Missing sampler " + uniform.name());
}

The other two uniform types in the same setupDraw switch diverge as well: Uniform.Ubo and Uniform.Utb dereference the value with no null check, so a missing UBO throws NullPointerException instead of being skipped. One unset uniform therefore gives three outcomes depending on its type and the backend.

Comments 2

Thank you for your report!
After consideration, the issue is being closed as Invalid.

This report does not describe a bug.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

Lolo

(Unassigned)

Community Consensus

26.3 Snapshot 10

Retrieved