Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
src
gpu
ganesh
GrSPIRVVaryingHandler.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2019 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
8
#include "
src/gpu/ganesh/GrSPIRVVaryingHandler.h
"
9
10
/** Returns the number of locations take up by a given SkSLType. We assume that all
11
scalar values are 32 bits. */
12
static
inline
int
sksltype_to_location_size
(
SkSLType
type
) {
13
// If a new GrSL type is added, this function will need to be updated.
14
static_assert
(
kSkSLTypeCount
== 41);
15
16
switch
(
type
) {
17
case
SkSLType::kVoid
:
18
return
0;
19
case
SkSLType::kFloat
:
// fall through
20
case
SkSLType::kHalf
:
21
return
1;
22
case
SkSLType::kFloat2
:
// fall through
23
case
SkSLType::kHalf2
:
24
return
1;
25
case
SkSLType::kFloat3
:
26
case
SkSLType::kHalf3
:
27
return
1;
28
case
SkSLType::kFloat4
:
29
case
SkSLType::kHalf4
:
30
return
1;
31
case
SkSLType::kInt2
:
32
case
SkSLType::kUInt2
:
33
case
SkSLType::kShort2
:
34
case
SkSLType::kUShort2
:
35
return
1;
36
case
SkSLType::kInt3
:
37
case
SkSLType::kUInt3
:
38
case
SkSLType::kShort3
:
39
case
SkSLType::kUShort3
:
40
return
1;
41
case
SkSLType::kInt4
:
42
case
SkSLType::kUInt4
:
43
case
SkSLType::kShort4
:
44
case
SkSLType::kUShort4
:
45
return
1;
46
case
SkSLType::kFloat2x2
:
47
case
SkSLType::kHalf2x2
:
48
return
2;
49
case
SkSLType::kFloat3x3
:
50
case
SkSLType::kHalf3x3
:
51
return
3;
52
case
SkSLType::kFloat4x4
:
53
case
SkSLType::kHalf4x4
:
54
return
4;
55
case
SkSLType::kTexture2DSampler
:
56
return
0;
57
case
SkSLType::kTextureExternalSampler
:
58
return
0;
59
case
SkSLType::kTexture2DRectSampler
:
60
return
0;
61
case
SkSLType::kBool
:
62
case
SkSLType::kBool2
:
63
case
SkSLType::kBool3
:
64
case
SkSLType::kBool4
:
65
return
1;
66
case
SkSLType::kInt
:
// fall through
67
case
SkSLType::kShort
:
68
return
1;
69
case
SkSLType::kUInt
:
// fall through
70
case
SkSLType::kUShort
:
71
return
1;
72
case
SkSLType::kTexture2D
:
73
return
0;
74
case
SkSLType::kSampler
:
75
return
0;
76
case
SkSLType::kInput
:
77
return
0;
78
}
79
SK_ABORT
(
"Unexpected type"
);
80
}
81
82
static
void
finalize_helper
(
GrSPIRVVaryingHandler::VarArray
&
vars
) {
83
int
locationIndex = 0;
84
for
(
GrShaderVar
& var :
vars
.items()) {
85
SkString
location;
86
location.
appendf
(
"location = %d"
, locationIndex);
87
var.addLayoutQualifier(location.
c_str
());
88
89
int
elementSize =
sksltype_to_location_size
(var.getType());
90
SkASSERT
(elementSize > 0);
91
int
numElements = var.isArray() ? var.getArrayCount() : 1;
92
SkASSERT
(numElements > 0);
93
locationIndex += elementSize * numElements;
94
}
95
// TODO: determine the layout limits for SPIR-V, and enforce them via asserts here.
96
}
97
98
void
GrSPIRVVaryingHandler::onFinalize
() {
99
finalize_helper
(
fVertexInputs
);
100
finalize_helper
(
fVertexOutputs
);
101
finalize_helper
(
fFragInputs
);
102
finalize_helper
(
fFragOutputs
);
103
}
sksltype_to_location_size
static int sksltype_to_location_size(SkSLType type)
Definition
GrSPIRVVaryingHandler.cpp:12
finalize_helper
static void finalize_helper(GrSPIRVVaryingHandler::VarArray &vars)
Definition
GrSPIRVVaryingHandler.cpp:82
GrSPIRVVaryingHandler.h
SK_ABORT
#define SK_ABORT(message,...)
Definition
SkAssert.h:70
SkASSERT
#define SkASSERT(cond)
Definition
SkAssert.h:116
kSkSLTypeCount
static const int kSkSLTypeCount
Definition
SkSLTypeShared.h:61
SkSLType
SkSLType
Definition
SkSLTypeShared.h:16
SkSLType::kUShort4
@ kUShort4
SkSLType::kBool
@ kBool
SkSLType::kShort
@ kShort
SkSLType::kFloat2x2
@ kFloat2x2
SkSLType::kUInt3
@ kUInt3
SkSLType::kFloat4
@ kFloat4
SkSLType::kInt4
@ kInt4
SkSLType::kInt
@ kInt
SkSLType::kFloat3x3
@ kFloat3x3
SkSLType::kShort4
@ kShort4
SkSLType::kFloat3
@ kFloat3
SkSLType::kHalf4
@ kHalf4
SkSLType::kTextureExternalSampler
@ kTextureExternalSampler
SkSLType::kBool4
@ kBool4
SkSLType::kHalf2x2
@ kHalf2x2
SkSLType::kShort2
@ kShort2
SkSLType::kTexture2DSampler
@ kTexture2DSampler
SkSLType::kUShort3
@ kUShort3
SkSLType::kShort3
@ kShort3
SkSLType::kFloat
@ kFloat
SkSLType::kHalf
@ kHalf
SkSLType::kUInt
@ kUInt
SkSLType::kFloat2
@ kFloat2
SkSLType::kUShort2
@ kUShort2
SkSLType::kUShort
@ kUShort
SkSLType::kInt3
@ kInt3
SkSLType::kSampler
@ kSampler
SkSLType::kVoid
@ kVoid
SkSLType::kTexture2D
@ kTexture2D
SkSLType::kBool3
@ kBool3
SkSLType::kTexture2DRectSampler
@ kTexture2DRectSampler
SkSLType::kUInt2
@ kUInt2
SkSLType::kInt2
@ kInt2
SkSLType::kHalf3
@ kHalf3
SkSLType::kInput
@ kInput
SkSLType::kBool2
@ kBool2
SkSLType::kFloat4x4
@ kFloat4x4
SkSLType::kHalf4x4
@ kHalf4x4
SkSLType::kHalf2
@ kHalf2
SkSLType::kUInt4
@ kUInt4
SkSLType::kHalf3x3
@ kHalf3x3
GrGLSLVaryingHandler::fVertexInputs
VarArray fVertexInputs
Definition
GrGLSLVarying.h:159
GrGLSLVaryingHandler::fVertexOutputs
VarArray fVertexOutputs
Definition
GrGLSLVarying.h:160
GrGLSLVaryingHandler::fFragOutputs
VarArray fFragOutputs
Definition
GrGLSLVarying.h:162
GrGLSLVaryingHandler::fFragInputs
VarArray fFragInputs
Definition
GrGLSLVarying.h:161
GrSPIRVVaryingHandler::onFinalize
void onFinalize() override
Definition
GrSPIRVVaryingHandler.cpp:98
GrShaderVar
Definition
GrShaderVar.h:20
SkString
Definition
SkString.h:118
SkString::c_str
const char * c_str() const
Definition
SkString.h:133
SkString::appendf
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition
SkString.cpp:550
SkTBlockList< GrShaderVar >
type
uint8_t type
Definition
fl_standard_message_codec_test.cc:1115
vars
Definition
__init__.py:1
Generated on Fri Apr 26 2024 06:17:05 for Flutter Engine by
1.9.8