Bug 93178

Summary: Textures are filled with garbage
Product: Mesa Reporter: Józef Kucia <joseph.kucia>
Component: Drivers/Gallium/radeonsiAssignee: Default DRI bug account <dri-devel>
Status: CLOSED NOTOURBUG QA Contact: Default DRI bug account <dri-devel>
Severity: normal    
Priority: medium    
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Frame 1 rendered on Radeonsi
The expected image to be rendered for frame 1 in the attached apitrace

Description Józef Kucia 2015-11-30 19:21:38 UTC
Created attachment 120218 [details]
Frame 1 rendered on Radeonsi

The following apitrace renders garbage (see the attached screenshot) when replayed on radeonsi. The same apitrace is rendered correctly on nouveau and nvidia. The cause of the problem seems to be textures filled with garbage.

apitrace: https://drive.google.com/file/d/0Bz0HXJUyjAh3Z0Z2SW9tNUJ3bXM/view

OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD CAPE VERDE (DRM 2.43.0, LLVM 3.8.0)
OpenGL core profile version string: 4.1 (Core Profile) Mesa
11.2.0-devel (git-2571a76)
OpenGL core profile shading language version string: 4.10
OpenGL core profile context flags: (none)

AMD Radeon R9 M375

04:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI]
Venus XTX [Radeon HD 8890M / R9 M275X/M375X] (rev ff)
Comment 1 Józef Kucia 2015-11-30 19:25:28 UTC
Created attachment 120219 [details]
The expected image to be rendered for frame 1 in the attached apitrace
Comment 2 Michel Dänzer 2015-12-01 03:28:09 UTC
Replaying the trace on radeonsi generates lots of GL API errors:

Mesa: User error: GL_INVALID_FRAMEBUFFER_OPERATION in glClear(incomplete framebuffer)
Mesa: User error: GL_INVALID_FRAMEBUFFER_OPERATION in glDrawArrays(incomplete framebuffer)
Mesa: 1 similar GL_INVALID_FRAMEBUFFER_OPERATION errors
(repeated several times)

Mesa: User error: GL_INVALID_ENUM in glRenderbufferStorage(internalFormat=GL_SLUMINANCE8)
Mesa: User error: GL_INVALID_ENUM in glRenderbufferStorage(internalFormat=GL_SLUMINANCE8_ALPHA8)

(the first three lines repeated several times again)

I think those errors could explain the incorrect rendering. Which driver was the apitrace captured with? Does the same problem occur when running the application with radeonsi directly?
Comment 3 Józef Kucia 2015-12-01 06:41:04 UTC
(In reply to Michel Dänzer from comment #2)
> Replaying the trace on radeonsi generates lots of GL API errors:
>
> I think those errors could explain the incorrect rendering. Which driver was
> the apitrace captured with? Does the same problem occur when running the
> application with radeonsi directly?

The GL errors should not be related. Those are generated by format support detection code.

This particular apitrace was captured with nouveau. The application generates different GL errors in this part of code when run with radeonsi. However, it exhibits exactly the same problem when run directly. I'll upload another apitrace later.
Comment 4 Józef Kucia 2015-12-01 08:11:48 UTC
https://drive.google.com/file/d/0Bz0HXJUyjAh3ZkFEOHdNVnAyWWM/view

This apitrace was captured with radeonsi. It is not trimmed. The problem appears at 935th frame. The previous frames are rendered correctly.
Comment 5 Nicolai Hähnle 2016-01-26 01:27:55 UTC
This is a game bug.

The game tries to be clever by uploading some of its textures from a different OpenGL context, but never uses any kind of synchronization between the texture upload and the main context, so the texture upload never actually happens. This is a serious programming mistake, and it is merely by chance that this works on other drivers.

For your own purposes, you can work around the game bug in the driver by applying the following patch:

---- SNIP ----
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -105,6 +105,7 @@ static void r600_copy_from_staging_texture(struct pipe_context *ctx, struct r600
        rctx->dma_copy(ctx, dst, transfer->level,
                       transfer->box.x, transfer->box.y, transfer->box.z,
                       src, 0, &sbox);
+       rctx->b.flush(&rctx->b, NULL, 0);
 }
 
 static unsigned r600_texture_get_offset(struct r600_texture *rtex, unsigned level,
---- SNIP ----

However, doing this seriously hurts the performance of games that are programmed properly. I encourage you to forward this message to the developers, telling them they should take a look at Section 5.3.1 of the OpenGL 4.5 (Compatibility Profile) specification, specifically the part about using Finish or FenceSync/WaitSync.
Comment 6 Józef Kucia 2016-03-24 15:21:04 UTC
(In reply to Nicolai Hähnle from comment #5)
> This is a game bug.
 
Thanks for debugging this. I am sorry for reporting invalid bug. This is actually a bug in Wine. For now the workaround is to enable StrictDrawOrdering. I will do more investigation before reporting a bug next time.

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.