Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef COMPONENTS_VIZ_HOST_GPU_HOST_IMPL_H_ |
| 6 | #define COMPONENTS_VIZ_HOST_GPU_HOST_IMPL_H_ |
| 7 | |
| 8 | #include <map> |
| 9 | #include <queue> |
| 10 | #include <set> |
| 11 | #include <string> |
Mohsen Izadi | babed2b | 2018-08-31 01:37:39 | [diff] [blame] | 12 | #include <vector> |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 13 | |
Mohsen Izadi | babed2b | 2018-08-31 01:37:39 | [diff] [blame] | 14 | #include "base/callback.h" |
John Abd-El-Malek | b36a379 | 2021-04-19 20:54:31 | [diff] [blame] | 15 | #include "base/containers/flat_map.h" |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 16 | #include "base/macros.h" |
| 17 | #include "base/memory/scoped_refptr.h" |
| 18 | #include "base/memory/weak_ptr.h" |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 19 | #include "base/process/process_handle.h" |
| 20 | #include "base/sequence_checker.h" |
Bo Liu | 95570f3 | 2020-03-16 23:42:17 | [diff] [blame] | 21 | #include "base/timer/timer.h" |
Peter McNeeley | 40245f0 | 2021-05-04 21:50:50 | [diff] [blame] | 22 | #include "base/values.h" |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 23 | #include "build/build_config.h" |
Miyoung Shin | 8b0b0f2 | 2019-07-17 04:35:08 | [diff] [blame] | 24 | #include "components/discardable_memory/public/mojom/discardable_shared_memory_manager.mojom.h" |
Robert Sesek | a9b47c9 | 2019-08-30 01:22:54 | [diff] [blame] | 25 | #include "components/ui_devtools/buildflags.h" |
Peter McNeeley | 40245f0 | 2021-05-04 21:50:50 | [diff] [blame] | 26 | #include "components/viz/common/buildflags.h" |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 27 | #include "components/viz/host/viz_host_export.h" |
| 28 | #include "gpu/command_buffer/common/activity_flags.h" |
Mohsen Izadi | 312c692 | 2018-09-07 14:21:36 | [diff] [blame] | 29 | #include "gpu/config/gpu_domain_guilt.h" |
Ken Rockot | b2928f3 | 2019-03-12 04:43:03 | [diff] [blame] | 30 | #include "mojo/public/cpp/bindings/pending_receiver.h" |
Shimi Zhang | 88ae922 | 2019-07-19 16:54:16 | [diff] [blame] | 31 | #include "mojo/public/cpp/bindings/pending_remote.h" |
| 32 | #include "mojo/public/cpp/bindings/receiver.h" |
| 33 | #include "mojo/public/cpp/bindings/remote.h" |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 34 | #include "mojo/public/cpp/system/message_pipe.h" |
Ken Rockot | b2928f3 | 2019-03-12 04:43:03 | [diff] [blame] | 35 | #include "services/service_manager/public/mojom/service.mojom.h" |
Miyoung Shin | 2be27f5 | 2019-07-27 15:35:39 | [diff] [blame] | 36 | #include "services/viz/privileged/mojom/compositing/frame_sink_manager.mojom.h" |
| 37 | #include "services/viz/privileged/mojom/gl/gpu_host.mojom.h" |
| 38 | #include "services/viz/privileged/mojom/gl/gpu_service.mojom.h" |
| 39 | #include "services/viz/privileged/mojom/viz_main.mojom.h" |
Anton Bikineev | 1156b5f | 2021-05-15 22:35:36 | [diff] [blame^] | 40 | #include "third_party/abseil-cpp/absl/types/optional.h" |
Alexander Dunaev | e6e09c1 | 2020-10-23 16:43:42 | [diff] [blame] | 41 | #include "ui/gfx/gpu_extra_info.h" |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 42 | #include "url/gurl.h" |
| 43 | |
Maggie Chen | a6ece77 | 2020-04-27 17:19:06 | [diff] [blame] | 44 | #if defined(OS_WIN) |
| 45 | #include "services/viz/privileged/mojom/gl/info_collection_gpu_service.mojom.h" |
| 46 | #endif |
| 47 | |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 48 | namespace gfx { |
| 49 | struct FontRenderParams; |
| 50 | } |
| 51 | |
| 52 | namespace gpu { |
| 53 | class ShaderCacheFactory; |
| 54 | class ShaderDiskCache; |
| 55 | } // namespace gpu |
| 56 | |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 57 | namespace viz { |
| 58 | |
Peter McNeeley | 40245f0 | 2021-05-04 21:50:50 | [diff] [blame] | 59 | class VIZ_HOST_EXPORT GpuHostImpl : public mojom::GpuHost |
| 60 | #if BUILDFLAG(USE_VIZ_DEBUGGER) |
| 61 | , |
| 62 | public mojom::VizDebugOutput |
| 63 | #endif |
| 64 | { |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 65 | public: |
| 66 | class VIZ_HOST_EXPORT Delegate { |
| 67 | public: |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 68 | virtual gpu::GPUInfo GetGPUInfo() const = 0; |
| 69 | virtual gpu::GpuFeatureInfo GetGpuFeatureInfo() const = 0; |
Mohsen Izadi | f9505d8 | 2018-10-06 01:34:03 | [diff] [blame] | 70 | virtual void DidInitialize( |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 71 | const gpu::GPUInfo& gpu_info, |
| 72 | const gpu::GpuFeatureInfo& gpu_feature_info, |
Anton Bikineev | 1156b5f | 2021-05-15 22:35:36 | [diff] [blame^] | 73 | const absl::optional<gpu::GPUInfo>& gpu_info_for_hardware_gpu, |
| 74 | const absl::optional<gpu::GpuFeatureInfo>& |
Jonah Ryan-Davis | a70577c | 2019-06-26 18:54:31 | [diff] [blame] | 75 | gpu_feature_info_for_hardware_gpu, |
Alexander Dunaev | e6e09c1 | 2020-10-23 16:43:42 | [diff] [blame] | 76 | const gfx::GpuExtraInfo& gpu_extra_info) = 0; |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 77 | virtual void DidFailInitialize() = 0; |
| 78 | virtual void DidCreateContextSuccessfully() = 0; |
Bo Liu | 95570f3 | 2020-03-16 23:42:17 | [diff] [blame] | 79 | virtual void MaybeShutdownGpuProcess() = 0; |
Jonah Ryan-Davis | a54a300 | 2020-12-08 17:34:50 | [diff] [blame] | 80 | virtual void DidUpdateGPUInfo(const gpu::GPUInfo& gpu_info) = 0; |
Maggie Chen | 8f17717 | 2020-02-11 00:02:28 | [diff] [blame] | 81 | #if defined(OS_WIN) |
| 82 | virtual void DidUpdateOverlayInfo(const gpu::OverlayInfo& overlay_info) = 0; |
Maggie Chen | 05364bf3 | 2020-06-03 08:34:06 | [diff] [blame] | 83 | virtual void DidUpdateHDRStatus(bool hdr_enabled) = 0; |
Maggie Chen | 8f17717 | 2020-02-11 00:02:28 | [diff] [blame] | 84 | #endif |
Mohsen Izadi | 312c692 | 2018-09-07 14:21:36 | [diff] [blame] | 85 | virtual void BlockDomainFrom3DAPIs(const GURL& url, |
| 86 | gpu::DomainGuilt guilt) = 0; |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 87 | virtual void DisableGpuCompositing() = 0; |
| 88 | virtual bool GpuAccessAllowed() const = 0; |
| 89 | virtual gpu::ShaderCacheFactory* GetShaderCacheFactory() = 0; |
| 90 | virtual void RecordLogMessage(int32_t severity, |
| 91 | const std::string& header, |
| 92 | const std::string& message) = 0; |
Julie Jeongeun Kim | 7b4a6aa1 | 2019-09-20 14:57:12 | [diff] [blame] | 93 | virtual void BindDiscardableMemoryReceiver( |
| 94 | mojo::PendingReceiver< |
| 95 | discardable_memory::mojom::DiscardableSharedMemoryManager> |
| 96 | receiver) = 0; |
Mohsen Izadi | 63d85e7 | 2018-09-06 16:00:21 | [diff] [blame] | 97 | virtual void BindInterface( |
| 98 | const std::string& interface_name, |
| 99 | mojo::ScopedMessagePipeHandle interface_pipe) = 0; |
Mohsen Izadi | 63d85e7 | 2018-09-06 16:00:21 | [diff] [blame] | 100 | #if defined(USE_OZONE) |
| 101 | virtual void TerminateGpuProcess(const std::string& message) = 0; |
Mohsen Izadi | 63d85e7 | 2018-09-06 16:00:21 | [diff] [blame] | 102 | #endif |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 103 | |
| 104 | protected: |
| 105 | virtual ~Delegate() {} |
| 106 | }; |
| 107 | |
| 108 | struct VIZ_HOST_EXPORT InitParams { |
| 109 | InitParams(); |
| 110 | InitParams(InitParams&&); |
| 111 | ~InitParams(); |
| 112 | |
| 113 | // An ID that changes for each GPU restart. |
| 114 | int restart_id = -1; |
| 115 | |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 116 | // Whether caching GPU shader on disk is disabled or not. |
Mohsen Izadi | 50c2805 | 2018-09-07 00:32:14 | [diff] [blame] | 117 | bool disable_gpu_shader_disk_cache = false; |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 118 | |
| 119 | // A string representing the product name and version; used to build a |
| 120 | // prefix for shader keys. |
| 121 | std::string product; |
| 122 | |
| 123 | // Number of frames to CompositorFrame activation deadline. |
Anton Bikineev | 1156b5f | 2021-05-15 22:35:36 | [diff] [blame^] | 124 | absl::optional<uint32_t> deadline_to_synchronize_surfaces; |
Mohsen Izadi | 63d85e7 | 2018-09-06 16:00:21 | [diff] [blame] | 125 | |
| 126 | // Task runner corresponding to the main thread. |
| 127 | scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner; |
Maggie Chen | a6ece77 | 2020-04-27 17:19:06 | [diff] [blame] | 128 | |
| 129 | // Whether this GPU process is used for GPU info collection only. |
| 130 | bool info_collection_gpu_process = false; |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | enum class EstablishChannelStatus { |
| 134 | kGpuAccessDenied, // GPU access was not allowed. |
| 135 | kGpuHostInvalid, // Request failed because the GPU host became invalid |
| 136 | // while processing the request (e.g. the GPU process |
| 137 | // may have been killed). The caller should normally |
| 138 | // make another request to establish a new channel. |
| 139 | kSuccess, |
| 140 | }; |
| 141 | using EstablishChannelCallback = |
| 142 | base::OnceCallback<void(mojo::ScopedMessagePipeHandle, |
| 143 | const gpu::GPUInfo&, |
| 144 | const gpu::GpuFeatureInfo&, |
| 145 | EstablishChannelStatus)>; |
| 146 | |
Mohsen Izadi | f9505d8 | 2018-10-06 01:34:03 | [diff] [blame] | 147 | GpuHostImpl(Delegate* delegate, |
Ken Rockot | 7f8a282 | 2021-04-06 23:27:52 | [diff] [blame] | 148 | mojo::PendingRemote<mojom::VizMain> viz_main, |
Mohsen Izadi | f9505d8 | 2018-10-06 01:34:03 | [diff] [blame] | 149 | InitParams params); |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 150 | ~GpuHostImpl() override; |
| 151 | |
| 152 | static void InitFontRenderParams(const gfx::FontRenderParams& params); |
Mohsen Izadi | f9505d8 | 2018-10-06 01:34:03 | [diff] [blame] | 153 | static void ResetFontRenderParams(); |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 154 | |
kylechar | 9b37f17 | 2019-09-19 22:55:27 | [diff] [blame] | 155 | void SetProcessId(base::ProcessId pid); |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 156 | void OnProcessCrashed(); |
| 157 | |
Mohsen Izadi | babed2b | 2018-08-31 01:37:39 | [diff] [blame] | 158 | // Adds a connection error handler for the GpuService. |
| 159 | void AddConnectionErrorHandler(base::OnceClosure handler); |
| 160 | |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 161 | void BlockLiveOffscreenContexts(); |
| 162 | |
| 163 | // Connects to FrameSinkManager running in the Viz service. |
Mario Sanchez Prada | 745dd5e | 2019-10-16 14:14:30 | [diff] [blame] | 164 | void ConnectFrameSinkManager( |
| 165 | mojo::PendingReceiver<mojom::FrameSinkManager> receiver, |
Alexander Alekseev | 81b0161 | 2020-07-10 22:56:29 | [diff] [blame] | 166 | mojo::PendingRemote<mojom::FrameSinkManagerClient> client, |
| 167 | const DebugRendererSettings& debug_renderer_settings); |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 168 | |
Robert Sesek | a9b47c9 | 2019-08-30 01:22:54 | [diff] [blame] | 169 | #if BUILDFLAG(USE_VIZ_DEVTOOLS) |
Sean Gilhuly | da1ee4b | 2018-11-13 21:56:09 | [diff] [blame] | 170 | // Connects to Viz DevTools running in the Viz service. |
| 171 | void ConnectVizDevTools(mojom::VizDevToolsParamsPtr params); |
| 172 | #endif |
| 173 | |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 174 | // Tells the GPU service to create a new channel for communication with a |
| 175 | // client. Once the GPU service responds asynchronously with the channel |
John Abd-El-Malek | b36a379 | 2021-04-19 20:54:31 | [diff] [blame] | 176 | // handle and GPUInfo, we call the callback. If |sync| is true then the |
| 177 | // callback will be run before this method returns, and note that the |
| 178 | // browser GPU info data might not be initialized as well. |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 179 | void EstablishGpuChannel(int client_id, |
| 180 | uint64_t client_tracing_id, |
| 181 | bool is_gpu_host, |
John Abd-El-Malek | b36a379 | 2021-04-19 20:54:31 | [diff] [blame] | 182 | bool sync, |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 183 | EstablishChannelCallback callback); |
John Abd-El-Malek | b36a379 | 2021-04-19 20:54:31 | [diff] [blame] | 184 | void CloseChannel(int client_id); |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 185 | |
Peter McNeeley | 40245f0 | 2021-05-04 21:50:50 | [diff] [blame] | 186 | #if BUILDFLAG(USE_VIZ_DEBUGGER) |
| 187 | // Command as a Json string that the visual debugging instance interprets as |
| 188 | // stream filtering. |
| 189 | void FilterVisualDebugStream(base::Value filter_data); |
| 190 | |
| 191 | // Establishes the connection between the visual debugging instance and the |
| 192 | // output stream. |
| 193 | void StartVisualDebugStream( |
| 194 | base::RepeatingCallback<void(base::Value)> callback); |
| 195 | |
| 196 | void StopVisualDebugStream(); |
| 197 | #endif |
| 198 | |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 199 | void SendOutstandingReplies(); |
| 200 | |
Mohsen Izadi | 63d85e7 | 2018-09-06 16:00:21 | [diff] [blame] | 201 | void BindInterface(const std::string& interface_name, |
| 202 | mojo::ScopedMessagePipeHandle interface_pipe); |
Mohsen Izadi | 63d85e7 | 2018-09-06 16:00:21 | [diff] [blame] | 203 | |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 204 | mojom::GpuService* gpu_service(); |
| 205 | |
Maggie Chen | a6ece77 | 2020-04-27 17:19:06 | [diff] [blame] | 206 | #if defined(OS_WIN) |
| 207 | mojom::InfoCollectionGpuService* info_collection_gpu_service(); |
| 208 | #endif |
| 209 | |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 210 | bool wake_up_gpu_before_drawing() const { |
| 211 | return wake_up_gpu_before_drawing_; |
| 212 | } |
| 213 | |
| 214 | private: |
Mohsen Izadi | f9505d8 | 2018-10-06 01:34:03 | [diff] [blame] | 215 | friend class GpuHostImplTestApi; |
| 216 | |
Mohsen Izadi | 63d85e7 | 2018-09-06 16:00:21 | [diff] [blame] | 217 | #if defined(USE_OZONE) |
| 218 | void InitOzone(); |
| 219 | void TerminateGpuProcess(const std::string& message); |
| 220 | #endif // defined(USE_OZONE) |
| 221 | |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 222 | std::string GetShaderPrefixKey(); |
| 223 | |
| 224 | void LoadedShader(int32_t client_id, |
| 225 | const std::string& key, |
| 226 | const std::string& data); |
| 227 | |
| 228 | void CreateChannelCache(int32_t client_id); |
| 229 | |
| 230 | void OnChannelEstablished(int client_id, |
John Abd-El-Malek | b36a379 | 2021-04-19 20:54:31 | [diff] [blame] | 231 | bool sync, |
| 232 | mojo::ScopedMessagePipeHandle channel_handle, |
| 233 | const gpu::GPUInfo& gpu_info, |
| 234 | const gpu::GpuFeatureInfo& gpu_feature_info); |
Bo Liu | 95570f3 | 2020-03-16 23:42:17 | [diff] [blame] | 235 | void MaybeShutdownGpuProcess(); |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 236 | |
| 237 | // mojom::GpuHost: |
| 238 | void DidInitialize( |
| 239 | const gpu::GPUInfo& gpu_info, |
| 240 | const gpu::GpuFeatureInfo& gpu_feature_info, |
Anton Bikineev | 1156b5f | 2021-05-15 22:35:36 | [diff] [blame^] | 241 | const absl::optional<gpu::GPUInfo>& gpu_info_for_hardware_gpu, |
| 242 | const absl::optional<gpu::GpuFeatureInfo>& |
Jonah Ryan-Davis | a70577c | 2019-06-26 18:54:31 | [diff] [blame] | 243 | gpu_feature_info_for_hardware_gpu, |
Alexander Dunaev | e6e09c1 | 2020-10-23 16:43:42 | [diff] [blame] | 244 | const gfx::GpuExtraInfo& gpu_extra_info) override; |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 245 | void DidFailInitialize() override; |
| 246 | void DidCreateContextSuccessfully() override; |
| 247 | void DidCreateOffscreenContext(const GURL& url) override; |
| 248 | void DidDestroyOffscreenContext(const GURL& url) override; |
| 249 | void DidDestroyChannel(int32_t client_id) override; |
Bo Liu | 95570f3 | 2020-03-16 23:42:17 | [diff] [blame] | 250 | void DidDestroyAllChannels() override; |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 251 | void DidLoseContext(bool offscreen, |
| 252 | gpu::error::ContextLostReason reason, |
| 253 | const GURL& active_url) override; |
| 254 | void DisableGpuCompositing() override; |
Jonah Ryan-Davis | a54a300 | 2020-12-08 17:34:50 | [diff] [blame] | 255 | void DidUpdateGPUInfo(const gpu::GPUInfo& gpu_info) override; |
Mohsen Izadi | 50c2805 | 2018-09-07 00:32:14 | [diff] [blame] | 256 | #if defined(OS_WIN) |
Maggie Chen | 8f17717 | 2020-02-11 00:02:28 | [diff] [blame] | 257 | void DidUpdateOverlayInfo(const gpu::OverlayInfo& overlay_info) override; |
Maggie Chen | 05364bf3 | 2020-06-03 08:34:06 | [diff] [blame] | 258 | void DidUpdateHDRStatus(bool hdr_enabled) override; |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 259 | void SetChildSurface(gpu::SurfaceHandle parent, |
| 260 | gpu::SurfaceHandle child) override; |
Mohsen Izadi | 50c2805 | 2018-09-07 00:32:14 | [diff] [blame] | 261 | #endif |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 262 | void StoreShaderToDisk(int32_t client_id, |
| 263 | const std::string& key, |
| 264 | const std::string& shader) override; |
| 265 | void RecordLogMessage(int32_t severity, |
| 266 | const std::string& header, |
| 267 | const std::string& message) override; |
| 268 | |
Peter McNeeley | 40245f0 | 2021-05-04 21:50:50 | [diff] [blame] | 269 | // Implements mojom::VizDebugOutput and is called by VizDebugger. |
| 270 | #if BUILDFLAG(USE_VIZ_DEBUGGER) |
| 271 | void LogFrame(base::Value frame_data) override; |
| 272 | #endif |
| 273 | |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 274 | Delegate* const delegate_; |
Ken Rockot | 7f8a282 | 2021-04-06 23:27:52 | [diff] [blame] | 275 | mojo::Remote<mojom::VizMain> viz_main_; |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 276 | const InitParams params_; |
| 277 | |
Mohsen Izadi | 63d85e7 | 2018-09-06 16:00:21 | [diff] [blame] | 278 | // Task runner corresponding to the thread |this| is created on. |
| 279 | scoped_refptr<base::SingleThreadTaskRunner> host_thread_task_runner_; |
| 280 | |
Shimi Zhang | 88ae922 | 2019-07-19 16:54:16 | [diff] [blame] | 281 | mojo::Remote<mojom::GpuService> gpu_service_remote_; |
Maggie Chen | a6ece77 | 2020-04-27 17:19:06 | [diff] [blame] | 282 | #if defined(OS_WIN) |
| 283 | mojo::Remote<mojom::InfoCollectionGpuService> |
| 284 | info_collection_gpu_service_remote_; |
| 285 | #endif |
Shimi Zhang | 88ae922 | 2019-07-19 16:54:16 | [diff] [blame] | 286 | mojo::Receiver<mojom::GpuHost> gpu_host_receiver_{this}; |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 287 | gpu::GpuProcessHostActivityFlags activity_flags_; |
| 288 | |
Peter McNeeley | 40245f0 | 2021-05-04 21:50:50 | [diff] [blame] | 289 | #if BUILDFLAG(USE_VIZ_DEBUGGER) |
| 290 | mojo::Receiver<mojom::VizDebugOutput> viz_debug_output_{this}; |
| 291 | base::RepeatingCallback<void(base::Value)> viz_debug_output_callback_; |
| 292 | #endif |
| 293 | |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 294 | base::ProcessId pid_ = base::kNullProcessId; |
| 295 | |
Mohsen Izadi | babed2b | 2018-08-31 01:37:39 | [diff] [blame] | 296 | // List of connection error handlers for the GpuService. |
| 297 | std::vector<base::OnceClosure> connection_error_handlers_; |
| 298 | |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 299 | // The following are a list of driver bug workarounds that will only be |
| 300 | // set to true in DidInitialize(), where GPU service has started and GPU |
| 301 | // driver bug workarounds have been computed and sent back. |
| 302 | bool wake_up_gpu_before_drawing_ = false; |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 303 | |
| 304 | // Track the URLs of the pages which have live offscreen contexts, assumed to |
| 305 | // be associated with untrusted content such as WebGL. For best robustness, |
| 306 | // when any context lost notification is received, assume all of these URLs |
| 307 | // are guilty, and block automatic execution of 3D content from those domains. |
| 308 | std::multiset<GURL> urls_with_live_offscreen_contexts_; |
| 309 | |
| 310 | std::map<int32_t, scoped_refptr<gpu::ShaderDiskCache>> |
| 311 | client_id_to_shader_cache_; |
| 312 | std::string shader_prefix_key_; |
| 313 | |
| 314 | // These are the channel requests that we have already sent to the GPU |
| 315 | // service, but haven't heard back about yet. |
John Abd-El-Malek | b36a379 | 2021-04-19 20:54:31 | [diff] [blame] | 316 | base::flat_map<int, EstablishChannelCallback> channel_requests_; |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 317 | |
Bo Liu | 95570f3 | 2020-03-16 23:42:17 | [diff] [blame] | 318 | base::OneShotTimer shutdown_timeout_; |
| 319 | |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 320 | SEQUENCE_CHECKER(sequence_checker_); |
| 321 | |
Jeremy Roman | 5c341f6d | 2019-07-15 15:56:10 | [diff] [blame] | 322 | base::WeakPtrFactory<GpuHostImpl> weak_ptr_factory_{this}; |
Mohsen Izadi | 0b9fbb6 | 2018-08-30 20:30:00 | [diff] [blame] | 323 | |
| 324 | DISALLOW_COPY_AND_ASSIGN(GpuHostImpl); |
| 325 | }; |
| 326 | |
| 327 | } // namespace viz |
| 328 | |
| 329 | #endif // COMPONENTS_VIZ_HOST_GPU_HOST_IMPL_H_ |