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

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

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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) 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "gpu/command_buffer/service/image_manager.h" 49 #include "gpu/command_buffer/service/image_manager.h"
50 #include "gpu/command_buffer/service/mailbox_manager.h" 50 #include "gpu/command_buffer/service/mailbox_manager.h"
51 #include "gpu/command_buffer/service/memory_tracking.h" 51 #include "gpu/command_buffer/service/memory_tracking.h"
52 #include "gpu/command_buffer/service/program_manager.h" 52 #include "gpu/command_buffer/service/program_manager.h"
53 #include "gpu/command_buffer/service/query_manager.h" 53 #include "gpu/command_buffer/service/query_manager.h"
54 #include "gpu/command_buffer/service/renderbuffer_manager.h" 54 #include "gpu/command_buffer/service/renderbuffer_manager.h"
55 #include "gpu/command_buffer/service/shader_manager.h" 55 #include "gpu/command_buffer/service/shader_manager.h"
56 #include "gpu/command_buffer/service/shader_translator.h" 56 #include "gpu/command_buffer/service/shader_translator.h"
57 #include "gpu/command_buffer/service/shader_translator_cache.h" 57 #include "gpu/command_buffer/service/shader_translator_cache.h"
58 #include "gpu/command_buffer/service/texture_manager.h" 58 #include "gpu/command_buffer/service/texture_manager.h"
59 #include "gpu/command_buffer/service/valuebuffer_manager.h"
59 #include "gpu/command_buffer/service/vertex_array_manager.h" 60 #include "gpu/command_buffer/service/vertex_array_manager.h"
60 #include "gpu/command_buffer/service/vertex_attrib_manager.h" 61 #include "gpu/command_buffer/service/vertex_attrib_manager.h"
61 #include "third_party/smhasher/src/City.h" 62 #include "third_party/smhasher/src/City.h"
62 #include "ui/gl/gl_fence.h" 63 #include "ui/gl/gl_fence.h"
63 #include "ui/gl/gl_image.h" 64 #include "ui/gl/gl_image.h"
64 #include "ui/gl/gl_implementation.h" 65 #include "ui/gl/gl_implementation.h"
65 #include "ui/gl/gl_surface.h" 66 #include "ui/gl/gl_surface.h"
66 67
67 #if defined(OS_MACOSX) 68 #if defined(OS_MACOSX)
68 #include <IOSurface/IOSurfaceAPI.h> 69 #include <IOSurface/IOSurfaceAPI.h>
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 void RestoreTextureState(unsigned service_id) const override; 621 void RestoreTextureState(unsigned service_id) const override;
621 622
622 void ClearAllAttributes() const override; 623 void ClearAllAttributes() const override;
623 void RestoreAllAttributes() const override; 624 void RestoreAllAttributes() const override;
624 625
625 QueryManager* GetQueryManager() override { return query_manager_.get(); } 626 QueryManager* GetQueryManager() override { return query_manager_.get(); }
626 VertexArrayManager* GetVertexArrayManager() override { 627 VertexArrayManager* GetVertexArrayManager() override {
627 return vertex_array_manager_.get(); 628 return vertex_array_manager_.get();
628 } 629 }
629 ImageManager* GetImageManager() override { return image_manager_.get(); } 630 ImageManager* GetImageManager() override { return image_manager_.get(); }
630 bool ProcessPendingQueries() override; 631 bool ProcessPendingQueries(bool did_finish) override;
631 bool HasMoreIdleWork() override; 632 bool HasMoreIdleWork() override;
632 void PerformIdleWork() override; 633 void PerformIdleWork() override;
633 634
634 void WaitForReadPixels(base::Closure callback) override; 635 void WaitForReadPixels(base::Closure callback) override;
635 636
636 void SetResizeCallback( 637 void SetResizeCallback(
637 const base::Callback<void(gfx::Size, float)>& callback) override; 638 const base::Callback<void(gfx::Size, float)>& callback) override;
638 639
639 Logger* GetLogger() override; 640 Logger* GetLogger() override;
640 641
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 721
721 // Helpers for the glGen and glDelete functions. 722 // Helpers for the glGen and glDelete functions.
722 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids); 723 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids);
723 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids); 724 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids);
724 bool GenBuffersHelper(GLsizei n, const GLuint* client_ids); 725 bool GenBuffersHelper(GLsizei n, const GLuint* client_ids);
725 void DeleteBuffersHelper(GLsizei n, const GLuint* client_ids); 726 void DeleteBuffersHelper(GLsizei n, const GLuint* client_ids);
726 bool GenFramebuffersHelper(GLsizei n, const GLuint* client_ids); 727 bool GenFramebuffersHelper(GLsizei n, const GLuint* client_ids);
727 void DeleteFramebuffersHelper(GLsizei n, const GLuint* client_ids); 728 void DeleteFramebuffersHelper(GLsizei n, const GLuint* client_ids);
728 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); 729 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids);
729 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); 730 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids);
731 bool GenValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids);
732 void DeleteValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids);
730 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); 733 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids);
731 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); 734 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids);
732 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); 735 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids);
733 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); 736 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids);
734 737
735 // Helper for async upload token completion notification callback. 738 // Helper for async upload token completion notification callback.
736 base::Closure AsyncUploadTokenCompletionClosure(uint32 async_upload_token, 739 base::Closure AsyncUploadTokenCompletionClosure(uint32 async_upload_token,
737 uint32 sync_data_shm_id, 740 uint32 sync_data_shm_id,
738 uint32 sync_data_shm_offset); 741 uint32 sync_data_shm_offset);
739 742
740 743
741 744
742 // Workarounds 745 // Workarounds
743 void OnFboChanged() const; 746 void OnFboChanged() const;
744 void OnUseFramebuffer() const; 747 void OnUseFramebuffer() const;
745 748
746 // TODO(gman): Cache these pointers? 749 // TODO(gman): Cache these pointers?
747 BufferManager* buffer_manager() { 750 BufferManager* buffer_manager() {
748 return group_->buffer_manager(); 751 return group_->buffer_manager();
749 } 752 }
750 753
751 RenderbufferManager* renderbuffer_manager() { 754 RenderbufferManager* renderbuffer_manager() {
752 return group_->renderbuffer_manager(); 755 return group_->renderbuffer_manager();
753 } 756 }
754 757
755 FramebufferManager* framebuffer_manager() { 758 FramebufferManager* framebuffer_manager() {
756 return group_->framebuffer_manager(); 759 return group_->framebuffer_manager();
757 } 760 }
758 761
762 ValuebufferManager* valuebuffer_manager() {
763 return group_->valuebuffer_manager();
764 }
765
759 ProgramManager* program_manager() { 766 ProgramManager* program_manager() {
760 return group_->program_manager(); 767 return group_->program_manager();
761 } 768 }
762 769
763 ShaderManager* shader_manager() { 770 ShaderManager* shader_manager() {
764 return group_->shader_manager(); 771 return group_->shader_manager();
765 } 772 }
766 773
767 ShaderTranslatorCache* shader_translator_cache() { 774 ShaderTranslatorCache* shader_translator_cache() {
768 return group_->shader_translator_cache(); 775 return group_->shader_translator_cache();
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); 944 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key);
938 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, 945 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target,
939 const GLbyte* key); 946 const GLbyte* key);
940 void ProduceTextureRef(std::string func_name, TextureRef* texture_ref, 947 void ProduceTextureRef(std::string func_name, TextureRef* texture_ref,
941 GLenum target, const GLbyte* data); 948 GLenum target, const GLbyte* data);
942 949
943 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); 950 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key);
944 void DoCreateAndConsumeTextureCHROMIUM(GLenum target, const GLbyte* key, 951 void DoCreateAndConsumeTextureCHROMIUM(GLenum target, const GLbyte* key,
945 GLuint client_id); 952 GLuint client_id);
946 953
954 bool DoIsValuebufferCHROMIUM(GLuint client_id);
955 void DoBindValueBufferCHROMIUM(GLenum target, GLuint valuebuffer);
956 void DoSubscribeValueCHROMIUM(GLenum target, GLenum subscription);
957 void DoPopulateSubscribedValuesCHROMIUM(GLenum target);
958 void DoUniformValueBufferCHROMIUM(GLint location,
959 GLenum target,
960 GLenum subscription);
961
947 void DoBindTexImage2DCHROMIUM( 962 void DoBindTexImage2DCHROMIUM(
948 GLenum target, 963 GLenum target,
949 GLint image_id); 964 GLint image_id);
950 void DoReleaseTexImage2DCHROMIUM( 965 void DoReleaseTexImage2DCHROMIUM(
951 GLenum target, 966 GLenum target,
952 GLint image_id); 967 GLint image_id);
953 968
954 void DoTraceEndCHROMIUM(void); 969 void DoTraceEndCHROMIUM(void);
955 970
956 void DoDrawBuffersEXT(GLsizei count, const GLenum* bufs); 971 void DoDrawBuffersEXT(GLsizei count, const GLenum* bufs);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 // Gets the renderbuffer info for the given renderbuffer. 1104 // Gets the renderbuffer info for the given renderbuffer.
1090 Renderbuffer* GetRenderbuffer(GLuint client_id) { 1105 Renderbuffer* GetRenderbuffer(GLuint client_id) {
1091 return renderbuffer_manager()->GetRenderbuffer(client_id); 1106 return renderbuffer_manager()->GetRenderbuffer(client_id);
1092 } 1107 }
1093 1108
1094 // Removes the renderbuffer info for the given renderbuffer. 1109 // Removes the renderbuffer info for the given renderbuffer.
1095 void RemoveRenderbuffer(GLuint client_id) { 1110 void RemoveRenderbuffer(GLuint client_id) {
1096 renderbuffer_manager()->RemoveRenderbuffer(client_id); 1111 renderbuffer_manager()->RemoveRenderbuffer(client_id);
1097 } 1112 }
1098 1113
1114 // Creates a valuebuffer info for the given valuebuffer.
1115 void CreateValuebuffer(GLuint client_id) {
1116 return valuebuffer_manager()->CreateValuebuffer(client_id);
1117 }
1118
1119 // Gets the valuebuffer info for a given valuebuffer.
1120 Valuebuffer* GetValuebuffer(GLuint client_id) {
1121 return valuebuffer_manager()->GetValuebuffer(client_id);
1122 }
1123
1124 // Removes the valuebuffer info for the given valuebuffer.
1125 void RemoveValuebuffer(GLuint client_id) {
1126 valuebuffer_manager()->RemoveValuebuffer(client_id);
1127 }
1128
1099 // Gets the vertex attrib manager for the given vertex array. 1129 // Gets the vertex attrib manager for the given vertex array.
1100 VertexAttribManager* GetVertexAttribManager(GLuint client_id) { 1130 VertexAttribManager* GetVertexAttribManager(GLuint client_id) {
1101 VertexAttribManager* info = 1131 VertexAttribManager* info =
1102 vertex_array_manager()->GetVertexAttribManager(client_id); 1132 vertex_array_manager()->GetVertexAttribManager(client_id);
1103 return info; 1133 return info;
1104 } 1134 }
1105 1135
1106 // Removes the vertex attrib manager for the given vertex array. 1136 // Removes the vertex attrib manager for the given vertex array.
1107 void RemoveVertexAttribManager(GLuint client_id) { 1137 void RemoveVertexAttribManager(GLuint client_id) {
1108 vertex_array_manager()->RemoveVertexAttribManager(client_id); 1138 vertex_array_manager()->RemoveVertexAttribManager(client_id);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 // Check that the currently bound read framebuffer's color image 1200 // Check that the currently bound read framebuffer's color image
1171 // isn't the target texture of the glCopyTex{Sub}Image2D. 1201 // isn't the target texture of the glCopyTex{Sub}Image2D.
1172 bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level); 1202 bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level);
1173 1203
1174 // Check if a framebuffer meets our requirements. 1204 // Check if a framebuffer meets our requirements.
1175 bool CheckFramebufferValid( 1205 bool CheckFramebufferValid(
1176 Framebuffer* framebuffer, 1206 Framebuffer* framebuffer,
1177 GLenum target, 1207 GLenum target,
1178 const char* func_name); 1208 const char* func_name);
1179 1209
1210 // Check if the current valuebuffer exists and is valid. If not generates
1211 // the appropriate GL error. Returns true if the current valuebuffer is in
1212 // a usable state.
1213 bool CheckCurrentValuebuffer(const char* function_name);
1214
1215 // Check if the current valuebuffer exists and is valiud and that the
1216 // value buffer is actually subscribed to the given subscription
1217 bool CheckCurrentValuebufferForSubscription(GLenum subscription,
1218 const char* function_name);
1219
1220 // Check if the location can be used for the given subscription target. If not
1221 // generates the appropriate GL error. Returns true if the location is usable
1222 bool CheckSubscriptionTarget(GLint location,
1223 GLenum subscription,
1224 const char* function_name);
1225
1180 // Checks if the current program exists and is valid. If not generates the 1226 // Checks if the current program exists and is valid. If not generates the
1181 // appropriate GL error. Returns true if the current program is in a usable 1227 // appropriate GL error. Returns true if the current program is in a usable
1182 // state. 1228 // state.
1183 bool CheckCurrentProgram(const char* function_name); 1229 bool CheckCurrentProgram(const char* function_name);
1184 1230
1185 // Checks if the current program exists and is valid and that location is not 1231 // Checks if the current program exists and is valid and that location is not
1186 // -1. If the current program is not valid generates the appropriate GL 1232 // -1. If the current program is not valid generates the appropriate GL
1187 // error. Returns true if the current program is in a usable state and 1233 // error. Returns true if the current program is in a usable state and
1188 // location is not -1. 1234 // location is not -1.
1189 bool CheckCurrentProgramForUniform(GLint location, const char* function_name); 1235 bool CheckCurrentProgramForUniform(GLint location, const char* function_name);
1190 1236
1191 // Checks if the current program samples a texture that is also the color 1237 // Checks if the current program samples a texture that is also the color
1192 // image of the current bound framebuffer, i.e., the source and destination 1238 // image of the current bound framebuffer, i.e., the source and destination
1193 // of the draw operation are the same. 1239 // of the draw operation are the same.
1194 bool CheckDrawingFeedbackLoops(); 1240 bool CheckDrawingFeedbackLoops();
1195 1241
1242 // Checks if |api_type| is valid for the given uniform
1243 // If the api type is not valid generates the appropriate GL
1244 // error. Returns true if |api_type| is valid for the uniform
1245 bool CheckUniformForApiType(const Program::UniformInfo* info,
1246 const char* function_name,
1247 Program::UniformApiType api_type);
1248
1196 // Gets the type of a uniform for a location in the current program. Sets GL 1249 // Gets the type of a uniform for a location in the current program. Sets GL
1197 // errors if the current program is not valid. Returns true if the current 1250 // errors if the current program is not valid. Returns true if the current
1198 // program is valid and the location exists. Adjusts count so it 1251 // program is valid and the location exists. Adjusts count so it
1199 // does not overflow the uniform. 1252 // does not overflow the uniform.
1200 bool PrepForSetUniformByLocation(GLint fake_location, 1253 bool PrepForSetUniformByLocation(GLint fake_location,
1201 const char* function_name, 1254 const char* function_name,
1202 Program::UniformApiType api_type, 1255 Program::UniformApiType api_type,
1203 GLint* real_location, 1256 GLint* real_location,
1204 GLenum* type, 1257 GLenum* type,
1205 GLsizei* count); 1258 GLsizei* count);
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after
2663 2716
2664 // Set all the default state because some GL drivers get it wrong. 2717 // Set all the default state because some GL drivers get it wrong.
2665 state_.InitCapabilities(NULL); 2718 state_.InitCapabilities(NULL);
2666 state_.InitState(NULL); 2719 state_.InitState(NULL);
2667 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); 2720 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit);
2668 2721
2669 DoBindBuffer(GL_ARRAY_BUFFER, 0); 2722 DoBindBuffer(GL_ARRAY_BUFFER, 0);
2670 DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); 2723 DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
2671 DoBindFramebuffer(GL_FRAMEBUFFER, 0); 2724 DoBindFramebuffer(GL_FRAMEBUFFER, 0);
2672 DoBindRenderbuffer(GL_RENDERBUFFER, 0); 2725 DoBindRenderbuffer(GL_RENDERBUFFER, 0);
2726 DoBindValueBufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 0);
2673 2727
2674 bool call_gl_clear = !surfaceless_; 2728 bool call_gl_clear = !surfaceless_;
2675 #if defined(OS_ANDROID) 2729 #if defined(OS_ANDROID)
2676 // Temporary workaround for Android WebView because this clear ignores the 2730 // Temporary workaround for Android WebView because this clear ignores the
2677 // clip and corrupts that external UI of the App. Not calling glClear is ok 2731 // clip and corrupts that external UI of the App. Not calling glClear is ok
2678 // because the system already clears the buffer before each draw. Proper 2732 // because the system already clears the buffer before each draw. Proper
2679 // fix might be setting the scissor clip properly before initialize. See 2733 // fix might be setting the scissor clip properly before initialize. See
2680 // crbug.com/259023 for details. 2734 // crbug.com/259023 for details.
2681 call_gl_clear = surface_->GetHandle(); 2735 call_gl_clear = surface_->GetHandle();
2682 #endif 2736 #endif
(...skipping 29 matching lines...) Expand all
2712 2766
2713 framebuffer_manager()->AddObserver(this); 2767 framebuffer_manager()->AddObserver(this);
2714 2768
2715 return true; 2769 return true;
2716 } 2770 }
2717 2771
2718 Capabilities GLES2DecoderImpl::GetCapabilities() { 2772 Capabilities GLES2DecoderImpl::GetCapabilities() {
2719 DCHECK(initialized()); 2773 DCHECK(initialized());
2720 2774
2721 Capabilities caps; 2775 Capabilities caps;
2776 caps.VisitPrecisions([](GLenum shader, GLenum type,
2777 Capabilities::ShaderPrecision* shader_precision) {
2778 GLint range[2] = {0, 0};
2779 GLint precision = 0;
2780 GetShaderPrecisionFormatImpl(shader, type, range, &precision);
2781 shader_precision->min_range = range[0];
2782 shader_precision->max_range = range[1];
2783 shader_precision->precision = precision;
2784 });
2785 DoGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
2786 &caps.max_combined_texture_image_units);
2787 DoGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &caps.max_cube_map_texture_size);
2788 DoGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS,
2789 &caps.max_fragment_uniform_vectors);
2790 DoGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &caps.max_renderbuffer_size);
2791 DoGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &caps.max_texture_image_units);
2792 DoGetIntegerv(GL_MAX_TEXTURE_SIZE, &caps.max_texture_size);
2793 DoGetIntegerv(GL_MAX_VARYING_VECTORS, &caps.max_varying_vectors);
2794 DoGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &caps.max_vertex_attribs);
2795 DoGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS,
2796 &caps.max_vertex_texture_image_units);
2797 DoGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS,
2798 &caps.max_vertex_uniform_vectors);
2799 DoGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS,
2800 &caps.num_compressed_texture_formats);
2801 DoGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &caps.num_shader_binary_formats);
2802 DoGetIntegerv(GL_BIND_GENERATES_RESOURCE_CHROMIUM,
2803 &caps.bind_generates_resource_chromium);
2722 2804
2723 caps.egl_image_external = 2805 caps.egl_image_external =
2724 feature_info_->feature_flags().oes_egl_image_external; 2806 feature_info_->feature_flags().oes_egl_image_external;
2725 caps.texture_format_bgra8888 = 2807 caps.texture_format_bgra8888 =
2726 feature_info_->feature_flags().ext_texture_format_bgra8888; 2808 feature_info_->feature_flags().ext_texture_format_bgra8888;
2727 caps.texture_format_etc1 = 2809 caps.texture_format_etc1 =
2728 feature_info_->feature_flags().oes_compressed_etc1_rgb8_texture; 2810 feature_info_->feature_flags().oes_compressed_etc1_rgb8_texture;
2729 caps.texture_format_etc1_npot = 2811 caps.texture_format_etc1_npot =
2730 caps.texture_format_etc1 && !workarounds().etc1_power_of_two_only; 2812 caps.texture_format_etc1 && !workarounds().etc1_power_of_two_only;
2731 caps.texture_rectangle = feature_info_->feature_flags().arb_texture_rectangle; 2813 caps.texture_rectangle = feature_info_->feature_flags().arb_texture_rectangle;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2900 } 2982 }
2901 } 2983 }
2902 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); 2984 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
2903 glGenRenderbuffersEXT(n, service_ids.get()); 2985 glGenRenderbuffersEXT(n, service_ids.get());
2904 for (GLsizei ii = 0; ii < n; ++ii) { 2986 for (GLsizei ii = 0; ii < n; ++ii) {
2905 CreateRenderbuffer(client_ids[ii], service_ids[ii]); 2987 CreateRenderbuffer(client_ids[ii], service_ids[ii]);
2906 } 2988 }
2907 return true; 2989 return true;
2908 } 2990 }
2909 2991
2992 bool GLES2DecoderImpl::GenValuebuffersCHROMIUMHelper(GLsizei n,
2993 const GLuint* client_ids) {
2994 for (GLsizei ii = 0; ii < n; ++ii) {
2995 if (GetValuebuffer(client_ids[ii])) {
2996 return false;
2997 }
2998 }
2999 for (GLsizei ii = 0; ii < n; ++ii) {
3000 CreateValuebuffer(client_ids[ii]);
3001 }
3002 return true;
3003 }
3004
2910 bool GLES2DecoderImpl::GenTexturesHelper(GLsizei n, const GLuint* client_ids) { 3005 bool GLES2DecoderImpl::GenTexturesHelper(GLsizei n, const GLuint* client_ids) {
2911 for (GLsizei ii = 0; ii < n; ++ii) { 3006 for (GLsizei ii = 0; ii < n; ++ii) {
2912 if (GetTexture(client_ids[ii])) { 3007 if (GetTexture(client_ids[ii])) {
2913 return false; 3008 return false;
2914 } 3009 }
2915 } 3010 }
2916 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); 3011 scoped_ptr<GLuint[]> service_ids(new GLuint[n]);
2917 glGenTextures(n, service_ids.get()); 3012 glGenTextures(n, service_ids.get());
2918 for (GLsizei ii = 0; ii < n; ++ii) { 3013 for (GLsizei ii = 0; ii < n; ++ii) {
2919 CreateTexture(client_ids[ii], service_ids[ii]); 3014 CreateTexture(client_ids[ii], service_ids[ii]);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2989 framebuffer_state_.bound_draw_framebuffer 3084 framebuffer_state_.bound_draw_framebuffer
2990 ->UnbindRenderbuffer(GL_FRAMEBUFFER, renderbuffer); 3085 ->UnbindRenderbuffer(GL_FRAMEBUFFER, renderbuffer);
2991 } 3086 }
2992 } 3087 }
2993 framebuffer_state_.clear_state_dirty = true; 3088 framebuffer_state_.clear_state_dirty = true;
2994 RemoveRenderbuffer(client_ids[ii]); 3089 RemoveRenderbuffer(client_ids[ii]);
2995 } 3090 }
2996 } 3091 }
2997 } 3092 }
2998 3093
3094 void GLES2DecoderImpl::DeleteValuebuffersCHROMIUMHelper(
3095 GLsizei n,
3096 const GLuint* client_ids) {
3097 for (GLsizei ii = 0; ii < n; ++ii) {
3098 Valuebuffer* valuebuffer = GetValuebuffer(client_ids[ii]);
3099 if (valuebuffer) {
3100 if (state_.bound_valuebuffer.get() == valuebuffer) {
3101 state_.bound_valuebuffer = NULL;
3102 }
3103 RemoveValuebuffer(client_ids[ii]);
3104 }
3105 }
3106 }
3107
2999 void GLES2DecoderImpl::DeleteTexturesHelper( 3108 void GLES2DecoderImpl::DeleteTexturesHelper(
3000 GLsizei n, const GLuint* client_ids) { 3109 GLsizei n, const GLuint* client_ids) {
3001 bool supports_separate_framebuffer_binds = 3110 bool supports_separate_framebuffer_binds =
3002 features().chromium_framebuffer_multisample; 3111 features().chromium_framebuffer_multisample;
3003 for (GLsizei ii = 0; ii < n; ++ii) { 3112 for (GLsizei ii = 0; ii < n; ++ii) {
3004 TextureRef* texture_ref = GetTexture(client_ids[ii]); 3113 TextureRef* texture_ref = GetTexture(client_ids[ii]);
3005 if (texture_ref) { 3114 if (texture_ref) {
3006 Texture* texture = texture_ref->texture(); 3115 Texture* texture = texture_ref->texture();
3007 if (texture->IsAttachedToFramebuffer()) { 3116 if (texture->IsAttachedToFramebuffer()) {
3008 framebuffer_state_.clear_state_dirty = true; 3117 framebuffer_state_.clear_state_dirty = true;
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
3418 3527
3419 // Unbind everything. 3528 // Unbind everything.
3420 state_.vertex_attrib_manager = NULL; 3529 state_.vertex_attrib_manager = NULL;
3421 state_.default_vertex_attrib_manager = NULL; 3530 state_.default_vertex_attrib_manager = NULL;
3422 state_.texture_units.clear(); 3531 state_.texture_units.clear();
3423 state_.bound_array_buffer = NULL; 3532 state_.bound_array_buffer = NULL;
3424 state_.current_queries.clear(); 3533 state_.current_queries.clear();
3425 framebuffer_state_.bound_read_framebuffer = NULL; 3534 framebuffer_state_.bound_read_framebuffer = NULL;
3426 framebuffer_state_.bound_draw_framebuffer = NULL; 3535 framebuffer_state_.bound_draw_framebuffer = NULL;
3427 state_.bound_renderbuffer = NULL; 3536 state_.bound_renderbuffer = NULL;
3537 state_.bound_valuebuffer = NULL;
3428 3538
3429 if (offscreen_saved_color_texture_info_.get()) { 3539 if (offscreen_saved_color_texture_info_.get()) {
3430 DCHECK(offscreen_target_color_texture_); 3540 DCHECK(offscreen_target_color_texture_);
3431 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(), 3541 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(),
3432 offscreen_saved_color_texture_->id()); 3542 offscreen_saved_color_texture_->id());
3433 offscreen_saved_color_texture_->Invalidate(); 3543 offscreen_saved_color_texture_->Invalidate();
3434 offscreen_saved_color_texture_info_ = NULL; 3544 offscreen_saved_color_texture_info_ = NULL;
3435 } 3545 }
3436 if (have_context) { 3546 if (have_context) {
3437 if (copy_texture_CHROMIUM_.get()) { 3547 if (copy_texture_CHROMIUM_.get()) {
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
3909 GLuint service_id = glCreateShader(type); 4019 GLuint service_id = glCreateShader(type);
3910 if (service_id != 0) { 4020 if (service_id != 0) {
3911 CreateShader(client_id, service_id, type); 4021 CreateShader(client_id, service_id, type);
3912 } 4022 }
3913 return true; 4023 return true;
3914 } 4024 }
3915 4025
3916 void GLES2DecoderImpl::DoFinish() { 4026 void GLES2DecoderImpl::DoFinish() {
3917 glFinish(); 4027 glFinish();
3918 ProcessPendingReadPixels(); 4028 ProcessPendingReadPixels();
3919 ProcessPendingQueries(); 4029 ProcessPendingQueries(true);
3920 } 4030 }
3921 4031
3922 void GLES2DecoderImpl::DoFlush() { 4032 void GLES2DecoderImpl::DoFlush() {
3923 glFlush(); 4033 glFlush();
3924 ProcessPendingQueries(); 4034 ProcessPendingQueries(false);
3925 } 4035 }
3926 4036
3927 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) { 4037 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) {
3928 GLuint texture_index = texture_unit - GL_TEXTURE0; 4038 GLuint texture_index = texture_unit - GL_TEXTURE0;
3929 if (texture_index >= state_.texture_units.size()) { 4039 if (texture_index >= state_.texture_units.size()) {
3930 LOCAL_SET_GL_ERROR_INVALID_ENUM( 4040 LOCAL_SET_GL_ERROR_INVALID_ENUM(
3931 "glActiveTexture", texture_unit, "texture_unit"); 4041 "glActiveTexture", texture_unit, "texture_unit");
3932 return; 4042 return;
3933 } 4043 }
3934 state_.active_texture_unit = texture_index; 4044 state_.active_texture_unit = texture_index;
(...skipping 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after
5715 if (!texture) { 5825 if (!texture) {
5716 LOCAL_SET_GL_ERROR( 5826 LOCAL_SET_GL_ERROR(
5717 GL_INVALID_VALUE, "glTexParameteriv", "unknown texture"); 5827 GL_INVALID_VALUE, "glTexParameteriv", "unknown texture");
5718 return; 5828 return;
5719 } 5829 }
5720 5830
5721 texture_manager()->SetParameteri( 5831 texture_manager()->SetParameteri(
5722 "glTexParameteriv", GetErrorState(), texture, pname, *params); 5832 "glTexParameteriv", GetErrorState(), texture, pname, *params);
5723 } 5833 }
5724 5834
5835 bool GLES2DecoderImpl::CheckCurrentValuebuffer(const char* function_name) {
5836 if (!state_.bound_valuebuffer.get()) {
5837 // There is no valuebuffer bound
5838 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
5839 "no valuebuffer in use");
5840 return false;
5841 }
5842 return true;
5843 }
5844
5845 bool GLES2DecoderImpl::CheckCurrentValuebufferForSubscription(
5846 GLenum subscription,
5847 const char* function_name) {
5848 if (!CheckCurrentValuebuffer(function_name)) {
5849 return false;
5850 }
5851 if (!state_.bound_valuebuffer.get()->IsSubscribed(subscription)) {
5852 // The valuebuffer is not subscribed to the target
5853 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
5854 "valuebuffer is not subscribed");
5855 return false;
5856 }
5857 return true;
5858 }
5859
5860 bool GLES2DecoderImpl::CheckSubscriptionTarget(GLint location,
5861 GLenum subscription,
5862 const char* function_name) {
5863 if (!CheckCurrentProgramForUniform(location, function_name)) {
5864 return false;
5865 }
5866 GLint real_location = -1;
5867 GLint array_index = -1;
5868 const Program::UniformInfo* info =
5869 state_.current_program->GetUniformInfoByFakeLocation(
5870 location, &real_location, &array_index);
5871 if (!info) {
5872 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, "unknown location");
5873 return false;
5874 }
5875 if ((ValuebufferManager::ApiTypeForSubscriptionTarget(subscription) &
5876 info->accepts_api_type) == 0) {
5877 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
5878 "wrong type for subscription");
5879 return false;
5880 }
5881 return true;
5882 }
5883
5725 bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) { 5884 bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) {
5726 if (!state_.current_program.get()) { 5885 if (!state_.current_program.get()) {
5727 // The program does not exist. 5886 // The program does not exist.
5728 LOCAL_SET_GL_ERROR( 5887 LOCAL_SET_GL_ERROR(
5729 GL_INVALID_OPERATION, function_name, "no program in use"); 5888 GL_INVALID_OPERATION, function_name, "no program in use");
5730 return false; 5889 return false;
5731 } 5890 }
5732 if (!state_.current_program->InUse()) { 5891 if (!state_.current_program->InUse()) {
5733 LOCAL_SET_GL_ERROR( 5892 LOCAL_SET_GL_ERROR(
5734 GL_INVALID_OPERATION, function_name, "program not linked"); 5893 GL_INVALID_OPERATION, function_name, "program not linked");
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5770 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; 5929 TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
5771 TextureRef* texture_ref = 5930 TextureRef* texture_ref =
5772 texture_unit.GetInfoForSamplerType(GL_SAMPLER_2D).get(); 5931 texture_unit.GetInfoForSamplerType(GL_SAMPLER_2D).get();
5773 if (attachment->IsTexture(texture_ref)) 5932 if (attachment->IsTexture(texture_ref))
5774 return true; 5933 return true;
5775 } 5934 }
5776 } 5935 }
5777 return false; 5936 return false;
5778 } 5937 }
5779 5938
5939 bool GLES2DecoderImpl::CheckUniformForApiType(
5940 const Program::UniformInfo* info,
5941 const char* function_name,
5942 Program::UniformApiType api_type) {
5943 DCHECK(info);
5944 if ((api_type & info->accepts_api_type) == 0) {
5945 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
5946 "wrong uniform function for type");
5947 return false;
5948 }
5949 return true;
5950 }
5951
5780 bool GLES2DecoderImpl::PrepForSetUniformByLocation( 5952 bool GLES2DecoderImpl::PrepForSetUniformByLocation(
5781 GLint fake_location, 5953 GLint fake_location,
5782 const char* function_name, 5954 const char* function_name,
5783 Program::UniformApiType api_type, 5955 Program::UniformApiType api_type,
5784 GLint* real_location, 5956 GLint* real_location,
5785 GLenum* type, 5957 GLenum* type,
5786 GLsizei* count) { 5958 GLsizei* count) {
5787 DCHECK(type); 5959 DCHECK(type);
5788 DCHECK(count); 5960 DCHECK(count);
5789 DCHECK(real_location); 5961 DCHECK(real_location);
5790 5962
5791 if (!CheckCurrentProgramForUniform(fake_location, function_name)) { 5963 if (!CheckCurrentProgramForUniform(fake_location, function_name)) {
5792 return false; 5964 return false;
5793 } 5965 }
5794 GLint array_index = -1; 5966 GLint array_index = -1;
5795 const Program::UniformInfo* info = 5967 const Program::UniformInfo* info =
5796 state_.current_program->GetUniformInfoByFakeLocation( 5968 state_.current_program->GetUniformInfoByFakeLocation(
5797 fake_location, real_location, &array_index); 5969 fake_location, real_location, &array_index);
5798 if (!info) { 5970 if (!info) {
5799 LOCAL_SET_GL_ERROR( 5971 LOCAL_SET_GL_ERROR(
5800 GL_INVALID_OPERATION, function_name, "unknown location"); 5972 GL_INVALID_OPERATION, function_name, "unknown location");
5801 return false; 5973 return false;
5802 } 5974 }
5803 5975 if (!CheckUniformForApiType(info, function_name, api_type)) {
5804 if ((api_type & info->accepts_api_type) == 0) {
5805 LOCAL_SET_GL_ERROR(
5806 GL_INVALID_OPERATION, function_name,
5807 "wrong uniform function for type");
5808 return false; 5976 return false;
5809 } 5977 }
5810 if (*count > 1 && !info->is_array) { 5978 if (*count > 1 && !info->is_array) {
5811 LOCAL_SET_GL_ERROR( 5979 LOCAL_SET_GL_ERROR(
5812 GL_INVALID_OPERATION, function_name, "count > 1 for non-array"); 5980 GL_INVALID_OPERATION, function_name, "count > 1 for non-array");
5813 return false; 5981 return false;
5814 } 5982 }
5815 *count = std::min(info->size - array_index, *count); 5983 *count = std::min(info->size - array_index, *count);
5816 if (*count <= 0) { 5984 if (*count <= 0) {
5817 return false; 5985 return false;
(...skipping 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after
7601 7769
7602 // If the row is in range, copy it. 7770 // If the row is in range, copy it.
7603 if (ry >= 0 && ry < max_size.height() && read_width > 0) { 7771 if (ry >= 0 && ry < max_size.height() && read_width > 0) {
7604 glReadPixels( 7772 glReadPixels(
7605 read_x, ry, read_width, 1, format, type, dst + dest_row_offset); 7773 read_x, ry, read_width, 1, format, type, dst + dest_row_offset);
7606 } 7774 }
7607 dst += padded_row_size; 7775 dst += padded_row_size;
7608 } 7776 }
7609 } else { 7777 } else {
7610 if (async && features().use_async_readpixels) { 7778 if (async && features().use_async_readpixels) {
7611 GLuint buffer; 7779 GLuint buffer = 0;
7612 glGenBuffersARB(1, &buffer); 7780 glGenBuffersARB(1, &buffer);
7613 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, buffer); 7781 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, buffer);
7614 glBufferData(GL_PIXEL_PACK_BUFFER_ARB, pixels_size, NULL, GL_STREAM_READ); 7782 glBufferData(GL_PIXEL_PACK_BUFFER_ARB, pixels_size, NULL, GL_STREAM_READ);
7615 GLenum error = glGetError(); 7783 GLenum error = glGetError();
7616 if (error == GL_NO_ERROR) { 7784 if (error == GL_NO_ERROR) {
7617 glReadPixels(x, y, width, height, format, type, 0); 7785 glReadPixels(x, y, width, height, format, type, 0);
7618 pending_readpixel_fences_.push(linked_ptr<FenceCallback>( 7786 pending_readpixel_fences_.push(linked_ptr<FenceCallback>(
7619 new FenceCallback())); 7787 new FenceCallback()));
7620 WaitForReadPixels(base::Bind( 7788 WaitForReadPixels(base::Bind(
7621 &GLES2DecoderImpl::FinishReadPixels, 7789 &GLES2DecoderImpl::FinishReadPixels,
7622 base::internal::SupportsWeakPtrBase::StaticAsWeakPtr 7790 base::internal::SupportsWeakPtrBase::StaticAsWeakPtr
7623 <GLES2DecoderImpl>(this), 7791 <GLES2DecoderImpl>(this),
7624 c, buffer)); 7792 c, buffer));
7625 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); 7793 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
7626 return error::kNoError; 7794 return error::kNoError;
7627 } else { 7795 } else {
7628 // On error, unbind pack buffer and fall through to sync readpixels 7796 // On error, unbind pack buffer and fall through to sync readpixels
7629 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0); 7797 glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
7798 glDeleteBuffersARB(1, &buffer);
7630 } 7799 }
7631 } 7800 }
7632 glReadPixels(x, y, width, height, format, type, pixels); 7801 glReadPixels(x, y, width, height, format, type, pixels);
7633 } 7802 }
7634 GLenum error = LOCAL_PEEK_GL_ERROR("glReadPixels"); 7803 GLenum error = LOCAL_PEEK_GL_ERROR("glReadPixels");
7635 if (error == GL_NO_ERROR) { 7804 if (error == GL_NO_ERROR) {
7636 if (result != NULL) { 7805 if (result != NULL) {
7637 *result = true; 7806 *result = true;
7638 } 7807 }
7639 FinishReadPixels(c, 0); 7808 FinishReadPixels(c, 0);
(...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after
9565 draw_buffers_explicitly_enabled_ |= desire_draw_buffers; 9734 draw_buffers_explicitly_enabled_ |= desire_draw_buffers;
9566 shader_texture_lod_explicitly_enabled_ |= desire_shader_texture_lod; 9735 shader_texture_lod_explicitly_enabled_ |= desire_shader_texture_lod;
9567 InitializeShaderTranslator(); 9736 InitializeShaderTranslator();
9568 } 9737 }
9569 9738
9570 UpdateCapabilities(); 9739 UpdateCapabilities();
9571 9740
9572 return error::kNoError; 9741 return error::kNoError;
9573 } 9742 }
9574 9743
9575 error::Error GLES2DecoderImpl::HandleGetMultipleIntegervCHROMIUM(
9576 uint32 immediate_data_size,
9577 const void* cmd_data) {
9578 const gles2::cmds::GetMultipleIntegervCHROMIUM& c =
9579 *static_cast<const gles2::cmds::GetMultipleIntegervCHROMIUM*>(cmd_data);
9580 GLuint count = c.count;
9581 uint32 pnames_size;
9582 if (!SafeMultiplyUint32(count, sizeof(GLenum), &pnames_size)) {
9583 return error::kOutOfBounds;
9584 }
9585 const GLenum* pnames = GetSharedMemoryAs<const GLenum*>(
9586 c.pnames_shm_id, c.pnames_shm_offset, pnames_size);
9587 if (pnames == NULL) {
9588 return error::kOutOfBounds;
9589 }
9590
9591 // We have to copy them since we use them twice so the client
9592 // can't change them between the time we validate them and the time we use
9593 // them.
9594 scoped_ptr<GLenum[]> enums(new GLenum[count]);
9595 memcpy(enums.get(), pnames, pnames_size);
9596
9597 // Count up the space needed for the result.
9598 uint32 num_results = 0;
9599 for (GLuint ii = 0; ii < count; ++ii) {
9600 uint32 num = util_.GLGetNumValuesReturned(enums[ii]);
9601 if (num == 0) {
9602 LOCAL_SET_GL_ERROR_INVALID_ENUM(
9603 "glGetMultipleCHROMIUM", enums[ii], "pname");
9604 return error::kNoError;
9605 }
9606 // Num will never be more than 4.
9607 DCHECK_LE(num, 4u);
9608 if (!SafeAddUint32(num_results, num, &num_results)) {
9609 return error::kOutOfBounds;
9610 }
9611 }
9612
9613 uint32 result_size = 0;
9614 if (!SafeMultiplyUint32(num_results, sizeof(GLint), &result_size)) {
9615 return error::kOutOfBounds;
9616 }
9617
9618 if (result_size != static_cast<uint32>(c.size)) {
9619 LOCAL_SET_GL_ERROR(
9620 GL_INVALID_VALUE,
9621 "glGetMultipleCHROMIUM", "bad size GL_INVALID_VALUE");
9622 return error::kNoError;
9623 }
9624
9625 GLint* results = GetSharedMemoryAs<GLint*>(
9626 c.results_shm_id, c.results_shm_offset, result_size);
9627 if (results == NULL) {
9628 return error::kOutOfBounds;
9629 }
9630
9631 // Check the results have been cleared in case the context was lost.
9632 for (uint32 ii = 0; ii < num_results; ++ii) {
9633 if (results[ii]) {
9634 return error::kInvalidArguments;
9635 }
9636 }
9637
9638 // Get each result.
9639 GLint* start = results;
9640 for (GLuint ii = 0; ii < count; ++ii) {
9641 GLsizei num_written = 0;
9642 if (!state_.GetStateAsGLint(enums[ii], results, &num_written) &&
9643 !GetHelper(enums[ii], results, &num_written)) {
9644 DoGetIntegerv(enums[ii], results);
9645 }
9646 results += num_written;
9647 }
9648
9649 // Just to verify. Should this be a DCHECK?
9650 if (static_cast<uint32>(results - start) != num_results) {
9651 return error::kOutOfBounds;
9652 }
9653
9654 return error::kNoError;
9655 }
9656
9657 error::Error GLES2DecoderImpl::HandleGetProgramInfoCHROMIUM( 9744 error::Error GLES2DecoderImpl::HandleGetProgramInfoCHROMIUM(
9658 uint32 immediate_data_size, 9745 uint32 immediate_data_size,
9659 const void* cmd_data) { 9746 const void* cmd_data) {
9660 const gles2::cmds::GetProgramInfoCHROMIUM& c = 9747 const gles2::cmds::GetProgramInfoCHROMIUM& c =
9661 *static_cast<const gles2::cmds::GetProgramInfoCHROMIUM*>(cmd_data); 9748 *static_cast<const gles2::cmds::GetProgramInfoCHROMIUM*>(cmd_data);
9662 GLuint program_id = static_cast<GLuint>(c.program); 9749 GLuint program_id = static_cast<GLuint>(c.program);
9663 uint32 bucket_id = c.bucket_id; 9750 uint32 bucket_id = c.bucket_id;
9664 Bucket* bucket = CreateBucket(bucket_id); 9751 Bucket* bucket = CreateBucket(bucket_id);
9665 bucket->SetSize(sizeof(ProgramInfoHeader)); // in case we fail. 9752 bucket->SetSize(sizeof(ProgramInfoHeader)); // in case we fail.
9666 Program* program = NULL; 9753 Program* program = NULL;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
9810 state_.current_queries.find(query->target()); 9897 state_.current_queries.find(query->target());
9811 if (it != state_.current_queries.end()) 9898 if (it != state_.current_queries.end())
9812 state_.current_queries.erase(it); 9899 state_.current_queries.erase(it);
9813 9900
9814 query->Destroy(true); 9901 query->Destroy(true);
9815 } 9902 }
9816 query_manager_->RemoveQuery(client_ids[ii]); 9903 query_manager_->RemoveQuery(client_ids[ii]);
9817 } 9904 }
9818 } 9905 }
9819 9906
9820 bool GLES2DecoderImpl::ProcessPendingQueries() { 9907 bool GLES2DecoderImpl::ProcessPendingQueries(bool did_finish) {
9821 if (query_manager_.get() == NULL) { 9908 if (query_manager_.get() == NULL) {
9822 return false; 9909 return false;
9823 } 9910 }
9824 if (!query_manager_->ProcessPendingQueries()) { 9911 if (!query_manager_->ProcessPendingQueries(did_finish)) {
9825 current_decoder_error_ = error::kOutOfBounds; 9912 current_decoder_error_ = error::kOutOfBounds;
9826 } 9913 }
9827 return query_manager_->HavePendingQueries(); 9914 return query_manager_->HavePendingQueries();
9828 } 9915 }
9829 9916
9830 // Note that if there are no pending readpixels right now, 9917 // Note that if there are no pending readpixels right now,
9831 // this function will call the callback immediately. 9918 // this function will call the callback immediately.
9832 void GLES2DecoderImpl::WaitForReadPixels(base::Closure callback) { 9919 void GLES2DecoderImpl::WaitForReadPixels(base::Closure callback) {
9833 if (features().use_async_readpixels && !pending_readpixel_fences_.empty()) { 9920 if (features().use_async_readpixels && !pending_readpixel_fences_.empty()) {
9834 pending_readpixel_fences_.back()->callbacks.push_back(callback); 9921 pending_readpixel_fences_.back()->callbacks.push_back(callback);
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
10689 if (texture->target() != target) { 10776 if (texture->target() != target) {
10690 LOCAL_SET_GL_ERROR( 10777 LOCAL_SET_GL_ERROR(
10691 GL_INVALID_OPERATION, 10778 GL_INVALID_OPERATION,
10692 "glCreateAndConsumeTextureCHROMIUM", "invalid target"); 10779 "glCreateAndConsumeTextureCHROMIUM", "invalid target");
10693 return; 10780 return;
10694 } 10781 }
10695 10782
10696 texture_ref = texture_manager()->Consume(client_id, texture); 10783 texture_ref = texture_manager()->Consume(client_id, texture);
10697 } 10784 }
10698 10785
10786 bool GLES2DecoderImpl::DoIsValuebufferCHROMIUM(GLuint client_id) {
10787 const Valuebuffer* valuebuffer = GetValuebuffer(client_id);
10788 return valuebuffer && valuebuffer->IsValid();
10789 }
10790
10791 void GLES2DecoderImpl::DoBindValueBufferCHROMIUM(GLenum target,
10792 GLuint client_id) {
10793 Valuebuffer* valuebuffer = NULL;
10794 if (client_id != 0) {
10795 valuebuffer = GetValuebuffer(client_id);
10796 if (!valuebuffer) {
10797 if (!group_->bind_generates_resource()) {
10798 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBindValuebufferCHROMIUM",
10799 "id not generated by glBindValuebufferCHROMIUM");
10800 return;
10801 }
10802
10803 // It's a new id so make a valuebuffer for it.
10804 CreateValuebuffer(client_id);
10805 valuebuffer = GetValuebuffer(client_id);
10806 }
10807 valuebuffer->MarkAsValid();
10808 }
10809 state_.bound_valuebuffer = valuebuffer;
10810 }
10811
10812 void GLES2DecoderImpl::DoSubscribeValueCHROMIUM(GLenum target,
10813 GLenum subscription) {
10814 if (!CheckCurrentValuebuffer("glSubscribeValueCHROMIUM")) {
10815 return;
10816 }
10817 state_.bound_valuebuffer.get()->AddSubscription(subscription);
10818 }
10819
10820 void GLES2DecoderImpl::DoPopulateSubscribedValuesCHROMIUM(GLenum target) {
10821 if (!CheckCurrentValuebuffer("glPopulateSubscribedValuesCHROMIUM")) {
10822 return;
10823 }
10824 valuebuffer_manager()->UpdateValuebufferState(state_.bound_valuebuffer.get());
10825 }
10826
10827 void GLES2DecoderImpl::DoUniformValueBufferCHROMIUM(GLint location,
10828 GLenum target,
10829 GLenum subscription) {
10830 if (!CheckCurrentValuebufferForSubscription(
10831 subscription, "glPopulateSubscribedValuesCHROMIUM")) {
10832 return;
10833 }
10834 if (!CheckSubscriptionTarget(location, subscription,
10835 "glPopulateSubscribedValuesCHROMIUM")) {
10836 return;
10837 }
10838 const ValueState* state =
10839 state_.bound_valuebuffer.get()->GetState(subscription);
10840 if (state) {
10841 switch (subscription) {
10842 case GL_MOUSE_POSITION_CHROMIUM:
10843 DoUniform2iv(location, 1, state->int_value);
10844 break;
10845 default:
10846 NOTREACHED() << "Unhandled uniform subscription target "
10847 << subscription;
10848 break;
10849 }
10850 }
10851 }
10852
10699 void GLES2DecoderImpl::DoInsertEventMarkerEXT( 10853 void GLES2DecoderImpl::DoInsertEventMarkerEXT(
10700 GLsizei length, const GLchar* marker) { 10854 GLsizei length, const GLchar* marker) {
10701 if (!marker) { 10855 if (!marker) {
10702 marker = ""; 10856 marker = "";
10703 } 10857 }
10704 debug_marker_manager_.SetMarker( 10858 debug_marker_manager_.SetMarker(
10705 length ? std::string(marker, length) : std::string(marker)); 10859 length ? std::string(marker, length) : std::string(marker));
10706 } 10860 }
10707 10861
10708 void GLES2DecoderImpl::DoPushGroupMarkerEXT( 10862 void GLES2DecoderImpl::DoPushGroupMarkerEXT(
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
11254 } 11408 }
11255 } 11409 }
11256 11410
11257 // Include the auto-generated part of this file. We split this because it means 11411 // Include the auto-generated part of this file. We split this because it means
11258 // we can easily edit the non-auto generated parts right here in this file 11412 // we can easily edit the non-auto generated parts right here in this file
11259 // instead of having to edit some template or the code generator. 11413 // instead of having to edit some template or the code generator.
11260 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 11414 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
11261 11415
11262 } // namespace gles2 11416 } // namespace gles2
11263 } // namespace gpu 11417 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.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