public class MPSCommandBuffer extends NSObject implements MTLCommandBuffer
A MPSCommandBuffer object is used to wrap an existing command buffer with MPS specific options.
A MPS kernel typically operates between a fixed set of inputs and outputs. The MPSCommandBuffer class provides a way to add further encode-time parameters to the encode call using the command buffer. Currently the only parameter included in the MPSCommandBuffer that all MPS kernels support is the the predicate option, which can be used to pre-empt the kernel from the GPU side. NOTE: the options that contain metal resources will be referenced by this object and therefore it is advisable to make the lifetime of this object as short as possible as is the case for all command buffers.
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_retMTLCommandBuffer.Block_addCompletedHandler, MTLCommandBuffer.Block_addScheduledHandler| Modifier | Constructor and Description |
|---|---|
protected |
MPSCommandBuffer(org.moe.natj.general.Pointer peer) |
| Modifier and Type | Method and Description |
|---|---|
MTLAccelerationStructureCommandEncoder |
accelerationStructureCommandEncoder() |
static boolean |
accessInstanceVariablesDirectly() |
void |
addCompletedHandler(MTLCommandBuffer.Block_addCompletedHandler block)
addCompletedHandler:block:
|
void |
addScheduledHandler(MTLCommandBuffer.Block_addScheduledHandler block)
addScheduledHandler:block:
|
static MPSCommandBuffer |
alloc() |
static MPSCommandBuffer |
allocWithZone(org.moe.natj.general.ptr.VoidPtr zone) |
static boolean |
automaticallyNotifiesObserversForKey(java.lang.String key) |
MTLBlitCommandEncoder |
blitCommandEncoder()
blitCommandEncoder
|
MTLBlitCommandEncoder |
blitCommandEncoderWithDescriptor(MTLBlitPassDescriptor blitPassDescriptor)
blitCommandEncoderWithDescriptor:
|
static void |
cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget) |
static void |
cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument) |
static NSArray<java.lang.String> |
classFallbacksForKeyedArchiver() |
static org.moe.natj.objc.Class |
classForKeyedUnarchiver() |
MTLCommandBuffer |
commandBuffer()
[@property] commandBuffer
|
static MPSCommandBuffer |
commandBufferFromCommandQueue(MTLCommandQueue commandQueue)
Initializes a MPSCommandBuffer object from a given command queue.
|
static MPSCommandBuffer |
commandBufferWithCommandBuffer(MTLCommandBuffer commandBuffer)
Initializes a MPSCommandBuffer object with given MTLCommandBuffer.
|
MTLCommandQueue |
commandQueue()
[@property] commandQueue
|
void |
commit()
commit
|
void |
commitAndContinue()
Commit work encoded so far and continue with a new underlying command buffer
|
MTLComputeCommandEncoder |
computeCommandEncoder()
computeCommandEncoder
|
MTLComputeCommandEncoder |
computeCommandEncoderWithDescriptor(MTLComputePassDescriptor computePassDescriptor)
computeCommandEncoderWithDescriptor:
|
MTLComputeCommandEncoder |
computeCommandEncoderWithDispatchType(long dispatchType)
computeCommandEncoderWithDispatchType
|
static java.lang.String |
debugDescription_static() |
static java.lang.String |
description_static() |
MTLDevice |
device()
[@property] device
|
void |
encodeSignalEventValue(MTLEvent event,
long value)
encodeSignalEvent:value:
|
void |
encodeWaitForEventValue(MTLEvent event,
long value)
encodeWaitForEvent:value:
|
void |
enqueue()
enqueue
|
NSError |
error()
[@property] error
|
long |
errorOptions()
The set of options configuring the error reporting of the created command buffer.
|
double |
GPUEndTime()
[@property] GPUEndTime
|
double |
GPUStartTime()
[@property] GPUStartTime
|
static long |
hash_static() |
MPSHeapProvider |
heapProvider()
[@property] heapProvider
|
MPSCommandBuffer |
init() |
MPSCommandBuffer |
initWithCommandBuffer(MTLCommandBuffer commandBuffer)
Initializes an empty MPSCommandBuffer object with given MTLCommandBuffer.
|
static NSObject.Function_instanceMethodForSelector_ret |
instanceMethodForSelector(org.moe.natj.objc.SEL aSelector) |
static NSMethodSignature |
instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
instancesRespondToSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
isSubclassOfClass(org.moe.natj.objc.Class aClass) |
double |
kernelEndTime() |
double |
kernelStartTime() |
static NSSet<java.lang.String> |
keyPathsForValuesAffectingValueForKey(java.lang.String key) |
java.lang.String |
label()
[@property] label
|
MTLLogContainer |
logs()
[@property] logs
|
static MPSCommandBuffer |
new_objc() |
MTLParallelRenderCommandEncoder |
parallelRenderCommandEncoderWithDescriptor(MTLRenderPassDescriptor renderPassDescriptor)
parallelRenderCommandEncoderWithDescriptor:
|
void |
popDebugGroup()
popDebugGroup
|
MPSPredicate |
predicate()
[@property] predicate
|
void |
prefetchHeapForWorkloadSize(long size)
Prefetch heap into the MPS command buffer heap cache.
|
void |
presentDrawable(MTLDrawable drawable)
presentDrawable:
|
void |
presentDrawableAfterMinimumDuration(MTLDrawable drawable,
double duration)
presentDrawable:afterMinimumDuration:
|
void |
presentDrawableAtTime(MTLDrawable drawable,
double presentationTime)
presentDrawable:atTime:
|
void |
pushDebugGroup(java.lang.String string)
pushDebugGroup:
|
MTLRenderCommandEncoder |
renderCommandEncoderWithDescriptor(MTLRenderPassDescriptor renderPassDescriptor)
renderCommandEncoderWithDescriptor:
|
static boolean |
resolveClassMethod(org.moe.natj.objc.SEL sel) |
static boolean |
resolveInstanceMethod(org.moe.natj.objc.SEL sel) |
MTLResourceStateCommandEncoder |
resourceStateCommandEncoder() |
MTLResourceStateCommandEncoder |
resourceStateCommandEncoderWithDescriptor(MTLResourceStatePassDescriptor resourceStatePassDescriptor) |
boolean |
retainedReferences()
[@property] retainedReferences
|
MTLCommandBuffer |
rootCommandBuffer()
[@property] rootCommandBuffer
|
void |
setHeapProvider(MPSHeapProvider value)
[@property] heapProvider
|
void |
setLabel(java.lang.String value)
[@property] label
|
void |
setPredicate(MPSPredicate value)
[@property] predicate
|
static void |
setVersion_static(long aVersion) |
long |
status()
[@property] status
|
static org.moe.natj.objc.Class |
superclass_static() |
static long |
version_static() |
void |
waitUntilCompleted()
waitUntilCompleted
|
void |
waitUntilScheduled()
waitUntilScheduled
|
accessibilityActivate, accessibilityActivationPoint, accessibilityAssistiveTechnologyFocusedIdentifiers, accessibilityAttributedHint, accessibilityAttributedLabel, accessibilityAttributedUserInputLabels, accessibilityAttributedValue, accessibilityContainerType, accessibilityCustomActions, accessibilityCustomRotors, accessibilityDecrement, accessibilityDragSourceDescriptors, accessibilityDropPointDescriptors, accessibilityElementAtIndex, accessibilityElementCount, accessibilityElementDidBecomeFocused, accessibilityElementDidLoseFocus, accessibilityElementIsFocused, accessibilityElements, accessibilityElementsHidden, accessibilityFrame, accessibilityHint, accessibilityIncrement, accessibilityLabel, accessibilityLanguage, accessibilityNavigationStyle, accessibilityPath, accessibilityPerformEscape, accessibilityPerformMagicTap, accessibilityRespondsToUserInteraction, accessibilityScroll, accessibilityTextualContext, accessibilityTraits, accessibilityUserInputLabels, accessibilityValue, accessibilityViewIsModal, addObserverForKeyPathOptionsContext, attemptRecoveryFromErrorOptionIndex, attemptRecoveryFromErrorOptionIndexDelegateDidRecoverSelectorContextInfo, autoContentAccessingProxy, awakeAfterUsingCoder, awakeFromNib, class_objc, classForCoder, classForKeyedArchiver, copy, dealloc, debugDescription, description, dictionaryWithValuesForKeys, didChangeValueForKey, didChangeValueForKeyWithSetMutationUsingObjects, didChangeValuesAtIndexesForKey, doesNotRecognizeSelector, fileManagerShouldProceedAfterError, fileManagerWillProcessPath, finalize_objc, forwardingTargetForSelector, forwardInvocation, hash, indexOfAccessibilityElement, isAccessibilityElement, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableArrayValueForKey, mutableArrayValueForKeyPath, mutableCopy, mutableOrderedSetValueForKey, mutableOrderedSetValueForKeyPath, mutableSetValueForKey, mutableSetValueForKeyPath, observationInfo, observeValueForKeyPathOfObjectChangeContext, performSelector, performSelectorInBackgroundWithObject, performSelectorOnMainThreadWithObjectWaitUntilDone, performSelectorOnMainThreadWithObjectWaitUntilDoneModes, performSelectorOnThreadWithObjectWaitUntilDone, performSelectorOnThreadWithObjectWaitUntilDoneModes, performSelectorWithObject, performSelectorWithObjectAfterDelay, performSelectorWithObjectAfterDelayInModes, performSelectorWithObjectWithObject, prepareForInterfaceBuilder, provideImageDataBytesPerRowOrigin_Size_UserInfo, removeObserverForKeyPath, removeObserverForKeyPathContext, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, self, setAccessibilityActivationPoint, setAccessibilityAttributedHint, setAccessibilityAttributedLabel, setAccessibilityAttributedUserInputLabels, setAccessibilityAttributedValue, setAccessibilityContainerType, setAccessibilityCustomActions, setAccessibilityCustomRotors, setAccessibilityDragSourceDescriptors, setAccessibilityDropPointDescriptors, setAccessibilityElements, setAccessibilityElementsHidden, setAccessibilityFrame, setAccessibilityHint, setAccessibilityLabel, setAccessibilityLanguage, setAccessibilityNavigationStyle, setAccessibilityPath, setAccessibilityRespondsToUserInteraction, setAccessibilityTextualContext, setAccessibilityTraits, setAccessibilityUserInputLabels, setAccessibilityValue, setAccessibilityViewIsModal, setIsAccessibilityElement, setNilValueForKey, setObservationInfo, setShouldGroupAccessibilityChildren, setValueForKey, setValueForKeyPath, setValueForUndefinedKey, setValuesForKeysWithDictionary, shouldGroupAccessibilityChildren, superclass, validateValueForKeyError, validateValueForKeyPathError, valueForKey, valueForKeyPath, valueForUndefinedKey, willChangeValueForKey, willChangeValueForKeyWithSetMutationUsingObjects, willChangeValuesAtIndexesForKeypublic double GPUEndTime()
MTLCommandBufferThe host time in seconds that GPU finishes executing this command buffer. Returns zero if CPU has not received completion notification. This usually can be called in command buffer completion handler.
GPUEndTime in interface MTLCommandBufferpublic double GPUStartTime()
MTLCommandBufferThe host time in seconds that GPU starts executing this command buffer. Returns zero if it has not started. This usually can be called in command buffer completion handler.
GPUStartTime in interface MTLCommandBufferpublic static boolean accessInstanceVariablesDirectly()
public void addCompletedHandler(MTLCommandBuffer.Block_addCompletedHandler block)
MTLCommandBufferAdd a block to be called when this command buffer has completed execution.
addCompletedHandler in interface MTLCommandBufferpublic void addScheduledHandler(MTLCommandBuffer.Block_addScheduledHandler block)
MTLCommandBufferAdds a block to be called when this command buffer has been scheduled for execution.
addScheduledHandler in interface MTLCommandBufferpublic static MPSCommandBuffer alloc()
public static MPSCommandBuffer allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
public MTLBlitCommandEncoder blitCommandEncoder()
MTLCommandBufferreturns a blit command encoder to encode into this command buffer.
blitCommandEncoder in interface MTLCommandBufferpublic static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument)
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
public MTLCommandBuffer commandBuffer()
The Metal Command Buffer that was used to initialize this object.
public static MPSCommandBuffer commandBufferFromCommandQueue(MTLCommandQueue commandQueue)
public static MPSCommandBuffer commandBufferWithCommandBuffer(MTLCommandBuffer commandBuffer)
public MTLCommandQueue commandQueue()
MTLCommandBufferThe command queue this command buffer was created from.
commandQueue in interface MTLCommandBufferpublic void commit()
MTLCommandBufferCommit a command buffer so it can be executed as soon as possible.
commit in interface MTLCommandBufferpublic void commitAndContinue()
This method commits the underlying root MTLCommandBuffer, and makes a new one on the same command queue. The MPS heap is moved forward to the new command buffer such that temporary objects used by the previous command buffer can be still be used with the new one.
This provides a way to move work already encoded into consideration by the Metal back end sooner. For large workloads, e.g. a neural networking graph periodically calling -commitAndContinue may allow you to improve CPU / GPU parallelism without the substantial memory increases associated with double buffering. It will also help decrease overall latency.
Any Metal schedule or completion callbacks previously attached to this object will remain attached to the old command buffer and will fire as expected as the old command buffer is scheduled and completes. If your application is relying on such callbacks to coordinate retain / release of important objects that are needed for work encoded after -commitAndContinue, your application should retain these objects before calling commitAndContinue, and attach new release callbacks to this object with a new completion handler so that they persist through the lifetime of the new underlying command buffer. You may do this, for example by adding the objects to a mutable array before calling -commitAndContinue, then release the mutable array in a new completion callback added after -commitAndContinue.
Because -commitAndContinue commits the old command buffer then switches to a new one, some aspects of command buffer completion may surprise unwary developers. For example, -waitUntilCompleted called immediately after -commitAndContinue asks Metal to wait for the new command buffer to finish, not the old one. Since the new command buffer presumably hasn't been committed yet, it is formally a deadlock, resources may leak and Metal may complain. Your application should ether call -commit before -waitUntilCompleted, or capture the -rootCommandBuffer from before the call to -commitAndContinue and wait on that. Similarly, your application should be sure to use the appropriate command buffer when querying the [MTLCommandBuffer status] property.
If the underlying MTLCommandBuffer also implements -commitAndContinue, then the message will be forwarded to that object instead. In this way, underlying predicate objects and other state will be preserved.
public MTLComputeCommandEncoder computeCommandEncoder()
MTLCommandBufferreturns a compute command encoder to encode into this command buffer.
computeCommandEncoder in interface MTLCommandBufferpublic MTLComputeCommandEncoder computeCommandEncoderWithDispatchType(long dispatchType)
MTLCommandBufferreturns a compute command encoder to encode into this command buffer. Optionally allow this command encoder to execute dispatches concurrently.
On devices that do not support concurrent command encoders, this call is equivalent to computeCommandEncoder
computeCommandEncoderWithDispatchType in interface MTLCommandBufferpublic static java.lang.String debugDescription_static()
public static java.lang.String description_static()
public MTLDevice device()
MTLCommandBufferThe device this resource was created against.
device in interface MTLCommandBufferpublic void encodeSignalEventValue(MTLEvent event, long value)
MTLCommandBufferEncodes a command that signals an event with a given value.
This method may only be called if there is no current command encoder on the receiver.
encodeSignalEventValue in interface MTLCommandBufferpublic void encodeWaitForEventValue(MTLEvent event, long value)
MTLCommandBufferEncodes a command that pauses execution of this command buffer until the specified event reaches a given value.
This method may only be called if there is no current command encoder on the receiver.
encodeWaitForEventValue in interface MTLCommandBufferpublic void enqueue()
MTLCommandBufferAppend this command buffer to the end of its MTLCommandQueue.
enqueue in interface MTLCommandBufferpublic NSError error()
MTLCommandBufferIf an error occurred during execution, the NSError may contain more details about the problem.
error in interface MTLCommandBufferpublic static long hash_static()
public MPSHeapProvider heapProvider()
A application supplied object to allocate MTLHeaps for MPS
By default this is nil, which will use MPS' device level global heap cache to allocate the heaps. This is a reasonable choice. However, it may be inefficient if you are keeping your own MTLHeap, since there will be two pessimistically sized free stores which may be larger than is strictly necessary, and of course fragmentation across multiple heaps. In such cases, the problem may be solved either by using MPS' automatically managed heap (simple) or having MPS use your heap. The heapProvider allows you to implement the second case. To use the MPS heap, simply make temporary MPSImages, vectors and matrices.
If multiple MPSCommandBuffers reference the same MTLCommandBuffer, changing the heapProvider on one will change the heap provider for all of them.
public MPSCommandBuffer init()
public MPSCommandBuffer initWithCommandBuffer(MTLCommandBuffer commandBuffer)
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
public double kernelEndTime()
kernelEndTime in interface MTLCommandBufferpublic double kernelStartTime()
kernelStartTime in interface MTLCommandBufferpublic static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
public java.lang.String label()
MTLCommandBufferA string to help identify this object.
label in interface MTLCommandBufferpublic static MPSCommandBuffer new_objc()
public MTLParallelRenderCommandEncoder parallelRenderCommandEncoderWithDescriptor(MTLRenderPassDescriptor renderPassDescriptor)
MTLCommandBufferreturns a parallel render pass encoder to encode into this command buffer.
parallelRenderCommandEncoderWithDescriptor in interface MTLCommandBufferpublic void popDebugGroup()
MTLCommandBufferPop the latest named string off of the stack.
popDebugGroup in interface MTLCommandBufferpublic MPSPredicate predicate()
A GPU predicate object. Default: nil.
public void prefetchHeapForWorkloadSize(long size)
If there is not sufficient free storage in the MPS heap for the command buffer for allocations of total size size, pre-warm the MPS heap with a new MTLHeap allocation of sufficient size. If this size turns out to be too small MPS may ask for more heaps later to cover additional allocations. If heapProvider is not nil, the heapProvider will be used.
size - The minimum size of the free store neededpublic void presentDrawable(MTLDrawable drawable)
MTLCommandBufferAdd a drawable present that will be invoked when this command buffer has been scheduled for execution.
The submission thread will be lock stepped with present call been serviced by window server
presentDrawable in interface MTLCommandBufferpublic void presentDrawableAfterMinimumDuration(MTLDrawable drawable, double duration)
MTLCommandBufferAdd a drawable present for a specific host time that allows previous frame to be on screen for at least duration time.
The difference of this API versus presentDrawable:atTime is that this API defers calculation of the presentation time until the previous frame's actual presentation time is known, thus to be able to maintain a more consistent and stable frame time. This also provides an easy way to set frame rate. The submission thread will be lock stepped with present call been serviced by window server
presentDrawableAfterMinimumDuration in interface MTLCommandBufferdrawable - The drawable to be presentedduration - The minimum time that previous frame should be displayed. The time is double preceision floating point in the unit of seconds.public void presentDrawableAtTime(MTLDrawable drawable, double presentationTime)
MTLCommandBufferAdd a drawable present for a specific host time that will be invoked when this command buffer has been scheduled for execution.
The submission thread will be lock stepped with present call been serviced by window server
presentDrawableAtTime in interface MTLCommandBufferpublic void pushDebugGroup(java.lang.String string)
MTLCommandBufferPush a new named string onto a stack of string labels.
pushDebugGroup in interface MTLCommandBufferpublic MTLRenderCommandEncoder renderCommandEncoderWithDescriptor(MTLRenderPassDescriptor renderPassDescriptor)
MTLCommandBufferreturns a render command endcoder to encode into this command buffer.
renderCommandEncoderWithDescriptor in interface MTLCommandBufferpublic static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
public MTLResourceStateCommandEncoder resourceStateCommandEncoder()
resourceStateCommandEncoder in interface MTLCommandBufferpublic boolean retainedReferences()
MTLCommandBufferIf YES, this command buffer holds strong references to objects needed to execute this command buffer.
retainedReferences in interface MTLCommandBufferpublic MTLCommandBuffer rootCommandBuffer()
The base MTLCommandBuffer underlying the MPSCommandBuffer
MPSCommandBuffers may wrap other MPSCommandBuffers, in the process creating what is in effect a stack of predicate objects that may be pushed or popped by making new MPSCommandBuffers or by calling -commandBuffer. In some circumstances, it is preferable to use the root command buffer, particularly when trying to identify the command buffer that will be commited by -commitAndContinue.
public void setHeapProvider(MPSHeapProvider value)
A application supplied object to allocate MTLHeaps for MPS
By default this is nil, which will use MPS' device level global heap cache to allocate the heaps. This is a reasonable choice. However, it may be inefficient if you are keeping your own MTLHeap, since there will be two pessimistically sized free stores which may be larger than is strictly necessary, and of course fragmentation across multiple heaps. In such cases, the problem may be solved either by using MPS' automatically managed heap (simple) or having MPS use your heap. The heapProvider allows you to implement the second case. To use the MPS heap, simply make temporary MPSImages, vectors and matrices.
If multiple MPSCommandBuffers reference the same MTLCommandBuffer, changing the heapProvider on one will change the heap provider for all of them.
public void setLabel(java.lang.String value)
MTLCommandBufferA string to help identify this object.
setLabel in interface MTLCommandBufferpublic void setPredicate(MPSPredicate value)
A GPU predicate object. Default: nil.
public static void setVersion_static(long aVersion)
public long status()
MTLCommandBufferstatus reports the current stage in the lifetime of MTLCommandBuffer, as it proceeds to enqueued, committed, scheduled, and completed.
status in interface MTLCommandBufferpublic static org.moe.natj.objc.Class superclass_static()
public static long version_static()
public void waitUntilCompleted()
MTLCommandBufferSynchronously wait for this command buffer to complete.
waitUntilCompleted in interface MTLCommandBufferpublic void waitUntilScheduled()
MTLCommandBufferSynchronously wait for this command buffer to be scheduled.
waitUntilScheduled in interface MTLCommandBufferpublic MTLAccelerationStructureCommandEncoder accelerationStructureCommandEncoder()
accelerationStructureCommandEncoder in interface MTLCommandBufferpublic MTLBlitCommandEncoder blitCommandEncoderWithDescriptor(MTLBlitPassDescriptor blitPassDescriptor)
MTLCommandBufferreturns a blit command endcoder to encode into this command buffer.
blitCommandEncoderWithDescriptor in interface MTLCommandBufferpublic MTLComputeCommandEncoder computeCommandEncoderWithDescriptor(MTLComputePassDescriptor computePassDescriptor)
MTLCommandBufferreturns a compute command endcoder to encode into this command buffer.
computeCommandEncoderWithDescriptor in interface MTLCommandBufferpublic long errorOptions()
MTLCommandBuffererrorOptions in interface MTLCommandBufferpublic MTLLogContainer logs()
MTLCommandBufferLogs generated by the command buffer during execution of the GPU commands. Valid after GPU execution is completed
logs in interface MTLCommandBufferpublic MTLResourceStateCommandEncoder resourceStateCommandEncoderWithDescriptor(MTLResourceStatePassDescriptor resourceStatePassDescriptor)
resourceStateCommandEncoderWithDescriptor in interface MTLCommandBuffer