Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Side by Side Diff: gpu/command_buffer/service/shader_translator_unittest.cc

Issue 2852923004: Remove NameMap from shader translator and shader/program managers (Closed)
Patch Set: remove some TODO(zmo)s Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <GLES2/gl2.h> 5 #include <GLES2/gl2.h>
6 6
7 #include "gpu/command_buffer/service/shader_translator.h" 7 #include "gpu/command_buffer/service/shader_translator.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gl/gl_version_info.h" 9 #include "ui/gl/gl_version_info.h"
10 10
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 "}"; 96 "}";
97 97
98 // A valid shader should be successfully translated. 98 // A valid shader should be successfully translated.
99 std::string info_log, translated_source; 99 std::string info_log, translated_source;
100 int shader_version; 100 int shader_version;
101 AttributeMap attrib_map; 101 AttributeMap attrib_map;
102 UniformMap uniform_map; 102 UniformMap uniform_map;
103 VaryingMap varying_map; 103 VaryingMap varying_map;
104 InterfaceBlockMap interface_block_map; 104 InterfaceBlockMap interface_block_map;
105 OutputVariableList output_variable_list; 105 OutputVariableList output_variable_list;
106 NameMap name_map;
107 EXPECT_TRUE(vertex_translator_->Translate( 106 EXPECT_TRUE(vertex_translator_->Translate(
108 shader, &info_log, &translated_source, &shader_version, &attrib_map, 107 shader, &info_log, &translated_source, &shader_version, &attrib_map,
109 &uniform_map, &varying_map, &interface_block_map, &output_variable_list, 108 &uniform_map, &varying_map, &interface_block_map, &output_variable_list));
110 &name_map));
111 109
112 // Info log must be NULL. 110 // Info log must be NULL.
113 EXPECT_TRUE(info_log.empty()); 111 EXPECT_TRUE(info_log.empty());
114 // Translated shader must be valid and non-empty. 112 // Translated shader must be valid and non-empty.
115 ASSERT_FALSE(translated_source.empty()); 113 ASSERT_FALSE(translated_source.empty());
116 // There should be no attributes, uniforms, and only one built-in 114 // There should be no attributes, uniforms, and only one built-in
117 // varying: gl_Position. 115 // varying: gl_Position.
118 EXPECT_TRUE(attrib_map.empty()); 116 EXPECT_TRUE(attrib_map.empty());
119 EXPECT_TRUE(uniform_map.empty()); 117 EXPECT_TRUE(uniform_map.empty());
120 EXPECT_TRUE(interface_block_map.empty()); 118 EXPECT_TRUE(interface_block_map.empty());
121 EXPECT_EQ(1u, varying_map.size()); 119 EXPECT_EQ(1u, varying_map.size());
122 EXPECT_TRUE(output_variable_list.empty()); 120 EXPECT_TRUE(output_variable_list.empty());
123 // There should be no name mapping.
124 EXPECT_TRUE(name_map.empty());
125 } 121 }
126 122
127 TEST_F(ShaderTranslatorTest, InvalidVertexShader) { 123 TEST_F(ShaderTranslatorTest, InvalidVertexShader) {
128 const char* bad_shader = "foo-bar"; 124 const char* bad_shader = "foo-bar";
129 const char* good_shader = 125 const char* good_shader =
130 "void main() {\n" 126 "void main() {\n"
131 " gl_Position = vec4(1.0);\n" 127 " gl_Position = vec4(1.0);\n"
132 "}"; 128 "}";
133 129
134 // An invalid shader should fail. 130 // An invalid shader should fail.
135 std::string info_log, translated_source; 131 std::string info_log, translated_source;
136 int shader_version; 132 int shader_version;
137 AttributeMap attrib_map; 133 AttributeMap attrib_map;
138 UniformMap uniform_map; 134 UniformMap uniform_map;
139 VaryingMap varying_map; 135 VaryingMap varying_map;
140 InterfaceBlockMap interface_block_map; 136 InterfaceBlockMap interface_block_map;
141 OutputVariableList output_variable_list; 137 OutputVariableList output_variable_list;
142 NameMap name_map;
143 EXPECT_FALSE(vertex_translator_->Translate( 138 EXPECT_FALSE(vertex_translator_->Translate(
144 bad_shader, &info_log, &translated_source, &shader_version, &attrib_map, 139 bad_shader, &info_log, &translated_source, &shader_version, &attrib_map,
145 &uniform_map, &varying_map, &interface_block_map, &output_variable_list, 140 &uniform_map, &varying_map, &interface_block_map, &output_variable_list));
146 &name_map));
147 // Info log must be valid and non-empty. 141 // Info log must be valid and non-empty.
148 ASSERT_FALSE(info_log.empty()); 142 ASSERT_FALSE(info_log.empty());
149 // Translated shader must be NULL. 143 // Translated shader must be NULL.
150 EXPECT_TRUE(translated_source.empty()); 144 EXPECT_TRUE(translated_source.empty());
151 // There should be no attributes, uniforms, varyings, interface block or 145 // There should be no attributes, uniforms, varyings, interface block or
152 // name mapping. 146 // name mapping.
153 EXPECT_TRUE(attrib_map.empty()); 147 EXPECT_TRUE(attrib_map.empty());
154 EXPECT_TRUE(uniform_map.empty()); 148 EXPECT_TRUE(uniform_map.empty());
155 EXPECT_TRUE(varying_map.empty()); 149 EXPECT_TRUE(varying_map.empty());
156 EXPECT_TRUE(interface_block_map.empty()); 150 EXPECT_TRUE(interface_block_map.empty());
157 EXPECT_TRUE(output_variable_list.empty()); 151 EXPECT_TRUE(output_variable_list.empty());
158 EXPECT_TRUE(name_map.empty());
159 152
160 // Try a good shader after bad. 153 // Try a good shader after bad.
161 info_log.clear(); 154 info_log.clear();
162 EXPECT_TRUE(vertex_translator_->Translate( 155 EXPECT_TRUE(vertex_translator_->Translate(
163 good_shader, &info_log, &translated_source, &shader_version, &attrib_map, 156 good_shader, &info_log, &translated_source, &shader_version, &attrib_map,
164 &uniform_map, &varying_map, &interface_block_map, &output_variable_list, 157 &uniform_map, &varying_map, &interface_block_map, &output_variable_list));
165 &name_map));
166 EXPECT_TRUE(info_log.empty()); 158 EXPECT_TRUE(info_log.empty());
167 EXPECT_FALSE(translated_source.empty()); 159 EXPECT_FALSE(translated_source.empty());
168 EXPECT_TRUE(interface_block_map.empty()); 160 EXPECT_TRUE(interface_block_map.empty());
169 } 161 }
170 162
171 TEST_F(ShaderTranslatorTest, ValidFragmentShader) { 163 TEST_F(ShaderTranslatorTest, ValidFragmentShader) {
172 const char* shader = 164 const char* shader =
173 "void main() {\n" 165 "void main() {\n"
174 " gl_FragColor = vec4(1.0);\n" 166 " gl_FragColor = vec4(1.0);\n"
175 "}"; 167 "}";
176 168
177 // A valid shader should be successfully translated. 169 // A valid shader should be successfully translated.
178 std::string info_log, translated_source; 170 std::string info_log, translated_source;
179 int shader_version; 171 int shader_version;
180 AttributeMap attrib_map; 172 AttributeMap attrib_map;
181 UniformMap uniform_map; 173 UniformMap uniform_map;
182 VaryingMap varying_map; 174 VaryingMap varying_map;
183 InterfaceBlockMap interface_block_map; 175 InterfaceBlockMap interface_block_map;
184 OutputVariableList output_variable_list; 176 OutputVariableList output_variable_list;
185 NameMap name_map;
186 EXPECT_TRUE(fragment_translator_->Translate( 177 EXPECT_TRUE(fragment_translator_->Translate(
187 shader, &info_log, &translated_source, &shader_version, &attrib_map, 178 shader, &info_log, &translated_source, &shader_version, &attrib_map,
188 &uniform_map, &varying_map, &interface_block_map, &output_variable_list, 179 &uniform_map, &varying_map, &interface_block_map, &output_variable_list));
189 &name_map));
190 // Info log must be NULL. 180 // Info log must be NULL.
191 EXPECT_TRUE(info_log.empty()); 181 EXPECT_TRUE(info_log.empty());
192 // Translated shader must be valid and non-empty. 182 // Translated shader must be valid and non-empty.
193 ASSERT_FALSE(translated_source.empty()); 183 ASSERT_FALSE(translated_source.empty());
194 // There should be no attributes, uniforms, varyings, interface block or 184 // There should be no attributes, uniforms, varyings, interface block or
195 // name mapping. 185 // name mapping.
196 EXPECT_TRUE(attrib_map.empty()); 186 EXPECT_TRUE(attrib_map.empty());
197 EXPECT_TRUE(uniform_map.empty()); 187 EXPECT_TRUE(uniform_map.empty());
198 EXPECT_TRUE(varying_map.empty()); 188 EXPECT_TRUE(varying_map.empty());
199 EXPECT_TRUE(interface_block_map.empty()); 189 EXPECT_TRUE(interface_block_map.empty());
200 EXPECT_TRUE(name_map.empty());
201 // gl_FragColor. 190 // gl_FragColor.
202 EXPECT_EQ(1u, output_variable_list.size()); 191 EXPECT_EQ(1u, output_variable_list.size());
203 } 192 }
204 193
205 TEST_F(ShaderTranslatorTest, InvalidFragmentShader) { 194 TEST_F(ShaderTranslatorTest, InvalidFragmentShader) {
206 const char* shader = "foo-bar"; 195 const char* shader = "foo-bar";
207 196
208 std::string info_log, translated_source; 197 std::string info_log, translated_source;
209 int shader_version; 198 int shader_version;
210 AttributeMap attrib_map; 199 AttributeMap attrib_map;
211 UniformMap uniform_map; 200 UniformMap uniform_map;
212 VaryingMap varying_map; 201 VaryingMap varying_map;
213 InterfaceBlockMap interface_block_map; 202 InterfaceBlockMap interface_block_map;
214 OutputVariableList output_variable_list; 203 OutputVariableList output_variable_list;
215 NameMap name_map;
216 // An invalid shader should fail. 204 // An invalid shader should fail.
217 EXPECT_FALSE(fragment_translator_->Translate( 205 EXPECT_FALSE(fragment_translator_->Translate(
218 shader, &info_log, &translated_source, &shader_version, &attrib_map, 206 shader, &info_log, &translated_source, &shader_version, &attrib_map,
219 &uniform_map, &varying_map, &interface_block_map, &output_variable_list, 207 &uniform_map, &varying_map, &interface_block_map, &output_variable_list));
220 &name_map));
221 // Info log must be valid and non-empty. 208 // Info log must be valid and non-empty.
222 EXPECT_FALSE(info_log.empty()); 209 EXPECT_FALSE(info_log.empty());
223 // Translated shader must be NULL. 210 // Translated shader must be NULL.
224 EXPECT_TRUE(translated_source.empty()); 211 EXPECT_TRUE(translated_source.empty());
225 // There should be no attributes, uniforms, varyings, interface block or 212 // There should be no attributes, uniforms, varyings, interface block or
226 // name mapping. 213 // name mapping.
227 EXPECT_TRUE(attrib_map.empty()); 214 EXPECT_TRUE(attrib_map.empty());
228 EXPECT_TRUE(uniform_map.empty()); 215 EXPECT_TRUE(uniform_map.empty());
229 EXPECT_TRUE(varying_map.empty()); 216 EXPECT_TRUE(varying_map.empty());
230 EXPECT_TRUE(output_variable_list.empty()); 217 EXPECT_TRUE(output_variable_list.empty());
231 EXPECT_TRUE(name_map.empty());
232 } 218 }
233 219
234 TEST_F(ShaderTranslatorTest, GetAttributes) { 220 TEST_F(ShaderTranslatorTest, GetAttributes) {
235 const char* shader = 221 const char* shader =
236 "attribute vec4 vPosition;\n" 222 "attribute vec4 vPosition;\n"
237 "void main() {\n" 223 "void main() {\n"
238 " gl_Position = vPosition;\n" 224 " gl_Position = vPosition;\n"
239 "}"; 225 "}";
240 226
241 std::string info_log, translated_source; 227 std::string info_log, translated_source;
242 int shader_version; 228 int shader_version;
243 AttributeMap attrib_map; 229 AttributeMap attrib_map;
244 UniformMap uniform_map; 230 UniformMap uniform_map;
245 VaryingMap varying_map; 231 VaryingMap varying_map;
246 InterfaceBlockMap interface_block_map; 232 InterfaceBlockMap interface_block_map;
247 OutputVariableList output_variable_list; 233 OutputVariableList output_variable_list;
248 NameMap name_map;
249 EXPECT_TRUE(vertex_translator_->Translate( 234 EXPECT_TRUE(vertex_translator_->Translate(
250 shader, &info_log, &translated_source, &shader_version, &attrib_map, 235 shader, &info_log, &translated_source, &shader_version, &attrib_map,
251 &uniform_map, &varying_map, &interface_block_map, &output_variable_list, 236 &uniform_map, &varying_map, &interface_block_map, &output_variable_list));
252 &name_map));
253 // Info log must be NULL. 237 // Info log must be NULL.
254 EXPECT_TRUE(info_log.empty()); 238 EXPECT_TRUE(info_log.empty());
255 // Translated shader must be valid and non-empty. 239 // Translated shader must be valid and non-empty.
256 EXPECT_FALSE(translated_source.empty()); 240 EXPECT_FALSE(translated_source.empty());
257 // There should be no uniforms. 241 // There should be no uniforms.
258 EXPECT_TRUE(uniform_map.empty()); 242 EXPECT_TRUE(uniform_map.empty());
259 // There should be no interface blocks. 243 // There should be no interface blocks.
260 EXPECT_TRUE(interface_block_map.empty()); 244 EXPECT_TRUE(interface_block_map.empty());
261 // There should be one attribute with following characteristics: 245 // There should be one attribute with following characteristics:
262 // name:vPosition type:GL_FLOAT_VEC4 size:0. 246 // name:vPosition type:GL_FLOAT_VEC4 size:0.
(...skipping 19 matching lines...) Expand all
282 " gl_FragColor = bar[0].foo.color[0] + bar[1].foo.color[0];\n" 266 " gl_FragColor = bar[0].foo.color[0] + bar[1].foo.color[0];\n"
283 "}"; 267 "}";
284 268
285 std::string info_log, translated_source; 269 std::string info_log, translated_source;
286 int shader_version; 270 int shader_version;
287 AttributeMap attrib_map; 271 AttributeMap attrib_map;
288 UniformMap uniform_map; 272 UniformMap uniform_map;
289 VaryingMap varying_map; 273 VaryingMap varying_map;
290 InterfaceBlockMap interface_block_map; 274 InterfaceBlockMap interface_block_map;
291 OutputVariableList output_variable_list; 275 OutputVariableList output_variable_list;
292 NameMap name_map;
293 EXPECT_TRUE(fragment_translator_->Translate( 276 EXPECT_TRUE(fragment_translator_->Translate(
294 shader, &info_log, &translated_source, &shader_version, &attrib_map, 277 shader, &info_log, &translated_source, &shader_version, &attrib_map,
295 &uniform_map, &varying_map, &interface_block_map, &output_variable_list, 278 &uniform_map, &varying_map, &interface_block_map, &output_variable_list));
296 &name_map));
297 // Info log must be NULL. 279 // Info log must be NULL.
298 EXPECT_TRUE(info_log.empty()); 280 EXPECT_TRUE(info_log.empty());
299 // Translated shader must be valid and non-empty. 281 // Translated shader must be valid and non-empty.
300 EXPECT_FALSE(translated_source.empty()); 282 EXPECT_FALSE(translated_source.empty());
301 // There should be no attributes. 283 // There should be no attributes.
302 EXPECT_TRUE(attrib_map.empty()); 284 EXPECT_TRUE(attrib_map.empty());
303 // There should be no interface blocks. 285 // There should be no interface blocks.
304 EXPECT_TRUE(interface_block_map.empty()); 286 EXPECT_TRUE(interface_block_map.empty());
305 // There should be two uniforms with following characteristics: 287 // There should be two uniforms with following characteristics:
306 // 1. name:bar[0].foo.color[0] type:GL_FLOAT_VEC4 size:1 288 // 1. name:bar[0].foo.color[0] type:GL_FLOAT_VEC4 size:1
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 " oColor = vec4(red * R, green * green, blue * B, 1.0);\n" 332 " oColor = vec4(red * R, green * green, blue * B, 1.0);\n"
351 "}"; 333 "}";
352 334
353 std::string info_log, translated_source; 335 std::string info_log, translated_source;
354 int shader_version; 336 int shader_version;
355 AttributeMap attrib_map; 337 AttributeMap attrib_map;
356 UniformMap uniform_map; 338 UniformMap uniform_map;
357 VaryingMap varying_map; 339 VaryingMap varying_map;
358 InterfaceBlockMap interface_block_map; 340 InterfaceBlockMap interface_block_map;
359 OutputVariableList output_variable_list; 341 OutputVariableList output_variable_list;
360 NameMap name_map;
361 EXPECT_FALSE(fragment_translator_->Translate( 342 EXPECT_FALSE(fragment_translator_->Translate(
362 shader, &info_log, &translated_source, &shader_version, &attrib_map, 343 shader, &info_log, &translated_source, &shader_version, &attrib_map,
363 &uniform_map, &varying_map, &interface_block_map, &output_variable_list, 344 &uniform_map, &varying_map, &interface_block_map, &output_variable_list));
364 &name_map));
365 // Info log must be valid and non-empty. 345 // Info log must be valid and non-empty.
366 ASSERT_FALSE(info_log.empty()); 346 ASSERT_FALSE(info_log.empty());
367 // Translated shader must be NULL. 347 // Translated shader must be NULL.
368 EXPECT_TRUE(translated_source.empty()); 348 EXPECT_TRUE(translated_source.empty());
369 // There should be no attributes, uniforms, varyings, interface block or 349 // There should be no attributes, uniforms, varyings, interface block or
370 // name mapping. 350 // name mapping.
371 EXPECT_TRUE(attrib_map.empty()); 351 EXPECT_TRUE(attrib_map.empty());
372 EXPECT_TRUE(uniform_map.empty()); 352 EXPECT_TRUE(uniform_map.empty());
373 EXPECT_TRUE(varying_map.empty()); 353 EXPECT_TRUE(varying_map.empty());
374 EXPECT_TRUE(interface_block_map.empty()); 354 EXPECT_TRUE(interface_block_map.empty());
375 EXPECT_TRUE(name_map.empty());
376 } 355 }
377 356
378 TEST_F(ES3ShaderTranslatorTest, GetInterfaceBlocks) { 357 TEST_F(ES3ShaderTranslatorTest, GetInterfaceBlocks) {
379 const char* shader = 358 const char* shader =
380 "#version 300 es\n" 359 "#version 300 es\n"
381 "precision mediump float;\n" 360 "precision mediump float;\n"
382 "layout(location=0) out vec4 oColor;\n" 361 "layout(location=0) out vec4 oColor;\n"
383 "uniform Color {\n" 362 "uniform Color {\n"
384 " float red;\n" 363 " float red;\n"
385 " float green;\n" 364 " float green;\n"
386 " float blue;\n" 365 " float blue;\n"
387 "};\n" 366 "};\n"
388 "void main() {\n" 367 "void main() {\n"
389 " oColor = vec4(red, green, blue, 1.0);\n" 368 " oColor = vec4(red, green, blue, 1.0);\n"
390 "}"; 369 "}";
391 370
392 std::string info_log, translated_source; 371 std::string info_log, translated_source;
393 int shader_version; 372 int shader_version;
394 AttributeMap attrib_map; 373 AttributeMap attrib_map;
395 UniformMap uniform_map; 374 UniformMap uniform_map;
396 VaryingMap varying_map; 375 VaryingMap varying_map;
397 InterfaceBlockMap interface_block_map; 376 InterfaceBlockMap interface_block_map;
398 OutputVariableList output_variable_list; 377 OutputVariableList output_variable_list;
399 NameMap name_map;
400 EXPECT_TRUE(fragment_translator_->Translate( 378 EXPECT_TRUE(fragment_translator_->Translate(
401 shader, &info_log, &translated_source, &shader_version, &attrib_map, 379 shader, &info_log, &translated_source, &shader_version, &attrib_map,
402 &uniform_map, &varying_map, &interface_block_map, &output_variable_list, 380 &uniform_map, &varying_map, &interface_block_map, &output_variable_list));
403 &name_map));
404 // Info log must be NULL. 381 // Info log must be NULL.
405 EXPECT_TRUE(info_log.empty()); 382 EXPECT_TRUE(info_log.empty());
406 // Translated shader must be valid and non-empty. 383 // Translated shader must be valid and non-empty.
407 EXPECT_FALSE(translated_source.empty()); 384 EXPECT_FALSE(translated_source.empty());
408 // There should be no attributes. 385 // There should be no attributes.
409 EXPECT_TRUE(attrib_map.empty()); 386 EXPECT_TRUE(attrib_map.empty());
410 // There should be one block in interface_block_map 387 // There should be one block in interface_block_map
411 EXPECT_EQ(1u, interface_block_map.size()); 388 EXPECT_EQ(1u, interface_block_map.size());
412 InterfaceBlockMap::const_iterator iter; 389 InterfaceBlockMap::const_iterator iter;
413 for (iter = interface_block_map.begin(); 390 for (iter = interface_block_map.begin();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 std::string translated_source; 458 std::string translated_source;
482 int shader_version; 459 int shader_version;
483 { 460 {
484 const char* kShader = 461 const char* kShader =
485 "attribute vec4 vPosition;\n" 462 "attribute vec4 vPosition;\n"
486 "void main() {\n" 463 "void main() {\n"
487 "}"; 464 "}";
488 465
489 EXPECT_TRUE(vertex_translator->Translate( 466 EXPECT_TRUE(vertex_translator->Translate(
490 kShader, nullptr, &translated_source, &shader_version, nullptr, nullptr, 467 kShader, nullptr, &translated_source, &shader_version, nullptr, nullptr,
491 nullptr, nullptr, nullptr, nullptr)); 468 nullptr, nullptr, nullptr));
492 EXPECT_TRUE(translated_source.find("#version") == std::string::npos); 469 EXPECT_TRUE(translated_source.find("#version") == std::string::npos);
493 if (translated_source.find("gl_Position =") == std::string::npos) { 470 if (translated_source.find("gl_Position =") == std::string::npos) {
494 ADD_FAILURE() << "Did not find gl_Position initialization."; 471 ADD_FAILURE() << "Did not find gl_Position initialization.";
495 LOG(ERROR) << "Generated output:\n" << translated_source; 472 LOG(ERROR) << "Generated output:\n" << translated_source;
496 } 473 }
497 } 474 }
498 { 475 {
499 const char* kShader = 476 const char* kShader =
500 "#pragma STDGL invariant(all)\n" 477 "#pragma STDGL invariant(all)\n"
501 "precision mediump float;\n" 478 "precision mediump float;\n"
502 "varying vec4 v_varying;\n" 479 "varying vec4 v_varying;\n"
503 "void main() {\n" 480 "void main() {\n"
504 " gl_FragColor = v_varying;\n" 481 " gl_FragColor = v_varying;\n"
505 "}\n"; 482 "}\n";
506 483
507 EXPECT_TRUE(fragment_translator->Translate( 484 EXPECT_TRUE(fragment_translator->Translate(
508 kShader, nullptr, &translated_source, &shader_version, nullptr, nullptr, 485 kShader, nullptr, &translated_source, &shader_version, nullptr, nullptr,
509 nullptr, nullptr, nullptr, nullptr)); 486 nullptr, nullptr, nullptr));
510 EXPECT_TRUE(translated_source.find("#version 120") != std::string::npos); 487 EXPECT_TRUE(translated_source.find("#version 120") != std::string::npos);
511 if (translated_source.find("#pragma STDGL invariant(all)") != 488 if (translated_source.find("#pragma STDGL invariant(all)") !=
512 std::string::npos) { 489 std::string::npos) {
513 ADD_FAILURE() << "Found forbidden pragma."; 490 ADD_FAILURE() << "Found forbidden pragma.";
514 LOG(ERROR) << "Generated output:\n" << translated_source; 491 LOG(ERROR) << "Generated output:\n" << translated_source;
515 } 492 }
516 } 493 }
517 } 494 }
518 495
519 TEST_P(ShaderTranslatorOutputVersionTest, HasCorrectOutputGLSLVersion) { 496 TEST_P(ShaderTranslatorOutputVersionTest, HasCorrectOutputGLSLVersion) {
(...skipping 17 matching lines...) Expand all
537 ShShaderOutput shader_output_language = 514 ShShaderOutput shader_output_language =
538 ShaderTranslator::GetShaderOutputLanguageForContext( 515 ShaderTranslator::GetShaderOutputLanguageForContext(
539 output_context_version); 516 output_context_version);
540 ASSERT_TRUE(translator->Init(GL_VERTEX_SHADER, SH_GLES2_SPEC, &resources, 517 ASSERT_TRUE(translator->Init(GL_VERTEX_SHADER, SH_GLES2_SPEC, &resources,
541 shader_output_language, compile_options, false)); 518 shader_output_language, compile_options, false));
542 519
543 std::string translated_source; 520 std::string translated_source;
544 int shader_version; 521 int shader_version;
545 EXPECT_TRUE(translator->Translate(kShader, nullptr, &translated_source, 522 EXPECT_TRUE(translator->Translate(kShader, nullptr, &translated_source,
546 &shader_version, nullptr, nullptr, nullptr, 523 &shader_version, nullptr, nullptr, nullptr,
547 nullptr, nullptr, nullptr)); 524 nullptr, nullptr));
548 525
549 std::string expected_version_directive = testing::get<1>(GetParam()); 526 std::string expected_version_directive = testing::get<1>(GetParam());
550 if (expected_version_directive.empty()) { 527 if (expected_version_directive.empty()) {
551 EXPECT_TRUE(translated_source.find("#version") == std::string::npos) 528 EXPECT_TRUE(translated_source.find("#version") == std::string::npos)
552 << "Translation was:\n" << translated_source; 529 << "Translation was:\n" << translated_source;
553 } else { 530 } else {
554 EXPECT_TRUE(translated_source.find(expected_version_directive) != 531 EXPECT_TRUE(translated_source.find(expected_version_directive) !=
555 std::string::npos) 532 std::string::npos)
556 << "Translation was:\n" << translated_source; 533 << "Translation was:\n" << translated_source;
557 } 534 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 INSTANTIATE_TEST_CASE_P(OpenGLESContexts, 590 INSTANTIATE_TEST_CASE_P(OpenGLESContexts,
614 ShaderTranslatorOutputVersionTest, 591 ShaderTranslatorOutputVersionTest,
615 testing::Values(make_gl_glsl_tuple("opengl es 2.0", ""), 592 testing::Values(make_gl_glsl_tuple("opengl es 2.0", ""),
616 make_gl_glsl_tuple("opengl es 3.0", ""), 593 make_gl_glsl_tuple("opengl es 3.0", ""),
617 make_gl_glsl_tuple("opengl es 3.1", ""), 594 make_gl_glsl_tuple("opengl es 3.1", ""),
618 make_gl_glsl_tuple("opengl es 3.2", 595 make_gl_glsl_tuple("opengl es 3.2",
619 ""))); 596 "")));
620 597
621 } // namespace gles2 598 } // namespace gles2
622 } // namespace gpu 599 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/shader_translator.cc ('k') | gpu/command_buffer/service/test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698