mesa: implement GL_NVX_gpu_memory_info (v2)
v2: implement eviction queries properly add gl_memory_info structure Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
d2e4c9e737
commit
1d79b99580
|
@ -12721,6 +12721,14 @@
|
|||
<enum name="EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD" value="0x9160"/>
|
||||
</category>
|
||||
|
||||
<category name="GL_NVX_gpu_memory_info" number="438">
|
||||
<enum name="GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX" value="0x9047" />
|
||||
<enum name="GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX" value="0x9048" />
|
||||
<enum name="GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX" value="0x9049" />
|
||||
<enum name="GPU_MEMORY_INFO_EVICTION_COUNT_NVX" value="0x904A" />
|
||||
<enum name="GPU_MEMORY_INFO_EVICTED_MEMORY_NVX" value="0x904B" />
|
||||
</category>
|
||||
|
||||
<xi:include href="INTEL_performance_query.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
|
||||
<category name="GL_EXT_polygon_offset_clamp" number="460">
|
||||
|
|
|
@ -48,6 +48,7 @@ struct gl_shader;
|
|||
struct gl_shader_program;
|
||||
struct gl_texture_image;
|
||||
struct gl_texture_object;
|
||||
struct gl_memory_info;
|
||||
|
||||
/* GL_ARB_vertex_buffer_object */
|
||||
/* Modifies GL_MAP_UNSYNCHRONIZED_BIT to allow driver to fail (return
|
||||
|
@ -948,6 +949,13 @@ struct dd_function_table {
|
|||
void (*DispatchCompute)(struct gl_context *ctx, const GLuint *num_groups);
|
||||
void (*DispatchComputeIndirect)(struct gl_context *ctx, GLintptr indirect);
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* Query information about memory. Device memory is e.g. VRAM. Staging
|
||||
* memory is e.g. GART. All sizes are in kilobytes.
|
||||
*/
|
||||
void (*QueryMemoryInfo)(struct gl_context *ctx,
|
||||
struct gl_memory_info *info);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -292,6 +292,7 @@ EXT(NV_texture_barrier , NV_texture_barrier
|
|||
EXT(NV_texture_env_combine4 , NV_texture_env_combine4 , GLL, x , x , x , 1999)
|
||||
EXT(NV_texture_rectangle , NV_texture_rectangle , GLL, x , x , x , 2000)
|
||||
EXT(NV_vdpau_interop , NV_vdpau_interop , GLL, GLC, x , x , 2010)
|
||||
EXT(NVX_gpu_memory_info , NVX_gpu_memory_info , GLL, GLC, x , x , 2013)
|
||||
|
||||
EXT(OES_EGL_image , OES_EGL_image , GLL, GLC, ES1, ES2, 2006) /* FIXME: Mesa expects GL_OES_EGL_image to be available in OpenGL contexts. */
|
||||
EXT(OES_EGL_image_external , OES_EGL_image_external , x , x , ES1, ES2, 2010)
|
||||
|
|
|
@ -450,6 +450,7 @@ EXTRA_EXT(ARB_tessellation_shader);
|
|||
EXTRA_EXT(ARB_shader_subroutine);
|
||||
EXTRA_EXT(ARB_shader_storage_buffer_object);
|
||||
EXTRA_EXT(ARB_indirect_parameters);
|
||||
EXTRA_EXT(NVX_gpu_memory_info);
|
||||
|
||||
static const int
|
||||
extra_ARB_color_buffer_float_or_glcore[] = {
|
||||
|
@ -1091,6 +1092,29 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
|
|||
break;
|
||||
case GL_SAMPLE_BUFFERS:
|
||||
v->value_int = _mesa_geometric_samples(ctx->DrawBuffer) > 0;
|
||||
/* GL_NVX_gpu_memory_info */
|
||||
case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX:
|
||||
case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX:
|
||||
case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX:
|
||||
case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX:
|
||||
case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX:
|
||||
{
|
||||
struct gl_memory_info info;
|
||||
|
||||
ctx->Driver.QueryMemoryInfo(ctx, &info);
|
||||
|
||||
if (d->pname == GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX)
|
||||
v->value_int = info.total_device_memory;
|
||||
else if (d->pname == GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX)
|
||||
v->value_int = info.total_device_memory +
|
||||
info.total_staging_memory;
|
||||
else if (d->pname == GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX)
|
||||
v->value_int = info.avail_device_memory;
|
||||
else if (d->pname == GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX)
|
||||
v->value_int = info.nr_device_memory_evictions;
|
||||
else if (d->pname == GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX)
|
||||
v->value_int = info.device_memory_evicted;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -850,6 +850,13 @@ descriptor=[
|
|||
|
||||
# GL_ARB_query_buffer_object
|
||||
[ "QUERY_BUFFER_BINDING", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_query_buffer_object" ],
|
||||
|
||||
# GL_NVX_gpu_memory_info
|
||||
[ "GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX", "LOC_CUSTOM, TYPE_INT, NO_OFFSET, extra_NVX_gpu_memory_info" ],
|
||||
[ "GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX", "LOC_CUSTOM, TYPE_INT, NO_OFFSET, extra_NVX_gpu_memory_info" ],
|
||||
[ "GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX", "LOC_CUSTOM, TYPE_INT, NO_OFFSET, extra_NVX_gpu_memory_info" ],
|
||||
[ "GPU_MEMORY_INFO_EVICTION_COUNT_NVX", "LOC_CUSTOM, TYPE_INT, NO_OFFSET, extra_NVX_gpu_memory_info" ],
|
||||
[ "GPU_MEMORY_INFO_EVICTED_MEMORY_NVX", "LOC_CUSTOM, TYPE_INT, NO_OFFSET, extra_NVX_gpu_memory_info" ],
|
||||
]},
|
||||
|
||||
# Enums restricted to OpenGL Core profile
|
||||
|
|
|
@ -3911,6 +3911,7 @@ struct gl_extensions
|
|||
GLboolean NV_texture_env_combine4;
|
||||
GLboolean NV_texture_rectangle;
|
||||
GLboolean NV_vdpau_interop;
|
||||
GLboolean NVX_gpu_memory_info;
|
||||
GLboolean TDFX_texture_compression_FXT1;
|
||||
GLboolean OES_EGL_image;
|
||||
GLboolean OES_draw_texture;
|
||||
|
@ -4589,6 +4590,18 @@ struct gl_context
|
|||
GLboolean ShareGroupReset;
|
||||
};
|
||||
|
||||
/**
|
||||
* Information about memory usage. All sizes are in kilobytes.
|
||||
*/
|
||||
struct gl_memory_info
|
||||
{
|
||||
unsigned total_device_memory; /**< size of device memory, e.g. VRAM */
|
||||
unsigned avail_device_memory; /**< free device memory at the moment */
|
||||
unsigned total_staging_memory; /**< size of staging memory, e.g. GART */
|
||||
unsigned avail_staging_memory; /**< free staging memory at the moment */
|
||||
unsigned device_memory_evicted; /**< size of memory evicted (monotonic counter) */
|
||||
unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
extern int MESA_VERBOSE;
|
||||
|
|
Loading…
Reference in New Issue