blob: 22a259428b05153f38e6165e5e54fb0b4e627353 [file] [log] [blame]
Greg Daniel164a9f02016-02-22 09:56:40 -05001/*
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "src/gpu/vk/GrVkUniformHandler.h"
Greg Daniel9a51a862018-11-30 10:18:14 -05009
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "src/gpu/GrTexturePriv.h"
11#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
12#include "src/gpu/vk/GrVkGpu.h"
13#include "src/gpu/vk/GrVkPipelineStateBuilder.h"
14#include "src/gpu/vk/GrVkTexture.h"
Greg Daniel164a9f02016-02-22 09:56:40 -050015
16// To determine whether a current offset is aligned, we can just 'and' the lowest bits with the
17// alignment mask. A value of 0 means aligned, any other value is how many bytes past alignment we
18// are. This works since all alignments are powers of 2. The mask is always (alignment - 1).
egdaniel4ee1cda2016-02-26 08:18:49 -080019// This alignment mask will give correct alignments for using the std430 block layout. If you want
20// the std140 alignment, you can use this, but then make sure if you have an array type it is
21// aligned to 16 bytes (i.e. has mask of 0xF).
Chris Dalton51ebd662017-10-24 16:10:48 -060022// These are designated in the Vulkan spec, section 14.5.4 "Offset and Stride Assignment".
23// https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/html/vkspec.html#interfaces-resources-layout
Mike Kleindc735592018-10-11 14:26:30 -040024static uint32_t grsltype_to_alignment_mask(GrSLType type) {
Brian Salomonfa26e662016-11-14 11:27:00 -050025 switch(type) {
Ruiqi Maob609e6d2018-07-17 10:19:38 -040026 case kByte_GrSLType: // fall through
27 case kUByte_GrSLType:
28 return 0x0;
29 case kByte2_GrSLType: // fall through
30 case kUByte2_GrSLType:
31 return 0x1;
32 case kByte3_GrSLType: // fall through
33 case kByte4_GrSLType:
34 case kUByte3_GrSLType:
35 case kUByte4_GrSLType:
36 return 0x3;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040037 case kShort_GrSLType: // fall through
Chris Dalton51ebd662017-10-24 16:10:48 -060038 case kUShort_GrSLType:
39 return 0x1;
40 case kShort2_GrSLType: // fall through
41 case kUShort2_GrSLType:
Chris Dalton6dd0d8a2017-10-24 19:53:13 +000042 return 0x3;
Chris Dalton51ebd662017-10-24 16:10:48 -060043 case kShort3_GrSLType: // fall through
44 case kShort4_GrSLType:
45 case kUShort3_GrSLType:
46 case kUShort4_GrSLType:
47 return 0x7;
48 case kInt_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050049 case kUint_GrSLType:
50 return 0x3;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040051 case kHalf_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -040052 case kFloat_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050053 return 0x3;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040054 case kHalf2_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -040055 case kFloat2_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050056 return 0x7;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040057 case kHalf3_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -040058 case kFloat3_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050059 return 0xF;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040060 case kHalf4_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -040061 case kFloat4_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050062 return 0xF;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040063 case kUint2_GrSLType:
Chris Dalton51ebd662017-10-24 16:10:48 -060064 return 0x7;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040065 case kInt2_GrSLType:
csmartdaltonb37cb232017-02-08 14:56:27 -050066 return 0x7;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040067 case kInt3_GrSLType:
csmartdaltonb37cb232017-02-08 14:56:27 -050068 return 0xF;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040069 case kInt4_GrSLType:
csmartdaltonb37cb232017-02-08 14:56:27 -050070 return 0xF;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040071 case kHalf2x2_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -040072 case kFloat2x2_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050073 return 0x7;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040074 case kHalf3x3_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -040075 case kFloat3x3_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050076 return 0xF;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040077 case kHalf4x4_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -040078 case kFloat4x4_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050079 return 0xF;
80
81 // This query is only valid for certain types.
82 case kVoid_GrSLType:
83 case kBool_GrSLType:
84 case kTexture2DSampler_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050085 case kTextureExternalSampler_GrSLType:
86 case kTexture2DRectSampler_GrSLType:
Stephen Whiteff5d7a22019-07-26 17:42:06 -040087 case kSampler_GrSLType:
88 case kTexture2D_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050089 break;
90 }
Ben Wagnerb4aab9a2017-08-16 10:53:04 -040091 SK_ABORT("Unexpected type");
Greg Daniel164a9f02016-02-22 09:56:40 -050092}
93
Chris Dalton51ebd662017-10-24 16:10:48 -060094/** Returns the size in bytes taken up in vulkanbuffers for GrSLTypes. */
egdaniel4ee1cda2016-02-26 08:18:49 -080095static inline uint32_t grsltype_to_vk_size(GrSLType type) {
Brian Salomonfa26e662016-11-14 11:27:00 -050096 switch(type) {
Ruiqi Maob609e6d2018-07-17 10:19:38 -040097 case kByte_GrSLType:
98 return sizeof(int8_t);
99 case kByte2_GrSLType:
100 return 2 * sizeof(int8_t);
101 case kByte3_GrSLType:
102 return 3 * sizeof(int8_t);
103 case kByte4_GrSLType:
104 return 4 * sizeof(int8_t);
105 case kUByte_GrSLType:
106 return sizeof(uint8_t);
107 case kUByte2_GrSLType:
108 return 2 * sizeof(uint8_t);
109 case kUByte3_GrSLType:
110 return 3 * sizeof(uint8_t);
111 case kUByte4_GrSLType:
112 return 4 * sizeof(uint8_t);
Chris Dalton51ebd662017-10-24 16:10:48 -0600113 case kShort_GrSLType:
114 return sizeof(int16_t);
115 case kShort2_GrSLType:
116 return 2 * sizeof(int16_t);
117 case kShort3_GrSLType:
118 return 3 * sizeof(int16_t);
119 case kShort4_GrSLType:
120 return 4 * sizeof(int16_t);
121 case kUShort_GrSLType:
122 return sizeof(uint16_t);
123 case kUShort2_GrSLType:
124 return 2 * sizeof(uint16_t);
125 case kUShort3_GrSLType:
126 return 3 * sizeof(uint16_t);
127 case kUShort4_GrSLType:
128 return 4 * sizeof(uint16_t);
Brian Salomonfa26e662016-11-14 11:27:00 -0500129 case kInt_GrSLType:
csmartdaltonb37cb232017-02-08 14:56:27 -0500130 return sizeof(int32_t);
Brian Salomonfa26e662016-11-14 11:27:00 -0500131 case kUint_GrSLType:
csmartdaltonb37cb232017-02-08 14:56:27 -0500132 return sizeof(int32_t);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400133 case kHalf_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400134 case kFloat_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500135 return sizeof(float);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400136 case kHalf2_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400137 case kFloat2_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500138 return 2 * sizeof(float);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400139 case kHalf3_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400140 case kFloat3_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500141 return 3 * sizeof(float);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400142 case kHalf4_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400143 case kFloat4_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500144 return 4 * sizeof(float);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400145 case kUint2_GrSLType:
Chris Dalton51ebd662017-10-24 16:10:48 -0600146 return 2 * sizeof(uint32_t);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400147 case kInt2_GrSLType:
csmartdaltonb37cb232017-02-08 14:56:27 -0500148 return 2 * sizeof(int32_t);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400149 case kInt3_GrSLType:
csmartdaltonb37cb232017-02-08 14:56:27 -0500150 return 3 * sizeof(int32_t);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400151 case kInt4_GrSLType:
csmartdaltonb37cb232017-02-08 14:56:27 -0500152 return 4 * sizeof(int32_t);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400153 case kHalf2x2_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400154 case kFloat2x2_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500155 //TODO: this will be 4 * szof(float) on std430.
156 return 8 * sizeof(float);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400157 case kHalf3x3_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400158 case kFloat3x3_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500159 return 12 * sizeof(float);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400160 case kHalf4x4_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400161 case kFloat4x4_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500162 return 16 * sizeof(float);
egdaniel4ee1cda2016-02-26 08:18:49 -0800163
Brian Salomonfa26e662016-11-14 11:27:00 -0500164 // This query is only valid for certain types.
165 case kVoid_GrSLType:
166 case kBool_GrSLType:
167 case kTexture2DSampler_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500168 case kTextureExternalSampler_GrSLType:
169 case kTexture2DRectSampler_GrSLType:
Stephen Whiteff5d7a22019-07-26 17:42:06 -0400170 case kSampler_GrSLType:
171 case kTexture2D_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500172 break;
173 }
Ben Wagnerb4aab9a2017-08-16 10:53:04 -0400174 SK_ABORT("Unexpected type");
egdaniel4ee1cda2016-02-26 08:18:49 -0800175}
176
177
Greg Daniel164a9f02016-02-22 09:56:40 -0500178// Given the current offset into the ubo, calculate the offset for the uniform we're trying to add
179// taking into consideration all alignment requirements. The uniformOffset is set to the offset for
180// the new uniform, and currentOffset is updated to be the offset to the end of the new uniform.
Mike Kleindc735592018-10-11 14:26:30 -0400181static void get_ubo_aligned_offset(uint32_t* uniformOffset,
182 uint32_t* currentOffset,
183 GrSLType type,
184 int arrayCount) {
Greg Daniel164a9f02016-02-22 09:56:40 -0500185 uint32_t alignmentMask = grsltype_to_alignment_mask(type);
egdaniel4ee1cda2016-02-26 08:18:49 -0800186 // We want to use the std140 layout here, so we must make arrays align to 16 bytes.
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400187 if (arrayCount || type == kFloat2x2_GrSLType) {
egdaniel4ee1cda2016-02-26 08:18:49 -0800188 alignmentMask = 0xF;
189 }
Greg Daniel164a9f02016-02-22 09:56:40 -0500190 uint32_t offsetDiff = *currentOffset & alignmentMask;
191 if (offsetDiff != 0) {
192 offsetDiff = alignmentMask - offsetDiff + 1;
193 }
194 *uniformOffset = *currentOffset + offsetDiff;
195 SkASSERT(sizeof(float) == 4);
egdaniel4ee1cda2016-02-26 08:18:49 -0800196 if (arrayCount) {
197 uint32_t elementSize = SkTMax<uint32_t>(16, grsltype_to_vk_size(type));
198 SkASSERT(0 == (elementSize & 0xF));
199 *currentOffset = *uniformOffset + elementSize * arrayCount;
200 } else {
201 *currentOffset = *uniformOffset + grsltype_to_vk_size(type);
202 }
Greg Daniel164a9f02016-02-22 09:56:40 -0500203}
204
Sergey Ulanov2739fd22019-08-11 22:46:33 -0700205GrVkUniformHandler::~GrVkUniformHandler() {
206 GrVkGpu* gpu = static_cast<GrVkPipelineStateBuilder*>(fProgramBuilder)->gpu();
207 for (decltype(fSamplers)::Iter iter(&fSamplers); iter.next();) {
208 if (iter->fImmutableSampler) {
209 iter->fImmutableSampler->unref(gpu);
210 iter->fImmutableSampler = nullptr;
211 }
212 }
213}
214
Greg Daniel164a9f02016-02-22 09:56:40 -0500215GrGLSLUniformHandler::UniformHandle GrVkUniformHandler::internalAddUniformArray(
216 uint32_t visibility,
217 GrSLType type,
Greg Daniel164a9f02016-02-22 09:56:40 -0500218 const char* name,
219 bool mangleName,
220 int arrayCount,
221 const char** outName) {
222 SkASSERT(name && strlen(name));
Ethan Nicholas0be34802019-08-15 12:36:58 -0400223 SkASSERT(GrSLTypeIsFloatType(type));
Greg Daniel164a9f02016-02-22 09:56:40 -0500224
225 UniformInfo& uni = fUniforms.push_back();
226 uni.fVariable.setType(type);
227 // TODO this is a bit hacky, lets think of a better way. Basically we need to be able to use
228 // the uniform view matrix name in the GP, and the GP is immutable so it has to tell the PB
229 // exactly what name it wants to use for the uniform view matrix. If we prefix anythings, then
230 // the names will mismatch. I think the correct solution is to have all GPs which need the
231 // uniform view matrix, they should upload the view matrix in their setData along with regular
232 // uniforms.
233 char prefix = 'u';
Robert Phillipsfe8da172018-01-24 14:52:02 +0000234 if ('u' == name[0] || !strncmp(name, GR_NO_MANGLE_PREFIX, strlen(GR_NO_MANGLE_PREFIX))) {
Greg Daniel164a9f02016-02-22 09:56:40 -0500235 prefix = '\0';
236 }
237 fProgramBuilder->nameVariable(uni.fVariable.accessName(), prefix, name, mangleName);
238 uni.fVariable.setArrayCount(arrayCount);
Greg Daniel164a9f02016-02-22 09:56:40 -0500239 uni.fVisibility = visibility;
egdaniel09aa1fc2016-04-20 07:09:46 -0700240 // When outputing the GLSL, only the outer uniform block will get the Uniform modifier. Thus
241 // we set the modifier to none for all uniforms declared inside the block.
Brian Salomon99938a82016-11-21 13:41:08 -0500242 uni.fVariable.setTypeModifier(GrShaderVar::kNone_TypeModifier);
Greg Daniel164a9f02016-02-22 09:56:40 -0500243
Ethan Nicholas0be34802019-08-15 12:36:58 -0400244 get_ubo_aligned_offset(&uni.fUBOffset, &fCurrentUBOOffset, type, arrayCount);
Greg Daniel164a9f02016-02-22 09:56:40 -0500245
Greg Danieldbd44c72017-01-24 15:12:12 -0500246 SkString layoutQualifier;
247 layoutQualifier.appendf("offset=%d", uni.fUBOffset);
248 uni.fVariable.addLayoutQualifier(layoutQualifier.c_str());
249
egdaniel09aa1fc2016-04-20 07:09:46 -0700250 if (outName) {
251 *outName = uni.fVariable.c_str();
Greg Daniel164a9f02016-02-22 09:56:40 -0500252 }
253
254 return GrGLSLUniformHandler::UniformHandle(fUniforms.count() - 1);
255}
256
Greg Daniel9a51a862018-11-30 10:18:14 -0500257GrGLSLUniformHandler::SamplerHandle GrVkUniformHandler::addSampler(const GrTexture* texture,
258 const GrSamplerState& state,
Greg Daniel2c3398d2019-06-19 11:58:01 -0400259 const GrSwizzle& swizzle,
Greg Daniel9a51a862018-11-30 10:18:14 -0500260 const char* name,
261 const GrShaderCaps* shaderCaps) {
egdaniel09aa1fc2016-04-20 07:09:46 -0700262 SkASSERT(name && strlen(name));
egdaniel09aa1fc2016-04-20 07:09:46 -0700263 SkString mangleName;
264 char prefix = 'u';
265 fProgramBuilder->nameVariable(&mangleName, prefix, name, true);
Brian Salomon101b8442016-11-18 11:58:54 -0500266
Greg Daniel9a51a862018-11-30 10:18:14 -0500267 GrTextureType type = texture->texturePriv().textureType();
268
Brian Salomon101b8442016-11-18 11:58:54 -0500269 UniformInfo& info = fSamplers.push_back();
Brian Salomon60dd8c72018-07-30 10:24:13 -0400270 info.fVariable.setType(GrSLCombinedSamplerTypeForTextureType(type));
Brian Salomon99938a82016-11-21 13:41:08 -0500271 info.fVariable.setTypeModifier(GrShaderVar::kUniform_TypeModifier);
Brian Salomon101b8442016-11-18 11:58:54 -0500272 info.fVariable.setName(mangleName);
273 SkString layoutQualifier;
274 layoutQualifier.appendf("set=%d, binding=%d", kSamplerDescSet, fSamplers.count() - 1);
Brian Salomon60397682016-11-22 15:06:46 -0500275 info.fVariable.addLayoutQualifier(layoutQualifier.c_str());
Greg Daniel0f70be82018-10-08 17:35:08 +0000276 info.fVisibility = kFragment_GrShaderFlag;
Brian Salomon101b8442016-11-18 11:58:54 -0500277 info.fUBOffset = 0;
Greg Daniel9a51a862018-11-30 10:18:14 -0500278
Sergey Ulanov2739fd22019-08-11 22:46:33 -0700279 // Check if we are dealing with an external texture and store the needed information if so.
Greg Daniel9a51a862018-11-30 10:18:14 -0500280 const GrVkTexture* vkTexture = static_cast<const GrVkTexture*>(texture);
281 if (vkTexture->ycbcrConversionInfo().isValid()) {
Greg Daniel9a51a862018-11-30 10:18:14 -0500282 GrVkGpu* gpu = static_cast<GrVkPipelineStateBuilder*>(fProgramBuilder)->gpu();
283 info.fImmutableSampler = gpu->resourceProvider().findOrCreateCompatibleSampler(
284 state, vkTexture->ycbcrConversionInfo());
285 SkASSERT(info.fImmutableSampler);
286 }
287
Brian Salomon68ba1172019-06-05 11:15:08 -0400288 SkASSERT(shaderCaps->textureSwizzleAppliedInShader());
Brian Salomon101b8442016-11-18 11:58:54 -0500289 fSamplerSwizzles.push_back(swizzle);
290 SkASSERT(fSamplerSwizzles.count() == fSamplers.count());
egdaniel09aa1fc2016-04-20 07:09:46 -0700291 return GrGLSLUniformHandler::SamplerHandle(fSamplers.count() - 1);
292}
293
Greg Daniel164a9f02016-02-22 09:56:40 -0500294void GrVkUniformHandler::appendUniformDecls(GrShaderFlags visibility, SkString* out) const {
egdaniel09aa1fc2016-04-20 07:09:46 -0700295 for (int i = 0; i < fSamplers.count(); ++i) {
Brian Salomon101b8442016-11-18 11:58:54 -0500296 const UniformInfo& sampler = fSamplers[i];
297 SkASSERT(sampler.fVariable.getType() == kTexture2DSampler_GrSLType);
298 if (visibility == sampler.fVisibility) {
Brian Salomon94efbf52016-11-29 13:43:05 -0500299 sampler.fVariable.appendDecl(fProgramBuilder->shaderCaps(), out);
egdaniel09aa1fc2016-04-20 07:09:46 -0700300 out->append(";\n");
301 }
302 }
303
Greg Danielaa352de2017-07-17 09:05:16 -0400304#ifdef SK_DEBUG
Ethan Nicholas0be34802019-08-15 12:36:58 -0400305 bool firstOffsetCheck = false;
Greg Danielaa352de2017-07-17 09:05:16 -0400306 for (int i = 0; i < fUniforms.count(); ++i) {
307 const UniformInfo& localUniform = fUniforms[i];
Ethan Nicholas0be34802019-08-15 12:36:58 -0400308 if (!firstOffsetCheck) {
309 // Check to make sure we are starting our offset at 0 so the offset qualifier we
310 // set on each variable in the uniform block is valid.
311 SkASSERT(0 == localUniform.fUBOffset);
312 firstOffsetCheck = true;
Greg Danielaa352de2017-07-17 09:05:16 -0400313 }
314 }
315#endif
316
egdaniel09aa1fc2016-04-20 07:09:46 -0700317 SkString uniformsString;
Greg Daniel164a9f02016-02-22 09:56:40 -0500318 for (int i = 0; i < fUniforms.count(); ++i) {
319 const UniformInfo& localUniform = fUniforms[i];
Greg Daniel18f96022017-05-04 15:09:03 -0400320 if (visibility & localUniform.fVisibility) {
Greg Daniel164a9f02016-02-22 09:56:40 -0500321 if (GrSLTypeIsFloatType(localUniform.fVariable.getType())) {
Brian Salomon94efbf52016-11-29 13:43:05 -0500322 localUniform.fVariable.appendDecl(fProgramBuilder->shaderCaps(), &uniformsString);
Greg Daniel164a9f02016-02-22 09:56:40 -0500323 uniformsString.append(";\n");
Greg Daniel164a9f02016-02-22 09:56:40 -0500324 }
325 }
326 }
Greg Danielaa352de2017-07-17 09:05:16 -0400327
Greg Daniel164a9f02016-02-22 09:56:40 -0500328 if (!uniformsString.isEmpty()) {
Ethan Nicholas0be34802019-08-15 12:36:58 -0400329 out->appendf("layout (set=%d, binding=%d) uniform uniformBuffer\n{\n",
330 kUniformBufferDescSet, kUniformBinding);
Greg Daniel164a9f02016-02-22 09:56:40 -0500331 out->appendf("%s\n};\n", uniformsString.c_str());
332 }
egdaniel4ee1cda2016-02-26 08:18:49 -0800333}
Ethan Nicholas0be34802019-08-15 12:36:58 -0400334
335uint32_t GrVkUniformHandler::getRTHeightOffset() const {
336 uint32_t result;
337 uint32_t currentOffset = fCurrentUBOOffset;
338 get_ubo_aligned_offset(&result, &currentOffset, kFloat_GrSLType, 0);
339 return result;
340}