48 for (
const std::string &item : items) {
49 const std::string wrapped =
" " + item +
" ";
58 const std::string &format,
62 std::string subversion;
65 if (format[f] ==
'0') {
66 if (std::isdigit(version[
v])) {
68 subversion.push_back(version[
v]);
72 match = version[
v] == format[f];
73 if (!subversion.empty()) {
74 r_version.append(std::stoi(subversion));
88 if (f == format.size()) {
99 std::string version_str = version_cstr;
101 version_str.push_back(
' ');
114 return version[0] < 23;
117 if (
parse_version(version_str,
" 00.00.00000.00000 ", version) ||
121 return version[0] < 31 || (version[0] == 31 && version[2] < 21001);
128void GLBackend::platform_init()
132 const char *vendor =
reinterpret_cast<const char *
>(glGetString(GL_VENDOR));
133 const char *renderer =
reinterpret_cast<const char *
>(glGetString(GL_RENDERER));
134 const char *version =
reinterpret_cast<const char *
>(glGetString(GL_VERSION));
147 printf(
"Warning: No OpenGL vendor detected.\n");
151 else if (strstr(renderer,
"Mesa DRI R") ||
152 (strstr(renderer,
"Radeon") && (strstr(vendor,
"X.Org") || strstr(version,
"Mesa"))) ||
153 (strstr(renderer,
"AMD") && (strstr(vendor,
"X.Org") || strstr(version,
"Mesa"))) ||
154 (strstr(renderer,
"Gallium ") && strstr(renderer,
" on ATI ")) ||
155 (strstr(renderer,
"Gallium ") && strstr(renderer,
" on AMD ")))
160 else if (strstr(vendor,
"ATI") || strstr(vendor,
"AMD")) {
164 else if (strstr(vendor,
"NVIDIA")) {
168 else if (strstr(vendor,
"Intel") ||
170 strstr(renderer,
"Mesa DRI Intel") || strstr(renderer,
"Mesa DRI Mobile Intel"))
175 if (strstr(renderer,
"UHD Graphics") ||
177 strstr(renderer,
"HD Graphics 530") || strstr(renderer,
"Kaby Lake GT2") ||
178 strstr(renderer,
"Whiskey Lake"))
183 else if (strstr(renderer,
"Nouveau") || strstr(vendor,
"nouveau")) {
187 else if (strstr(vendor,
"Mesa")) {
191 else if (strstr(vendor,
"Microsoft")) {
193 if (strstr(renderer,
"Qualcomm")) {
202 else if (strstr(vendor,
"Apple")) {
207 else if (strstr(renderer,
"Apple Software Renderer")) {
211 else if (strstr(renderer,
"llvmpipe") || strstr(renderer,
"softpipe")) {
216 printf(
"Warning: Could not find a matching GPU name. Things may not behave as expected.\n");
217 printf(
"Detected OpenGL configuration:\n");
218 printf(
"Vendor: %s\n", vendor);
219 printf(
"Renderer: %s\n", renderer);
223 if (!(epoxy_gl_version() >= 43)) {
228 long long driverVersion = 0;
232 WORD ver0 = (driverVersion >> 48) & 0xffff;
233 WORD ver1 = (driverVersion >> 32) & 0xffff;
234 WORD ver2 = (driverVersion >> 16) & 0xffff;
240 if (ver0 < 30 || (ver0 == 30 && ver1 == 0 && ver2 < 3820)) {
242 <<
"=====================================\n"
243 <<
"Qualcomm drivers older than 30.0.3820.x cannot run Blender 4.0 or later.\n"
244 <<
"If your device is older than an 8cx Gen3, you must use a 3.x LTS release.\n"
245 <<
"If you have an 8cx Gen3 or newer device, a driver update may be available.\n"
246 <<
"=====================================\n";
255 constexpr long long last_unsupported_version = (23LL << 48) | (21LL << 32) | (13LL << 16) |
259 if (driverVersion <= last_unsupported_version) {
260 std::cout <<
"=====================================\n"
261 <<
"NVIDIA drivers 23.21.13.9135 (391.35) and older are not supported.\n"
262 <<
"Please update to a newer driver.\n"
263 <<
"=====================================\n";
273 if (strstr(version,
"Build 7.14") || strstr(version,
"Build 7.15") ||
274 strstr(version,
"Build 8.15") || strstr(version,
"Build 9.17") ||
275 strstr(version,
"Build 9.18") || strstr(version,
"Build 10.18.10.3") ||
276 strstr(version,
"Build 10.18.10.4") || strstr(version,
"Build 10.18.10.5") ||
277 strstr(version,
"Build 10.18.14.4"))
282 if (strstr(renderer,
"HD Graphics 405")) {
288 if (strstr(version,
"Build 20.19.15.51")) {
295 if (strstr(renderer,
"AMD CEDAR")) {
300 if (strstr(version,
"Mesa 20.") || strstr(version,
"Mesa 21.") ||
301 strstr(version,
"Mesa 22.") || strstr(version,
"Mesa 23."))
303 std::cerr <<
"Unsupported driver. Requires at least Mesa 24.0.0." << std::endl;
309 GLint max_ssbo_binds_vertex;
310 GLint max_ssbo_binds_fragment;
311 GLint max_ssbo_binds_compute;
312 glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &max_ssbo_binds_vertex);
313 glGetIntegerv(GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS, &max_ssbo_binds_fragment);
314 glGetIntegerv(GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS, &max_ssbo_binds_compute);
315 GLint max_ssbo_binds = std::min(
316 {max_ssbo_binds_vertex, max_ssbo_binds_fragment, max_ssbo_binds_compute});
317 if (max_ssbo_binds < 12) {
318 std::cout <<
"Warning: Unsupported platform as it supports max " << max_ssbo_binds
319 <<
" SSBO binding locations\n";
323 if (!epoxy_has_gl_extension(
"GL_ARB_shader_draw_parameters")) {
324 std::cout <<
"Error: The OpenGL implementation doesn't support ARB_shader_draw_parameters\n";
328 if (!epoxy_has_gl_extension(
"GL_ARB_clip_control")) {
329 std::cout <<
"Error: The OpenGL implementation doesn't support ARB_clip_control\n";
333 if (!epoxy_has_gl_extension(
"GL_ARB_get_texture_sub_image")) {
334 std::cout <<
"Error: The OpenGL implementation doesn't support ARB_get_texture_sub_image\n";
341 (strstr(version,
"4.5.14831") || strstr(version,
"4.5.14760")))
357 {.identifier =
"OPENGL", .index = 0, .vendor_id = 0, .device_id = 0, .name = renderer});
363 if (epoxy_has_gl_extension(
"GL_EXT_memory_object")) {
364 GLint number_of_devices = 0;
365 glGetIntegerv(GL_NUM_DEVICE_UUIDS_EXT, &number_of_devices);
370 GLubyte device_uuid[GL_UUID_SIZE_EXT] = {0};
371 glGetUnsignedBytei_vEXT(GL_DEVICE_UUID_EXT, 0, device_uuid);
372 GPG.
device_uuid = Array<uint8_t, 16>(Span<uint8_t>(device_uuid, GL_UUID_SIZE_EXT));
375 if (epoxy_has_gl_extension(
"GL_EXT_memory_object_win32") && (os &
GPU_OS_WIN)) {
376 GLubyte device_luid[GL_LUID_SIZE_EXT] = {0};
377 glGetUnsignedBytevEXT(GL_DEVICE_LUID_EXT, device_luid);
378 GPG.
device_luid = Array<uint8_t, 8>(Span<uint8_t>(device_luid, GL_LUID_SIZE_EXT));
381 glGetIntegerv(GL_DEVICE_NODE_MASK_EXT, &node_mask);
387void GLBackend::platform_exit()
412 return reinterpret_cast<char *
>(
const_cast<GLubyte *
>(glGetStringi(GL_EXTENSIONS, i)));
417 const char *vendor =
reinterpret_cast<const char *
>(glGetString(GL_VENDOR));
418 const char *renderer =
reinterpret_cast<const char *
>(glGetString(GL_RENDERER));
419 const char *version =
reinterpret_cast<const char *
>(glGetString(GL_VERSION));
423 printf(
"GL: Forcing workaround usage and disabling extensions.\n");
424 printf(
" OpenGL identification strings\n");
425 printf(
" vendor: %s\n", vendor);
426 printf(
" renderer: %s\n", renderer);
427 printf(
" version: %s\n\n", version);
463 (strstr(version,
"4.5.13399") || strstr(version,
"4.5.13417") ||
464 strstr(version,
"4.5.13422") || strstr(version,
"4.5.13467")))
477 (strstr(renderer,
"AMD VERDE") || strstr(renderer,
"AMD KAVERI") ||
478 strstr(renderer,
"AMD TAHITI")))
494 "RX550/550",
"(TM) 520",
"(TM) 530",
"(TM) 535",
"R5",
"R7",
"R9",
"HD"};
506 (strstr(version,
"Build 10.18.10.3") || strstr(version,
"Build 10.18.10.4") ||
507 strstr(version,
"Build 10.18.10.5") || strstr(version,
"Build 10.18.14.4") ||
508 strstr(version,
"Build 10.18.14.5")))
514 strstr(version,
"Build 20.19.15.4285"))
531 (strstr(version,
"Mesa 18.") || strstr(version,
"Mesa 19.0") ||
532 strstr(version,
"Mesa 19.1") || strstr(version,
"Mesa 19.2")))
541 long long driverVersion = 0;
545 WORD ver0 = (driverVersion >> 48) & 0xffff;
584 int driver_version_minor = 0, driver_version_major = 0;
586 if (epoxy_has_gl_extension(
"GL_EXT_memory_object_win32")) {
588 glGetUnsignedBytevEXT(GL_DEVICE_LUID_EXT,
reinterpret_cast<GLubyte *
>(&device_luid));
591 device_luid, &driver_version_minor, &driver_version_major, &device_id))
601 if (driver_version_major < 101 || (driver_version_major == 101 && driver_version_minor < 5972))
608 (driver_version_major == 101 && driver_version_minor < 8801))
654void GLBackend::capabilities_init()
673 epoxy_has_gl_extension(
"GL_ATI_meminfo");
689 int64_t max_ssbo_size, max_ubo_size;
690 glGetInteger64v(GL_MAX_UNIFORM_BLOCK_SIZE, &max_ubo_size);
692 glGetInteger64v(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &max_ssbo_size);
694 GLint ssbo_alignment;
695 glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, &ssbo_alignment);
702 glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE,
706 GLint max_ssbo_binds;
708 glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &max_ssbo_binds);
710 glGetIntegerv(GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS, &max_ssbo_binds);
712 glGetIntegerv(GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS, &max_ssbo_binds);
715 epoxy_has_gl_extension(
"GL_KHR_debug") ||
716 epoxy_has_gl_extension(
"GL_ARB_debug_output");
721 "GL_ARB_shader_viewport_layer_array");
723 "GL_AMD_vertex_shader_viewport_index");
726 "GL_AMD_shader_explicit_vertex_parameter");
728 "GL_ARB_multi_bind");
731 epoxy_has_gl_extension(
"GL_ARB_derivative_control");
733 "GL_EXT_texture_filter_anisotropic");
740#if BLI_SUBPROCESS_SUPPORT
751 int thread_count =
U.gpu_shader_workers;
753 if (thread_count == 0) {
815void GLBackend::log_extensions()
818 "OpenGL Extensions\n"
819 " - [%c] Multi-bind\n"
820 " - [%c] Direct state access\n"
821 " - [%c] Anisotropic Texture Filtering\n"
822 " - [%c] Layered rendering\n"
823 " - [%c] Vertex shader viewport index\n"
824 " - [%c] Vertex shader layer array\n"
825 " - [%c] Native barycentric coordinates\n"
826 " - [%c] Framebuffer fetch\n"
827 " - [%c] Texture barrier\n"
828 " - [%c] Shader stencil export\n"
829 " - [%c] Derivative control\n",
849void GLBackend::log_workarounds()
852 "OpenGL Workarounds\n"
853 " - [%c] Debug layer workaround\n"
854 " - [%c] Unused framebuffer slot workaround\n"
855 " - [%c] Depth blitting workaround\n"
856 " - [%c] Stencil classify buffer workaround\n"
857 " - [%c] High-quality normals\n"
858 " - [%c] Use main context\n",
Compatibility-like things for windows.
#define CLOG_DEBUG(clg_ref,...)
#define CLOG_TRACE(clg_ref,...)
void reinitialize(const int64_t new_size)
constexpr IndexRange()=default
static constexpr int64_t not_found
constexpr int64_t find(char c, int64_t pos=0) const
constexpr bool endswith(StringRef suffix) const
TexturePool * texturepool_alloc() override
static bool stencil_texturing_support
static bool layered_rendering_support
static bool debug_layer_support
static bool framebuffer_fetch_support
static GLint max_ssbo_binds
static bool debug_layer_workaround
static bool vertex_shader_layer_support
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 vertex_shader_viewport_index_support
static bool derivative_control_support
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)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
unsigned __int64 uint64_t
ATTR_WARN_UNUSED_RESULT const BMVert * v
bool BLI_windows_get_directx_driver_version(const wchar_t *deviceSubString, long long *r_driverVersion)
@ G_DEBUG_GPU_NO_TEXTURE_POOL
@ G_DEBUG_GPU_FORCE_WORKAROUNDS
@ GPU_SUPPORT_LEVEL_UNSUPPORTED
@ GPU_SUPPORT_LEVEL_LIMITED
@ GPU_SUPPORT_LEVEL_SUPPORTED
int BLI_system_thread_count()
bool GPU_type_matches(GPUDeviceType device, GPUOSType os, GPUDriverType driver)
GPUIntelGpuArch GPU_platform_get_intel_arch(uint32_t device_id)
bool BLI_windows_get_directx_intel_driver_info(uint64_t device_luid, int *driver_version_minor, int *driver_version_major, uint32_t *device_id)
@ USER_SHADER_COMPILE_SUBPROCESS
MINLINE int min_ii(int a, int b)
bool frontbuffer_read_workaround
int max_shader_storage_buffer_bindings
bool multi_viewport_support
bool stencil_classify_buffer_workaround
int max_parallel_compilations
bool geometry_shader_support
bool use_subprocess_shader_compilations
bool texture_pool_workaround
int max_work_group_size[3]
size_t max_uniform_buffer_size
bool use_main_context_workaround
const char *(*) extension_get(int)
bool depth_blitting_workaround
bool hdr_viewport_support
int minimum_per_vertex_stride
uint32_t max_buffer_texture_size
int max_work_group_count[3]
int max_compute_shader_storage_blocks
size_t storage_buffer_alignment
bool vertex_pipeline_stores_and_atomics_support
bool stencil_export_support
bool use_hq_normals_workaround
bool srgb_write_view_support
size_t max_storage_buffer_size