| 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 20 matching lines...) Expand all Loading... |
| 31 #include "gpu/command_buffer/service/buffer_manager.h" | 31 #include "gpu/command_buffer/service/buffer_manager.h" |
| 32 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 32 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
| 33 #include "gpu/command_buffer/service/context_group.h" | 33 #include "gpu/command_buffer/service/context_group.h" |
| 34 #include "gpu/command_buffer/service/feature_info.h" | 34 #include "gpu/command_buffer/service/feature_info.h" |
| 35 #include "gpu/command_buffer/service/framebuffer_manager.h" | 35 #include "gpu/command_buffer/service/framebuffer_manager.h" |
| 36 #include "gpu/command_buffer/service/gl_utils.h" | 36 #include "gpu/command_buffer/service/gl_utils.h" |
| 37 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 37 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
| 38 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 38 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
| 39 #include "gpu/command_buffer/service/gpu_switches.h" | 39 #include "gpu/command_buffer/service/gpu_switches.h" |
| 40 #include "gpu/command_buffer/service/mailbox_manager.h" | 40 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 41 #include "gpu/command_buffer/service/program_cache.h" |
| 41 #include "gpu/command_buffer/service/program_manager.h" | 42 #include "gpu/command_buffer/service/program_manager.h" |
| 42 #include "gpu/command_buffer/service/query_manager.h" | 43 #include "gpu/command_buffer/service/query_manager.h" |
| 43 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 44 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
| 44 #include "gpu/command_buffer/service/shader_manager.h" | 45 #include "gpu/command_buffer/service/shader_manager.h" |
| 45 #include "gpu/command_buffer/service/shader_translator.h" | 46 #include "gpu/command_buffer/service/shader_translator.h" |
| 46 #include "gpu/command_buffer/service/shader_translator_cache.h" | 47 #include "gpu/command_buffer/service/shader_translator_cache.h" |
| 47 #include "gpu/command_buffer/service/stream_texture.h" | 48 #include "gpu/command_buffer/service/stream_texture.h" |
| 48 #include "gpu/command_buffer/service/stream_texture_manager.h" | 49 #include "gpu/command_buffer/service/stream_texture_manager.h" |
| 49 #include "gpu/command_buffer/service/texture_definition.h" | 50 #include "gpu/command_buffer/service/texture_definition.h" |
| 50 #include "gpu/command_buffer/service/texture_manager.h" | 51 #include "gpu/command_buffer/service/texture_manager.h" |
| (...skipping 4659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4710 } | 4711 } |
| 4711 | 4712 |
| 4712 void GLES2DecoderImpl::DoLinkProgram(GLuint program) { | 4713 void GLES2DecoderImpl::DoLinkProgram(GLuint program) { |
| 4713 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoLinkProgram"); | 4714 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoLinkProgram"); |
| 4714 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( | 4715 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( |
| 4715 program, "glLinkProgram"); | 4716 program, "glLinkProgram"); |
| 4716 if (!info) { | 4717 if (!info) { |
| 4717 return; | 4718 return; |
| 4718 } | 4719 } |
| 4719 | 4720 |
| 4720 if (info->Link()) { | 4721 ShaderTranslator* vertex_translator = NULL; |
| 4722 ShaderTranslator* fragment_translator = NULL; |
| 4723 if (use_shader_translator_) { |
| 4724 vertex_translator = vertex_translator_; |
| 4725 fragment_translator = fragment_translator_; |
| 4726 } |
| 4727 if (info->Link(shader_manager(), |
| 4728 vertex_translator, |
| 4729 fragment_translator, |
| 4730 feature_info_)) { |
| 4721 if (info == current_program_.get()) { | 4731 if (info == current_program_.get()) { |
| 4722 program_manager()->ClearUniforms(info); | 4732 program_manager()->ClearUniforms(info); |
| 4723 } | 4733 } |
| 4724 } | 4734 } |
| 4725 }; | 4735 }; |
| 4726 | 4736 |
| 4727 void GLES2DecoderImpl::DoTexParameterf( | 4737 void GLES2DecoderImpl::DoTexParameterf( |
| 4728 GLenum target, GLenum pname, GLfloat param) { | 4738 GLenum target, GLenum pname, GLfloat param) { |
| 4729 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); | 4739 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
| 4730 if (!info) { | 4740 if (!info) { |
| (...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5797 bucket->size() - 1); | 5807 bucket->size() - 1); |
| 5798 } | 5808 } |
| 5799 | 5809 |
| 5800 void GLES2DecoderImpl::DoCompileShader(GLuint client_id) { | 5810 void GLES2DecoderImpl::DoCompileShader(GLuint client_id) { |
| 5801 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompileShader"); | 5811 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompileShader"); |
| 5802 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( | 5812 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( |
| 5803 client_id, "glCompileShader"); | 5813 client_id, "glCompileShader"); |
| 5804 if (!info) { | 5814 if (!info) { |
| 5805 return; | 5815 return; |
| 5806 } | 5816 } |
| 5807 // Translate GL ES 2.0 shader to Desktop GL shader and pass that to | |
| 5808 // glShaderSource and then glCompileShader. | |
| 5809 const char* shader_src = info->source() ? info->source()->c_str() : ""; | |
| 5810 ShaderTranslator* translator = NULL; | 5817 ShaderTranslator* translator = NULL; |
| 5811 if (use_shader_translator_) { | 5818 if (use_shader_translator_) { |
| 5812 translator = info->shader_type() == GL_VERTEX_SHADER ? | 5819 translator = info->shader_type() == GL_VERTEX_SHADER ? |
| 5813 vertex_translator_.get() : fragment_translator_.get(); | 5820 vertex_translator_.get() : fragment_translator_.get(); |
| 5814 | |
| 5815 if (!translator->Translate(shader_src)) { | |
| 5816 info->SetStatus(false, translator->info_log(), NULL); | |
| 5817 return; | |
| 5818 } | |
| 5819 shader_src = translator->translated_shader(); | |
| 5820 if (!feature_info_->feature_flags().angle_translated_shader_source) | |
| 5821 info->UpdateTranslatedSource(shader_src); | |
| 5822 } | 5821 } |
| 5823 | 5822 |
| 5824 glShaderSource(info->service_id(), 1, &shader_src, NULL); | 5823 program_manager()->DoCompileShader(info, translator, feature_info_); |
| 5825 glCompileShader(info->service_id()); | |
| 5826 if (feature_info_->feature_flags().angle_translated_shader_source) { | |
| 5827 GLint max_len = 0; | |
| 5828 glGetShaderiv(info->service_id(), | |
| 5829 GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, | |
| 5830 &max_len); | |
| 5831 scoped_array<char> temp(new char[max_len]); | |
| 5832 GLint len = 0; | |
| 5833 glGetTranslatedShaderSourceANGLE( | |
| 5834 info->service_id(), max_len, &len, temp.get()); | |
| 5835 DCHECK(max_len == 0 || len < max_len); | |
| 5836 DCHECK(len == 0 || temp[len] == '\0'); | |
| 5837 info->UpdateTranslatedSource(temp.get()); | |
| 5838 } | |
| 5839 | |
| 5840 GLint status = GL_FALSE; | |
| 5841 glGetShaderiv(info->service_id(), GL_COMPILE_STATUS, &status); | |
| 5842 if (status) { | |
| 5843 info->SetStatus(true, "", translator); | |
| 5844 } else { | |
| 5845 // We cannot reach here if we are using the shader translator. | |
| 5846 // All invalid shaders must be rejected by the translator. | |
| 5847 // All translated shaders must compile. | |
| 5848 LOG_IF(ERROR, use_shader_translator_) | |
| 5849 << "Shader translator allowed/produced an invalid shader."; | |
| 5850 GLint max_len = 0; | |
| 5851 glGetShaderiv(info->service_id(), GL_INFO_LOG_LENGTH, &max_len); | |
| 5852 scoped_array<char> temp(new char[max_len]); | |
| 5853 GLint len = 0; | |
| 5854 glGetShaderInfoLog(info->service_id(), max_len, &len, temp.get()); | |
| 5855 DCHECK(max_len == 0 || len < max_len); | |
| 5856 DCHECK(len == 0 || temp[len] == '\0'); | |
| 5857 info->SetStatus(false, std::string(temp.get(), len).c_str(), NULL); | |
| 5858 } | |
| 5859 }; | 5824 }; |
| 5860 | 5825 |
| 5861 void GLES2DecoderImpl::DoGetShaderiv( | 5826 void GLES2DecoderImpl::DoGetShaderiv( |
| 5862 GLuint shader, GLenum pname, GLint* params) { | 5827 GLuint shader, GLenum pname, GLint* params) { |
| 5863 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( | 5828 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( |
| 5864 shader, "glGetShaderiv"); | 5829 shader, "glGetShaderiv"); |
| 5865 if (!info) { | 5830 if (!info) { |
| 5866 return; | 5831 return; |
| 5867 } | 5832 } |
| 5868 switch (pname) { | 5833 switch (pname) { |
| (...skipping 3320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9189 BindAndApplyTextureParameters(info); | 9154 BindAndApplyTextureParameters(info); |
| 9190 } | 9155 } |
| 9191 | 9156 |
| 9192 // Include the auto-generated part of this file. We split this because it means | 9157 // Include the auto-generated part of this file. We split this because it means |
| 9193 // we can easily edit the non-auto generated parts right here in this file | 9158 // we can easily edit the non-auto generated parts right here in this file |
| 9194 // instead of having to edit some template or the code generator. | 9159 // instead of having to edit some template or the code generator. |
| 9195 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9160 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 9196 | 9161 |
| 9197 } // namespace gles2 | 9162 } // namespace gles2 |
| 9198 } // namespace gpu | 9163 } // namespace gpu |
| OLD | NEW |