From b403802cbdfadea0cf1c86130521d874b5aa0c81 Mon Sep 17 00:00:00 2001
From: Roman Mamedov <roman@rm.pp.ru>
Date: Fri, 23 Nov 2007 20:48:08 +0500
Subject: WineD3D: Implement detection of ATI cards with Mesa DRI drivers

---
 dlls/wined3d/directx.c |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 36d7ebc..a6c26ea 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -487,7 +488,8 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
         } else if (strstr(gl_string, "Intel(R)") || 
 		   strstr(gl_info->gl_renderer, "Intel(R)")) {
             gl_info->gl_vendor = VENDOR_INTEL;
-        } else if (strstr(gl_string, "Mesa")) {
+        } else if (strstr(gl_string, "Mesa") ||
+                   strstr(gl_info->gl_renderer, "Mesa")) {
             gl_info->gl_vendor = VENDOR_MESA;
         } else {
             gl_info->gl_vendor = VENDOR_WINE;
@@ -1123,6 +1125,37 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
             }
             break;
         case VENDOR_MESA:
+            /* For ATI cards, the Mesa DRI renderer string does not contain the name of the exact card used.
+             * Instead, that string contains the name of a driver module, which is loaded for it. Currently,
+             * there are only four driver modules for whole supported ATI model range. If we see one of their
+             * names, then it's surely VENDOR_ATI. But to use these names for guessing the exact card model
+             * is not too reliable. Therefore, the D3D capability estimations are used instead.
+             * For details about the specific card models returned, see the VENDOR_ATI section.
+             */
+            if(strstr(gl_info->gl_renderer, "Rage 128")||
+               strstr(gl_info->gl_renderer, "R200")||
+               strstr(gl_info->gl_renderer, "R300")||
+               strstr(gl_info->gl_renderer, "Radeon"))
+            {
+                gl_info->gl_vendor = VENDOR_ATI;
+                if(WINE_D3D9_CAPABLE(gl_info)) {
+                    gl_info->gl_card = CARD_ATI_RADEON_9500;
+                    vidmem = 128;
+                } else if(WINE_D3D8_CAPABLE(gl_info)) {
+                    gl_info->gl_card = CARD_ATI_RADEON_8500;
+                    vidmem = 64;
+                } else if(WINE_D3D7_CAPABLE(gl_info)) {
+                    gl_info->gl_card = CARD_ATI_RADEON_7200;
+                    vidmem = 32;
+                } else {
+                    gl_info->gl_card = CARD_ATI_RAGE_128PRO;
+                    vidmem = 16;
+                }
+                break;
+            }
+            /* Card is probably one of the non-ATI cards which are also supported by Mesa.
+             * Continue to the fallback behavior of VENDOR_WINE.
+             */
         case VENDOR_WINE:
         default:
             /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice 
-- 
1.5.3.4


