예제 #1
0
 private void OnDestroy()
 {
     if (_maskBuffer != null)
     {
         _maskBuffer.Release();
     }
 }
예제 #2
0
        void Reallocate(int newSize)
        {
            if (m_Buffer != null)
            {
                m_Buffer.Release();
            }

            m_Buffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, newSize, Marshal.SizeOf(typeof(CustomData)));
            m_Buffer.SetData(new CustomData[newSize]);

            var vfx = GetComponent <VisualEffect>();

            vfx.SetGraphicsBuffer(s_BufferID, m_Buffer);
        }
예제 #3
0
 void OnDestroy()
 {
     _vertexBuffer.Release();
     _indexBuffer.Release();
     Destroy(_mesh);
     Destroy(_computeShader);
 }
예제 #4
0
    private void OnDestroy()
    {
        if (quadTree != null)
        {
            quadTree.Release();
            quadTree = null;
        }

        if (perlin != null)
        {
            perlin.Release();
            perlin = null;
        }

        if (meshTerrain != null)
        {
            meshTerrain.Clear();
            meshTerrain = null;
        }

        if (argBuffer != null)
        {
            argBuffer.Release();
            argBuffer.Dispose();
            argBuffer = null;
        }

        renderPatchesBuffer = null;
    }
        void CreateOrResizeIdxBuffer(ref GraphicsBuffer buffer, int count)
        {
            int num = ((count - 1) / 256 + 1) * 256;

            buffer?.Release();
            buffer = new GraphicsBuffer(GraphicsBuffer.Target.Index, num, UnsafeUtility.SizeOf <ushort>());
        }
 void OnDestroy()
 {
     if (bvhBuffer != null)
     {
         bvhBuffer.Release();
     }
     if (triangleBuffer != null)
     {
         triangleBuffer.Release();
     }
 }
예제 #7
0
 void Release()
 {
     if (_Mesh != null)
     {
         Destroy(_Mesh);
     }
     if (_GraphicsBuffer != null)
     {
         _GraphicsBuffer.Release();
     }
 }
        public void Shutdown(ImGuiIOPtr io)
        {
            io.SetBackendRendererName(null);

            if (_material != null)
            {
                Object.Destroy(_material); _material = null;
            }
            _vtxBuf?.Release(); _vtxBuf = null;
            _idxBuf?.Release(); _idxBuf = null;
            _argBuf?.Release(); _argBuf = null;
        }
예제 #9
0
 private void OnDisable()
 {
     vertexBuffer.Release();
     grassBuffer.Release();
     triangleBuffer.Release();
     drawArgsBuffer.Release();
     if (shadowMapRT != null)
     {
         shadowMapRT.Release();
     }
     perlinRT.Release();
     cam.RemoveAllCommandBuffers();
     light.RemoveAllCommandBuffers();
 }
예제 #10
0
 void CleanUp()
 {
     if (indexBuffer != null)
     {
         indexBuffer.Release();
         indexBuffer = null;
     }
     if (bufferWithArgs != null)
     {
         bufferWithArgs.Release();
         bufferWithArgs = null;
     }
     vertexBuffer.Release();
 }
예제 #11
0
    void ReleaseGraphicsBuffer()
    {
        if (CullingPatchesBuffer != null)
        {
            CullingPatchesBuffer.Release();
            CullingPatchesBuffer.Dispose();
            CullingPatchesBuffer = null;
        }

        if (argBuffer != null)
        {
            argBuffer.Release();
            argBuffer.Dispose();
            argBuffer = null;
        }
    }
예제 #12
0
    void ReleaseGraphicsBuffer()
    {
        if (PerlinPerm != null)
        {
            PerlinPerm.Release();
            PerlinPerm.Dispose();
            PerlinPerm = null;
        }

        if (PerlinGrad != null)
        {
            PerlinGrad.Release();
            PerlinGrad.Dispose();
            PerlinGrad = null;
        }
    }
예제 #13
0
    void ReleaseGraphicsBuffer()
    {
        if (perm != null)
        {
            perm.Release();
            perm.Dispose();
            perm = null;
        }

        if (permGrad2 != null)
        {
            permGrad2.Release();
            permGrad2.Dispose();
            permGrad2 = null;
        }
    }
예제 #14
0
 public void ReleaseShader()
 {
     if (vertexBuffer != null)
     {
         vertexBuffer.Release();
     }
     if (grassBuffer != null)
     {
         grassBuffer.Release();
     }
     if (triangleBuffer != null)
     {
         triangleBuffer.Release();
     }
     if (drawArgsBuffer != null)
     {
         drawArgsBuffer.Release();
     }
 }
 public void Dispose()
 {
     Debug.Log("release buffers");
     if (_positionBuffer != null)
     {
         _positionBuffer.Release();
         _positionBuffer = null;
     }
     if (_velocitiesBuffer != null)
     {
         _velocitiesBuffer.Release();
         _velocitiesBuffer = null;
     }
     if (_indexBuffer != null)
     {
         _indexBuffer.Release();
         _indexBuffer = null;
     }
 }
예제 #16
0
    void ReleaseGraphicsBuffer()
    {
        if (ConsumeNodeList != null)
        {
            ConsumeNodeList.Release();
            ConsumeNodeList.Dispose();
            ConsumeNodeList = null;
        }

        if (AppendNodeList != null)
        {
            AppendNodeList.Release();
            AppendNodeList.Dispose();
            AppendNodeList = null;
        }

        if (AppendFinalNodeList != null)
        {
            AppendFinalNodeList.Release();
            AppendFinalNodeList.Dispose();
            AppendFinalNodeList = null;
        }

        if (CounterBuffer != null)
        {
            CounterBuffer.Release();
            CounterBuffer.Dispose();
            CounterBuffer = null;
        }

        if (NodeDescriptorBuffer != null)
        {
            NodeDescriptorBuffer.Release();
            NodeDescriptorBuffer.Dispose();
            NodeDescriptorBuffer = null;
        }
    }
예제 #17
0
        public static bool Run(GrassBakeSettings settings, int lod, out Mesh generatedMesh)
        {
            GrassLODLevelSettings currentLOD;

            try
            {
                currentLOD = settings.grassLODLevelSettings[lod];
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                generatedMesh = null;
                return(false);
            }

            DecomposeMesh(currentLOD.grassBladeMesh, 0, out SourceVertex[] sourceGrassBladeVertices, out int[] sourceGrassBladeIndices);

            int numBlades = (int)((settings.extents.x / settings.numTiles.x) * (settings.extents.y / settings.numTiles.y)
                                  / (currentLOD.density * currentLOD.density));

            GeneratedVertex[] generatedVertices = new GeneratedVertex[numBlades * sourceGrassBladeVertices.Length];
            int[]             generatedIndices  = new int[numBlades * sourceGrassBladeIndices.Length];

            GraphicsBuffer sourceGrassBladeVertexBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, sourceGrassBladeIndices.Length, SOURCE_VERTEX_STRIDE);
            GraphicsBuffer sourceGrassBladeIndexBuffer  = new GraphicsBuffer(GraphicsBuffer.Target.Structured, sourceGrassBladeIndices.Length, SOURCE_INDEX_STRIDE);
            GraphicsBuffer generatedVertexBuffer        = new GraphicsBuffer(GraphicsBuffer.Target.Structured, generatedVertices.Length, GENERATED_VERTEX_STRIDE);
            GraphicsBuffer generatedIndexBuffer         = new GraphicsBuffer(GraphicsBuffer.Target.Structured, generatedIndices.Length, GENERATED_INDEX_STRIDE);

            ComputeShader shader        = settings.computeShader;
            int           idGrassKernel = shader.FindKernel("CSMain");

            shader.SetBuffer(idGrassKernel, "_SourceGrassBladeVertices", sourceGrassBladeVertexBuffer);
            shader.SetBuffer(idGrassKernel, "_SourceGrassBladeIndices", sourceGrassBladeIndexBuffer);
            shader.SetBuffer(idGrassKernel, "_GeneratedVertices", generatedVertexBuffer);
            shader.SetBuffer(idGrassKernel, "_GeneratedIndices", generatedIndexBuffer);
            shader.SetVector("_MinMaxRandomScale", currentLOD.minMaxScale);
            shader.SetVector("_TileSize", settings.extents / settings.numTiles);
            shader.SetFloat("_Density", currentLOD.density);
            shader.SetFloat("_MaxRandomPositionShift", currentLOD.maxRandomPositionShift);
            shader.SetInt("_NumGrassBladeVertices", sourceGrassBladeVertices.Length);
            shader.SetInt("_NumGrassBladeIndices", sourceGrassBladeIndices.Length);

            sourceGrassBladeVertexBuffer.SetData(sourceGrassBladeVertices);
            sourceGrassBladeIndexBuffer.SetData(sourceGrassBladeIndices);

            int numBladesRemaining = numBlades;

            for (int i = 0; i <= generatedVertices.Length / MAX_VERTS_PER_DISPATCH; ++i)
            {
                int maxBlades            = MAX_VERTS_PER_DISPATCH / sourceGrassBladeVertices.Length;
                int numBladesToCalculate = numBladesRemaining > maxBlades ? maxBlades : numBladesRemaining;
                if (numBladesRemaining == 0)
                {
                    break;
                }

                shader.SetInt("_NumBlades", numBladesToCalculate);
                shader.SetInt("_StartBladeIndex", i * maxBlades);
                shader.SetInt("_StartVertexIndex", i * Mathf.FloorToInt((float)MAX_VERTS_PER_DISPATCH / sourceGrassBladeVertices.Length) * sourceGrassBladeVertices.Length);
                shader.GetKernelThreadGroupSizes(idGrassKernel, out uint threadGroupSize, out _, out _);
                int dispatchSize = Mathf.CeilToInt((float)numBladesToCalculate / threadGroupSize);
                shader.Dispatch(idGrassKernel, dispatchSize, 1, 1);

                generatedVertexBuffer.GetData(generatedVertices, i * maxBlades * sourceGrassBladeVertices.Length, 0, numBladesToCalculate * sourceGrassBladeVertices.Length);
                generatedIndexBuffer.GetData(generatedIndices, i * maxBlades * sourceGrassBladeIndices.Length, 0, numBladesToCalculate * sourceGrassBladeIndices.Length);

                numBladesRemaining -= numBladesToCalculate;
            }

            generatedMesh = ComposeMesh(generatedVertices, generatedIndices);

            sourceGrassBladeVertexBuffer.Release();
            sourceGrassBladeIndexBuffer.Release();
            generatedVertexBuffer.Release();
            generatedIndexBuffer.Release();

            return(true);
        }
 void OnDestroy()
 {
     _buffer.Release();
     _drawArgsBuffer.Release();
     _indexBuffer.Release();
 }
 void OnDestroy()
 {
     _vertexBuffer.Release();
     _indexBuffer.Release();
     Destroy(_mesh);
 }