Bug 16452

Summary: Mipmap texture filtering broken on RS690
Product: Mesa Reporter: Maciej Cencora <m.cencora>
Component: Drivers/DRI/r300Assignee: Default DRI bug account <dri-devel>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: git   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: screenshot1
screenshot2
updated drm texture tiling patch
updated texture tiling patch for mesa
Override pitch alignment in textures to 64 bytes
piglit results

Description Maciej Cencora 2008-06-21 02:41:16 UTC
Created attachment 17279 [details]
screenshot1

mipmap texture filtering is broken on my rs690. it looks like only last mipmaps (the smallest) are wrong. If had to guess what's the problem, I would say it's uploading of small textures.
Comment 1 Maciej Cencora 2008-06-21 02:41:56 UTC
Created attachment 17280 [details]
screenshot2
Comment 2 Nicolai Hähnle 2008-06-21 06:17:02 UTC
The screenshot is from anisotropictest, http://steinsoft.net/index.php?site=Programming/Projects/OpenGL/anisotropictest

I cannot reproduce this with current Git and my R420 (X800 Pro), but obviously there's a problem here.

Uploading small textures seems like a good initial guess. Does anybody know of differences in the texture filtering on that hardware? Also, could you test programs that use small textures to begin with, without mipmapping? For example, start with Mesa's crossbar test and change the texture sizes by editing the code starting at line 246. There are four calls

   glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0,
                 GL_RGBA, GL_UNSIGNED_BYTE, temp );

The first 8 is the texture width, the second 8 is the texture height. Try with the original size first, and if this works, try with successively smaller sizes and see if it fails. This would point towards small texture memory layout as the culprit. I'd be kind of surprised by that, but then we all know the RS690 is a bit weird ;)

If this does not fail, then who knows... I can't think of anything right now.
Comment 3 Maciej Cencora 2008-06-21 07:20:09 UTC
I checked mesa crossbar tests, and 8x8 textures are broken. Bigger textures are good
Comment 4 Alex Deucher 2008-06-21 08:07:25 UTC
IIRC, RS4xx/RS6xx IGP chips require tiling for small textures.  The patch in bug 8056 fixes the issue I think.
Comment 5 Maciej Cencora 2008-06-21 09:55:28 UTC
(In reply to comment #4)
> IIRC, RS4xx/RS6xx IGP chips require tiling for small textures.  The patch in
> bug 8056 fixes the issue I think.
> 

Probably, but it doesn't apply anymore.

I checked before only square textures. If it's any help here are results for all POT textures from 1x1 up to 64x64 (all RGBA)

Textures that are broken:
1x2, 1x4, 1x8, 1x16, 1x32, 1x64
2x2, 2x4, 2x8, 2x16, 2x32, 2x64
4x2, 4x4, 4x8, 4x16, 4x32, 4x64
8x8, 8x16, 8x32, 8x64
Comment 6 Alex Deucher 2008-06-22 21:23:13 UTC
Created attachment 17311 [details] [review]
updated drm texture tiling patch

Updated texture tiling patch for the drm from bug 8056 (untested).
Comment 7 Alex Deucher 2008-06-22 21:24:20 UTC
Created attachment 17312 [details] [review]
updated texture tiling patch for mesa

Updated mesa texture tiling patch from bug 8056 (untested).
Comment 8 Nicolai Hähnle 2008-06-23 04:41:01 UTC
Created attachment 17320 [details] [review]
Override pitch alignment in textures to 64 bytes

Except for the fact that you're saying 8x2 and 8x4 is okay, this also looks like the required alignment for textures is different on RS690.

It would be interesting if you could try the attached patch, independently from the texture tiling patches. The attached patch makes the alignment *larger* (to 64 bytes), but you might also want to try making the alignment *smaller* (to 16 bytes) by changing the 63 to a 15 and the 0x3f to 0x0f.

[Of course, the attached patch is incorrect for normal R300/R500 texture engines, but if it works we've learnt something and we can then add an appropriate case switch to the driver; yes, in the long run, enabling texture tiling is better, but it's always nice to have the simpler fallback working as well.]
Comment 9 Maciej Cencora 2008-06-24 05:58:32 UTC
Alex: those tiling patches helps a LOT, but don't fix the problem completely. Small textures are still broken.

Nicolai: your patch doesn't help at all.
Comment 10 Nicolai Hähnle 2008-06-24 09:44:46 UTC
So we'll definitely have to work on texture tiling. It's quite possible that those patches aren't 100% correct or, if we're particularly unlucky, that there is a subtle difference in how tiling works.

One final thing that I'd be curious about is (only if you have the time) a summary of a piglit run (./piglit-run.py tests/r300.tests results-dir) on RS690. I expect that many tests should fail because of the small-texture problem, but I don't think there's an explicit small-texture test. Perhaps I should write one....
Comment 11 Alex Deucher 2008-06-24 10:05:50 UTC
I'll see if I can find anything special for IGP chips.  Tiling should be pretty straight forward, see chapter 2 of the r5xx acceleration guide.  The tiling info there is relevant to previous chips as well.
Comment 12 Maciej Cencora 2008-06-25 05:35:12 UTC
Created attachment 17375 [details]
piglit results

Nicolai: unfortunately my machine soft locks during texcombine test. I uploaded partial results.
Comment 13 Maciej Cencora 2009-05-04 15:22:09 UTC
Fix commited to radeon-rewrite branch - 0b22615c2c860968a027c04519e25864ae69f6cd
Comment 14 Adam Jackson 2009-08-24 12:30:27 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.