private void OnDestroy() { if (_maskBuffer != null) { _maskBuffer.Release(); } }
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); }
void OnDestroy() { _vertexBuffer.Release(); _indexBuffer.Release(); Destroy(_mesh); Destroy(_computeShader); }
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(); } }
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; }
private void OnDisable() { vertexBuffer.Release(); grassBuffer.Release(); triangleBuffer.Release(); drawArgsBuffer.Release(); if (shadowMapRT != null) { shadowMapRT.Release(); } perlinRT.Release(); cam.RemoveAllCommandBuffers(); light.RemoveAllCommandBuffers(); }
void CleanUp() { if (indexBuffer != null) { indexBuffer.Release(); indexBuffer = null; } if (bufferWithArgs != null) { bufferWithArgs.Release(); bufferWithArgs = null; } vertexBuffer.Release(); }
void ReleaseGraphicsBuffer() { if (CullingPatchesBuffer != null) { CullingPatchesBuffer.Release(); CullingPatchesBuffer.Dispose(); CullingPatchesBuffer = null; } if (argBuffer != null) { argBuffer.Release(); argBuffer.Dispose(); argBuffer = null; } }
void ReleaseGraphicsBuffer() { if (PerlinPerm != null) { PerlinPerm.Release(); PerlinPerm.Dispose(); PerlinPerm = null; } if (PerlinGrad != null) { PerlinGrad.Release(); PerlinGrad.Dispose(); PerlinGrad = null; } }
void ReleaseGraphicsBuffer() { if (perm != null) { perm.Release(); perm.Dispose(); perm = null; } if (permGrad2 != null) { permGrad2.Release(); permGrad2.Dispose(); permGrad2 = null; } }
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; } }
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; } }
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); }