Refactor: move code related to fcurve keyframe insertion #114570
|
@ -343,6 +343,11 @@ string MetalDevice::preprocess_source(MetalPipelineType pso_type,
|
|||
}
|
||||
}
|
||||
|
||||
if (@available(macos 14.0, *)) {
|
||||
/* Use Program Scope Global Built-ins, when available. */
|
||||
global_defines += "#define __METAL_GLOBAL_BUILTINS__\n";
|
||||
}
|
||||
|
||||
# ifdef WITH_CYCLES_DEBUG
|
||||
global_defines += "#define __KERNEL_DEBUG__\n";
|
||||
# endif
|
||||
|
|
|
@ -108,6 +108,31 @@ using namespace metal::raytracing;
|
|||
|
||||
/* Generate a struct containing the entry-point parameters and a "run"
|
||||
* method which can access them implicitly via this-> */
|
||||
|
||||
#ifdef __METAL_GLOBAL_BUILTINS__
|
||||
|
||||
#define ccl_gpu_kernel_signature(name, ...) \
|
||||
struct kernel_gpu_##name \
|
||||
{ \
|
||||
PARAMS_MAKER(__VA_ARGS__)(__VA_ARGS__) \
|
||||
void run(thread MetalKernelContext& context, \
|
||||
threadgroup atomic_int *threadgroup_array) ccl_global const; \
|
||||
}; \
|
||||
kernel void cycles_metal_##name(device const kernel_gpu_##name *params_struct, \
|
||||
constant KernelParamsMetal &ccl_restrict _launch_params_metal, \
|
||||
constant MetalAncillaries *_metal_ancillaries, \
|
||||
threadgroup atomic_int *threadgroup_array[[ threadgroup(0) ]]) { \
|
||||
MetalKernelContext context(_launch_params_metal, _metal_ancillaries); \
|
||||
params_struct->run(context, threadgroup_array); \
|
||||
} \
|
||||
void kernel_gpu_##name::run(thread MetalKernelContext& context, \
|
||||
threadgroup atomic_int *threadgroup_array) ccl_global const
|
||||
|
||||
#else
|
||||
|
||||
/* On macOS versions before 14.x, builtin constants (e.g. metal_global_id) must
|
||||
* be accessed through attributed entrypoint parameters. */
|
||||
|
||||
#define ccl_gpu_kernel_signature(name, ...) \
|
||||
struct kernel_gpu_##name \
|
||||
{ \
|
||||
|
@ -149,6 +174,8 @@ void kernel_gpu_##name::run(thread MetalKernelContext& context, \
|
|||
uint simd_group_index, \
|
||||
uint num_simd_groups) ccl_global const
|
||||
|
||||
#endif /* __METAL_GLOBAL_BUILTINS__ */
|
||||
|
||||
#define ccl_gpu_kernel_postfix
|
||||
#define ccl_gpu_kernel_call(x) context.x
|
||||
#define ccl_gpu_kernel_within_bounds(i,n) true
|
||||
|
@ -365,3 +392,14 @@ constant constexpr array<sampler, SamplerCount> metal_samplers = {
|
|||
sampler(address::clamp_to_zero, filter::linear),
|
||||
sampler(address::mirrored_repeat, filter::linear),
|
||||
};
|
||||
|
||||
#ifdef __METAL_GLOBAL_BUILTINS__
|
||||
const uint metal_global_id [[thread_position_in_grid]];
|
||||
const ushort metal_local_id [[thread_position_in_threadgroup]];
|
||||
const ushort metal_local_size [[threads_per_threadgroup]];
|
||||
const uint metal_grid_id [[threadgroup_position_in_grid]];
|
||||
const uint simdgroup_size [[threads_per_simdgroup]];
|
||||
const uint simd_lane_index [[thread_index_in_simdgroup]];
|
||||
const uint simd_group_index [[simdgroup_index_in_threadgroup]];
|
||||
const uint num_simd_groups [[simdgroups_per_threadgroup]];
|
||||
#endif /* __METAL_GLOBAL_BUILTINS__ */
|
|
@ -0,0 +1,33 @@
|
|||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup animrig
|
||||
*
|
||||
* \brief Functions to work with Actions.
|
||||
*/
|
||||
|
||||
#include "RNA_types.hh"
|
||||
|
||||
struct FCurve;
|
||||
struct bAction;
|
||||
|
||||
namespace blender::animrig {
|
||||
/**
|
||||
* Get (or add relevant data to be able to do so) F-Curve from the given Action,
|
||||
* for the given Animation Data block. This assumes that all the destinations are valid.
|
||||
*/
|
||||
FCurve *action_fcurve_ensure(Main *bmain,
|
||||
bAction *act,
|
||||
const char group[],
|
||||
PointerRNA *ptr,
|
||||
const char rna_path[],
|
||||
int array_index);
|
||||
|
||||
/**
|
||||
* Find the F-Curve from the given Action. This assumes that all the destinations are valid.
|
||||
*/
|
||||
FCurve *action_fcurve_find(bAction *act, const char rna_path[], int array_index);
|
||||
|
||||
} // namespace blender::animrig
|
|
@ -9,30 +9,10 @@
|
|||
*/
|
||||
|
||||
#include "DNA_anim_types.h"
|
||||
#include "RNA_types.hh"
|
||||
|
||||
struct AnimData;
|
||||
struct FCurve;
|
||||
struct bAction;
|
||||
|
||||
namespace blender::animrig {
|
||||
|
||||
/**
|
||||
* Get (or add relevant data to be able to do so) F-Curve from the given Action,
|
||||
* for the given Animation Data block. This assumes that all the destinations are valid.
|
||||
*/
|
||||
FCurve *action_fcurve_ensure(Main *bmain,
|
||||
bAction *act,
|
||||
const char group[],
|
||||
PointerRNA *ptr,
|
||||
const char rna_path[],
|
||||
int array_index);
|
||||
|
||||
/**
|
||||
* Find the F-Curve from the given Action. This assumes that all the destinations are valid.
|
||||
*/
|
||||
FCurve *action_fcurve_find(bAction *act, const char rna_path[], int array_index);
|
||||
|
||||
/**
|
||||
* \note The caller needs to run #BKE_nla_tweakedit_remap to get NLA relative frame.
|
||||
* The caller should also check #BKE_fcurve_is_protected before keying.
|
||||
|
|
|
@ -20,6 +20,7 @@ set(INC_SYS
|
|||
)
|
||||
|
||||
set(SRC
|
||||
intern/action.cc
|
||||
intern/anim_rna.cc
|
||||
intern/bone_collections.cc
|
||||
intern/bonecolor.cc
|
||||
|
@ -28,6 +29,7 @@ set(SRC
|
|||
intern/keyframing_auto.cc
|
||||
intern/visualkey.cc
|
||||
|
||||
ANIM_action.hh
|
||||
ANIM_armature_iter.hh
|
||||
ANIM_bone_collections.h
|
||||
ANIM_bone_collections.hh
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup animrig
|
||||
*/
|
||||
|
||||
#include "ANIM_action.hh"
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_string.h"
|
||||
#include "DEG_depsgraph_build.hh"
|
||||
#include "DNA_anim_types.h"
|
||||
#include "RNA_prototypes.h"
|
||||
|
||||
namespace blender::animrig {
|
||||
|
||||
FCurve *action_fcurve_find(bAction *act, const char rna_path[], const int array_index)
|
||||
{
|
||||
if (ELEM(nullptr, act, rna_path)) {
|
||||
return nullptr;
|
||||
}
|
||||
return BKE_fcurve_find(&act->curves, rna_path, array_index);
|
||||
}
|
||||
|
||||
FCurve *action_fcurve_ensure(Main *bmain,
|
||||
bAction *act,
|
||||
const char group[],
|
||||
PointerRNA *ptr,
|
||||
const char rna_path[],
|
||||
const int array_index)
|
||||
{
|
||||
if (ELEM(nullptr, act, rna_path)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* try to find f-curve matching for this setting
|
||||
* - add if not found and allowed to add one
|
||||
* TODO: add auto-grouping support? how this works will need to be resolved
|
||||
*/
|
||||
FCurve *fcu = BKE_fcurve_find(&act->curves, rna_path, array_index);
|
||||
|
||||
if (fcu != nullptr) {
|
||||
return fcu;
|
||||
}
|
||||
|
||||
fcu = BKE_fcurve_create();
|
||||
|
||||
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
|
||||
fcu->auto_smoothing = U.auto_smoothing_new;
|
||||
if (BLI_listbase_is_empty(&act->curves)) {
|
||||
fcu->flag |= FCURVE_ACTIVE;
|
||||
}
|
||||
|
||||
fcu->rna_path = BLI_strdup(rna_path);
|
||||
fcu->array_index = array_index;
|
||||
|
||||
if (group) {
|
||||
bActionGroup *agrp = BKE_action_group_find_name(act, group);
|
||||
|
||||
if (agrp == nullptr) {
|
||||
agrp = action_groups_add_new(act, group);
|
||||
|
||||
/* Sync bone group colors if applicable. */
|
||||
if (ptr && (ptr->type == &RNA_PoseBone)) {
|
||||
bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
|
||||
action_group_colors_set_from_posebone(agrp, pchan);
|
||||
}
|
||||
}
|
||||
|
||||
action_groups_add_channel(act, agrp, fcu);
|
||||
}
|
||||
else {
|
||||
BLI_addtail(&act->curves, fcu);
|
||||
}
|
||||
|
||||
/* New f-curve was added, meaning it's possible that it affects
|
||||
* dependency graph component which wasn't previously animated.
|
||||
*/
|
||||
DEG_relations_tag_update(bmain);
|
||||
|
||||
return fcu;
|
||||
}
|
||||
} // namespace blender::animrig
|
|
@ -10,85 +10,13 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "ANIM_fcurve.hh"
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_string.h"
|
||||
#include "DEG_depsgraph_build.hh"
|
||||
#include "DNA_anim_types.h"
|
||||
#include "ED_anim_api.hh"
|
||||
#include "MEM_guardedalloc.h"
|
||||
#include "RNA_prototypes.h"
|
||||
|
||||
namespace blender::animrig {
|
||||
|
||||
FCurve *action_fcurve_find(bAction *act, const char rna_path[], const int array_index)
|
||||
{
|
||||
if (ELEM(nullptr, act, rna_path)) {
|
||||
return nullptr;
|
||||
}
|
||||
return BKE_fcurve_find(&act->curves, rna_path, array_index);
|
||||
}
|
||||
|
||||
FCurve *action_fcurve_ensure(Main *bmain,
|
||||
bAction *act,
|
||||
const char group[],
|
||||
PointerRNA *ptr,
|
||||
const char rna_path[],
|
||||
const int array_index)
|
||||
{
|
||||
if (ELEM(nullptr, act, rna_path)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* try to find f-curve matching for this setting
|
||||
* - add if not found and allowed to add one
|
||||
* TODO: add auto-grouping support? how this works will need to be resolved
|
||||
*/
|
||||
FCurve *fcu = BKE_fcurve_find(&act->curves, rna_path, array_index);
|
||||
|
||||
if (fcu != nullptr) {
|
||||
return fcu;
|
||||
}
|
||||
|
||||
fcu = BKE_fcurve_create();
|
||||
|
||||
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
|
||||
fcu->auto_smoothing = U.auto_smoothing_new;
|
||||
if (BLI_listbase_is_empty(&act->curves)) {
|
||||
fcu->flag |= FCURVE_ACTIVE;
|
||||
}
|
||||
|
||||
fcu->rna_path = BLI_strdup(rna_path);
|
||||
fcu->array_index = array_index;
|
||||
|
||||
if (group) {
|
||||
bActionGroup *agrp = BKE_action_group_find_name(act, group);
|
||||
|
||||
if (agrp == nullptr) {
|
||||
agrp = action_groups_add_new(act, group);
|
||||
|
||||
/* Sync bone group colors if applicable. */
|
||||
if (ptr && (ptr->type == &RNA_PoseBone)) {
|
||||
bPoseChannel *pchan = static_cast<bPoseChannel *>(ptr->data);
|
||||
action_group_colors_set_from_posebone(agrp, pchan);
|
||||
}
|
||||
}
|
||||
|
||||
action_groups_add_channel(act, agrp, fcu);
|
||||
}
|
||||
else {
|
||||
BLI_addtail(&act->curves, fcu);
|
||||
}
|
||||
|
||||
/* New f-curve was added, meaning it's possible that it affects
|
||||
* dependency graph component which wasn't previously animated.
|
||||
*/
|
||||
DEG_relations_tag_update(bmain);
|
||||
|
||||
return fcu;
|
||||
}
|
||||
|
||||
bool delete_keyframe_fcurve(AnimData *adt, FCurve *fcu, float cfra)
|
||||
{
|
||||
bool found;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <cfloat>
|
||||
#include <cmath>
|
||||
|
||||
#include "ANIM_action.hh"
|
||||
#include "ANIM_fcurve.hh"
|
||||
#include "ANIM_keyframing.hh"
|
||||
#include "ANIM_rna.hh"
|
||||
|
|
|
@ -39,7 +39,8 @@ void vertbuf_data_extract_direct(const GSpan attribute, GPUVertBuf &vbo)
|
|||
using Converter = AttributeConverter<T>;
|
||||
using VBOType = typename Converter::VBOType;
|
||||
const Span<T> src = attribute.typed<T>();
|
||||
MutableSpan data(static_cast<VBOType *>(GPU_vertbuf_get_data(&vbo)), attribute.size());
|
||||
MutableSpan<VBOType> data(static_cast<VBOType *>(GPU_vertbuf_get_data(&vbo)),
|
||||
attribute.size());
|
||||
if constexpr (std::is_same_v<T, VBOType>) {
|
||||
array_utils::copy(src, data);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <cstdio>
|
||||
|
||||
#include "ANIM_fcurve.hh"
|
||||
#include "ANIM_action.hh"
|
||||
#include "ANIM_keyframing.hh"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
#include "UI_resources.hh"
|
||||
#include "UI_view2d.hh"
|
||||
|
||||
#include "ANIM_fcurve.hh"
|
||||
#include "ANIM_action.hh"
|
||||
#include "ANIM_keyframing.hh"
|
||||
|
||||
#include "ED_clip.hh"
|
||||
|
|
|
@ -2454,6 +2454,7 @@ bool ui_but_is_bool(const uiBut *but)
|
|||
UI_BTYPE_ICON_TOGGLE_N,
|
||||
UI_BTYPE_CHECKBOX,
|
||||
UI_BTYPE_CHECKBOX_N,
|
||||
UI_BTYPE_BUT_TOGGLE,
|
||||
UI_BTYPE_TAB))
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
#include "ED_object.hh"
|
||||
#include "ED_screen.hh"
|
||||
|
||||
#include "ANIM_fcurve.hh"
|
||||
#include "ANIM_action.hh"
|
||||
|
||||
#include "UI_interface.hh"
|
||||
#include "UI_resources.hh"
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
#include "ED_screen.hh"
|
||||
#include "ED_view3d.hh"
|
||||
|
||||
#include "ANIM_fcurve.hh"
|
||||
#include "ANIM_action.hh"
|
||||
|
||||
#include "MOD_nodes.hh"
|
||||
|
||||
|
|
|
@ -2228,6 +2228,7 @@ static void node_draw_panels(bNodeTree &ntree, const bNode &node, uiBlock &block
|
|||
0.0f,
|
||||
0.0f,
|
||||
"");
|
||||
UI_but_func_pushed_state_set(but, [&state](const uiBut &) { return state.is_collapsed(); });
|
||||
UI_but_func_set(
|
||||
but, node_panel_toggle_button_cb, const_cast<bNodePanelState *>(&state), &ntree);
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
# include "DEG_depsgraph.hh"
|
||||
|
||||
# include "ANIM_fcurve.hh"
|
||||
# include "ANIM_action.hh"
|
||||
|
||||
# include "WM_api.hh"
|
||||
|
||||
|
|
|
@ -3251,10 +3251,19 @@ void SEQ_effect_text_font_load(TextVars *data, const bool do_id_user)
|
|||
else {
|
||||
char filepath[FILE_MAX];
|
||||
STRNCPY(filepath, vfont->filepath);
|
||||
BLI_assert(BLI_thread_is_main());
|
||||
BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id));
|
||||
if (BLI_thread_is_main()) {
|
||||
/* FIXME: This is a band-aid fix. A proper solution has to be worked on by the VSE team.
|
||||
*
|
||||
* This code can be called from non-main thread, e.g. when copying sequences as part of
|
||||
* depsgraph CoW copy of the evaluated scene. Just skip font loading in that case, BLF code
|
||||
* is not thread-safe, and if this happens from threaded context, it almost certainly means
|
||||
* that a previous atempt to load the font already failed, e.g. because font filepath is
|
||||
* invalid. Propoer fix would likely be to not attempt to reload a failed-to-load font every
|
||||
* time. */
|
||||
BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&vfont->id));
|
||||
|
||||
data->text_blf_id = BLF_load(filepath);
|
||||
data->text_blf_id = BLF_load(filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ void SEQ_iterator_set_expand(const Scene *scene,
|
|||
}
|
||||
|
||||
/* Merge all expanded results in provided VectorSet. */
|
||||
query_matches.add_multiple(query_matches);
|
||||
strips.add_multiple(query_matches);
|
||||
}
|
||||
|
||||
static void query_all_strips_recursive(ListBase *seqbase, VectorSet<Sequence *> &strips)
|
||||
|
@ -94,20 +94,14 @@ static void query_all_strips_recursive(ListBase *seqbase, VectorSet<Sequence *>
|
|||
|
||||
VectorSet<Sequence *> SEQ_query_all_strips_recursive(ListBase *seqbase)
|
||||
{
|
||||
static VectorSet<Sequence *> strips;
|
||||
LISTBASE_FOREACH (Sequence *, seq, seqbase) {
|
||||
if (seq->type == SEQ_TYPE_META) {
|
||||
query_all_strips_recursive(&seq->seqbase, strips);
|
||||
}
|
||||
strips.add(seq);
|
||||
}
|
||||
|
||||
VectorSet<Sequence *> strips;
|
||||
query_all_strips_recursive(seqbase, strips);
|
||||
return strips;
|
||||
}
|
||||
|
||||
VectorSet<Sequence *> SEQ_query_all_strips(ListBase *seqbase)
|
||||
{
|
||||
static VectorSet<Sequence *> strips;
|
||||
VectorSet<Sequence *> strips;
|
||||
LISTBASE_FOREACH (Sequence *, strip, seqbase) {
|
||||
strips.add(strip);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue