コード例 #1
0
        /// <summary>
        /// Wait for the latest sync number that the texture handle was written to,
        /// removing the modified flag if it was reached, or leaving it set if it has not yet been created.
        /// </summary>
        /// <param name="context">The GPU context used to wait for sync</param>
        public void Sync(GpuContext context)
        {
            bool needsSync = !context.IsGpuThread();

            if (needsSync)
            {
                ulong registeredSync = _registeredSync;
                long  diff           = (long)(context.SyncNumber - registeredSync);

                if (diff > 0)
                {
                    context.Renderer.WaitSync(registeredSync);

                    if ((long)(_modifiedSync - registeredSync) > 0)
                    {
                        // Flush the data in a previous state. Do not remove the modified flag - it will be removed to ignore following writes.
                        return;
                    }

                    Modified = false;
                }

                // If the difference is <= 0, no data is not ready yet. Flush any data we can without waiting or removing modified flag.
            }
            else
            {
                Modified = false;
            }
        }