util/shader_stats: allow "hidden" stats

to allow drivers to do more complex printing without needing a subclass
paradigm. To be used on Intel.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37517>
This commit is contained in:
Alyssa Rosenzweig 2025-09-22 13:37:22 -04:00 committed by Marge Bot
parent 040201d46a
commit b575b0954a
2 changed files with 8 additions and 3 deletions

View file

@ -85,7 +85,8 @@ class Stat:
self.name = el.attrib['name']
self.display = el.attrib.get('display', self.name)
self.description = textwrap.dedent(el.text).replace('\n', ' ').strip()
self.hidden = el.attrib.get('hidden', False)
self.description = textwrap.dedent(el.text or '').replace('\n', ' ').strip()
self.count = int(el.attrib.get('count', 1))
self.c_name = safe_name(self.display).lower()
self.c_type, self.vk_type, format_specifier = TYPE_MAP[type_]
@ -106,9 +107,10 @@ class ISA:
# Derive a the format string to print statistics in GL (report.py)
# format. report.py has a weird special case for spills/fills, which we
# need to fix up here.
fmt = ', '.join([x for stat in self.stats for x in stat.format_strings])
external_stats = [stat for stat in self.stats if not stat.hidden]
fmt = ', '.join([x for stat in external_stats for x in stat.format_strings])
self.format_string = fmt.replace('%" PRIu32 " spills, %" PRIu32 " fills', '%" PRIu32 ":%" PRIu32 " spills:fills')
self.format_args = ', '.join([x for stat in self.stats for x in stat.format_args])
self.format_args = ', '.join([x for stat in external_stats for x in stat.format_args])
class Family:
def __init__(self, el):
@ -174,6 +176,7 @@ ${isa.c_name}_stats_util_debug(struct util_debug_callback *debug, const char *pr
#define vk_add_${isa.c_name}_stats(out, stats) do { ${'\\\\'}
% for stat in isa.stats:
% if not stat.hidden:
% for i in range(stat.count):
% if stat.count > 1:
vk_add_exec_statistic_${stat.vk_type}(out, "${stat.name.replace('#', str(i))}", "${stat.description.replace('#', str(i))}", (stats)->${stat.c_name}[${i}]); ${'\\\\'}
@ -181,6 +184,7 @@ ${isa.c_name}_stats_util_debug(struct util_debug_callback *debug, const char *pr
vk_add_exec_statistic_${stat.vk_type}(out, "${stat.name}", "${stat.description}", (stats)->${stat.c_name}); ${'\\\\'}
% endif
% endfor
% endif
% endfor
} while(0)

View file

@ -18,6 +18,7 @@ isa = element isa {
attribute count { xsd:integer }?,
attribute more { "better" | "worse" }?,
attribute hash { xsd:boolean }?,
attribute hidden { xsd:boolean }?,
[ a:defaultValue = "u32" ] attribute type
{ "u8" | "i8" | "u16" | "i16" | "u32" | "i32" | "u64" | "i64" | "float" | "bool" }?,