- Create radeon{Vendor,GetRenderer}String helpers.
- Drop __DRI2_RENDERER_PREFERRED_PROFILE case.
- Cleanup return statements.
To be used by the upcomming GLX_MESA_query_renderer implementation.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
}
}
+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;
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,
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,
#endif
&radeonFlushExtension.base,
&radeonImageExtension.base,
+ &radeonRendererQueryExtension.base,
NULL
};
#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);