15 , fUniforms(kUniformsPerBlock)
16 , fSamplers(kUniformsPerBlock) {}
95 return sizeof(int16_t);
97 return 2 *
sizeof(int16_t);
99 return 3 *
sizeof(int16_t);
101 return 4 *
sizeof(int16_t);
103 return sizeof(uint16_t);
105 return 2 *
sizeof(uint16_t);
107 return 3 *
sizeof(uint16_t);
109 return 4 *
sizeof(uint16_t);
112 return sizeof(
float);
115 return 2 *
sizeof(
float);
118 return 3 *
sizeof(
float);
121 return 4 *
sizeof(
float);
124 return sizeof(int32_t);
127 return 2 *
sizeof(int32_t);
130 return 3 *
sizeof(int32_t);
133 return 4 *
sizeof(int32_t);
137 return 8 *
sizeof(
float);
140 return 12 *
sizeof(
float);
143 return 16 *
sizeof(
float);
162uint32_t get_ubo_offset(uint32_t* currentOffset,
SkSLType type,
int arrayCount) {
170 uint32_t offsetDiff = *currentOffset & alignmentMask;
171 if (offsetDiff != 0) {
172 offsetDiff = alignmentMask - offsetDiff + 1;
174 uint32_t uniformOffset = *currentOffset + offsetDiff;
177 uint32_t elementSize = std::max<uint32_t>(16, sksltype_to_size(
type));
179 *currentOffset = uniformOffset + elementSize * arrayCount;
181 *currentOffset = uniformOffset + sksltype_to_size(
type);
183 return uniformOffset;
195 const char** outName) {
202 int offset = get_ubo_offset(&fCurrentUBOOffset,
type, arrayCount);
206 SPIRVUniformInfo tempInfo;
207 tempInfo.fVariable =
GrShaderVar{std::move(resolvedName),
211 std::move(layoutQualifier),
214 tempInfo.fVisibility = visibility;
215 tempInfo.fOwner = owner;
217 tempInfo.fUBOOffset =
offset;
227GrGLSLUniformHandler::SamplerHandle GrSPIRVUniformHandler::addSampler(
235 int binding = fSamplers.
count() * 2;
243 SPIRVUniformInfo& uniformInfo = fSamplers.
emplace_back();
249 std::move(layoutQualifier),
253 uniformInfo.fOwner =
nullptr;
255 uniformInfo.fUBOOffset = 0;
260 return GrGLSLUniformHandler::SamplerHandle(fSamplers.
count() - 1);
263const char* GrSPIRVUniformHandler::samplerVariable(
264 GrGLSLUniformHandler::SamplerHandle handle)
const {
269 GrGLSLUniformHandler::SamplerHandle handle)
const {
270 return fSamplerSwizzles[handle.toIndex()];
274 for (
const SPIRVUniformInfo& sampler : fSamplers.
items()) {
275 if (sampler.fVisibility & visibility) {
284 uniformsString.
append(
";\n");
287 if (!uniformsString.
isEmpty()) {
288 out->appendf(
"layout (set = %d, binding = %d) uniform UniformBuffer\n{\n",
290 out->appendf(
"%s\n};\n", uniformsString.
c_str());
295 uint32_t currentOffset = fCurrentUBOOffset;
static SkSLType SkSLCombinedSamplerTypeForTextureType(GrTextureType type)
#define SK_ABORT(message,...)
#define INHERITED(method,...)
@ kTextureExternalSampler
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
SkString nameVariable(char prefix, const char *name, bool mangle=true)
const GrShaderCaps * shaderCaps() const
const char * c_str() const
const SkString & getName() const
void appendDecl(const GrShaderCaps *, SkString *out) const
void append(const char text[])
const char * c_str() const
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
T & emplace_back(Args &&... args)
DEF_SWITCHES_START aot vmservice shared library name