Bug 8273

Summary: smooth shading and alpha shading mixed up in r300
Product: Mesa Reporter: James C. Georgas <jgeorgas>
Component: Drivers/DRI/r300Assignee: Default DRI bug account <dri-devel>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: high CC: cryos, glisse, jlp.bugs, tehfoo
Version: git   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: jpeg of expected correct rendering
jpeg of incorrect rendering

Description James C. Georgas 2006-09-14 07:08:58 UTC
I've seen this one come and go a couple of times over the past few months.

In the spheremonics screensaver, from xscreensaver-4.24, the surface triangles
are supposed to be smoothly shaded into adjacent triangles.

With DRI turned off, things work as expected (see attachment: right-shading.jpg).

However, with DRI turned on, the triangles are see-through, and the smooth
shading is not done (see attachment: wrong-shading.jpg).

My card is a FireGL X1-128.

I'm running:
  xorg-server-1.1.1
  today's git version of xf86-video-ati
  today's CVS HEAD version of mesa
  today's git versions of the drm modules
  today's git versions of libdrm

james@Rainsong ~ $ uname -a
Linux Rainsong 2.6.18-rc7 #1 SMP PREEMPT Thu Sep 14 08:41:23 EDT 2006 x86_64 AMD
Opteron(tm) Processor 246 GNU/Linux

james@Rainsong ~ $ glxinfo
name of display: :0.0
display: :0  screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.2
server glx extensions:
    GLX_ARB_multisample, GLX_EXT_visual_info, GLX_EXT_visual_rating, 
    GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, GLX_OML_swap_method, 
    GLX_SGI_make_current_read, GLX_SGIS_multisample, GLX_SGIX_hyperpipe, 
    GLX_SGIX_swap_barrier, GLX_SGIX_fbconfig
client glx vendor string: SGI
client glx version string: 1.4
client glx extensions:
    GLX_ARB_get_proc_address, GLX_ARB_multisample, GLX_EXT_import_context, 
    GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_allocate_memory, 
    GLX_MESA_copy_sub_buffer, GLX_MESA_swap_control, 
    GLX_MESA_swap_frame_usage, GLX_OML_swap_method, GLX_OML_sync_control, 
    GLX_SGI_make_current_read, GLX_SGI_swap_control, GLX_SGI_video_sync, 
    GLX_SGIS_multisample, GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, 
    GLX_SGIX_visual_select_group, GLX_EXT_texture_from_pixmap
GLX version: 1.2
GLX extensions:
    GLX_ARB_get_proc_address, GLX_ARB_multisample, GLX_EXT_import_context, 
    GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_swap_control, 
    GLX_MESA_swap_frame_usage, GLX_OML_swap_method, GLX_SGI_video_sync, 
    GLX_SGIS_multisample, GLX_SGIX_fbconfig
OpenGL vendor string: Tungsten Graphics, Inc.
OpenGL renderer string: Mesa DRI R300 20060815 AGP 8x TCL
OpenGL version string: 1.3 Mesa 6.5.1
OpenGL extensions:
    GL_ARB_fragment_program, GL_ARB_imaging, GL_ARB_multisample, 
    GL_ARB_multitexture, GL_ARB_texture_border_clamp, 
    GL_ARB_texture_compression, GL_ARB_texture_cube_map, 
    GL_ARB_texture_env_add, GL_ARB_texture_env_combine, 
    GL_ARB_texture_env_crossbar, GL_ARB_texture_env_dot3, 
    GL_MESAX_texture_float, GL_ARB_texture_mirrored_repeat, 
    GL_ARB_texture_rectangle, GL_ARB_transpose_matrix, 
    GL_ARB_vertex_buffer_object, GL_ARB_vertex_program, GL_ARB_window_pos, 
    GL_EXT_abgr, GL_EXT_bgra, GL_EXT_blend_color, 
    GL_EXT_blend_equation_separate, GL_EXT_blend_func_separate, 
    GL_EXT_blend_minmax, GL_EXT_blend_subtract, GL_EXT_clip_volume_hint, 
    GL_EXT_compiled_vertex_array, GL_EXT_convolution, GL_EXT_copy_texture, 
    GL_EXT_draw_range_elements, GL_EXT_gpu_program_parameters, 
    GL_EXT_histogram, GL_EXT_packed_pixels, GL_EXT_polygon_offset, 
    GL_EXT_rescale_normal, GL_EXT_secondary_color, 
    GL_EXT_separate_specular_color, GL_EXT_stencil_wrap, GL_EXT_subtexture, 
    GL_EXT_texture, GL_EXT_texture3D, 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_bias, GL_EXT_texture_mirror_clamp, 
    GL_EXT_texture_object, GL_EXT_texture_rectangle, GL_EXT_vertex_array, 
    GL_APPLE_packed_pixels, GL_ATI_blend_equation_separate, 
    GL_ATI_texture_env_combine3, GL_ATI_texture_mirror_once, 
    GL_IBM_rasterpos_clip, GL_IBM_texture_mirrored_repeat, 
    GL_INGR_blend_func_separate, GL_MESA_pack_invert, GL_MESA_ycbcr_texture, 
    GL_MESA_window_pos, GL_NV_blend_square, GL_NV_light_max_exponent, 
    GL_NV_texture_rectangle, GL_NV_texgen_reflection, GL_NV_vertex_program, 
    GL_OES_read_format, GL_SGI_color_matrix, GL_SGI_color_table, 
    GL_SGIS_generate_mipmap, GL_SGIS_texture_border_clamp, 
    GL_SGIS_texture_edge_clamp, GL_SGIS_texture_lod

   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
----------------------------------------------------------------------
0x23 24 tc  0 32  0 r  y  .  8  8  8  8  0 24  8  0  0  0  0  0 0 None
0x24 24 tc  0 32  0 r  y  .  8  8  8  8  0 24  0  0  0  0  0  0 0 None
0x25 24 tc  0 32  0 r  y  .  8  8  8  8  0 24  8 16 16 16 16  0 0 Slow
0x26 24 tc  0 32  0 r  y  .  8  8  8  8  0 24  0 16 16 16 16  0 0 Slow
0x27 24 tc  0 32  0 r  .  .  8  8  8  8  0 24  8  0  0  0  0  0 0 None
0x28 24 tc  0 32  0 r  .  .  8  8  8  8  0 24  0  0  0  0  0  0 0 None
0x29 24 tc  0 32  0 r  .  .  8  8  8  8  0 24  8 16 16 16 16  0 0 Slow
0x2a 24 tc  0 32  0 r  .  .  8  8  8  8  0 24  0 16 16 16 16  0 0 Slow
0x2b 24 dc  0 32  0 r  y  .  8  8  8  8  0 24  8  0  0  0  0  0 0 None
0x2c 24 dc  0 32  0 r  y  .  8  8  8  8  0 24  0  0  0  0  0  0 0 None
0x2d 24 dc  0 32  0 r  y  .  8  8  8  8  0 24  8 16 16 16 16  0 0 Slow
0x2e 24 dc  0 32  0 r  y  .  8  8  8  8  0 24  0 16 16 16 16  0 0 Slow
0x2f 24 dc  0 32  0 r  .  .  8  8  8  8  0 24  8  0  0  0  0  0 0 None
0x30 24 dc  0 32  0 r  .  .  8  8  8  8  0 24  0  0  0  0  0  0 0 None
0x31 24 dc  0 32  0 r  .  .  8  8  8  8  0 24  8 16 16 16 16  0 0 Slow
0x32 24 dc  0 32  0 r  .  .  8  8  8  8  0 24  0 16 16 16 16  0 0 Slow
Comment 1 James C. Georgas 2006-09-14 07:10:34 UTC
Created attachment 6976 [details]
jpeg of expected correct rendering

This is how I expected the rendering to be done. Works with software rendering.
Comment 2 James C. Georgas 2006-09-14 07:12:09 UTC
Created attachment 6977 [details]
jpeg of incorrect rendering

This is what I got with direct rendering enabled.
Comment 3 Michel Dänzer 2006-09-14 08:10:27 UTC
I'm seeing this as well.
Comment 4 James C. Georgas 2006-09-14 08:39:33 UTC
I forgot to mention that I patched mesa to disable some software fallbacks for
smooth shading.

There's a comment in r300_render.c that says that the hardware doesn't appear to
support smooth line shading. However, I have seen it work, so I believe that to
be incorrect, at least for my hardware.

Here's the mesa patch, from phoronix's gentoo overlay:

--- Mesa.orig/src/mesa/drivers/dri/r300/r300_render.c
+++ Mesa/src/mesa/drivers/dri/r300/r300_render.c
@@ -397,18 +397,18 @@ int r300Fallback(GLcontext *ctx)
 #endif
 
 	if(!r300->disable_lowimpact_fallback){
-		FALLBACK_IF(ctx->Polygon.OffsetPoint); // GL_POLYGON_OFFSET_POINT
-		FALLBACK_IF(ctx->Polygon.OffsetLine); // GL_POLYGON_OFFSET_LINE
+		//FALLBACK_IF(ctx->Polygon.OffsetPoint); // GL_POLYGON_OFFSET_POINT
+		//FALLBACK_IF(ctx->Polygon.OffsetLine); // GL_POLYGON_OFFSET_LINE
 		//FALLBACK_IF(ctx->Stencil.Enabled); // GL_STENCIL_TEST
 
 		//FALLBACK_IF(ctx->Polygon.SmoothFlag); // GL_POLYGON_SMOOTH disabling to get
blender going
 		FALLBACK_IF(ctx->Polygon.StippleFlag); // GL_POLYGON_STIPPLE
 		FALLBACK_IF(ctx->Multisample.Enabled); // GL_MULTISAMPLE_ARB
 
-		FALLBACK_IF(ctx->Line.StippleFlag);
+		//FALLBACK_IF(ctx->Line.StippleFlag);
 
 		/* HW doesnt appear to directly support these */
-		FALLBACK_IF(ctx->Line.SmoothFlag); // GL_LINE_SMOOTH
+		//FALLBACK_IF(ctx->Line.SmoothFlag); // GL_LINE_SMOOTH
 		FALLBACK_IF(ctx->Point.SmoothFlag); // GL_POINT_SMOOTH
 	}
Comment 5 Jerome Glisse 2006-09-14 08:43:18 UTC
Smooth line haven't yet been implemented in the driver.
Comment 6 James C. Georgas 2006-09-14 08:49:28 UTC
Well something weird is going on then, because it was working for me a couple of
weeks ago, with the fallbacks disabled.

I can't think of any explanation.
Comment 7 James C. Georgas 2006-09-14 08:57:51 UTC
Just to be orthodox, I removed the patch. My mesa now matches the CVS image, and
I am using the "Disable Low-impact fallback" option in driconf to affect the
same change.
Comment 8 James C. Georgas 2006-09-14 09:21:22 UTC
EDIT:

The gentoo portage overlay mentioned earlier was done by primozic of the gentoo
forums, not by phoronix.

The patch mentioned earlier was by FieserKiller of the gentoo forums, and
incorporated by primozic, into his overlay.

Sorry for the mis-attribution.
Comment 9 Jacek Poplawski 2006-09-15 06:52:05 UTC
Where can I read about options like "Disable Low-impact fallback"? Is there any
place with list of all of them?
Comment 10 Rune Petersen 2006-09-15 14:48:14 UTC
If you wan't a list of DRI configuration options for your card
Then driconf will list them along with a short description.

Though a more descriptive list might be in order.
Comment 11 Michel Dänzer 2006-09-18 05:48:04 UTC
(In reply to comment #10)
> Though a more descriptive list might be in order.

If there's anything wrong with the built-in descriptions, I think it would be
much better to fix it than to create a duplicated list.
Comment 12 Marcus D. Hanwell 2008-03-06 22:54:27 UTC
I am observing a very similar behaviour. Using the r300 driver on an X700 in an Acer Ferrari laptop. I could swear I had this working but now smooth shading is broken for triangles and it appears that the colour is not changed for the triangle vertices.

I am working on Avogadro which uses much of this. Tried git as of a few hours ago and still no smooth shading and observing similar artifacts. This is on an amd64 but it looks like it is not dependent upon that.
Comment 13 Maciej Cencora 2009-05-01 18:17:28 UTC
Can you reproduce it on current radeon-rewrite branch of mesa?
It works for me.
Comment 14 Adam Jackson 2009-08-24 12:24:25 UTC
Mass version move, cvs -> git
Comment 15 Maciej Cencora 2009-09-19 02:47:13 UTC
Closing due to lack of user input, also works for me on RV535 and RV380.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.