Bug 94595

Summary: [Mesa AMD&swrast] Texture views attached as framebuffers return their viewed tecture's color encoding and render incorrectly
Product: Mesa Reporter: Edwin Smith (Feral Interactive) <esmith>
Component: Drivers/Gallium/radeonsiAssignee: Default DRI bug account <dri-devel>
Status: VERIFIED FIXED QA Contact: Default DRI bug account <dri-devel>
Severity: normal    
Priority: medium    
Version: git   
Hardware: Other   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: TextureViewFramebufferSRGB Test Sample Code
AMD Mesa Output (Incorrect Behaviour)
Intel Output (Correct Behaviour)
Nvidia Output (Correct Behaviour)
Swrast Output (Incorrect Behaviour)

Description Edwin Smith (Feral Interactive) 2016-03-17 16:33:53 UTC
As seen in the example given, when attaching an SRGB/RGB texture view is created from an alternate RGB/SRGB texture, then attached as a framebuffer, rendering will gamma correct wrongly and querying GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING will return GL_LINEAR for an SRGB backed frame buffer.

This is causing AA renders to be too dark as in our unreleased project, among many other subtle colour issues.

Tested on latest 11.3 (git-9d9965c from oibaf) and seen on older drivers as well.
$ g++ TextureViewFramebufferSRGBTest.cpp.cpp $( sdl2-config --cflags --libs ) -lGL
This reproduces on Mesa AMD and swrast.
Comment 1 Nicolai Hähnle 2016-03-17 17:13:36 UTC
Thanks for the report - did you forget to attach a source file?
Comment 2 Edwin Smith (Feral Interactive) 2016-03-18 09:07:05 UTC
Created attachment 122407 [details]
TextureViewFramebufferSRGB Test Sample Code
Comment 3 Edwin Smith (Feral Interactive) 2016-03-18 09:07:53 UTC
Created attachment 122408 [details]
AMD Mesa Output (Incorrect Behaviour)
Comment 4 Edwin Smith (Feral Interactive) 2016-03-18 09:08:42 UTC
Created attachment 122409 [details]
Intel Output (Correct Behaviour)
Comment 5 Edwin Smith (Feral Interactive) 2016-03-18 09:09:16 UTC
Created attachment 122410 [details]
Nvidia Output (Correct Behaviour)
Comment 6 Edwin Smith (Feral Interactive) 2016-03-18 09:09:42 UTC
Created attachment 122411 [details]
Swrast Output (Incorrect Behaviour)
Comment 7 Nicolai Hähnle 2016-03-18 19:33:36 UTC
Hi Edwin, thanks for following up with the details. I'm going to look into this.
Comment 8 Nicolai Hähnle 2016-03-18 23:14:46 UTC
There is a patch at https://patchwork.freedesktop.org/patch/77510/ which fixes your test case (and should fix format casting with render-to-texture more generally).

Let us know if this fixes your SRGB-related rendering problems.
Comment 9 Nicolai Hähnle 2016-03-22 04:11:07 UTC
Fixed in Mesa master, commit a8b315b8271e867db30650dedb52e53d8dd9667c
Comment 10 Edwin Smith (Feral Interactive) 2016-03-22 09:35:57 UTC
The test case submitted now works as expected using the latest mesa git drivers. Thank you for such a quick fix!

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.