Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrMtlVaryingHandler.mm
Go to the documentation of this file.
1/*
2 * Copyright 2018 Google Inc.
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
11
12#if !__has_feature(objc_arc)
13#error This file must be compiled with Arc. Use -fobjc-arc flag
14#endif
15
16GR_NORETAIN_BEGIN
17
19 int locationIndex = 0;
20
21 SkDEBUGCODE(int componentCount = 0);
22 for (GrShaderVar& var : vars.items()) {
23 // Metal only allows scalars (including bool and char) and vectors as varyings
24 SkASSERT(SkSLTypeVecLength(var.getType()) != -1);
25 SkDEBUGCODE(componentCount += SkSLTypeVecLength(var.getType()));
26
27 SkString location;
28 location.appendf("location = %d", locationIndex);
29 var.addLayoutQualifier(location.c_str());
30 ++locationIndex;
31 }
32 // The max number of inputs is 60 for iOS and 32 for macOS. The max number of components is 60
33 // for iOS and 128 for macOS. To be conservative, we are going to assert that we have less than
34 // 32 varyings and less than 60 components across all varyings. If we hit this assert, we can
35 // implement a function in GrMtlCaps to be less conservative.
36 SkASSERT(locationIndex <= 32);
37 SkASSERT(componentCount <= 60);
38}
39
46
47GR_NORETAIN_END
static GR_NORETAIN_BEGIN void finalize_helper(GrMtlVaryingHandler::VarArray &vars)
static void finalize_helper(GrSPIRVVaryingHandler::VarArray &vars)
#define SkASSERT(cond)
Definition SkAssert.h:116
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
static constexpr int SkSLTypeVecLength(SkSLType type)
const char * c_str() const
Definition SkString.h:133
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition SkString.cpp:550