Skip to content

Commit 6d9b96a

Browse files
committed
Swap index and resetting the left framebuffers
1 parent 532f26e commit 6d9b96a

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

common/src/main/java/org/vivecraft/client_vr/provider/openxr/OpenXRStereoRenderer.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package org.vivecraft.client_vr.provider.openxr;
22

3-
import com.mojang.blaze3d.opengl.GlStateManager;
43
import com.mojang.blaze3d.pipeline.RenderTarget;
54
import net.minecraft.util.Tuple;
65
import org.joml.Matrix4f;
76
import org.lwjgl.PointerBuffer;
8-
import org.lwjgl.opengl.GL11C;
97
import org.lwjgl.openxr.*;
108
import org.lwjgl.system.MemoryStack;
119
import org.vivecraft.client_vr.VRTextureTarget;
@@ -18,7 +16,7 @@
1816

1917
public class OpenXRStereoRenderer extends VRRenderer {
2018
private final MCOpenXR openxr;
21-
private int[] swapIndex = new int[2];
19+
private final int[] swapIndex = new int[] {0, 0}; // Needs to be initialized otherwise stuff splodes
2220
private VRTextureTarget[] leftFramebuffers;
2321
private VRTextureTarget[] rightFramebuffers;
2422
private boolean render;
@@ -49,8 +47,11 @@ public void createRenderTexture(int width, int height) {
4947
XrSwapchainImageBaseHeader.create(swapchainImageBuffer.address(), swapchainImageBuffer.capacity()));
5048
this.openxr.logError(error, "xrEnumerateSwapchainImages", "get images");
5149

52-
this.leftFramebuffers = new VRTextureTarget[imageCount];
53-
this.rightFramebuffers = new VRTextureTarget[imageCount];
50+
if(i == 0) {
51+
this.leftFramebuffers = new VRTextureTarget[imageCount];
52+
} else {
53+
this.rightFramebuffers = new VRTextureTarget[imageCount];
54+
}
5455

5556
String leftError = "";
5657
String rightError = "";
@@ -103,7 +104,7 @@ public void setupRenderConfiguration(boolean render) throws IOException, RenderC
103104
.fov(this.openxr.viewBuffer.get(i).fov())
104105
.subImage();
105106
subImage.swapchain(this.openxr.swapchain[i]);
106-
subImage.imageRect().offset().set(i * this.openxr.width, 0);
107+
subImage.imageRect().offset().set(0, 0);
107108
subImage.imageRect().extent().set(this.openxr.width, this.openxr.height);
108109
}
109110
this.recalculateProjectionMatrix = true;
@@ -197,13 +198,19 @@ public void destroy() {
197198

198199
if (this.leftFramebuffers != null) {
199200
for (VRTextureTarget leftFramebuffer : this.leftFramebuffers) {
201+
if(leftFramebuffer == null) {
202+
continue;
203+
}
200204
leftFramebuffer.destroyBuffers();
201205
}
202206
this.leftFramebuffers = null;
203207
}
204208

205209
if (this.rightFramebuffers != null) {
206210
for (VRTextureTarget rightFramebuffer : this.rightFramebuffers) {
211+
if(rightFramebuffer == null) {
212+
continue;
213+
}
207214
rightFramebuffer.destroyBuffers();
208215
}
209216
this.rightFramebuffers = null;

common/src/main/java/org/vivecraft/client_vr/render/helpers/VRPassHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public static void renderAndSubmit(boolean renderLevel, DeltaTracker.Timer delta
239239
Profiler.get().pop();
240240

241241
DATA_HOLDER.vrPlayer.postRender(deltaTracker.getGameTimeDeltaPartialTick(true));
242-
Profiler.get().popPush("Display/Reproject");
242+
Profiler.get().push("Display/Reproject");
243243

244244
try {
245245
DATA_HOLDER.vrRenderer.endFrame();

0 commit comments

Comments
 (0)