Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
MtlComputePipeline.mm
Go to the documentation of this file.
1/*
2 * Copyright 2022 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
9
18
19namespace skgpu::graphite {
20
21// static
23 const std::string& label,
24 MSLFunction computeMain) {
25 id<MTLLibrary> library = std::get<0>(computeMain);
26 if (!library) {
27 return nullptr;
28 }
29
30 sk_cfp<MTLComputePipelineDescriptor*> psoDescriptor([MTLComputePipelineDescriptor new]);
31
32 (*psoDescriptor).label = @(label.c_str());
33
34 NSString* entryPointName = [NSString stringWithUTF8String:std::get<1>(computeMain).c_str()];
35 (*psoDescriptor).computeFunction = [library newFunctionWithName:entryPointName];
36
37 // TODO(b/240604614): Populate input data attribute and buffer layout descriptors using the
38 // `stageInputDescriptor` property based on the contents of `pipelineDesc` (on iOS 10+ or
39 // macOS 10.12+).
40
41 // TODO(b/240604614): Define input buffer mutability using the `buffers` property based on
42 // the contents of `pipelineDesc` (on iOS 11+ or macOS 10.13+).
43
44 // TODO(b/240615224): Metal docs claim that setting the
45 // `threadGroupSizeIsMultipleOfThreadExecutionWidth` to YES may improve performance, IF we can
46 // guarantee that the thread group size used in a dispatch command is a multiple of
47 // `threadExecutionWidth` property of the pipeline state object (otherwise this will cause UB).
48
49 NSError* error;
50 sk_cfp<id<MTLComputePipelineState>> pso([sharedContext->device()
51 newComputePipelineStateWithDescriptor:psoDescriptor.get()
52 options:MTLPipelineOptionNone
53 reflection:nil
54 error:&error]);
55 if (!pso) {
56 SKGPU_LOG_E("Compute pipeline creation failure:\n%s", error.debugDescription.UTF8String);
57 return nullptr;
58 }
59
61}
62
63void MtlComputePipeline::freeGpuData() { fPipelineState.reset(); }
64
65} // namespace skgpu::graphite
const char * options
#define SKGPU_LOG_E(fmt,...)
Definition Log.h:38
std::pair< id< MTLLibrary >, std::string > MSLFunction
static sk_sp< MtlComputePipeline > Make(const MtlSharedContext *, const std::string &label, MSLFunction computeMain)
const SharedContext * sharedContext() const
Definition Resource.h:187
const uint8_t uint32_t uint32_t GError ** error