42 for (
const std::string &item : items) {
43 const std::string wrapped =
" " + item +
" ";
56 std::string subversion;
60 if (std::isdigit(version[
v])) {
62 subversion.push_back(version[
v]);
66 match = version[
v] ==
format[f];
67 if (!subversion.empty()) {
68 r_version.
append(std::stoi(subversion));
93 std::string version_str = version_cstr;
95 version_str.push_back(
' ');
106 return version[0] < 23;
109 if (
parse_version(version_str,
" 00.00.00000.00000 ", version) ||
113 return version[0] < 31 || (version[0] == 31 && version[2] < 21001);
120void GLBackend::platform_init()
124 const char *vendor = (
const char *)glGetString(GL_VENDOR);
125 const char *renderer = (
const char *)glGetString(GL_RENDERER);
126 const char *version = (
const char *)glGetString(GL_VERSION);
139 printf(
"Warning: No OpenGL vendor detected.\n");
143 else if (strstr(renderer,
"Mesa DRI R") ||
144 (strstr(renderer,
"Radeon") && (strstr(vendor,
"X.Org") || strstr(version,
"Mesa"))) ||
145 (strstr(renderer,
"AMD") && (strstr(vendor,
"X.Org") || strstr(version,
"Mesa"))) ||
146 (strstr(renderer,
"Gallium ") && strstr(renderer,
" on ATI ")) ||
147 (strstr(renderer,
"Gallium ") && strstr(renderer,
" on AMD ")))
152 else if (strstr(vendor,
"ATI") || strstr(vendor,
"AMD")) {
156 else if (strstr(vendor,
"NVIDIA")) {
160 else if (strstr(vendor,
"Intel") ||
162 strstr(renderer,
"Mesa DRI Intel") || strstr(renderer,
"Mesa DRI Mobile Intel"))
167 if (strstr(renderer,
"UHD Graphics") ||
169 strstr(renderer,
"HD Graphics 530") || strstr(renderer,
"Kaby Lake GT2") ||
170 strstr(renderer,
"Whiskey Lake"))
175 else if (strstr(renderer,
"Nouveau") || strstr(vendor,
"nouveau")) {
179 else if (strstr(vendor,
"Mesa")) {
183 else if (strstr(vendor,
"Microsoft")) {
185 if (strstr(renderer,
"Qualcomm")) {
194 else if (strstr(vendor,
"Apple")) {
199 else if (strstr(renderer,
"Apple Software Renderer")) {
203 else if (strstr(renderer,
"llvmpipe") || strstr(renderer,
"softpipe")) {
208 printf(
"Warning: Could not find a matching GPU name. Things may not behave as expected.\n");
209 printf(
"Detected OpenGL configuration:\n");
210 printf(
"Vendor: %s\n", vendor);
211 printf(
"Renderer: %s\n", renderer);
215 if (!(epoxy_gl_version() >= 43)) {
220 long long driverVersion = 0;
224 WORD ver0 = (driverVersion >> 48) & 0xffff;
225 WORD ver1 = (driverVersion >> 32) & 0xffff;
226 WORD ver2 = (driverVersion >> 16) & 0xffff;
232 if (ver0 < 30 || (ver0 == 30 && ver1 == 0 && ver2 < 3820)) {
234 <<
"=====================================\n"
235 <<
"Qualcomm drivers older than 30.0.3820.x cannot run Blender 4.0 or later.\n"
236 <<
"If your device is older than an 8cx Gen3, you must use a 3.x LTS release.\n"
237 <<
"If you have an 8cx Gen3 or newer device, a driver update may be available.\n"
238 <<
"=====================================\n";
248 if (strstr(version,
"Build 7.14") || strstr(version,
"Build 7.15") ||
249 strstr(version,
"Build 8.15") || strstr(version,
"Build 9.17") ||
250 strstr(version,
"Build 9.18") || strstr(version,
"Build 10.18.10.3") ||
251 strstr(version,
"Build 10.18.10.4") || strstr(version,
"Build 10.18.10.5") ||
252 strstr(version,
"Build 10.18.14.4"))
257 if (strstr(renderer,
"HD Graphics 405")) {
263 if (strstr(version,
"Build 20.19.15.51")) {
270 if (strstr(renderer,
"AMD CEDAR")) {
275 if (strstr(version,
"Mesa 20.") || strstr(version,
"Mesa 21.") ||
276 strstr(version,
"Mesa 22.") || strstr(version,
"Mesa 23."))
278 std::cerr <<
"Unsupported driver. Requires at least Mesa 24.0.0." << std::endl;
284 GLint max_ssbo_binds_vertex;
285 GLint max_ssbo_binds_fragment;
286 GLint max_ssbo_binds_compute;
287 glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &max_ssbo_binds_vertex);
288 glGetIntegerv(GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS, &max_ssbo_binds_fragment);
289 glGetIntegerv(GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS, &max_ssbo_binds_compute);
290 GLint max_ssbo_binds =
min_iii(
291 max_ssbo_binds_vertex, max_ssbo_binds_fragment, max_ssbo_binds_compute);
292 if (max_ssbo_binds < 12) {
293 std::cout <<
"Warning: Unsupported platform as it supports max " << max_ssbo_binds
294 <<
" SSBO binding locations\n";
298 if (!epoxy_has_gl_extension(
"GL_ARB_shader_draw_parameters")) {
299 std::cout <<
"Error: The OpenGL implementation doesn't support ARB_shader_draw_parameters\n";
303 if (!epoxy_has_gl_extension(
"GL_ARB_clip_control")) {
304 std::cout <<
"Error: The OpenGL implementation doesn't support ARB_clip_control\n";
311 (strstr(version,
"4.5.14831") || strstr(version,
"4.5.14760")))
330 if (epoxy_has_gl_extension(
"GL_EXT_memory_object")) {
331 GLint number_of_devices = 0;
332 glGetIntegerv(GL_NUM_DEVICE_UUIDS_EXT, &number_of_devices);
337 GLubyte device_uuid[GL_UUID_SIZE_EXT] = {0};
338 glGetUnsignedBytei_vEXT(GL_DEVICE_UUID_EXT, 0, device_uuid);
339 GPG.
device_uuid = Array<uint8_t, 16>(Span<uint8_t>(device_uuid, GL_UUID_SIZE_EXT));
342 if (epoxy_has_gl_extension(
"GL_EXT_memory_object_win32") && (os &
GPU_OS_WIN)) {
343 GLubyte device_luid[GL_LUID_SIZE_EXT] = {0};
344 glGetUnsignedBytevEXT(GL_DEVICE_LUID_EXT, device_luid);
345 GPG.
device_luid = Array<uint8_t, 8>(Span<uint8_t>(device_luid, GL_LUID_SIZE_EXT));
348 glGetIntegerv(GL_DEVICE_NODE_MASK_EXT, &node_mask);
354void GLBackend::platform_exit()
368 return (
char *)glGetStringi(GL_EXTENSIONS,
i);
373 const char *vendor = (
const char *)glGetString(GL_VENDOR);
374 const char *renderer = (
const char *)glGetString(GL_RENDERER);
375 const char *version = (
const char *)glGetString(GL_VERSION);
379 printf(
"GL: Forcing workaround usage and disabling extensions.\n");
380 printf(
" OpenGL identification strings\n");
381 printf(
" vendor: %s\n", vendor);
382 printf(
" renderer: %s\n", renderer);
383 printf(
" version: %s\n\n", version);
384 GCaps.depth_blitting_workaround =
true;
385 GCaps.stencil_clasify_buffer_workaround =
true;
388 GCaps.hdr_viewport_support =
false;
402 GCaps.stencil_export_support =
false;
414 (strstr(version,
"4.5.13399") || strstr(version,
"4.5.13417") ||
415 strstr(version,
"4.5.13422") || strstr(version,
"4.5.13467")))
428 (strstr(renderer,
"AMD VERDE") || strstr(renderer,
"AMD KAVERI") ||
429 strstr(renderer,
"AMD TAHITI")))
442 GCaps.use_hq_normals_workaround =
true;
445 "RX550/550",
"(TM) 520",
"(TM) 530",
"(TM) 535",
"R5",
"R7",
"R9",
"HD"};
448 GCaps.use_hq_normals_workaround =
true;
457 (strstr(version,
"Build 10.18.10.3") || strstr(version,
"Build 10.18.10.4") ||
458 strstr(version,
"Build 10.18.10.5") || strstr(version,
"Build 10.18.14.4") ||
459 strstr(version,
"Build 10.18.14.5")))
461 GCaps.use_main_context_workaround =
true;
465 strstr(version,
"Build 20.19.15.4285"))
467 GCaps.use_main_context_workaround =
true;
473 GCaps.use_main_context_workaround =
true;
478 (strstr(version,
"Mesa 18.") || strstr(version,
"Mesa 19.0") ||
479 strstr(version,
"Mesa 19.1") || strstr(version,
"Mesa 19.2")))
488 long long driverVersion = 0;
492 WORD ver0 = (driverVersion >> 48) & 0xffff;
498 GCaps.stencil_clasify_buffer_workaround =
true;
525 GCaps.minimum_per_vertex_stride = 1;
554void GLBackend::capabilities_init()
577 epoxy_has_gl_extension(
"GL_ATI_meminfo");
590 int64_t max_ssbo_size, max_ubo_size;
591 glGetInteger64v(GL_MAX_UNIFORM_BLOCK_SIZE, &max_ubo_size);
593 glGetInteger64v(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &max_ssbo_size);
595 GLint ssbo_alignment;
596 glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, &ssbo_alignment);
603 glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE,
607 GLint max_ssbo_binds;
609 glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &max_ssbo_binds);
611 glGetIntegerv(GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS, &max_ssbo_binds);
613 glGetIntegerv(GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS, &max_ssbo_binds);
616 epoxy_has_gl_extension(
"GL_KHR_debug") ||
617 epoxy_has_gl_extension(
"GL_ARB_debug_output");
623 "GL_ARB_shader_viewport_layer_array");
625 "GL_AMD_shader_explicit_vertex_parameter");
627 "GL_ARB_multi_bind");
630 "GL_EXT_texture_filter_anisotropic");
637#if BLI_SUBPROCESS_SUPPORT
648 int thread_count =
U.gpu_shader_workers;
650 if (thread_count == 0) {
@ G_DEBUG_GPU_FORCE_WORKAROUNDS
MINLINE int min_ii(int a, int b)
MINLINE int min_iii(int a, int b, int c)
int BLI_system_thread_count(void)
Compatibility-like things for windows.
bool BLI_windows_get_directx_driver_version(const wchar_t *deviceSubString, long long *r_driverVersion)
@ USER_SHADER_COMPILE_SUBPROCESS
ATTR_WARN_UNUSED_RESULT const BMVert * v
void reinitialize(const int64_t new_size)
static constexpr int64_t not_found
constexpr int64_t find(char c, int64_t pos=0) const
constexpr bool endswith(StringRef suffix) const
void append(const T &value)
static bool stencil_texturing_support
static bool layered_rendering_support
static bool debug_layer_support
static bool framebuffer_fetch_support
static bool explicit_location_support
static GLint max_ssbo_binds
static bool debug_layer_workaround
static GLint max_ubo_binds
static bool direct_state_access_support
static bool texture_filter_anisotropic_support
static bool unused_fb_slot_workaround
static bool multi_bind_support
static GLint max_cubemap_size
static bool texture_barrier_support
static bool native_barycentric_support
static bool multi_bind_image_support
static bool generate_mipmap_workaround
static bool parse_version(const std::string &version, const std::string &format, Vector< int > &r_version)
static void detect_workarounds()
static bool is_bad_AMD_driver(const char *version_cstr)
static const char * gl_extension_get(int i)
static bool match_renderer(StringRef renderer, const Vector< std::string > &items)
int max_shader_storage_buffer_bindings
int max_parallel_compilations
bool geometry_shader_support
bool use_subprocess_shader_compilations
int max_work_group_size[3]
size_t max_uniform_buffer_size
bool hdr_viewport_support
uint32_t max_buffer_texture_size
int max_work_group_count[3]
const char *(* extension_get)(int)
int max_compute_shader_storage_blocks
size_t storage_buffer_alignment
bool stencil_export_support
size_t max_storage_buffer_size