incremental sparse allocation, clear viewport on resize
This commit is contained in:
@@ -111,7 +111,9 @@ public abstract class Viewport <A extends Viewport<A>> {
|
||||
(float) (this.cameraY-(sy<<5)),
|
||||
(float) (this.cameraZ-(sz<<5)));
|
||||
|
||||
this.depthBoundingBuffer.resize(this.width, this.height);
|
||||
if (this.depthBoundingBuffer.resize(this.width, this.height)) {
|
||||
this.depthBoundingBuffer.clear(0.0f);
|
||||
}
|
||||
|
||||
return (A) this;
|
||||
}
|
||||
|
||||
@@ -34,12 +34,12 @@ public class BasicSectionGeometryData implements IGeometryData {
|
||||
Logger.info("if your game crashes/exits here without any other log message, try manually decreasing the geometry capacity");
|
||||
glGetError();//Clear any errors
|
||||
GlBuffer buffer = null;
|
||||
if (!(Capabilities.INSTANCE.isNvidia && ThreadUtils.isWindows)) {
|
||||
if (!(Capabilities.INSTANCE.isNvidia)) {// && ThreadUtils.isWindows
|
||||
buffer = new GlBuffer(geometryCapacity, false);//Only do this if we are not on nvidia
|
||||
//TODO: FIXME: TEST, see if the issue is that we are trying to zero the entire buffer, try only zeroing increments
|
||||
// or dont zero it at all
|
||||
} else {
|
||||
Logger.info("Running on windows nvidia, using workaround sparse buffer allocation");
|
||||
Logger.info("Running on nvidia, using workaround sparse buffer allocation");
|
||||
}
|
||||
int error = glGetError();
|
||||
if (error != GL_NO_ERROR || buffer == null) {
|
||||
@@ -116,6 +116,9 @@ public class BasicSectionGeometryData implements IGeometryData {
|
||||
glFinish();
|
||||
if (Capabilities.INSTANCE.canQueryGpuMemory) {
|
||||
long releaseSize = (long) (this.geometryBuffer.size()*0.75);//if gpu memory usage drops by 75% of the expected value assume we freed it
|
||||
if (this.geometryBuffer.isSparse()) {//If we are using sparse buffers, use the commited size instead
|
||||
releaseSize = (long)(this.sparseCommitment*0.75);
|
||||
}
|
||||
if (Capabilities.INSTANCE.getFreeDedicatedGpuMemory()-gpuMemory<=releaseSize) {
|
||||
Logger.info("Attempting to wait for gpu memory to release");
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
@@ -22,14 +22,16 @@ public class DepthFramebuffer {
|
||||
this.depthType = depthType;
|
||||
}
|
||||
|
||||
public void resize(int width, int height) {
|
||||
public boolean resize(int width, int height) {
|
||||
if (this.depthBuffer == null || this.depthBuffer.getWidth() != width || this.depthBuffer.getHeight() != height) {
|
||||
if (this.depthBuffer != null) {
|
||||
this.depthBuffer.free();
|
||||
}
|
||||
this.depthBuffer = new GlTexture().store(this.depthType, 1, width, height);
|
||||
this.framebuffer.bind(this.depthType == GL_DEPTH24_STENCIL8?GL_DEPTH_STENCIL_ATTACHMENT: GL_DEPTH_ATTACHMENT, this.depthBuffer).verify();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
|
||||
Reference in New Issue
Block a user