PDA

View Full Version : A serious Java3D/NVIDIA off-screen rendering bug


Rami Hänninen
04-16-03, 07:30 AM
Dear NVIDIA Linux driver developers.

I would like to report a serious Java3D/NVIDIA off-screen rendering bug.

The bug concerns at least the following software/hardware:

- Geforce4 MX440 graphics card
- RedHat 7.3
- XFree86 4.2.0-8
- Sun JDK 1.4.1_01
- Blackdown Java3D 1.3.1-beta

The bug prevents Java3D off-screen antialias rendering, and causes all such result images to contain only "garbage".

Attached you will find a small Java 'XXX' test program that
demonstrates the problem. The program renders a simple color cube
into a scene antialiased off-screen buffer, and writes the result into
a 'xxx.png' PNG image file.

As an another example, Blackdown own 'OffScreenTest' fails to produce scene antialiased images
even if so requested by sligly modifying the original 'OffScreenTest'
code:

public OffScreenTest ()
{
}

public void init() {
setLayout(new BorderLayout());
/*
GraphicsConfiguration config =
SimpleUniverse.getPreferredConfiguration();
*/
GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();

template.setSceneAntialiasing(template.REQUIRED);

GraphicsConfiguration config =
GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getBestConfiguration(temp late);



This issue has been reported also to Blackdown Java3D developers, but since the problem concerns NVIDIA drivers, I though this might interest NVIDIA driver developers, too. I apologise for this extra posting if this turns out to be a purely Blackdown Java3D issue.

Rami


--------------------

Test environment glxinfo:

name of display: :0.0
display: :0 screen: 0
direct rendering: Yes
server glx vendor string: NVIDIA Corporation
server glx version string: 1.3
server glx extensions:
GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_SGIX_fbconfig,
GLX_SGIX_pbuffer
client glx vendor string: NVIDIA Corporation
client glx version string: 1.3
client glx extensions:
GLX_ARB_get_proc_address, GLX_ARB_multisample, GLX_EXT_visual_info,
GLX_EXT_visual_rating, GLX_EXT_import_context, GLX_SGI_video_sync,
GLX_SGIX_swap_group, GLX_SGIX_swap_barrier, GLX_SGIX_fbconfig,
GLX_SGIX_pbuffer, GLX_NV_float_buffer
GLX extensions:
GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_SGIX_fbconfig,
GLX_SGIX_pbuffer, GLX_ARB_get_proc_address
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce2 MX/AGP/SSE
OpenGL version string: 1.4.0 NVIDIA 41.91
OpenGL extensions:
GL_ARB_imaging, GL_ARB_multitexture, GL_ARB_point_parameters,
GL_ARB_texture_compression, GL_ARB_texture_cube_map,
GL_ARB_texture_env_add, GL_ARB_texture_env_combine,
GL_ARB_texture_env_dot3, GL_ARB_texture_mirrored_repeat,
GL_ARB_transpose_matrix, GL_ARB_vertex_program, GL_ARB_window_pos,
GL_S3_s3tc, GL_EXT_abgr, GL_EXT_bgra, GL_EXT_blend_color,
GL_EXT_blend_minmax, GL_EXT_blend_subtract, GL_EXT_clip_volume_hint,
GL_EXT_compiled_vertex_array, GL_EXT_draw_range_elements,
GL_EXT_fog_coord, GL_EXT_multi_draw_arrays, GL_EXT_packed_pixels,
GL_EXT_paletted_texture, GL_EXT_point_parameters, GL_EXT_rescale_normal,
GL_EXT_secondary_color, GL_EXT_separate_specular_color,
GL_EXT_shared_texture_palette, GL_EXT_stencil_wrap,
GL_EXT_texture_compression_s3tc, GL_EXT_texture_cube_map,
GL_EXT_texture_edge_clamp, GL_EXT_texture_env_add,
GL_EXT_texture_env_combine, GL_EXT_texture_env_dot3,
GL_EXT_texture_filter_anisotropic, GL_EXT_texture_lod,
GL_EXT_texture_lod_bias, GL_EXT_texture_object, GL_EXT_vertex_array,
GL_IBM_texture_mirrored_repeat, GL_KTX_buffer_region, GL_NV_blend_square,
GL_NV_fence, GL_NV_fog_distance, GL_NV_light_max_exponent,
GL_NV_packed_depth_stencil, GL_NV_pixel_data_range, GL_NV_point_sprite,
GL_NV_register_combiners, GL_NV_texgen_reflection,
GL_NV_texture_env_combine4, GL_NV_texture_rectangle,
GL_NV_vertex_array_range, GL_NV_vertex_array_range2, GL_NV_vertex_program,
GL_NV_vertex_program1_1, GL_NVX_ycrcb, GL_SGIS_generate_mipmap,
GL_SGIS_multitexture, GL_SGIS_texture_lod
glu version: 1.3
glu extensions:
GLU_EXT_nurbs_tessellator, GLU_EXT_object_space_tess

visual x bf lv rg d st colorbuffer ax dp st accumbuffer ms cav
id dep cl sp sz l ci b ro r g b a bf th cl r g b a ns b eat
----------------------------------------------------------------------
0x21 16 tc 0 16 0 r y . 5 6 5 0 0 16 0 16 16 16 16 0 0 None
0x22 16 dc 0 16 0 r y . 5 6 5 0 0 16 0 16 16 16 16 0 0 None
0x23 16 tc 0 16 0 r . . 5 6 5 0 0 16 0 16 16 16 16 0 0 None
0x24 16 tc 0 16 0 r y . 5 6 5 0 0 0 0 16 16 16 16 0 0 None
0x25 16 tc 0 16 0 r . . 5 6 5 0 0 0 0 16 16 16 16 0 0 None
0x26 16 dc 0 16 0 r . . 5 6 5 0 0 16 0 16 16 16 16 0 0 None
0x27 16 dc 0 16 0 r y . 5 6 5 0 0 0 0 16 16 16 16 0 0 None
0x28 16 dc 0 16 0 r . . 5 6 5 0 0 0 0 16 16 16 16 0 0 None



---------------------
Test program to test scene antialiased off-screen rendering:


import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.media.j3d.*;
import javax.vecmath.*;

public class XXX extends Canvas3D
{
public XXX(boolean antialias)
{
super(getPreferredGraphicsConfiguration(antialias) ,true);

System.err.println("--- Creating off-screen canvas ---");

Screen3D screen3D = getScreen3D();

/*
screen3D.setSize(1280,1024);
screen3D.setPhysicalScreenWidth(0.36);
screen3D.setPhysicalScreenHeight(0.29);
*/

Canvas3D osc = new Canvas3D(getPreferredGraphicsConfiguration(antiali as));
Screen3D oss = osc.getScreen3D();
screen3D.setSize(oss.getSize());
screen3D.setPhysicalScreenWidth(oss.getPhysicalScr eenWidth());
screen3D.setPhysicalScreenHeight(oss.getPhysicalSc reenHeight());

System.err.println("--- Off-screen canvas done ---");
}

public void preRender()
{
System.err.println("--- Off-screen canvas preRender callback ---");
super.preRender();
}

public void postRender()
{
System.err.println("--- Off-screen canvas postRender callback ---");
super.postRender();

// bImage = getOffScreenBuffer().getImage();
}

public void postSwap()
{
System.err.println("--- Off-screen canvas postSwap callback ---");
super.postSwap();
}

// --------------------------------------------------------------------------

public static void main(String[] args)
{
boolean antialias = (args.length>0) && new Boolean(args[0]).booleanValue();

test(antialias);
}

public static void test(boolean antialias)
{
try
{
System.err.println("--- Off-screen canvas test begins ---");
Canvas3D offScreenCanvas3D = new XXX(antialias);

System.err.println("--- Creating virtual universe ---");
VirtualUniverse virtualUniverse = new VirtualUniverse();
Locale locale = new Locale(virtualUniverse);

BranchGroup viewBG = createBranchGroup();
TransformGroup viewTG = createTransformGroup();
viewBG.addChild(viewTG);

ViewPlatform viewPlatform = createViewPlatform();
viewTG.addChild(viewPlatform);

locale.addBranchGraph(viewBG);

View view = createView();
view.addCanvas3D(offScreenCanvas3D);
view.attachViewPlatform(viewPlatform);

System.err.println("--- Creating view transformation ---");
Transform3D t3d = new Transform3D();
t3d.set(new Vector3d(0,0,2));
viewTG.setTransform(t3d);

System.err.println("--- Configuring view antialiasing ---");
view.setSceneAntialiasingEnable(true);

System.err.println("--- Creating scene graph ---");
locale.addBranchGraph(createSceneGraph());

System.err.println("--- Creating off-screen image buffer ---");
BufferedImage bImage =
new BufferedImage(200,200,BufferedImage.TYPE_INT_ARGB) ;
ImageComponent2D buffer = new ImageComponent2D(bImage.getType(),bImage);
offScreenCanvas3D.setOffScreenBuffer(buffer);

System.err.println("--- Triggering off-screen image rendering ---");
offScreenCanvas3D.renderOffScreenBuffer();

System.err.println("--- Waiting for rendering to complete ---");
offScreenCanvas3D.waitForOffScreenRendering();

System.err.println("--- Writing image ---");
ImageIO.write(buffer.getRenderedImage(),"png",new File("xxx.png"));

System.err.println("--- Off-screen canvas test done ---");
}
catch(Throwable t)
{
t.printStackTrace();
}
}

// --------------------------------------------------------------------------

public static BranchGroup createBranchGroup()
{
BranchGroup bg = new BranchGroup();

bg.setCapability(Group.ALLOW_CHILDREN_READ);
bg.setCapability(Group.ALLOW_CHILDREN_WRITE);
bg.setCapability(Group.ALLOW_CHILDREN_EXTEND);
bg.setCapability(BranchGroup.ALLOW_DETACH);

return bg;
}

public static BranchGroup createSceneGraph()
{
BranchGroup objRoot = new BranchGroup();

Transform3D spin = new Transform3D();
spin.rotZ(Math.PI/4.0d);

TransformGroup objTrans = new TransformGroup(spin);
objRoot.addChild(objTrans);

objTrans.addChild(new ColorCube(0.4));

objRoot.compile();

return objRoot;
}

public static TransformGroup createTransformGroup()
{
TransformGroup tg = new TransformGroup();

tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WR ITE);
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_RE AD);
tg.setCapability(TransformGroup.ALLOW_CHILDREN_WRI TE);
tg.setCapability(TransformGroup.ALLOW_CHILDREN_EXT END);

return tg;
}

public static View createView()
{
View view = new View();

view.setPhysicalBody(new PhysicalBody());
view.setPhysicalEnvironment(new PhysicalEnvironment());

return view;
}

public static ViewPlatform createViewPlatform()
{
ViewPlatform vp = new ViewPlatform();

vp.setCapability(ViewPlatform.ALLOW_POLICY_READ);
vp.setCapability(ViewPlatform.ALLOW_POLICY_WRITE);

return vp;
}

public static GraphicsConfiguration
getPreferredGraphicsConfiguration(boolean antialias)
{
GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();

template.setSceneAntialiasing(antialias ?
template.REQUIRED :
template.UNNECESSARY);

GraphicsConfiguration config =
GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getBestConfiguration(temp late);

return config;
}
}

Andy Mecham
04-16-03, 12:47 PM
Thanks for your report - we're looking into it. You can attach sample programs as files.

--andy