Skip to content

Commit 75822e2

Browse files
authored
ReleasedDynamicTexture: Fix default nearest min/mag filter not being applied on 1.21.5+
The 1.21.5 `setTextureFilter` method doesn't actually apply the filter to the OpenGL object, it merely stores the desired values inside the `GpuTexture` object which are then applied lazily in `GlCommandEncoder.setupRenderPass`. This however necessitates that the same `GpuTexture` object that was created here is also passed to the render pass, and since a lot of UniversalCraft-using code simply passes around raw OpenGL IDs, this isn't often the case (in fact, our URenderPass doesn't even support accepting MC's `GpuTexture` type). A proper solution would be to introduce a universal `GpuTexture` type and to deprecate all the old raw OpenGL ID APIs. This however introduces a lot of new API surface, so I'd want to get it right, and I'm not yet confident enough in having a good picture of how this new API should look. This commit fixes the issue by eagerly applying the filter during construction, matching the behavior of older MC versions. Another alternate solution I had considered was to internally pass around the `GpuTexture` objects via a global weak Map which maps OpenGL IDs to ReleasedDynamicTexture objects. However, this would break existing users which re-configure the filter mode via raw OpenGL before rendering, since any such modification would then be lost when MC applies the filters configured on the `GpuTexture` object. Linear: EM-3194 GitHub: #113
1 parent 4fd7050 commit 75822e2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/kotlin/gg/essential/universal/utils/ReleasedDynamicTexture.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ class ReleasedDynamicTexture private constructor(
127127
//$$ val texture = device.createTexture(null as String?, TextureFormat.RGBA8, width, height, 1)
128128
//#endif
129129
//$$ texture.setTextureFilter(FilterMode.NEAREST, true)
130+
//$$ UGraphics.configureTexture((texture as GlTexture).glId) {
131+
//#if MC>=12106
132+
//$$ texture.checkDirty(GL11.GL_TEXTURE_2D)
133+
//#else
134+
//$$ texture.checkDirty()
135+
//#endif
136+
//$$ }
130137
//$$ device.createCommandEncoder().writeToTexture(texture, textureData!!)
131138
//$$ textureData = null
132139
//$$ uploaded = true

0 commit comments

Comments
 (0)