示例#1
0
        public void releaseTemporaryBuffers()
        {
            ComputeBuffer[] buffs = new ComputeBuffer[]
            {
                ShownVoxelCount,
                ShownVoxelOffset,
                ShownVoxels,
                ShownVoxelsLOD2,
                ShownVoxelsLOD4,
                TotalVoxelsPerLODCount,
                HilbertIndices,
                OutHilbertIndices,
                HilbertLODRanges,
                SolidVoxels,
                SolidVoxelsLOD2,
                SolidVoxelsLOD4
            };
            BufferUtil.ReleaseBuffers(buffs);

            //int i = 0;
            //foreach (var buff in buffs)
            //{
            //    if (buff == null)
            //    {
            //        Debug.Log("buff " + i + "was already null");
            //    }
            //    i++;
            //    releaseBuffer(buff);
            //}
        }
示例#2
0
 public void DebugSetSolids(ChunkGenData data)
 {
     BufferUtil.ReleaseBuffers(SolidVoxels, SolidVoxelsLOD2, SolidVoxelsLOD4);
     for (int i = 0; i < data.displays.lodArrays.Length; ++i)
     {
         DebugSetSolidAt(i, data.displays.lodArrays[i]);
     }
 }
示例#3
0
 public void Release()
 {
     ComputeBuffer[] buffs = new ComputeBuffer[]
     {
         TotalVoxelsPerLODCount,
         SolidVoxels,
         SolidVoxelsLOD2,
         SolidVoxelsLOD4
     };
     BufferUtil.ReleaseBuffers(buffs);
 }
示例#4
0
        //TODO: possible to use counting buffers to
        // avoid releasing resetting like this?
        void ResetBufferData(uint[] nextData)
        {
            BufferUtil.ReleaseBuffers(buffer);

            if (nextData.Length == 0)
            {
                return;
            }

            buffer = new ComputeBuffer(nextData.Length, sizeof(uint));
            buffer.SetData(nextData);
        }
 public void Release()
 {
     BufferUtil.ReleaseBuffers(
         MapVoxels,
         MapVoxelsLOD2,
         MapVoxelsLOD4,
         ExistsMap27,
         ShownVoxels,
         ShownVoxelsLOD2,
         ShownVoxelsLOD4
         );
 }
示例#6
0
        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);
        }
示例#7
0
        //
        // 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);
        }
示例#8
0
 private void OnDestroy()
 {
     BufferUtil.ReleaseBuffers(buffer);
 }
示例#9
0
 private void OnDestroy()
 {
     BufferUtil.ReleaseBuffers(storage.Values.ToArray());
 }
示例#10
0
 public void releaseTemporaryBuffers()
 {
     BufferUtil.ReleaseBuffers(MapVoxels, MapVoxelsLOD2, MapVoxelsLOD4, MapHeights, ExistsMap);
 }