Exemple #1
0
        public void CanUseGraphValueResolver_ToResolveValues_InAJob(NodeSet.RenderExecutionModel computeType)
        {
            using (var results = new NativeArray <float>(1, Allocator.Persistent))
                using (var set = new RenderGraphTests.PotentiallyJobifiedNodeSet(computeType))
                {
                    var root = set.Create <RenderPipe>();

                    GraphValue <float> rootValue = set.CreateGraphValue(root, RenderPipe.KernelPorts.Output);

                    for (int i = 0; i < 100; ++i)
                    {
                        set.SendMessage(root, RenderPipe.SimulationPorts.Input, i);

                        set.Update();

                        GraphValueReadbackJob 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();

                        Assert.AreEqual(i, results[0]);
                        Assert.AreEqual(i, set.GetValueBlocking(rootValue));
                    }

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