Exemplo n.º 1
0
 private void Release()
 {
     if (this.m_displacementBuffer != null)
     {
         this.m_displacementBuffer.Release();
         this.m_displacementBuffer = null;
     }
     if (this.m_slopeBuffer != null)
     {
         this.m_slopeBuffer.Release();
         this.m_slopeBuffer = null;
     }
     if (this.m_jacobianBuffer != null)
     {
         this.m_jacobianBuffer.Release();
         this.m_jacobianBuffer = null;
     }
     if (this.m_readBuffer != null)
     {
         this.m_readBuffer.Release();
         this.m_readBuffer = null;
     }
     if (this.m_conditions != null && this.m_conditions[0] != null && this.m_conditions[0].Done)
     {
         this.CacheCondition(this.m_conditions[0]);
         if (this.m_conditionCache == null || !this.m_conditionCache.ContainsKey(this.m_conditions[0].Key))
         {
             this.m_conditions[0].Release();
             this.m_conditions[0] = null;
         }
     }
     if (this.m_conditions != null && this.m_conditions[1] != null && this.m_conditions[1].Done && (this.m_conditionCache == null || !this.m_conditionCache.ContainsKey(this.m_conditions[1].Key)))
     {
         this.m_conditions[1].Release();
         this.m_conditions[1] = null;
     }
     this.m_conditions    = null;
     this.m_findRangeTask = null;
     RTUtility.ReleaseAndDestroy(this.m_displacementMaps);
     this.m_displacementMaps = null;
     RTUtility.ReleaseAndDestroy(this.m_slopeMaps);
     this.m_slopeMaps = null;
     RTUtility.ReleaseAndDestroy(this.m_foamMaps);
     this.m_foamMaps = null;
 }
Exemplo n.º 2
0
        private void CreateBuffers()
        {
            int  num;
            bool flag;

            this.GetFourierSize(out num, out flag);
            if (this.m_bufferSettings.beenCreated)
            {
                if (this.m_bufferSettings.size == num && this.m_bufferSettings.isCpu == flag)
                {
                    return;
                }
                while (this.m_scheduler.HasTasks())
                {
                    this.UpdateSpectrumScheduler();
                }
                this.Release();
                this.m_bufferSettings.beenCreated = false;
            }
            if (flag)
            {
                this.m_displacementBuffer = new DisplacementBufferCPU(num, this.m_scheduler);
            }
            else
            {
                this.m_displacementBuffer = new DisplacementBufferGPU(num, this.fourierSdr);
            }
            this.m_slopeBuffer                = new WaveSpectrumBufferGPU(num, this.fourierSdr, 2);
            this.m_jacobianBuffer             = new WaveSpectrumBufferGPU(num, this.fourierSdr, 3);
            this.m_readBuffer                 = new ComputeBuffer(num * num, 12);
            this.m_conditions                 = new WaveSpectrumCondition[2];
            this.m_displacementMaps           = new RenderTexture[4];
            this.m_slopeMaps                  = new RenderTexture[2];
            this.m_foamMaps                   = new RenderTexture[1];
            this.m_bufferSettings.beenCreated = true;
            this.m_bufferSettings.size        = num;
            this.m_bufferSettings.isCpu       = flag;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Release all data.
        /// </summary>
        void Release()
        {
            if (m_displacementBuffer != null)
            {
                m_displacementBuffer.Release();
                m_displacementBuffer = null;
            }

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

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

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

			if(m_conditions != null && m_conditions[0] != null && m_conditions[0].Done)
            {

                //Cache the condition so it can be resued.
                CacheCondition(m_conditions[0]);

                //if not a cached condition then release it.
                if (m_conditionCache == null || !m_conditionCache.ContainsKey(m_conditions[0].Key))
                {
                    m_conditions[0].Release();
                    m_conditions[0] = null;
                }
     
            }

			if(m_conditions != null && m_conditions[1] != null && m_conditions[1].Done)
            {
                //if not a cached condition then release it.
                if (m_conditionCache == null || !m_conditionCache.ContainsKey(m_conditions[1].Key))
                {
                    m_conditions[1].Release();
                    m_conditions[1] = null;
                }
            }

            m_conditions = null;
			m_findRangeTask = null;

            RTUtility.ReleaseAndDestroy(m_displacementMaps);
            m_displacementMaps = null;

            RTUtility.ReleaseAndDestroy(m_slopeMaps);
            m_slopeMaps = null;

            RTUtility.ReleaseAndDestroy(m_foamMaps);
            m_foamMaps = null;

        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates all the buffers and related data. 
        /// If fourier settings have changed the buffers
        /// are all released and recreated with new settings.
        /// </summary>
        void CreateBuffers()
        {
            int size;
            bool isCpu;
            GetFourierSize(out size, out isCpu);

            if (m_bufferSettings.beenCreated)
            {
                //buffers have already been created.
                //Check to see if settings have changed.

                if (m_bufferSettings.size == size &&
                    m_bufferSettings.isCpu == isCpu)
                {
                    //settings have not changed.
                    return;
                }
                else
                {
					//Process all tasks until scheduler is empty.
					while(m_scheduler.HasTasks())
						UpdateSpectrumScheduler();

                    //Settings changed and safe to recreate buffers.
                    //Clear everything and reset.
                    Release();
                    m_bufferSettings.beenCreated = false;
                    
                }

            }

            //Displacements can be carried out on the CPU or GPU.
            //Only CPU displacements support height queries for buoyancy currently.
            if (isCpu)
                m_displacementBuffer = new DisplacementBufferCPU(size, m_scheduler);
            else
                m_displacementBuffer = new DisplacementBufferGPU(size, fourierSdr);

            m_slopeBuffer = new WaveSpectrumBufferGPU(size, fourierSdr, 2);
            m_jacobianBuffer = new WaveSpectrumBufferGPU(size, fourierSdr, 3);

            m_readBuffer = new ComputeBuffer(size * size, sizeof(float) * 3);

            m_conditions = new WaveSpectrumCondition[2];
            m_displacementMaps = new RenderTexture[4];
            m_slopeMaps = new RenderTexture[2];
            m_foamMaps = new RenderTexture[1];

            m_bufferSettings.beenCreated = true;
            m_bufferSettings.size = size;
            m_bufferSettings.isCpu = isCpu;

        }
Exemplo n.º 5
0
 private void Release()
 {
     if (this.m_displacementBuffer != null)
     {
         this.m_displacementBuffer.Release();
         this.m_displacementBuffer = null;
     }
     if (this.m_slopeBuffer != null)
     {
         this.m_slopeBuffer.Release();
         this.m_slopeBuffer = null;
     }
     if (this.m_jacobianBuffer != null)
     {
         this.m_jacobianBuffer.Release();
         this.m_jacobianBuffer = null;
     }
     if (this.m_readBuffer != null)
     {
         this.m_readBuffer.Release();
         this.m_readBuffer = null;
     }
     if (this.m_conditions != null && this.m_conditions[0] != null && this.m_conditions[0].Done)
     {
         this.CacheCondition(this.m_conditions[0]);
         if (this.m_conditionCache == null || !this.m_conditionCache.ContainsKey(this.m_conditions[0].Key))
         {
             this.m_conditions[0].Release();
             this.m_conditions[0] = null;
         }
     }
     if (this.m_conditions != null && this.m_conditions[1] != null && this.m_conditions[1].Done && (this.m_conditionCache == null || !this.m_conditionCache.ContainsKey(this.m_conditions[1].Key)))
     {
         this.m_conditions[1].Release();
         this.m_conditions[1] = null;
     }
     this.m_conditions = null;
     this.m_findRangeTask = null;
     RTUtility.ReleaseAndDestroy(this.m_displacementMaps);
     this.m_displacementMaps = null;
     RTUtility.ReleaseAndDestroy(this.m_slopeMaps);
     this.m_slopeMaps = null;
     RTUtility.ReleaseAndDestroy(this.m_foamMaps);
     this.m_foamMaps = null;
 }
Exemplo n.º 6
0
 private void CreateBuffers()
 {
     int num;
     bool flag;
     this.GetFourierSize(out num, out flag);
     if (this.m_bufferSettings.beenCreated)
     {
         if (this.m_bufferSettings.size == num && this.m_bufferSettings.isCpu == flag)
         {
             return;
         }
         while (this.m_scheduler.HasTasks())
         {
             this.UpdateSpectrumScheduler();
         }
         this.Release();
         this.m_bufferSettings.beenCreated = false;
     }
     if (flag)
     {
         this.m_displacementBuffer = new DisplacementBufferCPU(num, this.m_scheduler);
     }
     else
     {
         this.m_displacementBuffer = new DisplacementBufferGPU(num, this.fourierSdr);
     }
     this.m_slopeBuffer = new WaveSpectrumBufferGPU(num, this.fourierSdr, 2);
     this.m_jacobianBuffer = new WaveSpectrumBufferGPU(num, this.fourierSdr, 3);
     this.m_readBuffer = new ComputeBuffer(num * num, 12);
     this.m_conditions = new WaveSpectrumCondition[2];
     this.m_displacementMaps = new RenderTexture[4];
     this.m_slopeMaps = new RenderTexture[2];
     this.m_foamMaps = new RenderTexture[1];
     this.m_bufferSettings.beenCreated = true;
     this.m_bufferSettings.size = num;
     this.m_bufferSettings.isCpu = flag;
 }