PBO read speed ATI vs NVIDIA

Started by MikOfClassX, October 04, 2007, 09:47:22

Previous topic - Next topic

MikOfClassX

Hello,

I noticed that asynchronous pixel reading using the PBO is really slow on ATI (much slower that a simple glReadPixels()) while it's quite fast on NVIDIA. Did anyone experience the same issue ?

Here's my code [takes a screenshot into an existing int_argb image]:

public void screenShot_PBO(BufferedImage image)
{
	IntBuffer buffers = BufferUtils.createIntBuffer(1);
	ARBPixelBufferObject.glGenBuffersARB(buffers);
	int id = buffers.get(0);

	validate();
	GL11.glReadBuffer(GL11.GL_FRONT);
	int sz = getPhysicalWidth() * getPhysicalHeight() * 4;
	ARBPixelBufferObject.glBindBufferARB(ARBPixelBufferObject.GL_PIXEL_PACK_BUFFER_ARB, id);
	ARBPixelBufferObject.glBufferDataARB(ARBPixelBufferObject.GL_PIXEL_PACK_BUFFER_ARB, sz, ARBPixelBufferObject.GL_STREAM_READ_ARB);

	GL11.glReadPixels(0, 0, getPhysicalWidth(), getPhysicalHeight(), EXTBgra.GL_BGRA_EXT, GL11.GL_UNSIGNED_BYTE, 0);

	ByteBuffer mapped_buffer = ARBPixelBufferObject.glMapBufferARB(ARBPixelBufferObject.GL_PIXEL_PACK_BUFFER_ARB, ARBPixelBufferObject.GL_READ_ONLY_ARB, null);

	// the image databuffer
	DataBufferInt db = (DataBufferInt) image.getRaster().getDataBuffer();

	// we have an INT_ARGB image
	int[] pix = ((DataBufferInt) db).getData();

	mapped_buffer.order(ByteOrder.LITTLE_ENDIAN);
	mapped_buffer.asIntBuffer().get(pix);

	ARBPixelBufferObject.glUnmapBufferARB(ARBPixelBufferObject.GL_PIXEL_PACK_BUFFER_ARB);
	ARBPixelBufferObject.glBindBufferARB(ARBPixelBufferObject.GL_PIXEL_PACK_BUFFER_ARB, 0);
	ARBPixelBufferObject.glDeleteBuffersARB(buffers);
}