Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing GPU via web browser

I came across this proof of concept earlier today (on TechCrunch.com) and was blown away and intrigued as to how they had managed to accomplish the end result. They state that they don't use webGL or any plugins yet they are able to interact directly with the GPU and render 3D visuals at up to 60 fps using nothing but Javascript. Any ideas how this could be done, or how to access the GPU from Javascript in general without the use of plugins?

Site Address is: famo.us

ps: Try using your arrow keys to shift orientation its far out!!

like image 979
Giles Thompson Avatar asked Mar 04 '13 23:03

Giles Thompson


People also ask

Can browser use GPU?

Traditionally, web browsers used the CPU to do all of the content rendering. In the last two years, the major browser makers have incorporated GPU support for rendering animations, video, and 3D graphics. With IE9, Firefox 4, and Chrome 8, all the major browsers enabled GPU acceleration.

How do I make my browser use my GPU?

Open the Chrome Web browser. In the address bar, enter “about:flags” (without the quotes), and then press Enter. A list of experimental features should be displayed. Search for “GPU Accelerated Compositing”, and then click the “Enable” link.

Can JavaScript access GPU?

js is a JavaScript acceleration library that can be used for general-purpose computations on GPUs using JavaScript. It supports browsers, Node. js and TypeScript. In addition to the performance boost, there are several reasons why I recommend using GPU.

What is GPU in browser?

Graphics processing units (GPUs) are becoming increasingly important for applications such as Microsoft Office and web browsers. All of the web browser's extensions, such as Chrome, Firefox, and Internet Explorer, allow you to disable hardware acceleration.


2 Answers

They're using standard HTML5 Javascript APIs to achieve this.

I saw several references to requestAnimationFrame in their code. This method allows one that uses a compatible browser, to display more fluid and optimized animations, with far better frame rates than setInterval based animations will ever allow you to have. This is certainly achieved by using the GPU and the available hardware background.

GPU or every other hardware component cannot be accessed directly using any Javascript routines. Instead, the browser, based on the called JS directives and the execution context, will use the GPU if possible to optimize some specific treatments, calculus and renderings.

EDIT

For future references, I recently found out (7 years after the original answer) that a new initiative - the W3C GPU for the Web Community Group, has recently been created in 2020 to do just that. It describes itself as follow.

The mission of the GPU on the Web Community Group is to provide an interface between the Web Platform and modern 3D graphics and computation capabilities present in native system platforms. The goal is to design a new Web API that exposes these modern technologies in a performant, powerful and safe manner. It should work with existing platform APIs such as Direct3D 12 from Microsoft, Metal from Apple, and Vulkan from the Khronos Group. This API will also expose the generic computational facilities available in today's GPUs to the Web, and investigate shader languages to produce a cross-platform solution.

In the long-term, this initiative might allow developers to directly interact with the GPU from all web browsers. You can track the implementation status of the WebGPU API Spec on Github here.

like image 124
Halim Qarroum Avatar answered Sep 19 '22 18:09

Halim Qarroum


Concerning famo.us: they did analysed the bottlenecks of the Webkit rendering pipe and then found a way to bypass them while building the pages. Basically: the DOM tree construction, the Render tree construction, the Layout of Render Tree are bypassed. Take a look on this article for a whole explanation.

enter image description here

like image 20
Flavien Volken Avatar answered Sep 21 '22 18:09

Flavien Volken