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

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

Issue 7458008: Support GL_OES_EGL_image_external (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 5 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 510
511 // The last target that was bound to this texture unit. 511 // The last target that was bound to this texture unit.
512 GLenum bind_target; 512 GLenum bind_target;
513 513
514 // texture currently bound to this unit's GL_TEXTURE_2D with glBindTexture 514 // texture currently bound to this unit's GL_TEXTURE_2D with glBindTexture
515 TextureManager::TextureInfo::Ref bound_texture_2d; 515 TextureManager::TextureInfo::Ref bound_texture_2d;
516 516
517 // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with 517 // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with
518 // glBindTexture 518 // glBindTexture
519 TextureManager::TextureInfo::Ref bound_texture_cube_map; 519 TextureManager::TextureInfo::Ref bound_texture_cube_map;
520
521 // texture currently bound to this unit's GL_TEXTURE_EXTERNAL_OES with
522 // glBindTexture
523 TextureManager::TextureInfo::Ref bound_texture_external_oes;
520 }; 524 };
521 525
522 // Initialize or re-initialize the shader translator. 526 // Initialize or re-initialize the shader translator.
523 bool InitializeShaderTranslator(); 527 bool InitializeShaderTranslator();
524 528
525 void UpdateCapabilities(); 529 void UpdateCapabilities();
526 530
527 // Helpers for the glGen and glDelete functions. 531 // Helpers for the glGen and glDelete functions.
528 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids); 532 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids);
529 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids); 533 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids);
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 break; 1091 break;
1088 case GL_TEXTURE_CUBE_MAP: 1092 case GL_TEXTURE_CUBE_MAP:
1089 case GL_TEXTURE_CUBE_MAP_POSITIVE_X: 1093 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1090 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: 1094 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1091 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: 1095 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1092 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: 1096 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1093 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: 1097 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1094 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: 1098 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1095 info = unit.bound_texture_cube_map; 1099 info = unit.bound_texture_cube_map;
1096 break; 1100 break;
1101 case GL_TEXTURE_EXTERNAL_OES:
1102 info = unit.bound_texture_external_oes;
1103 break;
1097 // Note: If we ever support TEXTURE_RECTANGLE as a target, be sure to 1104 // Note: If we ever support TEXTURE_RECTANGLE as a target, be sure to
1098 // track |texture_| with the currently bound TEXTURE_RECTANGLE texture, 1105 // track |texture_| with the currently bound TEXTURE_RECTANGLE texture,
1099 // because |texture_| is used by the FBO rendering mechanism for readback 1106 // because |texture_| is used by the FBO rendering mechanism for readback
1100 // to the bits that get sent to the browser. 1107 // to the bits that get sent to the browser.
1101 default: 1108 default:
1102 NOTREACHED(); 1109 NOTREACHED();
1103 return NULL; 1110 return NULL;
1104 } 1111 }
1105 return (info && !info->IsDeleted()) ? info : NULL; 1112 return (info && !info->IsDeleted()) ? info : NULL;
1106 } 1113 }
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 glGenBuffersARB(1, &attrib_0_buffer_id_); 1727 glGenBuffersARB(1, &attrib_0_buffer_id_);
1721 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); 1728 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_);
1722 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL); 1729 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL);
1723 glBindBuffer(GL_ARRAY_BUFFER, 0); 1730 glBindBuffer(GL_ARRAY_BUFFER, 0);
1724 glGenBuffersARB(1, &fixed_attrib_buffer_id_); 1731 glGenBuffersARB(1, &fixed_attrib_buffer_id_);
1725 1732
1726 texture_units_.reset( 1733 texture_units_.reset(
1727 new TextureUnit[group_->max_texture_units()]); 1734 new TextureUnit[group_->max_texture_units()]);
1728 for (uint32 tt = 0; tt < group_->max_texture_units(); ++tt) { 1735 for (uint32 tt = 0; tt < group_->max_texture_units(); ++tt) {
1729 glActiveTexture(GL_TEXTURE0 + tt); 1736 glActiveTexture(GL_TEXTURE0 + tt);
1730 // Do cube map first because we want the last bind to be 2D. 1737 // We want the last bind to be 2D.
1731 TextureManager::TextureInfo* info = 1738 TextureManager::TextureInfo* info;
1732 texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); 1739 if (feature_info_->feature_flags().oes_egl_image_external) {
1740 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_EXTERNAL_OES);
1741 texture_units_[tt].bound_texture_external_oes = info;
1742 glBindTexture(GL_TEXTURE_EXTERNAL_OES, info->service_id());
1743 }
1744 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP);
1733 texture_units_[tt].bound_texture_cube_map = info; 1745 texture_units_[tt].bound_texture_cube_map = info;
1734 glBindTexture(GL_TEXTURE_CUBE_MAP, info->service_id()); 1746 glBindTexture(GL_TEXTURE_CUBE_MAP, info->service_id());
1735 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); 1747 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D);
1736 texture_units_[tt].bound_texture_2d = info; 1748 texture_units_[tt].bound_texture_2d = info;
1737 glBindTexture(GL_TEXTURE_2D, info->service_id()); 1749 glBindTexture(GL_TEXTURE_2D, info->service_id());
1738 } 1750 }
1739 glActiveTexture(GL_TEXTURE0); 1751 glActiveTexture(GL_TEXTURE0);
1740 CHECK_GL_ERROR(); 1752 CHECK_GL_ERROR();
1741 1753
1742 ContextCreationAttribParser attrib_parser; 1754 ContextCreationAttribParser attrib_parser;
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
2812 glBindTexture(target, info->service_id()); 2824 glBindTexture(target, info->service_id());
2813 TextureUnit& unit = texture_units_[active_texture_unit_]; 2825 TextureUnit& unit = texture_units_[active_texture_unit_];
2814 unit.bind_target = target; 2826 unit.bind_target = target;
2815 switch (target) { 2827 switch (target) {
2816 case GL_TEXTURE_2D: 2828 case GL_TEXTURE_2D:
2817 unit.bound_texture_2d = info; 2829 unit.bound_texture_2d = info;
2818 break; 2830 break;
2819 case GL_TEXTURE_CUBE_MAP: 2831 case GL_TEXTURE_CUBE_MAP:
2820 unit.bound_texture_cube_map = info; 2832 unit.bound_texture_cube_map = info;
2821 break; 2833 break;
2834 case GL_TEXTURE_EXTERNAL_OES:
2835 if (feature_info_->feature_flags().oes_egl_image_external)
greggman 2011/07/20 01:41:18 I don't think you need to check here. If the featu
2836 unit.bound_texture_external_oes = info;
2837 else
2838 NOTREACHED(); // Validation should prevent us getting here.
2839 break;
2822 default: 2840 default:
2823 NOTREACHED(); // Validation should prevent us getting here. 2841 NOTREACHED(); // Validation should prevent us getting here.
2824 break; 2842 break;
2825 } 2843 }
2826 } 2844 }
2827 2845
2828 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) { 2846 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) {
2829 if (vertex_attrib_manager_.Enable(index, false)) { 2847 if (vertex_attrib_manager_.Enable(index, false)) {
2830 if (index != 0 || 2848 if (index != 0 ||
2831 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { 2849 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) {
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
3106 if (unit.bound_texture_cube_map) { 3124 if (unit.bound_texture_cube_map) {
3107 GLuint client_id = 0; 3125 GLuint client_id = 0;
3108 texture_manager()->GetClientId( 3126 texture_manager()->GetClientId(
3109 unit.bound_texture_cube_map->service_id(), &client_id); 3127 unit.bound_texture_cube_map->service_id(), &client_id);
3110 *params = client_id; 3128 *params = client_id;
3111 } else { 3129 } else {
3112 *params = 0; 3130 *params = 0;
3113 } 3131 }
3114 } 3132 }
3115 return true; 3133 return true;
3134 case GL_TEXTURE_BINDING_EXTERNAL_OES:
3135 *num_written = 1;
3136 if (params) {
3137 TextureUnit& unit = texture_units_[active_texture_unit_];
3138 if (unit.bound_texture_external_oes) {
3139 GLuint client_id = 0;
3140 texture_manager()->GetClientId(
3141 unit.bound_texture_external_oes->service_id(), &client_id);
3142 *params = client_id;
3143 } else {
3144 *params = 0;
3145 }
3146 }
3147 return true;
3116 default: 3148 default:
3117 *num_written = util_.GLGetNumValuesReturned(pname); 3149 *num_written = util_.GLGetNumValuesReturned(pname);
3118 return false; 3150 return false;
3119 } 3151 }
3120 } 3152 }
3121 3153
3122 bool GLES2DecoderImpl::GetNumValuesReturnedForGLGet( 3154 bool GLES2DecoderImpl::GetNumValuesReturnedForGLGet(
3123 GLenum pname, GLsizei* num_values) { 3155 GLenum pname, GLsizei* num_values) {
3124 return GetHelper(pname, NULL, num_values); 3156 return GetHelper(pname, NULL, num_values);
3125 } 3157 }
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
3875 3907
3876 void GLES2DecoderImpl::DoUniform1iv( 3908 void GLES2DecoderImpl::DoUniform1iv(
3877 GLint location, GLsizei count, const GLint *value) { 3909 GLint location, GLsizei count, const GLint *value) {
3878 if (!CheckCurrentProgramForUniform(location, "glUniform1iv")) { 3910 if (!CheckCurrentProgramForUniform(location, "glUniform1iv")) {
3879 return; 3911 return;
3880 } 3912 }
3881 GLenum type = 0; 3913 GLenum type = 0;
3882 if (!PrepForSetUniformByLocation(location, "glUniform1iv", &type, &count)) { 3914 if (!PrepForSetUniformByLocation(location, "glUniform1iv", &type, &count)) {
3883 return; 3915 return;
3884 } 3916 }
3885 if (type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE) { 3917 if (type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE ||
3918 type == GL_SAMPLER_EXTERNAL_OES) {
3886 current_program_->SetSamplers(location, count, value); 3919 current_program_->SetSamplers(location, count, value);
3887 } 3920 }
3888 glUniform1iv(location, count, value); 3921 glUniform1iv(location, count, value);
3889 } 3922 }
3890 3923
3891 void GLES2DecoderImpl::DoUniform1fv( 3924 void GLES2DecoderImpl::DoUniform1fv(
3892 GLint location, GLsizei count, const GLfloat* value) { 3925 GLint location, GLsizei count, const GLfloat* value) {
3893 GLenum type = 0; 3926 GLenum type = 0;
3894 if (!PrepForSetUniformByLocation(location, "glUniform1fv", &type, &count)) { 3927 if (!PrepForSetUniformByLocation(location, "glUniform1fv", &type, &count)) {
3895 return; 3928 return;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
4100 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = 4133 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices =
4101 current_program_->sampler_indices(); 4134 current_program_->sampler_indices();
4102 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 4135 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
4103 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = 4136 const ProgramManager::ProgramInfo::UniformInfo* uniform_info =
4104 current_program_->GetUniformInfo(sampler_indices[ii]); 4137 current_program_->GetUniformInfo(sampler_indices[ii]);
4105 DCHECK(uniform_info); 4138 DCHECK(uniform_info);
4106 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 4139 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
4107 GLuint texture_unit_index = uniform_info->texture_units[jj]; 4140 GLuint texture_unit_index = uniform_info->texture_units[jj];
4108 if (texture_unit_index < group_->max_texture_units()) { 4141 if (texture_unit_index < group_->max_texture_units()) {
4109 TextureUnit& texture_unit = texture_units_[texture_unit_index]; 4142 TextureUnit& texture_unit = texture_units_[texture_unit_index];
4110 TextureManager::TextureInfo* texture_info = 4143 TextureManager::TextureInfo* texture_info =
greggman 2011/07/20 01:41:18 This seems like it should be a function now that i
4111 uniform_info->type == GL_SAMPLER_2D ? 4144 uniform_info->type == GL_SAMPLER_2D ?
4112 texture_unit.bound_texture_2d : 4145 texture_unit.bound_texture_2d :
4113 texture_unit.bound_texture_cube_map; 4146 (uniform_info->type == GL_SAMPLER_EXTERNAL_OES ?
4147 texture_unit.bound_texture_external_oes :
4148 texture_unit.bound_texture_cube_map);
4114 if (!texture_info || !texture_info->CanRender(feature_info_)) { 4149 if (!texture_info || !texture_info->CanRender(feature_info_)) {
4115 textures_set = true; 4150 textures_set = true;
4116 glActiveTexture(GL_TEXTURE0 + texture_unit_index); 4151 glActiveTexture(GL_TEXTURE0 + texture_unit_index);
4117 glBindTexture( 4152 glBindTexture(
4118 uniform_info->type == GL_SAMPLER_2D ? GL_TEXTURE_2D : 4153 uniform_info->type == GL_SAMPLER_2D ? GL_TEXTURE_2D :
4119 GL_TEXTURE_CUBE_MAP, 4154 (uniform_info->type == GL_SAMPLER_EXTERNAL_OES ?
greggman 2011/07/20 01:41:18 This also seems like it might be better as a funct
4155 GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_CUBE_MAP),
4120 texture_manager()->black_texture_id(uniform_info->type)); 4156 texture_manager()->black_texture_id(uniform_info->type));
4121 } 4157 }
4122 } 4158 }
4123 // else: should this be an error? 4159 // else: should this be an error?
4124 } 4160 }
4125 } 4161 }
4126 return textures_set; 4162 return textures_set;
4127 } 4163 }
4128 4164
4129 void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() { 4165 void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() {
(...skipping 2668 matching lines...) Expand 10 before | Expand all | Expand 10 after
6798 return false; 6834 return false;
6799 } 6835 }
6800 6836
6801 // Include the auto-generated part of this file. We split this because it means 6837 // Include the auto-generated part of this file. We split this because it means
6802 // we can easily edit the non-auto generated parts right here in this file 6838 // we can easily edit the non-auto generated parts right here in this file
6803 // instead of having to edit some template or the code generator. 6839 // instead of having to edit some template or the code generator.
6804 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 6840 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
6805 6841
6806 } // namespace gles2 6842 } // namespace gles2
6807 } // namespace gpu 6843 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698