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 <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 #include "gpu/command_buffer/service/program_manager.h" | 58 #include "gpu/command_buffer/service/program_manager.h" |
59 #include "gpu/command_buffer/service/query_manager.h" | 59 #include "gpu/command_buffer/service/query_manager.h" |
60 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 60 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
61 #include "gpu/command_buffer/service/sampler_manager.h" | 61 #include "gpu/command_buffer/service/sampler_manager.h" |
62 #include "gpu/command_buffer/service/shader_manager.h" | 62 #include "gpu/command_buffer/service/shader_manager.h" |
63 #include "gpu/command_buffer/service/shader_translator.h" | 63 #include "gpu/command_buffer/service/shader_translator.h" |
64 #include "gpu/command_buffer/service/texture_manager.h" | 64 #include "gpu/command_buffer/service/texture_manager.h" |
65 #include "gpu/command_buffer/service/transform_feedback_manager.h" | 65 #include "gpu/command_buffer/service/transform_feedback_manager.h" |
66 #include "gpu/command_buffer/service/vertex_array_manager.h" | 66 #include "gpu/command_buffer/service/vertex_array_manager.h" |
67 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 67 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
68 #include "gpu/ipc/common/gpu_surface_lookup.h" | |
piman
2016/11/09 17:50:07
So, including gpu/ipc is a layering violation. Ind
klausw
2016/11/11 00:04:10
I'm a bit confused about the layering violation an
| |
68 #include "third_party/angle/src/image_util/loadimage.h" | 69 #include "third_party/angle/src/image_util/loadimage.h" |
69 #include "third_party/smhasher/src/City.h" | 70 #include "third_party/smhasher/src/City.h" |
70 #include "ui/gfx/buffer_types.h" | 71 #include "ui/gfx/buffer_types.h" |
71 #include "ui/gfx/geometry/point.h" | 72 #include "ui/gfx/geometry/point.h" |
72 #include "ui/gfx/geometry/rect.h" | 73 #include "ui/gfx/geometry/rect.h" |
73 #include "ui/gfx/geometry/rect_conversions.h" | 74 #include "ui/gfx/geometry/rect_conversions.h" |
74 #include "ui/gfx/geometry/size.h" | 75 #include "ui/gfx/geometry/size.h" |
75 #include "ui/gfx/gpu_memory_buffer.h" | 76 #include "ui/gfx/gpu_memory_buffer.h" |
76 #include "ui/gfx/overlay_transform.h" | 77 #include "ui/gfx/overlay_transform.h" |
77 #include "ui/gfx/transform.h" | 78 #include "ui/gfx/transform.h" |
78 #include "ui/gl/ca_renderer_layer_params.h" | 79 #include "ui/gl/ca_renderer_layer_params.h" |
79 #include "ui/gl/gl_bindings.h" | 80 #include "ui/gl/gl_bindings.h" |
80 #include "ui/gl/gl_context.h" | 81 #include "ui/gl/gl_context.h" |
81 #include "ui/gl/gl_fence.h" | 82 #include "ui/gl/gl_fence.h" |
82 #include "ui/gl/gl_image.h" | 83 #include "ui/gl/gl_image.h" |
83 #include "ui/gl/gl_implementation.h" | 84 #include "ui/gl/gl_implementation.h" |
84 #include "ui/gl/gl_surface.h" | 85 #include "ui/gl/gl_surface.h" |
86 #include "ui/gl/gl_surface_egl.h" | |
piman
2016/11/09 17:50:06
I believe we can't include this on Mac (EGL is not
klausw
2016/11/09 21:21:55
Done, now Android only.
| |
85 #include "ui/gl/gl_version_info.h" | 87 #include "ui/gl/gl_version_info.h" |
86 #include "ui/gl/gpu_timing.h" | 88 #include "ui/gl/gpu_timing.h" |
87 | 89 |
88 #if defined(OS_MACOSX) | 90 #if defined(OS_MACOSX) |
89 #include <IOSurface/IOSurface.h> | 91 #include <IOSurface/IOSurface.h> |
90 // Note that this must be included after gl_bindings.h to avoid conflicts. | 92 // Note that this must be included after gl_bindings.h to avoid conflicts. |
91 #include <OpenGL/CGLIOSurface.h> | 93 #include <OpenGL/CGLIOSurface.h> |
92 #endif | 94 #endif |
93 | 95 |
94 namespace gpu { | 96 namespace gpu { |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1027 | 1029 |
1028 void DoMatrixLoadfCHROMIUM(GLenum matrix_mode, | 1030 void DoMatrixLoadfCHROMIUM(GLenum matrix_mode, |
1029 const volatile GLfloat* matrix); | 1031 const volatile GLfloat* matrix); |
1030 void DoMatrixLoadIdentityCHROMIUM(GLenum matrix_mode); | 1032 void DoMatrixLoadIdentityCHROMIUM(GLenum matrix_mode); |
1031 void DoScheduleCALayerInUseQueryCHROMIUM(GLsizei count, | 1033 void DoScheduleCALayerInUseQueryCHROMIUM(GLsizei count, |
1032 const volatile GLuint* textures); | 1034 const volatile GLuint* textures); |
1033 | 1035 |
1034 void DoFlushMappedBufferRange( | 1036 void DoFlushMappedBufferRange( |
1035 GLenum target, GLintptr offset, GLsizeiptr size); | 1037 GLenum target, GLintptr offset, GLsizeiptr size); |
1036 | 1038 |
1039 void DoSetSurfaceHandleCHROMIUM(GLint surface_handle); | |
1040 | |
1037 // Creates a Program for the given program. | 1041 // Creates a Program for the given program. |
1038 Program* CreateProgram(GLuint client_id, GLuint service_id) { | 1042 Program* CreateProgram(GLuint client_id, GLuint service_id) { |
1039 return program_manager()->CreateProgram(client_id, service_id); | 1043 return program_manager()->CreateProgram(client_id, service_id); |
1040 } | 1044 } |
1041 | 1045 |
1042 // Gets the program info for the given program. Returns NULL if none exists. | 1046 // Gets the program info for the given program. Returns NULL if none exists. |
1043 Program* GetProgram(GLuint client_id) { | 1047 Program* GetProgram(GLuint client_id) { |
1044 return program_manager()->GetProgram(client_id); | 1048 return program_manager()->GetProgram(client_id); |
1045 } | 1049 } |
1046 | 1050 |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2124 Error Handle##name(uint32_t immediate_data_size, const volatile void* data); | 2128 Error Handle##name(uint32_t immediate_data_size, const volatile void* data); |
2125 | 2129 |
2126 GLES2_COMMAND_LIST(GLES2_CMD_OP) | 2130 GLES2_COMMAND_LIST(GLES2_CMD_OP) |
2127 | 2131 |
2128 #undef GLES2_CMD_OP | 2132 #undef GLES2_CMD_OP |
2129 | 2133 |
2130 // The GL context this decoder renders to on behalf of the client. | 2134 // The GL context this decoder renders to on behalf of the client. |
2131 scoped_refptr<gl::GLSurface> surface_; | 2135 scoped_refptr<gl::GLSurface> surface_; |
2132 scoped_refptr<gl::GLContext> context_; | 2136 scoped_refptr<gl::GLContext> context_; |
2133 | 2137 |
2138 // Direct render mode data for switching and restoring the | |
2139 // underlying destination surface, cf. DoSetSurfaceHandleCHROMIUM. | |
2140 struct DirectRenderState{ | |
2141 scoped_refptr<gl::GLSurface> direct_surface; | |
2142 scoped_refptr<gl::GLSurface> orig_surface; | |
2143 std::unique_ptr<BackFramebuffer> orig_offscreen_target_frame_buffer; | |
2144 bool orig_supports_async_swap; | |
2145 bool orig_back_buffer_has_depth; | |
piman
2016/11/09 17:50:07
saving/restoring the old values seems like additio
klausw
2016/11/09 21:21:56
I've refactored it by extracting bits of Initializ
| |
2146 }; | |
2147 std::unique_ptr<DirectRenderState> direct_render_state_; | |
2148 | |
2134 // The ContextGroup for this decoder uses to track resources. | 2149 // The ContextGroup for this decoder uses to track resources. |
2135 scoped_refptr<ContextGroup> group_; | 2150 scoped_refptr<ContextGroup> group_; |
2136 | 2151 |
2137 DebugMarkerManager debug_marker_manager_; | 2152 DebugMarkerManager debug_marker_manager_; |
2138 Logger logger_; | 2153 Logger logger_; |
2139 | 2154 |
2140 // All the state for this context. | 2155 // All the state for this context. |
2141 ContextState state_; | 2156 ContextState state_; |
2142 | 2157 |
2143 std::unique_ptr<TransformFeedbackManager> transform_feedback_manager_; | 2158 std::unique_ptr<TransformFeedbackManager> transform_feedback_manager_; |
(...skipping 14786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16930 static const char kFunctionName[] = | 16945 static const char kFunctionName[] = |
16931 "glApplyScreenSpaceAntialiasingCHROMIUM"; | 16946 "glApplyScreenSpaceAntialiasingCHROMIUM"; |
16932 if (!InitializeCopyTextureCHROMIUM(kFunctionName)) | 16947 if (!InitializeCopyTextureCHROMIUM(kFunctionName)) |
16933 return; | 16948 return; |
16934 apply_framebuffer_attachment_cmaa_intel_ | 16949 apply_framebuffer_attachment_cmaa_intel_ |
16935 ->ApplyFramebufferAttachmentCMAAINTEL(this, bound_framebuffer, | 16950 ->ApplyFramebufferAttachmentCMAAINTEL(this, bound_framebuffer, |
16936 copy_texture_CHROMIUM_.get()); | 16951 copy_texture_CHROMIUM_.get()); |
16937 } | 16952 } |
16938 } | 16953 } |
16939 | 16954 |
16955 void GLES2DecoderImpl::DoSetSurfaceHandleCHROMIUM(GLint surface_handle) { | |
16956 #if defined(OS_ANDROID) | |
16957 if (surface_handle) { | |
16958 // Use the specified surface as a render target, and save decoder | |
16959 // state so that this can be reverted later. | |
16960 | |
16961 // Ignore redundant calls. For now we don't support switching between | |
16962 // different surfaces, if you need this you have to make a call with | |
16963 // surface_handle=0 in between. | |
piman
2016/11/09 17:50:06
This is a bit distasteful as an API... It doesn't
klausw
2016/11/09 21:21:55
Fixed, it raises an error now if the current conte
| |
16964 if (direct_render_state_) { | |
16965 return; | |
16966 } | |
16967 | |
16968 direct_render_state_.reset(new DirectRenderState()); | |
16969 | |
16970 // One-time initialization when first activating a direct draw surface. | |
16971 ANativeWindow* window = | |
16972 gpu::GpuSurfaceLookup::GetInstance()->AcquireNativeWidget( | |
16973 surface_handle); | |
piman
2016/11/09 17:50:06
This could be NULL? How should we handle this?
klausw
2016/11/09 21:21:55
Changed to raise an error.
| |
16974 direct_render_state_->direct_surface = | |
16975 new gl::NativeViewGLSurfaceEGL(window); | |
piman
2016/11/09 17:50:07
So, this is an extremely powerful capability. If t
klausw
2016/11/11 00:04:10
After discussion with Brandon, it sounds best to g
| |
16976 | |
16977 // It would be useful if we could get a custom surface format such | |
16978 // as one with a depth buffer here, but the new surface must use | |
16979 // the same format as the one originally used for creating the GL | |
16980 // context. Anything else just results in BAD_MATCH errors. | |
16981 bool initialize_success = direct_render_state_->direct_surface->Initialize( | |
16982 surface_->GetFormat()); | |
16983 if (!initialize_success) { | |
16984 LOG(ERROR) << "Direct render surface init failed for handle " << | |
16985 surface_handle; | |
16986 } | |
16987 ANativeWindow_release(window); | |
16988 | |
16989 direct_render_state_->orig_surface = surface_; | |
16990 | |
16991 // We don't want async swap since we want full control over when the | |
16992 // SurfaceTexture gets updated. | |
piman
2016/11/09 17:50:06
FYI, "async" swap doesn't remove any "control", it
klausw
2016/11/09 21:21:55
I removed this, I had misunderstood how it works a
| |
16993 direct_render_state_->orig_supports_async_swap = supports_async_swap_; | |
16994 supports_async_swap_ = false; | |
piman
2016/11/09 17:50:06
what about other properties of the surface, like s
klausw
2016/11/09 21:21:55
See above, the new shared methods should keep them
| |
16995 direct_render_state_->orig_back_buffer_has_depth = back_buffer_has_depth_; | |
16996 back_buffer_has_depth_ = true; | |
piman
2016/11/09 17:50:06
What makes this true?
klausw
2016/11/09 21:21:55
This was an assumption based on the current use ca
| |
16997 // override back_buffer_has_stencil_ too? | |
piman
2016/11/09 17:50:07
What is this comment, is it a TODO? If so, please
klausw
2016/11/09 21:21:55
Should be fixed now.
| |
16998 | |
16999 // Offscreen surfaces don't support SwapBuffers, make sure it's not | |
17000 // considered offscreen. Various code in this file checks for is_offscreen | |
17001 // = !!offscreen_target_frame_buffer_.get(). | |
17002 direct_render_state_->orig_offscreen_target_frame_buffer = | |
17003 std::move(offscreen_target_frame_buffer_); | |
17004 offscreen_target_frame_buffer_.reset(nullptr); | |
17005 | |
17006 // Activate the surface. This does *not* rebind the active framebuffer, | |
17007 // callers must do so themselves as needed. | |
piman
2016/11/09 17:50:06
We should keep a consistent state. If the default
klausw
2016/11/09 21:21:55
I've added MakeCurrent and am applying glViewport
piman
2016/11/09 22:26:09
Correct.
klausw
2016/11/10 02:28:07
Acknowledged.
| |
17008 SetSurface(direct_render_state_->direct_surface); | |
17009 } else { | |
17010 // Restore original state for drawing offscreen. | |
17011 | |
17012 // Ignore redundant calls. | |
17013 if (!direct_render_state_) return; | |
17014 | |
17015 supports_async_swap_ = direct_render_state_->orig_supports_async_swap; | |
17016 back_buffer_has_depth_ = direct_render_state_->orig_back_buffer_has_depth; | |
17017 offscreen_target_frame_buffer_ = | |
17018 std::move(direct_render_state_->orig_offscreen_target_frame_buffer); | |
17019 | |
17020 SetSurface(direct_render_state_->orig_surface); | |
17021 | |
17022 // Trust the state struct's destructors to handle refcounting for | |
17023 // surfaces and trigger apprpriate cleanup. | |
17024 direct_render_state_.reset(); | |
17025 } | |
17026 #else // !OS_ANDROID | |
17027 LOCAL_SET_GL_ERROR( | |
17028 GL_INVALID_OPERATION, | |
17029 "glSetSurfaceHandleCHROMIUM", | |
17030 "Direct render surface is unsupported on this platform"); | |
17031 #endif | |
17032 } | |
17033 | |
16940 void GLES2DecoderImpl::DoInsertEventMarkerEXT( | 17034 void GLES2DecoderImpl::DoInsertEventMarkerEXT( |
16941 GLsizei length, const GLchar* marker) { | 17035 GLsizei length, const GLchar* marker) { |
16942 if (!marker) { | 17036 if (!marker) { |
16943 marker = ""; | 17037 marker = ""; |
16944 } | 17038 } |
16945 debug_marker_manager_.SetMarker( | 17039 debug_marker_manager_.SetMarker( |
16946 length ? std::string(marker, length) : std::string(marker)); | 17040 length ? std::string(marker, length) : std::string(marker)); |
16947 } | 17041 } |
16948 | 17042 |
16949 void GLES2DecoderImpl::DoPushGroupMarkerEXT( | 17043 void GLES2DecoderImpl::DoPushGroupMarkerEXT( |
(...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
18796 } | 18890 } |
18797 | 18891 |
18798 // Include the auto-generated part of this file. We split this because it means | 18892 // Include the auto-generated part of this file. We split this because it means |
18799 // we can easily edit the non-auto generated parts right here in this file | 18893 // we can easily edit the non-auto generated parts right here in this file |
18800 // instead of having to edit some template or the code generator. | 18894 // instead of having to edit some template or the code generator. |
18801 #include "base/macros.h" | 18895 #include "base/macros.h" |
18802 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18896 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
18803 | 18897 |
18804 } // namespace gles2 | 18898 } // namespace gles2 |
18805 } // namespace gpu | 18899 } // namespace gpu |
OLD | NEW |