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/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 4537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4548 } | 4548 } |
| 4549 | 4549 |
| 4550 void GLES2DecoderImpl::DoLinkProgram(GLuint program) { | 4550 void GLES2DecoderImpl::DoLinkProgram(GLuint program) { |
| 4551 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoLinkProgram"); | 4551 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoLinkProgram"); |
| 4552 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( | 4552 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( |
| 4553 program, "glLinkProgram"); | 4553 program, "glLinkProgram"); |
| 4554 if (!info) { | 4554 if (!info) { |
| 4555 return; | 4555 return; |
| 4556 } | 4556 } |
| 4557 | 4557 |
| 4558 if (info->Link()) { | 4558 ShaderTranslator* vertex_translator = NULL; |
| 4559 ShaderTranslator* fragment_translator = NULL; | |
| 4560 if(use_shader_translator_) { | |
| 4561 vertex_translator = vertex_translator_; | |
| 4562 fragment_translator = fragment_translator_; | |
| 4563 } | |
| 4564 if (info->Link(shader_manager(), | |
| 4565 vertex_translator, | |
| 4566 fragment_translator, | |
| 4567 feature_info_)) { | |
| 4559 if (info == current_program_.get()) { | 4568 if (info == current_program_.get()) { |
| 4560 program_manager()->ClearUniforms(info); | 4569 program_manager()->ClearUniforms(info); |
| 4561 } | 4570 } |
| 4562 } | 4571 } |
| 4563 }; | 4572 }; |
| 4564 | 4573 |
| 4565 void GLES2DecoderImpl::DoTexParameterf( | 4574 void GLES2DecoderImpl::DoTexParameterf( |
| 4566 GLenum target, GLenum pname, GLfloat param) { | 4575 GLenum target, GLenum pname, GLfloat param) { |
| 4567 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); | 4576 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
| 4568 if (!info) { | 4577 if (!info) { |
| (...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5631 bucket->size() - 1); | 5640 bucket->size() - 1); |
| 5632 } | 5641 } |
| 5633 | 5642 |
| 5634 void GLES2DecoderImpl::DoCompileShader(GLuint client_id) { | 5643 void GLES2DecoderImpl::DoCompileShader(GLuint client_id) { |
| 5635 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompileShader"); | 5644 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompileShader"); |
| 5636 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( | 5645 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( |
| 5637 client_id, "glCompileShader"); | 5646 client_id, "glCompileShader"); |
| 5638 if (!info) { | 5647 if (!info) { |
| 5639 return; | 5648 return; |
| 5640 } | 5649 } |
| 5641 // Translate GL ES 2.0 shader to Desktop GL shader and pass that to | |
| 5642 // glShaderSource and then glCompileShader. | |
| 5643 const char* shader_src = info->source() ? info->source()->c_str() : ""; | |
| 5644 ShaderTranslator* translator = NULL; | 5650 ShaderTranslator* translator = NULL; |
| 5645 if (use_shader_translator_) { | 5651 if (use_shader_translator_) { |
| 5646 translator = info->shader_type() == GL_VERTEX_SHADER ? | 5652 translator = info->shader_type() == GL_VERTEX_SHADER ? |
| 5647 vertex_translator_.get() : fragment_translator_.get(); | 5653 vertex_translator_.get() : fragment_translator_.get(); |
| 5648 | |
| 5649 if (!translator->Translate(shader_src)) { | |
| 5650 info->SetStatus(false, translator->info_log(), NULL); | |
| 5651 return; | |
| 5652 } | |
| 5653 shader_src = translator->translated_shader(); | |
| 5654 if (!feature_info_->feature_flags().angle_translated_shader_source) | |
| 5655 info->UpdateTranslatedSource(shader_src); | |
| 5656 } | 5654 } |
| 5657 | 5655 |
| 5658 glShaderSource(info->service_id(), 1, &shader_src, NULL); | 5656 ProgramManager* manager = GetContextGroup()->program_manager(); |
|
greggman
2012/06/15 08:10:24
you can just use program_manager();
No need to g
dmurph
2012/06/19 01:08:33
Done.
| |
| 5659 glCompileShader(info->service_id()); | 5657 ShaderCache* cache = manager->GetShaderCache(); |
| 5660 if (feature_info_->feature_flags().angle_translated_shader_source) { | 5658 if (cache && |
|
greggman
2012/06/15 08:10:24
If you get rid of the WeakPtr there should ways be
dmurph
2012/06/15 16:40:23
See above comment. This would be the fastest opti
| |
| 5661 GLint max_len = 0; | 5659 cache->getShaderCompilationStatus(info->source()->c_str()) |
|
greggman
2012/06/15 08:10:24
style: functions start with UpperCase
| |
| 5662 glGetShaderiv(info->service_id(), | 5660 == SHADER_CACHE_COMPILATION_SUCCEEDED) { |
| 5663 GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, | 5661 info->SetStatus(true, "possible cache hit", translator); |
|
greggman
2012/06/15 08:10:24
I don't think it's valid to set the status string
dmurph
2012/06/19 01:08:33
Done.
| |
| 5664 &max_len); | 5662 return; |
|
greggman
2012/06/15 08:10:24
the 6 lines above seem like they belong in Program
dmurph
2012/06/19 01:08:33
Well, we need separation between using the cache a
| |
| 5665 scoped_array<char> temp(new char[max_len]); | |
| 5666 GLint len = 0; | |
| 5667 glGetTranslatedShaderSourceANGLE( | |
| 5668 info->service_id(), max_len, &len, temp.get()); | |
| 5669 DCHECK(max_len == 0 || len < max_len); | |
| 5670 DCHECK(len == 0 || temp[len] == '\0'); | |
| 5671 info->UpdateTranslatedSource(temp.get()); | |
| 5672 } | 5663 } |
| 5673 | 5664 |
| 5674 GLint status = GL_FALSE; | 5665 manager->DoCompileShader(info, translator, feature_info_); |
| 5675 glGetShaderiv(info->service_id(), GL_COMPILE_STATUS, &status); | |
| 5676 if (status) { | |
| 5677 info->SetStatus(true, "", translator); | |
| 5678 } else { | |
| 5679 // We cannot reach here if we are using the shader translator. | |
| 5680 // All invalid shaders must be rejected by the translator. | |
| 5681 // All translated shaders must compile. | |
| 5682 LOG_IF(ERROR, use_shader_translator_) | |
| 5683 << "Shader translator allowed/produced an invalid shader."; | |
| 5684 GLint max_len = 0; | |
| 5685 glGetShaderiv(info->service_id(), GL_INFO_LOG_LENGTH, &max_len); | |
| 5686 scoped_array<char> temp(new char[max_len]); | |
| 5687 GLint len = 0; | |
| 5688 glGetShaderInfoLog(info->service_id(), max_len, &len, temp.get()); | |
| 5689 DCHECK(max_len == 0 || len < max_len); | |
| 5690 DCHECK(len == 0 || temp[len] == '\0'); | |
| 5691 info->SetStatus(false, std::string(temp.get(), len).c_str(), NULL); | |
| 5692 } | |
| 5693 }; | 5666 }; |
| 5694 | 5667 |
| 5695 void GLES2DecoderImpl::DoGetShaderiv( | 5668 void GLES2DecoderImpl::DoGetShaderiv( |
| 5696 GLuint shader, GLenum pname, GLint* params) { | 5669 GLuint shader, GLenum pname, GLint* params) { |
| 5697 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( | 5670 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( |
| 5698 shader, "glGetShaderiv"); | 5671 shader, "glGetShaderiv"); |
| 5699 if (!info) { | 5672 if (!info) { |
| 5700 return; | 5673 return; |
| 5701 } | 5674 } |
| 5702 switch (pname) { | 5675 switch (pname) { |
| (...skipping 3309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9012 BindAndApplyTextureParameters(info); | 8985 BindAndApplyTextureParameters(info); |
| 9013 } | 8986 } |
| 9014 | 8987 |
| 9015 // Include the auto-generated part of this file. We split this because it means | 8988 // Include the auto-generated part of this file. We split this because it means |
| 9016 // we can easily edit the non-auto generated parts right here in this file | 8989 // we can easily edit the non-auto generated parts right here in this file |
| 9017 // instead of having to edit some template or the code generator. | 8990 // instead of having to edit some template or the code generator. |
| 9018 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 8991 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 9019 | 8992 |
| 9020 } // namespace gles2 | 8993 } // namespace gles2 |
| 9021 } // namespace gpu | 8994 } // namespace gpu |
| OLD | NEW |