GLRenderer: the actual async FB read changes
This commit is contained in:
parent
860de88298
commit
f0b63e7910
@ -62,6 +62,7 @@ import java.util.EnumMap;
|
|||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -98,6 +99,7 @@ public class GLRenderer implements Renderer {
|
|||||||
private final GLExt glext;
|
private final GLExt glext;
|
||||||
private final GLFbo glfbo;
|
private final GLFbo glfbo;
|
||||||
private final TextureUtil texUtil;
|
private final TextureUtil texUtil;
|
||||||
|
private final AsyncFrameReader frameReader;
|
||||||
|
|
||||||
public GLRenderer(GL gl, GLExt glext, GLFbo glfbo) {
|
public GLRenderer(GL gl, GLExt glext, GLFbo glfbo) {
|
||||||
this.gl = gl;
|
this.gl = gl;
|
||||||
@ -107,6 +109,7 @@ public class GLRenderer implements Renderer {
|
|||||||
this.glfbo = glfbo;
|
this.glfbo = glfbo;
|
||||||
this.glext = glext;
|
this.glext = glext;
|
||||||
this.texUtil = new TextureUtil(gl, gl2, glext);
|
this.texUtil = new TextureUtil(gl, gl2, glext);
|
||||||
|
this.frameReader = new AsyncFrameReader(this, gl, glext, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -861,6 +864,7 @@ public class GLRenderer implements Renderer {
|
|||||||
|
|
||||||
public void postFrame() {
|
public void postFrame() {
|
||||||
objManager.deleteUnused(this);
|
objManager.deleteUnused(this);
|
||||||
|
frameReader.updateReadRequests();
|
||||||
gl.resetStats();
|
gl.resetStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1647,11 +1651,11 @@ public class GLRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readFrameBuffer(FrameBuffer fb, ByteBuffer byteBuf) {
|
public Future<ByteBuffer> readFrameBufferLater(FrameBuffer fb, ByteBuffer byteBuf) {
|
||||||
readFrameBufferWithGLFormat(fb, byteBuf, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE);
|
return frameReader.readFrameBufferLater(fb, byteBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readFrameBufferWithGLFormat(FrameBuffer fb, ByteBuffer byteBuf, int glFormat, int dataType) {
|
void readFrameBufferWithGLFormat(FrameBuffer fb, ByteBuffer byteBuf, int glFormat, int dataType, int pboId) {
|
||||||
if (fb != null) {
|
if (fb != null) {
|
||||||
RenderBuffer rb = fb.getColorBuffer();
|
RenderBuffer rb = fb.getColorBuffer();
|
||||||
if (rb == null) {
|
if (rb == null) {
|
||||||
@ -1670,12 +1674,30 @@ public class GLRenderer implements Renderer {
|
|||||||
setFrameBuffer(null);
|
setFrameBuffer(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context.boundPixelPackPBO != pboId) {
|
||||||
|
gl.glBindBuffer(GLExt.GL_PIXEL_PACK_BUFFER_ARB, pboId);
|
||||||
|
context.boundPixelPackPBO = pboId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (byteBuf == null) {
|
||||||
|
gl.glReadPixels(vpX, vpY, vpW, vpH, glFormat, dataType, 0);
|
||||||
|
} else {
|
||||||
gl.glReadPixels(vpX, vpY, vpW, vpH, glFormat, dataType, byteBuf);
|
gl.glReadPixels(vpX, vpY, vpW, vpH, glFormat, dataType, byteBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context.boundPixelPackPBO != 0) {
|
||||||
|
gl.glBindBuffer(GLExt.GL_PIXEL_PACK_BUFFER_ARB, 0);
|
||||||
|
context.boundPixelPackPBO = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) {
|
public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) {
|
||||||
GLImageFormat glFormat = texUtil.getImageFormatWithError(format, false);
|
GLImageFormat glFormat = texUtil.getImageFormatWithError(format, false);
|
||||||
readFrameBufferWithGLFormat(fb, byteBuf, glFormat.format, glFormat.dataType);
|
readFrameBufferWithGLFormat(fb, byteBuf, glFormat.format, glFormat.dataType, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readFrameBuffer(FrameBuffer fb, ByteBuffer byteBuf) {
|
||||||
|
readFrameBufferWithFormat(fb, byteBuf, Image.Format.RGBA8);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteRenderBuffer(FrameBuffer fb, RenderBuffer rb) {
|
private void deleteRenderBuffer(FrameBuffer fb, RenderBuffer rb) {
|
||||||
@ -2285,6 +2307,7 @@ public class GLRenderer implements Renderer {
|
|||||||
context.attribIndexList.copyNewToOld();
|
context.attribIndexList.copyNewToOld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private int updateAttributeLocation(Shader shader, VertexBuffer.Type attribType) {
|
private int updateAttributeLocation(Shader shader, VertexBuffer.Type attribType) {
|
||||||
Attribute attrib = shader.getAttribute(attribType);
|
Attribute attrib = shader.getAttribute(attribType);
|
||||||
int loc = attrib.getLocation();
|
int loc = attrib.getLocation();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user