Bug 59492

Summary: piglit dlist-color-material test fail
Product: Mesa Reporter: smoki <smoki00790>
Component: Drivers/DRI/r200Assignee: Default DRI bug account <dri-devel>
Status: NEW --- QA Contact:
Severity: normal    
Priority: medium    
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: swtcl
swtcl
tcl
tcl
proposed patch

Description smoki 2013-01-17 00:40:48 UTC
Piglit test "dlist-color-material" not passed on rv280. That is essential thing, i even tried 7.5.2. and UMS, and no go. Acctualy it seems to me that never worked on tcl_mode=1. So yeah it works with swtcl, but never on tcl.
Comment 1 smoki 2013-01-17 00:54:26 UTC
 So default command like

 glColorMaterial (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE)

 never worked quite right on tcl.
Comment 2 Roland Scheidegger 2013-01-18 00:37:46 UTC
(In reply to comment #1)
>  So default command like
> 
>  glColorMaterial (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE)
> 
>  never worked quite right on tcl.

How did you arrive at this conclusion?
You could try some things (like throwing out the dlist stuff) and see if that improves things. Or figure out if actually all of the subtests don't pass to narrow it down.
Comment 3 smoki 2013-01-18 01:15:25 UTC
Created attachment 73222 [details]
swtcl
Comment 4 smoki 2013-01-18 01:16:42 UTC
Created attachment 73223 [details]
swtcl
Comment 5 smoki 2013-01-18 01:17:35 UTC
Created attachment 73224 [details]
tcl
Comment 6 smoki 2013-01-18 01:18:47 UTC
Created attachment 73226 [details]
tcl
Comment 7 smoki 2013-01-18 01:20:14 UTC
 Supertuxkart game use irlicht engine and ECM_DIFFUSE_AND_AMBIENT command for the material color, which use vertex color for both diffuse and ambient light. That irlicht command is actualy glColorMaterial (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE).

 mb->getMaterial().ColorMaterial = video::ECM_DIFFUSE_AND_AMBIENT;

 http://sourceforge.net/apps/trac/supertuxkart/browser/main/trunk/src/graphics/material_manager.cpp

 And i get this results (see attached pictures) when i use tcl or tcl_mode=0. It get correct lighting with swtcl and incorrect with tcl.
Comment 8 smoki 2013-01-18 15:19:52 UTC
 Fails on ambient light and that check_material hack from r200_state. If i excluded that material check this test passed and supertuxkart get correct colors.
But performance is like swtcl without that check... that need to be fixed somehow
as comment there says ;).
Comment 9 smoki 2013-01-18 15:29:06 UTC
 Also infinite-spot-light piglit test fails because of this, it also pass if i exclude that material check.
Comment 10 Roland Scheidegger 2013-01-18 15:57:31 UTC
(In reply to comment #8)
>  Fails on ambient light and that check_material hack from r200_state. If i
> excluded that material check this test passed and supertuxkart get correct
> colors.
> But performance is like swtcl without that check... that need to be fixed
> somehow
> as comment there says ;).

When you say you excluded the test did you assume always true or always false?
If it works both ways then the fallback itself would cause the trouble (wouldn't be terribly surprising).
I think fixing this to not require a fallback would require quite a bit of work, the wiring necessary is probably ugly. I think not many apps actually change materials inside begin/end.
Comment 11 smoki 2013-01-18 16:33:44 UTC
 
 With always true it pass or opside out, with always false or what is now it fails.

 I think most if not every racing games fail to render correctly because of this, bugs like missing wheels will be there i guess, or loosed color somewhere, etc. Anyway proper lighting is broken there.
Comment 12 Roland Scheidegger 2013-01-18 16:55:04 UTC
Hmm maybe there are bugs in lighting model state somewhere I dunno. But since for this test case the material doesn't actually matter and the wiring looks ok to me (everything wired to vertex color 0) there must be some error elsewhere.
Comment 13 smoki 2013-01-18 23:23:20 UTC
 I agree... will be hard to find what is it, i've now tested 7.5.2, 7.0.3, 6.5.1 mesa - that is oldest i could run, and this never worked :(.
Comment 14 Marek Olšák 2013-01-18 23:53:04 UTC
(In reply to comment #13)
>  I agree... will be hard to find what is it, i've now tested 7.5.2, 7.0.3,
> 6.5.1 mesa - that is oldest i could run, and this never worked :(.

Yes, the test was fixed fairly recently in core Mesa:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1bc16bf98a1b5a4cca0c0ae2a80ba7982c6e4651
Comment 15 smoki 2013-01-19 00:09:33 UTC
 Thanks Marek, i already run these piglit tests with current (today) mesa master and current piglit, they does work and pass but on swtcl only. On tcl they fail, and supertuxkart gives incorrect colors.

 I just go to debian stable to test supertuxkart in hope that with some older UMS mesas somehow i can get correct colors, but nope :(.
Comment 16 smoki 2013-01-19 00:42:21 UTC
 OMG, i managed to fix it somehow :). I put in the end of r200UpdateMaterial function r200ColorMaterial( ctx, 0, 0 ); call and removed it from case GL_COLOR_MATERIAL:

 That fixed supertuxkart colors and dlist-color-material now passed ;).
Comment 17 smoki 2013-01-19 03:00:23 UTC
 Clean mesa up to git-commit 1ec1b577f726a70dd787227260e61928e97474e5

 No regression with piglit quick-driver.tests, just passed dlist-color-material
and fix supertuxkart colors;).
Comment 18 smoki 2013-01-19 04:04:22 UTC
Created attachment 73272 [details] [review]
proposed patch
Comment 19 Roland Scheidegger 2013-01-19 14:35:12 UTC
This looks very fishy to me, I can't see how this could be the right fix (you never know though since apparently some tcl regs have ordering requirements).
Comment 20 smoki 2013-01-20 03:36:12 UTC
 Honestly i don't beleve it is right solution neither (but at least, we are on the right track). I just know that r200ColorMaterial must also somehow in touch with tnl->Driver.NotifyMaterialChange for this to work.

 If i just inited that down in r200InitTnlFuncs that also worked... i know fishies, no way it's proper fix maybe, bla, bla... just idea, but those must be maked in conjuction somehow for this to work;).
Comment 21 smoki 2013-01-23 05:25:28 UTC
 But must say, this patch however worked perfectly here for supertuxkart ;), no issues spotted in any other games i tried these few days. 

 Maybe someone who use r200 driver can test:

 http://supertuxkart.sourceforge.net/Downloads

 0.8 version with or without patch, without patch whole olivermath track have broken colors and lights are broken but not always can be easely spoted. Anyway you can immediately broke lights if do one skid/ding on any single track. With a patch all these lighting/color issues should be fixed.
Comment 22 smoki 2013-01-23 05:56:05 UTC
 And of course dlist-color-material piglit test should pass ;).

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.