diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc index a359a80d026..148a24e1d5d 100644 --- a/source/blender/editors/mesh/mesh_data.cc +++ b/source/blender/editors/mesh/mesh_data.cc @@ -430,8 +430,15 @@ bool ED_mesh_color_ensure(Mesh *mesh, const char *name) { using namespace blender; BLI_assert(mesh->edit_mesh == nullptr); - if (mesh->attributes().contains(mesh->active_color_attribute)) { - return true; + const bke::AttributeAccessor attributes = mesh->attributes(); + if (const std::optional meta_data = attributes.lookup_meta_data( + mesh->active_color_attribute)) + { + if ((ATTR_DOMAIN_AS_MASK(meta_data->domain) & ATTR_DOMAIN_MASK_COLOR) && + (CD_TYPE_AS_MASK(meta_data->data_type) & CD_MASK_COLOR_ALL)) + { + return true; + } } const std::string unique_name = BKE_id_attribute_calc_unique_name(mesh->id, name); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index d274ed46922..9821c15afe4 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -598,6 +598,24 @@ void smooth_brush_toggle_on(const bContext *C, Paint *paint, StrokeCache *cache) /** \} */ } // namespace blender::ed::sculpt_paint::vwpaint +static bool color_attribute_supported(const std::optional meta_data) +{ + if (!meta_data) { + return false; + } + if (!(ATTR_DOMAIN_AS_MASK(meta_data->domain) & ATTR_DOMAIN_MASK_COLOR) || + !(CD_TYPE_AS_MASK(meta_data->data_type) & CD_MASK_COLOR_ALL)) + { + return false; + } + return true; +} + +static bool color_attribute_supported(const Mesh &mesh, const StringRef name) +{ + return color_attribute_supported(mesh.attributes().lookup_meta_data(name)); +} + bool vertex_paint_mode_poll(bContext *C) { const Object *ob = CTX_data_active_object(C); @@ -610,7 +628,7 @@ bool vertex_paint_mode_poll(bContext *C) return false; } - if (!mesh->attributes().contains(mesh->active_color_attribute)) { + if (!color_attribute_supported(*mesh, mesh->active_color_attribute)) { return false; } @@ -992,8 +1010,7 @@ static bool vpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo const std::optional meta_data = *mesh->attributes().lookup_meta_data( mesh->active_color_attribute); - - if (!meta_data) { + if (!color_attribute_supported(meta_data)) { return false; } diff --git a/source/blender/windowmanager/intern/wm_draw.cc b/source/blender/windowmanager/intern/wm_draw.cc index d828a0bc8ad..1311dd56148 100644 --- a/source/blender/windowmanager/intern/wm_draw.cc +++ b/source/blender/windowmanager/intern/wm_draw.cc @@ -1543,6 +1543,13 @@ void wm_draw_update(bContext *C) BKE_image_free_unused_gpu_textures(); +#ifdef WITH_METAL_BACKEND + /* Reset drawable to ensure GPU context activation happens at least once per frame if only a + * single context exists. This is required to ensure the default framebuffer is updated + * to be the latest backbuffer. */ + wm_window_clear_drawable(wm); +#endif + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { #ifdef WIN32 GHOST_TWindowState state = GHOST_GetWindowState(