92 return sizeof(int16_t);
94 return 2 *
sizeof(int16_t);
96 return 3 *
sizeof(int16_t);
98 return 4 *
sizeof(int16_t);
100 return sizeof(uint16_t);
102 return 2 *
sizeof(uint16_t);
104 return 3 *
sizeof(uint16_t);
106 return 4 *
sizeof(uint16_t);
109 return sizeof(
float);
112 return 2 *
sizeof(
float);
115 return 3 *
sizeof(
float);
118 return 4 *
sizeof(
float);
121 return sizeof(int32_t);
124 return 2 *
sizeof(int32_t);
127 return 3 *
sizeof(int32_t);
130 return 4 *
sizeof(int32_t);
134 return 4 *
sizeof(
float);
136 return 8 *
sizeof(
float);
140 return 12 *
sizeof(
float);
143 return 16 *
sizeof(
float);
177 uint32_t offsetDiff = *currentOffset & alignmentMask;
178 if (offsetDiff != 0) {
179 offsetDiff = alignmentMask - offsetDiff + 1;
181 int32_t uniformOffset = *currentOffset + offsetDiff;
187 *currentOffset = uniformOffset + elementSize * arrayCount;
191 return uniformOffset;
196 if (sampler.fImmutableSampler) {
197 sampler.fImmutableSampler->unref();
198 sampler.fImmutableSampler =
nullptr;
210 const char** outName) {
226 VkUniformInfo tempInfo;
227 tempInfo.fVariable =
GrShaderVar{std::move(resolvedName),
232 tempInfo.fVisibility = visibility;
233 tempInfo.fOwner = owner;
252GrGLSLUniformHandler::SamplerHandle GrVkUniformHandler::addSampler(
266 VkUniformInfo tempInfo;
272 std::move(layoutQualifier),
276 tempInfo.fOwner =
nullptr;
278 tempInfo.fOffsets[0] = 0;
279 tempInfo.fOffsets[1] = 0;
285 if (ycbcrInfo && ycbcrInfo->isValid()) {
297 return GrGLSLUniformHandler::SamplerHandle(fSamplers.
count() - 1);
300GrGLSLUniformHandler::SamplerHandle GrVkUniformHandler::addInputSampler(
308 auto layoutQualifier =
SkStringPrintf(
"vulkan, input_attachment_index=%d, set=%d, binding=%d",
313 fInputUniform = {
GrShaderVar{std::move(mangleName),
317 std::move(layoutQualifier),
322 fInputSwizzle = swizzle;
323 return GrGLSLUniformHandler::SamplerHandle(0);
327 for (
const VkUniformInfo& sampler : fSamplers.
items()) {
330 if (visibility == sampler.fVisibility) {
344 bool firstOffsetCheck =
false;
345 for (
const VkUniformInfo& localUniform : fUniforms.
items()) {
346 if (!firstOffsetCheck) {
351 firstOffsetCheck =
true;
359 this->determineIfUsePushConstants();
361 for (
const VkUniformInfo& localUniform : fUniforms.
items()) {
362 if (visibility & localUniform.fVisibility) {
365 uniformsString.
appendf(
"layout(offset=%u) ", localUniform.fOffsets[layout]);
367 uniformsString.
append(
";\n");
372 if (!uniformsString.
isEmpty()) {
373 if (fUsePushConstants) {
374 out->append(
"layout (vulkan, push_constant) ");
376 out->appendf(
"layout (vulkan, set=%d, binding=%d) ",
379 out->append(
"uniform uniformBuffer\n{\n");
380 out->appendf(
"%s\n};\n", uniformsString.
c_str());
390void GrVkUniformHandler::determineIfUsePushConstants()
const {
394 static constexpr uint32_t
kPad = 2*
sizeof(
float);
static SkSLType SkSLCombinedSamplerTypeForTextureType(GrTextureType type)
#define SK_ABORT(message,...)
static constexpr bool SkSLTypeCanBeUniformValue(SkSLType type)
@ 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.
uint32_t maxPushConstantsSize() const
SkString nameVariable(char prefix, const char *name, bool mangle=true)
virtual const GrCaps * caps() const =0
const GrShaderCaps * shaderCaps() const
const char * c_str() const
void appendDecl(const GrShaderCaps *, SkString *out) const
GrVkResourceProvider & resourceProvider()
GrVkSampler * findOrCreateCompatibleSampler(GrSamplerState, const skgpu::VulkanYcbcrConversionInfo &ycbcrInfo)
void append(const char text[])
const char * c_str() const
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
DEF_SWITCHES_START aot vmservice shared library name