22w16g improved occlusion query stability (reduced "chunk flickering")

This commit is contained in:
LAX1DUDE 2022-04-22 20:40:37 -07:00
parent df09eb33b5
commit 03d4511523
11 changed files with 60522 additions and 60482 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@ public class ConfigConstants {
public static boolean profanity = false;
public static final String version = "22w16f";
public static final String version = "22w16g";
public static final String mainMenuString = "eaglercraft " + version;
public static final String forkMe = "https://github.com/LAX1DUDE/eaglercraft";

View File

@ -1098,19 +1098,12 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
public static final void glDrawOcclusionBB(float posX, float posY, float posZ, float sizeX, float sizeY, float sizeZ) {
glPushMatrix();
glTranslatef(posX - sizeX * 0.0001f, posY - sizeY * 0.0001f, posZ - sizeZ * 0.0001f);
glScalef(sizeX * 1.0002f, sizeY * 1.0002f, sizeZ * 1.0002f);
glTranslatef(posX - sizeX * 0.01f, posY - sizeY * 0.01f, posZ - sizeZ * 0.01f);
glScalef(sizeX * 1.02f, sizeY * 1.02f, sizeZ * 1.02f);
matModelV[matModelPointer].store(occlusionModel);
_wglUniformMat4fv(occlusion_matrix_m, occlusionModel);
_wglDrawArrays(_wGL_TRIANGLES, 0, 36);
glPopMatrix();
//glPushMatrix();
//glTranslatef(posX + sizeX * 0.0001f, posY + sizeY * 0.0001f, posZ + sizeZ * 0.0001f);
//glScalef(sizeX * 0.9998f, sizeY * 0.9998f, sizeZ * 0.9998f);
//matModelV[matModelPointer].store(occlusionModel);
//_wglUniformMat4fv(occlusion_matrix_m, occlusionModel);
//_wglDrawArrays(_wGL_TRIANGLES, 0, 36);
//glPopMatrix();
}

View File

@ -211,6 +211,7 @@ public class GuiMainMenu extends GuiScreen {
int x = (this.width - 345) / 2;
int y = (this.height - 230) / 2;
if(par1 >= (x + 323) && par1 <= (x + 323 + 13) && par2 >= (y + 7) && par2 <= (y + 7 + 13)) {
this.mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
hideAck();
}
int trackHeight = 193;

View File

@ -156,7 +156,7 @@ public class RenderGlobal implements IWorldAccess {
this.glOcclusionQuery[i] = -1;
}
this.occlusionQueryAvailable = new boolean[glOcclusionQuery.length];
this.occlusionQueryStalled = new boolean[occlusionQueryAvailable.length];
this.occlusionQueryStalled = new long[occlusionQueryAvailable.length];
this.starGLCallList = GLAllocation.generateDisplayLists(3);
EaglerAdapter.glPushMatrix();
EaglerAdapter.glNewList(this.starGLCallList, EaglerAdapter.GL_COMPILE);
@ -504,7 +504,7 @@ public class RenderGlobal implements IWorldAccess {
private long lastOcclusionQuery = 0l;
private boolean[] occlusionQueryAvailable;
private boolean[] occlusionQueryStalled;
private long[] occlusionQueryStalled;
/**
* Sorts all renderers based on the passed in entity. Args: entityLiving,
@ -561,7 +561,11 @@ public class RenderGlobal implements IWorldAccess {
RenderHelper.disableStandardItemLighting();
byte var17 = 0;
int var34;
long queryRate = 50l;
long stallRate = 150l;
long ct = System.currentTimeMillis();
if(par2 == 0) {
this.theWorld.theProfiler.endStartSection("getoccl");
for (int i = 0; i < this.sortedWorldRenderers.length; ++i) {
@ -571,14 +575,14 @@ public class RenderGlobal implements IWorldAccess {
int ccz = c.chunkZ - fz;
if((ccx < 2 && ccx > -2 && ccy < 2 && ccy > -2 && ccz < 2 && ccz > -2) || glOcclusionQuery[c.chunkIndex] == -1) {
c.isVisible = true;
}else if(!c.skipAllRenderPasses() && c.isInFrustum && occlusionQueryAvailable[c.chunkIndex]) {
if(EaglerAdapter.glGetQueryResultAvailable(glOcclusionQuery[c.chunkIndex])) {
}else if(!c.skipAllRenderPasses() && c.isInFrustum) {
if(occlusionQueryAvailable[c.chunkIndex] && EaglerAdapter.glGetQueryResultAvailable(glOcclusionQuery[c.chunkIndex])) {
c.isVisible = EaglerAdapter.glGetQueryResult(glOcclusionQuery[c.chunkIndex]);
occlusionQueryAvailable[c.chunkIndex] = false;
}else if(occlusionQueryStalled[c.chunkIndex]) {
occlusionQueryStalled[c.chunkIndex] = 0l;
}else if(occlusionQueryStalled[c.chunkIndex] != 0l && ct - occlusionQueryStalled[c.chunkIndex] > stallRate) {
c.isVisible = true;
}
occlusionQueryStalled[c.chunkIndex] = false;
}
}
}
@ -588,8 +592,8 @@ public class RenderGlobal implements IWorldAccess {
var7 -= par1EntityLiving.getEyeHeight();
long ct = System.currentTimeMillis();
if(par2 == 0 && ct - lastOcclusionQuery > 50l) {
ct = System.currentTimeMillis();
if(par2 == 0 && ct - lastOcclusionQuery > queryRate) {
lastOcclusionQuery = ct;
this.theWorld.theProfiler.endStartSection("occl");
EaglerAdapter.glEnable(EaglerAdapter.GL_CULL_FACE);
@ -603,18 +607,25 @@ public class RenderGlobal implements IWorldAccess {
int ccy = c.chunkY - fy;
int ccz = c.chunkZ - fz;
if(!c.skipAllRenderPasses() && c.isInFrustum && !(ccx < 2 && ccx > -2 && ccy < 2 && ccy > -2 && ccz < 2 && ccz > -2)) {
boolean stalled = false;
if(occlusionQueryAvailable[c.chunkIndex]) {
occlusionQueryStalled[c.chunkIndex] = true;
}else {
if(occlusionQueryStalled[c.chunkIndex] == 0l) {
occlusionQueryStalled[c.chunkIndex] = ct;
stalled = true;
}else if(ct - occlusionQueryStalled[c.chunkIndex] < stallRate) {
stalled = true;
}
}
if(!stalled) {
occlusionQueryAvailable[c.chunkIndex] = true;
int q = glOcclusionQuery[c.chunkIndex];
if(q == -1) {
q = glOcclusionQuery[c.chunkIndex] = EaglerAdapter.glCreateQuery();
}
EaglerAdapter.glBeginQuery(q);
EaglerAdapter.glDrawOcclusionBB((float)(c.posX - var33), (float)(c.posY - var7), (float)(c.posZ - var9), 16, 16, 16);
EaglerAdapter.glEndQuery();
}
int q = glOcclusionQuery[c.chunkIndex];
if(q == -1) {
q = glOcclusionQuery[c.chunkIndex] = EaglerAdapter.glCreateQuery();
}
EaglerAdapter.glBeginQuery(q);
EaglerAdapter.glDrawOcclusionBB((float)(c.posX - var33), (float)(c.posY - var7), (float)(c.posZ - var9), 16, 16, 16);
EaglerAdapter.glEndQuery();
}
}
EaglerAdapter.glEndOcclusionBB();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long