예제 #1
0
 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;
 }
예제 #2
0
                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);
                    }
                }
예제 #3
0
            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);
            }