Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix VertexBufferHolder breaking with cached PoseStack entries #5778

Merged
merged 1 commit into from
Oct 15, 2023

Conversation

embeddedt
Copy link
Contributor

When creating buffered jobs, VertexBufferHolder stores the position matrix contained in the last entry of the PoseStack in order to use it later. However, the block entity renderer pops that entry off the PoseStack shortly after. In vanilla, this does not cause a problem, as PoseStacks allocate fresh entries each time. However, some performance mods (e.g. Sodium) might cache PoseStack entries to curb the allocation rate in scenes with lots of block entities. This causes issues with IE as the same Matrix4f instance ends up being reused many times, causing all block entities using VertexBufferHolder to render at the same location (video provided by the user who experienced the problem).

It's debatable whether this is a bug in IE, since the code works correctly if mods provide the same semantics as vanilla. Sodium's input on the issue was that it is undefined behavior in graphics programming to expect a matrix reference to be valid after popping it off the stack. I chose to fix the issue in Embeddium by disabling the problematic optimization, since I personally believe vanilla semantics have to be preserved for compatibility, but I'm providing this PR to also fix the issue on IE's end.

@malte0811 malte0811 merged commit 9af90d4 into BluSunrize:1.20.1 Oct 15, 2023
2 checks passed
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