OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
869 // location is not -1. | 869 // location is not -1. |
870 bool CheckCurrentProgramForUniform(GLint location, const char* function_name); | 870 bool CheckCurrentProgramForUniform(GLint location, const char* function_name); |
871 | 871 |
872 // Gets the type of a uniform for a location in the current program. Sets GL | 872 // Gets the type of a uniform for a location in the current program. Sets GL |
873 // errors if the current program is not valid. Returns true if the current | 873 // errors if the current program is not valid. Returns true if the current |
874 // program is valid and the location exists. Adjusts count so it | 874 // program is valid and the location exists. Adjusts count so it |
875 // does not overflow the uniform. | 875 // does not overflow the uniform. |
876 bool PrepForSetUniformByLocation( | 876 bool PrepForSetUniformByLocation( |
877 GLint location, const char* function_name, GLenum* type, GLsizei* count); | 877 GLint location, const char* function_name, GLenum* type, GLsizei* count); |
878 | 878 |
879 // Gets the service id for any simulated backbuffer fbo. | |
880 GLuint GetBackbufferServiceId(); | |
881 | |
879 // Helper for glGetBooleanv, glGetFloatv and glGetIntegerv | 882 // Helper for glGetBooleanv, glGetFloatv and glGetIntegerv |
880 bool GetHelper(GLenum pname, GLint* params, GLsizei* num_written); | 883 bool GetHelper(GLenum pname, GLint* params, GLsizei* num_written); |
881 | 884 |
882 // Wrapper for glCreateProgram | 885 // Wrapper for glCreateProgram |
883 bool CreateProgramHelper(GLuint client_id); | 886 bool CreateProgramHelper(GLuint client_id); |
884 | 887 |
885 // Wrapper for glCreateShader | 888 // Wrapper for glCreateShader |
886 bool CreateShaderHelper(GLenum type, GLuint client_id); | 889 bool CreateShaderHelper(GLenum type, GLuint client_id); |
887 | 890 |
888 // Wrapper for glActiveTexture | 891 // Wrapper for glActiveTexture |
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2157 if (info) { | 2160 if (info) { |
2158 GLuint service_id = info->service_id(); | 2161 GLuint service_id = info->service_id(); |
2159 glDeleteBuffersARB(1, &service_id); | 2162 glDeleteBuffersARB(1, &service_id); |
2160 RemoveBufferInfo(client_ids[ii]); | 2163 RemoveBufferInfo(client_ids[ii]); |
2161 } | 2164 } |
2162 } | 2165 } |
2163 } | 2166 } |
2164 | 2167 |
2165 void GLES2DecoderImpl::DeleteFramebuffersHelper( | 2168 void GLES2DecoderImpl::DeleteFramebuffersHelper( |
2166 GLsizei n, const GLuint* client_ids) { | 2169 GLsizei n, const GLuint* client_ids) { |
2170 bool supports_seperate_framebuffer_binds = | |
2171 feature_info_->feature_flags().chromium_framebuffer_multisample; | |
2172 | |
2167 for (GLsizei ii = 0; ii < n; ++ii) { | 2173 for (GLsizei ii = 0; ii < n; ++ii) { |
2168 FramebufferManager::FramebufferInfo* info = | 2174 FramebufferManager::FramebufferInfo* info = |
2169 GetFramebufferInfo(client_ids[ii]); | 2175 GetFramebufferInfo(client_ids[ii]); |
2170 if (info) { | 2176 if (info) { |
2171 if (info == bound_draw_framebuffer_) { | 2177 if (info == bound_draw_framebuffer_) { |
2172 bound_draw_framebuffer_ = NULL; | 2178 bound_draw_framebuffer_ = NULL; |
2173 state_dirty_ = true; | 2179 state_dirty_ = true; |
2180 GLenum target = supports_seperate_framebuffer_binds ? | |
alokp
2011/10/31 21:00:54
It seems in cases where (bound_draw_framebuffer_ =
| |
2181 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; | |
2182 glBindFramebufferEXT(target, GetBackbufferServiceId()); | |
2183 } | |
2184 if (info == bound_read_framebuffer_) { | |
2185 bound_read_framebuffer_ = NULL; | |
2186 GLenum target = supports_seperate_framebuffer_binds ? | |
2187 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; | |
2188 glBindFramebufferEXT(target, GetBackbufferServiceId()); | |
2174 } | 2189 } |
2175 GLuint service_id = info->service_id(); | 2190 GLuint service_id = info->service_id(); |
2176 glDeleteFramebuffersEXT(1, &service_id); | 2191 glDeleteFramebuffersEXT(1, &service_id); |
2177 RemoveFramebufferInfo(client_ids[ii]); | 2192 RemoveFramebufferInfo(client_ids[ii]); |
2178 } | 2193 } |
2179 } | 2194 } |
2180 } | 2195 } |
2181 | 2196 |
2182 void GLES2DecoderImpl::DeleteRenderbuffersHelper( | 2197 void GLES2DecoderImpl::DeleteRenderbuffersHelper( |
2183 GLsizei n, const GLuint* client_ids) { | 2198 GLsizei n, const GLuint* client_ids) { |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2832 glDepthMask(mask_depth_ && have_depth); | 2847 glDepthMask(mask_depth_ && have_depth); |
2833 EnableDisable(GL_DEPTH_TEST, enable_depth_test_ && have_depth); | 2848 EnableDisable(GL_DEPTH_TEST, enable_depth_test_ && have_depth); |
2834 bool have_stencil = BoundFramebufferHasStencilAttachment(); | 2849 bool have_stencil = BoundFramebufferHasStencilAttachment(); |
2835 glStencilMaskSeparate(GL_FRONT, have_stencil ? mask_stencil_front_ : 0); | 2850 glStencilMaskSeparate(GL_FRONT, have_stencil ? mask_stencil_front_ : 0); |
2836 glStencilMaskSeparate(GL_BACK, have_stencil ? mask_stencil_back_ : 0); | 2851 glStencilMaskSeparate(GL_BACK, have_stencil ? mask_stencil_back_ : 0); |
2837 EnableDisable(GL_STENCIL_TEST, enable_stencil_test_ && have_stencil); | 2852 EnableDisable(GL_STENCIL_TEST, enable_stencil_test_ && have_stencil); |
2838 state_dirty_ = false; | 2853 state_dirty_ = false; |
2839 } | 2854 } |
2840 } | 2855 } |
2841 | 2856 |
2857 GLuint GLES2DecoderImpl::GetBackbufferServiceId() { | |
2858 return (offscreen_target_frame_buffer_.get()) ? | |
2859 offscreen_target_frame_buffer_->id() : | |
2860 surface_->GetBackingFrameBufferObject(); | |
2861 } | |
2862 | |
2842 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { | 2863 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { |
2843 FramebufferManager::FramebufferInfo* info = NULL; | 2864 FramebufferManager::FramebufferInfo* info = NULL; |
2844 GLuint service_id = 0; | 2865 GLuint service_id = 0; |
2845 if (client_id != 0) { | 2866 if (client_id != 0) { |
2846 info = GetFramebufferInfo(client_id); | 2867 info = GetFramebufferInfo(client_id); |
2847 if (!info) { | 2868 if (!info) { |
2848 if (!group_->bind_generates_resource()) { | 2869 if (!group_->bind_generates_resource()) { |
2849 SetGLError(GL_INVALID_VALUE, | 2870 SetGLError(GL_INVALID_VALUE, |
2850 "glBindFramebuffer: id not generated by glGenFramebuffers"); | 2871 "glBindFramebuffer: id not generated by glGenFramebuffers"); |
2851 return; | 2872 return; |
2852 } | 2873 } |
2853 | 2874 |
2854 // It's a new id so make a framebuffer info for it. | 2875 // It's a new id so make a framebuffer info for it. |
2855 glGenFramebuffersEXT(1, &service_id); | 2876 glGenFramebuffersEXT(1, &service_id); |
2856 CreateFramebufferInfo(client_id, service_id); | 2877 CreateFramebufferInfo(client_id, service_id); |
2857 info = GetFramebufferInfo(client_id); | 2878 info = GetFramebufferInfo(client_id); |
2858 IdAllocatorInterface* id_allocator = | 2879 IdAllocatorInterface* id_allocator = |
2859 group_->GetIdAllocator(id_namespaces::kFramebuffers); | 2880 group_->GetIdAllocator(id_namespaces::kFramebuffers); |
2860 id_allocator->MarkAsUsed(client_id); | 2881 id_allocator->MarkAsUsed(client_id); |
2861 } else { | 2882 } else { |
2862 service_id = info->service_id(); | 2883 service_id = info->service_id(); |
2863 } | 2884 } |
2864 info->MarkAsValid(); | 2885 info->MarkAsValid(); |
2865 } else { | |
2866 service_id = surface_->GetBackingFrameBufferObject(); | |
2867 } | 2886 } |
2868 | 2887 |
2869 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER_EXT) { | 2888 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER_EXT) { |
2870 bound_draw_framebuffer_ = info; | 2889 bound_draw_framebuffer_ = info; |
2871 } | 2890 } |
2872 if (target == GL_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER_EXT) { | 2891 if (target == GL_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER_EXT) { |
2873 bound_read_framebuffer_ = info; | 2892 bound_read_framebuffer_ = info; |
2874 } | 2893 } |
2875 | 2894 |
2876 state_dirty_ = true; | 2895 state_dirty_ = true; |
2877 | 2896 |
2878 // When rendering to an offscreen frame buffer, instead of unbinding from | 2897 // If we are rendering to the backbuffer get the FBO id for any simulated |
2879 // the current frame buffer, bind to the offscreen target frame buffer. | 2898 // backbuffer. |
2880 if (info == NULL && offscreen_target_frame_buffer_.get()) { | 2899 if (info == NULL) { |
2881 service_id = offscreen_target_frame_buffer_->id(); | 2900 service_id = GetBackbufferServiceId(); |
2882 } | 2901 } |
2883 | 2902 |
2884 glBindFramebufferEXT(target, service_id); | 2903 glBindFramebufferEXT(target, service_id); |
2885 } | 2904 } |
2886 | 2905 |
2887 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { | 2906 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { |
2888 RenderbufferManager::RenderbufferInfo* info = NULL; | 2907 RenderbufferManager::RenderbufferInfo* info = NULL; |
2889 GLuint service_id = 0; | 2908 GLuint service_id = 0; |
2890 if (client_id != 0) { | 2909 if (client_id != 0) { |
2891 info = GetRenderbufferInfo(client_id); | 2910 info = GetRenderbufferInfo(client_id); |
(...skipping 4314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7206 return error::kNoError; | 7225 return error::kNoError; |
7207 } | 7226 } |
7208 | 7227 |
7209 // Include the auto-generated part of this file. We split this because it means | 7228 // Include the auto-generated part of this file. We split this because it means |
7210 // we can easily edit the non-auto generated parts right here in this file | 7229 // we can easily edit the non-auto generated parts right here in this file |
7211 // instead of having to edit some template or the code generator. | 7230 // instead of having to edit some template or the code generator. |
7212 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 7231 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
7213 | 7232 |
7214 } // namespace gles2 | 7233 } // namespace gles2 |
7215 } // namespace gpu | 7234 } // namespace gpu |
OLD | NEW |