| 1 |
/* |
| 2 |
* Copyright 2021 Google LLC |
| 3 |
* |
| 4 |
* Use of this source code is governed by a BSD-style license that can be |
| 5 |
* found in the LICENSE file. |
| 6 |
*/ |
| 7 |
|
| 8 |
#include "src/gpu/mtl/MtlMemoryAllocatorImpl.h" |
| 9 |
|
| 10 |
namespace skgpu { |
| 11 |
|
| 12 |
sk_sp<MtlMemoryAllocator> MtlMemoryAllocatorImpl::Make(id<MTLDevice> device) { |
| 13 |
return sk_sp<MtlMemoryAllocator>(new MtlMemoryAllocatorImpl(device)); |
| 14 |
} |
| 15 |
|
| 16 |
id<MTLBuffer> MtlMemoryAllocatorImpl::newBufferWithLength(NSUInteger length, |
| 17 |
MTLResourceOptions options, |
| 18 |
sk_sp<MtlAlloc>* allocation) { |
| 19 |
// TODO: suballocate and fill in Alloc |
| 20 |
allocation->reset(new Alloc()); |
| 21 |
return [fDevice newBufferWithLength:length options:options]; |
| 22 |
} |
| 23 |
|
| 24 |
id<MTLTexture> MtlMemoryAllocatorImpl::newTextureWithDescriptor(MTLTextureDescriptor* texDesc, |
| 25 |
sk_sp<MtlAlloc>* allocation) { |
| 26 |
// TODO: suballocate and fill in Alloc |
| 27 |
allocation->reset(new Alloc()); |
| 28 |
return [fDevice newTextureWithDescriptor:texDesc]; |
| 29 |
} |
| 30 |
|
| 31 |
} // namespace skgpu |