[POLARIS10] VRAM leak involving glTexImage2D with non-NULL data argument
Original Report
Originally reported as an mpv issue here.
Test Case
mpv --no-config \
-dither-depth auto \
-scale ewa_lanczos \
-tone-mapping-param 0.38 \
--input-conf <(echo -e "g add tone-mapping-param -.01\nh add tone-mapping-param +.01") \
$video_file
And pressing gggggghhhhhhggggggggghhhhhhh while the video is playing. The video must be scaled up to make sure the scaler is running.
MPV developer feedback from the original issue:
I think this is a Mesa or driver bug. Somehow it depends on whether you pass a data pointer to glTexImage2D (its last argument).
So with your test case, if you change
params->initial_data
toNULL
here:https://github.com/mpv-player/mpv/blob/bcc921bd2fc6bcd1cf45279a8497b230f8ebc700/video/out/opengl/ra_gl.c#L345 ...the leak goes away. In this case, it affects only the dither texture, so this won't be much visible. Your case doesn't actually change anything with the renderer configuration. But the dither texture is recreated anyway, which seems to leak a lot in VRAM. There don't seem to be any leaks on the mpv level. We definitely destroy the dither texture, for example.
It's notable that completely deinitializing the VO with
_
doesn't free this VRAM memory. This even closes the X connection, so I'd expect Mesa and the driver to free anything it still holds on.We could work this around, but I think it's better if you report this to Mesa instead.
Hardware/Platform Info
OpenGL vendor string: X.Org
OpenGL renderer string: Radeon RX 570 Series (POLARIS10, DRM 3.35.0, 5.4.6-arch3-1, LLVM 9.0.0)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 19.3.1
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile