mesa/src/intel/dev/intel_debug.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

205 lines
5.6 KiB
C
Raw Normal View History

/*
* Copyright 2003 VMware, Inc.
* Copyright © 2007 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef INTEL_DEBUG_H
#define INTEL_DEBUG_H
#include <stdint.h>
#include "compiler/shader_enums.h"
#include "util/bitset.h"
#include "util/macros.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \file intel_debug.h
*
* Basic INTEL_DEBUG environment variable handling. This file defines the
* list of debugging flags, as well as some macros for handling them.
*/
enum intel_debug_flag {
DEBUG_TEXTURE = 0,
DEBUG_BLIT,
DEBUG_PERF,
DEBUG_PERFMON,
DEBUG_BATCH,
DEBUG_BUFMGR,
DEBUG_SYNC,
DEBUG_SF,
DEBUG_SUBMIT,
DEBUG_URB,
DEBUG_CLIP,
DEBUG_STALL,
DEBUG_NO_RESOURCE_BARRIER,
DEBUG_BLORP,
DEBUG_NO_DUAL_OBJECT_GS,
DEBUG_OPTIMIZER,
DEBUG_MDA,
DEBUG_ANNOTATION,
DEBUG_NO_OACONFIG,
brw: Eliminate redundant fills and spills When the register allocator decides to spill a value, all writes to that value are spilled and all reads are filled. In regions where there is not high register pressure, a spill of a value may be followed by a fill of that same file while the spilled register is still live. This optimization pass finds these cases, and it converts the fill to a move from the still-live register. The restriction that the spill and the fill must have matching NoMask really hampers this optimization. With the restriction removed, the pass was more than 2x helpful. v2: Require force_writemask_all to be the same for the spill and the fill. v3: Use FIXED_GRF for register overlap tests. Since this is after register allocation, the VGRF values will not tell the whole truth. v4: Use brw_transform_inst. Suggested by Caio. The allows two of the loops to be merged. Add brw_scratch_inst::offset instead of storing it as a source. Suggested by Lionel. v5: Add no-fill-opt debug option to disable optimizations. Suggested by Lionel. v6: Move a calculation outside a loop. Suggested by Lionel. v7: Check that spill ranges overlap instead of just checking initial offset. Zero shaders in fossil-db were affected, but some CTS with spill_fs were fixed (e.g., dEQP-VK.subgroups.arithmetic.compute.subgroupmin_uint64_t_requiredsubgroupsize). Suggested by Lionel. v8: Add DEBUG_NO_FILL_OPT to debug_bits in brw_get_compiler_config_value(). Noticed by Lionel. shader-db: Lunar Lake total instructions in shared programs: 17249907 -> 17249903 (<.01%) instructions in affected programs: 10684 -> 10680 (-0.04%) helped: 2 / HURT: 0 total cycles in shared programs: 893092630 -> 893092398 (<.01%) cycles in affected programs: 237320 -> 237088 (-0.10%) helped: 2 / HURT: 0 total fills in shared programs: 1903 -> 1901 (-0.11%) fills in affected programs: 110 -> 108 (-1.82%) helped: 2 / HURT: 0 Meteor Lake and DG2 had similar results. (Meteor Lake shown) total instructions in shared programs: 19968898 -> 19968778 (<.01%) instructions in affected programs: 33020 -> 32900 (-0.36%) helped: 10 / HURT: 0 total cycles in shared programs: 885157211 -> 884925015 (-0.03%) cycles in affected programs: 39944544 -> 39712348 (-0.58%) helped: 8 / HURT: 2 total fills in shared programs: 4454 -> 4394 (-1.35%) fills in affected programs: 2678 -> 2618 (-2.24%) helped: 10 / HURT: 0 fossil-db: Lunar Lake Totals: Instrs: 930445228 -> 929949528 (-0.05%) Cycle count: 105195579417 -> 105126671329 (-0.07%); split: -0.07%, +0.00% Spill count: 3495279 -> 3494400 (-0.03%) Fill count: 6767063 -> 6520785 (-3.64%) Totals from 43844 (2.17% of 2018922) affected shaders: Instrs: 212614840 -> 212119140 (-0.23%) Cycle count: 19151130510 -> 19082222422 (-0.36%); split: -0.39%, +0.03% Spill count: 2831100 -> 2830221 (-0.03%) Fill count: 6128316 -> 5882038 (-4.02%) Meteor Lake and DG2 had similar results. (Meteor Lake shown) Totals: Instrs: 1001375893 -> 1001113407 (-0.03%) Cycle count: 92746180943 -> 92679877883 (-0.07%); split: -0.08%, +0.01% Spill count: 3729157 -> 3728585 (-0.02%) Fill count: 6697296 -> 6566874 (-1.95%) Totals from 35062 (1.53% of 2284674) affected shaders: Instrs: 179819265 -> 179556779 (-0.15%) Cycle count: 18111194752 -> 18044891692 (-0.37%); split: -0.41%, +0.04% Spill count: 2453752 -> 2453180 (-0.02%) Fill count: 5279259 -> 5148837 (-2.47%) Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37827>
2025-06-18 18:28:43 -07:00
DEBUG_NO_FILL_OPT,
DEBUG_SPILL_FS,
DEBUG_SPILL_VEC4,
DEBUG_HEX,
DEBUG_NO_COMPACTION,
DEBUG_L3,
DEBUG_NO_CCS,
DEBUG_NO_HIZ,
DEBUG_NO_CCS_MODIFIER,
DEBUG_COLOR,
DEBUG_REEMIT,
DEBUG_SOFT64,
DEBUG_BT,
DEBUG_PIPE_CONTROL,
DEBUG_NO_FAST_CLEAR,
DEBUG_CAPTURE_ALL,
DEBUG_PERF_SYMBOL_NAMES,
DEBUG_SWSB_STALL,
DEBUG_HEAPS,
DEBUG_ISL,
DEBUG_SPARSE,
DEBUG_DRAW_BKP,
DEBUG_DISPATCH_BKP,
DEBUG_BATCH_STATS,
DEBUG_REG_PRESSURE,
DEBUG_SHADER_PRINT,
DEBUG_CL_QUIET,
DEBUG_BVH_BLAS,
DEBUG_BVH_TLAS,
DEBUG_BVH_BLAS_IR_HDR,
DEBUG_BVH_TLAS_IR_HDR,
DEBUG_BVH_BLAS_IR_AS,
DEBUG_BVH_TLAS_IR_AS,
DEBUG_BVH_NO_BUILD,
DEBUG_NO_SEND_GATHER,
DEBUG_NO_VRT,
DEBUG_RT_NO_TRACE,
DEBUG_SHADERS_LINENO,
/* Keep the stages grouped */
DEBUG_VS,
DEBUG_TCS,
DEBUG_TES,
DEBUG_GS,
DEBUG_WM,
DEBUG_TASK,
DEBUG_MESH,
DEBUG_CS,
DEBUG_RT,
DEBUG_NO8,
DEBUG_NO16,
DEBUG_NO32,
DEBUG_DO32,
/* Must be the last entry */
INTEL_DEBUG_MAX,
};
extern BITSET_WORD intel_debug[BITSET_WORDS(INTEL_DEBUG_MAX)];
/* Check if a debug flag is enabled by testing its bit position */
#define INTEL_DEBUG(flag) unlikely(BITSET_TEST(intel_debug, (flag)))
/* These flags are not compatible with the disk shader cache */
#define DEBUG_DISK_CACHE_DISABLE_MASK 0
/* Flags to determine what bvh to dump out */
#define INTEL_DEBUG_BVH_ANY (unlikely(INTEL_DEBUG(DEBUG_BVH_BLAS) || \
INTEL_DEBUG(DEBUG_BVH_TLAS) || \
INTEL_DEBUG(DEBUG_BVH_BLAS_IR_HDR) || \
INTEL_DEBUG(DEBUG_BVH_TLAS_IR_HDR) || \
INTEL_DEBUG(DEBUG_BVH_BLAS_IR_AS) || \
INTEL_DEBUG(DEBUG_BVH_TLAS_IR_AS)))
extern uint64_t intel_simd;
extern uint32_t intel_debug_bkp_before_draw_count;
extern uint32_t intel_debug_bkp_after_draw_count;
extern uint32_t intel_debug_bkp_before_dispatch_count;
extern uint32_t intel_debug_bkp_after_dispatch_count;
extern uint64_t intel_debug_batch_frame_start;
extern uint64_t intel_debug_batch_frame_stop;
extern uint32_t intel_shader_dump_filter;
#define INTEL_SIMD(type, size) (!!(intel_simd & (DEBUG_ ## type ## _SIMD ## size)))
/* VS, TCS, TES and GS stages are dispatched in one size */
#define DEBUG_FS_SIMD8 (1ull << 0)
#define DEBUG_FS_SIMD16 (1ull << 1)
#define DEBUG_FS_SIMD32 (1ull << 2)
#define DEBUG_FS_SIMD2X8 (1ull << 3)
#define DEBUG_FS_SIMD4X8 (1ull << 4)
#define DEBUG_FS_SIMD2X16 (1ull << 5)
#define DEBUG_CS_SIMD8 (1ull << 6)
#define DEBUG_CS_SIMD16 (1ull << 7)
#define DEBUG_CS_SIMD32 (1ull << 8)
#define DEBUG_TS_SIMD8 (1ull << 9)
#define DEBUG_TS_SIMD16 (1ull << 10)
#define DEBUG_TS_SIMD32 (1ull << 11)
#define DEBUG_MS_SIMD8 (1ull << 12)
#define DEBUG_MS_SIMD16 (1ull << 13)
#define DEBUG_MS_SIMD32 (1ull << 14)
#define DEBUG_RT_SIMD8 (1ull << 15)
#define DEBUG_RT_SIMD16 (1ull << 16)
#define DEBUG_RT_SIMD32 (1ull << 17)
#define SIMD_DISK_CACHE_MASK ((1ull << 18) - 1)
#ifdef HAVE_ANDROID_PLATFORM
#define LOG_TAG "INTEL-MESA"
#if ANDROID_API_LEVEL >= 26
#include <log/log.h>
#else
#include <cutils/log.h>
#endif /* use log/log.h start from android 8 major version */
#ifndef ALOGW
#define ALOGW LOGW
#endif
#define dbg_printf(...) ALOGW(__VA_ARGS__)
#else
#define dbg_printf(...) fprintf(stderr, __VA_ARGS__)
#endif /* HAVE_ANDROID_PLATFORM */
#define DBG(...) do { \
if (INTEL_DEBUG(FILE_DEBUG_FLAG)) \
dbg_printf(__VA_ARGS__); \
} while(0)
extern uint64_t intel_debug_flag_for_shader_stage(mesa_shader_stage stage);
extern void process_intel_debug_variable(void);
#ifdef __cplusplus
}
#endif
#endif /* INTEL_DEBUG_H */