blob: 67fe2995fae9217112d89c6dc3dbf7aa58f0b29f [file] [log] [blame]
jvanverthcba99b82015-06-24 06:59:57 -07001/*
2 * Copyright 2011 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
Brian Salomon23c55b62018-06-19 16:28:41 -04008#include "GrGLSL.h"
Brian Salomon94efbf52016-11-29 13:43:05 -05009#include "GrShaderCaps.h"
Brian Salomon1d816b92017-08-17 11:07:59 -040010
Robert Phillips8296e752017-08-25 08:45:21 -040011const char* GrGLSLTypeString(const GrShaderCaps* shaderCaps, GrSLType t) {
12 switch (t) {
13 case kVoid_GrSLType:
14 return "void";
Ethan Nicholasf7b88202017-09-18 14:10:39 -040015 case kHalf_GrSLType:
16 return "half";
17 case kHalf2_GrSLType:
18 return "half2";
19 case kHalf3_GrSLType:
20 return "half3";
21 case kHalf4_GrSLType:
22 return "half4";
Ethan Nicholas8aa45692017-09-20 11:24:15 -040023 case kFloat_GrSLType:
24 return "float";
25 case kFloat2_GrSLType:
26 return "float2";
27 case kFloat3_GrSLType:
28 return "float3";
29 case kFloat4_GrSLType:
30 return "float4";
Ethan Nicholasf7b88202017-09-18 14:10:39 -040031 case kUint2_GrSLType:
Chris Dalton51ebd662017-10-24 16:10:48 -060032 return "uint2";
Ethan Nicholasf7b88202017-09-18 14:10:39 -040033 case kInt2_GrSLType:
Robert Phillips8296e752017-08-25 08:45:21 -040034 return "int2";
Ethan Nicholasf7b88202017-09-18 14:10:39 -040035 case kInt3_GrSLType:
Robert Phillips8296e752017-08-25 08:45:21 -040036 return "int3";
Ethan Nicholasf7b88202017-09-18 14:10:39 -040037 case kInt4_GrSLType:
Robert Phillips8296e752017-08-25 08:45:21 -040038 return "int4";
Ethan Nicholas8aa45692017-09-20 11:24:15 -040039 case kFloat2x2_GrSLType:
40 return "float2x2";
41 case kFloat3x3_GrSLType:
42 return "float3x3";
43 case kFloat4x4_GrSLType:
44 return "float4x4";
Ethan Nicholasf7b88202017-09-18 14:10:39 -040045 case kHalf2x2_GrSLType:
46 return "half2x2";
47 case kHalf3x3_GrSLType:
48 return "half3x3";
49 case kHalf4x4_GrSLType:
50 return "half4x4";
Robert Phillips8296e752017-08-25 08:45:21 -040051 case kTexture2DSampler_GrSLType:
52 return "sampler2D";
Robert Phillips8296e752017-08-25 08:45:21 -040053 case kTextureExternalSampler_GrSLType:
54 return "samplerExternalOES";
55 case kTexture2DRectSampler_GrSLType:
56 return "sampler2DRect";
57 case kBufferSampler_GrSLType:
58 return "samplerBuffer";
59 case kBool_GrSLType:
60 return "bool";
61 case kInt_GrSLType:
62 return "int";
63 case kUint_GrSLType:
64 return "uint";
Ethan Nicholasf7b88202017-09-18 14:10:39 -040065 case kShort_GrSLType:
66 return "short";
Chris Dalton51ebd662017-10-24 16:10:48 -060067 case kShort2_GrSLType:
68 return "short2";
69 case kShort3_GrSLType:
70 return "short3";
71 case kShort4_GrSLType:
72 return "short4";
Ethan Nicholasf7b88202017-09-18 14:10:39 -040073 case kUShort_GrSLType:
74 return "ushort";
Chris Dalton51ebd662017-10-24 16:10:48 -060075 case kUShort2_GrSLType:
76 if (shaderCaps->integerSupport()) {
77 return "ushort2";
78 } else {
79 // uint2 (aka uvec2) isn't supported in GLSL ES 1.00/GLSL 1.20
80 // FIXME: this should be handled by the client code rather than relying on
81 // unconventional ushort2 behavior.
82 return "float2";
83 }
84 case kUShort3_GrSLType:
85 return "ushort3";
86 case kUShort4_GrSLType:
87 return "ushort4";
Robert Phillips8296e752017-08-25 08:45:21 -040088 case kTexture2D_GrSLType:
89 return "texture2D";
90 case kSampler_GrSLType:
91 return "sampler";
Robert Phillips8296e752017-08-25 08:45:21 -040092 }
93 SK_ABORT("Unknown shader var type.");
94 return ""; // suppress warning
95}