Пример #1
0
        /// <summary>
        /// Method to create a new <typeparamref name="DSPNode"/> in the graph
        /// </summary>
        /// <remarks>
        /// A kernel of type <typeparamref name="TAudioKernel"/> is created inside the graph.
        /// A handle in the form of <typeparamref name="DSPNode"/> is returned
        /// for controlling the kernel.
        /// The created kernel will be bursted if its implementation is decorated with BurstCompileAttribute
        /// </remarks>
        /// <typeparam name="TParameters">Enum defining the parameters of the node</typeparam>
        /// <typeparam name="TProviders">Enum defining the sample providers of the node</typeparam>
        /// <typeparam name="TAudioKernel">IAudioKernel which is the DSP kernel of the node</typeparam>
        /// <returns>A DSPNode handle </returns>
        public DSPNode CreateDSPNode <TParameters, TProviders, TAudioKernel>()
            where TParameters  : unmanaged, Enum
            where TProviders   : unmanaged, Enum
            where TAudioKernel : struct, IAudioKernel <TParameters, TProviders>
        {
            AudioKernelExtensions.GetReflectionData <TAudioKernel, TParameters, TProviders>(out void *jobReflectionData, out AudioKernelExtensions.ParameterDescriptionData parameterDescriptionData, out AudioKernelExtensions.SampleProviderDescriptionData sampleProviderDescriptionData);
            var kernel = new TAudioKernel();
            var node   = new DSPNode
            {
                Graph  = m_Graph.Handle,
                Handle = m_Graph.AllocateHandle(),
            };

            QueueCommand(new CreateDSPNodeCommand
            {
                m_Type                          = DSPCommandType.CreateDSPNode,
                m_Graph                         = m_Graph,
                m_Handle                        = m_Handle,
                m_JobReflectionData             = jobReflectionData,
                m_ParameterDescriptionData      = parameterDescriptionData,
                m_SampleProviderDescriptionData = sampleProviderDescriptionData,
                m_JobStructMemory               = Utility.CopyToPersistentAllocation(ref kernel),
                m_KernelAlignment               = UnsafeUtility.AlignOf <TAudioKernel>(),
                m_KernelSize                    = UnsafeUtility.SizeOf <TAudioKernel>(),
                m_NodeHandle                    = node.Handle,
            });

            return(node);
        }
Пример #2
0
 internal DSPCommandBlock(DSPGraph graph)
 {
     m_Graph    = graph;
     m_Handle   = graph.AllocateHandle();
     m_Commands = new GrowableBuffer <IntPtr>(Allocator.Persistent);
 }