#define SAMPLES_PER_SEC 10000
#define GRBM_STATUS 0x8010
+#define SPI_BUSY(x) (((x) >> 22) & 0x1)
#define GUI_ACTIVE(x) (((x) >> 31) & 0x1)
static void r600_update_grbm_counters(struct r600_common_screen *rscreen,
rscreen->ws->read_registers(rscreen->ws, GRBM_STATUS, 1, &value);
+ if (SPI_BUSY(value))
+ p_atomic_inc(&counters->named.spi_busy);
+ else
+ p_atomic_inc(&counters->named.spi_idle);
+
if (GUI_ACTIVE(value))
p_atomic_inc(&counters->named.gui_busy);
else
#define BUSY_INDEX(rscreen, field) (&rscreen->grbm_counters.named.field##_busy - \
rscreen->grbm_counters.array)
+uint64_t r600_begin_counter_spi(struct r600_common_screen *rscreen)
+{
+ return r600_read_counter(rscreen, BUSY_INDEX(rscreen, spi));
+}
+
+unsigned r600_end_counter_spi(struct r600_common_screen *rscreen, uint64_t begin)
+{
+ return r600_end_counter(rscreen, begin, BUSY_INDEX(rscreen, spi));
+}
+
uint64_t r600_begin_counter_gui(struct r600_common_screen *rscreen)
{
return r600_read_counter(rscreen, BUSY_INDEX(rscreen, gui));
union r600_grbm_counters {
struct {
+ unsigned spi_busy;
+ unsigned spi_idle;
unsigned gui_busy;
unsigned gui_idle;
} named;
/* r600_gpu_load.c */
void r600_gpu_load_kill_thread(struct r600_common_screen *rscreen);
+uint64_t r600_begin_counter_spi(struct r600_common_screen *rscreen);
+unsigned r600_end_counter_spi(struct r600_common_screen *rscreen, uint64_t begin);
uint64_t r600_begin_counter_gui(struct r600_common_screen *rscreen);
unsigned r600_end_counter_gui(struct r600_common_screen *rscreen, uint64_t begin);
case R600_QUERY_GPU_LOAD:
query->begin_result = r600_begin_counter_gui(rctx->screen);
break;
+ case R600_QUERY_GPU_SHADERS_BUSY:
+ query->begin_result = r600_begin_counter_spi(rctx->screen);
+ break;
case R600_QUERY_NUM_COMPILATIONS:
query->begin_result = p_atomic_read(&rctx->screen->num_compilations);
break;
query->begin_result);
query->begin_result = 0;
break;
+ case R600_QUERY_GPU_SHADERS_BUSY:
+ query->end_result = r600_end_counter_spi(rctx->screen,
+ query->begin_result);
+ query->begin_result = 0;
+ break;
case R600_QUERY_NUM_COMPILATIONS:
query->end_result = p_atomic_read(&rctx->screen->num_compilations);
break;
/* The following queries must be at the end of the list because their
* availability is adjusted dynamically based on the DRM version. */
X("GPU-load", GPU_LOAD, UINT64, AVERAGE),
+ X("GPU-shaders-busy", GPU_SHADERS_BUSY, UINT64, AVERAGE),
X("temperature", GPU_TEMPERATURE, UINT64, AVERAGE),
X("shader-clock", CURRENT_GPU_SCLK, HZ, AVERAGE),
X("memory-clock", CURRENT_GPU_MCLK, HZ, AVERAGE),
else if (rscreen->info.drm_major == 3)
return ARRAY_SIZE(r600_driver_query_list) - 3;
else
- return ARRAY_SIZE(r600_driver_query_list) - 4;
+ return ARRAY_SIZE(r600_driver_query_list) - 5;
}
static int r600_get_driver_query_info(struct pipe_screen *screen,
R600_QUERY_CURRENT_GPU_SCLK,
R600_QUERY_CURRENT_GPU_MCLK,
R600_QUERY_GPU_LOAD,
+ R600_QUERY_GPU_SHADERS_BUSY,
R600_QUERY_NUM_COMPILATIONS,
R600_QUERY_NUM_SHADERS_CREATED,
R600_QUERY_BACK_BUFFER_PS_DRAW_RATIO,