32 for (
const std::string &item : items) {
33 const std::string wrapped =
" " + item +
" ";
41void GLBackend::platform_init()
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);
60 printf(
"Warning: No OpenGL vendor detected.\n");
64 else if (strstr(vendor,
"ATI") || strstr(vendor,
"AMD")) {
68 else if (strstr(vendor,
"NVIDIA")) {
72 else if (strstr(vendor,
"Intel") ||
74 strstr(renderer,
"Mesa DRI Intel") || strstr(renderer,
"Mesa DRI Mobile Intel"))
79 if (strstr(renderer,
"UHD Graphics") ||
81 strstr(renderer,
"HD Graphics 530") || strstr(renderer,
"Kaby Lake GT2") ||
82 strstr(renderer,
"Whiskey Lake"))
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 ")))
96 else if (strstr(renderer,
"Nouveau") || strstr(vendor,
"nouveau")) {
100 else if (strstr(vendor,
"Mesa")) {
104 else if (strstr(vendor,
"Microsoft")) {
106 if (strstr(renderer,
"Qualcomm")) {
115 else if (strstr(vendor,
"Apple")) {
120 else if (strstr(renderer,
"Apple Software Renderer")) {
124 else if (strstr(renderer,
"llvmpipe") || strstr(renderer,
"softpipe")) {
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);
136 if (!(epoxy_gl_version() >= 43)) {
141 long long driverVersion = 0;
145 WORD ver0 = (driverVersion >> 48) & 0xffff;
146 WORD ver1 = (driverVersion >> 32) & 0xffff;
147 WORD ver2 = (driverVersion >> 16) & 0xffff;
153 if (ver0 < 30 || (ver0 == 30 && ver1 == 0 && ver2 < 3820)) {
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";
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"))
178 if (strstr(renderer,
"HD Graphics 405")) {
184 if (strstr(version,
"Build 20.19.15.51")) {
191 if (strstr(renderer,
"AMD CEDAR")) {
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";
214 (strstr(version,
"4.5.14831") || strstr(version,
"4.5.14760")))
230void GLBackend::platform_exit()
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__);
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);
262 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BASE_LEVEL, 0);
263 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, 0);
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);
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);
279 glDeleteFramebuffers(1, &
fb);
280 glDeleteTextures(1, &
tex);
284 return enable_workaround;
289 return (
char *)glGetStringi(GL_EXTENSIONS, i);
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);
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);
348 (strstr(version,
"4.5.13399") || strstr(version,
"4.5.13417") ||
349 strstr(version,
"4.5.13422") || strstr(version,
"4.5.13467")))
365 (strstr(renderer,
"AMD VERDE") || strstr(renderer,
"AMD KAVERI") ||
366 strstr(renderer,
"AMD TAHITI")))
374 strstr(version,
"Mesa 19.3.4"))
387 if (strstr(version,
" 22.6.1 ") || strstr(version,
" 21.Q1.2 ") ||
388 strstr(version,
" 21.Q2.1 "))
393 "RX550/550",
"(TM) 520",
"(TM) 530",
"(TM) 535",
"R5",
"R7",
"R9",
"HD"};
402 (strstr(renderer,
"HD Graphics 620") || strstr(renderer,
"HD Graphics 630")))
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")))
419 strstr(version,
"Build 20.19.15.4285"))
426 (strstr(version,
"Mesa 18.") || strstr(version,
"Mesa 19.0") ||
427 strstr(version,
"Mesa 19.1") || strstr(version,
"Mesa 19.2")))
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"))
453 if (strstr(version,
"Mesa 20.") || strstr(version,
"Mesa 21.") ||
454 strstr(version,
"Mesa 22.") || strstr(version,
"Mesa 23."))
465 long long driverVersion = 0;
469 WORD ver0 = (driverVersion >> 48) & 0xffff;
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") ||
522 strstr(renderer,
"W6800") || strstr(renderer,
"W6900"))
565void GLBackend::capabilities_init()
588 epoxy_has_gl_extension(
"GL_ATI_meminfo");
603 glGetInteger64v(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &max_ssbo_size);
608 epoxy_has_gl_extension(
"GL_ARB_texture_view");
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);
626 epoxy_has_gl_extension(
"GL_KHR_debug") ||
627 epoxy_has_gl_extension(
"GL_ARB_debug_output");
633 "GL_ARB_shader_viewport_layer_array");
635 "GL_AMD_shader_explicit_vertex_parameter");
637 "GL_ARB_multi_bind");
640 "GL_ARB_shader_draw_parameters");
643 "GL_EXT_texture_filter_anisotropic");
650#if BLI_SUBPROCESS_SUPPORT
@ G_DEBUG_GPU_FORCE_WORKAROUNDS
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)
Compatibility-like things for windows.
bool BLI_windows_get_directx_driver_version(const wchar_t *deviceSubString, long long *r_driverVersion)
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
static bool layered_rendering_support
static bool debug_layer_support
static bool framebuffer_fetch_support
static bool shader_draw_parameters_support
static bool explicit_location_support
static GLint max_ssbo_binds
static bool debug_layer_workaround
static float derivative_signs[2]
static GLint max_ubo_binds
static GLint max_ubo_size
static bool direct_state_access_support
static bool texture_filter_anisotropic_support
static bool clear_texture_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 multi_draw_indirect_support
BLI_INLINE float fb(float length, float L)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void check_gl_error(const char *info)
static void detect_workarounds()
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)
bool mip_render_workaround
int max_shader_storage_buffer_bindings
int max_parallel_compilations
bool geometry_shader_support
int max_work_group_size[3]
bool stencil_clasify_buffer_workaround
bool use_main_context_workaround
bool depth_blitting_workaround
bool hdr_viewport_support
int minimum_per_vertex_stride
int max_work_group_count[3]
const char *(* extension_get)(int)
bool shader_draw_parameters_support
int max_compute_shader_storage_blocks
bool transform_feedback_support
bool stencil_export_support
bool use_hq_normals_workaround
bool texture_view_support
size_t max_storage_buffer_size