mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 10:30:08 +01:00
r300: move r300_query_memory_info to r300_screen.c
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37329>
This commit is contained in:
parent
5c68b351fe
commit
6d605a3dde
4 changed files with 28 additions and 55 deletions
|
|
@ -28,8 +28,6 @@ files_r300 = files(
|
|||
'r300_screen_buffer.h',
|
||||
'r300_screen.c',
|
||||
'r300_screen.h',
|
||||
'r300_meminfo.c',
|
||||
'r300_meminfo.h',
|
||||
'r300_shader_semantics.h',
|
||||
'r300_state.c',
|
||||
'r300_state_derived.c',
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 Advanced Micro Devices, Inc.
|
||||
* Copyright 2025 Brais Solla <brais.1997@gmail.com<
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
|
||||
#include "r300_screen.h"
|
||||
#include "r300_meminfo.h"
|
||||
|
||||
|
||||
void r300_query_memory_info(struct pipe_screen *pscreen, struct pipe_memory_info *info)
|
||||
{
|
||||
struct r300_screen *rscreen = (struct r300_screen*) pscreen;
|
||||
struct radeon_winsys *ws = rscreen->rws;
|
||||
|
||||
info->total_device_memory = rscreen->info.vram_size_kb;
|
||||
info->total_staging_memory = rscreen->info.gart_size_kb;
|
||||
|
||||
/* The real TTM memory usage is somewhat random, because:
|
||||
*
|
||||
* 1) TTM delays freeing memory, because it can only free it after
|
||||
* fences expire.
|
||||
*
|
||||
* 2) The memory usage can be really low if big VRAM evictions are
|
||||
* taking place, but the real usage is well above the size of VRAM.
|
||||
*
|
||||
* Instead, return statistics of this process.
|
||||
*/
|
||||
unsigned vram_used = ws->query_value(ws, RADEON_VRAM_USAGE) / 1024;
|
||||
unsigned gtt_used = ws->query_value(ws, RADEON_GTT_USAGE) / 1024;
|
||||
|
||||
info->avail_device_memory = (vram_used > info->total_device_memory) ? 0 : info->total_device_memory - vram_used;
|
||||
info->avail_staging_memory = (gtt_used > info->total_staging_memory) ? 0 : info->total_staging_memory - gtt_used;
|
||||
info->device_memory_evicted = ws->query_value(ws, RADEON_NUM_BYTES_MOVED) / 1024;
|
||||
info->nr_device_memory_evictions = ws->query_value(ws, RADEON_NUM_EVICTIONS);
|
||||
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 Advanced Micro Devices, Inc.
|
||||
* Copyright 2025 Brais Solla <brais.1997@gmail.com<
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef R300_MEMINFO_H
|
||||
#define R300_MEMINFO_H
|
||||
|
||||
void r300_query_memory_info(struct pipe_screen *pscreen, struct pipe_memory_info *info);
|
||||
|
||||
#endif
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
#include "r300_screen_buffer.h"
|
||||
#include "r300_state_inlines.h"
|
||||
#include "r300_public.h"
|
||||
#include "r300_meminfo.h"
|
||||
|
||||
#include "draw/draw_context.h"
|
||||
|
||||
|
|
@ -640,6 +639,34 @@ static int r300_screen_get_fd(struct pipe_screen *screen)
|
|||
return rws->get_fd(rws);
|
||||
}
|
||||
|
||||
static void r300_query_memory_info(struct pipe_screen *pscreen,
|
||||
struct pipe_memory_info *info)
|
||||
{
|
||||
struct r300_screen *rscreen = (struct r300_screen*) pscreen;
|
||||
struct radeon_winsys *ws = rscreen->rws;
|
||||
|
||||
info->total_device_memory = rscreen->info.vram_size_kb;
|
||||
info->total_staging_memory = rscreen->info.gart_size_kb;
|
||||
|
||||
/* The real TTM memory usage is somewhat random, because:
|
||||
*
|
||||
* 1) TTM delays freeing memory, because it can only free it after
|
||||
* fences expire.
|
||||
*
|
||||
* 2) The memory usage can be really low if big VRAM evictions are
|
||||
* taking place, but the real usage is well above the size of VRAM.
|
||||
*
|
||||
* Instead, return statistics of this process.
|
||||
*/
|
||||
unsigned vram_used = ws->query_value(ws, RADEON_VRAM_USAGE) / 1024;
|
||||
unsigned gtt_used = ws->query_value(ws, RADEON_GTT_USAGE) / 1024;
|
||||
|
||||
info->avail_device_memory = (vram_used > info->total_device_memory) ? 0 : info->total_device_memory - vram_used;
|
||||
info->avail_staging_memory = (gtt_used > info->total_staging_memory) ? 0 : info->total_staging_memory - gtt_used;
|
||||
info->device_memory_evicted = ws->query_value(ws, RADEON_NUM_BYTES_MOVED) / 1024;
|
||||
info->nr_device_memory_evictions = ws->query_value(ws, RADEON_NUM_EVICTIONS);
|
||||
}
|
||||
|
||||
struct pipe_screen* r300_screen_create(struct radeon_winsys *rws,
|
||||
const struct pipe_screen_config *config)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue