Bug 1865224 - Avoid invalidating render targets on more Mali GPUs. r=gfx-reviewers,aosmond

We had previously encountered a driver bug on Mali Valhall GPUs where
invalidating render targets once they are no longer required results
in rendering artefacts. This invalidation was purely an optimization,
which probably doesn't help much on Mali architecture anyway, so we
can workaround the bug by skipping the invalidation. See bug 1787520
for details.

The latest Mali Valhall GPUs are also affected. This patch therefore
applies the workaround to *all* "Mali-G" models apart from a list of
known working ones. This means we will avoid hitting this issue again
when the next generation of GPUs are released. Once ARM move on to the
next family we can see whether it is still affected and update the
code accordingly if required.

Differential Revision: https://phabricator.services.mozilla.com/D194063
This commit is contained in:
Jamie Nicol 2023-11-20 17:26:30 +00:00
parent 415dc9403d
commit cf198fa5f7

View File

@ -1413,6 +1413,28 @@ fn parse_mali_version(version_string: &str) -> Option<(u32, u32, u32)> {
Some((v, r, p))
}
/// Returns whether this GPU belongs to the Mali Midgard family
fn is_mali_midgard(renderer_name: &str) -> bool {
renderer_name.starts_with("Mali-T")
}
/// Returns whether this GPU belongs to the Mali Bifrost family
fn is_mali_bifrost(renderer_name: &str) -> bool {
renderer_name == "Mali-G31"
|| renderer_name == "Mali-G51"
|| renderer_name == "Mali-G71"
|| renderer_name == "Mali-G52"
|| renderer_name == "Mali-G72"
|| renderer_name == "Mali-G76"
}
/// Returns whether this GPU belongs to the Mali Valhall family
fn is_mali_valhall(renderer_name: &str) -> bool {
// As new Valhall GPUs may be released in the future we match all Mali-G models, apart from
// Bifrost models (of which we don't expect any new ones to be released)
renderer_name.starts_with("Mali-G") && !is_mali_bifrost(renderer_name)
}
impl Device {
pub fn new(
mut gl: Rc<dyn gl::Gl>,
@ -1732,13 +1754,8 @@ impl Device {
// variety of Mali GPUs. As a precaution avoid doing so on all Midgard and Bifrost GPUs.
// Valhall (eg Mali-Gx7 onwards) appears to be unnaffected. See bug 1691955, bug 1558374,
// and bug 1663355.
let supports_render_target_partial_update = !(renderer_name.starts_with("Mali-T")
|| renderer_name == "Mali-G31"
|| renderer_name == "Mali-G51"
|| renderer_name == "Mali-G71"
|| renderer_name == "Mali-G52"
|| renderer_name == "Mali-G72"
|| renderer_name == "Mali-G76");
let supports_render_target_partial_update =
!is_mali_midgard(&renderer_name) && !is_mali_bifrost(&renderer_name);
let supports_shader_storage_object = match gl.get_type() {
// see https://www.g-truc.net/post-0734.html
@ -1791,7 +1808,7 @@ impl Device {
// On Mali-Txxx devices we have observed crashes during draw calls when rendering
// to an alpha target immediately after using glClear to clear regions of it.
// Using a shader to clear the regions avoids the crash. See bug 1638593.
let supports_alpha_target_clears = !renderer_name.starts_with("Mali-T");
let supports_alpha_target_clears = !is_mali_midgard(&renderer_name);
// On Adreno 4xx devices with older drivers we have seen render tasks to alpha targets have
// no effect unless the target is fully cleared prior to rendering. See bug 1714227.
@ -1818,10 +1835,7 @@ impl Device {
// On Mali Valhall devices with a driver version v1.r36p0 we have seen that invalidating
// render targets can result in image corruption, perhaps due to subsequent reuses of the
// render target not correctly reinitializing them to a valid state. See bug 1787520.
if renderer_name.starts_with("Mali-G77")
|| renderer_name.starts_with("Mali-G78")
|| renderer_name.starts_with("Mali-G710")
{
if is_mali_valhall(&renderer_name) {
match parse_mali_version(&version_string) {
Some(version) if version >= (1, 36, 0) => supports_render_target_invalidate = false,
_ => {}