blob: e55216cdc5730091d9962a18ef5b8e5b4effbdf2 [file] [log] [blame]
daniel@transgaming.com91ed1492010-10-29 03:11:43 +00001//
2// Copyright (c) 2010 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
Geoff Lang17732822013-08-29 13:46:49 -04007#include "compiler/translator/util.h"
daniel@transgaming.com91ed1492010-10-29 03:11:43 +00008
Zhenyao Mof1d723c2013-09-23 14:57:07 -04009#include <limits>
10
Olli Etuaho99bd5f42016-11-07 12:44:29 +000011#include "common/utilities.h"
Zhenyao Mocc4ec642013-09-23 14:57:10 -040012#include "compiler/preprocessor/numeric_lex.h"
Zhenyao Mo94ac7b72014-10-15 18:22:08 -070013#include "compiler/translator/SymbolTable.h"
Zhenyao Mof1d723c2013-09-23 14:57:07 -040014
Olli Etuahof541f522015-10-13 12:21:01 +030015bool atoi_clamp(const char *str, unsigned int *value)
Zhenyao Mof1d723c2013-09-23 14:57:07 -040016{
Zhenyao Mocc4ec642013-09-23 14:57:10 -040017 bool success = pp::numeric_lex_int(str, value);
18 if (!success)
Olli Etuahof541f522015-10-13 12:21:01 +030019 *value = std::numeric_limits<unsigned int>::max();
Zhenyao Mocc4ec642013-09-23 14:57:10 -040020 return success;
Zhenyao Mof1d723c2013-09-23 14:57:07 -040021}
22
Jamie Madill033dae62014-06-18 12:56:28 -040023namespace sh
24{
25
Olli Etuaho99bd5f42016-11-07 12:44:29 +000026float NumericLexFloat32OutOfRangeToInfinity(const std::string &str)
27{
28 // Parses a decimal string using scientific notation into a floating point number.
29 // Out-of-range values are converted to infinity. Values that are too small to be
30 // represented are converted to zero.
31
32 // The mantissa in decimal scientific notation. The magnitude of the mantissa integer does not
33 // matter.
34 unsigned int decimalMantissa = 0;
35 size_t i = 0;
36 bool decimalPointSeen = false;
37 bool nonZeroSeenInMantissa = false;
38
39 // The exponent offset reflects the position of the decimal point.
40 int exponentOffset = -1;
41 while (i < str.length())
42 {
43 const char c = str[i];
44 if (c == 'e' || c == 'E')
45 {
46 break;
47 }
48 if (c == '.')
49 {
50 decimalPointSeen = true;
51 ++i;
52 continue;
53 }
54
55 unsigned int digit = static_cast<unsigned int>(c - '0');
56 ASSERT(digit < 10u);
57 if (digit != 0u)
58 {
59 nonZeroSeenInMantissa = true;
60 }
61 if (nonZeroSeenInMantissa)
62 {
63 // Add bits to the mantissa until space runs out in 32-bit int. This should be
64 // enough precision to make the resulting binary mantissa accurate to 1 ULP.
65 if (decimalMantissa <= (std::numeric_limits<unsigned int>::max() - 9u) / 10u)
66 {
67 decimalMantissa = decimalMantissa * 10u + digit;
68 }
69 if (!decimalPointSeen)
70 {
71 ++exponentOffset;
72 }
73 }
74 else if (decimalPointSeen)
75 {
76 --exponentOffset;
77 }
78 ++i;
79 }
80 if (decimalMantissa == 0)
81 {
82 return 0.0f;
83 }
84 int exponent = 0;
85 if (i < str.length())
86 {
87 ASSERT(str[i] == 'e' || str[i] == 'E');
88 ++i;
89 bool exponentOutOfRange = false;
90 bool negativeExponent = false;
91 if (str[i] == '-')
92 {
93 negativeExponent = true;
94 ++i;
95 }
96 else if (str[i] == '+')
97 {
98 ++i;
99 }
100 while (i < str.length())
101 {
102 const char c = str[i];
103 unsigned int digit = static_cast<unsigned int>(c - '0');
104 ASSERT(digit < 10u);
105 if (exponent <= (std::numeric_limits<int>::max() - 9) / 10)
106 {
107 exponent = exponent * 10 + digit;
108 }
109 else
110 {
111 exponentOutOfRange = true;
112 }
113 ++i;
114 }
115 if (negativeExponent)
116 {
117 exponent = -exponent;
118 }
119 if (exponentOutOfRange)
120 {
121 if (negativeExponent)
122 {
123 return 0.0f;
124 }
125 else
126 {
127 return std::numeric_limits<float>::infinity();
128 }
129 }
130 }
131 // Do the calculation in 64-bit to avoid overflow.
132 long long exponentLong =
133 static_cast<long long>(exponent) + static_cast<long long>(exponentOffset);
134 if (exponentLong > std::numeric_limits<float>::max_exponent10)
135 {
136 return std::numeric_limits<float>::infinity();
137 }
138 else if (exponentLong < std::numeric_limits<float>::min_exponent10)
139 {
140 return 0.0f;
141 }
142 // The exponent is in range, so we need to actually evaluate the float.
143 exponent = static_cast<int>(exponentLong);
144 double value = decimalMantissa;
145
146 // Calculate the exponent offset to normalize the mantissa.
147 int normalizationExponentOffset = 0;
148 while (decimalMantissa >= 10u)
149 {
150 --normalizationExponentOffset;
151 decimalMantissa /= 10u;
152 }
153 // Apply the exponent.
154 value *= std::pow(10.0, static_cast<double>(exponent + normalizationExponentOffset));
155 if (value > static_cast<double>(std::numeric_limits<float>::max()))
156 {
157 return std::numeric_limits<float>::infinity();
158 }
159 if (value < static_cast<double>(std::numeric_limits<float>::min()))
160 {
161 return 0.0f;
162 }
163 return static_cast<float>(value);
164}
165
166bool strtof_clamp(const std::string &str, float *value)
167{
168 // Try the standard float parsing path first.
169 bool success = pp::numeric_lex_float(str, value);
170
171 // If the standard path doesn't succeed, take the path that can handle the following corner
172 // cases:
173 // 1. The decimal mantissa is very small but the exponent is very large, putting the resulting
174 // number inside the float range.
175 // 2. The decimal mantissa is very large but the exponent is very small, putting the resulting
176 // number inside the float range.
177 // 3. The value is out-of-range and should be evaluated as infinity.
178 // 4. The value is too small and should be evaluated as zero.
179 // See ESSL 3.00.6 section 4.1.4 for the relevant specification.
180 if (!success)
181 *value = NumericLexFloat32OutOfRangeToInfinity(str);
182 return !gl::isInf(*value);
183}
184
Jamie Madill033dae62014-06-18 12:56:28 -0400185GLenum GLVariableType(const TType &type)
186{
187 if (type.getBasicType() == EbtFloat)
188 {
189 if (type.isScalar())
190 {
191 return GL_FLOAT;
192 }
193 else if (type.isVector())
194 {
195 switch (type.getNominalSize())
196 {
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500197 case 2:
198 return GL_FLOAT_VEC2;
199 case 3:
200 return GL_FLOAT_VEC3;
201 case 4:
202 return GL_FLOAT_VEC4;
203 default:
204 UNREACHABLE();
Jamie Madill033dae62014-06-18 12:56:28 -0400205 }
206 }
207 else if (type.isMatrix())
208 {
209 switch (type.getCols())
210 {
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500211 case 2:
212 switch (type.getRows())
213 {
214 case 2:
215 return GL_FLOAT_MAT2;
216 case 3:
217 return GL_FLOAT_MAT2x3;
218 case 4:
219 return GL_FLOAT_MAT2x4;
220 default:
221 UNREACHABLE();
222 }
Jamie Madill033dae62014-06-18 12:56:28 -0400223
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500224 case 3:
225 switch (type.getRows())
226 {
227 case 2:
228 return GL_FLOAT_MAT3x2;
229 case 3:
230 return GL_FLOAT_MAT3;
231 case 4:
232 return GL_FLOAT_MAT3x4;
233 default:
234 UNREACHABLE();
235 }
Jamie Madill033dae62014-06-18 12:56:28 -0400236
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500237 case 4:
238 switch (type.getRows())
239 {
240 case 2:
241 return GL_FLOAT_MAT4x2;
242 case 3:
243 return GL_FLOAT_MAT4x3;
244 case 4:
245 return GL_FLOAT_MAT4;
246 default:
247 UNREACHABLE();
248 }
Jamie Madill033dae62014-06-18 12:56:28 -0400249
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500250 default:
251 UNREACHABLE();
Jamie Madill033dae62014-06-18 12:56:28 -0400252 }
253 }
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500254 else
255 UNREACHABLE();
Jamie Madill033dae62014-06-18 12:56:28 -0400256 }
257 else if (type.getBasicType() == EbtInt)
258 {
259 if (type.isScalar())
260 {
261 return GL_INT;
262 }
263 else if (type.isVector())
264 {
265 switch (type.getNominalSize())
266 {
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500267 case 2:
268 return GL_INT_VEC2;
269 case 3:
270 return GL_INT_VEC3;
271 case 4:
272 return GL_INT_VEC4;
273 default:
274 UNREACHABLE();
Jamie Madill033dae62014-06-18 12:56:28 -0400275 }
276 }
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500277 else
278 UNREACHABLE();
Jamie Madill033dae62014-06-18 12:56:28 -0400279 }
280 else if (type.getBasicType() == EbtUInt)
281 {
282 if (type.isScalar())
283 {
284 return GL_UNSIGNED_INT;
285 }
286 else if (type.isVector())
287 {
288 switch (type.getNominalSize())
289 {
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500290 case 2:
291 return GL_UNSIGNED_INT_VEC2;
292 case 3:
293 return GL_UNSIGNED_INT_VEC3;
294 case 4:
295 return GL_UNSIGNED_INT_VEC4;
296 default:
297 UNREACHABLE();
Jamie Madill033dae62014-06-18 12:56:28 -0400298 }
299 }
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500300 else
301 UNREACHABLE();
Jamie Madill033dae62014-06-18 12:56:28 -0400302 }
303 else if (type.getBasicType() == EbtBool)
304 {
305 if (type.isScalar())
306 {
307 return GL_BOOL;
308 }
309 else if (type.isVector())
310 {
311 switch (type.getNominalSize())
312 {
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500313 case 2:
314 return GL_BOOL_VEC2;
315 case 3:
316 return GL_BOOL_VEC3;
317 case 4:
318 return GL_BOOL_VEC4;
319 default:
320 UNREACHABLE();
Jamie Madill033dae62014-06-18 12:56:28 -0400321 }
322 }
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500323 else
324 UNREACHABLE();
Jamie Madill033dae62014-06-18 12:56:28 -0400325 }
326
327 switch (type.getBasicType())
328 {
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500329 case EbtSampler2D:
330 return GL_SAMPLER_2D;
331 case EbtSampler3D:
332 return GL_SAMPLER_3D;
333 case EbtSamplerCube:
334 return GL_SAMPLER_CUBE;
335 case EbtSamplerExternalOES:
336 return GL_SAMPLER_EXTERNAL_OES;
Andrei Volykhina5527072017-03-22 16:46:30 +0300337 case EbtSamplerExternal2DY2YEXT:
338 return GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT;
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500339 case EbtSampler2DRect:
340 return GL_SAMPLER_2D_RECT_ARB;
341 case EbtSampler2DArray:
342 return GL_SAMPLER_2D_ARRAY;
JiangYizhou40219322016-12-09 09:50:51 +0800343 case EbtSampler2DMS:
344 return GL_SAMPLER_2D_MULTISAMPLE;
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500345 case EbtISampler2D:
346 return GL_INT_SAMPLER_2D;
347 case EbtISampler3D:
348 return GL_INT_SAMPLER_3D;
349 case EbtISamplerCube:
350 return GL_INT_SAMPLER_CUBE;
351 case EbtISampler2DArray:
352 return GL_INT_SAMPLER_2D_ARRAY;
JiangYizhou40219322016-12-09 09:50:51 +0800353 case EbtISampler2DMS:
354 return GL_INT_SAMPLER_2D_MULTISAMPLE;
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500355 case EbtUSampler2D:
356 return GL_UNSIGNED_INT_SAMPLER_2D;
357 case EbtUSampler3D:
358 return GL_UNSIGNED_INT_SAMPLER_3D;
359 case EbtUSamplerCube:
360 return GL_UNSIGNED_INT_SAMPLER_CUBE;
361 case EbtUSampler2DArray:
362 return GL_UNSIGNED_INT_SAMPLER_2D_ARRAY;
JiangYizhou40219322016-12-09 09:50:51 +0800363 case EbtUSampler2DMS:
364 return GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE;
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500365 case EbtSampler2DShadow:
366 return GL_SAMPLER_2D_SHADOW;
367 case EbtSamplerCubeShadow:
368 return GL_SAMPLER_CUBE_SHADOW;
369 case EbtSampler2DArrayShadow:
370 return GL_SAMPLER_2D_ARRAY_SHADOW;
371 case EbtImage2D:
372 return GL_IMAGE_2D;
373 case EbtIImage2D:
374 return GL_INT_IMAGE_2D;
375 case EbtUImage2D:
376 return GL_UNSIGNED_INT_IMAGE_2D;
377 case EbtImage2DArray:
378 return GL_IMAGE_2D_ARRAY;
379 case EbtIImage2DArray:
380 return GL_INT_IMAGE_2D_ARRAY;
381 case EbtUImage2DArray:
382 return GL_UNSIGNED_INT_IMAGE_2D_ARRAY;
383 case EbtImage3D:
384 return GL_IMAGE_3D;
385 case EbtIImage3D:
386 return GL_INT_IMAGE_3D;
387 case EbtUImage3D:
388 return GL_UNSIGNED_INT_IMAGE_3D;
389 case EbtImageCube:
390 return GL_IMAGE_CUBE;
391 case EbtIImageCube:
392 return GL_INT_IMAGE_CUBE;
393 case EbtUImageCube:
394 return GL_UNSIGNED_INT_IMAGE_CUBE;
jchen104cdac9e2017-05-08 11:01:20 +0800395 case EbtAtomicCounter:
396 return GL_UNSIGNED_INT_ATOMIC_COUNTER;
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500397 default:
398 UNREACHABLE();
Jamie Madill033dae62014-06-18 12:56:28 -0400399 }
400
401 return GL_NONE;
402}
403
404GLenum GLVariablePrecision(const TType &type)
405{
406 if (type.getBasicType() == EbtFloat)
407 {
408 switch (type.getPrecision())
409 {
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500410 case EbpHigh:
411 return GL_HIGH_FLOAT;
412 case EbpMedium:
413 return GL_MEDIUM_FLOAT;
414 case EbpLow:
415 return GL_LOW_FLOAT;
416 case EbpUndefined:
417 // Should be defined as the default precision by the parser
418 default:
419 UNREACHABLE();
Jamie Madill033dae62014-06-18 12:56:28 -0400420 }
421 }
422 else if (type.getBasicType() == EbtInt || type.getBasicType() == EbtUInt)
423 {
424 switch (type.getPrecision())
425 {
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500426 case EbpHigh:
427 return GL_HIGH_INT;
428 case EbpMedium:
429 return GL_MEDIUM_INT;
430 case EbpLow:
431 return GL_LOW_INT;
432 case EbpUndefined:
433 // Should be defined as the default precision by the parser
434 default:
435 UNREACHABLE();
Jamie Madill033dae62014-06-18 12:56:28 -0400436 }
437 }
438
439 // Other types (boolean, sampler) don't have a precision
440 return GL_NONE;
441}
442
443TString ArrayString(const TType &type)
444{
445 if (!type.isArray())
446 {
447 return "";
448 }
449
450 return "[" + str(type.getArraySize()) + "]";
451}
452
453bool IsVaryingOut(TQualifier qualifier)
454{
455 switch (qualifier)
456 {
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500457 case EvqVaryingOut:
458 case EvqSmoothOut:
459 case EvqFlatOut:
460 case EvqCentroidOut:
461 case EvqVertexOut:
462 return true;
Jamie Madill033dae62014-06-18 12:56:28 -0400463
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500464 default:
465 break;
Jamie Madill033dae62014-06-18 12:56:28 -0400466 }
467
468 return false;
469}
470
471bool IsVaryingIn(TQualifier qualifier)
472{
473 switch (qualifier)
474 {
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500475 case EvqVaryingIn:
476 case EvqSmoothIn:
477 case EvqFlatIn:
478 case EvqCentroidIn:
479 case EvqFragmentIn:
480 return true;
Jamie Madill033dae62014-06-18 12:56:28 -0400481
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500482 default:
483 break;
Jamie Madill033dae62014-06-18 12:56:28 -0400484 }
485
486 return false;
487}
488
489bool IsVarying(TQualifier qualifier)
490{
491 return IsVaryingIn(qualifier) || IsVaryingOut(qualifier);
492}
493
Jamie Madillf2575982014-06-25 16:04:54 -0400494InterpolationType GetInterpolationType(TQualifier qualifier)
Jamie Madill033dae62014-06-18 12:56:28 -0400495{
496 switch (qualifier)
497 {
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500498 case EvqFlatIn:
499 case EvqFlatOut:
500 return INTERPOLATION_FLAT;
Jamie Madill033dae62014-06-18 12:56:28 -0400501
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500502 case EvqSmoothIn:
503 case EvqSmoothOut:
504 case EvqVertexOut:
505 case EvqFragmentIn:
506 case EvqVaryingIn:
507 case EvqVaryingOut:
508 return INTERPOLATION_SMOOTH;
Jamie Madill033dae62014-06-18 12:56:28 -0400509
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500510 case EvqCentroidIn:
511 case EvqCentroidOut:
512 return INTERPOLATION_CENTROID;
Jamie Madill033dae62014-06-18 12:56:28 -0400513
Jamie Madilld7b1ab52016-12-12 14:42:19 -0500514 default:
515 UNREACHABLE();
516 return INTERPOLATION_SMOOTH;
Jamie Madill033dae62014-06-18 12:56:28 -0400517 }
518}
519
Corentin Wallez509e4562016-08-25 14:55:44 -0400520TType GetShaderVariableBasicType(const sh::ShaderVariable &var)
Zhenyao Mo72111912016-07-20 17:45:56 -0700521{
Corentin Wallez509e4562016-08-25 14:55:44 -0400522 switch (var.type)
Zhenyao Mo72111912016-07-20 17:45:56 -0700523 {
Qin Jiajia7835b522016-10-08 11:20:17 +0800524 case GL_BOOL:
525 return TType(EbtBool);
526 case GL_BOOL_VEC2:
527 return TType(EbtBool, 2);
528 case GL_BOOL_VEC3:
529 return TType(EbtBool, 3);
530 case GL_BOOL_VEC4:
531 return TType(EbtBool, 4);
Zhenyao Mo72111912016-07-20 17:45:56 -0700532 case GL_FLOAT:
533 return TType(EbtFloat);
534 case GL_FLOAT_VEC2:
535 return TType(EbtFloat, 2);
536 case GL_FLOAT_VEC3:
537 return TType(EbtFloat, 3);
538 case GL_FLOAT_VEC4:
539 return TType(EbtFloat, 4);
540 case GL_FLOAT_MAT2:
541 return TType(EbtFloat, 2, 2);
542 case GL_FLOAT_MAT3:
543 return TType(EbtFloat, 3, 3);
544 case GL_FLOAT_MAT4:
545 return TType(EbtFloat, 4, 4);
546 case GL_FLOAT_MAT2x3:
547 return TType(EbtFloat, 2, 3);
548 case GL_FLOAT_MAT2x4:
549 return TType(EbtFloat, 2, 4);
550 case GL_FLOAT_MAT3x2:
551 return TType(EbtFloat, 3, 2);
552 case GL_FLOAT_MAT3x4:
553 return TType(EbtFloat, 3, 4);
554 case GL_FLOAT_MAT4x2:
555 return TType(EbtFloat, 4, 2);
556 case GL_FLOAT_MAT4x3:
557 return TType(EbtFloat, 4, 3);
558 case GL_INT:
559 return TType(EbtInt);
560 case GL_INT_VEC2:
561 return TType(EbtInt, 2);
562 case GL_INT_VEC3:
563 return TType(EbtInt, 3);
564 case GL_INT_VEC4:
565 return TType(EbtInt, 4);
566 case GL_UNSIGNED_INT:
567 return TType(EbtUInt);
568 case GL_UNSIGNED_INT_VEC2:
569 return TType(EbtUInt, 2);
570 case GL_UNSIGNED_INT_VEC3:
571 return TType(EbtUInt, 3);
572 case GL_UNSIGNED_INT_VEC4:
573 return TType(EbtUInt, 4);
574 default:
575 UNREACHABLE();
576 return TType();
577 }
578}
579
Martin Radev70866b82016-07-22 15:27:42 +0300580// GLSL ES 1.0.17 4.6.1 The Invariant Qualifier
581bool CanBeInvariantESSL1(TQualifier qualifier)
582{
583 return IsVaryingIn(qualifier) || IsVaryingOut(qualifier) ||
584 IsBuiltinOutputVariable(qualifier) ||
585 (IsBuiltinFragmentInputVariable(qualifier) && qualifier != EvqFrontFacing);
Jamie Madill033dae62014-06-18 12:56:28 -0400586}
Martin Radev70866b82016-07-22 15:27:42 +0300587
588// GLSL ES 3.00 Revision 6, 4.6.1 The Invariant Qualifier
589// GLSL ES 3.10 Revision 4, 4.8.1 The Invariant Qualifier
590bool CanBeInvariantESSL3OrGreater(TQualifier qualifier)
591{
592 return IsVaryingOut(qualifier) || qualifier == EvqFragmentOut ||
593 IsBuiltinOutputVariable(qualifier);
594}
595
596bool IsBuiltinOutputVariable(TQualifier qualifier)
597{
598 switch (qualifier)
599 {
600 case EvqPosition:
601 case EvqPointSize:
602 case EvqFragDepth:
603 case EvqFragDepthEXT:
604 case EvqFragColor:
605 case EvqSecondaryFragColorEXT:
606 case EvqFragData:
607 case EvqSecondaryFragDataEXT:
608 return true;
609 default:
610 break;
611 }
612 return false;
613}
614
615bool IsBuiltinFragmentInputVariable(TQualifier qualifier)
616{
617 switch (qualifier)
618 {
619 case EvqFragCoord:
620 case EvqPointCoord:
621 case EvqFrontFacing:
622 return true;
623 default:
624 break;
625 }
626 return false;
627}
Martin Radeve469de82017-07-04 11:58:35 +0300628
629bool IsOutputESSL(ShShaderOutput output)
630{
631 return output == SH_ESSL_OUTPUT;
632}
633
634bool IsOutputGLSL(ShShaderOutput output)
635{
636 switch (output)
637 {
638 case SH_GLSL_130_OUTPUT:
639 case SH_GLSL_140_OUTPUT:
640 case SH_GLSL_150_CORE_OUTPUT:
641 case SH_GLSL_330_CORE_OUTPUT:
642 case SH_GLSL_400_CORE_OUTPUT:
643 case SH_GLSL_410_CORE_OUTPUT:
644 case SH_GLSL_420_CORE_OUTPUT:
645 case SH_GLSL_430_CORE_OUTPUT:
646 case SH_GLSL_440_CORE_OUTPUT:
647 case SH_GLSL_450_CORE_OUTPUT:
648 case SH_GLSL_COMPATIBILITY_OUTPUT:
649 return true;
650 default:
651 break;
652 }
653 return false;
654}
655bool IsOutputHLSL(ShShaderOutput output)
656{
657 switch (output)
658 {
659 case SH_HLSL_3_0_OUTPUT:
660 case SH_HLSL_4_1_OUTPUT:
661 case SH_HLSL_4_0_FL9_3_OUTPUT:
662 return true;
663 default:
664 break;
665 }
666 return false;
667}
668bool IsOutputVulkan(ShShaderOutput output)
669{
670 return output == SH_GLSL_VULKAN_OUTPUT;
671}
672
Martin Radev70866b82016-07-22 15:27:42 +0300673} // namespace sh