| 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 4701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4712 } | 4712 } |
| 4713 | 4713 |
| 4714 void GLES2DecoderImpl::DoLinkProgram(GLuint program) { | 4714 void GLES2DecoderImpl::DoLinkProgram(GLuint program) { |
| 4715 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoLinkProgram"); | 4715 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoLinkProgram"); |
| 4716 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( | 4716 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( |
| 4717 program, "glLinkProgram"); | 4717 program, "glLinkProgram"); |
| 4718 if (!info) { | 4718 if (!info) { |
| 4719 return; | 4719 return; |
| 4720 } | 4720 } |
| 4721 | 4721 |
| 4722 if (info->Link()) { | 4722 ShaderTranslator* vertex_translator = NULL; |
| 4723 ShaderTranslator* fragment_translator = NULL; |
| 4724 if (use_shader_translator_) { |
| 4725 vertex_translator = vertex_translator_; |
| 4726 fragment_translator = fragment_translator_; |
| 4727 } |
| 4728 if (info->Link(shader_manager(), |
| 4729 vertex_translator, |
| 4730 fragment_translator, |
| 4731 feature_info_)) { |
| 4723 if (info == current_program_.get()) { | 4732 if (info == current_program_.get()) { |
| 4724 program_manager()->ClearUniforms(info); | 4733 program_manager()->ClearUniforms(info); |
| 4725 } | 4734 } |
| 4726 } | 4735 } |
| 4727 }; | 4736 }; |
| 4728 | 4737 |
| 4729 void GLES2DecoderImpl::DoTexParameterf( | 4738 void GLES2DecoderImpl::DoTexParameterf( |
| 4730 GLenum target, GLenum pname, GLfloat param) { | 4739 GLenum target, GLenum pname, GLfloat param) { |
| 4731 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); | 4740 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
| 4732 if (!info) { | 4741 if (!info) { |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5805 bucket->size() - 1); | 5814 bucket->size() - 1); |
| 5806 } | 5815 } |
| 5807 | 5816 |
| 5808 void GLES2DecoderImpl::DoCompileShader(GLuint client_id) { | 5817 void GLES2DecoderImpl::DoCompileShader(GLuint client_id) { |
| 5809 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompileShader"); | 5818 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompileShader"); |
| 5810 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( | 5819 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( |
| 5811 client_id, "glCompileShader"); | 5820 client_id, "glCompileShader"); |
| 5812 if (!info) { | 5821 if (!info) { |
| 5813 return; | 5822 return; |
| 5814 } | 5823 } |
| 5815 // Translate GL ES 2.0 shader to Desktop GL shader and pass that to | |
| 5816 // glShaderSource and then glCompileShader. | |
| 5817 const char* shader_src = info->source() ? info->source()->c_str() : ""; | |
| 5818 ShaderTranslator* translator = NULL; | 5824 ShaderTranslator* translator = NULL; |
| 5819 if (use_shader_translator_) { | 5825 if (use_shader_translator_) { |
| 5820 translator = info->shader_type() == GL_VERTEX_SHADER ? | 5826 translator = info->shader_type() == GL_VERTEX_SHADER ? |
| 5821 vertex_translator_.get() : fragment_translator_.get(); | 5827 vertex_translator_.get() : fragment_translator_.get(); |
| 5822 | |
| 5823 if (!translator->Translate(shader_src)) { | |
| 5824 info->SetStatus(false, translator->info_log(), NULL); | |
| 5825 return; | |
| 5826 } | |
| 5827 shader_src = translator->translated_shader(); | |
| 5828 if (!feature_info_->feature_flags().angle_translated_shader_source) | |
| 5829 info->UpdateTranslatedSource(shader_src); | |
| 5830 } | 5828 } |
| 5831 | 5829 |
| 5832 glShaderSource(info->service_id(), 1, &shader_src, NULL); | 5830 program_manager()->DoCompileShader(info, translator, feature_info_); |
| 5833 glCompileShader(info->service_id()); | |
| 5834 if (feature_info_->feature_flags().angle_translated_shader_source) { | |
| 5835 GLint max_len = 0; | |
| 5836 glGetShaderiv(info->service_id(), | |
| 5837 GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, | |
| 5838 &max_len); | |
| 5839 scoped_array<char> temp(new char[max_len]); | |
| 5840 GLint len = 0; | |
| 5841 glGetTranslatedShaderSourceANGLE( | |
| 5842 info->service_id(), max_len, &len, temp.get()); | |
| 5843 DCHECK(max_len == 0 || len < max_len); | |
| 5844 DCHECK(len == 0 || temp[len] == '\0'); | |
| 5845 info->UpdateTranslatedSource(temp.get()); | |
| 5846 } | |
| 5847 | |
| 5848 GLint status = GL_FALSE; | |
| 5849 glGetShaderiv(info->service_id(), GL_COMPILE_STATUS, &status); | |
| 5850 if (status) { | |
| 5851 info->SetStatus(true, "", translator); | |
| 5852 } else { | |
| 5853 // We cannot reach here if we are using the shader translator. | |
| 5854 // All invalid shaders must be rejected by the translator. | |
| 5855 // All translated shaders must compile. | |
| 5856 LOG_IF(ERROR, use_shader_translator_) | |
| 5857 << "Shader translator allowed/produced an invalid shader."; | |
| 5858 GLint max_len = 0; | |
| 5859 glGetShaderiv(info->service_id(), GL_INFO_LOG_LENGTH, &max_len); | |
| 5860 scoped_array<char> temp(new char[max_len]); | |
| 5861 GLint len = 0; | |
| 5862 glGetShaderInfoLog(info->service_id(), max_len, &len, temp.get()); | |
| 5863 DCHECK(max_len == 0 || len < max_len); | |
| 5864 DCHECK(len == 0 || temp[len] == '\0'); | |
| 5865 info->SetStatus(false, std::string(temp.get(), len).c_str(), NULL); | |
| 5866 } | |
| 5867 }; | 5831 }; |
| 5868 | 5832 |
| 5869 void GLES2DecoderImpl::DoGetShaderiv( | 5833 void GLES2DecoderImpl::DoGetShaderiv( |
| 5870 GLuint shader, GLenum pname, GLint* params) { | 5834 GLuint shader, GLenum pname, GLint* params) { |
| 5871 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( | 5835 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( |
| 5872 shader, "glGetShaderiv"); | 5836 shader, "glGetShaderiv"); |
| 5873 if (!info) { | 5837 if (!info) { |
| 5874 return; | 5838 return; |
| 5875 } | 5839 } |
| 5876 switch (pname) { | 5840 switch (pname) { |
| (...skipping 3315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9192 BindAndApplyTextureParameters(info); | 9156 BindAndApplyTextureParameters(info); |
| 9193 } | 9157 } |
| 9194 | 9158 |
| 9195 // Include the auto-generated part of this file. We split this because it means | 9159 // Include the auto-generated part of this file. We split this because it means |
| 9196 // we can easily edit the non-auto generated parts right here in this file | 9160 // we can easily edit the non-auto generated parts right here in this file |
| 9197 // instead of having to edit some template or the code generator. | 9161 // instead of having to edit some template or the code generator. |
| 9198 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9162 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 9199 | 9163 |
| 9200 } // namespace gles2 | 9164 } // namespace gles2 |
| 9201 } // namespace gpu | 9165 } // namespace gpu |
| OLD | NEW |