On Tue, Feb 2, 2016 at 3:36 PM, Ilia Mirkin <imir...@alum.mit.edu> wrote: > On Tue, Feb 2, 2016 at 8:45 AM, Marek Olšák <mar...@gmail.com> wrote: >> From: Marek Olšák <marek.ol...@amd.com> >> >> --- >> src/mapi/glapi/gen/gl_API.xml | 8 ++++++++ >> src/mesa/main/dd.h | 10 ++++++++++ >> src/mesa/main/extensions_table.h | 1 + >> src/mesa/main/get.c | 30 ++++++++++++++++++++++++++++++ >> src/mesa/main/get_hash_params.py | 7 +++++++ >> src/mesa/main/mtypes.h | 1 + >> 6 files changed, 57 insertions(+) >> >> diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml >> index d7ab3bf..09dda19 100644 >> --- a/src/mapi/glapi/gen/gl_API.xml >> +++ b/src/mapi/glapi/gen/gl_API.xml >> @@ -12714,6 +12714,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"> >> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h >> index d4378e5..d34e610 100644 >> --- a/src/mesa/main/dd.h >> +++ b/src/mesa/main/dd.h >> @@ -939,6 +939,16 @@ 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, >> + unsigned *total_device_memory, >> + unsigned *avail_device_memory, >> + unsigned *total_staging_memory, >> + unsigned *avail_staging_memory); >> }; >> >> >> diff --git a/src/mesa/main/extensions_table.h >> b/src/mesa/main/extensions_table.h >> index ad5dc60..dfccb73 100644 >> --- a/src/mesa/main/extensions_table.h >> +++ b/src/mesa/main/extensions_table.h >> @@ -291,6 +291,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) > > More like 2009, or even earlier... 2013 is the last modified date, not > the creation date. Not sure where to get the creation date though.
If you know the exact date, feel free to tell me. Otherwise, I don't think it's important. > >> >> 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) >> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c >> index 0434836..dbc8605 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(NVX_gpu_memory_info); >> >> static const int >> extra_ARB_color_buffer_float_or_glcore[] = { >> @@ -1080,6 +1081,35 @@ 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 */ >> + 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: >> + { >> + unsigned total_device_memory; >> + unsigned avail_device_memory; >> + unsigned total_staging_memory; >> + unsigned avail_staging_memory; >> + >> + ctx->Driver.QueryMemoryInfo(ctx, >> + &total_device_memory, >> + &avail_device_memory, >> + &total_staging_memory, >> + &avail_staging_memory); >> + >> + if (d->pname == GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX) >> + v->value_int = total_device_memory; >> + else if (d->pname == GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX) >> + v->value_int = total_device_memory + total_staging_memory; > > Total memory is unlikely to change at runtime. Should these be ctx->Const.foo? > >> + else if (d->pname == >> GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX) >> + v->value_int = avail_device_memory; > > and then this becomes the only thing you need to query? The current design simplifies the implementation for both extensions. Since the query is almost free and a one-time thing, I'm not concerned about performance. Marek _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev