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" | |
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" | |
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 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1049 | 1051 |
1050 void DoMatrixLoadfCHROMIUM(GLenum matrix_mode, | 1052 void DoMatrixLoadfCHROMIUM(GLenum matrix_mode, |
1051 const volatile GLfloat* matrix); | 1053 const volatile GLfloat* matrix); |
1052 void DoMatrixLoadIdentityCHROMIUM(GLenum matrix_mode); | 1054 void DoMatrixLoadIdentityCHROMIUM(GLenum matrix_mode); |
1053 void DoScheduleCALayerInUseQueryCHROMIUM(GLsizei count, | 1055 void DoScheduleCALayerInUseQueryCHROMIUM(GLsizei count, |
1054 const volatile GLuint* textures); | 1056 const volatile GLuint* textures); |
1055 | 1057 |
1056 void DoFlushMappedBufferRange( | 1058 void DoFlushMappedBufferRange( |
1057 GLenum target, GLintptr offset, GLsizeiptr size); | 1059 GLenum target, GLintptr offset, GLsizeiptr size); |
1058 | 1060 |
1061 void DoSetSurfaceHandleCHROMIUM(GLint surface_handle); | |
1062 | |
1059 // Creates a Program for the given program. | 1063 // Creates a Program for the given program. |
1060 Program* CreateProgram(GLuint client_id, GLuint service_id) { | 1064 Program* CreateProgram(GLuint client_id, GLuint service_id) { |
1061 return program_manager()->CreateProgram(client_id, service_id); | 1065 return program_manager()->CreateProgram(client_id, service_id); |
1062 } | 1066 } |
1063 | 1067 |
1064 // Gets the program info for the given program. Returns NULL if none exists. | 1068 // Gets the program info for the given program. Returns NULL if none exists. |
1065 Program* GetProgram(GLuint client_id) { | 1069 Program* GetProgram(GLuint client_id) { |
1066 return program_manager()->GetProgram(client_id); | 1070 return program_manager()->GetProgram(client_id); |
1067 } | 1071 } |
1068 | 1072 |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2146 Error Handle##name(uint32_t immediate_data_size, const volatile void* data); | 2150 Error Handle##name(uint32_t immediate_data_size, const volatile void* data); |
2147 | 2151 |
2148 GLES2_COMMAND_LIST(GLES2_CMD_OP) | 2152 GLES2_COMMAND_LIST(GLES2_CMD_OP) |
2149 | 2153 |
2150 #undef GLES2_CMD_OP | 2154 #undef GLES2_CMD_OP |
2151 | 2155 |
2152 // The GL context this decoder renders to on behalf of the client. | 2156 // The GL context this decoder renders to on behalf of the client. |
2153 scoped_refptr<gl::GLSurface> surface_; | 2157 scoped_refptr<gl::GLSurface> surface_; |
2154 scoped_refptr<gl::GLContext> context_; | 2158 scoped_refptr<gl::GLContext> context_; |
2155 | 2159 |
2160 // WebVR data for switching and restoring the underlying destination surface. | |
2161 scoped_refptr<gl::GLSurface> webvr_surface_; | |
2162 scoped_refptr<gl::GLSurface> webvr_orig_surface_; | |
2163 std::unique_ptr<BackFramebuffer> webvr_orig_offscreen_target_frame_buffer_; | |
2164 bool webvr_orig_supports_async_swap_; | |
2165 | |
2156 // The ContextGroup for this decoder uses to track resources. | 2166 // The ContextGroup for this decoder uses to track resources. |
2157 scoped_refptr<ContextGroup> group_; | 2167 scoped_refptr<ContextGroup> group_; |
2158 | 2168 |
2159 DebugMarkerManager debug_marker_manager_; | 2169 DebugMarkerManager debug_marker_manager_; |
2160 Logger logger_; | 2170 Logger logger_; |
2161 | 2171 |
2162 // All the state for this context. | 2172 // All the state for this context. |
2163 ContextState state_; | 2173 ContextState state_; |
2164 | 2174 |
2165 std::unique_ptr<TransformFeedbackManager> transform_feedback_manager_; | 2175 std::unique_ptr<TransformFeedbackManager> transform_feedback_manager_; |
(...skipping 14634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16800 RestoreCurrentFramebufferBindings(); | 16810 RestoreCurrentFramebufferBindings(); |
16801 if (LOCAL_PEEK_GL_ERROR("glApplyFramebufferAttachmentCMAAINTEL") != | 16811 if (LOCAL_PEEK_GL_ERROR("glApplyFramebufferAttachmentCMAAINTEL") != |
16802 GL_NO_ERROR) | 16812 GL_NO_ERROR) |
16803 return; | 16813 return; |
16804 } | 16814 } |
16805 apply_framebuffer_attachment_cmaa_intel_ | 16815 apply_framebuffer_attachment_cmaa_intel_ |
16806 ->ApplyFramebufferAttachmentCMAAINTEL(this, bound_framebuffer); | 16816 ->ApplyFramebufferAttachmentCMAAINTEL(this, bound_framebuffer); |
16807 } | 16817 } |
16808 } | 16818 } |
16809 | 16819 |
16820 void GLES2DecoderImpl::DoSetSurfaceHandleCHROMIUM(GLint surface_handle) { | |
bajones
2016/10/28 00:41:22
Looking at this implementation the function name i
bajones
2016/10/28 16:47:46
Oh, and I also realized last night that you're goi
klausw
2016/11/08 02:18:30
It no longer changes the framebuffer binding in th
klausw
2016/11/08 02:18:30
Done, and added an #else to raise a GL_INVALID_OPE
| |
16821 if (surface_handle) { | |
16822 // Use the specified surface as a render target, saving the offscreen | |
16823 // render buffer so that we can restore it later. | |
16824 | |
16825 // Ignore redundant calls. For now we don't support switching between | |
16826 // different surfaces, if you need this you have to make a call with | |
16827 // surface_handle=0 in between. | |
16828 if (webvr_surface_) return; | |
16829 | |
16830 // One-time initialization when first activating WebVR surface. | |
16831 ANativeWindow* window = | |
16832 gpu::GpuSurfaceLookup::GetInstance()->AcquireNativeWidget( | |
16833 surface_handle); | |
16834 webvr_surface_ = new gl::NativeViewGLSurfaceEGL(window); | |
16835 // TODO(klausw): need to add a depth buffer for doing 3D rendering. | |
16836 // Currently it's just used for a 2D copy. | |
16837 bool initialize_success = | |
16838 webvr_surface_->Initialize(gl::GLSurface::SURFACE_ARGB8888); | |
16839 if (!initialize_success) { | |
16840 LOG(ERROR) << "WebVR surface init failed, handle=" << surface_handle; | |
16841 } | |
16842 ANativeWindow_release(window); | |
16843 | |
16844 webvr_orig_surface_ = surface_; | |
16845 | |
16846 // We don't want async swap since we want full control over when the | |
16847 // SurfaceTexture gets updated. | |
16848 webvr_orig_supports_async_swap_ = supports_async_swap_; | |
16849 supports_async_swap_ = false; | |
16850 | |
16851 // Offscreen surfaces don't support SwapBuffers, make sure it's not | |
16852 // considered offscreen. Various code in this file checks for is_offscreen | |
16853 // = !!offscreen_target_frame_buffer_.get(). | |
16854 webvr_orig_offscreen_target_frame_buffer_ = | |
16855 std::move(offscreen_target_frame_buffer_); | |
16856 offscreen_target_frame_buffer_.reset(nullptr); | |
16857 | |
16858 // Activate the surface, and use it for rendering. | |
16859 SetSurface(webvr_surface_); | |
16860 glBindFramebufferEXT(GL_FRAMEBUFFER, 0); | |
16861 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); | |
16862 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); | |
16863 | |
16864 // TODO(klausw): is any additional cleanup needed in destructor, or | |
16865 // do smart pointers do the right thing already? | |
16866 } else { | |
16867 // Restore original state for drawing offscreen. | |
16868 | |
16869 // Ignore redundant calls. | |
16870 if (!webvr_surface_) return; | |
16871 | |
16872 // TODO(klausw): check if this is sufficient cleanup, I'm assuming that | |
16873 // clearing the smart pointer calls the appropriate destructor. | |
16874 webvr_surface_ = nullptr; | |
16875 | |
16876 supports_async_swap_ = webvr_orig_supports_async_swap_; | |
16877 | |
16878 offscreen_target_frame_buffer_ = | |
16879 std::move(webvr_orig_offscreen_target_frame_buffer_); | |
16880 webvr_orig_offscreen_target_frame_buffer_.reset(nullptr); | |
16881 | |
16882 SetSurface(webvr_orig_surface_); | |
16883 } | |
16884 } | |
16885 | |
16810 void GLES2DecoderImpl::DoInsertEventMarkerEXT( | 16886 void GLES2DecoderImpl::DoInsertEventMarkerEXT( |
16811 GLsizei length, const GLchar* marker) { | 16887 GLsizei length, const GLchar* marker) { |
16812 if (!marker) { | 16888 if (!marker) { |
16813 marker = ""; | 16889 marker = ""; |
16814 } | 16890 } |
16815 debug_marker_manager_.SetMarker( | 16891 debug_marker_manager_.SetMarker( |
16816 length ? std::string(marker, length) : std::string(marker)); | 16892 length ? std::string(marker, length) : std::string(marker)); |
16817 } | 16893 } |
16818 | 16894 |
16819 void GLES2DecoderImpl::DoPushGroupMarkerEXT( | 16895 void GLES2DecoderImpl::DoPushGroupMarkerEXT( |
(...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
18660 } | 18736 } |
18661 | 18737 |
18662 // Include the auto-generated part of this file. We split this because it means | 18738 // Include the auto-generated part of this file. We split this because it means |
18663 // we can easily edit the non-auto generated parts right here in this file | 18739 // we can easily edit the non-auto generated parts right here in this file |
18664 // instead of having to edit some template or the code generator. | 18740 // instead of having to edit some template or the code generator. |
18665 #include "base/macros.h" | 18741 #include "base/macros.h" |
18666 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18742 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
18667 | 18743 |
18668 } // namespace gles2 | 18744 } // namespace gles2 |
18669 } // namespace gpu | 18745 } // namespace gpu |
OLD | NEW |