mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 22:10:10 +01:00
radv,gallium: Add driconf option to reduce advertised VRAM size.
To help debugging games that actually do active memory budget management. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6641>
This commit is contained in:
parent
cc431f48f9
commit
cf2eebdf4f
4 changed files with 27 additions and 5 deletions
|
|
@ -127,16 +127,26 @@ radv_get_device_uuid(struct radeon_info *info, void *uuid)
|
|||
ac_compute_device_uuid(info, uuid, VK_UUID_SIZE);
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
radv_get_adjusted_vram_size(struct radv_physical_device *device)
|
||||
{
|
||||
int ov = driQueryOptioni(&device->instance->dri_options,
|
||||
"override_vram_size");
|
||||
if (ov >= 0)
|
||||
return MIN2(device->rad_info.vram_size, (uint64_t)ov << 20);
|
||||
return device->rad_info.vram_size;
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
radv_get_visible_vram_size(struct radv_physical_device *device)
|
||||
{
|
||||
return MIN2(device->rad_info.vram_size, device->rad_info.vram_vis_size);
|
||||
return MIN2(radv_get_adjusted_vram_size(device) , device->rad_info.vram_vis_size);
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
radv_get_vram_size(struct radv_physical_device *device)
|
||||
{
|
||||
return device->rad_info.vram_size - radv_get_visible_vram_size(device);
|
||||
return radv_get_adjusted_vram_size(device) - device->rad_info.vram_vis_size;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -609,6 +619,7 @@ DRI_CONF_BEGIN
|
|||
DRI_CONF_SECTION_END
|
||||
|
||||
DRI_CONF_SECTION_DEBUG
|
||||
DRI_CONF_OVERRIDE_VRAM_SIZE()
|
||||
DRI_CONF_VK_WSI_FORCE_BGRA8_UNORM_FIRST("false")
|
||||
DRI_CONF_SECTION_END
|
||||
DRI_CONF_END;
|
||||
|
|
@ -2195,7 +2206,7 @@ radv_get_memory_budget_properties(VkPhysicalDevice physicalDevice,
|
|||
RADEON_ALLOCATED_VRAM);
|
||||
|
||||
heap_budget = vram_size -
|
||||
device->ws->query_value(device->ws, RADEON_VRAM_USAGE) +
|
||||
MIN2(vram_size, device->ws->query_value(device->ws, RADEON_VRAM_USAGE)) +
|
||||
heap_usage;
|
||||
|
||||
memoryBudget->heapBudget[heap_index] = heap_budget;
|
||||
|
|
@ -2205,7 +2216,7 @@ radv_get_memory_budget_properties(VkPhysicalDevice physicalDevice,
|
|||
RADEON_ALLOCATED_VRAM_VIS);
|
||||
|
||||
heap_budget = visible_vram_size -
|
||||
device->ws->query_value(device->ws, RADEON_VRAM_VIS_USAGE) +
|
||||
MIN2(visible_vram_size, device->ws->query_value(device->ws, RADEON_VRAM_VIS_USAGE)) +
|
||||
heap_usage;
|
||||
|
||||
memoryBudget->heapBudget[heap_index] = heap_budget;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ DRI_CONF_SECTION_DEBUG
|
|||
DRI_CONF_ALLOW_DRAW_OUT_OF_ORDER("false")
|
||||
DRI_CONF_FORCE_COMPAT_PROFILE("false")
|
||||
DRI_CONF_FORCE_GL_VENDOR()
|
||||
DRI_CONF_OVERRIDE_VRAM_SIZE()
|
||||
DRI_CONF_SECTION_END
|
||||
|
||||
DRI_CONF_SECTION_MISCELLANEOUS
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include "utils.h"
|
||||
#include "dri_screen.h"
|
||||
#include "dri_query_renderer.h"
|
||||
#include "pipe-loader/pipe_loader.h"
|
||||
|
||||
static int
|
||||
dri2_query_renderer_integer(__DRIscreen *_screen, int param,
|
||||
|
|
@ -30,11 +31,15 @@ dri2_query_renderer_integer(__DRIscreen *_screen, int param,
|
|||
PIPE_CAP_ACCELERATED);
|
||||
return 0;
|
||||
|
||||
case __DRI2_RENDERER_VIDEO_MEMORY:
|
||||
case __DRI2_RENDERER_VIDEO_MEMORY: {
|
||||
int ov = driQueryOptioni(&screen->dev->option_cache, "override_vram_size");
|
||||
value[0] =
|
||||
(unsigned int)screen->base.screen->get_param(screen->base.screen,
|
||||
PIPE_CAP_VIDEO_MEMORY);
|
||||
if (ov >= 0)
|
||||
value[0] = MIN2(ov, value[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE:
|
||||
value[0] =
|
||||
|
|
|
|||
|
|
@ -222,6 +222,11 @@ DRI_CONF_OPT_BEGIN_B(force_compat_profile, def) \
|
|||
DRI_CONF_DESC("Force an OpenGL compatibility context") \
|
||||
DRI_CONF_OPT_END
|
||||
|
||||
#define DRI_CONF_OVERRIDE_VRAM_SIZE() \
|
||||
DRI_CONF_OPT_BEGIN_V(override_vram_size, int, -1, "-1:2147483647") \
|
||||
DRI_CONF_DESC("Override the VRAM size advertised to the application in MiB (-1 = default)") \
|
||||
DRI_CONF_OPT_END
|
||||
|
||||
/**
|
||||
* \brief Image quality-related options
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue