Exemple #1
0
        public void CanUseGraphValueResolver_ToResolveAggregate_WithBuffers_InAJob(int bufferLength)
        {
            using (var results = new NativeArray <int>(bufferLength + 1, Allocator.Persistent))
                using (var set = new RenderGraphTests.PotentiallyJobifiedNodeSet(NodeSet.RenderExecutionModel.MaximallyParallel))
                {
                    var root = set.Create <RenderPipeAggregate>();

                    GraphValue <Aggregate> rootValue = set.CreateGraphValue(root, RenderPipeAggregate.KernelPorts.Output);

                    for (int i = 0; i < 20; ++i)
                    {
                        set.SetData(root, RenderPipeAggregate.KernelPorts.Input, i);

                        Aggregate aggr = default;
                        aggr.InputPlusOneI = Buffer <int> .SizeRequest(bufferLength);

                        set.SetBufferSize(root, RenderPipeAggregate.KernelPorts.Output, aggr);

                        set.Update();

                        GraphAggregateReadbackJob job;

                        job.Value    = rootValue;
                        job.Result   = results;
                        job.Resolver = set.GetGraphValueResolver(out var valueResolverDependency);

                        set.InjectDependencyFromConsumer(job.Schedule(valueResolverDependency));

                        // Automatically fences before CopyWorlds. Results is accessible now.
                        set.Update();

                        for (int z = 0; z < bufferLength + 1; ++z)
                        {
                            Assert.AreEqual(i + z, results[z]);
                        }
                    }

                    set.Destroy(root);
                    set.ReleaseGraphValue(rootValue);
                }
        }