1 // Copyright 2013 Dolphin Emulator Project
2 // Licensed under GPLv2+
3 // Refer to the license.txt file included.
4 #pragma once
5 #include "Common/CommonTypes.h"
6 
7 #undef OS  // CURL defines that, nobody uses it...
8 
9 namespace DriverDetails
10 {
11 // API types supported by driver details
12 // This is separate to APIType in VideoConfig.h due to the fact that a bug
13 // can affect multiple APIs.
14 enum API
15 {
16   API_OPENGL = (1 << 0),
17   API_VULKAN = (1 << 1)
18 };
19 
20 // Enum of supported operating systems
21 enum OS
22 {
23   OS_ALL = (1 << 0),
24   OS_WINDOWS = (1 << 1),
25   OS_LINUX = (1 << 2),
26   OS_OSX = (1 << 3),
27   OS_ANDROID = (1 << 4),
28   OS_FREEBSD = (1 << 5),
29   OS_OPENBSD = (1 << 6),
30 };
31 // Enum of known vendors
32 // Tegra and Nvidia are separated out due to such substantial differences
33 enum Vendor
34 {
35   VENDOR_ALL = 0,
36   VENDOR_NVIDIA,
37   VENDOR_ATI,
38   VENDOR_INTEL,
39   VENDOR_ARM,
40   VENDOR_QUALCOMM,
41   VENDOR_IMGTEC,
42   VENDOR_TEGRA,
43   VENDOR_VIVANTE,
44   VENDOR_MESA,
45   VENDOR_UNKNOWN
46 };
47 
48 // Enum of known drivers
49 enum Driver
50 {
51   DRIVER_ALL = 0,
52   DRIVER_NVIDIA,       // Official Nvidia, including mobile GPU
53   DRIVER_NOUVEAU,      // OSS nouveau
54   DRIVER_ATI,          // Official ATI
55   DRIVER_R600,         // OSS Radeon
56   DRIVER_INTEL,        // Official Intel
57   DRIVER_I965,         // OSS Intel
58   DRIVER_ARM,          // Official Mali driver
59   DRIVER_LIMA,         // OSS Mali driver
60   DRIVER_QUALCOMM,     // Official Adreno driver
61   DRIVER_FREEDRENO,    // OSS Adreno driver
62   DRIVER_IMGTEC,       // Official PowerVR driver
63   DRIVER_VIVANTE,      // Official Vivante driver
64   DRIVER_PORTABILITY,  // Vulkan via Metal on macOS
65   DRIVER_UNKNOWN       // Unknown driver, default to official hardware driver
66 };
67 
68 enum class Family
69 {
70   UNKNOWN,
71   INTEL_SANDY,
72   INTEL_IVY,
73 };
74 
75 // Enum of known bugs
76 // These can be vendor specific, but we put them all in here
77 // For putting a new bug in here, make sure to put a detailed comment above the enum
78 // This'll ensure we know exactly what the issue is.
79 enum Bug
80 {
81   // Bug: UBO buffer offset broken
82   // Affected devices: all mesa drivers
83   // Started Version: 9.0 (mesa doesn't support ubo before)
84   // Ended Version: up to 9.2
85   // The offset of glBindBufferRange was ignored on all Mesa Gallium3D drivers until 9.1.3
86   // Nouveau stored the offset as u16 which isn't enough for all cases with range until 9.1.6
87   // I965 has broken data fetches from uniform buffers which results in a dithering until 9.2.0
88   BUG_BROKEN_UBO,
89   // Bug: The pinned memory extension isn't working for index buffers
90   // Affected devices: AMD as they are the only vendor providing this extension
91   // Started Version: ?
92   // Ended Version: 13.9 working for me (neobrain).
93   // Affected OS: Linux
94   // Pinned memory is disabled for index buffer as the AMD driver (the only one with pinned memory
95   // support) seems
96   // to be broken. We just get flickering/black rendering when using pinned memory here -- degasus -
97   // 2013/08/20
98   // This bug only happens when paired with base_vertex.
99   // Please see issue #6105. Let's hope buffer storage solves this issue.
100   // TODO: Detect broken drivers.
101   BUG_BROKEN_PINNED_MEMORY,
102   // Bug: glBufferSubData/glMapBufferRange stalls + OOM
103   // Affected devices: Adreno a3xx/Mali-t6xx
104   // Started Version: -1
105   // Ended Version: -1
106   // Both Adreno and Mali have issues when you call glBufferSubData or glMapBufferRange
107   // The driver stalls in each instance no matter what you do
108   // Apparently Mali and Adreno share code in this regard since they were written by the same
109   // person.
110   BUG_BROKEN_BUFFER_STREAM,
111   // Bug: ARB_buffer_storage doesn't work with ARRAY_BUFFER type streams
112   // Affected devices: GeForce 4xx+
113   // Started Version: -1
114   // Ended Version: 332.21
115   // The buffer_storage streaming method is required for greater speed gains in our buffer streaming
116   // It reduces what is needed for streaming to basically a memcpy call
117   // It seems to work for all buffer types except GL_ARRAY_BUFFER
118   BUG_BROKEN_BUFFER_STORAGE,
119   // Bug: Intel HD 3000 on OS X has broken primitive restart
120   // Affected devices: Intel HD 3000
121   // Affected OS: OS X
122   // Started Version: -1
123   // Ended Version: -1
124   // The drivers on OS X has broken primitive restart.
125   // Intel HD 4000 series isn't affected by the bug
126   BUG_PRIMITIVE_RESTART,
127   // Bug: unsync mapping doesn't work fine
128   // Affected devices: Nvidia driver, ARM Mali
129   // Started Version: -1
130   // Ended Version: -1
131   // The Nvidia driver (both Windows + Linux) doesn't like unsync mapping performance wise.
132   // Because of their threaded behavior, they seem not to handle unsync mapping complete unsync,
133   // in fact, they serialize the driver which adds a much bigger overhead.
134   // Workaround: Use BufferSubData
135   // The Mali behavior is even worse: They just ignore the unsychronized flag and stall the GPU.
136   // Workaround: As they were even too lazy to implement asynchronous buffer updates,
137   //             BufferSubData stalls as well, so we have to use the slowest possible path:
138   //             Alloc one buffer per draw call with BufferData.
139   // TODO: some Windows AMD driver/GPU combination seems also affected
140   //       but as they all support pinned memory, it doesn't matter
141   BUG_BROKEN_UNSYNC_MAPPING,
142   // Bug: Intel's Window driver broke buffer_storage with GL_ELEMENT_ARRAY_BUFFER
143   // Affected devices: Intel (Windows)
144   // Started Version: 15.36.3.64.3907 (10.18.10.3907)
145   // Ended Version: 15.36.7.64.3960 (10.18.10.3960)
146   // Intel implemented buffer_storage in their GL 4.3 driver.
147   // It works for all the buffer types we use except GL_ELEMENT_ARRAY_BUFFER.
148   // Causes complete blackscreen issues.
149   BUG_INTEL_BROKEN_BUFFER_STORAGE,
150   // Bug: Qualcomm has broken boolean negation
151   // Affected devices: Adreno
152   // Started Version: -1
153   // Ended Version: -1
154   // Qualcomm has the boolean negation broken in their shader compiler
155   // Instead of inverting the boolean value it does a binary negation on the full 32bit register
156   // This causes a compare against zero to fail in their shader since it is no longer a 0 or 1 value
157   // but 0xFFFFFFFF or 0xFFFFFFFE depending on what the boolean value was before the negation.
158   //
159   // This bug has a secondary issue tied to it unlike other bugs.
160   // The correction of this bug is to check the boolean value against false which results in us
161   // not doing a negation of the source but instead checking against the boolean value we want.
162   // The issue with this is that Intel's Windows driver is broken when checking if a boolean value
163   // is equal to true or false, so one has to do a boolean negation of the source
164   //
165   // eg.
166   // Broken on Qualcomm
167   // Works on Windows Intel
168   // if (!cond)
169   //
170   // Works on Qualcomm
171   // Broken on Windows Intel
172   // if (cond == false)
173   BUG_BROKEN_NEGATED_BOOLEAN,
174 
175   // Bug: glCopyImageSubData doesn't work on i965
176   // Started Version: -1
177   // Ended Version: 10.6.4
178   // Mesa meta misses to disable the scissor test.
179   BUG_BROKEN_COPYIMAGE,
180 
181   // Bug: ARM Mali managed to break disabling vsync
182   // Affected Devices: Mali
183   // Started Version: r5p0-rev2
184   // Ended Version: -1
185   // If we disable vsync with eglSwapInterval(dpy, 0) then the screen will stop showing new updates
186   // after a handful of swaps.
187   // This was noticed on a Samsung Galaxy S6 with its Android 5.1.1 update.
188   // The default Android 5.0 image didn't encounter this issue.
189   // We can't actually detect what the driver version is on Android, so until the driver version
190   // lands that displays the version in
191   // the GL_VERSION string, we will have to force vsync to be enabled at all times.
192   BUG_BROKEN_VSYNC,
193 
194   // Bug: Broken lines in geometry shaders
195   // Affected Devices: Mesa r600/radeonsi, Mesa Sandy Bridge
196   // Started Version: -1
197   // Ended Version: 11.1.2 for radeon, -1 for Sandy
198   // Mesa introduced geometry shader support for radeon and sandy bridge devices and failed to test
199   // it with us.
200   // Causes misrenderings on a large amount of things that draw lines.
201   BUG_BROKEN_GEOMETRY_SHADERS,
202 
203   // Bug: glGetBufferSubData for bounding box reads is slow on AMD drivers
204   // Started Version: -1
205   // Ended Version: -1
206   // Bounding box reads use glGetBufferSubData to read back the contents of the SSBO, but this is
207   // slow on AMD drivers, compared to
208   // using glMapBufferRange. glMapBufferRange is slower on Nvidia drivers, we suspect due to the
209   // first call moving the buffer from
210   // GPU memory to system memory. Use glMapBufferRange for BBox reads on AMD, and glGetBufferSubData
211   // everywhere else.
212   BUG_SLOW_GETBUFFERSUBDATA,
213 
214   // Bug: Broken lines in geometry shaders when writing to gl_ClipDistance in the vertex shader
215   // Affected Devices: Mesa i965
216   // Started Version: -1
217   // Ended Version: -1
218   // Writing to gl_ClipDistance in both the vertex shader and the geometry shader will break
219   // the geometry shader. Current workaround is to make sure the geometry shader always consumes
220   // the gl_ClipDistance inputs from the vertex shader.
221   BUG_BROKEN_CLIP_DISTANCE,
222 
223   // Bug: Dual-source outputs from fragment shaders are broken on AMD Vulkan drivers
224   // Started Version: -1
225   // Ended Version: -1
226   // Fragment shaders that specify dual-source outputs, via layout(location = 0, index = ...) cause
227   // the driver to fail to create graphics pipelines. The workaround for this is to specify the
228   // index as a MRT location instead, or omit the binding completely.
229   BUG_BROKEN_FRAGMENT_SHADER_INDEX_DECORATION,
230 
231   // Bug: Dual-source outputs from fragment shaders are broken on AMD OpenGL drivers
232   // Started Version: -1
233   // Ended Version: -1
234   // Fragment shaders that specify dual-source outputs, cause the driver to crash
235   // sometimes this happens in the kernel mode part of the driver resulting in a BSOD.
236   // Disable dual-source blending support for now.
237   BUG_BROKEN_DUAL_SOURCE_BLENDING,
238   // BUG: ImgTec GLSL shader compiler fails when negating the input to a bitwise operation
239   // Started version: 1.5
240   // Ended version: 1.8@4693462
241   // Shaders that do something like "variable <<= (-othervariable);" cause the shader to
242   // fail compilation with no useful diagnostic log. This can be worked around by storing
243   // the negated value to a temporary variable then using that in the bitwise op.
244   BUG_BROKEN_BITWISE_OP_NEGATION,
245 
246   // BUG: The GPU shader code appears to be context-specific on Mesa/i965.
247   // This means that if we compiled the ubershaders asynchronously, they will be recompiled
248   // on the main thread the first time they are used, causing stutter. For now, disable
249   // asynchronous compilation on Mesa i965. On nouveau, our use of glFinish() can cause
250   // crashes and/or lockups.
251   // Started version: -1
252   // Ended Version: -1
253   BUG_SHARED_CONTEXT_SHADER_COMPILATION,
254 
255   // Bug: Fast clears on a MSAA framebuffer can cause NVIDIA GPU resets/lockups.
256   // Started version: -1
257   // Ended version: -1
258   // Calling vkCmdClearAttachments with a partial rect, or specifying a render area in a
259   // render pass with the load op set to clear can cause the GPU to lock up, or raise a
260   // bounds violation. This only occurs on MSAA framebuffers, and it seems when there are
261   // multiple clears in a single command buffer. Worked around by back to the slow path
262   // (drawing quads) when MSAA is enabled.
263   BUG_BROKEN_MSAA_CLEAR,
264 
265   // BUG: Some vulkan implementations don't like the 'clear' loadop renderpass.
266   // For example, the ImgTec VK driver fails if you try to use a framebuffer with a different
267   // load/store op than that which it was created with, despite the spec saying they should be
268   // compatible.
269   // Started Version: 1.7
270   // Ended Version: 1.10
271   BUG_BROKEN_CLEAR_LOADOP_RENDERPASS,
272 
273   // BUG: 32-bit depth clears are broken in the Adreno Vulkan driver, and have no effect.
274   // To work around this, we use a D24_S8 buffer instead, which results in a loss of accuracy.
275   // We still resolve this to a R32F texture, as there is no 24-bit format.
276   // Started version: -1
277   // Ended version: -1
278   BUG_BROKEN_D32F_CLEAR,
279 
280   // BUG: Reversed viewport depth range does not work as intended on some Vulkan drivers.
281   // The Vulkan spec allows the minDepth/maxDepth fields in the viewport to be reversed,
282   // however the implementation is broken on some drivers.
283   BUG_BROKEN_REVERSED_DEPTH_RANGE,
284 
285   // BUG: Cached memory is significantly slower for readbacks than coherent memory in the
286   // Mali Vulkan driver, causing high CPU usage in the __pi___inval_cache_range kernel
287   // function. This flag causes readback buffers to select the coherent type.
288   BUG_SLOW_CACHED_READBACK_MEMORY,
289 
290   // BUG: GPU Texture Decoding produces a spectacular mess or just outright crashes when using
291   // Vulkan on macOS through MoltenVK.
292   BUG_BROKEN_GPU_TEXTURE_DECODING,
293 };
294 
295 // Initializes our internal vendor, device family, and driver version
296 void Init(API api, Vendor vendor, Driver driver, const double version, const Family family);
297 
298 // Once Vendor and driver version is set, this will return if it has the applicable bug passed to
299 // it.
300 bool HasBug(Bug bug);
301 }  // namespace DriverDetails
302