Bug 92907

Summary: ARB_copy_image breaks recording with obs-studio
Product: Mesa Reporter: hadack
Component: Drivers/Gallium/radeonsiAssignee: Default DRI bug account <dri-devel>
Status: RESOLVED 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: dmesg
output from obs-studio
apitrace showing the issue

Description hadack 2015-11-11 19:11:18 UTC
Created attachment 119567 [details]
dmesg

Recording a desktop window with obs-studio produces only a red image. This has worked before so i did a bisect and it led to f04f13622f3e71bee057d60a6be9c53b92b56cc9 as the first broken commit.
obs-studio displays lots of:

error: glCopyImageSubData failed, glGetError returned 0x502
error: device_copy_texture (GL) failed

I'm running kernel 4.3, xserver 1.18 and mesa and llvm git.
This is on a cape verde card (7750)
Comment 1 hadack 2015-11-11 19:14:45 UTC
Created attachment 119568 [details]
output from obs-studio
Comment 2 Ilia Mirkin 2015-11-11 19:47:10 UTC
I just pushed a patch to fix bug 92860, also related to copy image. Please try with http://cgit.freedesktop.org/mesa/mesa/commit/?id=912babba7bf1abd3caa49f6372d581ae1afe7e84 and see if the issue still happens.
Comment 3 Ilia Mirkin 2015-11-11 20:07:33 UTC
Actually you're getting GL_INVALID_OPERATION, whereas the other issue would cause GL_INVALID_VALUE.

Please record an (ideally small) apitrace of the issue and make it available for analysis.
Comment 4 hadack 2015-11-11 20:25:17 UTC
Created attachment 119569 [details]
apitrace showing the issue

Here is an apitrace when trying to record xfce-panel.
Comment 5 Ilia Mirkin 2015-11-11 20:33:56 UTC
OK, so the issue is coming from

70518 glCopyImageSubData(srcName = 9, srcTarget = GL_TEXTURE_2D, srcLevel = 0, srcX = 0, srcY = 0, srcZ = 0, dstName = 8, dstTarget = GL_TEXTURE_2D, dstLevel = 0, dstX = 0, dstY = 0, dstZ = 0, srcWidth = 1920, srcHeight = 31, srcDepth = 1)

We error out complaining that the internal formats don't match.

Texture 9:

70257 glBindTexture(target = GL_TEXTURE_2D, texture = 9)
70258 glXBindTexImageEXT(display = 0x210df00, drawable = 69206018, buffer = GLX_FRONT_LEFT_EXT, attrib_list = {})
70259 glTexImage2D(target = GL_TEXTURE_2D, level = 0, internalformat = GL_RGB, width = 1920, height = 31, border = 
0, format = GL_RGBA, type = GL_UNSIGNED_BYTE, pixels = blob(238080))

Texture 8:

70244 glBindTexture(target = GL_TEXTURE_2D, texture = 8)
70246 glTexImage2D(target = GL_TEXTURE_2D, level = 0, internalformat = GL_RGBA, width = 1920, height = 31, border =
 0, format = GL_RGBA, type = GL_UNSIGNED_BYTE, pixels = blob(238080))

AFAIK this is illegal [copying between GL_RGB and GL_RGBA internal formats], but I haven't double-checked the ARB_copy_image spec or a full GL spec release (where these things are often updated).
Comment 6 Ilia Mirkin 2015-11-11 20:57:41 UTC
(In reply to Ilia Mirkin from comment #5)
> AFAIK this is illegal [copying between GL_RGB and GL_RGBA internal formats],
> but I haven't double-checked the ARB_copy_image spec or a full GL spec
> release (where these things are often updated).

Looks like the GL spec was slightly updated a bit on top of what GL_ARB_copy_image says. This is the text from GL 4.5, Section 18.3.3 (Copying Between Images):

For the purposes of CopyImageSubData, two internal formats are considered
compatible if any of the following conditions are met:

  • the formats are the same. If the formats are the same but are
    a base internal format, the the implementation’s effective internal
    format (see the end of section 8.5) for each image must be the same.
  • the formats are considered compatible according to the compatibility
    rules used for texture views as defined in section 8.18. In particular,
    if both internal formats are listed in the same entry of table 8.30,
    they are considered compatible
  • one format is compressed and the other is uncompressed and table 18.5
    lists the two formats in the same row.

The compressed bullet doesn't apply, and texture views are only defined for sized formats. Looks like on top of what the ARB_copy_image spec says, we're free to deny copying based on arbitrary rules if a base internal format is used (like GL_RGBA/GL_RGB). But only if the two are the same... if they're not (as is the case in the trace you gave), that's always illegal.

So... I'm gonna go with obs-studio bug.
Comment 7 hadack 2015-11-12 09:58:35 UTC
Ok, thanks. I opened a bug at the obs-studio bugtracker:
https://obsproject.com/mantis/view.php?id=370

btw, issue remains with the patch in comment 2.
Comment 8 Ilia Mirkin 2015-11-12 21:59:12 UTC
Closing this for now. Feel free to reopen should analysis on the obs-studio side disagree with my findings.

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.