Tizen 2.0 Release
[profile/ivi/osmesa.git] / src / mesa / drivers / windows / gldirect / gldlame8.c
1 /****************************************************************************
2 *
3 *                        Mesa 3-D graphics library
4 *                        Direct3D Driver Interface
5 *
6 *  ========================================================================
7 *
8 *   Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
9 *
10 *   Permission is hereby granted, free of charge, to any person obtaining a
11 *   copy of this software and associated documentation files (the "Software"),
12 *   to deal in the Software without restriction, including without limitation
13 *   the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 *   and/or sell copies of the Software, and to permit persons to whom the
15 *   Software is furnished to do so, subject to the following conditions:
16 *
17 *   The above copyright notice and this permission notice shall be included
18 *   in all copies or substantial portions of the Software.
19 *
20 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 *   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 *   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23 *   SCITECH SOFTWARE INC BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
25 *   OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 *   SOFTWARE.
27 *
28 *  ======================================================================
29 *
30 * Language:     ANSI C
31 * Environment:  Windows 9x (Win32)
32 *
33 * Description:  GLDirect utility for determining lame boards/drivers.
34 *
35 ****************************************************************************/
36
37 #define STRICT
38 #define WIN32_LEAN_AND_MEAN
39 #include <d3d8.h>
40
41 /*
42 Ack. Broken out from gldlame.c because of broken D3D headers. KeithH
43 */
44
45 /****************************************************************************
46 REMARKS:
47 Scans list of DirectDraw devices for specific device IDs.
48 ****************************************************************************/
49
50 #define VENDORID_ATI 0x1002
51
52 static DWORD devATIRagePro[] = {
53         0x4742, // 3D RAGE PRO BGA AGP 1X/2X
54         0x4744, // 3D RAGE PRO BGA AGP 1X only
55         0x4749, // 3D RAGE PRO BGA PCI 33 MHz
56         0x4750, // 3D RAGE PRO PQFP PCI 33 MHz
57         0x4751, // 3D RAGE PRO PQFP PCI 33 MHz limited 3D
58         0x4C42, // 3D RAGE LT PRO BGA-312 AGP 133 MHz
59         0x4C44, // 3D RAGE LT PRO BGA-312 AGP 66 MHz
60         0x4C49, // 3D RAGE LT PRO BGA-312 PCI 33 MHz
61         0x4C50, // 3D RAGE LT PRO BGA-256 PCI 33 MHz
62         0x4C51, // 3D RAGE LT PRO BGA-256 PCI 33 MHz limited 3D
63 };
64
65 static DWORD devATIRageIIplus[] = {
66         0x4755, // 3D RAGE II+
67         0x4756, // 3D RAGE IIC PQFP PCI
68         0x4757, // 3D RAGE IIC BGA AGP
69         0x475A, // 3D RAGE IIC PQFP AGP
70         0x4C47, // 3D RAGE LT-G
71 };
72
73 static __inline BOOL IsDevice(
74         DWORD *lpDeviceIdList,
75         DWORD dwDeviceId,
76         int count)
77 {
78         int i;
79
80         for (i=0; i<count; i++)
81                 if (dwDeviceId == lpDeviceIdList[i])
82                         return TRUE;
83
84         return FALSE;
85 }
86
87 /****************************************************************************
88 REMARKS:
89 Test the Direct3D8 device for "lameness" with respect to GLDirect.
90 This is done on per-chipset basis, as in GLD CAD driver (DGLCONTEXT.C).
91 If bTestForWHQL is set then the device is tested to see if it is
92 certified, and bIsWHQL is set to indicate TRUE or FALSE. Otherwise bIsWHQL
93 is not set. [WHQL = Windows Hardware Quality Labs]
94
95 NOTE: There is a one- or two-second time penalty incurred in determining
96       the WHQL certification date.
97 ****************************************************************************/
98 BOOL IsThisD3D8Lame(
99         IDirect3D8 *pD3D,
100         DWORD dwAdapter,
101         BOOL bTestForWHQL,
102         BOOL *bIsWHQL)
103 {
104         DWORD                                   dwFlags = bTestForWHQL ? 0 : D3DENUM_NO_WHQL_LEVEL;
105         D3DADAPTER_IDENTIFIER8  d3dai;
106         HRESULT                                 hr;
107
108         hr = IDirect3D8_GetAdapterIdentifier(pD3D, dwAdapter, dwFlags, &d3dai);
109         if (FAILED(hr))
110                 return TRUE; // Definitely lame if adapter details can't be obtained!
111
112         if (bTestForWHQL) {
113                 *bIsWHQL = d3dai.WHQLLevel ? TRUE : FALSE;
114         }
115
116         // Vendor 1: ATI
117         if (d3dai.VendorId == VENDORID_ATI) {
118                 // Test A: ATI Rage PRO
119                 if (IsDevice(devATIRagePro, d3dai.DeviceId, sizeof(devATIRagePro)))
120                         return TRUE;    // bad mipmapping
121                 // Test B: ATI Rage II+
122                 if (IsDevice(devATIRageIIplus, d3dai.DeviceId, sizeof(devATIRageIIplus)))
123                         return TRUE;    // bad HW alpha testing
124         }
125
126         return FALSE;
127 }
128
129 /****************************************************************************
130 REMARKS:
131 Test the Direct3DDevice8 device for "lameness" with respect to GLDirect.
132 This is done by querying for particular caps, as in GLD CPL (CPLMAIN.CPP).
133 ****************************************************************************/
134 BOOL IsThisD3D8DeviceLame(
135         IDirect3DDevice8 *pDev)
136 {
137         D3DCAPS8        d3dCaps;
138         HRESULT         hr;
139
140         hr = IDirect3DDevice8_GetDeviceCaps(pDev, &d3dCaps);
141         if (FAILED(hr))
142                 return TRUE;
143
144         // Test 1: Perspective-correct textures
145         // Any card that cannot do perspective-textures is *exceptionally* lame.
146         if (!(d3dCaps.TextureCaps & D3DPTEXTURECAPS_PERSPECTIVE)) {
147                 return TRUE; // Lame!
148         }
149
150         // Test 2: Bilinear filtering
151         if (!(d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MINFLINEAR)) {
152                 return TRUE; // Lame!
153         }
154
155         // Test 3: Mipmapping
156         if (!(d3dCaps.TextureCaps & D3DPTEXTURECAPS_MIPMAP)) {
157                 return TRUE; // Lame!
158         }
159
160         // Test 4: Depth-test modes (?)
161
162         // Test 5: Blend Modes -- Based on DX7 D3DIM MTEXTURE.CPP caps test
163
164         // Accept devices that can do multipass, alpha blending
165         if( !((d3dCaps.DestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) &&
166                         (d3dCaps.SrcBlendCaps & D3DPBLENDCAPS_SRCALPHA)) )
167                 return TRUE;
168
169         // Accept devices that can do multipass, color blending
170         if( !((d3dCaps.DestBlendCaps & D3DPBLENDCAPS_SRCCOLOR) &&
171                         (d3dCaps.SrcBlendCaps & D3DPBLENDCAPS_ZERO)) )
172                 return TRUE;
173
174         // Accept devices that really support multiple textures.
175         if( !((d3dCaps.MaxTextureBlendStages > 1 ) &&
176                         (d3dCaps.MaxSimultaneousTextures > 1 ) &&
177                         (d3dCaps.TextureOpCaps & D3DTEXOPCAPS_MODULATE )) )
178                 return TRUE;
179
180         return FALSE; // Not lame
181 }