improved occlusion query stability

This commit is contained in:
LAX1DUDE 2022-04-22 00:26:04 -07:00
parent b8cf84e97c
commit 7659bc095d
10 changed files with 73146 additions and 73152 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 boolean profanity = false;
public static final String version = "22w16d"; public static final String version = "22w16e";
public static final String mainMenuString = "eaglercraft " + version; public static final String mainMenuString = "eaglercraft " + version;
public static final String forkMe = "https://github.com/LAX1DUDE/eaglercraft"; public static final String forkMe = "https://github.com/LAX1DUDE/eaglercraft";

View File

@ -1120,7 +1120,12 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
public static final boolean glGetQueryResult(int obj) { public static final boolean glGetQueryResult(int obj) {
QueryGL q = queryObjs.get(obj); QueryGL q = queryObjs.get(obj);
return _wglGetQueryObjecti(q, _wGL_QUERY_RESULT_AVAILABLE) == 0 || _wglGetQueryObjecti(q, _wGL_QUERY_RESULT) > 0; return _wglGetQueryObjecti(q, _wGL_QUERY_RESULT) > 0;
}
public static final boolean glGetQueryResultAvailable(int obj) {
QueryGL q = queryObjs.get(obj);
return _wglGetQueryObjecti(q, _wGL_QUERY_RESULT_AVAILABLE) >= 0;
} }
public static final int glGenTextures() { public static final int glGenTextures() {

View File

@ -155,15 +155,7 @@ public class RenderGlobal implements IWorldAccess {
for(int i = 0; i < glOcclusionQuery.length; ++i) { for(int i = 0; i < glOcclusionQuery.length; ++i) {
this.glOcclusionQuery[i] = -1; this.glOcclusionQuery[i] = -1;
} }
// if (this.occlusionEnabled) { this.occlusionQueryAvailable = new boolean[glOcclusionQuery.length];
// this.occlusionResult.clear();
// this.glOcclusionQueryBase = GLAllocation.createDirectIntBuffer(var3 * var3 * var4);
// this.glOcclusionQueryBase.clear();
// this.glOcclusionQueryBase.position(0);
// this.glOcclusionQueryBase.limit(var3 * var3 * var4);
// EaglerAdapter.glGenQueriesARB(this.glOcclusionQueryBase);
// }
this.starGLCallList = GLAllocation.generateDisplayLists(3); this.starGLCallList = GLAllocation.generateDisplayLists(3);
EaglerAdapter.glPushMatrix(); EaglerAdapter.glPushMatrix();
EaglerAdapter.glNewList(this.starGLCallList, EaglerAdapter.GL_COMPILE); EaglerAdapter.glNewList(this.starGLCallList, EaglerAdapter.GL_COMPILE);
@ -510,7 +502,7 @@ public class RenderGlobal implements IWorldAccess {
} }
private long lastOcclusionQuery = 0l; private long lastOcclusionQuery = 0l;
private boolean occlusionQueryAvailable = false; private boolean[] occlusionQueryAvailable;
/** /**
* Sorts all renderers based on the passed in entity. Args: entityLiving, * Sorts all renderers based on the passed in entity. Args: entityLiving,
@ -568,18 +560,18 @@ public class RenderGlobal implements IWorldAccess {
byte var17 = 0; byte var17 = 0;
int var34; int var34;
if(par2 == 0 && occlusionQueryAvailable) { if(par2 == 0) {
occlusionQueryAvailable = false;
this.theWorld.theProfiler.endStartSection("getoccl"); this.theWorld.theProfiler.endStartSection("getoccl");
for (int i = 0; i < this.sortedWorldRenderers.length; ++i) { for (int i = 0; i < this.sortedWorldRenderers.length; ++i) {
WorldRenderer c = this.sortedWorldRenderers[i]; WorldRenderer c = this.sortedWorldRenderers[i];
int ccx = c.chunkX - fx; int ccx = c.chunkX - fx;
int ccy = c.chunkY - fy; int ccy = c.chunkY - fy;
int ccz = c.chunkZ - fz; int ccz = c.chunkZ - fz;
if(ccx < 2 && ccx > -2 && ccy < 2 && ccy > -2 && ccz < 2 && ccz > -2) { if((ccx < 2 && ccx > -2 && ccy < 2 && ccy > -2 && ccz < 2 && ccz > -2) || glOcclusionQuery[c.chunkIndex] == -1) {
c.isVisible = true; c.isVisible = true;
}else if(!c.skipAllRenderPasses() && c.isInFrustum) { }else if(!c.skipAllRenderPasses() && c.isInFrustum && occlusionQueryAvailable[c.chunkIndex] && EaglerAdapter.glGetQueryResultAvailable(glOcclusionQuery[c.chunkIndex])) {
c.isVisible = glOcclusionQuery[c.chunkIndex] == -1 ? true : EaglerAdapter.glGetQueryResult(glOcclusionQuery[c.chunkIndex]); c.isVisible = EaglerAdapter.glGetQueryResult(glOcclusionQuery[c.chunkIndex]);
occlusionQueryAvailable[c.chunkIndex] = false;
} }
} }
} }
@ -592,7 +584,6 @@ public class RenderGlobal implements IWorldAccess {
long ct = System.currentTimeMillis(); long ct = System.currentTimeMillis();
if(par2 == 0 && ct - lastOcclusionQuery > 50l) { if(par2 == 0 && ct - lastOcclusionQuery > 50l) {
lastOcclusionQuery = ct; lastOcclusionQuery = ct;
occlusionQueryAvailable = true;
this.theWorld.theProfiler.endStartSection("occl"); this.theWorld.theProfiler.endStartSection("occl");
EaglerAdapter.glEnable(EaglerAdapter.GL_CULL_FACE); EaglerAdapter.glEnable(EaglerAdapter.GL_CULL_FACE);
EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND); EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND);
@ -605,6 +596,7 @@ public class RenderGlobal implements IWorldAccess {
int ccy = c.chunkY - fy; int ccy = c.chunkY - fy;
int ccz = c.chunkZ - fz; int ccz = c.chunkZ - fz;
if(!c.skipAllRenderPasses() && c.isInFrustum && !(ccx < 2 && ccx > -2 && ccy < 2 && ccy > -2 && ccz < 2 && ccz > -2)) { if(!c.skipAllRenderPasses() && c.isInFrustum && !(ccx < 2 && ccx > -2 && ccy < 2 && ccy > -2 && ccz < 2 && ccz > -2)) {
occlusionQueryAvailable[c.chunkIndex] = true;
int q = glOcclusionQuery[c.chunkIndex]; int q = glOcclusionQuery[c.chunkIndex];
if(q == -1) { if(q == -1) {
q = glOcclusionQuery[c.chunkIndex] = EaglerAdapter.glCreateQuery(); q = glOcclusionQuery[c.chunkIndex] = EaglerAdapter.glCreateQuery();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long