diff options
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_common_context.c | 50 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_common_context.h | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_screen.c | 68 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_screen.h | 2 |
4 files changed, 103 insertions, 21 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.c b/src/mesa/drivers/dri/radeon/radeon_common_context.c index 353ecf5e243..06b606e8ac8 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_common_context.c @@ -70,39 +70,47 @@ static const char* get_chip_family_name(int chip_family) } } +const char const *radeonVendorString = "Mesa Project"; -/* Return various strings for glGetString(). +/* Return complete renderer string. */ -static const GLubyte *radeonGetString(struct gl_context * ctx, GLenum name) +const char *radeonGetRendererString(radeonScreenPtr radeonScreen) { - radeonContextPtr radeon = RADEON_CONTEXT(ctx); static char buffer[128]; + char hardwarename[32]; - switch (name) { - case GL_VENDOR: - return (GLubyte *) "Mesa Project"; + GLuint agp_mode = (radeonScreen->card_type==RADEON_CARD_PCI) ? 0 : + radeonScreen->AGPMode; - case GL_RENDERER: - { - char hardwarename[32]; - GLuint agp_mode = (radeon->radeonScreen->card_type==RADEON_CARD_PCI) ? 0 : - radeon->radeonScreen->AGPMode; - - sprintf(hardwarename, "%s (%s %04X)", + snprintf(hardwarename, sizeof(hardwarename), "%s (%s %04X)", #if defined(RADEON_R100) - "R100", + "R100", #elif defined(RADEON_R200) - "R200", + "R200", #endif - get_chip_family_name(radeon->radeonScreen->chip_family), - radeon->radeonScreen->device_id); + get_chip_family_name(radeonScreen->chip_family), + radeonScreen->device_id); - driGetRendererString(buffer, hardwarename, agp_mode); + driGetRendererString(buffer, hardwarename, agp_mode); - strcat(buffer, " DRI2"); + strcat(buffer, " DRI2"); - return (GLubyte *) buffer; - } + return buffer; +} + + +/* Return various strings for glGetString(). + */ +static const GLubyte *radeonGetString(struct gl_context * ctx, GLenum name) +{ + radeonContextPtr radeon = RADEON_CONTEXT(ctx); + + switch (name) { + case GL_VENDOR: + return (GLubyte *) radeonVendorString; + + case GL_RENDERER: + return (GLubyte *) radeonGetRendererString(radeon->radeonScreen); default: return NULL; diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.h b/src/mesa/drivers/dri/radeon/radeon_common_context.h index ac3e7b529b2..2a95d61d664 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common_context.h +++ b/src/mesa/drivers/dri/radeon/radeon_common_context.h @@ -515,6 +515,10 @@ static inline __DRIdrawable* radeon_get_readable(radeonContextPtr radeon) return radeon->dri.context->driReadablePriv; } +extern const char const *radeonVendorString; + +const char *radeonGetRendererString(radeonScreenPtr radeonScreen); + GLboolean radeonInitContext(radeonContextPtr radeon, gl_api api, struct dd_function_table* functions, diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index fe72b775228..9a6fbbdb051 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -481,6 +481,73 @@ 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 or vram_visible ? */ + value[0] = gem_info.vram_size >> 20; + return 0; + } + case __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE: + value[0] = 0; + return 0; + default: + return driQueryRendererIntegerCommon(psp, param, value); + } +} + +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: + return -1; + } +} + +static const __DRI2rendererQueryExtension radeonRendererQueryExtension = { + .base = { __DRI2_RENDERER_QUERY, 1 }, + + .queryInteger = radeonQueryRendererInteger, + .queryString = radeonQueryRendererString +}; + static const __DRIextension *radeon_screen_extensions[] = { &dri2ConfigQueryExtension.base, @@ -491,6 +558,7 @@ static const __DRIextension *radeon_screen_extensions[] = { #endif &radeonFlushExtension.base, &radeonImageExtension.base, + &radeonRendererQueryExtension.base, NULL }; diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.h b/src/mesa/drivers/dri/radeon/radeon_screen.h index 76fa1ec05dd..9b77627b857 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.h +++ b/src/mesa/drivers/dri/radeon/radeon_screen.h @@ -209,6 +209,8 @@ struct __DRIimageRec { #define untile_image r200_untile_image #define set_re_cntl_d3d r200_set_re_cntl_d3d #define radeonDestroyBuffer r200_radeonDestroyBuffer +#define radeonVendorString r200_radeonVendorString +#define radeonGetRendererString r200_radeonGetRendererString #endif extern void radeonDestroyBuffer(__DRIdrawable *driDrawPriv); |