Bug 15371

Summary: Draw untransformed repeating NPOT sources with tiles
Product: xorg Reporter: Owen Taylor <otaylor>
Component: Driver/RadeonAssignee: xf86-video-ati maintainers <xorg-driver-ati>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium CC: leio, revellion
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
The patch
none
Additional patch that hopefully gets things working on R100/R200
none
More R100/R200 fixes
none
Yet further patch of R100/R200 fixups
none
Turn on wrapping when repeating on R100 + R200
none
Radeon: emulate repeats by drawing in tiles
none
Test case (in pycairo)
none
Expected output of test case none

Description Owen Taylor 2008-04-05 14:20:12 UTC
Created attachment 15707 [details] [review]
The patch

When we have a repeating source that's non-power-of-two in a
dimension, we can't turn on wrap for that dimension, but
if we aren't transforming then we can break the destination
area up into tiles, each tile contained completely within
a single copy of the source, and render the tiles one-by-one.

This turns out to make a big difference for the way that cairo
handles horizontal and vertical or gradients, which is to
render a thin strip (POT in the repeating direction, not-necessarily-POT
in the other), then tile it. Not having that as a software
fallback makes my desktop much more usable.
Comment 1 Owen Taylor 2008-04-05 14:22:56 UTC
Ah, one additional comment: the same optimization is made when there
is no mask by the generic EXA code... it actually calls into the
code that would handle a tiled-fill with core X rendering.

This patch is more general by handling the mask. Non-rectangular shapes with gradients are common in many widget themes.
Comment 2 Owen Taylor 2008-04-05 15:41:04 UTC
Created attachment 15709 [details] [review]
Additional patch that hopefully gets things working on R100/R200

In the last patch I didn't know how to conditionalize wrapping
on R100/R200 because there was no code to turn it on at all! 
(Something I fixed for R300 in the patch in bug 14333). I think
this patch corrects that based on the code in radeon_render.c
Comment 3 Owen Taylor 2008-04-06 10:37:42 UTC
Created attachment 15718 [details] [review]
More R100/R200 fixes

Here's another sequential patch:

Further repeat fixes for R100 + R200
 - We need to tile in both directions if either is NPOT
 - It's OK to repeat even if the pixmap is padded
   (pitch > width)

I've also put up a git repo with the three patches here and the
patch they depend upon from bug 15334 in it:

 git://git.fishsoup.net/xf86-video-ati

In the npot-repeat branch.
Comment 4 Owen Taylor 2008-04-06 15:03:37 UTC
Created attachment 15727 [details] [review]
Yet further patch of R100/R200 fixups

 Upon further investigation, matching pitch is actually needed
 for R100 and possibly R200 as well. Add back that test and
 tile if pitch does not match.
Comment 5 Michel Dänzer 2008-04-07 04:17:45 UTC
(In reply to comment #4)
> Upon further investigation, matching pitch is actually needed for R100 and
> possibly R200 as well.

Pretty sure it's necessary on R200 as well - I was writing and testing those tests on an R200 equipped machine.

Also, it might be even better to only flush the 3D cache once after all tiles, if that works.

P.S. I think R5xx and newer can actually handle wrapping with arbitrary dimensions.
Comment 6 Owen Taylor 2008-04-07 07:40:31 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > Upon further investigation, matching pitch is actually needed for R100 and
> > possibly R200 as well.
> 
> Pretty sure it's necessary on R200 as well - I was writing and testing those
> tests on an R200 equipped machine.

Thanks ... I got stumped working with agd5f to figure out why the actual drawing-in-tiles wasn't working on R100 (very strange, must be obvious,
but not clear to me yet) and we never got back to testing on R200.
 
> Also, it might be even better to only flush the 3D cache once after all tiles,
> if that works.

Is there any reason the flush can't be moved to DoneComposite? .. not
just after all the tiles from a single box passed in by exa, but after
all the boxes?

> P.S. I think R5xx and newer can actually handle wrapping with arbitrary
> dimensions.

So I've heard. I'll leave that to someone with the hardware and the interest
to figure out. (Maybe requires going through some other texturing path?
the TX_FORMAT restriction is still in the R5xx docs.)


Comment 7 Michel Dänzer 2008-04-07 09:23:27 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > Also, it might be even better to only flush the 3D cache once after all tiles,
> > if that works.
> 
> Is there any reason the flush can't be moved to DoneComposite?

Good idea, just needs testing.
Comment 8 Owen Taylor 2008-04-14 06:42:48 UTC
Created attachment 15897 [details] [review]
Turn on wrapping when repeating on R100 + R200

 Actually enable repeats for R100 and R200. This corresponds
 to a R300 change made in the patch in:
 http://bugs.freedesktop.org/show_bug.cgi?id=15333

This patch, along with the next one compose my attempt at a final
patch ready to commit. They have been tested on R100 and R300, I'm
pretty confident that they work on R200, R500, but I haven't tested
there.
Comment 9 Owen Taylor 2008-04-14 06:47:32 UTC
Created attachment 15898 [details] [review]
Radeon: emulate repeats by drawing in tiles

 When we can't turn on hardware repeats, because the texture
 is non-power-of-two, or has padding at the ends of lines,
 try to draw the image in multiple tiles rather than falling
 back to software. (We can only do this when there is no
 transform.)
Comment 10 Owen Taylor 2008-04-14 06:49:58 UTC
Created attachment 15899 [details]
Test case (in pycairo)

Here's a test case. It needs to be run with a recent version of cairo
(say 1.6.x to be safe), or cairo will fall back to GetImage/PutImage for 
the repeating source.
Comment 11 Owen Taylor 2008-04-14 06:50:42 UTC
Created attachment 15900 [details]
Expected output of test case
Comment 12 Michel Dänzer 2008-04-17 04:26:39 UTC
Patches picked from your Git repository and pushed.

Unfortunately, moving the cache flush to DoneComposite locks up my RV350...

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.