Path: blob/21.2-virgl/src/broadcom/common/v3d_debug.c
4560 views
/*1* Copyright 2003 VMware, Inc.2* Copyright © 2006 Intel Corporation3* Copyright © 2017 Broadcom4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the "Software"),7* to deal in the Software without restriction, including without limitation8* the rights to use, copy, modify, merge, publish, distribute, sublicense,9* and/or sell copies of the Software, and to permit persons to whom the10* Software is furnished to do so, subject to the following conditions:11*12* The above copyright notice and this permission notice (including the next13* paragraph) shall be included in all copies or substantial portions of the14* Software.15*16* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR17* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,18* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL19* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER20* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING21* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS22* IN THE SOFTWARE.23*/2425/**26* \file v3d_debug.c27*28* Support for the V3D_DEBUG environment variable, along with other29* miscellaneous debugging code.30*/3132#include <stdlib.h>3334#include "common/v3d_debug.h"35#include "util/macros.h"36#include "util/debug.h"37#include "c11/threads.h"3839uint32_t V3D_DEBUG = 0;4041static const struct debug_control debug_control[] = {42{ "cl", V3D_DEBUG_CL},43{ "clif", V3D_DEBUG_CLIF},44{ "qpu", V3D_DEBUG_QPU},45{ "vir", V3D_DEBUG_VIR},46{ "nir", V3D_DEBUG_NIR},47{ "tgsi", V3D_DEBUG_TGSI},48{ "shaderdb", V3D_DEBUG_SHADERDB},49{ "surface", V3D_DEBUG_SURFACE},50{ "perf", V3D_DEBUG_PERF},51{ "norast", V3D_DEBUG_NORAST},52{ "fs", V3D_DEBUG_FS},53{ "gs", V3D_DEBUG_GS},54{ "vs", V3D_DEBUG_VS},55{ "cs", V3D_DEBUG_CS},56{ "always_flush", V3D_DEBUG_ALWAYS_FLUSH},57{ "precompile", V3D_DEBUG_PRECOMPILE},58{ "ra", V3D_DEBUG_RA},59{ "dump_spirv", V3D_DEBUG_DUMP_SPIRV},60{ NULL, 0 }61};6263uint32_t64v3d_debug_flag_for_shader_stage(gl_shader_stage stage)65{66uint32_t flags[] = {67[MESA_SHADER_VERTEX] = V3D_DEBUG_VS,68[MESA_SHADER_TESS_CTRL] = 0,69[MESA_SHADER_TESS_EVAL] = 0,70[MESA_SHADER_GEOMETRY] = V3D_DEBUG_GS,71[MESA_SHADER_FRAGMENT] = V3D_DEBUG_FS,72[MESA_SHADER_COMPUTE] = V3D_DEBUG_CS,73};74STATIC_ASSERT(MESA_SHADER_STAGES == 6);75return flags[stage];76}7778static void79v3d_process_debug_variable_once(void)80{81V3D_DEBUG = parse_debug_string(getenv("V3D_DEBUG"), debug_control);8283if (V3D_DEBUG & V3D_DEBUG_SHADERDB)84V3D_DEBUG |= V3D_DEBUG_NORAST;85}8687void88v3d_process_debug_variable(void)89{90static once_flag v3d_process_debug_variable_flag = ONCE_FLAG_INIT;9192call_once(&v3d_process_debug_variable_flag,93v3d_process_debug_variable_once);94}959697