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

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

Issue 2518413002: Add validation to the mailbox functions in the passthrough cmd decoder. (Closed)
Patch Set: Fix explicit. Created 4 years 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
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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_passthrough.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h"
6 6
7 #include "gpu/command_buffer/service/feature_info.h" 7 #include "gpu/command_buffer/service/feature_info.h"
8 #include "gpu/command_buffer/service/gl_utils.h" 8 #include "gpu/command_buffer/service/gl_utils.h"
9 #include "ui/gl/gl_version_info.h" 9 #include "ui/gl/gl_version_info.h"
10 10
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 resources_ = group_->passthrough_resources(); 185 resources_ = group_->passthrough_resources();
186 186
187 mailbox_manager_ = group_->mailbox_manager(); 187 mailbox_manager_ = group_->mailbox_manager();
188 188
189 // Query information about the texture units 189 // Query information about the texture units
190 GLint num_texture_units = 0; 190 GLint num_texture_units = 0;
191 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &num_texture_units); 191 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &num_texture_units);
192 192
193 active_texture_unit_ = 0; 193 active_texture_unit_ = 0;
194 bound_textures_.resize(num_texture_units, 0); 194 bound_textures_[GL_TEXTURE_2D].resize(num_texture_units, 0);
195 bound_textures_[GL_TEXTURE_CUBE_MAP].resize(num_texture_units, 0);
196 if (feature_info_->IsWebGL2OrES3Context()) {
197 bound_textures_[GL_TEXTURE_2D_ARRAY].resize(num_texture_units, 0);
198 bound_textures_[GL_TEXTURE_3D].resize(num_texture_units, 0);
199 }
195 200
196 if (group_->gpu_preferences().enable_gpu_driver_debug_logging && 201 if (group_->gpu_preferences().enable_gpu_driver_debug_logging &&
197 feature_info_->feature_flags().khr_debug) { 202 feature_info_->feature_flags().khr_debug) {
198 InitializeGLDebugLogging(); 203 InitializeGLDebugLogging();
199 } 204 }
200 205
201 emulated_extensions_.push_back("GL_CHROMIUM_async_pixel_transfers"); 206 emulated_extensions_.push_back("GL_CHROMIUM_async_pixel_transfers");
202 emulated_extensions_.push_back("GL_CHROMIUM_command_buffer_query"); 207 emulated_extensions_.push_back("GL_CHROMIUM_command_buffer_query");
203 emulated_extensions_.push_back("GL_CHROMIUM_command_buffer_latency_query"); 208 emulated_extensions_.push_back("GL_CHROMIUM_command_buffer_latency_query");
204 emulated_extensions_.push_back("GL_CHROMIUM_get_error_query"); 209 emulated_extensions_.push_back("GL_CHROMIUM_get_error_query");
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 sync->result = result; 819 sync->result = result;
815 base::subtle::Release_Store(&sync->process_count, query.submit_count); 820 base::subtle::Release_Store(&sync->process_count, query.submit_count);
816 pending_queries_.pop_front(); 821 pending_queries_.pop_front();
817 } 822 }
818 823
819 // If glFinish() has been called, all of our queries should be completed. 824 // If glFinish() has been called, all of our queries should be completed.
820 DCHECK(!did_finish || pending_queries_.empty()); 825 DCHECK(!did_finish || pending_queries_.empty());
821 return error::kNoError; 826 return error::kNoError;
822 } 827 }
823 828
829 void GLES2DecoderPassthroughImpl::UpdateTextureBinding(GLenum target,
830 GLuint client_id,
831 GLuint service_id) {
832 size_t cur_texture_unit = active_texture_unit_;
833 const auto& target_bound_textures = bound_textures_.at(target);
834 for (size_t bound_texture_index = 0;
835 bound_texture_index < target_bound_textures.size();
836 bound_texture_index++) {
837 GLuint bound_client_id = target_bound_textures[bound_texture_index];
838 if (bound_client_id == client_id) {
839 // Update the active texture unit if needed
840 if (bound_texture_index != cur_texture_unit) {
841 glActiveTexture(static_cast<GLenum>(GL_TEXTURE0 + bound_texture_index));
842 cur_texture_unit = bound_texture_index;
843 }
844
845 // Update the texture binding
846 glBindTexture(target, service_id);
847 }
848 }
849
850 // Reset the active texture unit if it was changed
851 if (cur_texture_unit != active_texture_unit_) {
852 glActiveTexture(static_cast<GLenum>(GL_TEXTURE0 + active_texture_unit_));
853 }
854 }
855
824 #define GLES2_CMD_OP(name) \ 856 #define GLES2_CMD_OP(name) \
825 { \ 857 { \
826 &GLES2DecoderPassthroughImpl::Handle##name, cmds::name::kArgFlags, \ 858 &GLES2DecoderPassthroughImpl::Handle##name, cmds::name::kArgFlags, \
827 cmds::name::cmd_flags, \ 859 cmds::name::cmd_flags, \
828 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ 860 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \
829 }, /* NOLINT */ 861 }, /* NOLINT */
830 862
831 const GLES2DecoderPassthroughImpl::CommandInfo 863 const GLES2DecoderPassthroughImpl::CommandInfo
832 GLES2DecoderPassthroughImpl::command_info[] = { 864 GLES2DecoderPassthroughImpl::command_info[] = {
833 GLES2_COMMAND_LIST(GLES2_CMD_OP)}; 865 GLES2_COMMAND_LIST(GLES2_CMD_OP)};
834 866
835 #undef GLES2_CMD_OP 867 #undef GLES2_CMD_OP
836 868
837 } // namespace gles2 869 } // namespace gles2
838 } // namespace gpu 870 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698