Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(837)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 39263004: Merge 229254 "Work around broken GL_TEXTURE_BINDING_EXTERNAL_OES..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1650/src/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 bool IsDrawValid( 1366 bool IsDrawValid(
1367 const char* function_name, GLuint max_vertex_accessed, GLsizei primcount); 1367 const char* function_name, GLuint max_vertex_accessed, GLsizei primcount);
1368 1368
1369 // Returns true if successful, simulated will be true if attrib0 was 1369 // Returns true if successful, simulated will be true if attrib0 was
1370 // simulated. 1370 // simulated.
1371 bool SimulateAttrib0( 1371 bool SimulateAttrib0(
1372 const char* function_name, GLuint max_vertex_accessed, bool* simulated); 1372 const char* function_name, GLuint max_vertex_accessed, bool* simulated);
1373 void RestoreStateForAttrib(GLuint attrib); 1373 void RestoreStateForAttrib(GLuint attrib);
1374 1374
1375 // If texture is a stream texture, this will update the stream to the newest 1375 // If texture is a stream texture, this will update the stream to the newest
1376 // buffer. 1376 // buffer and bind the texture implicitly.
1377 void UpdateStreamTextureIfNeeded(Texture* texture); 1377 void UpdateStreamTextureIfNeeded(Texture* texture, GLuint texture_unit_index);
1378 1378
1379 // Returns false if unrenderable textures were replaced. 1379 // Returns false if unrenderable textures were replaced.
1380 bool PrepareTexturesForRender(); 1380 bool PrepareTexturesForRender();
1381 void RestoreStateForNonRenderableTextures(); 1381 void RestoreStateForNonRenderableTextures();
1382 1382
1383 // Returns true if GL_FIXED attribs were simulated. 1383 // Returns true if GL_FIXED attribs were simulated.
1384 bool SimulateFixedAttribs( 1384 bool SimulateFixedAttribs(
1385 const char* function_name, 1385 const char* function_name,
1386 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount); 1386 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount);
1387 void RestoreStateForSimulatedFixedAttribs(); 1387 void RestoreStateForSimulatedFixedAttribs();
(...skipping 4330 matching lines...) Expand 10 before | Expand all | Expand 10 after
5718 const char* filename, int line, const std::string& msg) { 5718 const char* filename, int line, const std::string& msg) {
5719 logger_.LogMessage(filename, line, std::string("RENDER WARNING: ") + msg); 5719 logger_.LogMessage(filename, line, std::string("RENDER WARNING: ") + msg);
5720 } 5720 }
5721 5721
5722 void GLES2DecoderImpl::PerformanceWarning( 5722 void GLES2DecoderImpl::PerformanceWarning(
5723 const char* filename, int line, const std::string& msg) { 5723 const char* filename, int line, const std::string& msg) {
5724 logger_.LogMessage(filename, line, 5724 logger_.LogMessage(filename, line,
5725 std::string("PERFORMANCE WARNING: ") + msg); 5725 std::string("PERFORMANCE WARNING: ") + msg);
5726 } 5726 }
5727 5727
5728 void GLES2DecoderImpl::UpdateStreamTextureIfNeeded(Texture* texture) { 5728 void GLES2DecoderImpl::UpdateStreamTextureIfNeeded(Texture* texture,
5729 GLuint texture_unit_index) {
5729 if (texture && texture->IsStreamTexture()) { 5730 if (texture && texture->IsStreamTexture()) {
5730 DCHECK(stream_texture_manager()); 5731 DCHECK(stream_texture_manager());
5731 StreamTexture* stream_tex = 5732 StreamTexture* stream_tex =
5732 stream_texture_manager()->LookupStreamTexture(texture->service_id()); 5733 stream_texture_manager()->LookupStreamTexture(texture->service_id());
5733 if (stream_tex) 5734 if (stream_tex) {
5735 glActiveTexture(GL_TEXTURE0 + texture_unit_index);
5734 stream_tex->Update(); 5736 stream_tex->Update();
5737 }
5735 } 5738 }
5736 } 5739 }
5737 5740
5738 bool GLES2DecoderImpl::PrepareTexturesForRender() { 5741 bool GLES2DecoderImpl::PrepareTexturesForRender() {
5739 DCHECK(state_.current_program.get()); 5742 DCHECK(state_.current_program.get());
5740 bool have_unrenderable_textures = 5743 bool have_unrenderable_textures =
5741 texture_manager()->HaveUnrenderableTextures(); 5744 texture_manager()->HaveUnrenderableTextures();
5742 if (!have_unrenderable_textures && !features().oes_egl_image_external) { 5745 if (!have_unrenderable_textures && !features().oes_egl_image_external) {
5743 return true; 5746 return true;
5744 } 5747 }
5745 5748
5746 bool textures_set = false; 5749 bool textures_set = false;
5747 const Program::SamplerIndices& sampler_indices = 5750 const Program::SamplerIndices& sampler_indices =
5748 state_.current_program->sampler_indices(); 5751 state_.current_program->sampler_indices();
5749 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 5752 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
5750 const Program::UniformInfo* uniform_info = 5753 const Program::UniformInfo* uniform_info =
5751 state_.current_program->GetUniformInfo(sampler_indices[ii]); 5754 state_.current_program->GetUniformInfo(sampler_indices[ii]);
5752 DCHECK(uniform_info); 5755 DCHECK(uniform_info);
5753 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 5756 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
5754 GLuint texture_unit_index = uniform_info->texture_units[jj]; 5757 GLuint texture_unit_index = uniform_info->texture_units[jj];
5755 if (texture_unit_index < state_.texture_units.size()) { 5758 if (texture_unit_index < state_.texture_units.size()) {
5756 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; 5759 TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
5757 TextureRef* texture = 5760 TextureRef* texture =
5758 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); 5761 texture_unit.GetInfoForSamplerType(uniform_info->type).get();
5759 if (texture) 5762 if (texture)
5760 UpdateStreamTextureIfNeeded(texture->texture()); 5763 UpdateStreamTextureIfNeeded(texture->texture(), texture_unit_index);
5761 if (have_unrenderable_textures && 5764 if (have_unrenderable_textures &&
5762 (!texture || !texture_manager()->CanRender(texture))) { 5765 (!texture || !texture_manager()->CanRender(texture))) {
5763 textures_set = true; 5766 textures_set = true;
5764 glActiveTexture(GL_TEXTURE0 + texture_unit_index); 5767 glActiveTexture(GL_TEXTURE0 + texture_unit_index);
5765 glBindTexture( 5768 glBindTexture(
5766 GetBindTargetForSamplerType(uniform_info->type), 5769 GetBindTargetForSamplerType(uniform_info->type),
5767 texture_manager()->black_texture_id(uniform_info->type)); 5770 texture_manager()->black_texture_id(uniform_info->type));
5768 LOCAL_RENDER_WARNING( 5771 LOCAL_RENDER_WARNING(
5769 std::string("texture bound to texture unit ") + 5772 std::string("texture bound to texture unit ") +
5770 base::IntToString(texture_unit_index) + 5773 base::IntToString(texture_unit_index) +
(...skipping 4675 matching lines...) Expand 10 before | Expand all | Expand 10 after
10446 return error::kNoError; 10449 return error::kNoError;
10447 } 10450 }
10448 10451
10449 // Include the auto-generated part of this file. We split this because it means 10452 // Include the auto-generated part of this file. We split this because it means
10450 // we can easily edit the non-auto generated parts right here in this file 10453 // we can easily edit the non-auto generated parts right here in this file
10451 // instead of having to edit some template or the code generator. 10454 // instead of having to edit some template or the code generator.
10452 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10455 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10453 10456
10454 } // namespace gles2 10457 } // namespace gles2
10455 } // namespace gpu 10458 } // namespace gpu
OLDNEW
« no previous file with comments | « content/common/gpu/stream_texture_manager_android.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698