Bug 17099

Summary: Selection in a game does not work: RenderMode != GL_RENDER
Product: Mesa Reporter: MM <m_may>
Component: Drivers/DRI/r300Assignee: Default DRI bug account <dri-devel>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: Dieter
Version: 7.1   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: my most recent Xorg.0.log
my most recent xorg.conf
Patch
r300_fallback

Description MM 2008-08-12 14:30:14 UTC
Hi!

My Radeon Xpress 1100 IGP works fine now with the newer versions of the driver (starting with xorg-x11-drv-ati-6.8.0-19.fc9 on Fedora or 6.9 on Ubuntu Intrepid, both amd64), glxgears gives me 1200 FPS instead of 170 now. Great work!

But there is one problem, which seems to be a driver issue: In the game Glest (versions 3.0, 3.1.2, 3.2-beta1) I cannot select anything (clicking on a unit does not work), though the rest of the mouse actions work. The same in glchess, as soon as I go into "3d view". The first time I click somewhere, I see the error "File r300_render.c function r300Fallback line 360 Software fallback:ctx->RenderMode != GL_RENDER".

Any more information I can provide?
Comment 1 Michel Dänzer 2008-08-13 00:33:57 UTC
Yeah, it's likely related to software fallbacks being somewhat busted in the r300 driver. Interestingly, the Mesa progs/samples/select works here though, same for you?
Comment 2 MM 2008-08-13 02:18:44 UTC
No, progs/samples/select gives me the same error.
Comment 3 Michel Dänzer 2008-08-13 02:41:03 UTC
(In reply to comment #2)
> No, progs/samples/select gives me the same error.

Ignore the 'error' output, it just means the driver is 'falling back to software rendering' when the render mode is not GL_RENDER, which is expected.

Do the triangles change colour if you click them with progs/samples/select? If not, which version of Mesa are you using?
Comment 4 Nicolai Hähnle 2008-08-13 02:50:26 UTC
It would be interesting to know whether you're using recent Mesa and DRM git.

Other than that, I believe that chip (Radeon Xpress 1100 IGP) has no TCL unit, so perhaps this is a bug that's specific to NO_TCL mode? Just a thought since I can't verify it right now.
Comment 5 MM 2008-08-13 02:57:14 UTC
The triangles are not changing the colour. On Ubuntu Intrepid I am using Mesa 7.1 rc3 and libdrm2 2.3.1.
Comment 6 MM 2008-09-19 16:51:01 UTC
Still present in the most recent Ubuntu 8.10 (alpha 6) with version 6.9.0+git20080826 of the radeon driver.
Comment 7 MM 2008-10-02 09:21:05 UTC
It seems that I am not the only one with that problem, from the Radeon IRC Logs For 2008-10-02:

"[...]
diogo: hey all, still on mesa 7.2 there are problems with gl:select on blender and wings3
[...]
diogo: just the gl select that makes me unhappy"
Comment 8 MM 2008-10-04 13:39:35 UTC
Maybe this is of interest: When I have compiz enabled, the window of select (from mesademos) looses its borders, as soon as I click on a triangle. Without compiz, this doesn't happen, but still, triangles don't change colour.
Using xserver-xorg-video-radeon 6.9.0+git20081003.f9826a56-0ubuntu2.
Comment 9 MM 2008-10-04 13:48:07 UTC
Created attachment 19372 [details]
my most recent Xorg.0.log
Comment 10 MM 2008-10-04 13:57:52 UTC
Created attachment 19373 [details]
my most recent xorg.conf
Comment 11 MM 2008-10-05 07:09:33 UTC
Maybe this is related to this bug:
https://bugs.freedesktop.org/show_bug.cgi?id=16866
Any way to verify/falsify this?
Comment 12 MM 2008-10-15 12:07:27 UTC
Works on the same installation (Ubuntu 8.10) with the proprietary catalyst 8.10 driver.
Comment 13 Stephane Marchesin 2008-10-16 02:23:10 UTC
Traditionally, the zbuffer layout is different on low end/IGP variants (i.e. those that are TCL-less). That is the case for r100/r200 and that would be consistent with the fact that this bug is only seen on those chips, so I'd wager this geenralizes to r300 as well. Did anyone dig into that possibility ? Basically you'd just need to fix the span code in mesa.
Comment 14 Roland Scheidegger 2008-10-16 06:14:51 UTC
(In reply to comment #13)
> Traditionally, the zbuffer layout is different on low end/IGP variants (i.e.
> those that are TCL-less). That is the case for r100/r200 and that would be
> consistent with the fact that this bug is only seen on those chips, so I'd
> wager this geenralizes to r300 as well. Did anyone dig into that possibility ?
> Basically you'd just need to fix the span code in mesa.
But tile translation should be handled by the chip itself (except there was a bug with the tcl-less r100), by use of the tiling regions. This should work the same no matter what the layout actually is. Unless the surface bits would have different meaning for some r300 based chips or there are some other options with tile configuration...
Comment 15 Stephane Marchesin 2008-10-16 06:47:09 UTC
Created attachment 19691 [details] [review]
Patch

Try this patch.
Comment 16 Roland Scheidegger 2008-10-16 07:13:48 UTC
(In reply to comment #15)
> Created an attachment (id=19691) [details]
> Patch
> 
> Try this patch.

This is already fixed in master. Though I realize now there's actually a bug in the fix there, "screen->chip_family & RADEON_CLASS_R100" will always be false - that should have been "(screen->chip_flags & RADEON_CLASS_MASK) == RADEON_CLASS_R100" (I'll fix this). Anyway, it has the same effect on r300 chips as your patch.
Comment 17 Stephane Marchesin 2008-10-16 07:34:48 UTC
(In reply to comment #16)
> (In reply to comment #15)
> > Created an attachment (id=19691) [details] [details]
> > Patch
> > 
> > Try this patch.
> 
> This is already fixed in master. Though I realize now there's actually a bug in
> the fix there, "screen->chip_family & RADEON_CLASS_R100" will always be false -
> that should have been "(screen->chip_flags & RADEON_CLASS_MASK) ==
> RADEON_CLASS_R100" (I'll fix this). Anyway, it has the same effect on r300
> chips as your patch.
> 

Hmm right I used a stale mesa tree. 

Anyway, surfaces are not magic as you seem to imply. If you put one in front of a piece of memory, it applies the tiling function, whether the buffer is tiled or linear (in which case you scramble the contents). Here is what I think is the problem :
- the (low end) card doesn't tile the zbuffer
- we still setup the tile registers over the zbuffer
- reads are scrambled by the use of a surface. If the surface wasn't there, zbuffer reads would work
Comment 18 Roland Scheidegger 2008-10-16 08:28:41 UTC
(In reply to comment #17)
> Anyway, surfaces are not magic as you seem to imply. If you put one in front of
> a piece of memory, it applies the tiling function, whether the buffer is tiled
> or linear (in which case you scramble the contents). Here is what I think is
> the problem :
> - the (low end) card doesn't tile the zbuffer
> - we still setup the tile registers over the zbuffer
> - reads are scrambled by the use of a surface. If the surface wasn't there,
> zbuffer reads would work
> 

Oh, I didn't want to imply surfaces are magic. But I think only non-tcl r100-class chips don't use tiling for the z buffer.
But if that's indeed some bogus surface setup, you can verify that with mesa's progs/zreaddraw demo, which wouldn't work in this case.
Comment 19 Mihail Zenkov 2008-10-26 17:28:34 UTC
Created attachment 19873 [details] [review]
r300_fallback

R300 fallback to _tnl_render_stage when we have problem with hardware TCL, but it not fallback to _swrastr when we have problem with hardware rasterization. 

Tested on rs740.

Changes with this patch:
1. Add fallback to swrastr like in other radeon/r200
2. Small clean up useless things relation to fallback.
3. Add prefix TCL to things relation with TCL fallback.
4. Exclude useless warning (like in first post) when we don't have hardware TCL.

Not sure what we shall do when we have hardware TCL, but have problem with rasterization. Possibly we shall review current TCL fallback in r300_render.c and do it like in radeon/r200.

Also not sure where hardware supported by r300 have problem and should fallback to swrastr.
Comment 20 Dieter Nützel 2009-01-09 16:38:13 UTC
What about this?

I get the message with Mesa progs/samples/select with and without the patch on r300 (RV350 AS [Radeon 9550]) but colour changes.
Comment 21 Mihail Zenkov 2009-01-26 14:37:32 UTC
>I get the message with Mesa progs/samples/select with and without the patch on
>r300 (RV350 AS [Radeon 9550]) but colour changes.

Wath message? This patch needed only when we have problem with hardware rasterization (RS690/RS740 and possible other IGP).
Comment 22 MM 2009-03-11 06:39:20 UTC
Still there using version 6.11.0-1ubuntu5 on a Ubuntu 9.04 installation, RS482 [Radeon Xpress 200M].
Performance of glxgears has also dropped by factor 3 now, but that is probably another issue, :(
Comment 23 Maciej Cencora 2009-05-08 08:16:44 UTC
I've found out that software rasterizer fallbacks are broken when HW TCL is disabled.
Basically it's because in r300InitSwtcl we plug our custom functions for rendering, and when we hit rasterizer fallback we don't call _swsetup_Wakeup. Also looks like we don't flush when switching between HW<->SW rendering which could lead to rendering errors or maybe even GPU lockups.

I'm reimplementing fallbacks handling on r300 so it should be fixed soon.
Comment 24 Maciej Cencora 2009-05-19 06:27:38 UTC
Fixed since 2240c0d33365189f975b84b06792e2a5ecb8b13a in radeon-rewrite branch.
Closing

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.