public MapDisplay.LODArrays CopySolidArraysUsingCounts()
        {
            var lod = MapDisplay.LODArrays.Create();

            for (int i = 0; i < ChunkGenData.LODLevels; ++i)
            {
                lod[i] = BufferCountArgs.GetData <VoxelGeomDataMirror>(GetSolidAtLOD(i));
            }
            return(lod);
        }
        private void SetTotalsCountBuffer()
        {
            var totals = new int[vGenConfig.NumLODLevels];

            totals[0] = BufferCountArgs.FromBuffer(ShownVoxels).count;
            totals[1] = BufferCountArgs.FromBuffer(ShownVoxelsLOD2).count;
            totals[2] = BufferCountArgs.FromBuffer(ShownVoxelsLOD4).count;

            BufferUtil.ReleaseBuffers(TotalVoxelsPerLODCount);
            TotalVoxelsPerLODCount = new ComputeBuffer(totals.Length, sizeof(int));
            TotalVoxelsPerLODCount.SetData(totals);
        }
        //
        // Face copy kernels copy voxel data into packed arrays
        // Release each buffer reference (possibly pointing to data for which we are no longer responsible)
        // before assigning it to a new buffer.
        //
        public void callFaceCopyKernel()
        {
            int buffCreateError = 0;

            BufferUtil.ReleaseBuffers(SolidVoxels, SolidVoxelsLOD2, SolidVoxelsLOD4, TotalVoxelsPerLODCount);

            if (!BufferCountArgs.CreateBufferFromCount <VoxelGeomDataMirror>(ShownVoxels, out SolidVoxels))
            {
                buffCreateError++;
            }
            else
            {
                meshGen.SetBuffer(FaceCopyKernel, "SolidVoxels", SolidVoxels);
            }

            if (!BufferCountArgs.CreateBufferFromCount <VoxelGeomDataMirror>(ShownVoxelsLOD2, out SolidVoxelsLOD2))
            {
                buffCreateError++;
            }
            else
            {
                meshGen.SetBuffer(FaceCopyKernel, "SolidVoxelsLOD2", SolidVoxelsLOD2);
            }

            if (!BufferCountArgs.CreateBufferFromCount <VoxelGeomDataMirror>(ShownVoxelsLOD4, out SolidVoxelsLOD4))
            {
                buffCreateError++;
            }
            else
            {
                meshGen.SetBuffer(FaceCopyKernel, "SolidVoxelsLOD4", SolidVoxelsLOD4);
            }

            if (buffCreateError > 0)
            {
                BufferUtil.ReleaseBuffers(SolidVoxels, SolidVoxelsLOD2, SolidVoxelsLOD4, TotalVoxelsPerLODCount);
                //DBUG
                Debug.Log("Got buff create error: " + buffCreateError);
                //END DBUG
                return;
            }


            SetTotalsCountBuffer();
            meshGen.SetBuffer(FaceCopyKernel, "TotalVoxelsPerLODCount", TotalVoxelsPerLODCount);
            meshGen.Dispatch(FaceCopyKernel, 1, 1, 1);
        }
Exemple #4
0
        public void callFaceCopyKernel()
        {
            BufferCountArgs args = getBufferCount(ShownVoxels);

            if (args.count < 1)
            {
                return;
            }

            releaseSolidVoxels();

            SolidVoxels = new ComputeBuffer(args.count, sizeof(uint));
            meshGen.SetBuffer(FaceCopyKernel, "SolidVoxels", SolidVoxels);

            //ifdef CPU SIDE

            releaseHilbert();
            HilbertIndices = new ComputeBuffer(lod2HindicesCPUSide.Count, sizeof(int));
            meshGen.SetBuffer(FaceCopyKernel, "hilbertIndices", HilbertIndices);

            releaseOutHilbert();
            OutHilbertIndices = new ComputeBuffer(lod2HindicesCPUSide.Count, sizeof(int));
            meshGen.SetBuffer(FaceCopyKernel, "outHilbertIndices", OutHilbertIndices);

            meshGen.Dispatch(FaceCopyKernel, 1, 1, 1);

            // else

            /* // ifndef CPU SIDE
             * meshGen.SetBuffer(FaceCopyKernel, "hilbertIndices", HilbertIndices);
             *
             * BufferCountArgs hargs = getBufferCount(HilbertIndices);
             *
             * releaseOutHilbert(); //want this here?
             * OutHilbertIndices = new ComputeBuffer(Mathf.Max(1, hargs.count), sizeof(uint));
             * meshGen.SetBuffer(FaceCopyKernel, "outHilbertIndices", OutHilbertIndices);
             *
             * meshGen.Dispatch(FaceCopyKernel, 1, 1, 1);
             */

            // endif
        }
 public BufferCountArgs getBufferCount(ComputeBuffer buffer)
 {
     return(BufferCountArgs.FromBuffer(buffer));
 }