Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/render/render_preview.cc
| Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "IMB_imbuf.h" | #include "IMB_imbuf.h" | ||||
| #include "IMB_imbuf_types.h" | #include "IMB_imbuf_types.h" | ||||
| #include "IMB_thumbs.h" | #include "IMB_thumbs.h" | ||||
| #include "BIF_glutil.h" | #include "BIF_glutil.h" | ||||
| #include "GPU_context.h" | |||||
| #include "GPU_shader.h" | #include "GPU_shader.h" | ||||
| #include "RE_engine.h" | #include "RE_engine.h" | ||||
| #include "RE_pipeline.h" | #include "RE_pipeline.h" | ||||
| #include "RE_texture.h" | #include "RE_texture.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| ▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static bool check_engine_supports_preview(Scene *scene) | static bool check_engine_supports_preview(Scene *scene) | ||||
| { | { | ||||
| RenderEngineType *type = RE_engines_find(scene->r.engine); | RenderEngineType *type = RE_engines_find(scene->r.engine); | ||||
| return (type->flag & RE_USE_PREVIEW) != 0; | return (type->flag & RE_USE_PREVIEW) != 0; | ||||
| } | } | ||||
| static bool check_engine_uses_opengl(Scene *scene) | |||||
| { | |||||
| RenderEngineType *type = RE_engines_find(scene->r.engine); | |||||
| return (type->flag & RE_USE_GPU_CONTEXT) != 0 && (GPU_backend_get_type() == GPU_BACKEND_OPENGL); | |||||
| } | |||||
| static bool preview_method_is_render(const ePreviewRenderMethod pr_method) | static bool preview_method_is_render(const ePreviewRenderMethod pr_method) | ||||
| { | { | ||||
| return ELEM(pr_method, PR_ICON_RENDER, PR_BUTS_RENDER); | return ELEM(pr_method, PR_ICON_RENDER, PR_BUTS_RENDER); | ||||
| } | } | ||||
| void ED_preview_free_dbase() | void ED_preview_free_dbase() | ||||
| { | { | ||||
| if (G_pr_main) { | if (G_pr_main) { | ||||
| ▲ Show 20 Lines • Show All 1,391 Lines • ▼ Show 20 Lines | for (cur_size = static_cast<IconPreviewSize *>(ip->sizes.first); cur_size; | ||||
| /* TODO: Decouple the ID-type-specific render functions from this function, so that it's not | /* TODO: Decouple the ID-type-specific render functions from this function, so that it's not | ||||
| * necessary to know here what happens inside lower-level functions. */ | * necessary to know here what happens inside lower-level functions. */ | ||||
| const bool use_solid_render_mode = (ip->id != nullptr) && ELEM(GS(ip->id->name), ID_OB, ID_AC); | const bool use_solid_render_mode = (ip->id != nullptr) && ELEM(GS(ip->id->name), ID_OB, ID_AC); | ||||
| if (!use_solid_render_mode && preview_method_is_render(pr_method) && | if (!use_solid_render_mode && preview_method_is_render(pr_method) && | ||||
| !check_engine_supports_preview(ip->scene)) { | !check_engine_supports_preview(ip->scene)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| const bool is_opengl_render = preview_method_is_render(pr_method) && | |||||
| check_engine_uses_opengl(ip->scene); | |||||
| /* Workaround: Skip opengl preview renders for linked IDs. Because of shader compilation, this | |||||
| * can freeze the UI and in case of linked data, the result won't be stored in the file anyway, | |||||
| * so the UI freeze happens every time the file is reloaded and the preview is displayed. */ | |||||
| if (is_opengl_render && !use_solid_render_mode && ip->id && ID_IS_LINKED(ip->id)) { | |||||
| continue; | |||||
| } | |||||
| #ifndef NDEBUG | #ifndef NDEBUG | ||||
| { | { | ||||
| int size_index = icon_previewimg_size_index_get(cur_size, prv); | int size_index = icon_previewimg_size_index_get(cur_size, prv); | ||||
| BLI_assert(!BKE_previewimg_is_finished(prv, size_index)); | BLI_assert(!BKE_previewimg_is_finished(prv, size_index)); | ||||
| } | } | ||||
| #endif | #endif | ||||
| if (ip->id != nullptr) { | if (ip->id != nullptr) { | ||||
| ▲ Show 20 Lines • Show All 546 Lines • Show Last 20 Lines | |||||