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

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: fix typo which hung the windows gpu_unittests by corrupting the stack 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;
524
525 TextureManager::TextureInfo::Ref GetInfoForSamplerType(GLenum type) {
526 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE ||
527 type == GL_SAMPLER_EXTERNAL_OES);
528 return type == GL_SAMPLER_2D ? bound_texture_2d :
529 (type == GL_SAMPLER_EXTERNAL_OES ? bound_texture_external_oes :
530 bound_texture_cube_map);
531 }
520 }; 532 };
521 533
522 // Initialize or re-initialize the shader translator. 534 // Initialize or re-initialize the shader translator.
523 bool InitializeShaderTranslator(); 535 bool InitializeShaderTranslator();
524 536
525 void UpdateCapabilities(); 537 void UpdateCapabilities();
526 538
527 // Helpers for the glGen and glDelete functions. 539 // Helpers for the glGen and glDelete functions.
528 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids); 540 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids);
529 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids); 541 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids);
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 break; 1099 break;
1088 case GL_TEXTURE_CUBE_MAP: 1100 case GL_TEXTURE_CUBE_MAP:
1089 case GL_TEXTURE_CUBE_MAP_POSITIVE_X: 1101 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1090 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: 1102 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1091 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: 1103 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1092 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: 1104 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1093 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: 1105 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1094 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: 1106 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1095 info = unit.bound_texture_cube_map; 1107 info = unit.bound_texture_cube_map;
1096 break; 1108 break;
1109 case GL_TEXTURE_EXTERNAL_OES:
1110 info = unit.bound_texture_external_oes;
1111 break;
1097 // Note: If we ever support TEXTURE_RECTANGLE as a target, be sure to 1112 // Note: If we ever support TEXTURE_RECTANGLE as a target, be sure to
1098 // track |texture_| with the currently bound TEXTURE_RECTANGLE texture, 1113 // track |texture_| with the currently bound TEXTURE_RECTANGLE texture,
1099 // because |texture_| is used by the FBO rendering mechanism for readback 1114 // because |texture_| is used by the FBO rendering mechanism for readback
1100 // to the bits that get sent to the browser. 1115 // to the bits that get sent to the browser.
1101 default: 1116 default:
1102 NOTREACHED(); 1117 NOTREACHED();
1103 return NULL; 1118 return NULL;
1104 } 1119 }
1105 return (info && !info->IsDeleted()) ? info : NULL; 1120 return (info && !info->IsDeleted()) ? info : NULL;
1106 } 1121 }
1107 1122
1123 GLenum GetBindTargetForSamplerType(GLenum type) {
1124 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE ||
1125 type == GL_SAMPLER_EXTERNAL_OES);
1126 return type == GL_SAMPLER_2D ? GL_TEXTURE_2D :
1127 (type == GL_SAMPLER_EXTERNAL_OES ? GL_TEXTURE_EXTERNAL_OES :
1128 GL_TEXTURE_CUBE_MAP);
1129 }
1130
1108 // Gets the framebuffer info for a particular target. 1131 // Gets the framebuffer info for a particular target.
1109 FramebufferManager::FramebufferInfo* GetFramebufferInfoForTarget( 1132 FramebufferManager::FramebufferInfo* GetFramebufferInfoForTarget(
1110 GLenum target) { 1133 GLenum target) {
1111 FramebufferManager::FramebufferInfo* info = NULL; 1134 FramebufferManager::FramebufferInfo* info = NULL;
1112 switch (target) { 1135 switch (target) {
1113 case GL_FRAMEBUFFER: 1136 case GL_FRAMEBUFFER:
1114 case GL_DRAW_FRAMEBUFFER: 1137 case GL_DRAW_FRAMEBUFFER:
1115 info = bound_draw_framebuffer_; 1138 info = bound_draw_framebuffer_;
1116 break; 1139 break;
1117 case GL_READ_FRAMEBUFFER: 1140 case GL_READ_FRAMEBUFFER:
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 glGenBuffersARB(1, &attrib_0_buffer_id_); 1742 glGenBuffersARB(1, &attrib_0_buffer_id_);
1720 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); 1743 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_);
1721 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL); 1744 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL);
1722 glBindBuffer(GL_ARRAY_BUFFER, 0); 1745 glBindBuffer(GL_ARRAY_BUFFER, 0);
1723 glGenBuffersARB(1, &fixed_attrib_buffer_id_); 1746 glGenBuffersARB(1, &fixed_attrib_buffer_id_);
1724 1747
1725 texture_units_.reset( 1748 texture_units_.reset(
1726 new TextureUnit[group_->max_texture_units()]); 1749 new TextureUnit[group_->max_texture_units()]);
1727 for (uint32 tt = 0; tt < group_->max_texture_units(); ++tt) { 1750 for (uint32 tt = 0; tt < group_->max_texture_units(); ++tt) {
1728 glActiveTexture(GL_TEXTURE0 + tt); 1751 glActiveTexture(GL_TEXTURE0 + tt);
1729 // Do cube map first because we want the last bind to be 2D. 1752 // We want the last bind to be 2D.
1730 TextureManager::TextureInfo* info = 1753 TextureManager::TextureInfo* info;
1731 texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); 1754 if (feature_info_->feature_flags().oes_egl_image_external) {
1755 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_EXTERNAL_OES);
1756 texture_units_[tt].bound_texture_external_oes = info;
1757 glBindTexture(GL_TEXTURE_EXTERNAL_OES, info->service_id());
1758 }
1759 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP);
1732 texture_units_[tt].bound_texture_cube_map = info; 1760 texture_units_[tt].bound_texture_cube_map = info;
1733 glBindTexture(GL_TEXTURE_CUBE_MAP, info->service_id()); 1761 glBindTexture(GL_TEXTURE_CUBE_MAP, info->service_id());
1734 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); 1762 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D);
1735 texture_units_[tt].bound_texture_2d = info; 1763 texture_units_[tt].bound_texture_2d = info;
1736 glBindTexture(GL_TEXTURE_2D, info->service_id()); 1764 glBindTexture(GL_TEXTURE_2D, info->service_id());
1737 } 1765 }
1738 glActiveTexture(GL_TEXTURE0); 1766 glActiveTexture(GL_TEXTURE0);
1739 CHECK_GL_ERROR(); 1767 CHECK_GL_ERROR();
1740 1768
1741 ContextCreationAttribParser attrib_parser; 1769 ContextCreationAttribParser attrib_parser;
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
2814 glBindTexture(target, info->service_id()); 2842 glBindTexture(target, info->service_id());
2815 TextureUnit& unit = texture_units_[active_texture_unit_]; 2843 TextureUnit& unit = texture_units_[active_texture_unit_];
2816 unit.bind_target = target; 2844 unit.bind_target = target;
2817 switch (target) { 2845 switch (target) {
2818 case GL_TEXTURE_2D: 2846 case GL_TEXTURE_2D:
2819 unit.bound_texture_2d = info; 2847 unit.bound_texture_2d = info;
2820 break; 2848 break;
2821 case GL_TEXTURE_CUBE_MAP: 2849 case GL_TEXTURE_CUBE_MAP:
2822 unit.bound_texture_cube_map = info; 2850 unit.bound_texture_cube_map = info;
2823 break; 2851 break;
2852 case GL_TEXTURE_EXTERNAL_OES:
2853 unit.bound_texture_external_oes = info;
2854 break;
2824 default: 2855 default:
2825 NOTREACHED(); // Validation should prevent us getting here. 2856 NOTREACHED(); // Validation should prevent us getting here.
2826 break; 2857 break;
2827 } 2858 }
2828 } 2859 }
2829 2860
2830 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) { 2861 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) {
2831 if (vertex_attrib_manager_.Enable(index, false)) { 2862 if (vertex_attrib_manager_.Enable(index, false)) {
2832 if (index != 0 || 2863 if (index != 0 ||
2833 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { 2864 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) {
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 if (unit.bound_texture_cube_map) { 3139 if (unit.bound_texture_cube_map) {
3109 GLuint client_id = 0; 3140 GLuint client_id = 0;
3110 texture_manager()->GetClientId( 3141 texture_manager()->GetClientId(
3111 unit.bound_texture_cube_map->service_id(), &client_id); 3142 unit.bound_texture_cube_map->service_id(), &client_id);
3112 *params = client_id; 3143 *params = client_id;
3113 } else { 3144 } else {
3114 *params = 0; 3145 *params = 0;
3115 } 3146 }
3116 } 3147 }
3117 return true; 3148 return true;
3149 case GL_TEXTURE_BINDING_EXTERNAL_OES:
3150 *num_written = 1;
3151 if (params) {
3152 TextureUnit& unit = texture_units_[active_texture_unit_];
3153 if (unit.bound_texture_external_oes) {
3154 GLuint client_id = 0;
3155 texture_manager()->GetClientId(
3156 unit.bound_texture_external_oes->service_id(), &client_id);
3157 *params = client_id;
3158 } else {
3159 *params = 0;
3160 }
3161 }
3162 return true;
3118 default: 3163 default:
3119 *num_written = util_.GLGetNumValuesReturned(pname); 3164 *num_written = util_.GLGetNumValuesReturned(pname);
3120 return false; 3165 return false;
3121 } 3166 }
3122 } 3167 }
3123 3168
3124 bool GLES2DecoderImpl::GetNumValuesReturnedForGLGet( 3169 bool GLES2DecoderImpl::GetNumValuesReturnedForGLGet(
3125 GLenum pname, GLsizei* num_values) { 3170 GLenum pname, GLsizei* num_values) {
3126 return GetHelper(pname, NULL, num_values); 3171 return GetHelper(pname, NULL, num_values);
3127 } 3172 }
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
3877 3922
3878 void GLES2DecoderImpl::DoUniform1iv( 3923 void GLES2DecoderImpl::DoUniform1iv(
3879 GLint location, GLsizei count, const GLint *value) { 3924 GLint location, GLsizei count, const GLint *value) {
3880 if (!CheckCurrentProgramForUniform(location, "glUniform1iv")) { 3925 if (!CheckCurrentProgramForUniform(location, "glUniform1iv")) {
3881 return; 3926 return;
3882 } 3927 }
3883 GLenum type = 0; 3928 GLenum type = 0;
3884 if (!PrepForSetUniformByLocation(location, "glUniform1iv", &type, &count)) { 3929 if (!PrepForSetUniformByLocation(location, "glUniform1iv", &type, &count)) {
3885 return; 3930 return;
3886 } 3931 }
3887 if (type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE) { 3932 if (type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE ||
3933 type == GL_SAMPLER_EXTERNAL_OES) {
3888 current_program_->SetSamplers(location, count, value); 3934 current_program_->SetSamplers(location, count, value);
3889 } 3935 }
3890 glUniform1iv(location, count, value); 3936 glUniform1iv(location, count, value);
3891 } 3937 }
3892 3938
3893 void GLES2DecoderImpl::DoUniform1fv( 3939 void GLES2DecoderImpl::DoUniform1fv(
3894 GLint location, GLsizei count, const GLfloat* value) { 3940 GLint location, GLsizei count, const GLfloat* value) {
3895 GLenum type = 0; 3941 GLenum type = 0;
3896 if (!PrepForSetUniformByLocation(location, "glUniform1fv", &type, &count)) { 3942 if (!PrepForSetUniformByLocation(location, "glUniform1fv", &type, &count)) {
3897 return; 3943 return;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
4103 current_program_->sampler_indices(); 4149 current_program_->sampler_indices();
4104 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 4150 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
4105 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = 4151 const ProgramManager::ProgramInfo::UniformInfo* uniform_info =
4106 current_program_->GetUniformInfo(sampler_indices[ii]); 4152 current_program_->GetUniformInfo(sampler_indices[ii]);
4107 DCHECK(uniform_info); 4153 DCHECK(uniform_info);
4108 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 4154 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
4109 GLuint texture_unit_index = uniform_info->texture_units[jj]; 4155 GLuint texture_unit_index = uniform_info->texture_units[jj];
4110 if (texture_unit_index < group_->max_texture_units()) { 4156 if (texture_unit_index < group_->max_texture_units()) {
4111 TextureUnit& texture_unit = texture_units_[texture_unit_index]; 4157 TextureUnit& texture_unit = texture_units_[texture_unit_index];
4112 TextureManager::TextureInfo* texture_info = 4158 TextureManager::TextureInfo* texture_info =
4113 uniform_info->type == GL_SAMPLER_2D ? 4159 texture_unit.GetInfoForSamplerType(uniform_info->type);
4114 texture_unit.bound_texture_2d :
4115 texture_unit.bound_texture_cube_map;
4116 if (!texture_info || !texture_info->CanRender(feature_info_)) { 4160 if (!texture_info || !texture_info->CanRender(feature_info_)) {
4117 textures_set = true; 4161 textures_set = true;
4118 glActiveTexture(GL_TEXTURE0 + texture_unit_index); 4162 glActiveTexture(GL_TEXTURE0 + texture_unit_index);
4119 glBindTexture( 4163 glBindTexture(
4120 uniform_info->type == GL_SAMPLER_2D ? GL_TEXTURE_2D : 4164 GetBindTargetForSamplerType(uniform_info->type),
4121 GL_TEXTURE_CUBE_MAP,
4122 texture_manager()->black_texture_id(uniform_info->type)); 4165 texture_manager()->black_texture_id(uniform_info->type));
4123 } 4166 }
4124 } 4167 }
4125 // else: should this be an error? 4168 // else: should this be an error?
4126 } 4169 }
4127 } 4170 }
4128 return textures_set; 4171 return textures_set;
4129 } 4172 }
4130 4173
4131 void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() { 4174 void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() {
(...skipping 2618 matching lines...) Expand 10 before | Expand all | Expand 10 after
6750 return false; 6793 return false;
6751 } 6794 }
6752 6795
6753 // Include the auto-generated part of this file. We split this because it means 6796 // Include the auto-generated part of this file. We split this because it means
6754 // we can easily edit the non-auto generated parts right here in this file 6797 // we can easily edit the non-auto generated parts right here in this file
6755 // instead of having to edit some template or the code generator. 6798 // instead of having to edit some template or the code generator.
6756 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 6799 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
6757 6800
6758 } // namespace gles2 6801 } // namespace gles2
6759 } // namespace gpu 6802 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gl_utils.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698