AMD Radeon Xorg Screen tearing fix on 18.3 Cinnamon

nmjbhoffmann
  6 years ago
  -1

I've been plagued with screen tearning for a while now since I have to use the XOrg driver, and I finally found a half decent fix for it.
It's not super clean, but it works, (for my AMD Radeon R9 280x at least).

Bascially, Mint is configured to use the radeonsi driver, which by default vsyncs everything, though still has tearing in some apps (in my case, SM Player and Firefox).

The way I got around this was to switch to the direct renderer (dri2), which has vsync also has vsync by default, however, it actually does prevent tearing, and more importantly, you can configure it to disable vsync for specific applications (Like Minecraft and CS:GO) :D.

The fix:
Create or edit the file ~/.drirc     (Yeah, it's a user settings thing, so no scary Xorg.conf nonsense :) )

Add the following: (or if it exists, will explain below what to change)


<driconf>
    <device screen="0" driver="dri2">
        <application name="Default">
            <option name="radeonsi_enable_sisched" value="false" />
            <option name="mesa_no_error" value="false" />
            <option name="mesa_glthread" value="true" />
            <option name="glx_disable_oml_sync_control" value="false" />
            <option name="disable_glsl_line_continuations" value="false" />
            <option name="disable_blend_func_extended" value="false" />
            <option name="disable_shader_bit_encoding" value="false" />
            <option name="glsl_zero_init" value="false" />
            <option name="pp_celshade" value="0" />
            <option name="glx_disable_ext_buffer_age" value="false" />
            <option name="allow_glsl_extension_directive_midshader" value="false" />
            <option name="force_glsl_version" value="0" />
            <option name="force_glsl_abs_sqrt" value="false" />
            <option name="radeonsi_assume_no_z_fights" value="false" />
            <option name="force_glsl_extensions_warn" value="false" />
            <option name="pp_noblue" value="0" />
            <option name="allow_glsl_builtin_variable_redeclaration" value="false" />
            <option name="glsl_correct_derivatives_after_discard" value="false" />
            <option name="pp_jimenezmlaa" value="0" />
            <option name="always_have_depth_buffer" value="false" />
            <option name="pp_jimenezmlaa_color" value="0" />
            <option name="radeonsi_commutative_blend_add" value="false" />
            <option name="pp_nored" value="0" />
            <option name="radeonsi_clear_db_cache_before_clear" value="false" />
            <option name="allow_higher_compat_version" value="false" />
            <option name="pp_nogreen" value="0" />
        </application>

        <application name="Minecraft" executable="java">
            <option name="vblank_mode" value="0" />
        </application>
        <application name="LightDM" executable="lightdm">
            <option name="vblank_mode" value="0" />
        </application>
        <application name="Firefox" executable="firefox">
            <option name="vblank_mode" value="0" />
        </application>
        <application name="GLXgears" executable="glxgears">
            <option name="vblank_mode" value="0" />
        </application>
        <application name="Counter Strike: Global Offensive" executable="csgo_linux64">
            <option name="vblank_mode" value="0" />
        </application>
    </device>
</driconf>


The extra settings in <application name="Default"> were added by driconf (apt install driconf), you don't need to install it, but I didn't want to mess with those settings, you should be able to remove all of them if you want.

There are 3 important things here.
1. <device screen="0" driver="dri2">
    The driver as mentioned is normally set to "radeonsi" instead of "dri2"

2. <option name="vblank_mode" value="0" />
    This disables the vsync for a specific application, so it will be enabled for everything else. You can
    remove all the "<application>" tags, or replace them with whatever apps you want to add settings for.

3. You don't need to restart your pc to see the changes, after saving, just restart the application :D, I used glxgears for testing, since you can see  the framerate in it within a couple seconds to check if vsync actually did get disabled.


I hope this helps someone else, since this took a lot of research on my end to get to this point. Also if you install driconf it will create this file when you open it, though it will always add the radeonsi driver setting the moment you open it, even after you set it to dri2. That said it still seems to use the first section.

Also, from my testing, invalid settings seem to just get ignored, so you should be able to play fairly safely, just keep a backup of the last working version of .drirc just in case, that way, if it breaks you can just drop to tty and remove the file.

You can find more info here https://dri.freedesktop.org/wiki/ConfigurationInfrastructure/