mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-14 08:50:35 +02:00
Add an optimization pass to promote constants loaded in the shader to dedicated uniform registers preloaded before the shader. This is beneficial for two reasons: * fewer mov_imm instructions * less GPR pressure (uniforms have dedicated registers) The latter can significantly improve occupancy since we don't remat constants for occupancy. We do remat to avoid spilling so it won't affect spilling, although it can still be a win by reducing remat when a shader would otherwise spill. The problem is that we have limited uniform registers so can't promote everything that we would want to. We model this as a 0-1 knapsack problem and use the well-known heuristic to prioritize frequently used constants. This is not optimal but works quite well in practice. This gives a nice fps win in some complex shaders, including: * Dolphin ubers from 10.25fps to 10.85fps at 4K in MMG. * "Wall and chimney" shadertoy from 24.8fps to 29.5fps at 1188x658. shader-db results are excellent as well. total instructions in shared programs: 2088290 -> 2039709 (-2.33%) instructions in affected programs: 1478061 -> 1429480 (-3.29%) helped: 8246 HURT: 85 Instructions are helped. total bytes in shared programs: 14321004 -> 14111800 (-1.46%) bytes in affected programs: 10108742 -> 9899538 (-2.07%) helped: 7999 HURT: 1416 Bytes are helped. total regs in shared programs: 602415 -> 590371 (-2.00%) regs in affected programs: 92177 -> 80133 (-13.07%) helped: 1887 HURT: 209 Regs are helped. total uniforms in shared programs: 1457531 -> 1533232 (5.19%) uniforms in affected programs: 835522 -> 911223 (9.06%) helped: 0 HURT: 11042 Uniforms are HURT. total threads in shared programs: 20325824 -> 20329216 (0.02%) threads in affected programs: 29632 -> 33024 (11.45%) helped: 41 HURT: 0 Threads are helped. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28483>
37 lines
874 B
C
37 lines
874 B
C
/*
|
|
* Copyright 2021 Alyssa Rosenzweig
|
|
* Copyright 2020 Collabora Ltd.
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "util/macros.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* clang-format off */
|
|
enum agx_compiler_dbg {
|
|
/* bit 0 unused */
|
|
AGX_DBG_SHADERS = BITFIELD_BIT(1),
|
|
AGX_DBG_SHADERDB = BITFIELD_BIT(2),
|
|
AGX_DBG_VERBOSE = BITFIELD_BIT(3),
|
|
AGX_DBG_INTERNAL = BITFIELD_BIT(4),
|
|
AGX_DBG_NOVALIDATE = BITFIELD_BIT(5),
|
|
AGX_DBG_NOOPT = BITFIELD_BIT(6),
|
|
AGX_DBG_WAIT = BITFIELD_BIT(7),
|
|
AGX_DBG_NOPREAMBLE = BITFIELD_BIT(8),
|
|
AGX_DBG_DEMAND = BITFIELD_BIT(9),
|
|
AGX_DBG_NOSCHED = BITFIELD_BIT(10),
|
|
AGX_DBG_SPILL = BITFIELD_BIT(11),
|
|
AGX_DBG_NOPROMOTE = BITFIELD_BIT(12),
|
|
};
|
|
/* clang-format on */
|
|
|
|
uint64_t agx_get_compiler_debug(void);
|
|
|
|
#ifdef __cplusplus
|
|
} /* extern C */
|
|
#endif
|