43 for (
const std::string &item : items) {
44 const std::string wrapped =
" " + item +
" ";
52 void GLBackend::platform_init()
59 #elif defined(__APPLE__)
65 const char *vendor = (
const char *)glGetString(GL_VENDOR);
66 const char *renderer = (
const char *)glGetString(GL_RENDERER);
67 const char *version = (
const char *)glGetString(GL_VERSION);
69 if (strstr(vendor,
"ATI") || strstr(vendor,
"AMD")) {
73 else if (strstr(vendor,
"NVIDIA")) {
77 else if (strstr(vendor,
"Intel") ||
79 strstr(renderer,
"Mesa DRI Intel") || strstr(renderer,
"Mesa DRI Mobile Intel")) {
83 if (strstr(renderer,
"UHD Graphics") ||
85 strstr(renderer,
"HD Graphics 530") || strstr(renderer,
"Kaby Lake GT2") ||
86 strstr(renderer,
"Whiskey Lake")) {
90 else if ((strstr(renderer,
"Mesa DRI R")) ||
91 (strstr(renderer,
"Radeon") && strstr(vendor,
"X.Org")) ||
92 (strstr(renderer,
"AMD") && strstr(vendor,
"X.Org")) ||
93 (strstr(renderer,
"Gallium ") && strstr(renderer,
" on ATI ")) ||
94 (strstr(renderer,
"Gallium ") && strstr(renderer,
" on AMD "))) {
98 else if (strstr(renderer,
"Nouveau") || strstr(vendor,
"nouveau")) {
102 else if (strstr(vendor,
"Mesa")) {
106 else if (strstr(vendor,
"Microsoft")) {
110 else if (strstr(vendor,
"Apple")) {
115 else if (strstr(renderer,
"Apple Software Renderer")) {
119 else if (strstr(renderer,
"llvmpipe") || strstr(renderer,
"softpipe")) {
124 printf(
"Warning: Could not find a matching GPU name. Things may not behave as expected.\n");
125 printf(
"Detected OpenGL configuration:\n");
126 printf(
"Vendor: %s\n", vendor);
127 printf(
"Renderer: %s\n", renderer);
133 if (!GLEW_VERSION_3_3) {
141 if (strstr(version,
"Build 7.14") || strstr(version,
"Build 7.15") ||
142 strstr(version,
"Build 8.15") || strstr(version,
"Build 9.17") ||
143 strstr(version,
"Build 9.18") || strstr(version,
"Build 10.18.10.3") ||
144 strstr(version,
"Build 10.18.10.4") || strstr(version,
"Build 10.18.10.5") ||
145 strstr(version,
"Build 10.18.14.4")) {
152 if (strstr(renderer,
"AMD CEDAR")) {
161 void GLBackend::platform_exit()
176 float clear_color[4] = {1.0f, 0.5f, 0.0f, 0.0f};
177 float *source_pix = (
float *)
MEM_callocN(
sizeof(
float[4]) * cube_size * cube_size * 6, __func__);
184 glGenTextures(1, &
tex);
185 glBindTexture(GL_TEXTURE_CUBE_MAP,
tex);
186 for (
int mip = 0; mip < 2; mip++) {
187 for (
int i = 0; i < 6; i++) {
188 const int width = cube_size / (1 << mip);
189 GLenum target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;
190 glTexImage2D(target, mip, GL_RGBA16F,
width,
width, 0, GL_RGBA, GL_FLOAT, source_pix);
193 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BASE_LEVEL, 0);
194 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, 0);
196 glGenFramebuffers(1, &
fb);
197 glBindFramebuffer(GL_FRAMEBUFFER,
fb);
198 glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
tex, 1);
199 glDrawBuffer(GL_COLOR_ATTACHMENT0);
200 glClearColor(
UNPACK4(clear_color));
201 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
202 glClear(GL_COLOR_BUFFER_BIT);
203 glBindFramebuffer(GL_FRAMEBUFFER, 0);
206 glGetTexImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 1, GL_RGBA, GL_FLOAT, source_pix);
207 bool enable_workaround = !
equals_v4v4(clear_color, source_pix);
210 glDeleteFramebuffers(1, &
fb);
211 glDeleteTextures(1, &
tex);
215 return enable_workaround;
220 const char *vendor = (
const char *)glGetString(GL_VENDOR);
221 const char *renderer = (
const char *)glGetString(GL_RENDERER);
222 const char *version = (
const char *)glGetString(GL_VERSION);
226 printf(
"GL: Forcing workaround usage and disabling extensions.\n");
227 printf(
" OpenGL identification strings\n");
228 printf(
" vendor: %s\n", vendor);
229 printf(
" renderer: %s\n", renderer);
230 printf(
" version: %s\n\n", version);
260 if (!GLEW_VERSION_4_0) {
264 (strstr(version,
"4.5.13399") || strstr(version,
"4.5.13417") ||
265 strstr(version,
"4.5.13422") || strstr(version,
"4.5.13467"))) {
280 strstr(renderer,
"AMD VERDE")) {
287 strstr(version,
"Mesa 19.3.4")) {
323 if (strstr(renderer,
"AMD Radeon Pro") || strstr(renderer,
"AMD Radeon R9") ||
324 strstr(renderer,
"AMD Radeon RX")) {
337 (strstr(renderer,
"HD Graphics 620") || strstr(renderer,
"HD Graphics 630"))) {
342 (strstr(renderer,
"HD Graphics 4000") || strstr(renderer,
"HD Graphics 4400") ||
343 strstr(renderer,
"HD Graphics 2500"))) {
351 (strstr(version,
"Build 10.18.10.3") || strstr(version,
"Build 10.18.10.4") ||
352 strstr(version,
"Build 10.18.10.5") || strstr(version,
"Build 10.18.14.4") ||
353 strstr(version,
"Build 10.18.14.5"))) {
359 (strstr(version,
"Build 20.19.15.4285"))) {
365 (strstr(version,
"Mesa 18.") || strstr(version,
"Mesa 19.0") ||
366 strstr(version,
"Mesa 19.1") || strstr(version,
"Mesa 19.2"))) {
377 strstr(version,
"3.3.10750")) {
382 if (strstr(version,
"4.0.0 - Build 10.18.10.3308") ||
383 strstr(version,
"4.0.0 - Build 9.18.10.3186") ||
384 strstr(version,
"4.0.0 - Build 9.18.10.3165") ||
385 strstr(version,
"3.1.0 - Build 9.17.10.3347") ||
386 strstr(version,
"3.1.0 - Build 9.17.10.4101") ||
387 strstr(version,
"3.3.0 - Build 8.15.10.2618")) {
411 strstr(renderer,
"HD Graphics 4000")) {
441 void GLBackend::capabilities_init()
@ G_DEBUG_GPU_FORCE_WORKAROUNDS
MINLINE bool equals_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
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 debug_layer_support
static bool shader_draw_parameters_support
static GLint max_texture_3d_size
static bool debug_layer_workaround
static float derivative_signs[2]
static bool base_instance_support
static bool vertex_attrib_binding_support
static GLint max_ubo_binds
static bool fixed_restart_index_support
static bool copy_image_support
static bool texture_gather_support
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_cube_map_array_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 bool detect_mip_render_workaround()
static bool match_renderer(StringRef renderer, const Vector< std::string > &items)
bool mip_render_workaround
bool shader_image_load_store_support
bool use_main_context_workaround
bool depth_blitting_workaround
bool use_hq_normals_workaround