[Mesa-dev] [PATCH] glxinfo: test GL_ATI_meminfo and GL_NVX_gpu_memory_info (v2)

Brian Paul brianp at vmware.com
Tue Feb 2 19:46:27 UTC 2016


On 02/02/2016 12:22 PM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> v2: move the code to glinfo_common.c.
> ---
>   src/xdemos/glinfo_common.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++
>   src/xdemos/glinfo_common.h |  2 ++
>   src/xdemos/glxinfo.c       |  1 +
>   3 files changed, 59 insertions(+)
>
> diff --git a/src/xdemos/glinfo_common.c b/src/xdemos/glinfo_common.c
> index 5d865f3..a7e1142 100644
> --- a/src/xdemos/glinfo_common.c
> +++ b/src/xdemos/glinfo_common.c
> @@ -798,3 +798,59 @@ parse_args(int argc, char *argv[], struct options *options)
>         }
>      }
>   }
> +
> +static void
> +query_ATI_meminfo(void)
> +{
> +#ifdef GL_ATI_meminfo
> +    int i[4];
> +
> +    printf("Memory info (GL_ATI_meminfo):\n");
> +
> +    glGetIntegerv(GL_VBO_FREE_MEMORY_ATI, i);
> +    printf("    VBO free memory - total: %u MB, largest block: %u MB\n",
> +           i[0] / 1024, i[1] / 1024);
> +    printf("    VBO free aux. memory - total: %u MB, largest block: %u MB\n",
> +           i[2] / 1024, i[3] / 1024);
> +
> +    glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, i);
> +    printf("    Texture free memory - total: %u MB, largest block: %u MB\n",
> +           i[0] / 1024, i[1] / 1024);
> +    printf("    Texture free aux. memory - total: %u MB, largest block: %u MB\n",
> +           i[2] / 1024, i[3] / 1024);
> +
> +    glGetIntegerv(GL_RENDERBUFFER_FREE_MEMORY_ATI, i);
> +    printf("    Renderbuffer free memory - total: %u MB, largest block: %u MB\n",
> +           i[0] / 1024, i[1] / 1024);
> +    printf("    Renderbuffer free aux. memory - total: %u MB, largest block: %u MB\n",
> +           i[2] / 1024, i[3] / 1024);
> +#endif
> +}
> +
> +static void
> +query_NVX_gpu_memory_info(void)
> +{
> +#ifdef GL_NVX_gpu_memory_info
> +    int i;
> +
> +    printf("Memory info (GL_NVX_gpu_memory_info):\n");
> +
> +    glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &i);
> +    printf("    Dedicated video memory: %u MB\n", i / 1024);
> +
> +    glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &i);
> +    printf("    Total available memory: %u MB\n", i / 1024);
> +
> +    glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &i);
> +    printf("    Currently available dedicated video memory: %u MB\n", i / 1024);
> +#endif
> +}
> +
> +void
> +print_gpu_memory_info(const char *glExtensions)
> +{
> +   if (strstr(glExtensions, "GL_ATI_meminfo"))
> +      query_ATI_meminfo();
> +   if (strstr(glExtensions, "GL_NVX_gpu_memory_info"))
> +      query_NVX_gpu_memory_info();
> +}
> diff --git a/src/xdemos/glinfo_common.h b/src/xdemos/glinfo_common.h
> index ad867ee..0024f85 100644
> --- a/src/xdemos/glinfo_common.h
> +++ b/src/xdemos/glinfo_common.h
> @@ -138,5 +138,7 @@ context_flags_string(int mask);
>   void
>   parse_args(int argc, char *argv[], struct options *options);
>
> +void
> +print_gpu_memory_info(const char *glExtensions);
>
>   #endif /* GLINFO_COMMON_H */
> diff --git a/src/xdemos/glxinfo.c b/src/xdemos/glxinfo.c
> index f65451a..1893f7b 100644
> --- a/src/xdemos/glxinfo.c
> +++ b/src/xdemos/glxinfo.c
> @@ -547,6 +547,7 @@ print_screen_info(Display *dpy, int scrnum,
>            }
>            if (strstr(glxExtensions, "GLX_MESA_query_renderer"))
>   	    query_renderer();
> +         print_gpu_memory_info(glExtensions);
>            printf("OpenGL vendor string: %s\n", glVendor);
>            printf("OpenGL renderer string: %s\n", glRenderer);
>         } else
>

Thanks.

Reviewed-by: Brian Paul <brianp at vmware.com>



More information about the mesa-dev mailing list