Пример #1
0
        /// <summary>
        /// Allocates global buffers.
        /// </summary>
        private void OnCapacityCountChange()
        {
            // Allocate global buffers
            bool allocateGlobalBuffer = false;

            if (globalBuffer == null)
            {
                allocateGlobalBuffer = true;
            }
            else if (globalBuffer.ElementCount != CapacityCount)
            {
                // Reallocate global buffer if capacity changed
                allocateGlobalBuffer = true;
                // Release previous buffer
                globalBuffer.Release();
                sortBuffer.Release();
            }

            // Allocate new buffers
            if (allocateGlobalBuffer)
            {
                if (CapacityCount > 0)
                {
                    globalBuffer      = Buffer.Structured.New(graphicsDeviceService.GraphicsDevice, CapacityCount, StructureSize, true);
                    globalBuffer.Name = "ParticleGlobalBuffer";
                    sortBuffer        = Buffer.Structured.New(graphicsDeviceService.GraphicsDevice, CapacityCount, sizeof(int) * 2, true);
                    sortBuffer.Name   = "ParticleSortBuffer";
                }
            }
        }
Пример #2
0
            public void DisposeBuffers()
            {
                if (AppendBuffer != null)
                {
                    AppendBuffer.Release();
                    AppendBuffer = null;
                }

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