Blender V4.3
gl_backend.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "BKE_global.hh"
10#if defined(WIN32)
11# include "BLI_winstuff.h"
12#endif
13#include "BLI_subprocess.hh"
14#include "BLI_threads.h"
15#include "DNA_userdef_types.h"
16
19
20#include "gl_debug.hh"
21
22#include "gl_backend.hh"
23
24namespace blender::gpu {
25
26/* -------------------------------------------------------------------- */
30static bool match_renderer(StringRef renderer, const Vector<std::string> &items)
31{
32 for (const std::string &item : items) {
33 const std::string wrapped = " " + item + " ";
34 if (renderer.endswith(item) || renderer.find(wrapped) != StringRef::not_found) {
35 return true;
36 }
37 }
38 return false;
39}
40
41void GLBackend::platform_init()
42{
44
45 const char *vendor = (const char *)glGetString(GL_VENDOR);
46 const char *renderer = (const char *)glGetString(GL_RENDERER);
47 const char *version = (const char *)glGetString(GL_VERSION);
52
53#ifdef _WIN32
54 os = GPU_OS_WIN;
55#else
56 os = GPU_OS_UNIX;
57#endif
58
59 if (!vendor) {
60 printf("Warning: No OpenGL vendor detected.\n");
61 device = GPU_DEVICE_UNKNOWN;
62 driver = GPU_DRIVER_ANY;
63 }
64 else if (strstr(vendor, "ATI") || strstr(vendor, "AMD")) {
65 device = GPU_DEVICE_ATI;
66 driver = GPU_DRIVER_OFFICIAL;
67 }
68 else if (strstr(vendor, "NVIDIA")) {
69 device = GPU_DEVICE_NVIDIA;
70 driver = GPU_DRIVER_OFFICIAL;
71 }
72 else if (strstr(vendor, "Intel") ||
73 /* src/mesa/drivers/dri/intel/intel_context.c */
74 strstr(renderer, "Mesa DRI Intel") || strstr(renderer, "Mesa DRI Mobile Intel"))
75 {
76 device = GPU_DEVICE_INTEL;
77 driver = GPU_DRIVER_OFFICIAL;
78
79 if (strstr(renderer, "UHD Graphics") ||
80 /* Not UHD but affected by the same bugs. */
81 strstr(renderer, "HD Graphics 530") || strstr(renderer, "Kaby Lake GT2") ||
82 strstr(renderer, "Whiskey Lake"))
83 {
84 device |= GPU_DEVICE_INTEL_UHD;
85 }
86 }
87 else if (strstr(renderer, "Mesa DRI R") ||
88 (strstr(renderer, "Radeon") && strstr(vendor, "X.Org")) ||
89 (strstr(renderer, "AMD") && strstr(vendor, "X.Org")) ||
90 (strstr(renderer, "Gallium ") && strstr(renderer, " on ATI ")) ||
91 (strstr(renderer, "Gallium ") && strstr(renderer, " on AMD ")))
92 {
93 device = GPU_DEVICE_ATI;
94 driver = GPU_DRIVER_OPENSOURCE;
95 }
96 else if (strstr(renderer, "Nouveau") || strstr(vendor, "nouveau")) {
97 device = GPU_DEVICE_NVIDIA;
98 driver = GPU_DRIVER_OPENSOURCE;
99 }
100 else if (strstr(vendor, "Mesa")) {
101 device = GPU_DEVICE_SOFTWARE;
102 driver = GPU_DRIVER_SOFTWARE;
103 }
104 else if (strstr(vendor, "Microsoft")) {
105 /* Qualcomm devices use Mesa's GLOn12, which claims to be vended by Microsoft */
106 if (strstr(renderer, "Qualcomm")) {
107 device = GPU_DEVICE_QUALCOMM;
108 driver = GPU_DRIVER_OFFICIAL;
109 }
110 else {
111 device = GPU_DEVICE_SOFTWARE;
112 driver = GPU_DRIVER_SOFTWARE;
113 }
114 }
115 else if (strstr(vendor, "Apple")) {
116 /* Apple Silicon. */
117 device = GPU_DEVICE_APPLE;
118 driver = GPU_DRIVER_OFFICIAL;
119 }
120 else if (strstr(renderer, "Apple Software Renderer")) {
121 device = GPU_DEVICE_SOFTWARE;
122 driver = GPU_DRIVER_SOFTWARE;
123 }
124 else if (strstr(renderer, "llvmpipe") || strstr(renderer, "softpipe")) {
125 device = GPU_DEVICE_SOFTWARE;
126 driver = GPU_DRIVER_SOFTWARE;
127 }
128 else {
129 printf("Warning: Could not find a matching GPU name. Things may not behave as expected.\n");
130 printf("Detected OpenGL configuration:\n");
131 printf("Vendor: %s\n", vendor);
132 printf("Renderer: %s\n", renderer);
133 }
134
135 /* Detect support level */
136 if (!(epoxy_gl_version() >= 43)) {
137 support_level = GPU_SUPPORT_LEVEL_UNSUPPORTED;
138 }
139 else {
140#if defined(WIN32)
141 long long driverVersion = 0;
142 if (device & GPU_DEVICE_QUALCOMM) {
143 if (BLI_windows_get_directx_driver_version(L"Qualcomm(R) Adreno(TM)", &driverVersion)) {
144 /* Parse out the driver version in format x.x.x.x */
145 WORD ver0 = (driverVersion >> 48) & 0xffff;
146 WORD ver1 = (driverVersion >> 32) & 0xffff;
147 WORD ver2 = (driverVersion >> 16) & 0xffff;
148
149 /* Any Qualcomm driver older than 30.x.x.x will never capable of running blender >= 4.0
150 * As due to an issue in D3D typed UAV load capabilities, Compute Shaders are not available
151 * 30.0.3820.x and above are capable of running blender >=4.0, but these drivers
152 * are only available on 8cx gen3 devices or newer */
153 if (ver0 < 30 || (ver0 == 30 && ver1 == 0 && ver2 < 3820)) {
154 std::cout
155 << "=====================================\n"
156 << "Qualcomm drivers older than 30.0.3820.x are not capable of running Blender 4.0\n"
157 << "If your device is older than an 8cx Gen3, you must use a 3.x LTS release.\n"
158 << "If you have an 8cx Gen3 or newer device, a driver update may be available.\n"
159 << "=====================================\n";
160 support_level = GPU_SUPPORT_LEVEL_UNSUPPORTED;
161 }
162 }
163 }
164#endif
165 if ((device & GPU_DEVICE_INTEL) && (os & GPU_OS_WIN)) {
166 /* Old Intel drivers with known bugs that cause material properties to crash.
167 * Version Build 10.18.14.5067 is the latest available and appears to be working
168 * ok with our workarounds, so excluded from this list. */
169 if (strstr(version, "Build 7.14") || strstr(version, "Build 7.15") ||
170 strstr(version, "Build 8.15") || strstr(version, "Build 9.17") ||
171 strstr(version, "Build 9.18") || strstr(version, "Build 10.18.10.3") ||
172 strstr(version, "Build 10.18.10.4") || strstr(version, "Build 10.18.10.5") ||
173 strstr(version, "Build 10.18.14.4"))
174 {
175 support_level = GPU_SUPPORT_LEVEL_LIMITED;
176 }
177 /* A rare GPU that has z-fighting issues in edit mode. (see #128179) */
178 if (strstr(renderer, "HD Graphics 405")) {
179 support_level = GPU_SUPPORT_LEVEL_LIMITED;
180 }
181 /* Latest Intel driver have bugs that won't allow Blender to start.
182 * Users must install different version of the driver.
183 * See #113124 for more information. */
184 if (strstr(version, "Build 20.19.15.51")) {
185 support_level = GPU_SUPPORT_LEVEL_UNSUPPORTED;
186 }
187 }
188 if ((device & GPU_DEVICE_ATI) && (os & GPU_OS_UNIX)) {
189 /* Platform seems to work when SB backend is disabled. This can be done
190 * by adding the environment variable `R600_DEBUG=nosb`. */
191 if (strstr(renderer, "AMD CEDAR")) {
192 support_level = GPU_SUPPORT_LEVEL_LIMITED;
193 }
194 }
195
196 /* Check SSBO bindings requirement. */
197 GLint max_ssbo_binds_vertex;
198 GLint max_ssbo_binds_fragment;
199 GLint max_ssbo_binds_compute;
200 glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &max_ssbo_binds_vertex);
201 glGetIntegerv(GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS, &max_ssbo_binds_fragment);
202 glGetIntegerv(GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS, &max_ssbo_binds_compute);
203 GLint max_ssbo_binds = min_iii(
204 max_ssbo_binds_vertex, max_ssbo_binds_fragment, max_ssbo_binds_compute);
205 if (max_ssbo_binds < 12) {
206 std::cout << "Warning: Unsupported platform as it supports max " << max_ssbo_binds
207 << " SSBO binding locations\n";
208 support_level = GPU_SUPPORT_LEVEL_UNSUPPORTED;
209 }
210 }
211
212 /* Compute shaders have some issues with those versions (see #94936). */
213 if ((device & GPU_DEVICE_ATI) && (driver & GPU_DRIVER_OFFICIAL) &&
214 (strstr(version, "4.5.14831") || strstr(version, "4.5.14760")))
215 {
216 support_level = GPU_SUPPORT_LEVEL_UNSUPPORTED;
217 }
218
219 GPG.init(device,
220 os,
221 driver,
222 support_level,
224 vendor,
225 renderer,
226 version,
228}
229
230void GLBackend::platform_exit()
231{
233 GPG.clear();
234}
235
238/* -------------------------------------------------------------------- */
243{
244 int cube_size = 2;
245 float clear_color[4] = {1.0f, 0.5f, 0.0f, 0.0f};
246 float *source_pix = (float *)MEM_callocN(sizeof(float[4]) * cube_size * cube_size * 6, __func__);
247
248 /* NOTE: Debug layers are not yet enabled. Force use of glGetError. */
249 debug::check_gl_error("Cubemap Workaround Start");
250 /* Not using GPU API since it is not yet fully initialized. */
251 GLuint tex, fb;
252 /* Create cubemap with 2 mip level. */
253 glGenTextures(1, &tex);
254 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
255 for (int mip = 0; mip < 2; mip++) {
256 for (int i = 0; i < 6; i++) {
257 const int width = cube_size / (1 << mip);
258 GLenum target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;
259 glTexImage2D(target, mip, GL_RGBA16F, width, width, 0, GL_RGBA, GL_FLOAT, source_pix);
260 }
261 }
262 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BASE_LEVEL, 0);
263 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, 0);
264 /* Attach and clear mip 1. */
265 glGenFramebuffers(1, &fb);
266 glBindFramebuffer(GL_FRAMEBUFFER, fb);
267 glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex, 1);
268 glDrawBuffer(GL_COLOR_ATTACHMENT0);
269 glClearColor(UNPACK4(clear_color));
270 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
271 glClear(GL_COLOR_BUFFER_BIT);
272 glBindFramebuffer(GL_FRAMEBUFFER, 0);
273
274 /* Read mip 1. If color is not the same as the clear_color, the rendering failed. */
275 glGetTexImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 1, GL_RGBA, GL_FLOAT, source_pix);
276 bool enable_workaround = !equals_v4v4(clear_color, source_pix);
277 MEM_freeN(source_pix);
278
279 glDeleteFramebuffers(1, &fb);
280 glDeleteTextures(1, &tex);
281
282 debug::check_gl_error("Cubemap Workaround End9");
283
284 return enable_workaround;
285}
286
287static const char *gl_extension_get(int i)
288{
289 return (char *)glGetStringi(GL_EXTENSIONS, i);
290}
291
293{
294 const char *vendor = (const char *)glGetString(GL_VENDOR);
295 const char *renderer = (const char *)glGetString(GL_RENDERER);
296 const char *version = (const char *)glGetString(GL_VERSION);
297
298 if (G.debug & G_DEBUG_GPU_FORCE_WORKAROUNDS) {
299 printf("\n");
300 printf("GL: Forcing workaround usage and disabling extensions.\n");
301 printf(" OpenGL identification strings\n");
302 printf(" vendor: %s\n", vendor);
303 printf(" renderer: %s\n", renderer);
304 printf(" version: %s\n\n", version);
309 /* Turn off Blender features. */
311 /* Turn off OpenGL 4.4 features. */
315 /* Turn off OpenGL 4.5 features. */
317 /* Turn off OpenGL 4.6 features. */
321 /* Although an OpenGL 4.3 feature, our implementation requires shader_draw_parameters_support.
322 * NOTE: we should untangle this by checking both features for clarity. */
324 /* Turn off extensions. */
326 /* Turn off vendor specific extensions. */
331
332#if 0
333 /* Do not alter OpenGL 4.3 features.
334 * These code paths should be removed. */
336#endif
337
338 return;
339 }
340
341 /* Only use main context when running inside RenderDoc.
342 * RenderDoc requires that all calls are* from the same context. */
343 if (G.debug & G_DEBUG_GPU_RENDERDOC) {
345 }
346
348 (strstr(version, "4.5.13399") || strstr(version, "4.5.13417") ||
349 strstr(version, "4.5.13422") || strstr(version, "4.5.13467")))
350 {
351 /* The renderers include:
352 * Radeon HD 5000;
353 * Radeon HD 7500M;
354 * Radeon HD 7570M;
355 * Radeon HD 7600M;
356 * Radeon R5 Graphics;
357 * And others... */
362 }
363 /* We have issues with this specific renderer. (see #74024) */
365 (strstr(renderer, "AMD VERDE") || strstr(renderer, "AMD KAVERI") ||
366 strstr(renderer, "AMD TAHITI")))
367 {
371 }
372 /* Fix slowdown on this particular driver. (see #77641) */
374 strstr(version, "Mesa 19.3.4"))
375 {
378 }
379 /* See #82856: AMD drivers since 20.11 running on a polaris architecture doesn't support the
380 * `GL_INT_2_10_10_10_REV` data type correctly. This data type is used to pack normals and flags.
381 * The work around uses `GPU_RGBA16I`. In 22.?.? drivers this has been fixed for
382 * polaris platform. Keeping legacy platforms around just in case.
383 */
385 /* Check for AMD legacy driver. Assuming that when these drivers are used this bug is present.
386 */
387 if (strstr(version, " 22.6.1 ") || strstr(version, " 21.Q1.2 ") ||
388 strstr(version, " 21.Q2.1 "))
389 {
391 }
392 const Vector<std::string> matches = {
393 "RX550/550", "(TM) 520", "(TM) 530", "(TM) 535", "R5", "R7", "R9", "HD"};
394
395 if (match_renderer(renderer, matches)) {
397 }
398 }
399 /* Special fix for these specific GPUs.
400 * Without this workaround, blender crashes on startup. (see #72098) */
402 (strstr(renderer, "HD Graphics 620") || strstr(renderer, "HD Graphics 630")))
403 {
405 }
406 /* Maybe not all of these drivers have problems with `GL_ARB_base_instance`.
407 * But it's hard to test each case.
408 * We get crashes from some crappy Intel drivers don't work well with shaders created in
409 * different rendering contexts. */
411 (strstr(version, "Build 10.18.10.3") || strstr(version, "Build 10.18.10.4") ||
412 strstr(version, "Build 10.18.10.5") || strstr(version, "Build 10.18.14.4") ||
413 strstr(version, "Build 10.18.14.5")))
414 {
416 }
417 /* Somehow fixes armature display issues (see #69743). */
419 strstr(version, "Build 20.19.15.4285"))
420 {
422 }
423 /* See #70187: merging vertices fail. This has been tested from `18.2.2` till `19.3.0~dev`
424 * of the Mesa driver */
426 (strstr(version, "Mesa 18.") || strstr(version, "Mesa 19.0") ||
427 strstr(version, "Mesa 19.1") || strstr(version, "Mesa 19.2")))
428 {
430 }
431 /* dFdx/dFdy calculation factors, those are dependent on driver. */
432 if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY) && strstr(version, "3.3.10750"))
433 {
436 }
438 if (strstr(version, "4.0.0 - Build 10.18.10.3308") ||
439 strstr(version, "4.0.0 - Build 9.18.10.3186") ||
440 strstr(version, "4.0.0 - Build 9.18.10.3165") ||
441 strstr(version, "3.1.0 - Build 9.17.10.3347") ||
442 strstr(version, "3.1.0 - Build 9.17.10.4101") ||
443 strstr(version, "3.3.0 - Build 8.15.10.2618"))
444 {
447 }
448 }
449
450 /* Draw shader parameters are broken on Qualcomm Windows ARM64 devices
451 * on Mesa version < 24.0.0 */
453 if (strstr(version, "Mesa 20.") || strstr(version, "Mesa 21.") ||
454 strstr(version, "Mesa 22.") || strstr(version, "Mesa 23."))
455 {
458 }
459 }
460
461/* Snapdragon X Elite devices currently have a driver bug that results in
462 * eevee rendering a black cube with anything except an emission shader
463 * if shader draw parameters are enabled (#122837) */
464#if defined(WIN32)
465 long long driverVersion = 0;
467 if (BLI_windows_get_directx_driver_version(L"Qualcomm(R) Adreno(TM)", &driverVersion)) {
468 /* Parse out the driver version */
469 WORD ver0 = (driverVersion >> 48) & 0xffff;
470
471 /* X Elite devices have GPU driver version 31, and currently no known release version of the
472 * GPU driver renders the cube correctly. This will be changed when a working driver version
473 * is released to commercial devices to only enable this flags on older drivers. */
474 if (ver0 == 31) {
476 }
477 }
478 }
479#endif
480
481 /* Some Intel drivers have issues with using mips as frame-buffer targets if
482 * GL_TEXTURE_MAX_LEVEL is higher than the target MIP.
483 * Only check at the end after all other workarounds because this uses the drawing code.
484 * Also after device/driver flags to avoid the check that causes pre GCN Radeon to crash. */
485 if (GCaps.mip_render_workaround == false) {
487 }
488 /* Disable multi-draw if the base instance cannot be read. */
491 }
492 /* Enable our own incomplete debug layer if no other is available. */
493 if (GLContext::debug_layer_support == false) {
495 }
496
497 /* There is an issue in AMD official driver where we cannot use multi bind when using images. AMD
498 * is aware of the issue, but hasn't released a fix. */
501 }
502
503 /* #107642, #120273 Windows Intel iGPU (multiple generations) incorrectly report that
504 * they support image binding. But when used it results into `GL_INVALID_OPERATION` with
505 * `internal format of texture N is not supported`. */
508 }
509
510 /* Multi viewport creates small triangle discard on RDNA2 GPUs with official drivers.
511 * Using geometry shader workaround fixes the issue. */
513 if (strstr(renderer, "RX 6300") || strstr(renderer, "RX 6400") ||
514 strstr(renderer, "RX 6450") || strstr(renderer, "RX 6500") ||
515 strstr(renderer, "RX 6550") || strstr(renderer, "RX 6600") ||
516 strstr(renderer, "RX 6650") || strstr(renderer, "RX 6700") ||
517 strstr(renderer, "RX 6750") || strstr(renderer, "RX 6800") ||
518 strstr(renderer, "RX 6850") || strstr(renderer, "RX 6900") ||
519 strstr(renderer, "RX 6950") || strstr(renderer, "W6300") || strstr(renderer, "W6400") ||
520 strstr(renderer, "W6500") || strstr(renderer, "W6600") ||
521 /* NOTE: `W6700` was never released, so it's not in this list. */
522 strstr(renderer, "W6800") || strstr(renderer, "W6900"))
523 {
525 }
526 }
527
528 /* Metal-related Workarounds. */
529
530 /* Minimum Per-Vertex stride is 1 byte for OpenGL. */
532}
533
540
557
563float GLContext::derivative_signs[2] = {1.0f, 1.0f};
564
565void GLBackend::capabilities_init()
566{
567 BLI_assert(epoxy_gl_version() >= 33);
568 /* Common Capabilities. */
569 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &GCaps.max_texture_size);
570 glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &GCaps.max_texture_layers);
571 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &GCaps.max_textures_frag);
572 glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &GCaps.max_textures_vert);
573 glGetIntegerv(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, &GCaps.max_textures_geom);
574 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &GCaps.max_textures);
575 glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &GCaps.max_uniforms_vert);
576 glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &GCaps.max_uniforms_frag);
577 glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &GCaps.max_batch_indices);
578 glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &GCaps.max_batch_vertices);
579 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &GCaps.max_vertex_attribs);
580 glGetIntegerv(GL_MAX_VARYING_FLOATS, &GCaps.max_varying_floats);
581 glGetIntegerv(GL_MAX_IMAGE_UNITS, &GCaps.max_images);
582
583 glGetIntegerv(GL_NUM_EXTENSIONS, &GCaps.extensions_len);
585
587 GCaps.mem_stats_support = epoxy_has_gl_extension("GL_NVX_gpu_memory_info") ||
588 epoxy_has_gl_extension("GL_ATI_meminfo");
589 GCaps.shader_draw_parameters_support = epoxy_has_gl_extension("GL_ARB_shader_draw_parameters");
593
594 glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 0, &GCaps.max_work_group_count[0]);
595 glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 1, &GCaps.max_work_group_count[1]);
596 glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 2, &GCaps.max_work_group_count[2]);
597 glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 0, &GCaps.max_work_group_size[0]);
598 glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 1, &GCaps.max_work_group_size[1]);
599 glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 2, &GCaps.max_work_group_size[2]);
600 glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &GCaps.max_shader_storage_buffer_bindings);
601 glGetIntegerv(GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS, &GCaps.max_compute_shader_storage_blocks);
602 int64_t max_ssbo_size;
603 glGetInteger64v(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &max_ssbo_size);
604 GCaps.max_storage_buffer_size = size_t(max_ssbo_size);
605
607 GCaps.texture_view_support = epoxy_gl_version() >= 43 ||
608 epoxy_has_gl_extension("GL_ARB_texture_view");
609 GCaps.stencil_export_support = epoxy_has_gl_extension("GL_ARB_shader_stencil_export");
610
611 /* GL specific capabilities. */
612 glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &GCaps.max_texture_3d_size);
613 glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &GLContext::max_cubemap_size);
614 glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, &GLContext::max_ubo_binds);
615 glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &GLContext::max_ubo_size);
616 GLint max_ssbo_binds;
618 glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &max_ssbo_binds);
620 glGetIntegerv(GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS, &max_ssbo_binds);
622 glGetIntegerv(GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS, &max_ssbo_binds);
624 GLContext::clear_texture_support = epoxy_has_gl_extension("GL_ARB_clear_texture");
625 GLContext::debug_layer_support = epoxy_gl_version() >= 43 ||
626 epoxy_has_gl_extension("GL_KHR_debug") ||
627 epoxy_has_gl_extension("GL_ARB_debug_output");
628 GLContext::direct_state_access_support = epoxy_has_gl_extension("GL_ARB_direct_state_access");
629 GLContext::explicit_location_support = epoxy_gl_version() >= 43;
630 GLContext::framebuffer_fetch_support = epoxy_has_gl_extension("GL_EXT_shader_framebuffer_fetch");
631 GLContext::texture_barrier_support = epoxy_has_gl_extension("GL_ARB_texture_barrier");
632 GLContext::layered_rendering_support = epoxy_has_gl_extension(
633 "GL_ARB_shader_viewport_layer_array");
634 GLContext::native_barycentric_support = epoxy_has_gl_extension(
635 "GL_AMD_shader_explicit_vertex_parameter");
637 "GL_ARB_multi_bind");
638 GLContext::multi_draw_indirect_support = epoxy_has_gl_extension("GL_ARB_multi_draw_indirect");
639 GLContext::shader_draw_parameters_support = epoxy_has_gl_extension(
640 "GL_ARB_shader_draw_parameters");
641 GLContext::stencil_texturing_support = epoxy_gl_version() >= 43;
642 GLContext::texture_filter_anisotropic_support = epoxy_has_gl_extension(
643 "GL_EXT_texture_filter_anisotropic");
644
645 /* Disabled until it is proven to work. */
647
649
650#if BLI_SUBPROCESS_SUPPORT
652 GCaps.max_parallel_compilations = std::min(int(U.max_shader_compilation_subprocesses),
654 }
655 if (G.debug & G_DEBUG_GPU_RENDERDOC) {
656 /* Avoid crashes on RenderDoc sessions. */
658 }
659#else
661#endif
662
663 /* Disable this feature entirely when not debugging. */
664 if ((G.debug & G_DEBUG_GPU) == 0) {
667 }
668}
669
672} // namespace blender::gpu
@ G_DEBUG_GPU
@ G_DEBUG_GPU_FORCE_WORKAROUNDS
@ G_DEBUG_GPU_RENDERDOC
#define BLI_assert(a)
Definition BLI_assert.h:50
MINLINE int min_ii(int a, int b)
MINLINE int min_iii(int a, int b, int c)
MINLINE bool equals_v4v4(const float v1[4], const float v2[4]) ATTR_WARN_UNUSED_RESULT
int BLI_system_thread_count(void)
Definition threads.cc:253
#define UNPACK4(a)
Compatibility-like things for windows.
bool BLI_windows_get_directx_driver_version(const wchar_t *deviceSubString, long long *r_driverVersion)
eGPUDriverType
@ GPU_DRIVER_ANY
@ GPU_DRIVER_OFFICIAL
@ GPU_DRIVER_OPENSOURCE
@ GPU_DRIVER_SOFTWARE
@ GPU_ARCHITECTURE_IMR
eGPUSupportLevel
@ GPU_SUPPORT_LEVEL_LIMITED
@ GPU_SUPPORT_LEVEL_SUPPORTED
@ GPU_SUPPORT_LEVEL_UNSUPPORTED
eGPUOSType
@ GPU_OS_WIN
@ GPU_OS_UNIX
@ GPU_OS_ANY
eGPUDeviceType
@ GPU_DEVICE_UNKNOWN
@ GPU_DEVICE_ATI
@ GPU_DEVICE_INTEL_UHD
@ GPU_DEVICE_QUALCOMM
@ GPU_DEVICE_SOFTWARE
@ GPU_DEVICE_NVIDIA
@ GPU_DEVICE_ANY
@ GPU_DEVICE_APPLE
@ GPU_DEVICE_INTEL
bool GPU_type_matches(eGPUDeviceType device, eGPUOSType os, eGPUDriverType driver)
unsigned int U
Definition btGjkEpa3.h:78
static constexpr int64_t not_found
constexpr int64_t find(char c, int64_t pos=0) const
constexpr bool endswith(StringRef suffix) const
static bool stencil_texturing_support
Definition gl_context.hh:61
static bool layered_rendering_support
Definition gl_context.hh:55
static bool debug_layer_support
Definition gl_context.hh:51
static bool framebuffer_fetch_support
Definition gl_context.hh:54
static bool shader_draw_parameters_support
Definition gl_context.hh:60
static bool explicit_location_support
Definition gl_context.hh:53
static GLint max_ssbo_binds
Definition gl_context.hh:46
static bool debug_layer_workaround
Definition gl_context.hh:67
static float derivative_signs[2]
Definition gl_context.hh:70
static GLint max_ubo_binds
Definition gl_context.hh:45
static GLint max_ubo_size
Definition gl_context.hh:44
static bool direct_state_access_support
Definition gl_context.hh:52
static bool texture_filter_anisotropic_support
Definition gl_context.hh:63
static bool clear_texture_support
Definition gl_context.hh:50
static bool unused_fb_slot_workaround
Definition gl_context.hh:68
static bool multi_bind_support
Definition gl_context.hh:57
static GLint max_cubemap_size
Definition gl_context.hh:43
static bool texture_barrier_support
Definition gl_context.hh:62
static bool native_barycentric_support
Definition gl_context.hh:56
static bool multi_bind_image_support
Definition gl_context.hh:58
static bool generate_mipmap_workaround
Definition gl_context.hh:69
static bool multi_draw_indirect_support
Definition gl_context.hh:59
void init(eGPUDeviceType gpu_device, eGPUOSType os_type, eGPUDriverType driver_type, eGPUSupportLevel gpu_support_level, eGPUBackendType backend, const char *vendor_str, const char *renderer_str, const char *version_str, GPUArchitectureType arch_type)
#define printf
BLI_INLINE float fb(float length, float L)
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
void *(* MEM_callocN)(size_t len, const char *str)
Definition mallocn.cc:42
#define L
#define G(x, y, z)
void check_gl_error(const char *info)
Definition gl_debug.cc:182
GPUPlatformGlobal GPG
static void detect_workarounds()
GPUCapabilities GCaps
static const char * gl_extension_get(int i)
static bool detect_mip_render_workaround()
static bool match_renderer(StringRef renderer, const Vector< std::string > &items)
Definition gl_backend.cc:30
__int64 int64_t
Definition stdint.h:89