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" | |
60 #include "gpu/command_buffer/service/vertex_array_manager.h" | 59 #include "gpu/command_buffer/service/vertex_array_manager.h" |
61 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 60 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
62 #include "third_party/smhasher/src/City.h" | 61 #include "third_party/smhasher/src/City.h" |
63 #include "ui/gl/gl_fence.h" | 62 #include "ui/gl/gl_fence.h" |
64 #include "ui/gl/gl_image.h" | 63 #include "ui/gl/gl_image.h" |
65 #include "ui/gl/gl_implementation.h" | 64 #include "ui/gl/gl_implementation.h" |
66 #include "ui/gl/gl_surface.h" | 65 #include "ui/gl/gl_surface.h" |
67 | 66 |
68 #if defined(OS_MACOSX) | 67 #if defined(OS_MACOSX) |
69 #include <IOSurface/IOSurfaceAPI.h> | 68 #include <IOSurface/IOSurfaceAPI.h> |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 | 720 |
722 // Helpers for the glGen and glDelete functions. | 721 // Helpers for the glGen and glDelete functions. |
723 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids); | 722 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids); |
724 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids); | 723 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids); |
725 bool GenBuffersHelper(GLsizei n, const GLuint* client_ids); | 724 bool GenBuffersHelper(GLsizei n, const GLuint* client_ids); |
726 void DeleteBuffersHelper(GLsizei n, const GLuint* client_ids); | 725 void DeleteBuffersHelper(GLsizei n, const GLuint* client_ids); |
727 bool GenFramebuffersHelper(GLsizei n, const GLuint* client_ids); | 726 bool GenFramebuffersHelper(GLsizei n, const GLuint* client_ids); |
728 void DeleteFramebuffersHelper(GLsizei n, const GLuint* client_ids); | 727 void DeleteFramebuffersHelper(GLsizei n, const GLuint* client_ids); |
729 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); | 728 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); |
730 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); | 729 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); | |
733 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 730 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
734 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 731 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
735 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 732 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
736 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 733 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
737 | 734 |
738 // Helper for async upload token completion notification callback. | 735 // Helper for async upload token completion notification callback. |
739 base::Closure AsyncUploadTokenCompletionClosure(uint32 async_upload_token, | 736 base::Closure AsyncUploadTokenCompletionClosure(uint32 async_upload_token, |
740 uint32 sync_data_shm_id, | 737 uint32 sync_data_shm_id, |
741 uint32 sync_data_shm_offset); | 738 uint32 sync_data_shm_offset); |
742 | 739 |
743 | 740 |
744 | 741 |
745 // Workarounds | 742 // Workarounds |
746 void OnFboChanged() const; | 743 void OnFboChanged() const; |
747 void OnUseFramebuffer() const; | 744 void OnUseFramebuffer() const; |
748 | 745 |
749 // TODO(gman): Cache these pointers? | 746 // TODO(gman): Cache these pointers? |
750 BufferManager* buffer_manager() { | 747 BufferManager* buffer_manager() { |
751 return group_->buffer_manager(); | 748 return group_->buffer_manager(); |
752 } | 749 } |
753 | 750 |
754 RenderbufferManager* renderbuffer_manager() { | 751 RenderbufferManager* renderbuffer_manager() { |
755 return group_->renderbuffer_manager(); | 752 return group_->renderbuffer_manager(); |
756 } | 753 } |
757 | 754 |
758 FramebufferManager* framebuffer_manager() { | 755 FramebufferManager* framebuffer_manager() { |
759 return group_->framebuffer_manager(); | 756 return group_->framebuffer_manager(); |
760 } | 757 } |
761 | 758 |
762 ValuebufferManager* valuebuffer_manager() { | |
763 return group_->valuebuffer_manager(); | |
764 } | |
765 | |
766 ProgramManager* program_manager() { | 759 ProgramManager* program_manager() { |
767 return group_->program_manager(); | 760 return group_->program_manager(); |
768 } | 761 } |
769 | 762 |
770 ShaderManager* shader_manager() { | 763 ShaderManager* shader_manager() { |
771 return group_->shader_manager(); | 764 return group_->shader_manager(); |
772 } | 765 } |
773 | 766 |
774 ShaderTranslatorCache* shader_translator_cache() { | 767 ShaderTranslatorCache* shader_translator_cache() { |
775 return group_->shader_translator_cache(); | 768 return group_->shader_translator_cache(); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); | 937 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); |
945 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, | 938 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, |
946 const GLbyte* key); | 939 const GLbyte* key); |
947 void ProduceTextureRef(std::string func_name, TextureRef* texture_ref, | 940 void ProduceTextureRef(std::string func_name, TextureRef* texture_ref, |
948 GLenum target, const GLbyte* data); | 941 GLenum target, const GLbyte* data); |
949 | 942 |
950 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); | 943 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); |
951 void DoCreateAndConsumeTextureCHROMIUM(GLenum target, const GLbyte* key, | 944 void DoCreateAndConsumeTextureCHROMIUM(GLenum target, const GLbyte* key, |
952 GLuint client_id); | 945 GLuint client_id); |
953 | 946 |
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 | |
962 void DoBindTexImage2DCHROMIUM( | 947 void DoBindTexImage2DCHROMIUM( |
963 GLenum target, | 948 GLenum target, |
964 GLint image_id); | 949 GLint image_id); |
965 void DoReleaseTexImage2DCHROMIUM( | 950 void DoReleaseTexImage2DCHROMIUM( |
966 GLenum target, | 951 GLenum target, |
967 GLint image_id); | 952 GLint image_id); |
968 | 953 |
969 void DoTraceEndCHROMIUM(void); | 954 void DoTraceEndCHROMIUM(void); |
970 | 955 |
971 void DoDrawBuffersEXT(GLsizei count, const GLenum* bufs); | 956 void DoDrawBuffersEXT(GLsizei count, const GLenum* bufs); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 // Gets the renderbuffer info for the given renderbuffer. | 1089 // Gets the renderbuffer info for the given renderbuffer. |
1105 Renderbuffer* GetRenderbuffer(GLuint client_id) { | 1090 Renderbuffer* GetRenderbuffer(GLuint client_id) { |
1106 return renderbuffer_manager()->GetRenderbuffer(client_id); | 1091 return renderbuffer_manager()->GetRenderbuffer(client_id); |
1107 } | 1092 } |
1108 | 1093 |
1109 // Removes the renderbuffer info for the given renderbuffer. | 1094 // Removes the renderbuffer info for the given renderbuffer. |
1110 void RemoveRenderbuffer(GLuint client_id) { | 1095 void RemoveRenderbuffer(GLuint client_id) { |
1111 renderbuffer_manager()->RemoveRenderbuffer(client_id); | 1096 renderbuffer_manager()->RemoveRenderbuffer(client_id); |
1112 } | 1097 } |
1113 | 1098 |
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 | |
1129 // Gets the vertex attrib manager for the given vertex array. | 1099 // Gets the vertex attrib manager for the given vertex array. |
1130 VertexAttribManager* GetVertexAttribManager(GLuint client_id) { | 1100 VertexAttribManager* GetVertexAttribManager(GLuint client_id) { |
1131 VertexAttribManager* info = | 1101 VertexAttribManager* info = |
1132 vertex_array_manager()->GetVertexAttribManager(client_id); | 1102 vertex_array_manager()->GetVertexAttribManager(client_id); |
1133 return info; | 1103 return info; |
1134 } | 1104 } |
1135 | 1105 |
1136 // Removes the vertex attrib manager for the given vertex array. | 1106 // Removes the vertex attrib manager for the given vertex array. |
1137 void RemoveVertexAttribManager(GLuint client_id) { | 1107 void RemoveVertexAttribManager(GLuint client_id) { |
1138 vertex_array_manager()->RemoveVertexAttribManager(client_id); | 1108 vertex_array_manager()->RemoveVertexAttribManager(client_id); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 // Check that the currently bound read framebuffer's color image | 1170 // Check that the currently bound read framebuffer's color image |
1201 // isn't the target texture of the glCopyTex{Sub}Image2D. | 1171 // isn't the target texture of the glCopyTex{Sub}Image2D. |
1202 bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level); | 1172 bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level); |
1203 | 1173 |
1204 // Check if a framebuffer meets our requirements. | 1174 // Check if a framebuffer meets our requirements. |
1205 bool CheckFramebufferValid( | 1175 bool CheckFramebufferValid( |
1206 Framebuffer* framebuffer, | 1176 Framebuffer* framebuffer, |
1207 GLenum target, | 1177 GLenum target, |
1208 const char* func_name); | 1178 const char* func_name); |
1209 | 1179 |
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 | |
1226 // Checks if the current program exists and is valid. If not generates the | 1180 // Checks if the current program exists and is valid. If not generates the |
1227 // appropriate GL error. Returns true if the current program is in a usable | 1181 // appropriate GL error. Returns true if the current program is in a usable |
1228 // state. | 1182 // state. |
1229 bool CheckCurrentProgram(const char* function_name); | 1183 bool CheckCurrentProgram(const char* function_name); |
1230 | 1184 |
1231 // Checks if the current program exists and is valid and that location is not | 1185 // Checks if the current program exists and is valid and that location is not |
1232 // -1. If the current program is not valid generates the appropriate GL | 1186 // -1. If the current program is not valid generates the appropriate GL |
1233 // error. Returns true if the current program is in a usable state and | 1187 // error. Returns true if the current program is in a usable state and |
1234 // location is not -1. | 1188 // location is not -1. |
1235 bool CheckCurrentProgramForUniform(GLint location, const char* function_name); | 1189 bool CheckCurrentProgramForUniform(GLint location, const char* function_name); |
1236 | 1190 |
1237 // Checks if the current program samples a texture that is also the color | 1191 // Checks if the current program samples a texture that is also the color |
1238 // image of the current bound framebuffer, i.e., the source and destination | 1192 // image of the current bound framebuffer, i.e., the source and destination |
1239 // of the draw operation are the same. | 1193 // of the draw operation are the same. |
1240 bool CheckDrawingFeedbackLoops(); | 1194 bool CheckDrawingFeedbackLoops(); |
1241 | 1195 |
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 | |
1249 // Gets the type of a uniform for a location in the current program. Sets GL | 1196 // Gets the type of a uniform for a location in the current program. Sets GL |
1250 // errors if the current program is not valid. Returns true if the current | 1197 // errors if the current program is not valid. Returns true if the current |
1251 // program is valid and the location exists. Adjusts count so it | 1198 // program is valid and the location exists. Adjusts count so it |
1252 // does not overflow the uniform. | 1199 // does not overflow the uniform. |
1253 bool PrepForSetUniformByLocation(GLint fake_location, | 1200 bool PrepForSetUniformByLocation(GLint fake_location, |
1254 const char* function_name, | 1201 const char* function_name, |
1255 Program::UniformApiType api_type, | 1202 Program::UniformApiType api_type, |
1256 GLint* real_location, | 1203 GLint* real_location, |
1257 GLenum* type, | 1204 GLenum* type, |
1258 GLsizei* count); | 1205 GLsizei* count); |
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2716 | 2663 |
2717 // Set all the default state because some GL drivers get it wrong. | 2664 // Set all the default state because some GL drivers get it wrong. |
2718 state_.InitCapabilities(NULL); | 2665 state_.InitCapabilities(NULL); |
2719 state_.InitState(NULL); | 2666 state_.InitState(NULL); |
2720 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); | 2667 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); |
2721 | 2668 |
2722 DoBindBuffer(GL_ARRAY_BUFFER, 0); | 2669 DoBindBuffer(GL_ARRAY_BUFFER, 0); |
2723 DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | 2670 DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
2724 DoBindFramebuffer(GL_FRAMEBUFFER, 0); | 2671 DoBindFramebuffer(GL_FRAMEBUFFER, 0); |
2725 DoBindRenderbuffer(GL_RENDERBUFFER, 0); | 2672 DoBindRenderbuffer(GL_RENDERBUFFER, 0); |
2726 DoBindValueBufferCHROMIUM(GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM, 0); | |
2727 | 2673 |
2728 bool call_gl_clear = !surfaceless_; | 2674 bool call_gl_clear = !surfaceless_; |
2729 #if defined(OS_ANDROID) | 2675 #if defined(OS_ANDROID) |
2730 // Temporary workaround for Android WebView because this clear ignores the | 2676 // Temporary workaround for Android WebView because this clear ignores the |
2731 // clip and corrupts that external UI of the App. Not calling glClear is ok | 2677 // clip and corrupts that external UI of the App. Not calling glClear is ok |
2732 // because the system already clears the buffer before each draw. Proper | 2678 // because the system already clears the buffer before each draw. Proper |
2733 // fix might be setting the scissor clip properly before initialize. See | 2679 // fix might be setting the scissor clip properly before initialize. See |
2734 // crbug.com/259023 for details. | 2680 // crbug.com/259023 for details. |
2735 call_gl_clear = surface_->GetHandle(); | 2681 call_gl_clear = surface_->GetHandle(); |
2736 #endif | 2682 #endif |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2953 return false; | 2899 return false; |
2954 } | 2900 } |
2955 } | 2901 } |
2956 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); | 2902 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); |
2957 glGenRenderbuffersEXT(n, service_ids.get()); | 2903 glGenRenderbuffersEXT(n, service_ids.get()); |
2958 for (GLsizei ii = 0; ii < n; ++ii) { | 2904 for (GLsizei ii = 0; ii < n; ++ii) { |
2959 CreateRenderbuffer(client_ids[ii], service_ids[ii]); | 2905 CreateRenderbuffer(client_ids[ii], service_ids[ii]); |
2960 } | 2906 } |
2961 return true; | 2907 return true; |
2962 } | 2908 } |
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 | 2909 |
2977 bool GLES2DecoderImpl::GenTexturesHelper(GLsizei n, const GLuint* client_ids) { | 2910 bool GLES2DecoderImpl::GenTexturesHelper(GLsizei n, const GLuint* client_ids) { |
2978 for (GLsizei ii = 0; ii < n; ++ii) { | 2911 for (GLsizei ii = 0; ii < n; ++ii) { |
2979 if (GetTexture(client_ids[ii])) { | 2912 if (GetTexture(client_ids[ii])) { |
2980 return false; | 2913 return false; |
2981 } | 2914 } |
2982 } | 2915 } |
2983 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); | 2916 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); |
2984 glGenTextures(n, service_ids.get()); | 2917 glGenTextures(n, service_ids.get()); |
2985 for (GLsizei ii = 0; ii < n; ++ii) { | 2918 for (GLsizei ii = 0; ii < n; ++ii) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3055 if (framebuffer_state_.bound_draw_framebuffer.get()) { | 2988 if (framebuffer_state_.bound_draw_framebuffer.get()) { |
3056 framebuffer_state_.bound_draw_framebuffer | 2989 framebuffer_state_.bound_draw_framebuffer |
3057 ->UnbindRenderbuffer(GL_FRAMEBUFFER, renderbuffer); | 2990 ->UnbindRenderbuffer(GL_FRAMEBUFFER, renderbuffer); |
3058 } | 2991 } |
3059 } | 2992 } |
3060 framebuffer_state_.clear_state_dirty = true; | 2993 framebuffer_state_.clear_state_dirty = true; |
3061 RemoveRenderbuffer(client_ids[ii]); | 2994 RemoveRenderbuffer(client_ids[ii]); |
3062 } | 2995 } |
3063 } | 2996 } |
3064 } | 2997 } |
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 | 2998 |
3080 void GLES2DecoderImpl::DeleteTexturesHelper( | 2999 void GLES2DecoderImpl::DeleteTexturesHelper( |
3081 GLsizei n, const GLuint* client_ids) { | 3000 GLsizei n, const GLuint* client_ids) { |
3082 bool supports_separate_framebuffer_binds = | 3001 bool supports_separate_framebuffer_binds = |
3083 features().chromium_framebuffer_multisample; | 3002 features().chromium_framebuffer_multisample; |
3084 for (GLsizei ii = 0; ii < n; ++ii) { | 3003 for (GLsizei ii = 0; ii < n; ++ii) { |
3085 TextureRef* texture_ref = GetTexture(client_ids[ii]); | 3004 TextureRef* texture_ref = GetTexture(client_ids[ii]); |
3086 if (texture_ref) { | 3005 if (texture_ref) { |
3087 Texture* texture = texture_ref->texture(); | 3006 Texture* texture = texture_ref->texture(); |
3088 if (texture->IsAttachedToFramebuffer()) { | 3007 if (texture->IsAttachedToFramebuffer()) { |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3499 | 3418 |
3500 // Unbind everything. | 3419 // Unbind everything. |
3501 state_.vertex_attrib_manager = NULL; | 3420 state_.vertex_attrib_manager = NULL; |
3502 state_.default_vertex_attrib_manager = NULL; | 3421 state_.default_vertex_attrib_manager = NULL; |
3503 state_.texture_units.clear(); | 3422 state_.texture_units.clear(); |
3504 state_.bound_array_buffer = NULL; | 3423 state_.bound_array_buffer = NULL; |
3505 state_.current_queries.clear(); | 3424 state_.current_queries.clear(); |
3506 framebuffer_state_.bound_read_framebuffer = NULL; | 3425 framebuffer_state_.bound_read_framebuffer = NULL; |
3507 framebuffer_state_.bound_draw_framebuffer = NULL; | 3426 framebuffer_state_.bound_draw_framebuffer = NULL; |
3508 state_.bound_renderbuffer = NULL; | 3427 state_.bound_renderbuffer = NULL; |
3509 state_.bound_valuebuffer = NULL; | |
3510 | 3428 |
3511 if (offscreen_saved_color_texture_info_.get()) { | 3429 if (offscreen_saved_color_texture_info_.get()) { |
3512 DCHECK(offscreen_target_color_texture_); | 3430 DCHECK(offscreen_target_color_texture_); |
3513 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(), | 3431 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(), |
3514 offscreen_saved_color_texture_->id()); | 3432 offscreen_saved_color_texture_->id()); |
3515 offscreen_saved_color_texture_->Invalidate(); | 3433 offscreen_saved_color_texture_->Invalidate(); |
3516 offscreen_saved_color_texture_info_ = NULL; | 3434 offscreen_saved_color_texture_info_ = NULL; |
3517 } | 3435 } |
3518 if (have_context) { | 3436 if (have_context) { |
3519 if (copy_texture_CHROMIUM_.get()) { | 3437 if (copy_texture_CHROMIUM_.get()) { |
(...skipping 2277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5797 if (!texture) { | 5715 if (!texture) { |
5798 LOCAL_SET_GL_ERROR( | 5716 LOCAL_SET_GL_ERROR( |
5799 GL_INVALID_VALUE, "glTexParameteriv", "unknown texture"); | 5717 GL_INVALID_VALUE, "glTexParameteriv", "unknown texture"); |
5800 return; | 5718 return; |
5801 } | 5719 } |
5802 | 5720 |
5803 texture_manager()->SetParameteri( | 5721 texture_manager()->SetParameteri( |
5804 "glTexParameteriv", GetErrorState(), texture, pname, *params); | 5722 "glTexParameteriv", GetErrorState(), texture, pname, *params); |
5805 } | 5723 } |
5806 | 5724 |
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 | |
5856 bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) { | 5725 bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) { |
5857 if (!state_.current_program.get()) { | 5726 if (!state_.current_program.get()) { |
5858 // The program does not exist. | 5727 // The program does not exist. |
5859 LOCAL_SET_GL_ERROR( | 5728 LOCAL_SET_GL_ERROR( |
5860 GL_INVALID_OPERATION, function_name, "no program in use"); | 5729 GL_INVALID_OPERATION, function_name, "no program in use"); |
5861 return false; | 5730 return false; |
5862 } | 5731 } |
5863 if (!state_.current_program->InUse()) { | 5732 if (!state_.current_program->InUse()) { |
5864 LOCAL_SET_GL_ERROR( | 5733 LOCAL_SET_GL_ERROR( |
5865 GL_INVALID_OPERATION, function_name, "program not linked"); | 5734 GL_INVALID_OPERATION, function_name, "program not linked"); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5901 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; | 5770 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
5902 TextureRef* texture_ref = | 5771 TextureRef* texture_ref = |
5903 texture_unit.GetInfoForSamplerType(GL_SAMPLER_2D).get(); | 5772 texture_unit.GetInfoForSamplerType(GL_SAMPLER_2D).get(); |
5904 if (attachment->IsTexture(texture_ref)) | 5773 if (attachment->IsTexture(texture_ref)) |
5905 return true; | 5774 return true; |
5906 } | 5775 } |
5907 } | 5776 } |
5908 return false; | 5777 return false; |
5909 } | 5778 } |
5910 | 5779 |
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 | |
5924 bool GLES2DecoderImpl::PrepForSetUniformByLocation( | 5780 bool GLES2DecoderImpl::PrepForSetUniformByLocation( |
5925 GLint fake_location, | 5781 GLint fake_location, |
5926 const char* function_name, | 5782 const char* function_name, |
5927 Program::UniformApiType api_type, | 5783 Program::UniformApiType api_type, |
5928 GLint* real_location, | 5784 GLint* real_location, |
5929 GLenum* type, | 5785 GLenum* type, |
5930 GLsizei* count) { | 5786 GLsizei* count) { |
5931 DCHECK(type); | 5787 DCHECK(type); |
5932 DCHECK(count); | 5788 DCHECK(count); |
5933 DCHECK(real_location); | 5789 DCHECK(real_location); |
5934 | 5790 |
5935 if (!CheckCurrentProgramForUniform(fake_location, function_name)) { | 5791 if (!CheckCurrentProgramForUniform(fake_location, function_name)) { |
5936 return false; | 5792 return false; |
5937 } | 5793 } |
5938 GLint array_index = -1; | 5794 GLint array_index = -1; |
5939 const Program::UniformInfo* info = | 5795 const Program::UniformInfo* info = |
5940 state_.current_program->GetUniformInfoByFakeLocation( | 5796 state_.current_program->GetUniformInfoByFakeLocation( |
5941 fake_location, real_location, &array_index); | 5797 fake_location, real_location, &array_index); |
5942 if (!info) { | 5798 if (!info) { |
5943 LOCAL_SET_GL_ERROR( | 5799 LOCAL_SET_GL_ERROR( |
5944 GL_INVALID_OPERATION, function_name, "unknown location"); | 5800 GL_INVALID_OPERATION, function_name, "unknown location"); |
5945 return false; | 5801 return false; |
5946 } | 5802 } |
5947 if (!CheckUniformForApiType(info, function_name, api_type)) { | 5803 |
| 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"); |
5948 return false; | 5808 return false; |
5949 } | 5809 } |
5950 if (*count > 1 && !info->is_array) { | 5810 if (*count > 1 && !info->is_array) { |
5951 LOCAL_SET_GL_ERROR( | 5811 LOCAL_SET_GL_ERROR( |
5952 GL_INVALID_OPERATION, function_name, "count > 1 for non-array"); | 5812 GL_INVALID_OPERATION, function_name, "count > 1 for non-array"); |
5953 return false; | 5813 return false; |
5954 } | 5814 } |
5955 *count = std::min(info->size - array_index, *count); | 5815 *count = std::min(info->size - array_index, *count); |
5956 if (*count <= 0) { | 5816 if (*count <= 0) { |
5957 return false; | 5817 return false; |
(...skipping 4871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10829 if (texture->target() != target) { | 10689 if (texture->target() != target) { |
10830 LOCAL_SET_GL_ERROR( | 10690 LOCAL_SET_GL_ERROR( |
10831 GL_INVALID_OPERATION, | 10691 GL_INVALID_OPERATION, |
10832 "glCreateAndConsumeTextureCHROMIUM", "invalid target"); | 10692 "glCreateAndConsumeTextureCHROMIUM", "invalid target"); |
10833 return; | 10693 return; |
10834 } | 10694 } |
10835 | 10695 |
10836 texture_ref = texture_manager()->Consume(client_id, texture); | 10696 texture_ref = texture_manager()->Consume(client_id, texture); |
10837 } | 10697 } |
10838 | 10698 |
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 | |
10906 void GLES2DecoderImpl::DoInsertEventMarkerEXT( | 10699 void GLES2DecoderImpl::DoInsertEventMarkerEXT( |
10907 GLsizei length, const GLchar* marker) { | 10700 GLsizei length, const GLchar* marker) { |
10908 if (!marker) { | 10701 if (!marker) { |
10909 marker = ""; | 10702 marker = ""; |
10910 } | 10703 } |
10911 debug_marker_manager_.SetMarker( | 10704 debug_marker_manager_.SetMarker( |
10912 length ? std::string(marker, length) : std::string(marker)); | 10705 length ? std::string(marker, length) : std::string(marker)); |
10913 } | 10706 } |
10914 | 10707 |
10915 void GLES2DecoderImpl::DoPushGroupMarkerEXT( | 10708 void GLES2DecoderImpl::DoPushGroupMarkerEXT( |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11461 } | 11254 } |
11462 } | 11255 } |
11463 | 11256 |
11464 // Include the auto-generated part of this file. We split this because it means | 11257 // Include the auto-generated part of this file. We split this because it means |
11465 // we can easily edit the non-auto generated parts right here in this file | 11258 // we can easily edit the non-auto generated parts right here in this file |
11466 // instead of having to edit some template or the code generator. | 11259 // instead of having to edit some template or the code generator. |
11467 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11260 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
11468 | 11261 |
11469 } // namespace gles2 | 11262 } // namespace gles2 |
11470 } // namespace gpu | 11263 } // namespace gpu |
OLD | NEW |