Beispiel #1
0
        /// <summary>
        /// Initializes the data for a texture. Can optionally initialize the texture with or without data.
        /// If the texture is a view, it will initialize memory tracking to be non-dirty.
        /// </summary>
        /// <param name="isView">True if the texture is a view, false otherwise</param>
        /// <param name="withData">True if the texture is to be initialized with data</param>
        public void InitializeData(bool isView, bool withData = false)
        {
            _memoryTracking = _context.PhysicalMemory.BeginTracking(Range);

            if (withData)
            {
                Debug.Assert(!isView);

                TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities, ScaleFactor);
                HostTexture = _context.Renderer.CreateTexture(createInfo, ScaleFactor);

                SynchronizeMemory(); // Load the data.
                if (ScaleMode == TextureScaleMode.Scaled)
                {
                    SetScale(GraphicsConfig.ResScale); // Scale the data up.
                }
            }
            else
            {
                // Don't update this texture the next time we synchronize.
                ConsumeModified();
                _hasData = true;

                if (!isView)
                {
                    if (ScaleMode == TextureScaleMode.Scaled)
                    {
                        // Don't need to start at 1x as there is no data to scale, just go straight to the target scale.
                        ScaleFactor = GraphicsConfig.ResScale;
                    }

                    TextureCreateInfo createInfo = TextureManager.GetCreateInfo(Info, _context.Capabilities, ScaleFactor);
                    HostTexture = _context.Renderer.CreateTexture(createInfo, ScaleFactor);
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Disables memory tracking on this texture. Currently used for view containers, as we assume their views are covering all memory regions.
 /// Textures with disabled memory tracking also cannot flush in most circumstances.
 /// </summary>
 public void DisableMemoryTracking()
 {
     _memoryTracking?.Dispose();
     _memoryTracking = null;
 }