Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

rewrite Curv to use WebGPU #146

@doug-moen

Description

@doug-moen

The proposal is to rewrite the Curv "viewer" window to use WebGPU, replacing the use of OpenGL.

Rationale: Currently Curv is stuck at version 3.3 of OpenGL due to MacOS compatibility requirements. There's no way to use advanced features like compute shaders in OpenGL due to MacOS limitations. WebGPU can be thought of as the modern replacement for OpenGL. It is faster and more powerful than OpenGL. It is much easier to use than Vulkan. WebGPU is more portable than Vulkan, since it runs on all desktop and mobile platforms, plus it supports web assembly (WASM) and web browsers.

Once Curv is ported to WebGPU, we can build a faster and more powerful rendering engine based on the use of compute shaders.

How To Do It: The only Curv code that needs to change is located in libcurv/viewer. This code runs the graphical "viewer" window. This software component is well isolated from the rest of Curv. One approach is to write a new viewer from scratch, instead of attempting to translate the OpenGL code into WebGPU. There are lots of "GPU shader sandbox" apps available in open source, so we could use an existing such app coded to the WebGPU API as a starting point. (The current Curv viewer is based on GLSLViewer.)

The initial prototype need not be integrated into Curv, it could be a standalone app. Curv has the ability to export a shape as a *.jgpu file: this is a JSON encoding data structure containing all the inputs required to run a Viewer window. So the prototype could just read and parse this JSON file then display the shape in a window. This may simplify the development process.

Since Curv is written in C++, we can use Google's Dawn library, which has a C++ interface. The Curv shader compiler generates GLSL code, so we can use a library to translate GLSL into SPIR-V, which Dawn accepts as input. The current viewer code depends on the ImGUI library for GUI widgets. There's no requirement to use ImGUI in the new viewer implementation, but I see that there is already a WebGPU port for imgui.

Resources:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions