Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
68a305f
fixing problems
KaNaDaAT Nov 26, 2023
d4ce516
ignroe build
KaNaDaAT Nov 26, 2023
d10f98a
Now import via link directly and minor fixes
KaNaDaAT Nov 26, 2023
e851615
feat: Background color now white!
KaNaDaAT Nov 27, 2023
e6ff529
fixed rule drawing
KaNaDaAT Nov 27, 2023
728921b
feat: text rendering and error fix on hover
KaNaDaAT Dec 2, 2023
19b236e
feat: Rules now work
KaNaDaAT Dec 9, 2023
96275ee
fix: general improvement
KaNaDaAT Dec 13, 2023
a3c6c0e
fix: Hover effect didnt work with div
KaNaDaAT Dec 15, 2023
94d6d7f
update: packages updated
KaNaDaAT Dec 15, 2023
7f116a0
feat: VertexBufferManager
KaNaDaAT Dec 15, 2023
02cf28d
feat: Path/Symbol start
KaNaDaAT Dec 23, 2023
4a05e52
feat: cleanup with custom methods. Symbol WORK!
KaNaDaAT Dec 24, 2023
efa946e
refactor: Removed unnecessary files
KaNaDaAT Dec 25, 2023
1b6574e
feat: arc
KaNaDaAT Dec 27, 2023
44d4f1d
fix: Removed debug color
KaNaDaAT Dec 27, 2023
37ef6e7
feat: area
KaNaDaAT Dec 28, 2023
71f66a6
feat: area dirty fix
KaNaDaAT Dec 28, 2023
ae40b1f
fix: depth texture must be recreated on size changes
KaNaDaAT Dec 29, 2023
9ee4147
fix: some default values
KaNaDaAT Dec 29, 2023
2c9c4b5
feat: color updata and rect support borders
KaNaDaAT Dec 29, 2023
234453b
fix: rule
KaNaDaAT Dec 29, 2023
321dad1
todo: line
KaNaDaAT Dec 29, 2023
7ad20cd
fix: line
KaNaDaAT Dec 30, 2023
26601ef
update: General improvments
KaNaDaAT Dec 30, 2023
8663b83
feat: symbols now can have strokes
KaNaDaAT Dec 31, 2023
9ff4052
feat: render rework (less code duplication)
KaNaDaAT Jan 2, 2024
563dc5b
fix: shorter render code for line, arc and area as well
KaNaDaAT Jan 2, 2024
022bc57
feat: IT WORKS!
KaNaDaAT Jan 2, 2024
b73f9aa
feat: performance update
KaNaDaAT Jan 5, 2024
a5a8bdd
feat: path now renders strokes correctly
KaNaDaAT Jan 5, 2024
ed88f02
fix: arc
KaNaDaAT Jan 5, 2024
f96e110
feat: more improvements
KaNaDaAT Jan 6, 2024
abeb6b3
fix: location of paths
KaNaDaAT Jan 6, 2024
915b307
fix: smaller issues fixed and line performance
KaNaDaAT Jan 11, 2024
77ebd9c
feat: Performance update.
KaNaDaAT Jan 13, 2024
62cdd0a
Release: 0.1
KaNaDaAT Jan 13, 2024
1497ab0
small rebuild for test
KaNaDaAT Jan 13, 2024
fa678ab
Version: 1.0.0
KaNaDaAT Jan 14, 2024
c06044b
Update index.html
KaNaDaAT Jan 14, 2024
45a1d88
Release: Version 1.0.0
KaNaDaAT Jan 14, 2024
36ade4a
Update README.md
KaNaDaAT Jan 14, 2024
d92bc6a
Dev Stuff
KaNaDaAT Jan 14, 2024
72665f4
Squashed commit of the following:
KaNaDaAT Jan 14, 2024
00db7f6
Update: Demo updated to 1.1.0
KaNaDaAT Jan 14, 2024
c236d30
Feat: SImple Release
KaNaDaAT Jan 14, 2024
3bb2eee
1_0_0 currently bugged
KaNaDaAT Jan 14, 2024
862efce
README.md aktualisieren
KaNaDaAT Jan 15, 2024
7dccc41
feat: Example supporting Versions now
KaNaDaAT Jan 16, 2024
abf54a1
Performance and structure changes
KaNaDaAT Jan 16, 2024
126b251
Release: 1.1.0
KaNaDaAT Jan 16, 2024
88f6b35
Update README.md
KaNaDaAT Jan 18, 2024
639c959
Example: Now can also use webgl
KaNaDaAT Jan 20, 2024
6e94d2e
Merge branch 'main' of https://github.com/KaNaDaAT/vega-webgpu
KaNaDaAT Jan 20, 2024
c8a10e0
Performance for path
KaNaDaAT Jan 21, 2024
c8e3204
Update benchmark.vg.json
KaNaDaAT Jan 21, 2024
20af2fd
Release: 1.1.0
KaNaDaAT Jan 21, 2024
85abea5
update dependencies
KaNaDaAT Jan 21, 2024
588b256
Render loop improvements
KaNaDaAT Jan 21, 2024
01bac27
Rerelease: 1.1.1
KaNaDaAT Jan 21, 2024
be27f35
Create .gitattributes
KaNaDaAT Jan 23, 2024
d1caa98
Update .gitattributes
KaNaDaAT Jan 23, 2024
e1f19de
Update README.md
KaNaDaAT Jan 23, 2024
6f6316a
Update README.md
KaNaDaAT Jan 24, 2024
6b0b0ab
feat: clipping, line performance,
KaNaDaAT Mar 11, 2024
a2198a1
fix: path offset
KaNaDaAT Mar 11, 2024
5192810
fix: renderBatch
KaNaDaAT Mar 11, 2024
0f3e880
Release: 1.2.0
KaNaDaAT Mar 11, 2024
e7a08a6
Update README.md
KaNaDaAT Mar 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
releases/* linguist-vendored
releases/** linguist-vendored
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
build/*
dist/*
.DS_Store
node_modules
pnpm-debug.log
pnpm-debug.log
test/penguins_read.py
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:5500",
"webRoot": "${workspaceFolder}"
}
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.detectIndentation": false,
"editor.tabSize": 2,
"editor.insertSpaces": true
}

128 changes: 126 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,127 @@
# WebGPU Renderer Extension for Vega
# WebGPU Renderer for [Vega](https://vega.github.io/vega)

WebGPU extension for Vega. This renderer is currently **work in progress and not ready for use**.
[Demo](https://kanadaat.github.io/vega-webgpu/test)

**Warning:** The splom examples of the demo use a set of 50.000 data points. Thus canvas and svg will take very long for it to render or simply crash.

The Vega WebGPU Extension is created by [KaNaDaAT](https://github.com/KaNaDaAT) based on the already existing efforts of [lsh](https://github.com/lsh).

## Basics

This repository contains a WebGPU renderer extension for Vega JS.

Almost all Vega Components can be used. While some are more performant than others.
It is not yet possible to use:
- Images
- Gradient Colors
- Some Properties of Components as for example rounded edges for Rectangles or Groups

**Note:** The WebGPU renderer is currently a work in progress and might not be suitable for all production use.

## How to Use

Use this scaffolding to get started using the WebGPU renderer. Instead of being directly usable after loading Vega, as the SVG and Canvas renderers are, the WebGPU renderer is a plugin which requires the inclusion of an additional JavaScript library.

Therefor all that needs to be done is to link the Vega WebGPU Renderer
```html
<script src="https://kanadaat.github.io/vega-webgpu/releases/1_2_0/vega-webgpu-renderer.js"></script>
```

The WebGPU renderer was developed for Vega 5.19.1. Other Versions may work as well.
```html
<body>
<script src="https://d3js.org/d3.v4.min.js" charset="utf-8"></script>
<script src="https://cdn.jsdelivr.net/npm/vega@5.19.1/build/vega.js"></script>
<script src="https://kanadaat.github.io/vega-webgpu/releases/1_1_1/vega-webgpu-renderer.js"></script>
<div id="vis"></div>
<script>
// Load in your own Vega spec here.
d3.json('https://vega.github.io/vega/examples/bar-chart.vg.json', function (spec) {
var view = new vega.View(vega.parse(spec))
.initialize(document.querySelector('#vis'))
.renderer('webgpu')
.run();
});
</script>
</body>
```

The example shows how it is possible to always use the "latest" version.

For more infos look at [Hosted Versions](#hosted-versions).

## Building Locally
To build the WebGPU renderer locally, follow these steps:

1. Install dependencies: `npm install`
2. Build the renderer: `npm run build`
3. The built `vega-webgpu-renderer.js` file will be available in the `build` directory.


## Development Locally
To develop the WebGPU renderer locally, follow these steps:

1. Install dependencies: `npm install`
2. Build the renderer in dev mode: `npm run dev`
3. Go live using something as the Visual Studio Code "Live Server" Extension and open the test website.

Call: http://localhost:5500/test?spec=bar&renderer=webgpu&version=dev in order to use the local file.

New Versions can be simply released by using the npm run release script.
`npm run release 1.1.1 "Using Render Bundles for Performance"`

Readme has to be changed manually yet.

## Hosted Versions

| Version | Hosted Renderer Link | Changes |
| ------- | -------------------------------------------------------------------------------------------------------- | ------- |
| 1.0.0 | [vega-webgpu-renderer](https://kanadaat.github.io/vega-webgpu/releases/1_0_0/vega-webgpu-renderer.js) | First WebGPU Implementation |
| 1.1.0 | [vega-webgpu-renderer](https://kanadaat.github.io/vega-webgpu/releases/1_1_0/vega-webgpu-renderer.js) | Over all improvements in terms of performance and structure. |
| 1.1.1 | [vega-webgpu-renderer](https://kanadaat.github.io/vega-webgpu/releases/1_1_1/vega-webgpu-renderer.js) | Performance improvements on Paths.<br>Introducing WebGPU Render Option `renderLock`. |
| 1.2.0 | [vega-webgpu-renderer](https://kanadaat.github.io/vega-webgpu/releases/1_2_0/vega-webgpu-renderer.js) | Performance improvements on Lines. Render Bundling Option `renderBatch`. Support Clipping. Path offset fixed. |
Have a look at all versions [here](https://kanadaat.github.io/vega-webgpu/releases).


## WebGPU Renderer Specific Options

The WebGPU allows some options to be set:
```js
fetch('https://vega.github.io/vega/examples/bar-chart.vg.json')
.then(res => res.json())
.then(spec => render(spec))
.catch(err => console.error(err));
function render(spec) {
view = new vega.View(vega.parse(spec), {
renderer: 'webgpu', // renderer (canvas or svg)
container: '#vis', // parent DOM container
hover: true // enable hover processing
});
return view.runAsync();
}
view._renderer.wgOptions.debugLog = true;
// For Version 1.0.0 it is:
// view._renderer.debugLog = true;
```
| Option | Description | Default | Version | Note |
|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|---------|---|
| debugLog | Allows the renderer to log the time needed for the frame | false | 1.0.0 | |
| simpleLine | When set to `false` the renderer will use a different type of line rendering that is optimized for small amount of lines with alot of points (curved lines) | true | 1.0.0 | Since 1.2.0 Deprecated. Look at renderBatch |
| cacheShape | Allows shapes to cache its entries so it might be faster (experimental) | false | 1.1.0 | |
| renderLock | Will lock the render loop from beeing called again until the previous call is finished. Might skip render steps. The most recent will always be called. Will enhance the performance, esspecially for interactive GUI. | true | 1.1.1 | |
| renderBatch | Will enable to render marks in batches if possible. Will render multiple lines at once instead of one after another (parallel coordinates). | true | 1.2.0 | |

**Note:** Its a bit different on Version 1.0.0. Have a look at the demos index.js

## Contributing

Contributions are welcome as this project is very complex. The small amount of WebGPU sources yet make it even more complicated. (Especially for 2D rendering)

## Known Issues

- Performance of Areas, Shapes and Paths might not be very good. A hybrid version will be needed.
- Gradiants do not work. May do that via hybrid version or shaders.
- Symbols only support circles yet.
- Lines dont support dashes nor joins (miter join, bevel join, ...)
- Rects do not support rounded edges yet.
- Resizing the Canvas will cause webgpu renderer to fail.
16 changes: 16 additions & 0 deletions ToDo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
lines
drawing above other stuff
clipof
symbols faster/better
gradient color?



Bachelor Text:
Webgpu as new technology
rewriting code
performance
Line Rendering
miter join
performacne
limiting (dont do everything)
12 changes: 12 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { color } from 'd3-color';
import { Renderer, CanvasHandler, renderModule } from 'vega-scenegraph';
import { default as WebGPURenderer } from './src/WebGPURenderer';

// Patch CanvasHandler
CanvasHandler.prototype.context = function () {
return this._canvas.getContext('2d') || this._canvas._textCanvas.getContext('2d');
};

renderModule('webgpu', { handler: CanvasHandler, renderer: WebGPURenderer });

export { WebGPURenderer };
Loading