PBuffers suggestions

After doing some tests both with JOGL and LWJGL I got the impression that the PBuffers support of both libraries is imperfect.

I tested my code on WinXP and the following boards:

  • NVidia 61.72
  • ATI latest drivers
  • Matrox Pathelia latest drivers

From my tests results I see that:

On Matrox PBuffers are not working.

  • JOGL gives “pbuffers not available” (which is not true, as WGL_ARB_pbuffer is there).
  • LWJGL dumps with the following log

[i]

An unexpected error has been detected by HotSpot Virtual Machine:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x02e7be3e, pid=2772, tid=2864

Java VM: Java HotSpot™ Client VM (1.5.0-b64 mixed mode, sharing)

Problematic frame:

C [MTXOGL.DLL+0x1be3e]

--------------- T H R E A D ---------------

Current thread (0x00035a28): JavaThread “main” [_thread_in_native, id=2864]

siginfo: ExceptionCode=0xc0000005, reading address 0x00000000

Registers:
EAX=0x0007f950, EBX=0x00000001, ECX=0x0007f950, EDX=0x00000000
ESP=0x0007f928, EBP=0xfc01076e, ESI=0x00000240, EDI=0x000002d0
EIP=0x02e7be3e, EFLAGS=0x00010202

Top of Stack: (sp=0x0007f928)
0x0007f928: 00000240 02e7bace 00000000 00035ae4
0x0007f938: fc01076e 0005052e 00000001 00000000
0x0007f948: 0000202d 1001ac75 fc010000 00000001
0x0007f958: 000002d0 00000240 00000000 26a79b18
0x0007f968: 26a79b10 00035ae4 0007f9d8 00010000
0x0007f978: 1001ad57 000002d0 00000240 0007f9f0
0x0007f988: 00000000 00000000 26a79b10 00035a28
0x0007f998: 00ad826f 00035ae4 0007f9e0 0007f9fc

Instructions: (pc=0x02e7be3e)
0x02e7be2e: 03 c3 8b 54 24 04 8b c1 56 c6 00 00 c6 40 01 00
0x02e7be3e: 8b 32 85 f6 74 1c 81 fe 33 20 00 00 75 17 8b 4a

Stack: [0x00040000,0x00080000), sp=0x0007f928, free space=254k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [MTXOGL.DLL+0x1be3e]

[error occurred during error reporting, step 120, id 0xc0000005]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j org.lwjgl.opengl.Pbuffer.nCreate(Ljava/nio/ByteBuffer;IILorg/lwjgl/opengl/PixelFormat;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;)V+0
j org.lwjgl.opengl.Pbuffer.createPbuffer(IILorg/lwjgl/opengl/PixelFormat;Lorg/lwjgl/opengl/RenderTexture;)Ljava/nio/ByteBuffer;+21
j org.lwjgl.opengl.Pbuffer.(IILorg/lwjgl/opengl/PixelFormat;Lorg/lwjgl/opengl/RenderTexture;)V+20
j PbufferTest.initialize()V+23
j PbufferTest.execute()V+1
j PbufferTest.main([Ljava/lang/String;)V+27
v ~StubRoutines::call_stub

--------------- P R O C E S S ---------------

Java Threads: ( => current thread )
0x00a6b868 JavaThread “Low Memory Detector” daemon [_thread_blocked, id=2888]
0x00a6a4c8 JavaThread “CompilerThread0” daemon [_thread_blocked, id=2884]
0x00a69728 JavaThread “Signal Dispatcher” daemon [_thread_blocked, id=2880]
0x00a43b60 JavaThread “Finalizer” daemon [_thread_blocked, id=2876]
0x00a66aa0 JavaThread “Reference Handler” daemon [_thread_blocked, id=2872]
=>0x00035a28 JavaThread “main” [_thread_in_native, id=2864]

Other Threads:
0x00a64628 VMThread [id=2868]
0x00a86440 WatcherThread [id=2892]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
def new generation total 576K, used 354K [0x22a70000, 0x22b10000, 0x22f50000)
eden space 512K, 69% used [0x22a70000, 0x22ac89a0, 0x22af0000)
from space 64K, 0% used [0x22af0000, 0x22af0000, 0x22b00000)
to space 64K, 0% used [0x22b00000, 0x22b00000, 0x22b10000)
tenured generation total 1408K, used 0K [0x22f50000, 0x230b0000, 0x26a70000)
the space 1408K, 0% used [0x22f50000, 0x22f50000, 0x22f50200, 0x230b0000)
compacting perm gen total 8192K, used 71K [0x26a70000, 0x27270000, 0x2aa70000)
the space 8192K, 0% used [0x26a70000, 0x26a81ee0, 0x26a82000, 0x27270000)
ro space 8192K, 66% used [0x2aa70000, 0x2afc7960, 0x2afc7a00, 0x2b270000)
rw space 12288K, 46% used [0x2b270000, 0x2b8043a8, 0x2b804400, 0x2be70000)

Dynamic libraries:
0x00400000 - 0x0040c000 C:\Programmi\Java\jdk1.5.0\bin\java.exe
0x7c910000 - 0x7c9c6000 C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c8ff000 C:\WINDOWS\system32\kernel32.dll
0x77f40000 - 0x77feb000 C:\WINDOWS\system32\ADVAPI32.dll
0x77da0000 - 0x77e31000 C:\WINDOWS\system32\RPCRT4.dll
0x77be0000 - 0x77c38000 C:\WINDOWS\system32\MSVCRT.dll
0x6d640000 - 0x6d7c5000 C:\Programmi\Java\jdk1.5.0\jre\bin\client\jvm.dll
0x77d10000 - 0x77da0000 C:\WINDOWS\system32\USER32.dll
0x77e40000 - 0x77e86000 C:\WINDOWS\system32\GDI32.dll
0x76b00000 - 0x76b2e000 C:\WINDOWS\system32\WINMM.dll
0x6d280000 - 0x6d288000 C:\Programmi\Java\jdk1.5.0\jre\bin\hpi.dll
0x76bb0000 - 0x76bbb000 C:\WINDOWS\system32\PSAPI.DLL
0x6d610000 - 0x6d61c000 C:\Programmi\Java\jdk1.5.0\jre\bin\verify.dll
0x6d300000 - 0x6d31d000 C:\Programmi\Java\jdk1.5.0\jre\bin\java.dll
0x6d630000 - 0x6d63f000 C:\Programmi\Java\jdk1.5.0\jre\bin\zip.dll
0x10000000 - 0x10055000 C:\Documents and Settings\Fabio\Desktop\PBUFTEST\lwjgl.dll
0x72210000 - 0x7223b000 C:\WINDOWS\system32\DINPUT.dll
0x5f140000 - 0x5f20c000 C:\WINDOWS\system32\OPENGL32.dll
0x5c8a0000 - 0x5c8c1000 C:\WINDOWS\system32\GLU32.dll
0x736d0000 - 0x73719000 C:\WINDOWS\system32\DDRAW.dll
0x73b30000 - 0x73b36000 C:\WINDOWS\system32\DCIMAN32.dll
0x77bd0000 - 0x77bd8000 C:\WINDOWS\system32\VERSION.dll
0x02e60000 - 0x03159000 C:\WINDOWS\system32\MTXOGL.DLL

VM Arguments:
java_command: PbufferTest

Environment Variables:
JAVA_HOME=C:\Programmi\Java\jdk1.5.0
CLASSPATH=.;“C:\Programmi\Java\jre1.5.0\lib\ext\QTJava.zip”
PATH=C:\Programmi\Java\jdk1.5.0\bin;C:\WINDOWS;C:\WINDOWS\SYSTEM
USERNAME=Fabio
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 15 Model 3 Stepping 4, GenuineIntel

--------------- S Y S T E M ---------------

OS: Windows XP Build 2600 Service Pack 2

CPU:total 2 family 15, cmov, cx8, fxsr, mmx, sse, sse2, ht

Memory: 4k page, physical 1048044k(663816k free), swap 2996460k(2690000k free)

vm_info: Java HotSpot™ Client VM (1.5.0-b64) for windows-x86, built on Sep 15 2004 03:00:31 by “java_re” with MS VC++ 6.0
[/i]

On NVidia, Ati

  • JOGL: PBuffers working OK
  • LWJGL: PBuffers working Ok

On NVidia, Ati (forcing 4x antialiasing from the board’s CPL)

  • JOGL: PBuffers working but not antialiased
  • LWJGL: PBuffers working but not antialiased

The funniest thing is that Java3D 1.3.2 works very well on the three boards and it indeed uses PBuffers and antialiasing as requested.

The simplest suggestion I can give to the JOGL and LWJGL implementors is to take a look at the Java3D sourcecode (canvas3d.c) and take some “inspiration” from the PBuffers initialization code.

Cheers,

Mik

I’m not sure about these issues (antialiasing should be easily fixed, don’t know about Matrox’s problem), but I know I feel kind of disgusted with pbuffers recently. The moment EXT_framebuffer_object goes live, pbuffers will get the hell out of my code…:wink:

Have you tried to specify anti-aliasing when creating the Pbuffer? Maybe the control panel option only forces anti-aliasing on the on-screen contexts.

  • elias

SPASI: I hope to see it fixed asap. Can you tell me more on EXT_framebuffer_object ? Can I render/grab it with translucence ?

ELIAS: what can I do to ask for PBuffers antialiasing with LWJGL ?

Mik

[quote]Can you tell me more on EXT_framebuffer_object ? Can I render/grab it with translucence ?
[/quote]
EXT_framebuffer_object is a new extension (no spec yet) that is the outcome of 2 years of work. Actually, it is part of the notorious super-buffers and, at last, it gives OpenGL render-to-texture functionality without context switching. It’s a much better API, has new functionality (not possible with pbuffers), has room for new optimizations (not possible with pbuffers) and should be much faster from the beginning (no context switching). You can find more info at opengl.org.

[quote]what can I do to ask for PBuffers antialiasing with LWJGL ?
[/quote]
Set a proper value to the samples argument of the PixelFormat you pass to the pbuffer constructor.

Thanks Spasi,

the antialiasing works very well with the PBuffers !
I can grab a 720x576 pbuffer at 80 fps on my P4 3Ghz and an NVidia FX5200. I’m on the right path for the development of my HighSpeed2D lib (I’m trying to replace Java2D from my apps, at least for the framebuffer rendering phase).

I’m on the EXT_framebuffer_object docs. Really interesting, a way better than PBuffers… but when they’ll be implemented ? I think it will take ages to see it at work.

[quote]…but when they’ll be implemented ? I think it will take ages to see it at work.
[/quote]
Pretty soon actually (at least that is my hope). Both ATI and NV have already worked on it for ages, so there’s no apparent reason for big delays. I guess we’ll have to wait and see.

[quote]I guess we’ll have to wait and see.
[/quote]
how can you be so sure ? :slight_smile:

Of course I cannot wait a single day, so I’ll remain on the PBuffers for some time now. The LWJGL API for the PBuffers is quite straighforward so I can concentrate on design more than on the code itself.

Talking to the expert: do you know how to init/use PBuffers without opening an OGL window (i.e. by opening a single invisible window) ?

Anyway my suggestion to the LWJGL/OPENGL developers is still valid: take a look at the Java3D src code.

[quote]how can you be so sure ? :slight_smile:
[/quote]
Because I’ve been following the whole thing for too long! :wink: No, seriously, we can’t be sure about anything OpenGL related nowadays, I’m just a little optimistic on this particular extension.

[quote]The LWJGL API for the PBuffers is quite straighforward so I can concentrate on design more than on the code itself.
[/quote]
Yes it is, but unfortunately a game design is influenced considerably from a pbuffer’s different context and the different GL state it has. Everything would be much simpler with a single context.

[quote]Talking to the expert: do you know how to init/use PBuffers without opening an OGL window (i.e. by opening a single invisible window) ?
[/quote]
Hmm, I’m not sure if LWJGL has support for this (it is OS-specific functionality), Elias or Matzon should be able to answer that.