Flutter Engine
The Flutter Engine
third_party
skia
src
gpu
graphite
mtl
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
8
#include "
src/gpu/graphite/mtl/MtlComputePipeline.h
"
9
10
#include "
include/gpu/ShaderErrorHandler.h
"
11
#include "
src/gpu/graphite/ComputePipelineDesc.h
"
12
#include "
src/gpu/graphite/Log.h
"
13
#include "
src/gpu/graphite/ResourceProvider.h
"
14
#include "
src/gpu/graphite/mtl/MtlGraphiteUtilsPriv.h
"
15
#include "
src/gpu/graphite/mtl/MtlSharedContext.h
"
16
#include "
src/sksl/SkSLProgramKind.h
"
17
#include "
src/sksl/SkSLProgramSettings.h
"
18
19
namespace
skgpu::graphite
{
20
21
// static
22
sk_sp<MtlComputePipeline>
MtlComputePipeline::Make
(
const
MtlSharedContext
* sharedContext,
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
60
return
sk_sp<MtlComputePipeline>
(
new
MtlComputePipeline
(
sharedContext
, std::move(pso)));
61
}
62
63
void
MtlComputePipeline::freeGpuData() { fPipelineState.reset(); }
64
65
}
// namespace skgpu::graphite
options
const char * options
Definition:
CommonFlagsConfig.cpp:43
ComputePipelineDesc.h
Log.h
SKGPU_LOG_E
#define SKGPU_LOG_E(fmt,...)
Definition:
Log.h:38
MtlComputePipeline.h
MtlGraphiteUtilsPriv.h
MtlSharedContext.h
ResourceProvider.h
ShaderErrorHandler.h
SkSLProgramKind.h
SkSLProgramSettings.h
sk_sp
Definition:
SkRefCnt.h:220
skgpu::graphite::MtlComputePipeline
Definition:
MtlComputePipeline.h:23
skgpu::graphite::MtlComputePipeline::MSLFunction
std::pair< id< MTLLibrary >, std::string > MSLFunction
Definition:
MtlComputePipeline.h:25
skgpu::graphite::MtlComputePipeline::Make
static sk_sp< MtlComputePipeline > Make(const MtlSharedContext *, const std::string &label, MSLFunction computeMain)
Definition:
MtlComputePipeline.mm:22
skgpu::graphite::MtlSharedContext
Definition:
MtlSharedContext.h:27
skgpu::graphite::Resource::sharedContext
const SharedContext * sharedContext() const
Definition:
Resource.h:189
error
const uint8_t uint32_t uint32_t GError ** error
Definition:
fl_pixel_buffer_texture_test.cc:40
myers::get< 1 >
const myers::Point & get< 1 >(const myers::Segment &s)
Definition:
Myers.h:81
myers::get< 0 >
const myers::Point & get< 0 >(const myers::Segment &s)
Definition:
Myers.h:80
skgpu::graphite
Definition:
BoundsManagerBench.cpp:27
Generated on Sun Jun 23 2024 21:56:27 for Flutter Engine by
1.9.4