Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "gpu/command_buffer/service/shader_translator.h" | 5 #include "gpu/command_buffer/service/shader_translator.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 } | 120 } |
| 121 | 121 |
| 122 bool ShaderTranslator::Translate(const char* shader) { | 122 bool ShaderTranslator::Translate(const char* shader) { |
| 123 // Make sure this instance is initialized. | 123 // Make sure this instance is initialized. |
| 124 DCHECK(compiler_ != NULL); | 124 DCHECK(compiler_ != NULL); |
| 125 DCHECK(shader != NULL); | 125 DCHECK(shader != NULL); |
| 126 ClearResults(); | 126 ClearResults(); |
| 127 | 127 |
| 128 bool success = false; | 128 bool success = false; |
| 129 int compile_options = | 129 int compile_options = |
| 130 SH_OBJECT_CODE | SH_ATTRIBUTES_UNIFORMS | SH_MAP_LONG_VARIABLE_NAMES; | 130 SH_OBJECT_CODE | SH_ATTRIBUTES_UNIFORMS | |
| 131 SH_MAP_LONG_VARIABLE_NAMES | SH_CLAMP_INDIRECT_ARRAY_BOUNDS; | |
|
greggman
2013/01/12 01:31:37
Do you want | SH_ENFORCE_PACKING_RESTRICTIONS
or n
| |
| 131 if (needs_built_in_function_emulation_) | 132 if (needs_built_in_function_emulation_) |
| 132 compile_options |= SH_EMULATE_BUILT_IN_FUNCTIONS; | 133 compile_options |= SH_EMULATE_BUILT_IN_FUNCTIONS; |
| 133 if (ShCompile(compiler_, &shader, 1, compile_options)) { | 134 if (ShCompile(compiler_, &shader, 1, compile_options)) { |
| 134 success = true; | 135 success = true; |
| 135 // Get translated shader. | 136 // Get translated shader. |
| 136 int obj_code_len = 0; | 137 int obj_code_len = 0; |
| 137 ShGetInfo(compiler_, SH_OBJECT_CODE_LENGTH, &obj_code_len); | 138 ShGetInfo(compiler_, SH_OBJECT_CODE_LENGTH, &obj_code_len); |
| 138 if (obj_code_len > 1) { | 139 if (obj_code_len > 1) { |
| 139 translated_shader_.reset(new char[obj_code_len]); | 140 translated_shader_.reset(new char[obj_code_len]); |
| 140 ShGetObjectCode(compiler_, translated_shader_.get()); | 141 ShGetObjectCode(compiler_, translated_shader_.get()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 void ShaderTranslator::ClearResults() { | 198 void ShaderTranslator::ClearResults() { |
| 198 translated_shader_.reset(); | 199 translated_shader_.reset(); |
| 199 info_log_.reset(); | 200 info_log_.reset(); |
| 200 attrib_map_.clear(); | 201 attrib_map_.clear(); |
| 201 uniform_map_.clear(); | 202 uniform_map_.clear(); |
| 202 } | 203 } |
| 203 | 204 |
| 204 } // namespace gles2 | 205 } // namespace gles2 |
| 205 } // namespace gpu | 206 } // namespace gpu |
| 206 | 207 |
| OLD | NEW |