Exemple #1
0
        /// <summary>
        /// Creates a new instance of the physical memory.
        /// </summary>
        /// <param name="cpuMemory">CPU memory manager of the application process</param>
        public PhysicalMemory(IVirtualMemoryManagerTracked cpuMemory)
        {
            _cpuMemory = cpuMemory;

            if (_cpuMemory is IRefCounted rc)
            {
                rc.IncrementReferenceCount();
            }
        }
Exemple #2
0
        /// <summary>
        /// Release our reference to the CPU memory manager.
        /// </summary>
        public void Dispose()
        {
            if (_cpuMemory is IRefCounted rc)
            {
                rc.DecrementReferenceCount();

                _cpuMemory = null;
            }
        }
Exemple #3
0
        /// <summary>
        /// Creates a new instance of the physical memory.
        /// </summary>
        /// <param name="context">GPU context that the physical memory belongs to</param>
        /// <param name="cpuMemory">CPU memory manager of the application process</param>
        public PhysicalMemory(GpuContext context, IVirtualMemoryManagerTracked cpuMemory)
        {
            _context     = context;
            _cpuMemory   = cpuMemory;
            ShaderCache  = new ShaderCache(context);
            BufferCache  = new BufferCache(context, this);
            TextureCache = new TextureCache(context, this);

            if (cpuMemory is IRefCounted rc)
            {
                rc.IncrementReferenceCount();
            }

            _referenceCount = 1;
        }