| 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 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 bool IsDrawValid( | 1367 bool IsDrawValid( |
| 1368 const char* function_name, GLuint max_vertex_accessed, GLsizei primcount); | 1368 const char* function_name, GLuint max_vertex_accessed, GLsizei primcount); |
| 1369 | 1369 |
| 1370 // Returns true if successful, simulated will be true if attrib0 was | 1370 // Returns true if successful, simulated will be true if attrib0 was |
| 1371 // simulated. | 1371 // simulated. |
| 1372 bool SimulateAttrib0( | 1372 bool SimulateAttrib0( |
| 1373 const char* function_name, GLuint max_vertex_accessed, bool* simulated); | 1373 const char* function_name, GLuint max_vertex_accessed, bool* simulated); |
| 1374 void RestoreStateForAttrib(GLuint attrib); | 1374 void RestoreStateForAttrib(GLuint attrib); |
| 1375 | 1375 |
| 1376 // If texture is a stream texture, this will update the stream to the newest | 1376 // If texture is a stream texture, this will update the stream to the newest |
| 1377 // buffer. | 1377 // buffer and bind the texture implicitly. |
| 1378 void UpdateStreamTextureIfNeeded(Texture* texture); | 1378 void UpdateStreamTextureIfNeeded(Texture* texture, GLuint texture_unit_index); |
| 1379 | 1379 |
| 1380 // Returns false if unrenderable textures were replaced. | 1380 // Returns false if unrenderable textures were replaced. |
| 1381 bool PrepareTexturesForRender(); | 1381 bool PrepareTexturesForRender(); |
| 1382 void RestoreStateForNonRenderableTextures(); | 1382 void RestoreStateForNonRenderableTextures(); |
| 1383 | 1383 |
| 1384 // Returns true if GL_FIXED attribs were simulated. | 1384 // Returns true if GL_FIXED attribs were simulated. |
| 1385 bool SimulateFixedAttribs( | 1385 bool SimulateFixedAttribs( |
| 1386 const char* function_name, | 1386 const char* function_name, |
| 1387 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount); | 1387 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount); |
| 1388 void RestoreStateForSimulatedFixedAttribs(); | 1388 void RestoreStateForSimulatedFixedAttribs(); |
| (...skipping 4345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5734 const char* filename, int line, const std::string& msg) { | 5734 const char* filename, int line, const std::string& msg) { |
| 5735 logger_.LogMessage(filename, line, std::string("RENDER WARNING: ") + msg); | 5735 logger_.LogMessage(filename, line, std::string("RENDER WARNING: ") + msg); |
| 5736 } | 5736 } |
| 5737 | 5737 |
| 5738 void GLES2DecoderImpl::PerformanceWarning( | 5738 void GLES2DecoderImpl::PerformanceWarning( |
| 5739 const char* filename, int line, const std::string& msg) { | 5739 const char* filename, int line, const std::string& msg) { |
| 5740 logger_.LogMessage(filename, line, | 5740 logger_.LogMessage(filename, line, |
| 5741 std::string("PERFORMANCE WARNING: ") + msg); | 5741 std::string("PERFORMANCE WARNING: ") + msg); |
| 5742 } | 5742 } |
| 5743 | 5743 |
| 5744 void GLES2DecoderImpl::UpdateStreamTextureIfNeeded(Texture* texture) { | 5744 void GLES2DecoderImpl::UpdateStreamTextureIfNeeded(Texture* texture, |
| 5745 GLuint texture_unit_index) { |
| 5745 if (texture && texture->IsStreamTexture()) { | 5746 if (texture && texture->IsStreamTexture()) { |
| 5746 DCHECK(stream_texture_manager()); | 5747 DCHECK(stream_texture_manager()); |
| 5747 StreamTexture* stream_tex = | 5748 StreamTexture* stream_tex = |
| 5748 stream_texture_manager()->LookupStreamTexture(texture->service_id()); | 5749 stream_texture_manager()->LookupStreamTexture(texture->service_id()); |
| 5749 if (stream_tex) | 5750 if (stream_tex) { |
| 5751 glActiveTexture(GL_TEXTURE0 + texture_unit_index); |
| 5750 stream_tex->Update(); | 5752 stream_tex->Update(); |
| 5753 } |
| 5751 } | 5754 } |
| 5752 } | 5755 } |
| 5753 | 5756 |
| 5754 bool GLES2DecoderImpl::PrepareTexturesForRender() { | 5757 bool GLES2DecoderImpl::PrepareTexturesForRender() { |
| 5755 DCHECK(state_.current_program.get()); | 5758 DCHECK(state_.current_program.get()); |
| 5756 bool have_unrenderable_textures = | 5759 bool have_unrenderable_textures = |
| 5757 texture_manager()->HaveUnrenderableTextures(); | 5760 texture_manager()->HaveUnrenderableTextures(); |
| 5758 if (!have_unrenderable_textures && !features().oes_egl_image_external) { | 5761 if (!have_unrenderable_textures && !features().oes_egl_image_external) { |
| 5759 return true; | 5762 return true; |
| 5760 } | 5763 } |
| 5761 | 5764 |
| 5762 bool textures_set = false; | 5765 bool textures_set = false; |
| 5763 const Program::SamplerIndices& sampler_indices = | 5766 const Program::SamplerIndices& sampler_indices = |
| 5764 state_.current_program->sampler_indices(); | 5767 state_.current_program->sampler_indices(); |
| 5765 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 5768 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
| 5766 const Program::UniformInfo* uniform_info = | 5769 const Program::UniformInfo* uniform_info = |
| 5767 state_.current_program->GetUniformInfo(sampler_indices[ii]); | 5770 state_.current_program->GetUniformInfo(sampler_indices[ii]); |
| 5768 DCHECK(uniform_info); | 5771 DCHECK(uniform_info); |
| 5769 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | 5772 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { |
| 5770 GLuint texture_unit_index = uniform_info->texture_units[jj]; | 5773 GLuint texture_unit_index = uniform_info->texture_units[jj]; |
| 5771 if (texture_unit_index < state_.texture_units.size()) { | 5774 if (texture_unit_index < state_.texture_units.size()) { |
| 5772 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; | 5775 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
| 5773 TextureRef* texture = | 5776 TextureRef* texture = |
| 5774 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); | 5777 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); |
| 5775 if (texture) | 5778 if (texture) |
| 5776 UpdateStreamTextureIfNeeded(texture->texture()); | 5779 UpdateStreamTextureIfNeeded(texture->texture(), texture_unit_index); |
| 5777 if (have_unrenderable_textures && | 5780 if (have_unrenderable_textures && |
| 5778 (!texture || !texture_manager()->CanRender(texture))) { | 5781 (!texture || !texture_manager()->CanRender(texture))) { |
| 5779 textures_set = true; | 5782 textures_set = true; |
| 5780 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | 5783 glActiveTexture(GL_TEXTURE0 + texture_unit_index); |
| 5781 glBindTexture( | 5784 glBindTexture( |
| 5782 GetBindTargetForSamplerType(uniform_info->type), | 5785 GetBindTargetForSamplerType(uniform_info->type), |
| 5783 texture_manager()->black_texture_id(uniform_info->type)); | 5786 texture_manager()->black_texture_id(uniform_info->type)); |
| 5784 LOCAL_RENDER_WARNING( | 5787 LOCAL_RENDER_WARNING( |
| 5785 std::string("texture bound to texture unit ") + | 5788 std::string("texture bound to texture unit ") + |
| 5786 base::IntToString(texture_unit_index) + | 5789 base::IntToString(texture_unit_index) + |
| (...skipping 4539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10326 return error::kNoError; | 10329 return error::kNoError; |
| 10327 } | 10330 } |
| 10328 | 10331 |
| 10329 // Include the auto-generated part of this file. We split this because it means | 10332 // Include the auto-generated part of this file. We split this because it means |
| 10330 // we can easily edit the non-auto generated parts right here in this file | 10333 // we can easily edit the non-auto generated parts right here in this file |
| 10331 // instead of having to edit some template or the code generator. | 10334 // instead of having to edit some template or the code generator. |
| 10332 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10335 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 10333 | 10336 |
| 10334 } // namespace gles2 | 10337 } // namespace gles2 |
| 10335 } // namespace gpu | 10338 } // namespace gpu |
| OLD | NEW |