xref: /aosp_15_r20/external/skia/src/gpu/mtl/MtlMemoryAllocatorImpl.mm (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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
10namespace skgpu {
11
12sk_sp<MtlMemoryAllocator> MtlMemoryAllocatorImpl::Make(id<MTLDevice> device) {
13    return sk_sp<MtlMemoryAllocator>(new MtlMemoryAllocatorImpl(device));
14}
15
16id<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
24id<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
32