}
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
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;
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;
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;
#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,
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] =
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
*/