korge icon indicating copy to clipboard operation
korge copied to clipboard

M1 Mac Error: "UNSUPPORTED (log once): POSSIBLE ISSUE: unit 2 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float)"

Open davjhan opened this issue 4 years ago • 7 comments

Setup

  • JDK: 1.8 (Amazon Coretto 1.8)
  • (M1 Max) Mackbook Pro 16 2021.
  • MacOs Monterey 12.0.1

Issue:

UNSUPPORTED (log once): POSSIBLE ISSUE: unit 1 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable

This doesn't actually seem to affect the output of the program. It still runs completely as expected.

This seems to be a common issue that is specific to GLSL and M1?

  • https://developer.apple.com/forums/thread/683865
  • https://blog.dengine.net/2021/01/wonders-and-mysteries-of-the-m1/
  • https://stackoverflow.com/questions/32237439/why-do-i-get-texture-unit-0-is-accessed-both-as-sampler2d-and-samplercube-for

Repro steps:

The following will repro the issue.

import com.soywiz.korge.Korge
import com.soywiz.korge.view.circle
suspend fun main() = Korge() {
    circle {

    }
}

This however, does not reproduce the issue:

import com.soywiz.korge.Korge
suspend fun main() = Korge() {
}

davjhan avatar Dec 31 '21 20:12 davjhan

Getting the same error with imgui when trying to use AddImage(). Some report that the issue is caused by texture arrays and (float) indices. This doesn't apply here as Imgui only uses a single texture. Any insights welcome!

denniskb avatar Jul 16 '23 22:07 denniskb

Oh, this is a warning. I believe running OpenGL code is perfectly valid. We didn't figure out how to "fix" this, and this looks like a problem on Apple's side. In our case, we plan to publish a Metal backend at some point, that will circumvent this problem. But in any case, this is just a harmless "log once" warning, so not a big deal.

soywiz avatar Jul 17 '23 05:07 soywiz

For anybody who faces the same issue: The min/mag filter was defaulting to mipmap but the texture had no mipmaps attached. Explicotly seeting the filter to linear fixed it.

denniskb avatar Jul 17 '23 08:07 denniskb

For anybody who faces the same issue: The min/mag filter was defaulting to mipmap but the texture had no mipmaps attached. Explicotly seeting the filter to linear fixed it.

Ohh. Awesome. Thought it was not possible. Do you have a link to a commit in another code-base fixing it?

PS: Just tried to change this to linear or NEAREST: https://github.com/korlibs/korge/blob/c2251600d5e1dfeff0ce7d3ebb08b21a0ad12168/korgw/src/commonMain/kotlin/korlibs/graphics/gl/AGOpengl.kt#L749-L750 and doesn't fixes the issue. Also tried to call it before binding the texture and it doesn't help either. So if you can provide the imgui patch where it happened and it stops happening that will be really useful.

soywiz avatar Jul 17 '23 08:07 soywiz

@soywiz sry mate, it wasn't an issue with ImGui but with my OpenGL code:

int id;
glGenTextures(1, &id);
glBindTexture(GL_TEXTURE_2D, id);
glTexImage2D(GL_TEXTURE_2D, ...);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // *
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // *
...
ImGui::Image(id); // +

+ was failing with the above error message on my Mac until I inserted the lines *.

denniskb avatar Jul 31 '23 22:07 denniskb