2
* Copyright © 2021 Valve Corporation
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27
#include "radv_private.h"
31
radv_perfcounter_emit_shaders(struct radeon_cmdbuf *cs, unsigned shaders)
33
radeon_set_uconfig_reg_seq(cs, R_036780_SQ_PERFCOUNTER_CTRL, 2);
34
radeon_emit(cs, shaders & 0x7f);
35
radeon_emit(cs, 0xffffffff);
39
radv_perfcounter_emit_reset(struct radeon_cmdbuf *cs)
41
radeon_set_uconfig_reg(cs, R_036020_CP_PERFMON_CNTL,
42
S_036020_PERFMON_STATE(V_036020_CP_PERFMON_STATE_DISABLE_AND_RESET) |
43
S_036020_SPM_PERFMON_STATE(V_036020_STRM_PERFMON_STATE_DISABLE_AND_RESET));
47
radv_perfcounter_emit_start(struct radv_device *device, struct radeon_cmdbuf *cs, int family)
49
/* Start SPM counters. */
50
radeon_set_uconfig_reg(cs, R_036020_CP_PERFMON_CNTL,
51
S_036020_PERFMON_STATE(V_036020_CP_PERFMON_STATE_DISABLE_AND_RESET) |
52
S_036020_SPM_PERFMON_STATE(V_036020_STRM_PERFMON_STATE_START_COUNTING));
54
/* Start windowed performance counters. */
55
if (family == RADV_QUEUE_GENERAL) {
56
radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 0, 0));
57
radeon_emit(cs, EVENT_TYPE(V_028A90_PERFCOUNTER_START) | EVENT_INDEX(0));
59
radeon_set_sh_reg(cs, R_00B82C_COMPUTE_PERFCOUNT_ENABLE, S_00B82C_PERFCOUNT_ENABLE(1));
63
radv_perfcounter_emit_stop(struct radv_device *device, struct radeon_cmdbuf *cs, int family)
65
/* Stop windowed performance counters. */
66
if (family == RADV_QUEUE_GENERAL) {
67
radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 0, 0));
68
radeon_emit(cs, EVENT_TYPE(V_028A90_PERFCOUNTER_STOP) | EVENT_INDEX(0));
70
radeon_set_sh_reg(cs, R_00B82C_COMPUTE_PERFCOUNT_ENABLE, S_00B82C_PERFCOUNT_ENABLE(0));
72
/* Stop SPM counters. */
73
radeon_set_uconfig_reg(cs, R_036020_CP_PERFMON_CNTL,
74
S_036020_PERFMON_STATE(V_036020_CP_PERFMON_STATE_DISABLE_AND_RESET) |
75
S_036020_SPM_PERFMON_STATE(device->physical_device->rad_info.never_stop_sq_perf_counters ?
76
V_036020_STRM_PERFMON_STATE_START_COUNTING :
77
V_036020_STRM_PERFMON_STATE_STOP_COUNTING));