Ejemplo n.º 1
0
        protected override Shader CreateShaderCore(ref ShaderDescription description)
        {
            StagingBlock stagingBlock = _pool.Stage(description.ShaderBytes);
            OpenGLShader shader       = new OpenGLShader(_gd, description.Stage, stagingBlock, description.EntryPoint);

            _gd.EnsureResourceInitialized(shader);
            return(shader);
        }
Ejemplo n.º 2
0
        private void Allocate(uint sizeInBytes, out StagingBlock stagingBlock)
        {
            uint   capacity = Math.Max(MinimumCapacity, sizeInBytes);
            IntPtr ptr      = Marshal.AllocHGlobal((int)capacity);
            uint   id       = (uint)_storage.Count;

            stagingBlock = new StagingBlock(id, (void *)ptr, capacity, sizeInBytes);
            _storage.Add(stagingBlock);
        }
Ejemplo n.º 3
0
 public void Free(StagingBlock block)
 {
     lock (_lock)
     {
         if (!_disposed)
         {
             Debug.Assert(block.Id < _storage.Count);
             _availableBlocks.Add(block.Capacity, block.Id);
         }
     }
 }
Ejemplo n.º 4
0
        private void Rent(uint size, out StagingBlock block)
        {
            lock (_lock)
            {
                SortedList <uint, uint> available = _availableBlocks;
                IList <uint>            indices   = available.Values;
                for (int i = 0; i < available.Count; i++)
                {
                    int          index   = (int)indices[i];
                    StagingBlock current = _storage[index];
                    if (current.Capacity >= size)
                    {
                        available.RemoveAt(i);
                        current.SizeInBytes = size;
                        block           = current;
                        _storage[index] = current;
                        return;
                    }
                }

                Allocate(size, out block);
            }
        }
Ejemplo n.º 5
0
        public override Shader CreateShader(ref ShaderDescription description)
        {
            StagingBlock stagingBlock = _pool.Stage(description.ShaderBytes);

            return(new OpenGLShader(_gd, description.Stage, stagingBlock));
        }
Ejemplo n.º 6
0
 public HandleTrackedStagingBlock(StagingBlock stagingBlock)
 {
     GCHandle    = GCHandle.Alloc(stagingBlock.Array, GCHandleType.Pinned);
     SizeInBytes = stagingBlock.SizeInBytes;
 }
Ejemplo n.º 7
0
 public void Free(StagingBlock block)
 {
     _arrayPool.Return(block.Array);
 }
Ejemplo n.º 8
0
        protected override Shader CreateShaderCore(ref ShaderDescription description)
        {
            StagingBlock stagingBlock = _pool.Stage(description.ShaderBytes);

            return(new OpenGLShader(_gd, description.Stage, stagingBlock, description.EntryPoint));
        }