OLD | NEW |
1 // | 1 // |
2 // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. | 2 // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 // | 5 // |
6 | 6 |
7 #include "GLSLANG/ShaderLang.h" | 7 #include "GLSLANG/ShaderLang.h" |
8 | 8 |
9 #include <assert.h> | 9 #include <assert.h> |
10 #include <math.h> | 10 #include <math.h> |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 GenerateResources(&resources); | 76 GenerateResources(&resources); |
77 | 77 |
78 argc--; | 78 argc--; |
79 argv++; | 79 argv++; |
80 for (; (argc >= 1) && (failCode == ESuccess); argc--, argv++) { | 80 for (; (argc >= 1) && (failCode == ESuccess); argc--, argv++) { |
81 if (argv[0][0] == '-') { | 81 if (argv[0][0] == '-') { |
82 switch (argv[0][1]) { | 82 switch (argv[0][1]) { |
83 case 'i': compileOptions |= SH_INTERMEDIATE_TREE; break; | 83 case 'i': compileOptions |= SH_INTERMEDIATE_TREE; break; |
84 case 'm': compileOptions |= SH_MAP_LONG_VARIABLE_NAMES; break; | 84 case 'm': compileOptions |= SH_MAP_LONG_VARIABLE_NAMES; break; |
85 case 'o': compileOptions |= SH_OBJECT_CODE; break; | 85 case 'o': compileOptions |= SH_OBJECT_CODE; break; |
86 case 'u': compileOptions |= SH_ATTRIBUTES_UNIFORMS; break; | 86 case 'u': compileOptions |= SH_VARIABLES; break; |
87 case 'l': compileOptions |= SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX; b
reak; | 87 case 'l': compileOptions |= SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX; b
reak; |
88 case 'e': compileOptions |= SH_EMULATE_BUILT_IN_FUNCTIONS; break; | 88 case 'e': compileOptions |= SH_EMULATE_BUILT_IN_FUNCTIONS; break; |
89 case 'd': compileOptions |= SH_DEPENDENCY_GRAPH; break; | 89 case 'd': compileOptions |= SH_DEPENDENCY_GRAPH; break; |
90 case 't': compileOptions |= SH_TIMING_RESTRICTIONS; break; | 90 case 't': compileOptions |= SH_TIMING_RESTRICTIONS; break; |
91 case 's': | 91 case 's': |
92 if (argv[0][2] == '=') { | 92 if (argv[0][2] == '=') { |
93 switch (argv[0][3]) { | 93 switch (argv[0][3]) { |
94 case 'e': spec = SH_GLES2_SPEC; break; | 94 case 'e': spec = SH_GLES2_SPEC; break; |
95 case 'w': spec = SH_WEBGL_SPEC; break; | 95 case 'w': spec = SH_WEBGL_SPEC; break; |
96 case 'c': spec = SH_CSS_SHADERS_SPEC; break; | 96 case 'c': spec = SH_CSS_SHADERS_SPEC; break; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 165 |
166 if (compiled && (compileOptions & SH_OBJECT_CODE)) { | 166 if (compiled && (compileOptions & SH_OBJECT_CODE)) { |
167 LogMsg("BEGIN", "COMPILER", numCompiles, "OBJ CODE"); | 167 LogMsg("BEGIN", "COMPILER", numCompiles, "OBJ CODE"); |
168 ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &bufferLen); | 168 ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &bufferLen); |
169 buffer = (char*) realloc(buffer, bufferLen * sizeof(char)); | 169 buffer = (char*) realloc(buffer, bufferLen * sizeof(char)); |
170 ShGetObjectCode(compiler, buffer); | 170 ShGetObjectCode(compiler, buffer); |
171 puts(buffer); | 171 puts(buffer); |
172 LogMsg("END", "COMPILER", numCompiles, "OBJ CODE"); | 172 LogMsg("END", "COMPILER", numCompiles, "OBJ CODE"); |
173 printf("\n\n"); | 173 printf("\n\n"); |
174 } | 174 } |
175 if (compiled && (compileOptions & SH_ATTRIBUTES_UNIFORMS)) { | 175 if (compiled && (compileOptions & SH_VARIABLES)) { |
176 LogMsg("BEGIN", "COMPILER", numCompiles, "ACTIVE ATTRIBS"); | 176 LogMsg("BEGIN", "COMPILER", numCompiles, "ACTIVE ATTRIBS"); |
177 PrintActiveVariables(compiler, SH_ACTIVE_ATTRIBUTES, (compileO
ptions & SH_MAP_LONG_VARIABLE_NAMES) != 0); | 177 PrintActiveVariables(compiler, SH_ACTIVE_ATTRIBUTES, (compileO
ptions & SH_MAP_LONG_VARIABLE_NAMES) != 0); |
178 LogMsg("END", "COMPILER", numCompiles, "ACTIVE ATTRIBS"); | 178 LogMsg("END", "COMPILER", numCompiles, "ACTIVE ATTRIBS"); |
179 printf("\n\n"); | 179 printf("\n\n"); |
180 | 180 |
181 LogMsg("BEGIN", "COMPILER", numCompiles, "ACTIVE UNIFORMS"); | 181 LogMsg("BEGIN", "COMPILER", numCompiles, "ACTIVE UNIFORMS"); |
182 PrintActiveVariables(compiler, SH_ACTIVE_UNIFORMS, (compileOpt
ions & SH_MAP_LONG_VARIABLE_NAMES) != 0); | 182 PrintActiveVariables(compiler, SH_ACTIVE_UNIFORMS, (compileOpt
ions & SH_MAP_LONG_VARIABLE_NAMES) != 0); |
183 LogMsg("END", "COMPILER", numCompiles, "ACTIVE UNIFORMS"); | 183 LogMsg("END", "COMPILER", numCompiles, "ACTIVE UNIFORMS"); |
184 printf("\n\n"); | 184 printf("\n\n"); |
185 } | 185 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 char* mappedName = NULL; | 298 char* mappedName = NULL; |
299 if (mapLongVariableNames) { | 299 if (mapLongVariableNames) { |
300 size_t mappedNameSize = 0; | 300 size_t mappedNameSize = 0; |
301 ShGetInfo(compiler, SH_MAPPED_NAME_MAX_LENGTH, &mappedNameSize); | 301 ShGetInfo(compiler, SH_MAPPED_NAME_MAX_LENGTH, &mappedNameSize); |
302 mappedName = new char[mappedNameSize]; | 302 mappedName = new char[mappedNameSize]; |
303 } | 303 } |
304 | 304 |
305 size_t activeVars = 0; | 305 size_t activeVars = 0; |
306 int size = 0; | 306 int size = 0; |
307 ShDataType type = SH_NONE; | 307 ShDataType type = SH_NONE; |
| 308 ShPrecisionType precision = SH_PRECISION_UNDEFINED; |
| 309 int staticUse = 0; |
308 const char* typeName = NULL; | 310 const char* typeName = NULL; |
309 ShGetInfo(compiler, varType, &activeVars); | 311 ShGetInfo(compiler, varType, &activeVars); |
310 for (size_t i = 0; i < activeVars; ++i) { | 312 for (size_t i = 0; i < activeVars; ++i) { |
311 switch (varType) { | 313 switch (varType) { |
312 case SH_ACTIVE_ATTRIBUTES: | 314 case SH_ACTIVE_ATTRIBUTES: |
313 ShGetActiveAttrib(compiler, static_cast<int>(i), NULL, &size, &t
ype, name, mappedName); | 315 ShGetVariableInfo(compiler, SH_ACTIVE_ATTRIBUTES, static_cast<in
t>(i), NULL, &size, &type, &precision, &staticUse, name, mappedName); |
314 break; | 316 break; |
315 case SH_ACTIVE_UNIFORMS: | 317 case SH_ACTIVE_UNIFORMS: |
316 ShGetActiveUniform(compiler, static_cast<int>(i), NULL, &size, &
type, name, mappedName); | 318 ShGetVariableInfo(compiler, SH_ACTIVE_ATTRIBUTES, static_cast<in
t>(i), NULL, &size, &type, &precision, &staticUse, name, mappedName); |
317 break; | 319 break; |
318 default: assert(0); | 320 default: assert(0); |
319 } | 321 } |
320 switch (type) { | 322 switch (type) { |
321 case SH_FLOAT: typeName = "GL_FLOAT"; break; | 323 case SH_FLOAT: typeName = "GL_FLOAT"; break; |
322 case SH_FLOAT_VEC2: typeName = "GL_FLOAT_VEC2"; break; | 324 case SH_FLOAT_VEC2: typeName = "GL_FLOAT_VEC2"; break; |
323 case SH_FLOAT_VEC3: typeName = "GL_FLOAT_VEC3"; break; | 325 case SH_FLOAT_VEC3: typeName = "GL_FLOAT_VEC3"; break; |
324 case SH_FLOAT_VEC4: typeName = "GL_FLOAT_VEC4"; break; | 326 case SH_FLOAT_VEC4: typeName = "GL_FLOAT_VEC4"; break; |
325 case SH_INT: typeName = "GL_INT"; break; | 327 case SH_INT: typeName = "GL_INT"; break; |
326 case SH_INT_VEC2: typeName = "GL_INT_VEC2"; break; | 328 case SH_INT_VEC2: typeName = "GL_INT_VEC2"; break; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 return true; | 380 return true; |
379 } | 381 } |
380 | 382 |
381 static void FreeShaderSource(ShaderSource& source) { | 383 static void FreeShaderSource(ShaderSource& source) { |
382 for (ShaderSource::size_type i = 0; i < source.size(); ++i) { | 384 for (ShaderSource::size_type i = 0; i < source.size(); ++i) { |
383 delete [] source[i]; | 385 delete [] source[i]; |
384 } | 386 } |
385 source.clear(); | 387 source.clear(); |
386 } | 388 } |
387 | 389 |
OLD | NEW |