yutannihilation / wgpugd

A WebGPU Graphics Device for R
https://yutannihilation.github.io/wgpugd/
Other
45 stars 3 forks source link

wgpugd: A WebGPU Graphics Device for R

Overview

What is WebGPU?

WebGPU is an API that exposes the capabilities of GPU hardware. As the name indicates, it’s primarily designed for the Web. However, it’s not only for the Web^1.

What is wgpu?

As the name indicates, the wgpugd package uses wgpu, a pure-Rust implementation of the WebGPU standard. wgpu is what’s behind the WebGPU support of Firefox and Deno, and is widely used over the Rust’s graphics ecosystem.

Wait, Rust…? Can we use Rust in R??

Yes! extendr is the Rust framework for interacting with R.

Why WebGPU for R?

The main motivation is to add post-effect to graphics with WebGPU Shader Language (WGSL). But, of course, the power of GPU should simply contribute to high performance!

Installation

You can install the development version of wgpugd like so:

devtools::install_github("yutannihilation/wgpugd")

Usages

:warning: wgpugd is currently at its verrry early stage of the development! :warning:

library(wgpugd)
library(ggplot2)

file <- knitr::fig_path('.png')
wgpugd(file, 10, 10)
# ragg::agg_png(file, 10, 10, unit = "in")

set.seed(10)
dsamp <- diamonds[sample(nrow(diamonds), 1000), ]

ggplot(dsamp, aes(carat, price)) +
  geom_point(aes(colour = clarity)) +
  ggtitle("\( 'ω')/ウオオオオオオアアアアーーーーッッッ!!!!") +
  theme(text = element_text(size = 30, family = "Noto Sans JP"))

dev.off()
#> png 
#>   2

knitr::include_graphics(file)

References