Mesa (master): i965: Simplify brw_get_renderer_string()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jan 14 04:06:12 UTC 2020


Module: Mesa
Branch: master
Commit: 44bad9c31a11ca7bf67cba7eaa094963b5f5a2f7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=44bad9c31a11ca7bf67cba7eaa094963b5f5a2f7

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Tue Dec 17 01:00:14 2019 -0800

i965: Simplify brw_get_renderer_string()

This stops using driGetRendererString() in favor of a simple snprintf().
This should have the same functionality on 64-bit systems, but drops
a "x86/MMX/SSE2" suffix on 32-bit systems.  (People shouldn't be using
the GL_RENDERER string to check for CPU features...)

We also use gen_get_device_name() instead of PCI ID list munging.

Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3371>

---

 src/mesa/drivers/dri/i965/brw_context.c | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index aea2baa64fe..c30f1a04f30 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -103,32 +103,22 @@ get_bsw_model(const struct intel_screen *screen)
 const char *
 brw_get_renderer_string(const struct intel_screen *screen)
 {
-   const char *chipset;
-   static char buffer[128];
-   char *bsw = NULL;
-
-   switch (screen->deviceID) {
-#undef CHIPSET
-#define CHIPSET(id, symbol, str) case id: chipset = str; break;
-#include "pci_ids/i965_pci_ids.h"
-   default:
-      chipset = "Unknown Intel Chipset";
-      break;
-   }
+   static char buf[128];
+   const char *name = gen_get_device_name(screen->deviceID);
+
+   if (!name)
+      name = "Intel Unknown";
+
+   snprintf(buf, sizeof(buf), "Mesa DRI %s", name);
 
    /* Braswell branding is funny, so we have to fix it up here */
    if (screen->deviceID == 0x22B1) {
-      bsw = strdup(chipset);
-      char *needle = strstr(bsw, "XXX");
-      if (needle) {
+      char *needle = strstr(buf, "XXX");
+      if (needle)
          memcpy(needle, get_bsw_model(screen), 3);
-         chipset = bsw;
-      }
    }
 
-   (void) driGetRendererString(buffer, chipset, 0);
-   free(bsw);
-   return buffer;
+   return buf;
 }
 
 static const GLubyte *



More information about the mesa-commit mailing list