blob: 848d52a5cdf18c7a9bfe11f5283b0ce3fbcf3518 [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
8#include "GrVkUniformHandler.h"
9#include "glsl/GrGLSLProgramBuilder.h"
10
11// To determine whether a current offset is aligned, we can just 'and' the lowest bits with the
12// alignment mask. A value of 0 means aligned, any other value is how many bytes past alignment we
13// are. This works since all alignments are powers of 2. The mask is always (alignment - 1).
egdaniel4ee1cda2016-02-26 08:18:49 -080014// This alignment mask will give correct alignments for using the std430 block layout. If you want
15// the std140 alignment, you can use this, but then make sure if you have an array type it is
16// aligned to 16 bytes (i.e. has mask of 0xF).
Chris Dalton51ebd662017-10-24 16:10:48 -060017// These are designated in the Vulkan spec, section 14.5.4 "Offset and Stride Assignment".
18// https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/html/vkspec.html#interfaces-resources-layout
Greg Daniel164a9f02016-02-22 09:56:40 -050019uint32_t grsltype_to_alignment_mask(GrSLType type) {
Brian Salomonfa26e662016-11-14 11:27:00 -050020 switch(type) {
Ruiqi Maob609e6d2018-07-17 10:19:38 -040021 case kByte_GrSLType: // fall through
22 case kUByte_GrSLType:
23 return 0x0;
24 case kByte2_GrSLType: // fall through
25 case kUByte2_GrSLType:
26 return 0x1;
27 case kByte3_GrSLType: // fall through
28 case kByte4_GrSLType:
29 case kUByte3_GrSLType:
30 case kUByte4_GrSLType:
31 return 0x3;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040032 case kShort_GrSLType: // fall through
Chris Dalton51ebd662017-10-24 16:10:48 -060033 case kUShort_GrSLType:
34 return 0x1;
35 case kShort2_GrSLType: // fall through
36 case kUShort2_GrSLType:
Chris Dalton6dd0d8a2017-10-24 19:53:13 +000037 return 0x3;
Chris Dalton51ebd662017-10-24 16:10:48 -060038 case kShort3_GrSLType: // fall through
39 case kShort4_GrSLType:
40 case kUShort3_GrSLType:
41 case kUShort4_GrSLType:
42 return 0x7;
43 case kInt_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050044 case kUint_GrSLType:
45 return 0x3;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040046 case kHalf_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -040047 case kFloat_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050048 return 0x3;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040049 case kHalf2_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -040050 case kFloat2_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050051 return 0x7;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040052 case kHalf3_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -040053 case kFloat3_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050054 return 0xF;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040055 case kHalf4_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -040056 case kFloat4_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050057 return 0xF;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040058 case kUint2_GrSLType:
Chris Dalton51ebd662017-10-24 16:10:48 -060059 return 0x7;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040060 case kInt2_GrSLType:
csmartdaltonb37cb232017-02-08 14:56:27 -050061 return 0x7;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040062 case kInt3_GrSLType:
csmartdaltonb37cb232017-02-08 14:56:27 -050063 return 0xF;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040064 case kInt4_GrSLType:
csmartdaltonb37cb232017-02-08 14:56:27 -050065 return 0xF;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040066 case kHalf2x2_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -040067 case kFloat2x2_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050068 return 0x7;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040069 case kHalf3x3_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -040070 case kFloat3x3_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050071 return 0xF;
Ethan Nicholasf7b88202017-09-18 14:10:39 -040072 case kHalf4x4_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -040073 case kFloat4x4_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050074 return 0xF;
75
76 // This query is only valid for certain types.
77 case kVoid_GrSLType:
78 case kBool_GrSLType:
79 case kTexture2DSampler_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050080 case kTextureExternalSampler_GrSLType:
81 case kTexture2DRectSampler_GrSLType:
csmartdalton22458032016-11-16 11:28:16 -070082 case kBufferSampler_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -050083 case kTexture2D_GrSLType:
84 case kSampler_GrSLType:
85 break;
86 }
Ben Wagnerb4aab9a2017-08-16 10:53:04 -040087 SK_ABORT("Unexpected type");
Brian Salomonfa26e662016-11-14 11:27:00 -050088 return 0;
Greg Daniel164a9f02016-02-22 09:56:40 -050089}
90
Chris Dalton51ebd662017-10-24 16:10:48 -060091/** Returns the size in bytes taken up in vulkanbuffers for GrSLTypes. */
egdaniel4ee1cda2016-02-26 08:18:49 -080092static inline uint32_t grsltype_to_vk_size(GrSLType type) {
Brian Salomonfa26e662016-11-14 11:27:00 -050093 switch(type) {
Ruiqi Maob609e6d2018-07-17 10:19:38 -040094 case kByte_GrSLType:
95 return sizeof(int8_t);
96 case kByte2_GrSLType:
97 return 2 * sizeof(int8_t);
98 case kByte3_GrSLType:
99 return 3 * sizeof(int8_t);
100 case kByte4_GrSLType:
101 return 4 * sizeof(int8_t);
102 case kUByte_GrSLType:
103 return sizeof(uint8_t);
104 case kUByte2_GrSLType:
105 return 2 * sizeof(uint8_t);
106 case kUByte3_GrSLType:
107 return 3 * sizeof(uint8_t);
108 case kUByte4_GrSLType:
109 return 4 * sizeof(uint8_t);
Chris Dalton51ebd662017-10-24 16:10:48 -0600110 case kShort_GrSLType:
111 return sizeof(int16_t);
112 case kShort2_GrSLType:
113 return 2 * sizeof(int16_t);
114 case kShort3_GrSLType:
115 return 3 * sizeof(int16_t);
116 case kShort4_GrSLType:
117 return 4 * sizeof(int16_t);
118 case kUShort_GrSLType:
119 return sizeof(uint16_t);
120 case kUShort2_GrSLType:
121 return 2 * sizeof(uint16_t);
122 case kUShort3_GrSLType:
123 return 3 * sizeof(uint16_t);
124 case kUShort4_GrSLType:
125 return 4 * sizeof(uint16_t);
Brian Salomonfa26e662016-11-14 11:27:00 -0500126 case kInt_GrSLType:
csmartdaltonb37cb232017-02-08 14:56:27 -0500127 return sizeof(int32_t);
Brian Salomonfa26e662016-11-14 11:27:00 -0500128 case kUint_GrSLType:
csmartdaltonb37cb232017-02-08 14:56:27 -0500129 return sizeof(int32_t);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400130 case kHalf_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400131 case kFloat_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500132 return sizeof(float);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400133 case kHalf2_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400134 case kFloat2_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500135 return 2 * sizeof(float);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400136 case kHalf3_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400137 case kFloat3_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500138 return 3 * sizeof(float);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400139 case kHalf4_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400140 case kFloat4_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500141 return 4 * sizeof(float);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400142 case kUint2_GrSLType:
Chris Dalton51ebd662017-10-24 16:10:48 -0600143 return 2 * sizeof(uint32_t);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400144 case kInt2_GrSLType:
csmartdaltonb37cb232017-02-08 14:56:27 -0500145 return 2 * sizeof(int32_t);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400146 case kInt3_GrSLType:
csmartdaltonb37cb232017-02-08 14:56:27 -0500147 return 3 * sizeof(int32_t);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400148 case kInt4_GrSLType:
csmartdaltonb37cb232017-02-08 14:56:27 -0500149 return 4 * sizeof(int32_t);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400150 case kHalf2x2_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400151 case kFloat2x2_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500152 //TODO: this will be 4 * szof(float) on std430.
153 return 8 * sizeof(float);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400154 case kHalf3x3_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400155 case kFloat3x3_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500156 return 12 * sizeof(float);
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400157 case kHalf4x4_GrSLType: // fall through
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400158 case kFloat4x4_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500159 return 16 * sizeof(float);
egdaniel4ee1cda2016-02-26 08:18:49 -0800160
Brian Salomonfa26e662016-11-14 11:27:00 -0500161 // This query is only valid for certain types.
162 case kVoid_GrSLType:
163 case kBool_GrSLType:
164 case kTexture2DSampler_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500165 case kTextureExternalSampler_GrSLType:
166 case kTexture2DRectSampler_GrSLType:
csmartdalton22458032016-11-16 11:28:16 -0700167 case kBufferSampler_GrSLType:
Brian Salomonfa26e662016-11-14 11:27:00 -0500168 case kTexture2D_GrSLType:
169 case kSampler_GrSLType:
170 break;
171 }
Ben Wagnerb4aab9a2017-08-16 10:53:04 -0400172 SK_ABORT("Unexpected type");
Brian Salomonfa26e662016-11-14 11:27:00 -0500173 return 0;
egdaniel4ee1cda2016-02-26 08:18:49 -0800174}
175
176
Greg Daniel164a9f02016-02-22 09:56:40 -0500177// Given the current offset into the ubo, calculate the offset for the uniform we're trying to add
178// taking into consideration all alignment requirements. The uniformOffset is set to the offset for
179// the new uniform, and currentOffset is updated to be the offset to the end of the new uniform.
180void get_ubo_aligned_offset(uint32_t* uniformOffset,
181 uint32_t* currentOffset,
182 GrSLType type,
183 int arrayCount) {
184 uint32_t alignmentMask = grsltype_to_alignment_mask(type);
egdaniel4ee1cda2016-02-26 08:18:49 -0800185 // We want to use the std140 layout here, so we must make arrays align to 16 bytes.
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400186 if (arrayCount || type == kFloat2x2_GrSLType) {
egdaniel4ee1cda2016-02-26 08:18:49 -0800187 alignmentMask = 0xF;
188 }
Greg Daniel164a9f02016-02-22 09:56:40 -0500189 uint32_t offsetDiff = *currentOffset & alignmentMask;
190 if (offsetDiff != 0) {
191 offsetDiff = alignmentMask - offsetDiff + 1;
192 }
193 *uniformOffset = *currentOffset + offsetDiff;
194 SkASSERT(sizeof(float) == 4);
egdaniel4ee1cda2016-02-26 08:18:49 -0800195 if (arrayCount) {
196 uint32_t elementSize = SkTMax<uint32_t>(16, grsltype_to_vk_size(type));
197 SkASSERT(0 == (elementSize & 0xF));
198 *currentOffset = *uniformOffset + elementSize * arrayCount;
199 } else {
200 *currentOffset = *uniformOffset + grsltype_to_vk_size(type);
201 }
Greg Daniel164a9f02016-02-22 09:56:40 -0500202}
203
204GrGLSLUniformHandler::UniformHandle GrVkUniformHandler::internalAddUniformArray(
205 uint32_t visibility,
206 GrSLType type,
207 GrSLPrecision precision,
208 const char* name,
209 bool mangleName,
210 int arrayCount,
211 const char** outName) {
212 SkASSERT(name && strlen(name));
Greg Daniel18f96022017-05-04 15:09:03 -0400213 // For now asserting the the visibility is either geometry types (vertex, tesselation, geometry,
214 // etc.) or only fragment.
215 SkASSERT(kVertex_GrShaderFlag == visibility ||
216 kGeometry_GrShaderFlag == visibility ||
217 (kVertex_GrShaderFlag | kGeometry_GrShaderFlag) == visibility ||
218 kFragment_GrShaderFlag == visibility);
Greg Daniel164a9f02016-02-22 09:56:40 -0500219 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
egdaniel09aa1fc2016-04-20 07:09:46 -0700220 GrSLTypeIsFloatType(type);
Greg Daniel164a9f02016-02-22 09:56:40 -0500221
222 UniformInfo& uni = fUniforms.push_back();
223 uni.fVariable.setType(type);
224 // TODO this is a bit hacky, lets think of a better way. Basically we need to be able to use
225 // the uniform view matrix name in the GP, and the GP is immutable so it has to tell the PB
226 // exactly what name it wants to use for the uniform view matrix. If we prefix anythings, then
227 // the names will mismatch. I think the correct solution is to have all GPs which need the
228 // uniform view matrix, they should upload the view matrix in their setData along with regular
229 // uniforms.
230 char prefix = 'u';
Robert Phillipsfe8da172018-01-24 14:52:02 +0000231 if ('u' == name[0] || !strncmp(name, GR_NO_MANGLE_PREFIX, strlen(GR_NO_MANGLE_PREFIX))) {
Greg Daniel164a9f02016-02-22 09:56:40 -0500232 prefix = '\0';
233 }
234 fProgramBuilder->nameVariable(uni.fVariable.accessName(), prefix, name, mangleName);
235 uni.fVariable.setArrayCount(arrayCount);
Greg Daniel164a9f02016-02-22 09:56:40 -0500236 uni.fVisibility = visibility;
237 uni.fVariable.setPrecision(precision);
egdaniel09aa1fc2016-04-20 07:09:46 -0700238 // When outputing the GLSL, only the outer uniform block will get the Uniform modifier. Thus
239 // we set the modifier to none for all uniforms declared inside the block.
Brian Salomon99938a82016-11-21 13:41:08 -0500240 uni.fVariable.setTypeModifier(GrShaderVar::kNone_TypeModifier);
Greg Daniel164a9f02016-02-22 09:56:40 -0500241
Greg Daniel18f96022017-05-04 15:09:03 -0400242 uint32_t* currentOffset;
243 uint32_t geomStages = kVertex_GrShaderFlag | kGeometry_GrShaderFlag;
244 if (geomStages & visibility) {
245 currentOffset = &fCurrentGeometryUBOOffset;
246 } else {
247 SkASSERT(kFragment_GrShaderFlag == visibility);
248 currentOffset = &fCurrentFragmentUBOOffset;
249 }
egdaniel09aa1fc2016-04-20 07:09:46 -0700250 get_ubo_aligned_offset(&uni.fUBOffset, currentOffset, type, arrayCount);
Greg Daniel164a9f02016-02-22 09:56:40 -0500251
Greg Danieldbd44c72017-01-24 15:12:12 -0500252 SkString layoutQualifier;
253 layoutQualifier.appendf("offset=%d", uni.fUBOffset);
254 uni.fVariable.addLayoutQualifier(layoutQualifier.c_str());
255
egdaniel09aa1fc2016-04-20 07:09:46 -0700256 if (outName) {
257 *outName = uni.fVariable.c_str();
Greg Daniel164a9f02016-02-22 09:56:40 -0500258 }
259
260 return GrGLSLUniformHandler::UniformHandle(fUniforms.count() - 1);
261}
262
Brian Salomon101b8442016-11-18 11:58:54 -0500263GrGLSLUniformHandler::SamplerHandle GrVkUniformHandler::addSampler(uint32_t visibility,
264 GrSwizzle swizzle,
265 GrSLType type,
266 GrSLPrecision precision,
267 const char* name) {
egdaniel09aa1fc2016-04-20 07:09:46 -0700268 SkASSERT(name && strlen(name));
Greg Daniel18f96022017-05-04 15:09:03 -0400269 // For now asserting the the visibility is either only vertex, geometry, or fragment
270 SkASSERT(kVertex_GrShaderFlag == visibility ||
271 kFragment_GrShaderFlag == visibility ||
272 kGeometry_GrShaderFlag == visibility);
egdaniel09aa1fc2016-04-20 07:09:46 -0700273 SkString mangleName;
274 char prefix = 'u';
275 fProgramBuilder->nameVariable(&mangleName, prefix, name, true);
Brian Salomon101b8442016-11-18 11:58:54 -0500276
277 UniformInfo& info = fSamplers.push_back();
278 SkASSERT(GrSLTypeIsCombinedSamplerType(type));
279 info.fVariable.setType(type);
Brian Salomon99938a82016-11-21 13:41:08 -0500280 info.fVariable.setTypeModifier(GrShaderVar::kUniform_TypeModifier);
Brian Salomon101b8442016-11-18 11:58:54 -0500281 info.fVariable.setPrecision(precision);
282 info.fVariable.setName(mangleName);
283 SkString layoutQualifier;
284 layoutQualifier.appendf("set=%d, binding=%d", kSamplerDescSet, fSamplers.count() - 1);
Brian Salomon60397682016-11-22 15:06:46 -0500285 info.fVariable.addLayoutQualifier(layoutQualifier.c_str());
Brian Salomon101b8442016-11-18 11:58:54 -0500286 info.fVisibility = visibility;
287 info.fUBOffset = 0;
288 fSamplerSwizzles.push_back(swizzle);
289 SkASSERT(fSamplerSwizzles.count() == fSamplers.count());
egdaniel09aa1fc2016-04-20 07:09:46 -0700290 return GrGLSLUniformHandler::SamplerHandle(fSamplers.count() - 1);
291}
292
Greg Daniel164a9f02016-02-22 09:56:40 -0500293void GrVkUniformHandler::appendUniformDecls(GrShaderFlags visibility, SkString* out) const {
Greg Daniel18f96022017-05-04 15:09:03 -0400294 SkASSERT(kVertex_GrShaderFlag == visibility ||
295 kGeometry_GrShaderFlag == visibility ||
296 kFragment_GrShaderFlag == visibility);
egdaniel09aa1fc2016-04-20 07:09:46 -0700297
298 for (int i = 0; i < fSamplers.count(); ++i) {
Brian Salomon101b8442016-11-18 11:58:54 -0500299 const UniformInfo& sampler = fSamplers[i];
300 SkASSERT(sampler.fVariable.getType() == kTexture2DSampler_GrSLType);
301 if (visibility == sampler.fVisibility) {
Brian Salomon94efbf52016-11-29 13:43:05 -0500302 sampler.fVariable.appendDecl(fProgramBuilder->shaderCaps(), out);
egdaniel09aa1fc2016-04-20 07:09:46 -0700303 out->append(";\n");
304 }
305 }
306
Greg Danielaa352de2017-07-17 09:05:16 -0400307#ifdef SK_DEBUG
308 bool firstGeomOffsetCheck = false;
309 bool firstFragOffsetCheck = false;
310 for (int i = 0; i < fUniforms.count(); ++i) {
311 const UniformInfo& localUniform = fUniforms[i];
312 if (kVertex_GrShaderFlag == localUniform.fVisibility ||
313 kGeometry_GrShaderFlag == localUniform.fVisibility ||
314 (kVertex_GrShaderFlag | kGeometry_GrShaderFlag) == localUniform.fVisibility) {
315 if (!firstGeomOffsetCheck) {
316 // Check to make sure we are starting our offset at 0 so the offset qualifier we
317 // set on each variable in the uniform block is valid.
318 SkASSERT(0 == localUniform.fUBOffset);
319 firstGeomOffsetCheck = true;
320 }
321 } else {
322 SkASSERT(kFragment_GrShaderFlag == localUniform.fVisibility);
323 if (!firstFragOffsetCheck) {
324 // Check to make sure we are starting our offset at 0 so the offset qualifier we
325 // set on each variable in the uniform block is valid.
326 SkASSERT(0 == localUniform.fUBOffset);
327 firstFragOffsetCheck = true;
328 }
329 }
330 }
331#endif
332
egdaniel09aa1fc2016-04-20 07:09:46 -0700333 SkString uniformsString;
Greg Daniel164a9f02016-02-22 09:56:40 -0500334 for (int i = 0; i < fUniforms.count(); ++i) {
335 const UniformInfo& localUniform = fUniforms[i];
Greg Daniel18f96022017-05-04 15:09:03 -0400336 if (visibility & localUniform.fVisibility) {
Greg Daniel164a9f02016-02-22 09:56:40 -0500337 if (GrSLTypeIsFloatType(localUniform.fVariable.getType())) {
Brian Salomon94efbf52016-11-29 13:43:05 -0500338 localUniform.fVariable.appendDecl(fProgramBuilder->shaderCaps(), &uniformsString);
Greg Daniel164a9f02016-02-22 09:56:40 -0500339 uniformsString.append(";\n");
Greg Daniel164a9f02016-02-22 09:56:40 -0500340 }
341 }
342 }
Greg Danielaa352de2017-07-17 09:05:16 -0400343
Greg Daniel164a9f02016-02-22 09:56:40 -0500344 if (!uniformsString.isEmpty()) {
Greg Daniel18f96022017-05-04 15:09:03 -0400345 uint32_t uniformBinding;
346 const char* stage;
347 if (kVertex_GrShaderFlag == visibility) {
348 uniformBinding = kGeometryBinding;
349 stage = "vertex";
350 } else if (kGeometry_GrShaderFlag == visibility) {
351 uniformBinding = kGeometryBinding;
352 stage = "geometry";
353 } else {
354 SkASSERT(kFragment_GrShaderFlag == visibility);
355 uniformBinding = kFragBinding;
356 stage = "fragment";
357 }
Greg Daniel164a9f02016-02-22 09:56:40 -0500358 out->appendf("layout (set=%d, binding=%d) uniform %sUniformBuffer\n{\n",
359 kUniformBufferDescSet, uniformBinding, stage);
360 out->appendf("%s\n};\n", uniformsString.c_str());
361 }
egdaniel4ee1cda2016-02-26 08:18:49 -0800362}