| 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/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 4596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4607 } | 4607 } |
| 4608 | 4608 |
| 4609 void GLES2DecoderImpl::DoLinkProgram(GLuint program) { | 4609 void GLES2DecoderImpl::DoLinkProgram(GLuint program) { |
| 4610 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoLinkProgram"); | 4610 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoLinkProgram"); |
| 4611 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( | 4611 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( |
| 4612 program, "glLinkProgram"); | 4612 program, "glLinkProgram"); |
| 4613 if (!info) { | 4613 if (!info) { |
| 4614 return; | 4614 return; |
| 4615 } | 4615 } |
| 4616 | 4616 |
| 4617 if (info->Link()) { | 4617 ShaderTranslator* vertex_translator = NULL; |
| 4618 ShaderTranslator* fragment_translator = NULL; |
| 4619 if(use_shader_translator_) { |
| 4620 vertex_translator = vertex_translator_; |
| 4621 fragment_translator = fragment_translator_; |
| 4622 } |
| 4623 if (info->Link(shader_manager(), |
| 4624 vertex_translator, |
| 4625 fragment_translator, |
| 4626 feature_info_)) { |
| 4618 if (info == current_program_.get()) { | 4627 if (info == current_program_.get()) { |
| 4619 program_manager()->ClearUniforms(info); | 4628 program_manager()->ClearUniforms(info); |
| 4620 } | 4629 } |
| 4621 } | 4630 } |
| 4622 }; | 4631 }; |
| 4623 | 4632 |
| 4624 void GLES2DecoderImpl::DoTexParameterf( | 4633 void GLES2DecoderImpl::DoTexParameterf( |
| 4625 GLenum target, GLenum pname, GLfloat param) { | 4634 GLenum target, GLenum pname, GLfloat param) { |
| 4626 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); | 4635 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
| 4627 if (!info) { | 4636 if (!info) { |
| (...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5690 bucket->size() - 1); | 5699 bucket->size() - 1); |
| 5691 } | 5700 } |
| 5692 | 5701 |
| 5693 void GLES2DecoderImpl::DoCompileShader(GLuint client_id) { | 5702 void GLES2DecoderImpl::DoCompileShader(GLuint client_id) { |
| 5694 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompileShader"); | 5703 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompileShader"); |
| 5695 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( | 5704 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( |
| 5696 client_id, "glCompileShader"); | 5705 client_id, "glCompileShader"); |
| 5697 if (!info) { | 5706 if (!info) { |
| 5698 return; | 5707 return; |
| 5699 } | 5708 } |
| 5700 // Translate GL ES 2.0 shader to Desktop GL shader and pass that to | |
| 5701 // glShaderSource and then glCompileShader. | |
| 5702 const char* shader_src = info->source() ? info->source()->c_str() : ""; | |
| 5703 ShaderTranslator* translator = NULL; | 5709 ShaderTranslator* translator = NULL; |
| 5704 if (use_shader_translator_) { | 5710 if (use_shader_translator_) { |
| 5705 translator = info->shader_type() == GL_VERTEX_SHADER ? | 5711 translator = info->shader_type() == GL_VERTEX_SHADER ? |
| 5706 vertex_translator_.get() : fragment_translator_.get(); | 5712 vertex_translator_.get() : fragment_translator_.get(); |
| 5707 | |
| 5708 if (!translator->Translate(shader_src)) { | |
| 5709 info->SetStatus(false, translator->info_log(), NULL); | |
| 5710 return; | |
| 5711 } | |
| 5712 shader_src = translator->translated_shader(); | |
| 5713 if (!feature_info_->feature_flags().angle_translated_shader_source) | |
| 5714 info->UpdateTranslatedSource(shader_src); | |
| 5715 } | 5713 } |
| 5716 | 5714 |
| 5717 glShaderSource(info->service_id(), 1, &shader_src, NULL); | 5715 ProgramManager* manager = program_manager(); |
| 5718 glCompileShader(info->service_id()); | 5716 ProgramCache* cache = manager->program_cache(); |
| 5719 if (feature_info_->feature_flags().angle_translated_shader_source) { | 5717 if (cache && |
| 5720 GLint max_len = 0; | 5718 cache->GetShaderCompilationStatus(*info->source()) |
| 5721 glGetShaderiv(info->service_id(), | 5719 == ProgramCache::COMPILATION_SUCCEEDED) { |
| 5722 GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, | 5720 info->SetStatus(true, "", translator); |
| 5723 &max_len); | 5721 info->SetPendingCompilation(true); |
| 5724 scoped_array<char> temp(new char[max_len]); | 5722 return; |
| 5725 GLint len = 0; | |
| 5726 glGetTranslatedShaderSourceANGLE( | |
| 5727 info->service_id(), max_len, &len, temp.get()); | |
| 5728 DCHECK(max_len == 0 || len < max_len); | |
| 5729 DCHECK(len == 0 || temp[len] == '\0'); | |
| 5730 info->UpdateTranslatedSource(temp.get()); | |
| 5731 } | 5723 } |
| 5732 | 5724 |
| 5733 GLint status = GL_FALSE; | 5725 manager->DoCompileShader(info, translator, feature_info_); |
| 5734 glGetShaderiv(info->service_id(), GL_COMPILE_STATUS, &status); | |
| 5735 if (status) { | |
| 5736 info->SetStatus(true, "", translator); | |
| 5737 } else { | |
| 5738 // We cannot reach here if we are using the shader translator. | |
| 5739 // All invalid shaders must be rejected by the translator. | |
| 5740 // All translated shaders must compile. | |
| 5741 LOG_IF(ERROR, use_shader_translator_) | |
| 5742 << "Shader translator allowed/produced an invalid shader."; | |
| 5743 GLint max_len = 0; | |
| 5744 glGetShaderiv(info->service_id(), GL_INFO_LOG_LENGTH, &max_len); | |
| 5745 scoped_array<char> temp(new char[max_len]); | |
| 5746 GLint len = 0; | |
| 5747 glGetShaderInfoLog(info->service_id(), max_len, &len, temp.get()); | |
| 5748 DCHECK(max_len == 0 || len < max_len); | |
| 5749 DCHECK(len == 0 || temp[len] == '\0'); | |
| 5750 info->SetStatus(false, std::string(temp.get(), len).c_str(), NULL); | |
| 5751 } | |
| 5752 }; | 5726 }; |
| 5753 | 5727 |
| 5754 void GLES2DecoderImpl::DoGetShaderiv( | 5728 void GLES2DecoderImpl::DoGetShaderiv( |
| 5755 GLuint shader, GLenum pname, GLint* params) { | 5729 GLuint shader, GLenum pname, GLint* params) { |
| 5756 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( | 5730 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( |
| 5757 shader, "glGetShaderiv"); | 5731 shader, "glGetShaderiv"); |
| 5758 if (!info) { | 5732 if (!info) { |
| 5759 return; | 5733 return; |
| 5760 } | 5734 } |
| 5761 switch (pname) { | 5735 switch (pname) { |
| (...skipping 3313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9075 BindAndApplyTextureParameters(info); | 9049 BindAndApplyTextureParameters(info); |
| 9076 } | 9050 } |
| 9077 | 9051 |
| 9078 // Include the auto-generated part of this file. We split this because it means | 9052 // Include the auto-generated part of this file. We split this because it means |
| 9079 // we can easily edit the non-auto generated parts right here in this file | 9053 // we can easily edit the non-auto generated parts right here in this file |
| 9080 // instead of having to edit some template or the code generator. | 9054 // instead of having to edit some template or the code generator. |
| 9081 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9055 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 9082 | 9056 |
| 9083 } // namespace gles2 | 9057 } // namespace gles2 |
| 9084 } // namespace gpu | 9058 } // namespace gpu |
| OLD | NEW |