internal void Initialize(DeviceContext deviceContext, BufferBox <T> bufferBox) { this.deviceContext = deviceContext; this.bufferBox = bufferBox; this.currentBufferPointer = deviceContext.MapSubresource(bufferBox.Buffer, 0, MapMode.WriteDiscard, MapFlags.None).DataPointer; this.remaining = bufferBox.Count; }
public void Dispose() { if (currentBufferPointer != default(IntPtr)) { UpdateAndClose(); } // Zero self deviceContext = null; bufferBox = null; currentBufferPointer = default(IntPtr); remaining = 0; // return to pool lock (synchronization) { store.Push(this); } }
public static IBufferUpdater <T> Take(DeviceContext deviceContext, BufferBox <T> bufferBox) { BufferUpdater TakeUninitialized() { lock (synchronization) { if (store.Count > 0) { return(store.Pop()); } } return(new BufferUpdater()); } var updater = TakeUninitialized(); updater.Initialize(deviceContext, bufferBox); return(updater); }