Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
GrMtlUniformHandler.mm File Reference
#include "src/gpu/ganesh/mtl/GrMtlUniformHandler.h"
#include "src/gpu/ganesh/GrTexture.h"
#include "src/gpu/ganesh/GrUtil.h"
#include "src/gpu/ganesh/glsl/GrGLSLProgramBuilder.h"
#include "src/gpu/ganesh/mtl/GrMtlTypesPriv.h"

Go to the source code of this file.

Functions

static GR_NORETAIN_BEGIN uint32_t sksltype_to_alignment_mask (SkSLType type)
 
static uint32_t sksltype_to_mtl_size (SkSLType type)
 
static uint32_t get_ubo_aligned_offset (uint32_t *currentOffset, uint32_t *maxAlignment, SkSLType type, int arrayCount)
 

Function Documentation

◆ get_ubo_aligned_offset()

static uint32_t get_ubo_aligned_offset ( uint32_t *  currentOffset,
uint32_t *  maxAlignment,
SkSLType  type,
int  arrayCount 
)
static

Definition at line 158 of file GrMtlUniformHandler.mm.

161 {
162 uint32_t alignmentMask = sksltype_to_alignment_mask(type);
163 if (alignmentMask > *maxAlignment) {
164 *maxAlignment = alignmentMask;
165 }
166 uint32_t offsetDiff = *currentOffset & alignmentMask;
167 if (offsetDiff != 0) {
168 offsetDiff = alignmentMask - offsetDiff + 1;
169 }
170 uint32_t uniformOffset = *currentOffset + offsetDiff;
171 SkASSERT(sizeof(float) == 4);
172 if (arrayCount) {
173 *currentOffset = uniformOffset + sksltype_to_mtl_size(type) * arrayCount;
174 } else {
175 *currentOffset = uniformOffset + sksltype_to_mtl_size(type);
176 }
177 return uniformOffset;
178}
static GR_NORETAIN_BEGIN uint32_t sksltype_to_alignment_mask(SkSLType type)
static uint32_t sksltype_to_mtl_size(SkSLType type)
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ sksltype_to_alignment_mask()

static GR_NORETAIN_BEGIN uint32_t sksltype_to_alignment_mask ( SkSLType  type)
static

Definition at line 24 of file GrMtlUniformHandler.mm.

24 {
25 switch(type) {
26 case SkSLType::kInt:
27 case SkSLType::kUInt:
29 return 0x3;
30 case SkSLType::kInt2:
33 return 0x7;
34 case SkSLType::kInt3:
37 case SkSLType::kInt4:
40 return 0xF;
41
43 return 0x7;
45 return 0xF;
47 return 0xF;
48
51 case SkSLType::kHalf:
52 return 0x1;
56 return 0x3;
63 return 0x7;
64
66 return 0x3;
68 return 0x7;
70 return 0x7;
71
72 // This query is only valid for certain types.
73 case SkSLType::kVoid:
74 case SkSLType::kBool:
84 break;
85 }
86 SK_ABORT("Unexpected type");
87}
#define SK_ABORT(message,...)
Definition SkAssert.h:70
@ kTextureExternalSampler
@ kTexture2DSampler
@ kTexture2DRectSampler

◆ sksltype_to_mtl_size()

static uint32_t sksltype_to_mtl_size ( SkSLType  type)
inlinestatic

Returns the size in bytes taken up in Metal buffers for SkSLTypes.

Definition at line 90 of file GrMtlUniformHandler.mm.

90 {
91 switch(type) {
92 case SkSLType::kInt:
93 case SkSLType::kUInt:
95 return 4;
96 case SkSLType::kInt2:
99 return 8;
100 case SkSLType::kInt3:
101 case SkSLType::kUInt3:
103 case SkSLType::kInt4:
104 case SkSLType::kUInt4:
106 return 16;
107
109 return 16;
111 return 48;
113 return 64;
114
115 case SkSLType::kShort:
117 case SkSLType::kHalf:
118 return 2;
121 case SkSLType::kHalf2:
122 return 4;
127 case SkSLType::kHalf3:
128 case SkSLType::kHalf4:
129 return 8;
130
132 return 8;
134 return 24;
136 return 32;
137
138 // This query is only valid for certain types.
139 case SkSLType::kVoid:
140 case SkSLType::kBool:
141 case SkSLType::kBool2:
142 case SkSLType::kBool3:
143 case SkSLType::kBool4:
149 case SkSLType::kInput:
150 break;
151 }
152 SK_ABORT("Unexpected type");
153}