Bug 104272

Summary: [OpenGL CTS] [HSW] KHR-GL46.direct_state_access.textures_compressed_subimage assert fails
Product: Mesa Reporter: Kenneth Graunke <kenneth>
Component: Drivers/DRI/i965Assignee: Intel 3D Bugs Mailing List <intel-3d-bugs>
Status: RESOLVED FIXED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: medium CC: agomez, estea, jmcasanova
Version: git   
Hardware: Other   
OS: All   
See Also: https://bugs.freedesktop.org/show_bug.cgi?id=81843
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 102590    

Description Kenneth Graunke 2017-12-15 01:05:24 UTC
KHR-GL46.direct_state_access.textures_compressed_subimage assert fails on Haswell, and presumably older platforms as well which don't have native ETC support.

intel_mipmap_tree.c:3320: intel_miptree_map_etc: Assertion `map->mode & GL_MAP_WRITE_BIT' failed.
Comment 1 Kenneth Graunke 2017-12-16 03:59:02 UTC
The test does glGetCompressedTexImage() on an ETC texture, which we have never done correctly.  We'd need to implement that properly.
Comment 2 Andrés Gómez García 2018-05-02 12:21:21 UTC
There is a patch proposal waiting for review at:
https://patchwork.freedesktop.org/series/38872/

Kenneth, could you give it a view?
Comment 3 Eleni Maria Stea 2018-05-02 15:38:33 UTC
(In reply to Andrés Gómez García from comment #2)
> There is a patch proposal waiting for review at:
> https://patchwork.freedesktop.org/series/38872/
> 
> Kenneth, could you give it a view?

To add a couple more details, this patch fixes both GetCompressed* functions and an issue with the rendering of ETC2 formats on Gen7 GPUs (tested on HSW, Ivy), you may use this example to easily test both the rendering and the getCompressed functions: https://github.com/hikiko/test-compression (make and ./test compressed_texture)
Comment 4 Marina Chernish 2018-09-06 16:04:47 UTC
This patch cannot be applied on the latest 18.3.0 mesa, but it was successfully applied on 18.1.0 version of mesa and was verified on it.


Test 
MESA_GL_VERSION_OVERRIDE=4.6 ./glcts -n KHR-GL46.direct_state_access.textures_compressed_subimage
passes on mesa-18.1.0 having patch applied
and fails without this patch on the same mesa version.

Environment:
Haswell, Intel® HD Graphics 4600 
CPU: Intel Core i5-4300M 
OS: 16.04.1-Ubuntu
kernel: 4.15.0

Please be aware this patch should be merged carefully on the latest mesa so it has some mismatches in files.
Comment 5 Andrés Gómez García 2018-09-06 21:05:58 UTC
(In reply to Marina Chernish from comment #4)
> This patch cannot be applied on the latest 18.3.0 mesa, but it was
> successfully applied on 18.1.0 version of mesa and was verified on it.

Just commenting in case you are not aware, since patchwork seems to be very confused about the review of this patch.

It has gotten several reviews upt to v6 by now:
https://lists.freedesktop.org/archives/mesa-dev/2018-July/200422.html

But, AFAIK, Nanley and Eleni agreed that it needs to be rewritten from a different approach and Eleni is doing so.

Stay tuned.
Comment 6 Marina Chernish 2018-09-07 09:12:00 UTC
(In reply to Andrés Gómez García from comment #5)
> (In reply to Marina Chernish from comment #4)
> > This patch cannot be applied on the latest 18.3.0 mesa, but it was
> > successfully applied on 18.1.0 version of mesa and was verified on it.
> 
> Just commenting in case you are not aware, since patchwork seems to be very
> confused about the review of this patch.
> 
> It has gotten several reviews upt to v6 by now:
> https://lists.freedesktop.org/archives/mesa-dev/2018-July/200422.html
> 
> But, AFAIK, Nanley and Eleni agreed that it needs to be rewritten from a
> different approach and Eleni is doing so.
> 
> Stay tuned.

Sorry, reviewed email again and found all threads related to discussion of this patch. Thanks for pointing it. First assumption, that it might be a "final" version, was based on the mesa patchwork - there are only 2 versions of this patch now
https://patchwork.freedesktop.org/project/mesa/patches/?submitter=&state=&q=Fix+ETC2%2FEAC+GetCompressed*+functions+on+Gen7+GPUs&archive=&delegate=
Comment 7 Eleni Maria Stea 2018-09-10 11:36:19 UTC
Hello,
I am working on a new series of patches on that, I haven't sent it for review yet.
Comment 8 Nanley Chery 2019-02-16 00:00:59 UTC
This should be fixed by the following commit:

commit d8eb7287fe82e74da8f2938e7190610d3ded0051
Author: Eleni Maria Stea <estea@igalia.com>
Date:   Fri Feb 15 15:29:41 2019 +0200

    i965: Faking the ETC2 compression on Gen < 8 GPUs using two miptrees.
    
    GPUs Gen < 8 cannot sample ETC2 formats. So far, they converted the
    compressed EAC/ETC2 images to non-compressed RGBA images. When
    GetCompressed* functions were called, the pixels were returned in this
    RGBA format and not the compressed format that was expected.
    
    Trying to fix this problem, we use a secondary shadow miptree to store the
    decompressed data for the rendering and the main miptree to store the
    compressed for the Get functions to work. Each time that the main miptree
    is written with compressed data, we decompress them to RGB and update the
    shadow. Then we use the shadow for rendering.
    
    [snip]

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.