Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
GrVkVaryingHandler.cpp File Reference
#include "src/gpu/ganesh/vk/GrVkVaryingHandler.h"

Go to the source code of this file.

Functions

static int sksltype_to_location_size (SkSLType type)
 
static void finalize_helper (GrVkVaryingHandler::VarArray &vars)
 

Function Documentation

◆ finalize_helper()

static void finalize_helper ( GrVkVaryingHandler::VarArray vars)
static

Definition at line 76 of file GrVkVaryingHandler.cpp.

76 {
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}
static int sksltype_to_location_size(SkSLType type)
#define SkASSERT(cond)
Definition SkAssert.h:116
const char * c_str() const
Definition SkString.h:133
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition SkString.cpp:550

◆ sksltype_to_location_size()

static int sksltype_to_location_size ( SkSLType  type)
inlinestatic

Returns the number of locations take up by a given SkSLType. We assume that all scalar values are 32 bits.

Definition at line 12 of file GrVkVaryingHandler.cpp.

12 {
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
21 return 1;
24 return 1;
27 return 1;
28 case SkSLType::kInt2:
32 return 1;
33 case SkSLType::kInt3:
37 return 1;
38 case SkSLType::kInt4:
42 return 1;
45 return 2;
48 return 3;
51 return 4;
56 return 0;
58 return 0;
60 return 0;
61 case SkSLType::kBool:
65 return 1;
66 case SkSLType::kInt: // fall through
68 return 1;
69 case SkSLType::kUInt: // fall through
71 return 1;
72 }
73 SK_ABORT("Unexpected type");
74}
#define SK_ABORT(message,...)
Definition SkAssert.h:70
@ kTextureExternalSampler
@ kTexture2DSampler
@ kTexture2DRectSampler