diff options
author | Emil Velikov <[email protected]> | 2014-02-20 00:23:41 +0000 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2014-08-15 17:35:37 +0100 |
commit | 1bccf99c306372f2c281601be67c805952fd6bf6 (patch) | |
tree | a72c291346123aed688d4eb8439fbe32707d8271 /src/glx/dri2_query_renderer.c | |
parent | d10ba8b7c04b6f0f7f8e62715b7006494fb3915f (diff) |
glx/dri2: use mapping table for dri2_convert_glx_query_renderer_attribs()
Signed-off-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/glx/dri2_query_renderer.c')
-rw-r--r-- | src/glx/dri2_query_renderer.c | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/src/glx/dri2_query_renderer.c b/src/glx/dri2_query_renderer.c index c1e87723913..eb5884aba63 100644 --- a/src/glx/dri2_query_renderer.c +++ b/src/glx/dri2_query_renderer.c @@ -32,35 +32,37 @@ #include "dri3_priv.h" #endif +#define __RENDERER(attrib) \ + { GLX_RENDERER_##attrib##_MESA, __DRI2_RENDERER_##attrib } + +static const struct { + unsigned int glx_attrib, dri2_attrib; +} query_renderer_map[] = { + __RENDERER(VENDOR_ID), + __RENDERER(DEVICE_ID), + __RENDERER(VERSION), + __RENDERER(ACCELERATED), + __RENDERER(VIDEO_MEMORY), + __RENDERER(UNIFIED_MEMORY_ARCHITECTURE), + __RENDERER(PREFERRED_PROFILE), + __RENDERER(OPENGL_CORE_PROFILE_VERSION), + __RENDERER(OPENGL_COMPATIBILITY_PROFILE_VERSION), + __RENDERER(OPENGL_ES_PROFILE_VERSION), + __RENDERER(OPENGL_ES2_PROFILE_VERSION), +}; + +#undef __RENDERER + static int dri2_convert_glx_query_renderer_attribs(int attribute) { - switch (attribute) { - case GLX_RENDERER_VENDOR_ID_MESA: - return __DRI2_RENDERER_VENDOR_ID; - case GLX_RENDERER_DEVICE_ID_MESA: - return __DRI2_RENDERER_DEVICE_ID; - case GLX_RENDERER_VERSION_MESA: - return __DRI2_RENDERER_VERSION; - case GLX_RENDERER_ACCELERATED_MESA: - return __DRI2_RENDERER_ACCELERATED; - case GLX_RENDERER_VIDEO_MEMORY_MESA: - return __DRI2_RENDERER_VIDEO_MEMORY; - case GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA: - return __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE; - case GLX_RENDERER_PREFERRED_PROFILE_MESA: - return __DRI2_RENDERER_PREFERRED_PROFILE; - case GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA: - return __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION; - case GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA: - return __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION; - case GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA: - return __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION; - case GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA: - return __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION; - default: - return -1; - } + int i; + + for (i = 0; i < ARRAY_SIZE(query_renderer_map); i++) + if (query_renderer_map[i].glx_attrib == attribute) + return query_renderer_map[i].dri2_attrib; + + return -1; } _X_HIDDEN int |