Bug 6941

Summary: glxgears: initial rendering weirdness
Product: Mesa Reporter: Tilman Sauerbeck <tilman>
Component: DemosAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: high    
Version: git   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Screenshot
Set initial projection/viewing transform

Description Tilman Sauerbeck 2006-05-17 02:26:02 UTC
When glxgears starts, it seems to display one of the gears in extreme close up.
Resizing the window fixes the problem.
Comment 1 Tilman Sauerbeck 2006-05-17 02:28:14 UTC
Fixed.
Comment 2 Brian Paul 2006-05-18 00:00:00 UTC
I'm not sure changing glxgears.c is the right solution.  glxgears has been
running fine as-is on many drivers for many years.

It may be a driver bug.  Which driver are you using?
Comment 3 Tilman Sauerbeck 2006-05-18 01:51:34 UTC
I'm using the r300 driver.

IIRC it was mentioned on IRC that this behaviour was a bug in glxgears that was
fixed in the monolithic tree. I had a look at that copy but couldn't find the
fix for this specific problem, so I gave it a try myself ;)
Comment 4 Brian Paul 2006-05-18 02:00:49 UTC
OK, so just one of the three gears is the wrong size?  Which one?  Maybe attach
a screenshot?
Comment 5 Tilman Sauerbeck 2006-05-18 02:09:25 UTC
Created attachment 5655 [details]
Screenshot

No, the window just shows a section of the whole scene in closup (the lower
right part of the red gear).
Comment 6 Michel Dänzer 2006-05-18 02:14:56 UTC
Maybe it should be mentioned that this is WM specific to some degree; the best
way to reproduce it that I know of is to run glxgears with no WM running.

Brian, is it supposed to produce correct output without ever calling
glViewport() and friends?

That said, this isn't the fix I remember, which was just to call reshape()
during initialization I think.
Comment 7 Brian Paul 2006-05-18 02:23:39 UTC
Yes Michel, there should be no need to call glViewport during initialization
since the OpenGL spec says that the first time a new rendering context is bound
to a window, the context's viewport and scissor box should be initialized to
match the window size.

This is done in _mesa_make_current():

         if (newCtx->FirstTimeCurrent) {
            /* set initial viewport and scissor size now */
            _mesa_set_viewport(newCtx, 0, 0,
                               drawBuffer->Width, drawBuffer->Height);
	    _mesa_set_scissor(newCtx, 0, 0,
			      drawBuffer->Width, drawBuffer->Height );
            check_context_limits(newCtx);
         }

Tilman, can you set a breakpoint there and see if drawBuffer->Width and Height
are 300 (the initial window size)?
Comment 8 Tilman Sauerbeck 2006-05-18 02:41:42 UTC
Yes, they are both set to 300.
Comment 9 Brian Paul 2006-05-18 02:45:05 UTC
OK, next I'd check that the r300's viewport state is getting set. 
r300UpdateWindow() should be getting called with the 300x300 viewport size prior
to drawing the first frame.
Comment 10 Tilman Sauerbeck 2006-05-18 03:21:07 UTC
r300UpdateWindow() operates just fine. The bug is still present if I hardcode
the 4 VPT values to the ones that are being used when I resize the window (to
fix the rendering issue).
Comment 11 Brian Paul 2006-05-18 04:00:46 UTC
If you take any of the Mesa GLUT demos and comment-out the glViewport call, they
should still render properly, until you resize the window.  Maybe try that and
see if other programs show the problem...
Comment 12 Aapo Tahkola 2006-05-18 04:07:21 UTC
Does it get called at all?
Iv seen various little bugs dealing with window updates happen on r300 in the past.
rmesa->state.depth.scale might also be worth checking.
Comment 13 Brian Paul 2006-05-18 04:10:04 UTC
Created attachment 5661 [details] [review]
Set initial projection/viewing transform

Michel pointed out another possibility to me.  If reshape() isn't getting
called before rendering (maybe because of no window manager to trigger
ConfigureNotify), we won't properly set the projection/viewing transformations.


Try this patch.
Comment 14 Tilman Sauerbeck 2006-05-18 06:40:37 UTC
Aapo: Are you referring to r300UpdateWindow()? Yes, it's getting called.

Brian: Your patch works as well. Actually that's the same I did first, but I
thought calling reshape from the expose event handler was the more correct solution.
Comment 15 Brian Paul 2006-05-18 08:46:01 UTC
It sounds like the real problem is ConfigureNotify isn't always received when
the window first appears (depends on window manager).  Adding a call to
reshape() after init() fixes the problem.

I think we can close this bug now.
Comment 16 Adam Jackson 2009-08-24 12:23:54 UTC
Mass version move, cvs -> git

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.