ReleasedDynamicTexture: Fix default nearest min/mag filter not being applied on 1.21.5+ #113
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The 1.21.5
setTextureFiltermethod doesn't actually apply the filter to the OpenGL object, it merely stores the desired values inside theGpuTextureobject which are then applied lazily inGlCommandEncoder.setupRenderPass.This however necessitates that the same
GpuTextureobject 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'sGpuTexturetype).A proper solution would be to introduce a universal
GpuTexturetype 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
GpuTextureobjects 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 theGpuTextureobject.Linear: EM-3194