Ejemplo n.º 1
0
        public HashGrid(ComputeShader compute, ComputeShader computeSort, LifeService l, PositionService p, GridService.Grid g)
        {
            var capacity = l.Lifes.count;
            _compute = compute;
            _lifes = l;
            _positions = p;

            _kernelSolve = compute.FindKernel (ShaderConst.KERNEL_SOVLE_COLLISION_DETECTION);
            _sort = new BitonicMergeSort(computeSort);
            _keys = new ComputeBuffer(capacity, Marshal.SizeOf(typeof(uint)));
            CollisionData = new Collision[capacity];
            Collisions = new ComputeBuffer(capacity, Marshal.SizeOf(typeof(Collision)));
            _hashes = new HashService(compute, l, p);
            _grid = new GridService(compute, g, _hashes);
        }
Ejemplo n.º 2
0
        public GridService(ComputeShader compute, Grid g, HashService h)
        {
            _compute = compute;
            _grid = g;
            _hashes = h;
            _kernelInit = compute.FindKernel(ShaderConst.KERNEL_INIT_GRID);
            _kernelConstruct = compute.FindKernel(ShaderConst.KERNEL_CONSTRUCT_GRID);
            var gridCellCount = g.nx * g.ny;

            StartData = new uint[gridCellCount];
            EndData = new uint[gridCellCount];
            _hashGridStart = new ComputeBuffer(gridCellCount, Marshal.SizeOf(typeof(uint)));
            _hashGridEnd = new ComputeBuffer(gridCellCount, Marshal.SizeOf(typeof(uint)));
            _hashGridStart.SetData (StartData);
            _hashGridEnd.SetData (EndData);
        }