[Mesa-dev] [PATCH 09/25] dri/radeon: create radeon{Vendor, GetRenderer}String helpers

Emil Velikov emil.l.velikov at gmail.com
Fri Feb 21 19:03:59 PST 2014


To be used by the upcomming GLX_MESA_query_renderer implementation.

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 .../drivers/dri/radeon/radeon_common_context.c     | 50 +++++++++++++---------
 .../drivers/dri/radeon/radeon_common_context.h     |  4 ++
 src/mesa/drivers/dri/radeon/radeon_screen.h        |  2 +
 3 files changed, 35 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 353ecf5..06b606e 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 6cd1535..3bf29f5 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common_context.h
+++ b/src/mesa/drivers/dri/radeon/radeon_common_context.h
@@ -514,6 +514,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.h b/src/mesa/drivers/dri/radeon/radeon_screen.h
index 03abb2a..39341c8 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.h
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.h
@@ -211,6 +211,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);
-- 
1.9.0



More information about the mesa-dev mailing list