Skip to main content

PBuffers issues

24 replies [Last post]
mikofclassx
Offline
Joined: 2003-07-02
Points: 0

Hello J3D team,

I'm experimenting the freshly compiled PBuffers version of Java3D and I'm facing some problems.

1) I cannot construct more than one offscreen canvas with FSAA.: the first offscreen is antialiased while the others are not.

2) I often get an error after creating and destroying a number of "PBuffer" offscreen canvases.
Java 3D ERROR : In Canvas3D : wglCreatePbufferARB FAIL. - Risorse di sistema insufficienti per completare il servizio richiesto. -> (Not enough system resources to complete the requested service).

These could be driver issues.
I'm on a Matrox Parhelia P650 (latest drivers) / Win2k.
I'll try a NVidia 5700 the next days.

Also, is there a way to disable the PBuffer support i.e. with a java3d system property ?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kcr
Offline
Joined: 2004-03-17
Points: 0

After futher digging into this problem, and after fixing a somewhat related problem (Issue 66), we've done all we plan to do for the 1.3.2 release. It turns out that it isn't feasible to implement the automatic destruction of the native off-screen buffer resources (the native Pbuffer). So applications will need to dispose of the off-screen buffer resources by setting the off-screen buffer to null:

Canvas3D.setOffScreenBuffer(null)

Applications that need to run on 1.3.1 or 1.3.2 will need to put this call in a try/catch and ignore the NullPointerException that will result on 1.3.1.

-- Kevin

kcr
Offline
Joined: 2004-03-17
Points: 0

scotthong wrote:
> I have the same issues on the latest experimental Java3D build.

We will check in a fix for this, too. The problem was that the app was requesting a 32-bit Z-buffer which isn't supported by the card, but for which we were returning a software-only pixel format (and then trying to create a Pbuffer using that, which isn't suported). Java 3D will now refuse to create software-only pixel formats.

-- Kevin

scotthong
Offline
Joined: 2006-05-05
Points: 0

Hi Kevin,

"the app was requesting a 32-bit Z-buffer which isn't supported by the card"

The problem is that ,for the same system, under Java3D 1.3.1, 32-bit buffer is supported and working properly with hardware OpenGL acceleration. Why does it fail to get 32bit z-buffer under 1.3.2. Notice that there is no OffScreen pBuffer involved in the process. I can understand that, when creating an OffScreen PBuffer, not all on-screen formats are supported by PBuffer and it make sense in this case.

What concerns me is the inconsistency between 1.3.1 and 1.3.2 to get a GraphicConfiguration when no PBuffer is involved.

Thanks,

-- Scott

kcr
Offline
Joined: 2004-03-17
Points: 0

> "the app was requesting a 32-bit Z-buffer which isn't supported by the card"

Right.

> The problem is that ,for the same system, under Java3D 1.3.1, 32-bit buffer is supported and
> working properly with hardware OpenGL acceleration. Why does it fail to get 32bit z-buffer under 1.3.2.

This was most likely a bug in 1.3.1. On Windows in 1.3.1 we used the generic ChoosePixelFormat rather than the wglChoosePixelFormatARB. ChoosePixelFormat will attempt to return what you asked for, but may return something less than you asked for. My bet is that on 1.3.1 you were really getting a 24-bit Z-buffer even though you asked for 32-bits.

-- Kevin

scotthong
Offline
Joined: 2006-05-05
Points: 0

Hi Kevin,

The following is function to get a Preferred GraphicsConfiguration. Now the question is what does the function "getBestConfiguration()" do! When you pass a desired GraphicsConfigTemplate3D, should this function return the one that's the closest to the one you pass in?

Based on the JavaDoc's definition:
GraphicsConfigTemplate3D().getBestConfiguration()

Returns the "best" configuration possible that passes the criteria defined in the GraphicsConfigTemplate3D.

This is somewhat confusing?

Would you recommend to have a three level fall back to request 32-bit, 24bit and 16-bit z-buffer in that order?

Thanks,

-- Scott

--------------------------------------------------
public static GraphicsConfiguration getPreferredConfiguration() {
GraphicsConfigTemplate3D template = null;
GraphicsConfiguration config = null;
template = new GraphicsConfigTemplate3D();
template.setDepthSize(32);
config = GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getBestConfiguration(template);
if (config == null) {// fail back to default 16 bit Z buffer
template.setDepthSize(16);
config = GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getBestConfiguration(template);
if (config == null) {
template = new GraphicsConfigTemplate3D();
config = GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getBestConfiguration(template);
}
}
return config;
}
-------------------------------------------------------

kcr
Offline
Joined: 2004-03-17
Points: 0

> The following is function to get a Preferred GraphicsConfiguration. Now the question is what does the function "getBestConfiguration()" do!
> When you pass a desired GraphicsConfigTemplate3D, should this function return the one that's the
> closest to the one you pass in?

It's supposed to return a graphics configuration that meets or exceeds the requested values. If more than one configuration matches the specified criteria, then the one with the largest number of bits is returned. So in your case, if the only thing you are varying is depthSize, then you should just request 16 and you will get a configuration with the largest depth-size available, as long as there is at least one configuration with at least 16 bits (else you will get null). In other words, your function is more complicated than it needs to be for no additional benefit.

-- Kevin

scotthong
Offline
Joined: 2006-05-05
Points: 0

Hi Kevin,

Thanks for the clarification.

The reason that this function is more complicated than it has to be is because of MacOSX. After playing with Mac's Java3D implementation, the only way to get the highest available z-buffer depth is to implement the fall-back function like the one posted.

There are other issues with Mac's Java3D implementation and there seems to be no way other than file a bug report on Apple's website!

Thanks,

-- Scott

mikofclassx
Offline
Joined: 2003-07-02
Points: 0

Hi Kevin,

I tried the new version with Canvas.setOffScreen(null) but things did not change. Of couse I modified my src to force the cleanup. I also enabled the debug printfs to verify that the PBuffers are never destroyed.

Another problem is the FSAA, which is used only on the very first offscreen. Subsequent offscreen allocations return a non-FSAA canvas.

kcr
Offline
Joined: 2004-03-17
Points: 0

> I tried the new version with Canvas.setOffScreen(null) but things did not change.
> Of couse I modified my src to force the cleanup. I also enabled the debug printfs to
> verify that the PBuffers are never destroyed.

Did you call setOffScreenBuffer while the off-screen Canvas3D was still attached to a live universe? If not, then it won't have any effect.

Btw, I noticed the following error in your cleanup code in one of your earlier messages.

for (int i=0; i< view.numCanvas3Ds(); i++) {
view.removeCanvas3D(i);
}

This will only remove half of the Canvas3Ds from the view. After removing the element at index 0, all other array elements will be shifted down by 1 and the count of the number of canvases will be decremented.

> Another problem is the FSAA, which is used only on
> the very first offscreen. Subsequent offscreen
> allocations return a non-FSAA canvas.

This may be a limitation of the card. What card are you using?

-- Kevin

mikofclassx
Offline
Joined: 2003-07-02
Points: 0

Yes, the canvas removing code was surely buggy (poor me).

I can confirm you that calling the setOffScreenBuffer(null) before detaching makes the PBuffers go away. That's good for me. Thanks for the hint. I think everyone should be aware of it.

Anyway I think that calling setOffScreenBuffer(null) is not a real solution as:
1) it's not backwards compatible (j3d 1.3.1 gives a NullPointer exception).
2) one expects that the canvas3d resources are automatically freed up when they're no nonger required (i.e. setting canvas=null and letting the GC do his work). Maybe a silly suggestion: the Java3D system could free/reallocate PBuffers when needed, i.e. free them when detached and reallocate when attached. I don't think this would cause a big overhead. This would give some "automagic" handling of PBuffers allocation.

For the "board" side, I'm using a Matrox P650 and the FSAA problem is almost surely a driver issue. I tried to run two instances of the same application: the first one has FSAA, the second has not.

Mik
--

Message was edited by: MikOfClassX

kcr
Offline
Joined: 2004-03-17
Points: 0

> Anyway I think that calling setOffScreenBuffer(null) is not a real solution as:
> 1) it's not backwards compatible (j3d 1.3.1 gives a NullPointer exception).

This difference could be handled with a try/catch since the 1.3.1 version throws an immediate NPE with no side effects when a null ImageComponent2D is passed in (i.e., the state of the Canvas3D isn't changed).

> 2) one expects that the canvas3d resources are automatically freed up when they're
> no nonger required (i.e. setting canvas=null and letting the GC do his work).

In Java, there is no robust way to do this, since as you know, finalize is not guaranteed to be called. However, I like your next suggestion.

> Maybe a silly suggestion: the Java3D system could free/reallocate PBuffers when
> needed, i.e. free them when detached and reallocate when attached. I don't think this
> would cause a big overhead. This would give some "automagic" handling of PBuffers
> allocation.

Assuming that this is practical to implement, I think it makes sense to destroy the resource when the Canvas3D is removed from the view and reallocate it if/when it is added back in. We will at least look at it. No guarantees, though, for this release.

-- Kevin

mikofclassx
Offline
Joined: 2003-07-02
Points: 0

Thanks Kevin,

By this time I have implemented the "j3d.transparentOffScreen" property. sadly I couldn't manage to commit it to the CVS. Plase take a look into your mailbox for details.

Cheers,

Mik
--

jada
Offline
Joined: 2004-03-17
Points: 0

Mik,
Sorry of my typo and wasn't clear in my first question.
What I want to know is that the j3d build you used in your testing, has it been modified to include the suggestion you have mentioned in the "J3D Memory problems" thread.
Debugging someone's entire application really scare me. :-) I would rather not if possible, plus I can't wait to start on issue 24 : Sound is broken in Java 3D 1.3.2. We need this clear for Java 3D 1.3.2 release.

cheers,
Chien.

mikofclassx
Offline
Joined: 2003-07-02
Points: 0

Chien,

I have some more details of the issue. I'm using the plain latest java3d version from the CVS on an ATI mobility 9200 (winxp) and on a Matrox P650 (win2k). I'm facing the same low-resources problem on both system:

--
Couldn't register class
Couldn't register class
Java3D ERROR : In Canvas3D : wglCreatePBufferARB FAIL. - Insufficient system resources.
--

This happens when I open several offscreens. It does not happen on the previous version without PBuffer support.

Looks like PBuffer resources are limited (maybe it simply means that I'm running out of GFX mem). Anyway java3d could simply fall back to non-PBuffers when the resources are insufficient.

Also, a j3d.dontUsePBuffers property could help in case of buggy driver PBuffer implementation.

Cheers,

Mik

jada
Offline
Joined: 2004-03-17
Points: 0

Thanks for the feedback. We will need more informantion from your systems. We are instrumenting a debug build both you.

thanks,
Chien.

scotthong
Offline
Joined: 2006-05-05
Points: 0

Hi Java3D Team:

I have the same issues on the latest experimental Java3D build.

Video Card: ATI 9600 Pro
Driver Version: Catalyst : 4.6 WHQL Certified

Error Messages
-------------------------------------------------------
1.3.2-pre8-0410181151-experimental 18 Oct 2004 11:51:01 PDT
Couldn't register class
Java 3D ERROR : In Canvas3D : wglCreatePbufferARB FAIL. - Insufficie
nt system resources exist to complete the requested service.

Java 3D ERROR : In Canvas3D : wglCreatePbufferARB FAIL. - Insufficie
nt system resources exist to complete the requested service.
------------------------------------------------

-- Scott

kcr
Offline
Joined: 2004-03-17
Points: 0

Scott & Mik:

We're trying to track down the problem. Would each of you be able to try out your application using a debug build that I put up on java.net?

Here is the pointer:

https://j3d-core.dev.java.net/servlets/ProjectDocumentList

It is in the "Debug Builds" folder and is named java3d-1_3_2-pre8-0410191032-windows-i586.jar

Please send us the complete error log when running your application against this build. Thanks!

-- Kevin

mikofclassx
Offline
Joined: 2003-07-02
Points: 0

Hi Kevin, here's the log.

----

AWTPATH C:\Programmi\Java\jre1.5.0\bin\jawt.dll
Java 3D [dev] 1.3.2-pre8-0410191032-experimental 19 Oct 2004 10:32:00 PDT

Initializing Java 3D runtime system:
version = 1.3.2-pre8-0410191032-experimental 19 Oct 2004 10:32:00 PDT
vendor = Sun Microsystems, Inc.
specification.version = 1.3
specification.vendor = Sun Microsystems, Inc.

Java 3D system initialized
graphics library = Windows OpenGL
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x1, hdc = 0x33010827
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 120, height 120
Successfully created PBuffer = 0x5, hdc = 0x1801082a
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x9, hdc = 0x1401082b
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 120, height 120
Successfully created PBuffer = 0xd, hdc = 0x4c010829
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x11, hdc = 0xf010825
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 120, height 120
Successfully created PBuffer = 0x15, hdc = 0xeb010826
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x19, hdc = 0xc801082e
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 120, height 120
Successfully created PBuffer = 0x1d, hdc = 0x9701082f
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x21, hdc = 0x5b010837
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 120, height 120
Successfully created PBuffer = 0x25, hdc = 0xf501082d
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x29, hdc = 0xcc01083c
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 120, height 120
Successfully created PBuffer = 0x2d, hdc = 0x13010842
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x31, hdc = 0x4e010843
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 120, height 120
Successfully created PBuffer = 0x35, hdc = 0x92010841
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x39, hdc = 0xdb01083e
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 120, height 120
Successfully created PBuffer = 0x3d, hdc = 0x46010844
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 149, height 394
Successfully created PBuffer = 0x41, hdc = 0xaf010847
Canvas3D_destroyOffScreenBuffer : offScreenBufferInfo 0x7ee4f40
Canvas3D_destroyOffScreenBuffer : Pbuffer
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 232, height 394
Successfully created PBuffer = 0x41, hdc = 0xbb010847
Canvas3D_destroyOffScreenBuffer : offScreenBufferInfo 0x7ee4f70
Canvas3D_destroyOffScreenBuffer : Pbuffer
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 328, height 394
Successfully created PBuffer = 0x41, hdc = 0xb401084c
Canvas3D_destroyOffScreenBuffer : offScreenBufferInfo 0xd646480
Canvas3D_destroyOffScreenBuffer : Pbuffer
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 172, height 394
Successfully created PBuffer = 0x41, hdc = 0xc101084c
Canvas3D_destroyOffScreenBuffer : offScreenBufferInfo 0x7fc93f8
Canvas3D_destroyOffScreenBuffer : Pbuffer
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 185, height 394
Successfully created PBuffer = 0x41, hdc = 0x4010850
Canvas3D_destroyOffScreenBuffer : offScreenBufferInfo 0xd66bf88
Canvas3D_destroyOffScreenBuffer : Pbuffer
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 133, height 394
Successfully created PBuffer = 0x41, hdc = 0x12010850
Canvas3D_destroyOffScreenBuffer : offScreenBufferInfo 0x620dfc60
Canvas3D_destroyOffScreenBuffer : Pbuffer
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 107, height 422
Successfully created PBuffer = 0x41, hdc = 0xa6010847
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x45, hdc = 0x83010851
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 120, height 120
Successfully created PBuffer = 0x49, hdc = 0xa701084f
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x4d, hdc = 0xb7010839
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 120, height 120
Successfully created PBuffer = 0x51, hdc = 0xfa01084d
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x55, hdc = 0x3a01084c
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 120, height 120
Successfully created PBuffer = 0x59, hdc = 0x1201083d
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x5d, hdc = 0xa701084a
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 120, height 120
Successfully created PBuffer = 0x61, hdc = 0x12010854
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x65, hdc = 0x3e010855
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 240, height 240
Successfully created PBuffer = 0x69, hdc = 0xd5010850
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x6d, hdc = 0xa010857
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 240, height 240
Successfully created PBuffer = 0x71, hdc = 0x72010852
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x75, hdc = 0xc7010853
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 240, height 240
Successfully created PBuffer = 0x79, hdc = 0x2901085a
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x7d, hdc = 0x1001085b
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 240, height 240
Successfully created PBuffer = 0x81, hdc = 0x89010858
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x85, hdc = 0x4701085c
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 240, height 240
Successfully created PBuffer = 0x89, hdc = 0x2001085e
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x8d, hdc = 0x7001083f
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 240, height 240
Java 3D ERROR : In Canvas3D : wglCreatePbufferARB FAIL. - Risorse di sistema ins
ufficienti per completare il servizio richiesto.

****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x91, hdc = 0x1001084e
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 240, height 240
Java 3D ERROR : In Canvas3D : wglCreatePbufferARB FAIL. - Risorse di sistema ins
ufficienti per completare il servizio richiesto.

****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 1, height 1
Successfully created PBuffer = 0x95, hdc = 0x14010856
****** CreateOffScreenBuffer ******
display 0x0, pFormat 2, width 240, height 240
Java 3D ERROR : In Canvas3D : wglCreatePbufferARB FAIL. - Risorse di sistema ins
ufficienti per completare il servizio richiesto.

mikofclassx
Offline
Joined: 2003-07-02
Points: 0

Addemdum:

from the log it seems that we almost never destroy offscreens. Browsing the Canvas3D source I discovered that the canvas is destroyed on removeCTX() mainly when the canvas is resized or when the parent frame goes away (removeNotify()).

Our application creates a new scene each time the user changes the canvas size. Before creating the new canvas we use the following code to cleanup the resources:

--

if (universe != null)
{
// clear universe resources
universe.removeAllLocales();
universe.getViewingPlatform().detach();

// remove all canvas3Ds
View view = universe.getViewer().getView();
for (int i=0; i< view.numCanvas3Ds(); i++)
{
view.removeCanvas3D(i);
}

universe = null;
}

--

Cheers,

Mik

kcr
Offline
Joined: 2004-03-17
Points: 0

Hi Mik,

Yes, we came to this same conclusion yesterday. I am just about to checkin a fix that will destroy a pbuffer when the offscreen buffer is set to null (i.e., Canvas3D.setOffScreenBuffer(null)). This will allow applications that are done with a particular off-screen Canvas3D to ensure that the resources are freed.

-- Kevin

mikofclassx
Offline
Joined: 2003-07-02
Points: 0

Hi Kevin,

this is a nice solution. I was thinking about the same.. mental contact it seems!

Anyway it is a quick fix that does not explain me why the previuous non-PBuffers version worked OK. I'll be forced to make my own offscreen cleanups..

Why don't you simply free up the offscreens when the canvas is no longer used. Maybe we would need something like .reclaimMemory() in the Universe. Just an idea (that conflicts with the JCP, ok, I know..).

jada
Offline
Joined: 2004-03-17
Points: 0

Mik,
I've a couple questions :
1) Did you include the changes you have commentioned, in the OOM thread, in your build ?
2) Do you have a test program for problems ?
3) There isn't a system property for disabling PBuffer support. Is there a good reason to have one ? If you need it for debugging only you can shortcircuit the logic in function newPixelFormatInfo inside NativeConfigTemplate.c.

thanks,
Chien.

mikofclassx
Offline
Joined: 2003-07-02
Points: 0

1) No. What's the OOM thread ?
2) Not a simple one: I have an entire application that uses offscreens almost everywhere. It worked without pbuffers btw. I can put it on a FTP server if you want.
3) OK, I'll do it.

Mik

mikofclassx
Offline
Joined: 2003-07-02
Points: 0

1) silly me, you mean that I have to submit the changes I did to the original src, isn't it ?