[Mesa-dev] [PATCH 2/5] mesa: implement GL_NVX_gpu_memory_info

Roland Scheidegger sroland at vmware.com
Tue Feb 2 15:02:30 UTC 2016


Does anyone use these extensions?
I suppose maybe to get the total amount of video memory?
>From the dynamic counts, I would have thought the eviction one would be
the most interesting, but this one isn't implemented. Ah well I guess a
sloppily implemented extension is better than none.

Roland

Am 02.02.2016 um 14:45 schrieb Marek Olšák:
> From: Marek Olšák <marek.olsak at 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)
>  
>  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;
> +         else if (d->pname == GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX)
> +            v->value_int = avail_device_memory;
> +      }
> +      break;
> +   case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX:
> +   case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX:
> +      /* not interested in returning anything useful here */
> +      v->value_int = 0;
> +      break;
>     }
>  }
>  
> diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
> index 04aec03..be4e030 100644
> --- a/src/mesa/main/get_hash_params.py
> +++ b/src/mesa/main/get_hash_params.py
> @@ -847,6 +847,13 @@ descriptor=[
>  # GL_ARB_shader_storage_buffer_object
>    [ "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_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
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 101283c..805f2cd 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -3897,6 +3897,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;
> 



More information about the mesa-dev mailing list