Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
src
gpu
ganesh
vk
GrVkVaryingHandler.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2016 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/vk/GrVkVaryingHandler.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
switch
(
type
) {
14
case
SkSLType::kVoid
:
15
return
0;
16
case
SkSLType::kFloat
:
// fall through
17
case
SkSLType::kHalf
:
18
return
1;
19
case
SkSLType::kFloat2
:
// fall through
20
case
SkSLType::kHalf2
:
21
return
1;
22
case
SkSLType::kFloat3
:
23
case
SkSLType::kHalf3
:
24
return
1;
25
case
SkSLType::kFloat4
:
26
case
SkSLType::kHalf4
:
27
return
1;
28
case
SkSLType::kInt2
:
29
case
SkSLType::kUInt2
:
30
case
SkSLType::kShort2
:
31
case
SkSLType::kUShort2
:
32
return
1;
33
case
SkSLType::kInt3
:
34
case
SkSLType::kUInt3
:
35
case
SkSLType::kShort3
:
36
case
SkSLType::kUShort3
:
37
return
1;
38
case
SkSLType::kInt4
:
39
case
SkSLType::kUInt4
:
40
case
SkSLType::kShort4
:
41
case
SkSLType::kUShort4
:
42
return
1;
43
case
SkSLType::kFloat2x2
:
44
case
SkSLType::kHalf2x2
:
45
return
2;
46
case
SkSLType::kFloat3x3
:
47
case
SkSLType::kHalf3x3
:
48
return
3;
49
case
SkSLType::kFloat4x4
:
50
case
SkSLType::kHalf4x4
:
51
return
4;
52
case
SkSLType::kTexture2DSampler
:
53
case
SkSLType::kSampler
:
54
case
SkSLType::kTexture2D
:
55
case
SkSLType::kInput
:
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
}
73
SK_ABORT
(
"Unexpected type"
);
74
}
75
76
static
void
finalize_helper
(
GrVkVaryingHandler::VarArray
&
vars
) {
77
int
locationIndex = 0;
78
for
(
GrShaderVar
& var :
vars
.items()) {
79
SkString
location;
80
location.
appendf
(
"location = %d"
, locationIndex);
81
var.addLayoutQualifier(location.
c_str
());
82
83
int
elementSize =
sksltype_to_location_size
(var.getType());
84
SkASSERT
(elementSize > 0);
85
int
numElements = var.isArray() ? var.getArrayCount() : 1;
86
SkASSERT
(numElements > 0);
87
locationIndex += elementSize * numElements;
88
}
89
// Vulkan requires at least 64 locations to be supported for both vertex output and fragment
90
// input. If we ever hit this assert, then we'll need to add a cap to actually check the
91
// supported input and output values and adjust our supported shaders based on those values.
92
SkASSERT
(locationIndex <= 64);
93
}
94
95
void
GrVkVaryingHandler::onFinalize
() {
96
finalize_helper
(
fVertexInputs
);
97
finalize_helper
(
fVertexOutputs
);
98
finalize_helper
(
fFragInputs
);
99
finalize_helper
(
fFragOutputs
);
100
}
finalize_helper
static void finalize_helper(GrSPIRVVaryingHandler::VarArray &vars)
Definition
GrSPIRVVaryingHandler.cpp:82
sksltype_to_location_size
static int sksltype_to_location_size(SkSLType type)
Definition
GrVkVaryingHandler.cpp:12
finalize_helper
static void finalize_helper(GrVkVaryingHandler::VarArray &vars)
Definition
GrVkVaryingHandler.cpp:76
GrVkVaryingHandler.h
SK_ABORT
#define SK_ABORT(message,...)
Definition
SkAssert.h:70
SkASSERT
#define SkASSERT(cond)
Definition
SkAssert.h:116
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
GrShaderVar
Definition
GrShaderVar.h:20
GrVkVaryingHandler::onFinalize
void onFinalize() override
Definition
GrVkVaryingHandler.cpp:95
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:15 for Flutter Engine by
1.9.8