[Mesa-dev] [PATCH 3/5] mesa: implement GL_ATI_meminfo
Marek Olšák
maraeo at gmail.com
Tue Feb 2 13:45:02 UTC 2016
From: Marek Olšák <marek.olsak at amd.com>
---
src/mapi/glapi/gen/gl_API.xml | 6 ++++++
src/mesa/main/extensions_table.h | 1 +
src/mesa/main/get.c | 26 +++++++++++++++++++++++++-
src/mesa/main/get_hash_params.py | 5 +++++
src/mesa/main/mtypes.h | 1 +
5 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 09dda19..ca15b6d 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -12661,6 +12661,12 @@
<enum name="FRAMEBUFFER_SRGB_CAPABLE_EXT" value="0x8DBA"/>
</category>
+<category name="GL_ATI_meminfo" number="359">
+ <enum name="VBO_FREE_MEMORY_ATI" value="0x87FB" />
+ <enum name="TEXTURE_FREE_MEMORY_ATI" value="0x87FC" />
+ <enum name="RENDERBUFFER_FREE_MEMORY_ATI" value="0x87FD" />
+</category>
+
<xi:include href="AMD_performance_monitor.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<category name="GL_APPLE_texture_range" number="367">
diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index dfccb73..af7881c 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -165,6 +165,7 @@ EXT(ARB_window_pos , dummy_true
EXT(ATI_blend_equation_separate , EXT_blend_equation_separate , GLL, GLC, x , x , 2003)
EXT(ATI_draw_buffers , dummy_true , GLL, x , x , x , 2002)
EXT(ATI_fragment_shader , ATI_fragment_shader , GLL, x , x , x , 2001)
+EXT(ATI_meminfo , ATI_meminfo , GLL, GLC, x , x , 2009)
EXT(ATI_separate_stencil , ATI_separate_stencil , GLL, x , x , x , 2006)
EXT(ATI_texture_compression_3dc , ATI_texture_compression_3dc , GLL, x , x , x , 2004)
EXT(ATI_texture_env_combine3 , ATI_texture_env_combine3 , GLL, x , x , x , 2002)
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index dbc8605..50ca1be 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -449,6 +449,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(ATI_meminfo);
EXTRA_EXT(NVX_gpu_memory_info);
static const int
@@ -1081,7 +1082,10 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
case GL_DISPATCH_INDIRECT_BUFFER_BINDING:
v->value_int = ctx->DispatchIndirectBuffer->Name;
break;
- /* GL_NVX_gpu_memory_info */
+ /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */
+ case GL_VBO_FREE_MEMORY_ATI:
+ case GL_TEXTURE_FREE_MEMORY_ATI:
+ case GL_RENDERBUFFER_FREE_MEMORY_ATI:
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:
@@ -1103,6 +1107,26 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
v->value_int = total_device_memory + total_staging_memory;
else if (d->pname == GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX)
v->value_int = avail_device_memory;
+ else {
+ /* ATI free memory enums.
+ *
+ * Since the GPU memory is (usually) page-table based, every two
+ * consecutive elements are equal. From the GL_ATI_meminfo
+ * specification:
+ *
+ * "param[0] - total memory free in the pool
+ * param[1] - largest available free block in the pool
+ * param[2] - total auxiliary memory free
+ * param[3] - largest auxiliary free block"
+ *
+ * All three (VBO, TEXTURE, RENDERBUFFER) queries return
+ * the same numbers here.
+ */
+ v->value_int_4[0] = avail_device_memory;
+ v->value_int_4[1] = avail_device_memory;
+ v->value_int_4[2] = avail_staging_memory;
+ v->value_int_4[3] = avail_staging_memory;
+ }
}
break;
case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX:
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index be4e030..73610fb 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -848,6 +848,11 @@ descriptor=[
[ "MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxShaderStorageBlocks), extra_ARB_shader_storage_buffer_object" ],
[ "MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_TESS_EVAL].MaxShaderStorageBlocks), extra_ARB_shader_storage_buffer_object" ],
+# GL_ATI_meminfo
+ [ "VBO_FREE_MEMORY_ATI", "LOC_CUSTOM, TYPE_INT_4, NO_OFFSET, extra_ATI_meminfo" ],
+ [ "TEXTURE_FREE_MEMORY_ATI", "LOC_CUSTOM, TYPE_INT_4, NO_OFFSET, extra_ATI_meminfo" ],
+ [ "RENDERBUFFER_FREE_MEMORY_ATI", "LOC_CUSTOM, TYPE_INT_4, NO_OFFSET, extra_ATI_meminfo" ],
+
# 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" ],
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 805f2cd..224969d 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3877,6 +3877,7 @@ struct gl_extensions
GLboolean AMD_vertex_shader_layer;
GLboolean AMD_vertex_shader_viewport_index;
GLboolean APPLE_object_purgeable;
+ GLboolean ATI_meminfo;
GLboolean ATI_texture_compression_3dc;
GLboolean ATI_texture_mirror_once;
GLboolean ATI_texture_env_combine3;
--
2.1.4
More information about the mesa-dev
mailing list