Repository navigation
Lua GL: FBO attachment index and references, framebuffer restore after blits and RenderToTexture, attachment clears, cube map and multisample textures - #3482
Open
moss-orbit-9f339e wants to merge 2 commits into
Conversation
… after blits and RenderToTexture, attachment clears, cube map and multisample textures, LOD bias reset
- LuaFBOs::ApplyAttachment converted the index the wrong way round: a
positive index was turned into gettop + index + 1, past the top of the
stack. So assigning a table attachment (fbo.color0 = {tex, target,
level}, index 3 in meta_newindex) read the wrong stack slot.
- gl.CreateFBO did not store its attachments in the FBO reference
table, as fbo.key = value does, so an RBO given at creation could be
garbage collected while it was attached.
- gl.BlitFBO and gl.RenderToTexture restored only one framebuffer
binding (RenderToTexture restored 0 except in shadow drawing). They
now restore the read and draw bindings that were set before.
- gl.ClearAttachmentFBO: lua_isstring is also true for numbers, so a
numeric attachment was parsed as a name and failed. Stencil clears
now use glClearBufferiv.
- LuaTextures: a GL_TEXTURE_CUBE_MAP texture got no storage for its
faces; sampler parameters are not set on GL_TEXTURE_2D_MULTISAMPLE
(GL error); lodBias is applied also when it is 0, so it can be reset.
- Safe mode: also save and restore the scissor and stencil state around
Lua draw callins.
- ParseTextureImage: look up the Lua texture index once.
Found by a Codex audit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes in the Lua GL API for FBOs, textures and framebuffer state.
LuaFBOs::ApplyAttachmentconverted the stack index the wrong way round: a positive index becamegettop + index + 1, past the top of the stack. Sofbo.color0 = {tex, target, level}(index 3 inmeta_newindex) read the wrong stack slot.gl.CreateFBOcould be collected.fbo.key = valuestores the value in the FBO reference table, which keeps the RBO alive.gl.CreateFBOdid not do this for the attachments in its table.gl.BlitFBOandgl.RenderToTexture. Both restored one combined binding (RenderToTexturerestored 0 except in shadow drawing), so a separate read binding, or an FBO bound around a nestedRenderToTexture, was lost. They now restore the read and draw bindings that were set before.gl.ClearAttachmentFBO.lua_isstringis also true for numbers, so a numeric attachment was parsed as a name and failed. Stencil clears now useglClearBufferiv.GL_TEXTURE_CUBE_MAPtexture got no storage for its faces. Sampler parameters are no longer set onGL_TEXTURE_2D_MULTISAMPLE(GL error).lodBiasis applied also when it is 0, so it can be reset.ParseTextureImagelooks up the Lua texture index once.Sync: No change (unsynced Lua GL only).
Testing (Windows, RTX 3080; master
01efdf4312and this branch, each with thespringcontent.sdzof its own build; a Zero-K replay on Nuclear Winter, 29 players and about 1,000 units, at full graphics with many Lua GL widgets):gl.CreateFBO, nestedRenderToTexture, cube map storage, numeric and stencil clears). These are checked by reading the code.AI disclosure: OpenAI Codex (GPT-6.1 Sol) found these bugs in a code audit and drafted the fixes; a second Codex review checked the branch. Claude Code checked each finding against the code, reviewed every change, and ran the tests.
🤖 Generated with Claude Code