/** * has user activated? */ bool GPU_select_query_check_active(void) { return ((U.gpu_select_method == USER_SELECT_USE_OCCLUSION_QUERY) || ((U.gpu_select_method == USER_SELECT_AUTO) && (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY) || /* unsupported by nouveau, gallium 0.4, see: T47940 */ GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)))); }
static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH], bool use_opensubdiv, bool use_instancing, bool use_new_shading) { /* some useful defines to detect GPU type */ if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) { strcat(defines, "#define GPU_ATI\n"); if (GLEW_VERSION_3_0) { /* TODO(merwin): revisit this version check; GLEW_VERSION_3_0 means GL 3.0 or newer */ strcat(defines, "#define CLIP_WORKAROUND\n"); } } else if (GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_ANY)) strcat(defines, "#define GPU_NVIDIA\n"); else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY)) strcat(defines, "#define GPU_INTEL\n"); if (GPU_bicubic_bump_support()) strcat(defines, "#define BUMP_BICUBIC\n"); if (GLEW_VERSION_3_0) { strcat(defines, "#define BIT_OPERATIONS\n"); } #ifdef WITH_OPENSUBDIV /* TODO(sergey): Check whether we actually compiling shader for * the OpenSubdiv mesh. */ if (use_opensubdiv) { strcat(defines, "#define USE_OPENSUBDIV\n"); /* TODO(sergey): not strictly speaking a define, but this is * a global typedef which we don't have better place to define * in yet. */ strcat(defines, "struct VertexData {\n" " vec4 position;\n" " vec3 normal;\n" " vec2 uv;" "};\n"); } #else UNUSED_VARS(use_opensubdiv); #endif if (use_instancing) { strcat(defines, "#define USE_INSTANCING\n"); } if (use_new_shading) { strcat(defines, "#define USE_NEW_SHADING\n"); } return; }
static const char *gpu_shader_standard_defines(void) { /* some useful defines to detect GPU type */ if(GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) return "#define GPU_ATI\n"; else if(GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_ANY)) return "#define GPU_NVIDIA\n"; else if(GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY)) return "#define GPU_INTEL\n"; return ""; }
void wm_draw_update(bContext *C) { wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win; int drawmethod; GPU_free_unused_buffers(); for (win = wm->windows.first; win; win = win->next) { #ifdef WIN32 if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY)) { GHOST_TWindowState state = GHOST_GetWindowState(win->ghostwin); if (state == GHOST_kWindowStateMinimized) { /* do not update minimized windows, it gives issues on intel drivers (see [#33223]) * anyway, it seems logical to skip update for invisible windows */ continue; } } #endif if (win->drawmethod != U.wmdrawmethod) { wm_draw_window_clear(win); win->drawmethod = U.wmdrawmethod; } if (wm_draw_update_test_window(win)) { CTX_wm_window_set(C, win); /* sets context window+screen */ wm_window_make_drawable(wm, win); /* notifiers for screen redraw */ if (win->screen->do_refresh) ED_screen_refresh(wm, win); drawmethod = wm_automatic_draw_method(win); if (win->drawfail) wm_method_draw_overlap_all(C, win, 0); else if (drawmethod == USER_DRAW_FULL) wm_method_draw_full(C, win); else if (drawmethod == USER_DRAW_OVERLAP) wm_method_draw_overlap_all(C, win, 0); else if (drawmethod == USER_DRAW_OVERLAP_FLIP) wm_method_draw_overlap_all(C, win, 1); else // if (drawmethod == USER_DRAW_TRIPLE) wm_method_draw_triple(C, win); win->screen->do_draw_gesture = false; win->screen->do_draw_paintcursor = false; win->screen->do_draw_drag = false; wm_window_swap_buffers(win); CTX_wm_window_set(C, NULL); } } }
static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH]) { /* some useful defines to detect GPU type */ if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) { strcat(defines, "#define GPU_ATI\n"); if (GLEW_VERSION_3_0) strcat(defines, "#define CLIP_WORKAROUND"); } else if (GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_ANY)) strcat(defines, "#define GPU_NVIDIA\n"); else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY)) strcat(defines, "#define GPU_INTEL\n"); if (GPU_bicubic_bump_support()) strcat(defines, "#define BUMP_BICUBIC\n"); return; }
static const char *gpu_shader_version(void) { /* turn on glsl 1.30 for bicubic bump mapping and ATI clipping support */ if (GLEW_VERSION_3_0 && (GPU_bicubic_bump_support() || GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY))) { return "#version 130\n"; } return ""; }
/* belongs to below */ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) { GHOST_WindowHandle ghostwin; int scr_w, scr_h, posy; wm_get_screensize(&scr_w, &scr_h); posy = (scr_h - win->posy - win->sizey); #if defined(__APPLE__) && !defined(GHOST_COCOA) { extern int macPrefState; /* creator.c */ initial_state += macPrefState; } #endif /* Disable AA for now, as GL_SELECT (used for border, lasso, ... select) * doesn't work well when AA is initialized, even if not used. */ ghostwin = GHOST_CreateWindow(g_system, title, win->posx, posy, win->sizex, win->sizey, (GHOST_TWindowState)win->windowstate, GHOST_kDrawingContextTypeOpenGL, 0 /* no stereo */, 0 /* no AA */); if (ghostwin) { /* needed so we can detect the graphics card below */ GPU_extensions_init(); /* set the state*/ GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate); win->ghostwin = ghostwin; GHOST_SetWindowUserData(ghostwin, win); /* pointer back */ if (win->eventstate == NULL) win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state"); /* until screens get drawn, make it nice gray */ glClearColor(0.55, 0.55, 0.55, 0.0); /* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */ if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { glClear(GL_COLOR_BUFFER_BIT); } wm_window_swap_buffers(win); //GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified); /* standard state vars for window */ glEnable(GL_SCISSOR_TEST); GPU_state_init(); } }
int GPU_non_power_of_two_support(void) { /* Exception for buggy ATI/Apple driver in Mac OS X 10.5/10.6, * they claim to support this but can cause system freeze */ if(GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_MAC, GPU_DRIVER_OFFICIAL)) return 0; if(GG.npotdisabled) return 0; return GLEW_ARB_texture_non_power_of_two; }
static int wm_automatic_draw_method(wmWindow *win) { /* Ideally all cards would work well with triple buffer, since if it works * well gives the least redraws and is considerably faster at partial redraw * for sculpting or drawing overlapping menus. For typically lower end cards * copy to texture is slow though and so we use overlap instead there. */ if (win->drawmethod == USER_DRAW_AUTOMATIC) { /* ATI opensource driver is known to be very slow at this */ if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) return USER_DRAW_OVERLAP; /* also Intel drivers are slow */ #if 0 /* 2.64 BCon3 period, let's try if intel now works... */ else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_UNIX, GPU_DRIVER_ANY)) return USER_DRAW_OVERLAP; else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_WIN, GPU_DRIVER_ANY)) return USER_DRAW_OVERLAP_FLIP; else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_MAC, GPU_DRIVER_ANY)) return USER_DRAW_OVERLAP_FLIP; #endif /* Windows software driver darkens color on each redraw */ else if (GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_WIN, GPU_DRIVER_SOFTWARE)) return USER_DRAW_OVERLAP_FLIP; else if (GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_UNIX, GPU_DRIVER_SOFTWARE)) return USER_DRAW_OVERLAP; /* drawing lower color depth again degrades colors each time */ else if (GPU_color_depth() < 24) return USER_DRAW_OVERLAP; else return USER_DRAW_TRIPLE; } else return win->drawmethod; }
void EEVEE_occlusion_compute(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata, struct GPUTexture *depth_src, int layer) { EEVEE_PassList *psl = vedata->psl; EEVEE_FramebufferList *fbl = vedata->fbl; EEVEE_StorageList *stl = vedata->stl; EEVEE_EffectsInfo *effects = stl->effects; if ((effects->enabled_effects & EFFECT_GTAO) != 0) { DRW_stats_group_start("GTAO Horizon Scan"); effects->ao_src_depth = depth_src; effects->ao_depth_layer = layer; GPU_framebuffer_bind(fbl->gtao_fb); if (layer >= 0) { DRW_draw_pass(psl->ao_horizon_search_layer); } else { DRW_draw_pass(psl->ao_horizon_search); } if (GPU_mip_render_workaround() || GPU_type_matches(GPU_DEVICE_INTEL_UHD, GPU_OS_WIN, GPU_DRIVER_ANY)) { /* Fix dot corruption on intel HD5XX/HD6XX series. */ GPU_flush(); } /* Restore */ GPU_framebuffer_bind(fbl->main_fb); DRW_stats_group_end(); } }
/* belongs to below */ static void wm_window_add_ghostwindow(wmWindowManager *wm, const char *title, wmWindow *win) { GHOST_WindowHandle ghostwin; GHOST_GLSettings glSettings = {0}; static int multisamples = -1; int scr_w, scr_h, posy; /* force setting multisamples only once, it requires restart - and you cannot * mix it, either all windows have it, or none (tested in OSX opengl) */ if (multisamples == -1) multisamples = U.ogl_multisamples; glSettings.numOfAASamples = multisamples; /* a new window is created when pageflip mode is required for a window */ if (win->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP) glSettings.flags |= GHOST_glStereoVisual; if (G.debug & G_DEBUG_GPU) { glSettings.flags |= GHOST_glDebugContext; } if (!(U.uiflag2 & USER_OPENGL_NO_WARN_SUPPORT)) glSettings.flags |= GHOST_glWarnSupport; wm_get_screensize(&scr_w, &scr_h); posy = (scr_h - win->posy - win->sizey); ghostwin = GHOST_CreateWindow(g_system, title, win->posx, posy, win->sizex, win->sizey, (GHOST_TWindowState)win->windowstate, GHOST_kDrawingContextTypeOpenGL, glSettings); if (ghostwin) { GHOST_RectangleHandle bounds; /* the new window has already been made drawable upon creation */ wm->windrawable = win; /* needed so we can detect the graphics card below */ GPU_init(); win->ghostwin = ghostwin; GHOST_SetWindowUserData(ghostwin, win); /* pointer back */ if (win->eventstate == NULL) win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state"); #ifdef __APPLE__ /* set the state here, else OSX would not recognize changed screen resolution */ /* we agreed to not set any fullscreen or iconized state on startup */ GHOST_SetWindowState(ghostwin, GHOST_kWindowStateNormal); #endif /* store actual window size in blender window */ bounds = GHOST_GetClientBounds(win->ghostwin); win->sizex = GHOST_GetWidthRectangle(bounds); win->sizey = GHOST_GetHeightRectangle(bounds); GHOST_DisposeRectangle(bounds); #ifndef __APPLE__ /* set the state here, so minimized state comes up correct on windows */ GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate); #endif /* until screens get drawn, make it nice gray */ glClearColor(0.55, 0.55, 0.55, 0.0); /* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */ if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { glClear(GL_COLOR_BUFFER_BIT); } /* displays with larger native pixels, like Macbook. Used to scale dpi with */ /* needed here, because it's used before it reads userdef */ U.pixelsize = wm_window_pixelsize(win); BKE_userdef_state(); wm_window_swap_buffers(win); //GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified); /* standard state vars for window */ glEnable(GL_SCISSOR_TEST); GPU_state_init(); } }
/* belongs to below */ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) { GHOST_WindowHandle ghostwin; static int multisamples = -1; int scr_w, scr_h, posy; /* force setting multisamples only once, it requires restart - and you cannot * mix it, either all windows have it, or none (tested in OSX opengl) */ if (multisamples == -1) multisamples = U.ogl_multisamples; wm_get_screensize(&scr_w, &scr_h); posy = (scr_h - win->posy - win->sizey); ghostwin = GHOST_CreateWindow(g_system, title, win->posx, posy, win->sizex, win->sizey, (GHOST_TWindowState)win->windowstate, GHOST_kDrawingContextTypeOpenGL, 0 /* no stereo */, multisamples /* AA */); if (ghostwin) { GHOST_RectangleHandle bounds; /* needed so we can detect the graphics card below */ GPU_extensions_init(); win->ghostwin = ghostwin; GHOST_SetWindowUserData(ghostwin, win); /* pointer back */ if (win->eventstate == NULL) win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state"); /* set the state */ GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate); /* until screens get drawn, make it nice gray */ glClearColor(0.55, 0.55, 0.55, 0.0); /* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */ if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { glClear(GL_COLOR_BUFFER_BIT); } /* displays with larger native pixels, like Macbook. Used to scale dpi with */ /* needed here, because it's used before it reads userdef */ U.pixelsize = GHOST_GetNativePixelSize(win->ghostwin); BKE_userdef_state(); /* store actual window size in blender window */ bounds = GHOST_GetClientBounds(win->ghostwin); win->sizex = GHOST_GetWidthRectangle(bounds); win->sizey = GHOST_GetHeightRectangle(bounds); GHOST_DisposeRectangle(bounds); wm_window_swap_buffers(win); //GHOST_SetWindowState(ghostwin, GHOST_kWindowStateModified); /* standard state vars for window */ glEnable(GL_SCISSOR_TEST); GPU_state_init(); } }
bool GPU_select_query_check_active(void) { return ((U.gpu_select_method == USER_SELECT_USE_OCCLUSION_QUERY) || ((U.gpu_select_method == USER_SELECT_AUTO) && GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY))); }