final ByteBuffer buffer = BufferUtils.createByteBuffer(renderBytes + PAGE_SIZE); final int pageOffset = (int)(MemoryUtil.getAddress(buffer) % PAGE_SIZE); buffer.position(PAGE_SIZE - pageOffset); // Aligns to page buffer.limit(buffer.capacity() - pageOffset); // Caps remaining() to renderBytes pinnedBuffers[i] = buffer.slice().order(ByteOrder.nativeOrder()); gl.glBufferData(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, pinnedBuffers[i].remaining(), pinnedBuffers[i], GL_STREAM_READ);
which seems to rely on the physical position of buffer object (the MemoryUtil.getAddress is to native call), but wouldn't it just break if GC happens to move objects around?? I set the offset to be always 0 in my port and it's still working, with no apparent performance penalty
EDIT: I tested ported AMD code - the glBufferData(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD failed with GL_INVALID_ENUM: Invalid binding target, thrown by jogamp.opengl.GLBufferStateTracker.checkTargetName! (but works in LWJGL). I modified GLBufferStateTracker to allow it and now it seems to work fine!
glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY, height * stride, pinnedBuffers[index]);which is non-standard. The last argument (buffer) can be ignored, but they also send the parameter length which only exists in glMapBufferRange. It's said in LWJGL docs the parameter is meant to speed things up, but when I use JOGL's glMapBufferRange(target, offset=0, length, access) it always returns null. The standard glMapBuffer(target, access) works for me however. But why?
Free forum by Nabble | Edit this page |