Bug 98512 - radeon r600 vdpau: Invalid command stream: texture bo too small
Summary: radeon r600 vdpau: Invalid command stream: texture bo too small
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-31 04:49 UTC by jcamp
Modified: 2016-11-07 09:39 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description jcamp 2016-10-31 04:49:49 UTC
Mesa Git Master
Arch Linux
AMD A8-6600K APU

When playing an h264 video using mpv with vdpau hardware decoding over opengl, the video is corrupted and the following error appears in dmesg:

[ 8936.496231] radeon 0000:00:01.0: evergreen_cs_track_validate_texture:854 texture bo too small (layer size 225280, offset 1126400, max layer 2, depth 1, bo size 1351680) (640 176)
[ 8936.496257] [drm:radeon_cs_ioctl [radeon]] *ERROR* Invalid command stream !

If I downgrade mesa to 12.0.3, playback works ok.

Other mpv users have reported the same issue:
https://github.com/mpv-player/mpv/issues/3714
Comment 1 Christian König 2016-10-31 07:57:19 UTC
Clearly a bug in the part of the stack which uses the 3D engine for scaling and color space conversion.

Can you try to bisect? If you don't know how feel free to contact me by mail on christian.koenig@amd.com.
Comment 2 jcamp 2016-10-31 17:48:39 UTC
I'm a newbie at this, so I posted to the mpv bug tracker if anyone there can bisect (https://github.com/mpv-player/mpv/issues/3714).

If no one volunteers soon, then I'll give it a try.
Comment 3 jcamp 2016-11-01 02:03:26 UTC
I followed the Arch Linux wiki on how to git bisect, and here's the result:


e5cc84dd43be066c1dd418e32f5ad258e31a150a is the first bad commit
commit e5cc84dd43be066c1dd418e32f5ad258e31a150a
Author: Brian Paul <brianp@vmware.com>
Date:   Fri Sep 30 16:41:46 2016 -0600

    st/mesa: optimize pipe_sampler_view validation
    
    Before, st_get_texture_sampler_view_from_stobj() did a lot of work to
    check if the texture parameters matched the sampler view (format,
    swizzle, min/max lod, first/last layer, etc).  We did this every time
    we validated the texture state.
    
    Now, we use a ctx->Driver.TexParameter() callback and a couple other
    checks to proactively release texture views when we know that
    view-related parameters have changed.  Then, the validation step is
    simplified:
    - Search the texture's list of sampler views (just match the context).
    - If found, we're done.
    - Else, create a new sampler view.
    
    There will never be old, out-of-date sampler views attached to texture
    objects that we have to test.
    
    Most apps create textures and set the texture parameters once.  This
    make sampler view validation much cheaper for that case.
    
    Note that the old texture/sampler comparison code has been converted
    into a set of assertions to verify that the sampler view is in fact
    consistent with the texture parameters.  This should help to spot any
    potential regressions.
    
    Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
    Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
    Reviewed-by: Marek Olšák <marek.olsak@amd.com>

:040000 040000 33fe9075f262c8bed745dd732cf2047238698d56 194fe6083d5e3155de216a0990d7babb5c49ee8b M	src
Comment 4 Christian König 2016-11-01 09:28:37 UTC
Well done, thanks for that.

Brian, Marek, Nicolai any idea what's causing this?
Comment 5 Nicolai Hähnle 2016-11-03 14:47:17 UTC
This works just fine on radeonsi, so it's likely an r600-specific problem that happened to be uncovered by that commit. Have you tried running with a debug build of Mesa?
Comment 6 Andy Furniss 2016-11-03 14:54:22 UTC
(In reply to Nicolai Hähnle from comment #5)
> This works just fine on radeonsi, so it's likely an r600-specific problem
> that happened to be uncovered by that commit. Have you tried running with a
> debug build of Mesa?

FWIW on si this commit will assert with a debug build, there is also the pre existing issue on si where vdpau hwdec + opengl vo only renders half the lines.

https://bugs.freedesktop.org/show_bug.cgi?id=97988
Comment 7 Christian König 2016-11-03 15:06:20 UTC
Yeah, on SI we don't have a kernel command stream parser to double check those things.

So instead of an error message you probably just get incorrect rendering for maybe one frame or two.
Comment 8 Nicolai Hähnle 2016-11-03 15:26:41 UTC
Hmm, so why don't I see that assertion? Following the linked mpv-player github issue, I'm running

$ mpv --hwdec=auto Videos/Serenity.Trailer.H264.mp4

on a radeonsi debug build just fine. The log on the command line looks just like the one of the reporter of the github issue. What flags am I missing?
Comment 9 Christian König 2016-11-03 15:28:10 UTC
(In reply to Nicolai Hähnle from comment #8)
> What flags am I missing?

Just an educated guess, but try adding "-vo opengl" to the command line.
Comment 10 Andy Furniss 2016-11-03 15:43:53 UTC
(In reply to Nicolai Hähnle from comment #8)
> Hmm, so why don't I see that assertion? Following the linked mpv-player
> github issue, I'm running
> 
> $ mpv --hwdec=auto Videos/Serenity.Trailer.H264.mp4
> 
> on a radeonsi debug build just fine. The log on the command line looks just
> like the one of the reporter of the github issue. What flags am I missing?

It doesn't happen with older mpv, not sure what date it changed.
Comment 11 Nicolai Hähnle 2016-11-03 15:45:04 UTC
The -vo=opengl makes no difference. The one suspicious thing I'm seeing is:

Mesa: User error: GL_INVALID_OPERATION in VDPAUFiniNV

but mpv does call VDPAUInitNV later without error, and shows no other complaints. And I've double-checked that the driver .so's that it loads really are from my debug build, and if I manually add an assertion somewhere in the driver, that does trigger. It's probably something stupid that I'm missing.
Comment 12 Nicolai Hähnle 2016-11-03 15:50:28 UTC
Andy, that's it. With an upgraded mpv, I get the assertion as well. I'm going to look into it.
Comment 13 Nicolai Hähnle 2016-11-03 21:06:58 UTC
I think I understand the problem. https://patchwork.freedesktop.org/patch/119855/ fixes the issue for me, could you please check that it fixes r600 as well?
Comment 14 jcamp 2016-11-07 04:10:49 UTC
(In reply to Nicolai Hähnle from comment #13)
> I think I understand the problem.
> https://patchwork.freedesktop.org/patch/119855/ fixes the issue for me,
> could you please check that it fixes r600 as well?


Confirmed, patch fixes issue for me with AMD A8-6600K APU.
Comment 15 Nicolai Hähnle 2016-11-07 09:39:12 UTC
The fix is in Mesa master, commit 322483f71b068b3bbf69e5434e888f3fd3f4589e


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.