servo / servo

Servo, the embeddable, independent, memory-safe, modular, parallel web rendering engine
https://servo.org
Mozilla Public License 2.0
27.98k stars 2.99k forks source link

Implement WebGPU in Servo #24706

Open zakorgy opened 4 years ago

zakorgy commented 4 years ago

One of the goals of the University of Szeged team in this year is to implement the WebGPU API (https://gpuweb.github.io/gpuweb/) in Servo. This includes the following tasks:

Link to the modified compute example.

cc @jdm, @kvark

zakorgy commented 4 years ago

Some high-level design suggestions from @gterzian from https://github.com/servo/servo/pull/24708#discussion_r346662690:

kvark commented 4 years ago

fwiw, we do want multiple independent WebGPU applications to be able to run in parallel

gterzian commented 4 years ago

fwiw, we do want multiple independent WebGPU applications to be able to run in parallel

How would you define one "application"?

For example, I can imagine multiple agents, like a window and a dedicated worker, running in parallel but actually forming a single "application" and operating on the same (shared?) objects.

Then for example a cross-site iframe could be running another "application". It would be "in parallel", but also isolated in some way from the other application.

Then another example would be: can you share some webgpu obect with the cross-site iframe? Would the iframe and the main window then form a single application?

I think one way to express what an isolated application would be could be by limiting the serializablity of interfaces, using the upcoming infra from https://github.com/whatwg/html/pull/4940

You could also define some limitations in getting an adapter, so that for example multiple calls to get the same type of adapter within a given agent-cluster would return the same one(so that you can only have one application per agent-cluster, for example)


I have another question on something that is not clear to me from the spec: how would a webgpu application "run"? Will there be some equivalent of animation frame callbacks? I'm just wondering how the various interfaces will be used in practice, and how the JS would become aware of various stuff happening on the GPU.

For example the web audio spec defines a rendering-loop(which potentially calls into JS in a dedicated worklet).

I assume you'll define something similar? I assume there will be something requiring calling repeatedly into JS while the something like the GPU pipeline makes progress?

zakorgy commented 4 years ago

Some other things we should take care:

imiklos commented 4 years ago