Index: gpu/command_buffer/service/shader_manager.cc |
diff --git a/gpu/command_buffer/service/shader_manager.cc b/gpu/command_buffer/service/shader_manager.cc |
index 2707b90b92de4105d6b8c9f1dad28a0663158f0e..dabc7b492f68b072aba5a0b56ecbbc27a91d3c12 100644 |
--- a/gpu/command_buffer/service/shader_manager.cc |
+++ b/gpu/command_buffer/service/shader_manager.cc |
@@ -26,6 +26,7 @@ std::string GetTopVariableName(const std::string& fullname) { |
Shader::Shader(GLuint service_id, GLenum shader_type) |
: use_count_(0), |
+ shader_state_(kShaderStateWaiting), |
service_id_(service_id), |
shader_type_(shader_type), |
valid_(false) { |
@@ -34,13 +35,28 @@ Shader::Shader(GLuint service_id, GLenum shader_type) |
Shader::~Shader() { |
} |
+void Shader::RequestCompile() { |
+ shader_state_ = kShaderStateCompileRequested; |
+ last_compiled_source_ = source_; |
+} |
+ |
void Shader::DoCompile(ShaderTranslatorInterface* translator, |
TranslatedShaderSourceType type) { |
+ // We require that RequestCompile() must be called before DoCompile(), |
+ // so we can return early if the shader state is not what we expect. |
+ if (shader_state_ != kShaderStateCompileRequested) { |
+ return; |
Ken Russell (switch to Gerrit)
2015/02/04 22:59:59
The lack of error checking in this new code path s
David Yen
2015/02/05 00:09:02
That functionality will still work, it is handled
|
+ } |
+ |
+ // Signify the shader has been compiled, whether or not it is valid |
+ // is dependent on the |valid_| member variable. |
+ shader_state_ = kShaderStateCompiled; |
+ |
// Translate GL ES 2.0 shader to Desktop GL shader and pass that to |
// glShaderSource and then glCompileShader. |
- const char* source_for_driver = source_.c_str(); |
+ const char* source_for_driver = last_compiled_source_.c_str(); |
if (translator) { |
- valid_ = translator->Translate(source_, |
+ valid_ = translator->Translate(last_compiled_source_, |
&log_info_, |
&translated_source_, |
&attrib_map_, |
@@ -50,7 +66,6 @@ void Shader::DoCompile(ShaderTranslatorInterface* translator, |
if (!valid_) { |
return; |
} |
- signature_source_ = source_; |
source_for_driver = translated_source_.c_str(); |
} |
@@ -88,7 +103,7 @@ void Shader::DoCompile(ShaderTranslatorInterface* translator, |
LOG_IF(ERROR, translator) |
<< "Shader translator allowed/produced an invalid shader " |
<< "unless the driver is buggy:" |
- << "\n--original-shader--\n" << source_ |
+ << "\n--original-shader--\n" << last_compiled_source_ |
<< "\n--translated-shader--\n" << source_for_driver |
<< "\n--info-log--\n" << log_info_; |
} |