mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-27 07:26:48 +01:00
Conditional state restore and BufferUploader sanity check
- Only restore state that has changed - Sanity check to fix error condition on reset
This commit is contained in:
parent
3391e3e168
commit
b2c03a4069
3 changed files with 73 additions and 36 deletions
|
@ -45,11 +45,18 @@ public class GlStateTracker {
|
||||||
GlBufferType[] values = GlBufferType.values();
|
GlBufferType[] values = GlBufferType.values();
|
||||||
|
|
||||||
for (int i = 0; i < values.length; i++) {
|
for (int i = 0; i < values.length; i++) {
|
||||||
GlStateManager._glBindBuffer(values[i].glEnum, buffers[i]);
|
if (buffers[i] != GlStateTracker.buffers[i]) {
|
||||||
|
GlStateManager._glBindBuffer(values[i].glEnum, buffers[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager._glBindVertexArray(vao);
|
if (vao != GlStateTracker.vao) {
|
||||||
GlStateManager._glUseProgram(program);
|
GlStateManager._glBindVertexArray(vao);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (program != GlStateTracker.program) {
|
||||||
|
GlStateManager._glUseProgram(program);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.jozufozu.flywheel.mixin;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.gl.GlStateTracker;
|
||||||
|
import com.mojang.blaze3d.vertex.BufferUploader;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
|
|
||||||
|
@Mixin(BufferUploader.class)
|
||||||
|
public class BufferUploaderMixin {
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
@Nullable
|
||||||
|
private static VertexFormat lastFormat;
|
||||||
|
|
||||||
|
@Inject(method = "reset", at = @At("HEAD"))
|
||||||
|
private static void stopBufferUploaderFromClearingBufferStateIfNothingIsBound(CallbackInfo ci) {
|
||||||
|
// Trust our tracker over BufferUploader's.
|
||||||
|
if (GlStateTracker.getVertexArray() == 0) {
|
||||||
|
lastFormat = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,36 +1,37 @@
|
||||||
{
|
{
|
||||||
"required": true,
|
"required": true,
|
||||||
"minVersion": "0.8",
|
"minVersion": "0.8",
|
||||||
"package": "com.jozufozu.flywheel.mixin",
|
"package": "com.jozufozu.flywheel.mixin",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"refmap": "flywheel.refmap.json",
|
"refmap": "flywheel.refmap.json",
|
||||||
"client": [
|
"client": [
|
||||||
"BlockEntityTypeMixin",
|
"BlockEntityTypeMixin",
|
||||||
"BufferBuilderMixin",
|
"BufferBuilderMixin",
|
||||||
"CameraMixin",
|
"BufferUploaderMixin",
|
||||||
"CancelEntityRenderMixin",
|
"CameraMixin",
|
||||||
"ChunkRebuildHooksMixin",
|
"CancelEntityRenderMixin",
|
||||||
"EntityTypeMixin",
|
"ChunkRebuildHooksMixin",
|
||||||
"FixFabulousDepthMixin",
|
"EntityTypeMixin",
|
||||||
"FrustumMixin",
|
"FixFabulousDepthMixin",
|
||||||
"GlStateManagerMixin",
|
"FrustumMixin",
|
||||||
"InstanceAddMixin",
|
"GlStateManagerMixin",
|
||||||
"InstanceRemoveMixin",
|
"InstanceAddMixin",
|
||||||
"LevelRendererAccessor",
|
"InstanceRemoveMixin",
|
||||||
"LevelRendererMixin",
|
"LevelRendererAccessor",
|
||||||
"PausedPartialTickAccessor",
|
"LevelRendererMixin",
|
||||||
"RenderTexturesMixin",
|
"PausedPartialTickAccessor",
|
||||||
"RenderTypeMixin",
|
"RenderTexturesMixin",
|
||||||
"ShaderCloseMixin",
|
"RenderTypeMixin",
|
||||||
"atlas.AtlasDataMixin",
|
"ShaderCloseMixin",
|
||||||
"atlas.SheetDataAccessor",
|
"atlas.AtlasDataMixin",
|
||||||
"light.LightUpdateMixin",
|
"atlas.SheetDataAccessor",
|
||||||
"light.NetworkLightUpdateMixin",
|
"light.LightUpdateMixin",
|
||||||
"matrix.Matrix3fMixin",
|
"light.NetworkLightUpdateMixin",
|
||||||
"matrix.Matrix4fMixin",
|
"matrix.Matrix3fMixin",
|
||||||
"matrix.PoseStackMixin"
|
"matrix.Matrix4fMixin",
|
||||||
],
|
"matrix.PoseStackMixin"
|
||||||
"injectors": {
|
],
|
||||||
"defaultRequire": 1
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue