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); }
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); }
public void Free(StagingBlock block) { lock (_lock) { if (!_disposed) { Debug.Assert(block.Id < _storage.Count); _availableBlocks.Add(block.Capacity, block.Id); } } }
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); } }
public override Shader CreateShader(ref ShaderDescription description) { StagingBlock stagingBlock = _pool.Stage(description.ShaderBytes); return(new OpenGLShader(_gd, description.Stage, stagingBlock)); }
public HandleTrackedStagingBlock(StagingBlock stagingBlock) { GCHandle = GCHandle.Alloc(stagingBlock.Array, GCHandleType.Pinned); SizeInBytes = stagingBlock.SizeInBytes; }
public void Free(StagingBlock block) { _arrayPool.Return(block.Array); }
protected override Shader CreateShaderCore(ref ShaderDescription description) { StagingBlock stagingBlock = _pool.Stage(description.ShaderBytes); return(new OpenGLShader(_gd, description.Stage, stagingBlock, description.EntryPoint)); }