[Mesa-dev] [PATCH 10/25] dri/radeon: add GLX_MESA_query_renderer support
Emil Velikov
emil.l.velikov at gmail.com
Fri Feb 21 19:04:00 PST 2014
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
src/mesa/drivers/dri/radeon/radeon_screen.c | 77 +++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c
index 57e866e..8ad9d12 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -475,6 +475,80 @@ static int radeon_set_screen_flags(radeonScreenPtr screen, int device_id)
return 0;
}
+static int
+radeonQueryRendererInteger(__DRIscreen *psp, int param,
+ unsigned int *value)
+{
+ radeonScreenPtr screen = (radeonScreenPtr)psp->driverPrivate;
+
+ switch (param) {
+ case __DRI2_RENDERER_VENDOR_ID:
+ value[0] = 0x1002;
+ return 0;
+ case __DRI2_RENDERER_DEVICE_ID:
+ value[0] = screen->device_id;
+ return 0;
+ case __DRI2_RENDERER_ACCELERATED:
+ value[0] = 1;
+ return 0;
+ case __DRI2_RENDERER_VIDEO_MEMORY: {
+ struct drm_radeon_gem_info gem_info;
+ int retval;
+ memset(&gem_info, 0, sizeof(gem_info));
+
+ /* Get GEM info. */
+ retval = drmCommandWriteRead(psp->fd, DRM_RADEON_GEM_INFO, &gem_info,
+ sizeof(gem_info));
+
+ if (retval) {
+ fprintf(stderr, "radeon: Failed to get MM info, error number %d\n",
+ retval);
+ return -1;
+
+ }
+ /* XXX: Do we want to return vram_size/visible or gart_size ? */
+ value[0] = gem_info.vram_size >> 20;
+ return 0;
+ }
+ case __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE:
+ value[0] = 0;
+ return 0;
+ case __DRI2_RENDERER_PREFERRED_PROFILE:
+ value[0] = (1U << __DRI_API_OPENGL);
+ return 0;
+ default:
+ return driQueryRendererIntegerCommon(psp, param, value);
+ }
+
+ return -1;
+}
+
+static int
+radeonQueryRendererString(__DRIscreen *psp, int param, const char **value)
+{
+ radeonScreenPtr screen = (radeonScreenPtr)psp->driverPrivate;
+
+ switch (param) {
+ case __DRI2_RENDERER_VENDOR_ID:
+ value[0] = radeonVendorString;
+ return 0;
+ case __DRI2_RENDERER_DEVICE_ID:
+ value[0] = radeonGetRendererString(screen);
+ return 0;
+ default:
+ break;
+ }
+
+ return -1;
+}
+
+static const __DRI2rendererQueryExtension radeonRendererQueryExtension = {
+ .base = { __DRI2_RENDERER_QUERY, 1 },
+
+ .queryInteger = radeonQueryRendererInteger,
+ .queryString = radeonQueryRendererString
+};
+
static radeonScreenPtr
radeonCreateScreen2(__DRIscreen *sPriv)
{
@@ -526,6 +600,7 @@ radeonCreateScreen2(__DRIscreen *sPriv)
#endif
screen->extensions[i++] = &radeonFlushExtension.base;
+ screen->extensions[i++] = &radeonRendererQueryExtension.base;
screen->extensions[i++] = &radeonImageExtension.base;
screen->extensions[i++] = NULL;
@@ -723,8 +798,10 @@ __DRIconfig **radeonInitScreen2(__DRIscreen *psp)
int color;
__DRIconfig **configs = NULL;
+ psp->max_gl_core_version = 0;
psp->max_gl_compat_version = 13;
psp->max_gl_es1_version = 11;
+ psp->max_gl_es2_version = 0;
if (!radeonInitDriver(psp)) {
return NULL;
--
1.9.0
More information about the mesa-dev
mailing list