Skip to content

Restore buffer contents after native object reset - #3060

Open
8Keep wants to merge 1 commit into
jMonkeyEngine:masterfrom
8Keep:codex/buffer-reset-upload
Open

8Keep wants to merge 1 commit into
jMonkeyEngine:masterfrom
8Keep:codex/buffer-reset-upload

Conversation

@8Keep

@8Keep 8Keep commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

After a BufferObject has been uploaded, deleting or resetting its native object leaves it marked clean. Reusing it then skips the upload even though its GPU allocation no longer exists. The retained CPU data is never restored.

For an already uploaded buffer, the failing sequence is:

renderer.deleteBuffer(buffer);
renderer.setUniformBufferObject(0, buffer);

Mark the buffer and all its retained regions dirty in resetObject(), so the replacement allocation receives the complete data. This preserves the existing API and does not depend on another patch.

The new regression fails on upstream and passes with this fix.

Resetting a previously uploaded BufferObject must request a new upload and dirty every retained region, so context recreation or explicit deletion can allocate replacement storage with the original data.

Validation: BufferObjectResetTest fails on upstream and passes with the fix (offline Gradle, no GPU).
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T13:32:46.172051Z 8703bbb PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jaime-jmebot jaime-jmebot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for addressing this lifecycle bug. The change is focused and restores the important invariant that a reset buffer is considered out of date with its native allocation.

Calling setUpdateNeeded() from resetObject() is a good fit here: it marks both the buffer and every retained region dirty, so the renderer can recreate the native allocation and upload the complete retained data rather than incorrectly treating it as already synchronized. The regression test starts with clean state and verifies both levels become dirty after reset, covering the core behavior without adding API surface.

Looks good to me—thanks for including the regression test!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants