25 for (
const std::string &item : items) {
26 const std::string wrapped =
" " + item +
" ";
34 void GLBackend::platform_init()
38 const char *vendor = (
const char *)glGetString(GL_VENDOR);
39 const char *renderer = (
const char *)glGetString(GL_RENDERER);
40 const char *version = (
const char *)glGetString(GL_VERSION);
48 #elif defined(__APPLE__)
54 if (strstr(vendor,
"ATI") || strstr(vendor,
"AMD")) {
58 else if (strstr(vendor,
"NVIDIA")) {
62 else if (strstr(vendor,
"Intel") ||
64 strstr(renderer,
"Mesa DRI Intel") || strstr(renderer,
"Mesa DRI Mobile Intel")) {
68 if (strstr(renderer,
"UHD Graphics") ||
70 strstr(renderer,
"HD Graphics 530") || strstr(renderer,
"Kaby Lake GT2") ||
71 strstr(renderer,
"Whiskey Lake")) {
75 else if (strstr(renderer,
"Mesa DRI R") ||
76 (strstr(renderer,
"Radeon") && strstr(vendor,
"X.Org")) ||
77 (strstr(renderer,
"AMD") && strstr(vendor,
"X.Org")) ||
78 (strstr(renderer,
"Gallium ") && strstr(renderer,
" on ATI ")) ||
79 (strstr(renderer,
"Gallium ") && strstr(renderer,
" on AMD "))) {
83 else if (strstr(renderer,
"Nouveau") || strstr(vendor,
"nouveau")) {
87 else if (strstr(vendor,
"Mesa")) {
91 else if (strstr(vendor,
"Microsoft")) {
95 else if (strstr(vendor,
"Apple")) {
100 else if (strstr(renderer,
"Apple Software Renderer")) {
104 else if (strstr(renderer,
"llvmpipe") || strstr(renderer,
"softpipe")) {
109 printf(
"Warning: Could not find a matching GPU name. Things may not behave as expected.\n");
110 printf(
"Detected OpenGL configuration:\n");
111 printf(
"Vendor: %s\n", vendor);
112 printf(
"Renderer: %s\n", renderer);
116 if (!GLEW_VERSION_3_3) {
124 if (strstr(version,
"Build 7.14") || strstr(version,
"Build 7.15") ||
125 strstr(version,
"Build 8.15") || strstr(version,
"Build 9.17") ||
126 strstr(version,
"Build 9.18") || strstr(version,
"Build 10.18.10.3") ||
127 strstr(version,
"Build 10.18.10.4") || strstr(version,
"Build 10.18.10.5") ||
128 strstr(version,
"Build 10.18.14.4")) {
135 if (strstr(renderer,
"AMD CEDAR")) {
144 void GLBackend::platform_exit()
159 float clear_color[4] = {1.0f, 0.5f, 0.0f, 0.0f};
160 float *source_pix = (
float *)
MEM_callocN(
sizeof(
float[4]) * cube_size * cube_size * 6, __func__);
167 glGenTextures(1, &
tex);
168 glBindTexture(GL_TEXTURE_CUBE_MAP,
tex);
169 for (
int mip = 0; mip < 2; mip++) {
170 for (
int i = 0; i < 6; i++) {
171 const int width = cube_size / (1 << mip);
172 GLenum target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;
173 glTexImage2D(target, mip, GL_RGBA16F,
width,
width, 0, GL_RGBA, GL_FLOAT, source_pix);
176 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BASE_LEVEL, 0);
177 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, 0);
179 glGenFramebuffers(1, &
fb);
180 glBindFramebuffer(GL_FRAMEBUFFER,
fb);
181 glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
tex, 1);
182 glDrawBuffer(GL_COLOR_ATTACHMENT0);
183 glClearColor(
UNPACK4(clear_color));
184 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
185 glClear(GL_COLOR_BUFFER_BIT);
186 glBindFramebuffer(GL_FRAMEBUFFER, 0);
189 glGetTexImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 1, GL_RGBA, GL_FLOAT, source_pix);
190 bool enable_workaround = !
equals_v4v4(clear_color, source_pix);
193 glDeleteFramebuffers(1, &
fb);
194 glDeleteTextures(1, &
tex);
198 return enable_workaround;
203 return (
char *)glGetStringi(GL_EXTENSIONS, i);
208 const char *vendor = (
const char *)glGetString(GL_VENDOR);
209 const char *renderer = (
const char *)glGetString(GL_RENDERER);
210 const char *version = (
const char *)glGetString(GL_VERSION);
214 printf(
"GL: Forcing workaround usage and disabling extensions.\n");
215 printf(
" OpenGL identification strings\n");
216 printf(
" vendor: %s\n", vendor);
217 printf(
" renderer: %s\n", renderer);
218 printf(
" version: %s\n\n", version);
253 if (!GLEW_VERSION_4_0) {
257 (strstr(version,
"4.5.13399") || strstr(version,
"4.5.13417") ||
258 strstr(version,
"4.5.13422") || strstr(version,
"4.5.13467"))) {
273 (strstr(version,
"4.5.14831") || strstr(version,
"4.5.14760"))) {
278 (strstr(renderer,
"AMD VERDE") || strstr(renderer,
"AMD KAVERI") ||
279 strstr(renderer,
"AMD TAHITI"))) {
286 strstr(version,
"Mesa 19.3.4")) {
297 "RX550/550",
"(TM) 520",
"(TM) 530",
"(TM) 535",
"R5",
"R7",
"R9"};
308 if (strstr(renderer,
"AMD Radeon Pro") || strstr(renderer,
"AMD Radeon R9") ||
309 strstr(renderer,
"AMD Radeon RX")) {
322 (strstr(renderer,
"HD Graphics 620") || strstr(renderer,
"HD Graphics 630"))) {
327 (strstr(renderer,
"HD Graphics 4000") || strstr(renderer,
"HD Graphics 4400") ||
328 strstr(renderer,
"HD Graphics 2500"))) {
336 (strstr(version,
"Build 10.18.10.3") || strstr(version,
"Build 10.18.10.4") ||
337 strstr(version,
"Build 10.18.10.5") || strstr(version,
"Build 10.18.14.4") ||
338 strstr(version,
"Build 10.18.14.5"))) {
344 (strstr(version,
"Build 20.19.15.4285"))) {
350 (strstr(version,
"Mesa 18.") || strstr(version,
"Mesa 19.0") ||
351 strstr(version,
"Mesa 19.1") || strstr(version,
"Mesa 19.2"))) {
362 strstr(version,
"3.3.10750")) {
367 if (strstr(version,
"4.0.0 - Build 10.18.10.3308") ||
368 strstr(version,
"4.0.0 - Build 9.18.10.3186") ||
369 strstr(version,
"4.0.0 - Build 9.18.10.3165") ||
370 strstr(version,
"3.1.0 - Build 9.17.10.3347") ||
371 strstr(version,
"3.1.0 - Build 9.17.10.4101") ||
372 strstr(version,
"3.3.0 - Build 8.15.10.2618")) {
396 strstr(renderer,
"HD Graphics 4000")) {
402 (strstr(renderer,
"HD Graphics 4400") || strstr(renderer,
"HD Graphics 4600"))) {
458 void GLBackend::capabilities_init()
495 glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS,
@ 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 stencil_texturing_support
static bool geometry_shader_invocations
static bool layered_rendering_support
static bool debug_layer_support
static bool shader_draw_parameters_support
static bool explicit_location_support
static GLint max_ssbo_binds
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 bool texture_storage_support
static GLint max_ssbo_size
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 native_barycentric_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)
static const char * gl_extension_get(int i)
bool mip_render_workaround
int max_shader_storage_buffer_bindings
int max_work_group_size[3]
bool shader_image_load_store_support
const char *(* extension_get)(int)
bool use_main_context_workaround
bool depth_blitting_workaround
int minimum_per_vertex_stride
int max_work_group_count[3]
bool shader_storage_buffer_objects_support
int max_compute_shader_storage_blocks
bool clear_viewport_workaround
bool compute_shader_support
bool use_hq_normals_workaround