Flutter Engine
The Flutter Engine
shader_function_mtl.mm
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7namespace impeller {
8
9ShaderFunctionMTL::ShaderFunctionMTL(UniqueID parent_library_id,
10 id<MTLFunction> function,
11 id<MTLLibrary> library,
12 std::string name,
13 ShaderStage stage)
14 : ShaderFunction(parent_library_id, std::move(name), stage),
15 function_(function),
16 library_(library) {}
17
18ShaderFunctionMTL::~ShaderFunctionMTL() = default;
19
20void ShaderFunctionMTL::GetMTLFunctionSpecialized(
21 const std::vector<Scalar>& constants,
22 const CompileCallback& callback) const {
23 MTLFunctionConstantValues* constantValues =
24 [[MTLFunctionConstantValues alloc] init];
25 size_t index = 0;
26 for (const auto value : constants) {
27 Scalar copied_value = value;
28 [constantValues setConstantValue:&copied_value
29 type:MTLDataTypeFloat
30 atIndex:index];
31 index++;
32 }
33 CompileCallback callback_value = callback;
34 [library_ newFunctionWithName:@(GetName().data())
35 constantValues:constantValues
36 completionHandler:^(id<MTLFunction> _Nullable function,
37 NSError* _Nullable error) {
38 callback_value(function);
39 }];
40}
41
42id<MTLFunction> ShaderFunctionMTL::GetMTLFunction() const {
43 return function_;
44}
45
46} // namespace impeller
GLenum type
std::function< void(id< MTLFunction >)> CompileCallback
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
const uint8_t uint32_t uint32_t GError ** error
uint8_t value
Dart_NativeFunction function
Definition: fuchsia.cc:51
static bool init()
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
float Scalar
Definition: scalar.h:18
Definition: ref_ptr.h:256