Bug 6755

Summary: Radeon accelerated UploadToScreen broken
Product: xorg Reporter: Eric Anholt <eric>
Component: Driver/RadeonAssignee: Michel Dänzer <michel>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: high CC: alexdeucher, benh, cardoe, fredrik, mmacleod, pierre-bugzilla, sroland, tilman, zboszor
Version: gitKeywords: patch
Hardware: x86 (IA32)   
OS: FreeBSD   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
Handle tiling in UTS
none
screen shot
none
Patch to not accelerate broken cases
none
Handle tiling and clipping in UTS
none
Change HostDataBlit interface to take dst_pitch_offset and coordinates
none
Change HostDataBlit interface to take dst_pitch_offset and coordinates, take two none

Description Eric Anholt 2006-04-27 08:59:39 UTC
The Radeon UploadToScreen for the DRI seems broken.  Every time Xephyr does a
full repaint, it draws outside of the window (apparently the pitch is wrong). 
If I turn off the DRI, it works fine.

Issues I've noticed with Radeon UTS:
- Rounding of the width is wrong.  Unless it's in padding on the right side of
the pixmap, this will result in bad rendering.
- No need to do coordinate transformation.  That is, unless EXA is behaving
wrongly and handing too-large coordinates to the driver.  That would be an EXA
bug which I should fix (oops).

This is a full build of Xserver, EXA, and ATI driver as of no earlier than
2005-04-25 but the behavior is long-standing.
Comment 1 Michel Dänzer 2006-04-27 20:32:28 UTC
Does this also happen with colour tiling disabled? Looks like UTS doesn't deal
with tiling yet.
Comment 2 Michel Dänzer 2006-04-27 22:21:11 UTC
*** Bug 6740 has been marked as a duplicate of this bug. ***
Comment 3 Michel Dänzer 2006-04-27 22:44:44 UTC
Created attachment 5501 [details] [review]
Handle tiling in UTS

Does this patch fix it?

Also, Eric, I'm not sure what you mean by 'Rounding of the width is wrong' and
'No need to do coordinate transformation', please elaborate.
Comment 4 Pierre Ossman 2006-04-28 04:11:46 UTC
Created attachment 5504 [details]
screen shot

Nope, didn't solve it. But it did change the error a bit. See attached screen
shot.
Comment 5 Benjamin Herrenschmidt 2006-04-28 07:40:39 UTC
Also Michel, there is something that annoys me with the way HDB works at the
moment: We allocate a buffer, we fill the packet command, we call ADVANCE_RING()
and then fill the data... What is causing the buffer to be picked up by the
engine ? ADVANCE_RING() ? In this case, what prevents the card to start the HDB
before we actually write the data to the buffer ? Sounds quite fragile to me ...

I think we should rework the whole HDB interface to also include the copy loop
and maybe throttle internally on the number of in flight buffers (blocking on
interrupts if necessary
Comment 6 Eric Anholt 2006-04-28 09:55:35 UTC
Created attachment 5511 [details] [review]
Patch to not accelerate broken cases

Attached is a patch that fixes the issues noted here, by simply not
accelerating in those cases.  It hurts performance, but it also fixes several X
Test Suite errors along with the real world rendering issues noted here.
Comment 7 Pierre Ossman 2006-04-28 15:22:40 UTC
I can confirm that the last patch avoids the problem areas.
Comment 8 Michel Dänzer 2006-04-28 15:49:32 UTC
(In reply to comment #5)
> We allocate a buffer, we fill the packet command, we call ADVANCE_RING()
> and then fill the data... What is causing the buffer to be picked up by the
> engine ? ADVANCE_RING() ? 

No. The indirect buffer is fired when

* it becomes full; can't happen here because we BEGIN_ACCEL the whole packet
length in the beginning.
* FLUSH_RING() is called, which we don't explicitly (the BlockHandler eventually
does).

I know this is obscure, but there's really no problem. :)
Comment 9 Michel Dänzer 2006-04-28 19:53:16 UTC
Created attachment 5515 [details] [review]
Handle tiling and clipping in UTS

Does this patch work without the workaround?
Comment 10 Pierre Ossman 2006-04-30 03:49:00 UTC
Afraid not. It didn't change anything.
Comment 11 Michel Dänzer 2006-04-30 05:09:04 UTC
Bummer. Roland, any idea what's missing in UploadToScreen/HostDataBlit to
properly deal with tiling?
Comment 12 Roland Scheidegger 2006-04-30 11:06:47 UTC
(In reply to comment #11)
> Bummer. Roland, any idea what's missing in UploadToScreen/HostDataBlit to
> properly deal with tiling?
I'm not too familiar with exa (yet), but since it looks like exa basically deals
with tiling as does xaa, i.e. all pixmaps are still untiled, UTS only really
seems to have a problem if the "destination pixmap" is the front buffer. No idea
if this can happen but I would assume it should affect the whole screen - so I'm
surprised that the original patch (5501) actually changed anything, I think I'm
missing something.
Comment 13 Michel Dänzer 2006-04-30 21:21:26 UTC
Created attachment 5533 [details] [review]
Change HostDataBlit interface to take dst_pitch_offset and coordinates

I suspect the problem is that the HostDataBlit interface still tries to
calculate backwards from just a destination pointer, so I took Eric's advice
and changed it to take dst_pitch_offset and coordinates instead. Does this fix
it? :}
Comment 14 Benjamin Herrenschmidt 2006-05-01 17:03:24 UTC
Hrm... we should fire it at the end of the loop at least and maybe throttle on
the number of indirect buffer we allocate... Right now, if we get to do a lot of
HDB's between 2 block handlers we might exhaust the pool of indirect buffers...
and we sort-of lose the asynchronicity of blits in some cases
Comment 15 Michel Dänzer 2006-05-01 17:32:44 UTC
(In reply to comment #14)
The radeon driver only ever allocates one indirect buffer at a time so far. It
should always get fired in time as commands are queued or the BlockHandler kicks
in. In particular, with HostDataBlit, one indirect buffer gets allocated, filled
and fired per HostDataBlit/HostDataBlitCopyPass pair. When this exhausts all
available indirect buffers, the next allocation just waits until the first one
has been consumed by the hardware.
Comment 16 Michel Dänzer 2006-05-01 22:11:19 UTC
Created attachment 5536 [details] [review]
Change HostDataBlit interface to take dst_pitch_offset and coordinates, take two

Yet another attempt - HostDataParams didn't mask the offset properly. FWIW,
this one seems to work fine here with tiling.
Comment 17 Pierre Ossman 2006-05-02 01:34:49 UTC
The last patch solved the problem. Great work :)
Comment 18 Michel Dänzer 2006-05-02 18:16:24 UTC
Fixed in CVS, thanks for the suggestions Eric and testing Pierre.
Comment 19 Michel Dänzer 2006-05-20 22:39:12 UTC
*** Bug 6976 has been marked as a duplicate of this bug. ***
Comment 20 Bernhard Rosenkraenzer 2006-05-25 03:24:51 UTC
*** Bug 7025 has been marked as a duplicate of this bug. ***
Comment 21 Michel Dänzer 2006-06-07 06:45:48 UTC
*** Bug 7147 has been marked as a duplicate of this bug. ***
Comment 22 Michel Dänzer 2006-06-12 23:31:31 UTC
*** Bug 7201 has been marked as a duplicate of this bug. ***

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.