1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
gpu / ipc / common / gpu_channel.mojom [blame]
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module gpu.mojom;
import "gpu/ipc/common/capabilities.mojom";
import "gpu/ipc/common/context_result.mojom";
import "gpu/ipc/common/mailbox.mojom";
import "gpu/ipc/common/shared_image_metadata.mojom";
import "gpu/ipc/common/shared_image_pool_id.mojom";
import "gpu/ipc/common/surface_handle.mojom";
import "gpu/ipc/common/sync_token.mojom";
import "gpu/ipc/common/vulkan_ycbcr_info.mojom";
import "mojo/public/mojom/base/shared_memory.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
import "services/viz/public/mojom/compositing/shared_image_format.mojom";
import "skia/public/mojom/image_info.mojom";
import "skia/public/mojom/surface_origin.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "ui/gfx/mojom/buffer_types.mojom";
import "ui/gfx/mojom/color_space.mojom";
import "ui/gfx/mojom/gpu_fence_handle.mojom";
import "ui/gfx/mojom/native_handle_types.mojom";
import "ui/gfx/mojom/presentation_feedback.mojom";
import "ui/gl/mojom/gpu_preference.mojom";
import "url/mojom/url.mojom";
// Maps to its namesake in gpu/command_buffer/common/context_creation_attribs.h.
enum ContextType {
kWebGL1,
kWebGL2,
kOpenGLES2,
kOpenGLES3,
kOpenGLES31ForTesting,
kWebGPU,
};
// Maps to its namesake in gpu/command_buffer/common/context_creation_attribs.h.
enum ContextColorSpace {
kUnspecified,
kSRGB,
kDisplayP3,
};
// Maps to its namesake in gpu/command_buffer/common/scheduling_priority.h.
enum SchedulingPriority {
kHigh,
kNormal,
kLow,
};
// Maps to its namesake in gpu/command_buffer/common/context_creation_attribs.h.
struct ContextCreationAttribs {
gl.mojom.GpuPreference gpu_preference = kLowPower;
bool bind_generates_resource = true;
bool fail_if_major_perf_caveat = false;
bool lose_context_when_out_of_memory = false;
bool enable_gles2_interface = true;
bool enable_grcontext = false;
bool enable_raster_interface = false;
bool enable_oop_rasterization = false;
ContextType context_type = kOpenGLES2;
};
struct CreateCommandBufferParams {
int32 share_group_id;
int32 stream_id;
SchedulingPriority stream_priority;
ContextCreationAttribs attribs;
url.mojom.Url active_url;
};
// Corresponds to the definition in gpu/command_buffer/common/constants.h.
[Native]
enum Error;
// Corresponds to the definition in gpu/command_buffer/common/constants.h.
[Native]
enum ContextLostReason;
// Information used by the GPU service to convey the current state of a specific
// CommandBuffer instance. Corresponds to gpu::CommandBuffer::State. See
// gpu/command_buffer/common/command_buffer.h.
struct CommandBufferState {
int32 get_offset;
int32 token;
uint64 release_count;
Error error;
ContextLostReason context_lost_reason;
uint32 generation;
uint32 set_get_buffer_count;
};
struct ScheduleImageDecodeParams {
array<uint8> encoded_data;
gfx.mojom.Size output_size;
int32 raster_decoder_route_id;
uint32 transfer_cache_entry_id;
int32 discardable_handle_shm_id;
uint32 discardable_handle_shm_offset;
uint64 discardable_handle_release_count;
gfx.mojom.ColorSpace target_color_space;
bool needs_mips;
};
// Main control interface for a GPU process connection. For now an instance of
// this interface is associated with each C++ GpuChannel/Host's underlying
// IPC::Channel interface. Eventually it will replace the IPC::Channel.
interface GpuChannel {
// Crashes the GPU process in a similar way to how chrome://gpucrash does.
// This is only supported in testing environments with the GPU benchmarking
// extension enabled and is otherwise ignored.
//
// NOTE: It's important to handle this message early, on the IO thread, in
// case the main thread is hung. This is the purpose of this message:
// generating minidumps on the bots, which are symbolized later by the test
// harness.
CrashForTesting();
// Terminates the GPU process with an exit code of 0. This message is handled
// only in tests when the GPU benchmarking extension is enabled. Its purpose
// is to enable test coverage of scenarios where the GPU process is
// intentionally terminated with an exit code of 0.
TerminateForTesting();
// Returns a globally unique token which can be used by other interfaces to
// securely identify this GpuChannel endpoint within the GPU process.
[Sync] GetChannelToken() => (mojo_base.mojom.UnguessableToken token);
// A simple no-op message used as a fence to ensure all previously sent
// messages have been received.
//
// NoInterrupt is safe on this message because it's handled immediately on the
// GPU IO thread, which is never allowed to block.
[Sync, NoInterrupt] Flush() => ();
// `version_buffer` is a handle to a shared memory region that only
// contains a single 64 bit atomic integer used as a flushed message id.
// The number is read from renderers and updated from the
// gpu process on FlushDeferredRequests.
[Sync, NoInterrupt] GetSharedMemoryForFlushId() =>
(mojo_base.mojom.ReadOnlySharedMemoryRegion? version_buffer);
// Tells the GPU process to create a new command buffer. A corresponding
// CommandBufferStub is created. If `params` provides a non-null
// SurfaceHandle, |size| is ignored and it will render directly to the native
// surface (only the browser process is allowed to create those). Otherwise it
// will create an offscreen backbuffer of dimensions `size`.
[Sync, NoInterrupt] CreateCommandBuffer(
CreateCommandBufferParams params, int32 routing_id,
mojo_base.mojom.UnsafeSharedMemoryRegion shared_state,
pending_associated_receiver<CommandBuffer> receiver,
pending_associated_remote<CommandBufferClient> client)
=> (ContextResult result, Capabilities capabilties,
GLCapabilities gl_capabilities);
// The CommandBufferProxy sends this to the CommandBufferStub in its
// destructor, so that the stub deletes the actual CommandBufferService
// object that it's hosting.
[Sync, NoInterrupt] DestroyCommandBuffer(int32 routing_id) => ();
// Schedules a hardware-accelerated image decode in the GPU process. Renderers
// should use gpu::ImageDecodeAcceleratorProxy to schedule decode requests
// which are processed by gpu::ImageDecodeAcceleratorStub on the service side.
ScheduleImageDecode(ScheduleImageDecodeParams params,
uint64 decode_release_count);
// Sends a batch of DeferredRequests to be executed by the service.
// `flushed_deferred_message_id` is used to update the per-channel id of
// messages confirmed to be flushed that's read on the client side through
// shared memory obtained by GetSharedMemoryForFlushId().
FlushDeferredRequests(array<DeferredRequest> requests,
uint32 flushed_deferred_message_id);
// Create a GpuMemoryBuffer on IO thread. Note that this needs to be a
// blocking call on calling client's thread in order to return the
// GpuMemoryBufferHandle before it's used to create a mailbox from it.
[Sync] CreateGpuMemoryBuffer(gfx.mojom.Size size,
viz.mojom.SharedImageFormat format, gfx.mojom.BufferUsage buffer_usage)
=> (gfx.mojom.GpuMemoryBufferHandle buffer_handle);
// Gets the GpuMemoryBufferHandle for the corresponding `mailbox` from
// service side. Note that this needs to be a blocking call on calling
// client's thread in order to return the GpuMemoryBufferHandle and other
// metadata required by client to map the mailbox to CPU memory before it can
// read/write from/to it.
[Sync] GetGpuMemoryBufferHandleInfo(gpu.mojom.Mailbox mailbox)
=> (gfx.mojom.GpuMemoryBufferHandle buffer_handle,
viz.mojom.SharedImageFormat format, gfx.mojom.Size size,
gfx.mojom.BufferUsage buffer_usage);
// Creates a StreamTexture associated with the given `stream_id`.
[Sync, EnableIf=is_android] CreateStreamTexture(
int32 stream_id,
pending_associated_receiver<StreamTexture> receiver) => (bool success);
// Creates a DCOMPTexture and attaches to the provided `route_id`.
// Note: this `route_id` must not conflict with the routing ids for command
// buffers or shared image stub. Otherwise, unexpected behaviour can happen
// if `Add/RemoveRoute()` is called with a pre-existing routing id.
[Sync, EnableIf=is_win] CreateDCOMPTexture(
int32 route_id,
pending_associated_receiver<DCOMPTexture> receiver) => (bool success);
// This interface is used by MediaFoundationRendererClient to subscribe
// to overlay state information from the Viz layer (as provided by the
// DCOverlayProcessor). The MediaFoundationRendererClient uses the overlay
// state associated with a Video Frame texture (correlated via 'mailbox') as
// a heuristic to determine the best video presentation mode to use.
[Sync, EnableIf=is_win] RegisterOverlayStateObserver(
pending_remote<OverlayStateObserver> promotion_hint_observer,
gpu.mojom.Mailbox mailbox) => (bool success);
// Instructs the command buffer to wait asynchronously until its State is
// changed by the reader to have a current token value within the (inclusive)
// range [start, end]. Once in range, the command buffer will reply and
// unblock the caller.
//
// TODO(rockot): This should move to the CommandBuffer interface, but it has
// unique dispatching constraints which require it to be processed
// out-of-order from other scheduled messages targeting the command buffer.
// For now we use a GpuChannel message with a `routing_id` to target a
// specific CommandBuffer.
[Sync, NoInterrupt] WaitForTokenInRange(
int32 routing_id, int32 start, int32 end) => (CommandBufferState state);
// Instructs the command buffer to wait asynchronously until its State is
// changed by the reader to have a current get offset within the (inclusive)
// range [start, end], on the get buffer identified by `set_get_buffer_count`.
// Once in range, the command buffer will reply and unblock the caller.
//
// TODO(rockot): This should move to the CommandBuffer interface, but it has
// unique dispatching constraints which require it to be processed
// out-of-order from other scheduled messages targeting the command buffer.
// For now we use a GpuChannel message with a `routing_id` to target a
// specific CommandBuffer.
[Sync, NoInterrupt] WaitForGetOffsetInRange(
int32 routing_id, uint32 set_get_buffer_count, int32 start, int32 end)
=> (CommandBufferState state);
[EnableIf=is_fuchsia]
RegisterSysmemBufferCollection(
handle<platform> service_handle, handle<platform> sysmem_token,
viz.mojom.SharedImageFormat format, gfx.mojom.BufferUsage usage,
bool register_with_image_pipe);
// Updates the contents of the GpuMemoryBuffer associated with the shared
// image. Necessary on platforms like Windows where we use shared memory GMBs
// for readback from D3D texture shared images. The copy, if successful, is
// complete when the callback runs.
[EnableIf=is_win]
CopyToGpuMemoryBufferAsync(
Mailbox mailbox, array<SyncToken> sync_token_dependencies,
uint64 release_count) => (bool success);
[Sync, EnableIf=is_win]
// Copies GMB pixel data from the native handle to the |shared_memory|.
// Returns |true| if the copy has succeeded.
// Note that this method has some similar functionality but is different than
// above CopyToGpuMemoryBufferAsync in the sense that above method is only
// used for shared memory GMBs whereas this method is used for native GMBs.
// This has to be a blocking operation since it will be called during
// GpuMemoryBuffer::Map() operation which should provide updated data to
// clients before using it.
CopyNativeGmbToSharedMemorySync(gfx.mojom.GpuMemoryBufferHandle
buffer_handle, mojo_base.mojom.UnsafeSharedMemoryRegion shared_memory)
=> (bool success);
// This is non-blocking version of above method.
[EnableIf=is_win]
CopyNativeGmbToSharedMemoryAsync(gfx.mojom.GpuMemoryBufferHandle
buffer_handle, mojo_base.mojom.UnsafeSharedMemoryRegion shared_memory)
=> (bool success);
};
// Interface used to issue commands to a specific CommandBuffer instance in the
// GPU process.
interface CommandBuffer {
// Sets the shared memory buffer to use for commands. The ID given here must
// correspond to one registered by a prior RegisterTransferBuffer IPC to the
// same CommandBuffer.
SetGetBuffer(int32 shm_id);
// Registers an existing shared memory transfer buffer with an `id` that can
// be used to identify it within a command buffer.
RegisterTransferBuffer(int32 id,
mojo_base.mojom.UnsafeSharedMemoryRegion buffer);
// Sends a GPU fence handle and store it for the specified gpu fence ID.
CreateGpuFenceFromHandle(uint32 gpu_fence_id,
gfx.mojom.GpuFenceHandle fence_handle);
// Requests retrieval of a GpuFenceHandle by ID.
GetGpuFenceHandle(uint32 id) => (gfx.mojom.GpuFenceHandle? fence_handle);
// Asynchronously waits until the SyncToken is signaled, then sends a
// corresponding SignalAck on the CommandBufferClient interface, using
// `signal_id` to identify this request.
SignalSyncToken(SyncToken sync_token, uint32 signal_id);
// Asynchronously waits until a given query is reached in the command buffer,
// then sends a corresponding SignalAck on the CommandBufferClient interface,
// using `signal_id` to identify this request.
SignalQuery(uint32 query, uint32 signal_id);
};
// Corresponds to gpu::SwapBuffersCompleteParams.
[Native]
struct SwapBuffersCompleteParams;
// Interface used by the GPU process to send the client messages from a specific
// CommandBuffer instance.
interface CommandBufferClient {
// Notifies the client about a console message emitted on behalf of the
// command buffer. These messages are intended to be exposed by
// developer-facing UI such as the DevTools console.
OnConsoleMessage(string message);
// Notifies the client of a GPU switch.
OnGpuSwitched(gl.mojom.GpuPreference active_gpu_heuristic);
// Tells the proxy that there was an error and the command buffer had to be
// destroyed for some reason.
OnDestroyed(ContextLostReason reason, Error error);
// Returns a block of data from the GPU process to the client.
// This contains server->client messages produced by dawn_wire and is used to
// remote WebGPU.
OnReturnData(array<uint8> data);
// Signals the completion of an asynchronous wait initiated by SignalSyncToken
// or SignalQuery on the corresponding CommandBuffer interface. `signal_id`
// identifies the specific request being acknowledged.
OnSignalAck(uint32 signal_id, CommandBufferState state);
};
// Interface to control a single StreamTexture instance. Implemented in the GPU
// process and called by renderer clients.
//
// NOTE: Due to limitations of Channel-associated interfaces, message replies on
// this interface must not be used to pass other associated interface remotes or
// receivers.
[EnableIf=is_android]
interface StreamTexture {
// Tells the StreamTexture to send its SurfaceTexture to the browser process,
// via the ScopedSurfaceRequestConduit. `token` is used to uniquely identify
// the surface request to the browser, and therefore must be a token already
// minted by the browser and somehow procured by the caller.
ForwardForSurfaceRequest(mojo_base.mojom.UnguessableToken token);
// Tells the service-side instance to start sending frame available
// notifications.
StartListening(pending_associated_remote<StreamTextureClient> client);
// Updates the visible size from MediaPlayer. The size includes rotation of
// video.
UpdateRotatedVisibleSize(gfx.mojom.Size rotated_visible_size);
};
// Interface used by GPU to notify the client of a StreamTexture instance about
// new frame availability. Implemented by renderer clients and called by
// StreamTexture instances in the GPU process.
//
// NOTE: Due to limitations of Channel-associated interfaces, messages on this
// interface must not be used to pass other associated interface remotes or
// receivers.
[EnableIf=is_android]
interface StreamTextureClient {
// Informs the client that a new frame is available.
OnFrameAvailable();
// Informs the client that a new frame with VulkanYcbcrInfo is available.
OnFrameWithInfoAvailable(Mailbox mailbox, gfx.mojom.Size coded_size,
gfx.mojom.Rect visible_rect,
VulkanYCbCrInfo? info);
};
// Interface to control a single DCOMPTexture instance. Implemented in the GPU
// process and called by renderer clients.
[EnableIf=is_win]
interface DCOMPTexture {
// Starts sending DCOMP surface notifications via the `client`. Follows the
// pattern in `StreamTexture::StartListening()` to delay notifications until
// the client side is ready.
//
// TODO(crbug.com/40642952): Investigate if we can remove this by having the
// `client` as a parameter to `CreateDCOMPTexture()`.
StartListening(pending_associated_remote<DCOMPTextureClient> client);
// Sets the size of DCOMPTexture.
SetTextureSize(gfx.mojom.Size size);
// Binds the DCOMPTexture to a DCOMP surface handle and returns whether the
// operation succeeded or not. The surface handle is provided as `token`
// registered with the DCOMP surface handle registry in the GPU process.
SetDCOMPSurfaceHandle(mojo_base.mojom.UnguessableToken token)
=> (bool success);
};
// Interface used by GPU to notify the client of a DCOMPTexture instance about
// SharedImage mailbox and DCOMP Surface Handle have been bound to the
// DCOMPTexture instance. It also notifies client about the change in compositon
// on-screen output video rectangle. Implemented by renderer clients and called
// by DCOMPTexture instances in the GPU process.
[EnableIf=is_win]
interface DCOMPTextureClient {
// Informs the client that a SharedImage mailbox has been bound to the
// DCOMPTexture instance.
OnSharedImageMailboxBound(Mailbox mailbox);
// Informs the client of a change in video composition parameter.
OnOutputRectChange(gfx.mojom.Rect output_rect);
};
// Interface used by GPU to notify clients when the overlay promotion hint state
// has changed.
[EnableIf=is_win]
interface OverlayStateObserver {
// Called when the texture associated with the specified mailbox has had a
// change in promotion state. If promoted is true then the texture is
// currently using a DC Layer Overlay. If promoted is false then the texture
// is not using a DC Layer Overlay.
OnStateChanged(bool promoted);
};
// DeferredRequests are batched locally by clients and sent to the service only
// when flushing the channel via GpuChannelHost's EnsureFlush or VerifyFlush.
struct DeferredRequest {
// Parameters for the specific type of request.
DeferredRequestParams params;
// A list of SyncTokens which must be released before the request can be
// processed.
array<SyncToken> sync_token_fences;
// The sync point release count that is expected to be reached after execution
// of this request.
// 0 means this request doesn't release.
uint64 release_count;
};
// Details of a batched request.
union DeferredRequestParams {
// This request targets a specific command buffer instance.
DeferredCommandBufferRequest command_buffer_request;
// This request pertains to shared image management.
DeferredSharedImageRequest shared_image_request;
// Sent to indicate the client wants to destroy the StreamTexture identified
// by this ID.
[EnableIf=is_android]
int32 destroy_stream_texture;
// Sent to indicate the client wants to destroy the DCOMPTexture identified
// by this ID.
[EnableIf=is_win]
int32 destroy_dcomp_texture;
};
// Details of a batched request targeting a specific command buffer.
struct DeferredCommandBufferRequest {
// Identifies the command buffer targeted by this request.
int32 routing_id;
// The specific request parameters.
DeferredCommandBufferRequestParams params;
};
// Details of a batched request targeting a specific command buffer.
union DeferredCommandBufferRequestParams {
// See AsyncFlushParams.
AsyncFlushParams async_flush;
// Destroys a transfer buffer identified by this ID.
int32 destroy_transfer_buffer;
// Allows to attach SharedImage to default framebuffer of this context.
// NOTE: Used only for PNaCL.
SetDefaultFramebufferSharedImageParams set_default_framebuffer_shared_image;
};
// Details of a batched request pertaining to shared image management.
union DeferredSharedImageRequest {
// Sent by clients to record a point in the sequence of pending deferred
// messages. Actual value is ignored.
uint8 nop;
// See CreateSharedImageParams.
CreateSharedImageParams create_shared_image;
// See CreateSharedImageWithDataParams.
CreateSharedImageWithDataParams create_shared_image_with_data;
// See CreateSharedImageWithBufferParams.
CreateSharedImageWithBufferParams create_shared_image_with_buffer;
// Registers a new shared memory region to share with the GPU process for
// uploading shared image data.
mojo_base.mojom.ReadOnlySharedMemoryRegion register_upload_buffer;
// See UpdateSharedImageParams.
UpdateSharedImageParams update_shared_image;
// See CopyToGpuMemoryBufferParams.
CopyToGpuMemoryBufferParams copy_to_gpu_memory_buffer;
// Destroys the shared image identified by this Mailbox.
Mailbox destroy_shared_image;
AddReferenceToSharedImageParams add_reference_to_shared_image;
// See CreateSwapChainParams.
[EnableIf=is_win]
CreateSwapChainParams create_swap_chain;
// See PresentSwapChainParams.
[EnableIf=is_win]
PresentSwapChainParams present_swap_chain;
// See RegisterDxgiFenceParams.
[EnableIf=is_win]
RegisterDxgiFenceParams register_dxgi_fence;
// See UpdateDxgiFenceParams.
[EnableIf=is_win]
UpdateDxgiFenceParams update_dxgi_fence;
// See UnregisterDxgiFenceParams.
[EnableIf=is_win]
UnregisterDxgiFenceParams unregister_dxgi_fence;
};
// Asynchronously synchronize the put and get offsets of both processes.
// Caller passes its current put offset. Current state (including get offset)
// is returned in shared memory.
// TODO(sunnyps): This is an internal implementation detail of the gpu service
// and is not sent by the client. Remove this once the non-scheduler code path
// is removed.
struct AsyncFlushParams {
int32 put_offset;
uint32 flush_id;
array<SyncToken> sync_token_fences;
};
// Sets SharedImage mailbox and other framebuffer params to the default
// framebuffer. NOTE: This exists only to support PNaCl.
struct SetDefaultFramebufferSharedImageParams {
// The mailbox of the shared image. Can be empty if client wants to detach
// SharedImage from the color buffer.
Mailbox mailbox;
// Number of samples for the multisampling.
uint32 samples_count;
// If default framebuffer needs to presevre contents across the frames.
bool preserve;
// If this framebuffer needs depth buffer.
bool needs_depth;
// If this framebuffer needs stencil buffer.
bool needs_stencil;
};
// Common params used when creating a new shared image.
struct SharedImageInfo {
// Metadata about the shared image being created.
SharedImageMetadata meta;
// Retained for heap dumps and passed to graphics APIs for tracing tools.
// Pick a name that is unique to the allocation site.
string debug_label;
};
// Creates a new shared image.
struct CreateSharedImageParams {
// The mailbox used to identify the shared image.
Mailbox mailbox;
// Information about the shared image.
SharedImageInfo si_info;
// An optional SharedImagePoolId which indicates the pool this shared image
// is created from.
SharedImagePoolId? pool_id;
};
// Creates a new shared image and populates it with pixel data from a shared
// memory region previously configured by the client.
struct CreateSharedImageWithDataParams {
// The mailbox used to identify the shared image.
Mailbox mailbox;
// Information about the shared image.
SharedImageInfo si_info;
// Offset from which to copy data out of the current image upload shared
// memory region.
uint32 pixel_data_offset;
// Size of data to copy out of the current image upload shared memory region.
uint32 pixel_data_size;
// If `true`, this is the last usage of the current image upload shared memory
// region, so the region can be discarded after servicing this request.
bool done_with_shm;
};
// Creates a new shared image with an existing GPU memory buffer.
// If format is multi-planar then `buffer_handle` contains all the planes.
struct CreateSharedImageWithBufferParams {
// The mailbox used to identify the shared image.
Mailbox mailbox;
// Information about the shared image.
SharedImageInfo si_info;
// A handle to the existing GPU memory buffer.
gfx.mojom.GpuMemoryBufferHandle buffer_handle;
// An optional SharedImagePoolId which indicates the pool this shared image
// is created from.
SharedImagePoolId? pool_id;
};
// Updates the contents of a shared image from whatever is backing it, if
// applicable.
struct UpdateSharedImageParams {
// The mailbox identifying the shared image to update.
Mailbox mailbox;
// An optional GpuFenceHandle for the server to wait on before updating the
// image from whatever backs it.
gfx.mojom.GpuFenceHandle? in_fence_handle;
};
// Adds reference to the shared image that was created on a different
// GpuChannel. This allows SharedImage that is shared across processes to
// outlive original client.
struct AddReferenceToSharedImageParams {
// The mailbox identifying the shared image to add ref.
Mailbox mailbox;
};
// Updates the contents of the GpuMemoryBuffer associated with the shared image.
// Necessary on platforms like Windows and Linux where renderer cannot create
// native GMBs. The command performs synchronization with the GPU so the copy is
// complete after the command runs.
struct CopyToGpuMemoryBufferParams {
// The mailbox identifying the shared image which should update its GMB.
Mailbox mailbox;
};
[EnableIf=is_win]
struct CreateSwapChainParams {
// Mailbox identifying the front buffer of the swap chain.
Mailbox front_buffer_mailbox;
// Mailbox identifying the back buffer of the swap chain.
Mailbox back_buffer_mailbox;
// Pixel format of the front and back buffers.
viz.mojom.SharedImageFormat format;
// Size of the buffers.
gfx.mojom.Size size;
// Color space of the buffers.
gfx.mojom.ColorSpace color_space;
// Usage flags corresponding to values defined in
// gpu/command_buffer/common/shared_image_usage.h.
uint32 usage;
// Which corner is considered the origin of the swap chain's buffers.
skia.mojom.SurfaceOrigin surface_origin;
// Indicates how the alpha component of each pixel is interpreted.
skia.mojom.AlphaType alpha_type;
};
[EnableIf=is_win]
struct PresentSwapChainParams {
// Mailbox identifying the swap chain to present.
Mailbox mailbox;
};
[EnableIf=is_win]
struct RegisterDxgiFenceParams {
// Mailbox identifying the shared image backing to register fence.
Mailbox mailbox;
// The DXGIHandleToken to identifying the registered gpu fence handle.
// Use this token to update fence after registration.
gfx.mojom.DXGIHandleToken dxgi_token;
// The fence handle to register.
gfx.mojom.GpuFenceHandle fence_handle;
};
[EnableIf=is_win]
struct UpdateDxgiFenceParams {
// Mailbox identifying the shared image backing to update the fence.
Mailbox mailbox;
// The DXGIHandleToken to identifying the fence to update.
gfx.mojom.DXGIHandleToken dxgi_token;
// The fence value to signal.
uint64 fence_value;
};
[EnableIf=is_win]
struct UnregisterDxgiFenceParams {
// Mailbox identifying the shared image backing to clear the fence.
Mailbox mailbox;
// The DXGIHandleToken to identifying the fence needs to be cleared.
gfx.mojom.DXGIHandleToken dxgi_token;
};