「这是我参与11月更文挑战的第 25 天,活动详情查看:2021最后一次更文挑战」。
参加该活动的第 42 篇文章
正文
消息收发
(上接)
PF_Cmd_GET_EXTERNAL_DEPENDENCIES
只在 PF_Cmd_GLOBAL_SETUP 期间设置了 PF_OutFlag_I_HAVE_EXTERNAL_DEPENDENCIES 时发送。用插件依赖关系的描述填充一个字符串句柄(在 PF_ExtDependenciesExtra 中由 extra 所指向),确保为终止 NULL 字符分配了空间。如果没有需要报告的依赖项,返回一个 NULL 指针作为字符串句柄。如果检查类型是 PF_DepCheckType_ALL_DEPENDENCIES,则报告插件渲染可能需要的所有内容。如果检查类型是 PF_DepCheckType_MISSING_DEPENDENCIES ,则只报告缺失的项(如果什么都没有丢失,则报告一个空字符串)。
PF_Cmd_COMPLETELY_GENERAL
响应 AEGP 。额外的参数指向 AEGP 发送的任何参数。AEGP 只能与响应这个选择器的效果进行通信。
PF_Cmd_QUERY_DYNAMIC_FLAGS
只发送给在 PF_OutFlags2 中指定了PF_OutFlag2_SUPPORTS_QUERY_DYNAMIC_FLAGS 的插件,在它们的 PiPL 并在 PF_Cmd_GLOBAL_SETUP 期间。对于所有的动态标志,如果你要在这个命令期间改变它们,你必须在 PF_Cmd_GLOBAL_SETUP 期间设置标志。这个选择器将在任意时间被发送。作为响应,effect 应该使用 PF_CHECKOUT_PARAM 来访问它的(非层)参数,并决定是否应该设置任何支持 PF_Cmd_QUERY_DYNAMIC_FLAGS 的标志,例如:
PF_OutFlag_NON_PARAM_VARYPF_OutFlag_PIX_INDEPENDENTPF_OutFlag_I_USE_SHUTTER_ANGLEPF_OutFlag2_I_USE_3D_CAMERAPF_OutFlag2_I_USE_3D_LIGHTSPF_OutFlag2_DOESNT_NEED_EMPTY_PIXELSPF_OutFlag2_REVEALS_ZERO_ALPHAPF_OutFlag2_DEPENDS_ON_UNREFERENCED_MASKSPF_OutFlag2_OUTPUT_IS_WATERMARKED
After Effects 使用这些信息进行缓存和优化,所以要尽可能快地响应。
PF_Cmd_GPU_DEVICE_SETUP
这个选择器可以在任何时候被主机调用。对于每个 GPU 设备,它只会被调用一次。多个 GPU 设备可能同时处于 setup 状态。它将在 GlobalSetup 之后和 SequencSetup 之前被调用。这样做的目的是让效果在必要时进行 GPU 初始化,并让效果有机会仅基于该设备的属性而不是任何渲染上下文(帧大小等)来选择退出 GPU 设备。如果效果拒绝 GPU 设备,它将被 CPU 渲染所调用。PF_InData::what_gpu != PF_GPU_Framework_None 是预期的。如果支持 what_gpu 中的设备和框架,效果将在 PF_OutData::out_flags2 中设置一个或两个 PF_OutFlag2_SUPPORTS_GPU_RENDER_Fxx 标志。注意,只有PF_OutFlag2_SUPPORTS_GPU_RENDER_F32 将在 AE 16.0 中。没有在这里设置标志的效果将不会被认为支持这些设备的 GPU 渲染。PF_GPUDeviceSetupOutput::gpu_data 是插件拥有的指针,必须通过 PF_Cmd_GPU_DEVICE_SETDOWN 选择器释放。该指针在渲染时也可用。
PF_Cmd_GPU_DEVICE_SETDOWN
释放所有与 gpu_data 关联的资源。在 AE 中,这将在 GPU 设备发布之前调用。
typedef struct
{
void *gpu_data; // effect 必须负责释放
PF_GPU_Framework what_gpu;
A_u_long device_index; // 与 PrSDKGPUDeviceSuite 一起使用
} PF_GPUDeviceSetdownInput;
typedef struct
{
PF_GPUDeviceSetdownInput input;
} PF_GPUDeviceSetdownExtra;
PF_Cmd_GPU_SMART_RENDER_GPU
GPU 等价于现有的 PF_Cmd_SMART_RENDER 选择器。在渲染时,PF_Cmd_SMART_RENDER 或 PF_Cmd_SMART_RENDER_GPU 选择器将被调用,这取决于预期的效果是产生 CPU 帧还是 GPU 帧作为输出。当 what_gpu != PF_GPU_Framework_None ,并对任何输入/输出的 PF_LayerDef 有效果时, 将只调用 PF_Cmd_SMART_RENDER_GPU 。当这个选择器在运行时,所有的帧检入和检出都将在 GPU 帧上操作。注意PF_Cmd_SMART_RENDER 共享 Extra 结构体。
typedef struct
{
PF_RenderRequest output_request; // what the effect is being asked to render
short bitdepth; // bitdepth the effect is being driven in (in bpc)
void *pre_render_data; // passed back from value placed in extra->output->pre_render_data during PF_Cmd_PRE_RENDER
const void *gpu_data; // (new AE 16.0)
PF_GPU_Framework what_gpu; // (new AE 16.0)
A_u_long device_index; // (new AE 16.0)
} PF_SmartRenderInput;
typedef struct
{
PF_SmartRenderInput *input;
PF_SmartRenderCallbacks *cb;
} PF_SmartRenderExtra;
what_gpu 和 device_index 字段是 GPU 相关选择器的额外输入,指示插件进行渲染所使用的 GPU 框架。输入和输出缓冲区将在这个框架和设备上准备。设备、上下文、命令队列和其他相关的 GPU 状态可以通过PrSDKGPUDeviceSuite::GetDeviceInfo查询。what_gpu 在 PF_Cmd_SMART_PRE_RENDER 和 PF_Cmd_SMART_RENDER_GPU 选择器调用之间是相同的。
Messaging
PF_Cmd_GET_EXTERNAL_DEPENDENCIES
Only sent if
PF_OutFlag_I_HAVE_EXTERNAL_DEPENDENCIESwas set duringPF_Cmd_GLOBAL_SETUP.Populate a string handle (in the PF_ExtDependenciesExtra pointed to by extra) with a description of your plug-in’s dependencies, making sure to allocate space for the terminating NULL character.Return just aNULLpointer for the string handle if there are no dependencies to report.If the check type isPF_DepCheckType_ALL_DEPENDENCIES, report everything that might be required for your plug-in to render.Report only missing items (or a null string if nothing’s missing) if the check type isPF_DepCheckType_MISSING_DEPENDENCIES.PF_Cmd_COMPLETELY_GENERAL
Respond to an AEGP. The extra parameter points to whatever parameter the AEGP sent.AEGPs can only communicate with effects which respond to this selector.
PF_Cmd_QUERY_DYNAMIC_FLAGS
Sent only to plug-ins which have specified
PF_OutFlag2_SUPPORTS_QUERY_DYNAMIC_FLAGSinPF_OutFlags2, in their PiPL and duringPF_Cmd_GLOBAL_SETUP.With all of the dynamic flags, if you will ever change them during this command, you must have set the flag on duringPF_Cmd_GLOBAL_SETUP.This selector will be sent at arbitrary times.In response, the effect should access its (non-layer) parameters usingPF_CHECKOUT_PARAM, and decide whether any of the flags that supportPF_Cmd_QUERY_DYNAMIC_FLAGSshould be set, such as:> -PF_OutFlag_WIDE_TIME_INPUT
PF_OutFlag_NON_PARAM_VARYPF_OutFlag_PIX_INDEPENDENTPF_OutFlag_I_USE_SHUTTER_ANGLEPF_OutFlag2_I_USE_3D_CAMERAPF_OutFlag2_I_USE_3D_LIGHTSPF_OutFlag2_DOESNT_NEED_EMPTY_PIXELSPF_OutFlag2_REVEALS_ZERO_ALPHAPF_OutFlag2_DEPENDS_ON_UNREFERENCED_MASKSPF_OutFlag2_OUTPUT_IS_WATERMARKEDAfter Effects uses this information for caching and optimization purposes, so try to respond as quickly as possible.
PF_Cmd_GPU_DEVICE_SETUP`
This selector can be called at any time by the host. It will be called not more than once for each GPU device.Multiple GPU devices may be in the setup state at one time.It will be called after GlobalSetup and before SequenceSetup.The intent is for the effect to do GPU initialization if necessary and to give the effect an opportunity to opt out of a GPU device based solely on the properties of that device, and not any render context (frame size, etc).If the effect rejects the GPU device it will get called for CPU render.
PF_InData::what_gpu != PF_GPU_Framework_Noneis expected.Effect is expected to set one or both of thePF_OutFlag2_SUPPORTS_GPU_RENDER_Fxxflags inPF_OutData::out_flags2if the device and framework in what_gpu is supported.Note that onlyPF_OutFlag2_SUPPORTS_GPU_RENDER_F32will be in AE 16.0.Effects that do not set flags here will NOT be considered to support GPU rendering for any of these devices.PF_GPUDeviceSetupOutput::gpu_datais a plug-in owned pointer that must be released with a thePF_Cmd_GPU_DEVICE_SETDOWNselector.This pointer is also available at render time.PF_Cmd_GPU_DEVICE_SETDOWN
Release any resources associated with gpu_data. In AE this will be called just before GPU device release.
typedef struct { void *gpu_data; // effect must dispose. PF_GPU_Framework what_gpu; A_u_long device_index; // For use in conjunction with PrSDKGPUDeviceSuite } PF_GPUDeviceSetdownInput; typedef struct { PF_GPUDeviceSetdownInput input; } PF_GPUDeviceSetdownExtra;PF_Cmd_GPU_SMART_RENDER_GPU
GPU equivalent to the existing
PF_Cmd_SMART_RENDERselector.At render time, either thePF_Cmd_SMART_RENDERor thePF_Cmd_SMART_RENDER_GPUselector will be called, depending on whether the effect is expected to produce a CPU or GPU frame as output.PF_Cmd_SMART_RENDER_GPUwill only be called whenwhat_gpu != PF_GPU_Framework_None, and has effects on any input / outputPF_LayerDef’s.All frame check-ins and check-outs will operate on GPU frames when this selector is in progress. NotePF_Cmd_SMART_RENDERshares theExtrastructs.typedef struct { PF_RenderRequest output_request; // what the effect is being asked to render short bitdepth; // bitdepth the effect is being driven in (in bpc) void *pre_render_data; // passed back from value placed in extra->output->pre_render_data during PF_Cmd_PRE_RENDER const void *gpu_data; // (new AE 16.0) PF_GPU_Framework what_gpu; // (new AE 16.0) A_u_long device_index; // (new AE 16.0) } PF_SmartRenderInput; typedef struct { PF_SmartRenderInput *input; PF_SmartRenderCallbacks *cb; } PF_SmartRenderExtra;The
what_gpuanddevice_indexfields are in the extra input for GPU-related selectors indicates to the plug-in the GPU framework to be used for rendering.Input and output buffers will be prepared on this framework and device.The device, context, command queue, and other associated GPU state can be queried withPrSDKGPUDeviceSuite::GetDeviceInfo.what_gpuwill be the same betweenPF_Cmd_SMART_PRE_RENDERandPF_Cmd_SMART_RENDER_GPUselector calls.