OLD | NEW |
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 Loading... |
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 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2900 } | 2954 } |
2901 } | 2955 } |
2902 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); | 2956 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); |
2903 glGenRenderbuffersEXT(n, service_ids.get()); | 2957 glGenRenderbuffersEXT(n, service_ids.get()); |
2904 for (GLsizei ii = 0; ii < n; ++ii) { | 2958 for (GLsizei ii = 0; ii < n; ++ii) { |
2905 CreateRenderbuffer(client_ids[ii], service_ids[ii]); | 2959 CreateRenderbuffer(client_ids[ii], service_ids[ii]); |
2906 } | 2960 } |
2907 return true; | 2961 return true; |
2908 } | 2962 } |
2909 | 2963 |
| 2964 bool GLES2DecoderImpl::GenValuebuffersCHROMIUMHelper(GLsizei n, |
| 2965 const GLuint* client_ids) { |
| 2966 for (GLsizei ii = 0; ii < n; ++ii) { |
| 2967 if (GetValuebuffer(client_ids[ii])) { |
| 2968 return false; |
| 2969 } |
| 2970 } |
| 2971 for (GLsizei ii = 0; ii < n; ++ii) { |
| 2972 CreateValuebuffer(client_ids[ii]); |
| 2973 } |
| 2974 return true; |
| 2975 } |
| 2976 |
2910 bool GLES2DecoderImpl::GenTexturesHelper(GLsizei n, const GLuint* client_ids) { | 2977 bool GLES2DecoderImpl::GenTexturesHelper(GLsizei n, const GLuint* client_ids) { |
2911 for (GLsizei ii = 0; ii < n; ++ii) { | 2978 for (GLsizei ii = 0; ii < n; ++ii) { |
2912 if (GetTexture(client_ids[ii])) { | 2979 if (GetTexture(client_ids[ii])) { |
2913 return false; | 2980 return false; |
2914 } | 2981 } |
2915 } | 2982 } |
2916 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); | 2983 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); |
2917 glGenTextures(n, service_ids.get()); | 2984 glGenTextures(n, service_ids.get()); |
2918 for (GLsizei ii = 0; ii < n; ++ii) { | 2985 for (GLsizei ii = 0; ii < n; ++ii) { |
2919 CreateTexture(client_ids[ii], service_ids[ii]); | 2986 CreateTexture(client_ids[ii], service_ids[ii]); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2989 framebuffer_state_.bound_draw_framebuffer | 3056 framebuffer_state_.bound_draw_framebuffer |
2990 ->UnbindRenderbuffer(GL_FRAMEBUFFER, renderbuffer); | 3057 ->UnbindRenderbuffer(GL_FRAMEBUFFER, renderbuffer); |
2991 } | 3058 } |
2992 } | 3059 } |
2993 framebuffer_state_.clear_state_dirty = true; | 3060 framebuffer_state_.clear_state_dirty = true; |
2994 RemoveRenderbuffer(client_ids[ii]); | 3061 RemoveRenderbuffer(client_ids[ii]); |
2995 } | 3062 } |
2996 } | 3063 } |
2997 } | 3064 } |
2998 | 3065 |
| 3066 void GLES2DecoderImpl::DeleteValuebuffersCHROMIUMHelper( |
| 3067 GLsizei n, |
| 3068 const GLuint* client_ids) { |
| 3069 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3070 Valuebuffer* valuebuffer = GetValuebuffer(client_ids[ii]); |
| 3071 if (valuebuffer) { |
| 3072 if (state_.bound_valuebuffer.get() == valuebuffer) { |
| 3073 state_.bound_valuebuffer = NULL; |
| 3074 } |
| 3075 RemoveValuebuffer(client_ids[ii]); |
| 3076 } |
| 3077 } |
| 3078 } |
| 3079 |
2999 void GLES2DecoderImpl::DeleteTexturesHelper( | 3080 void GLES2DecoderImpl::DeleteTexturesHelper( |
3000 GLsizei n, const GLuint* client_ids) { | 3081 GLsizei n, const GLuint* client_ids) { |
3001 bool supports_separate_framebuffer_binds = | 3082 bool supports_separate_framebuffer_binds = |
3002 features().chromium_framebuffer_multisample; | 3083 features().chromium_framebuffer_multisample; |
3003 for (GLsizei ii = 0; ii < n; ++ii) { | 3084 for (GLsizei ii = 0; ii < n; ++ii) { |
3004 TextureRef* texture_ref = GetTexture(client_ids[ii]); | 3085 TextureRef* texture_ref = GetTexture(client_ids[ii]); |
3005 if (texture_ref) { | 3086 if (texture_ref) { |
3006 Texture* texture = texture_ref->texture(); | 3087 Texture* texture = texture_ref->texture(); |
3007 if (texture->IsAttachedToFramebuffer()) { | 3088 if (texture->IsAttachedToFramebuffer()) { |
3008 framebuffer_state_.clear_state_dirty = true; | 3089 framebuffer_state_.clear_state_dirty = true; |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3418 | 3499 |
3419 // Unbind everything. | 3500 // Unbind everything. |
3420 state_.vertex_attrib_manager = NULL; | 3501 state_.vertex_attrib_manager = NULL; |
3421 state_.default_vertex_attrib_manager = NULL; | 3502 state_.default_vertex_attrib_manager = NULL; |
3422 state_.texture_units.clear(); | 3503 state_.texture_units.clear(); |
3423 state_.bound_array_buffer = NULL; | 3504 state_.bound_array_buffer = NULL; |
3424 state_.current_queries.clear(); | 3505 state_.current_queries.clear(); |
3425 framebuffer_state_.bound_read_framebuffer = NULL; | 3506 framebuffer_state_.bound_read_framebuffer = NULL; |
3426 framebuffer_state_.bound_draw_framebuffer = NULL; | 3507 framebuffer_state_.bound_draw_framebuffer = NULL; |
3427 state_.bound_renderbuffer = NULL; | 3508 state_.bound_renderbuffer = NULL; |
| 3509 state_.bound_valuebuffer = NULL; |
3428 | 3510 |
3429 if (offscreen_saved_color_texture_info_.get()) { | 3511 if (offscreen_saved_color_texture_info_.get()) { |
3430 DCHECK(offscreen_target_color_texture_); | 3512 DCHECK(offscreen_target_color_texture_); |
3431 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(), | 3513 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(), |
3432 offscreen_saved_color_texture_->id()); | 3514 offscreen_saved_color_texture_->id()); |
3433 offscreen_saved_color_texture_->Invalidate(); | 3515 offscreen_saved_color_texture_->Invalidate(); |
3434 offscreen_saved_color_texture_info_ = NULL; | 3516 offscreen_saved_color_texture_info_ = NULL; |
3435 } | 3517 } |
3436 if (have_context) { | 3518 if (have_context) { |
3437 if (copy_texture_CHROMIUM_.get()) { | 3519 if (copy_texture_CHROMIUM_.get()) { |
(...skipping 2277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5715 if (!texture) { | 5797 if (!texture) { |
5716 LOCAL_SET_GL_ERROR( | 5798 LOCAL_SET_GL_ERROR( |
5717 GL_INVALID_VALUE, "glTexParameteriv", "unknown texture"); | 5799 GL_INVALID_VALUE, "glTexParameteriv", "unknown texture"); |
5718 return; | 5800 return; |
5719 } | 5801 } |
5720 | 5802 |
5721 texture_manager()->SetParameteri( | 5803 texture_manager()->SetParameteri( |
5722 "glTexParameteriv", GetErrorState(), texture, pname, *params); | 5804 "glTexParameteriv", GetErrorState(), texture, pname, *params); |
5723 } | 5805 } |
5724 | 5806 |
| 5807 bool GLES2DecoderImpl::CheckCurrentValuebuffer(const char* function_name) { |
| 5808 if (!state_.bound_valuebuffer.get()) { |
| 5809 // There is no valuebuffer bound |
| 5810 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 5811 "no valuebuffer in use"); |
| 5812 return false; |
| 5813 } |
| 5814 return true; |
| 5815 } |
| 5816 |
| 5817 bool GLES2DecoderImpl::CheckCurrentValuebufferForSubscription( |
| 5818 GLenum subscription, |
| 5819 const char* function_name) { |
| 5820 if (!CheckCurrentValuebuffer(function_name)) { |
| 5821 return false; |
| 5822 } |
| 5823 if (!state_.bound_valuebuffer.get()->IsSubscribed(subscription)) { |
| 5824 // The valuebuffer is not subscribed to the target |
| 5825 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 5826 "valuebuffer is not subscribed"); |
| 5827 return false; |
| 5828 } |
| 5829 return true; |
| 5830 } |
| 5831 |
| 5832 bool GLES2DecoderImpl::CheckSubscriptionTarget(GLint location, |
| 5833 GLenum subscription, |
| 5834 const char* function_name) { |
| 5835 if (!CheckCurrentProgramForUniform(location, function_name)) { |
| 5836 return false; |
| 5837 } |
| 5838 GLint real_location = -1; |
| 5839 GLint array_index = -1; |
| 5840 const Program::UniformInfo* info = |
| 5841 state_.current_program->GetUniformInfoByFakeLocation( |
| 5842 location, &real_location, &array_index); |
| 5843 if (!info) { |
| 5844 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, "unknown location"); |
| 5845 return false; |
| 5846 } |
| 5847 if ((ValuebufferManager::ApiTypeForSubscriptionTarget(subscription) & |
| 5848 info->accepts_api_type) == 0) { |
| 5849 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 5850 "wrong type for subscription"); |
| 5851 return false; |
| 5852 } |
| 5853 return true; |
| 5854 } |
| 5855 |
5725 bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) { | 5856 bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) { |
5726 if (!state_.current_program.get()) { | 5857 if (!state_.current_program.get()) { |
5727 // The program does not exist. | 5858 // The program does not exist. |
5728 LOCAL_SET_GL_ERROR( | 5859 LOCAL_SET_GL_ERROR( |
5729 GL_INVALID_OPERATION, function_name, "no program in use"); | 5860 GL_INVALID_OPERATION, function_name, "no program in use"); |
5730 return false; | 5861 return false; |
5731 } | 5862 } |
5732 if (!state_.current_program->InUse()) { | 5863 if (!state_.current_program->InUse()) { |
5733 LOCAL_SET_GL_ERROR( | 5864 LOCAL_SET_GL_ERROR( |
5734 GL_INVALID_OPERATION, function_name, "program not linked"); | 5865 GL_INVALID_OPERATION, function_name, "program not linked"); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5770 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; | 5901 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
5771 TextureRef* texture_ref = | 5902 TextureRef* texture_ref = |
5772 texture_unit.GetInfoForSamplerType(GL_SAMPLER_2D).get(); | 5903 texture_unit.GetInfoForSamplerType(GL_SAMPLER_2D).get(); |
5773 if (attachment->IsTexture(texture_ref)) | 5904 if (attachment->IsTexture(texture_ref)) |
5774 return true; | 5905 return true; |
5775 } | 5906 } |
5776 } | 5907 } |
5777 return false; | 5908 return false; |
5778 } | 5909 } |
5779 | 5910 |
| 5911 bool GLES2DecoderImpl::CheckUniformForApiType( |
| 5912 const Program::UniformInfo* info, |
| 5913 const char* function_name, |
| 5914 Program::UniformApiType api_type) { |
| 5915 DCHECK(info); |
| 5916 if ((api_type & info->accepts_api_type) == 0) { |
| 5917 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 5918 "wrong uniform function for type"); |
| 5919 return false; |
| 5920 } |
| 5921 return true; |
| 5922 } |
| 5923 |
5780 bool GLES2DecoderImpl::PrepForSetUniformByLocation( | 5924 bool GLES2DecoderImpl::PrepForSetUniformByLocation( |
5781 GLint fake_location, | 5925 GLint fake_location, |
5782 const char* function_name, | 5926 const char* function_name, |
5783 Program::UniformApiType api_type, | 5927 Program::UniformApiType api_type, |
5784 GLint* real_location, | 5928 GLint* real_location, |
5785 GLenum* type, | 5929 GLenum* type, |
5786 GLsizei* count) { | 5930 GLsizei* count) { |
5787 DCHECK(type); | 5931 DCHECK(type); |
5788 DCHECK(count); | 5932 DCHECK(count); |
5789 DCHECK(real_location); | 5933 DCHECK(real_location); |
5790 | 5934 |
5791 if (!CheckCurrentProgramForUniform(fake_location, function_name)) { | 5935 if (!CheckCurrentProgramForUniform(fake_location, function_name)) { |
5792 return false; | 5936 return false; |
5793 } | 5937 } |
5794 GLint array_index = -1; | 5938 GLint array_index = -1; |
5795 const Program::UniformInfo* info = | 5939 const Program::UniformInfo* info = |
5796 state_.current_program->GetUniformInfoByFakeLocation( | 5940 state_.current_program->GetUniformInfoByFakeLocation( |
5797 fake_location, real_location, &array_index); | 5941 fake_location, real_location, &array_index); |
5798 if (!info) { | 5942 if (!info) { |
5799 LOCAL_SET_GL_ERROR( | 5943 LOCAL_SET_GL_ERROR( |
5800 GL_INVALID_OPERATION, function_name, "unknown location"); | 5944 GL_INVALID_OPERATION, function_name, "unknown location"); |
5801 return false; | 5945 return false; |
5802 } | 5946 } |
5803 | 5947 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; | 5948 return false; |
5809 } | 5949 } |
5810 if (*count > 1 && !info->is_array) { | 5950 if (*count > 1 && !info->is_array) { |
5811 LOCAL_SET_GL_ERROR( | 5951 LOCAL_SET_GL_ERROR( |
5812 GL_INVALID_OPERATION, function_name, "count > 1 for non-array"); | 5952 GL_INVALID_OPERATION, function_name, "count > 1 for non-array"); |
5813 return false; | 5953 return false; |
5814 } | 5954 } |
5815 *count = std::min(info->size - array_index, *count); | 5955 *count = std::min(info->size - array_index, *count); |
5816 if (*count <= 0) { | 5956 if (*count <= 0) { |
5817 return false; | 5957 return false; |
(...skipping 4871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10689 if (texture->target() != target) { | 10829 if (texture->target() != target) { |
10690 LOCAL_SET_GL_ERROR( | 10830 LOCAL_SET_GL_ERROR( |
10691 GL_INVALID_OPERATION, | 10831 GL_INVALID_OPERATION, |
10692 "glCreateAndConsumeTextureCHROMIUM", "invalid target"); | 10832 "glCreateAndConsumeTextureCHROMIUM", "invalid target"); |
10693 return; | 10833 return; |
10694 } | 10834 } |
10695 | 10835 |
10696 texture_ref = texture_manager()->Consume(client_id, texture); | 10836 texture_ref = texture_manager()->Consume(client_id, texture); |
10697 } | 10837 } |
10698 | 10838 |
| 10839 bool GLES2DecoderImpl::DoIsValuebufferCHROMIUM(GLuint client_id) { |
| 10840 const Valuebuffer* valuebuffer = GetValuebuffer(client_id); |
| 10841 return valuebuffer && valuebuffer->IsValid(); |
| 10842 } |
| 10843 |
| 10844 void GLES2DecoderImpl::DoBindValueBufferCHROMIUM(GLenum target, |
| 10845 GLuint client_id) { |
| 10846 Valuebuffer* valuebuffer = NULL; |
| 10847 if (client_id != 0) { |
| 10848 valuebuffer = GetValuebuffer(client_id); |
| 10849 if (!valuebuffer) { |
| 10850 if (!group_->bind_generates_resource()) { |
| 10851 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBindValuebufferCHROMIUM", |
| 10852 "id not generated by glBindValuebufferCHROMIUM"); |
| 10853 return; |
| 10854 } |
| 10855 |
| 10856 // It's a new id so make a valuebuffer for it. |
| 10857 CreateValuebuffer(client_id); |
| 10858 valuebuffer = GetValuebuffer(client_id); |
| 10859 } |
| 10860 valuebuffer->MarkAsValid(); |
| 10861 } |
| 10862 state_.bound_valuebuffer = valuebuffer; |
| 10863 } |
| 10864 |
| 10865 void GLES2DecoderImpl::DoSubscribeValueCHROMIUM(GLenum target, |
| 10866 GLenum subscription) { |
| 10867 if (!CheckCurrentValuebuffer("glSubscribeValueCHROMIUM")) { |
| 10868 return; |
| 10869 } |
| 10870 state_.bound_valuebuffer.get()->AddSubscription(subscription); |
| 10871 } |
| 10872 |
| 10873 void GLES2DecoderImpl::DoPopulateSubscribedValuesCHROMIUM(GLenum target) { |
| 10874 if (!CheckCurrentValuebuffer("glPopulateSubscribedValuesCHROMIUM")) { |
| 10875 return; |
| 10876 } |
| 10877 valuebuffer_manager()->UpdateValuebufferState(state_.bound_valuebuffer.get()); |
| 10878 } |
| 10879 |
| 10880 void GLES2DecoderImpl::DoUniformValueBufferCHROMIUM(GLint location, |
| 10881 GLenum target, |
| 10882 GLenum subscription) { |
| 10883 if (!CheckCurrentValuebufferForSubscription( |
| 10884 subscription, "glPopulateSubscribedValuesCHROMIUM")) { |
| 10885 return; |
| 10886 } |
| 10887 if (!CheckSubscriptionTarget(location, subscription, |
| 10888 "glPopulateSubscribedValuesCHROMIUM")) { |
| 10889 return; |
| 10890 } |
| 10891 const ValueState* state = |
| 10892 state_.bound_valuebuffer.get()->GetState(subscription); |
| 10893 if (state) { |
| 10894 switch (subscription) { |
| 10895 case GL_MOUSE_POSITION_CHROMIUM: |
| 10896 DoUniform2iv(location, 1, state->int_value); |
| 10897 break; |
| 10898 default: |
| 10899 NOTREACHED() << "Unhandled uniform subscription target " |
| 10900 << subscription; |
| 10901 break; |
| 10902 } |
| 10903 } |
| 10904 } |
| 10905 |
10699 void GLES2DecoderImpl::DoInsertEventMarkerEXT( | 10906 void GLES2DecoderImpl::DoInsertEventMarkerEXT( |
10700 GLsizei length, const GLchar* marker) { | 10907 GLsizei length, const GLchar* marker) { |
10701 if (!marker) { | 10908 if (!marker) { |
10702 marker = ""; | 10909 marker = ""; |
10703 } | 10910 } |
10704 debug_marker_manager_.SetMarker( | 10911 debug_marker_manager_.SetMarker( |
10705 length ? std::string(marker, length) : std::string(marker)); | 10912 length ? std::string(marker, length) : std::string(marker)); |
10706 } | 10913 } |
10707 | 10914 |
10708 void GLES2DecoderImpl::DoPushGroupMarkerEXT( | 10915 void GLES2DecoderImpl::DoPushGroupMarkerEXT( |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11254 } | 11461 } |
11255 } | 11462 } |
11256 | 11463 |
11257 // Include the auto-generated part of this file. We split this because it means | 11464 // 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 | 11465 // 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. | 11466 // instead of having to edit some template or the code generator. |
11260 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11467 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
11261 | 11468 |
11262 } // namespace gles2 | 11469 } // namespace gles2 |
11263 } // namespace gpu | 11470 } // namespace gpu |
OLD | NEW |