Skip to content

Framebuffer support on WebGPU renderer #8008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: webgpu
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 15 additions & 1 deletion .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,26 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: 20.x
- name: Install Vulkan
run: |
sudo apt-get update
sudo apt-get install -y libvulkan1 vulkan-tools mesa-vulkan-drivers
- name: Install Chrome (latest stable)
run: |
sudo apt-get update
sudo apt-get install -y wget gnupg
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
sudo apt-get install -y google-chrome-stable
which google-chrome
google-chrome --version
- name: Get node modules
run: npm ci
env:
CI: true
- name: build and test
run: npm test
run: xvfb-run --auto-servernum --server-args='-screen 0 1280x1024x24' npm test
env:
CI: true
- name: report test coverage
Expand Down
7 changes: 6 additions & 1 deletion preview/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

p.setup = async function () {
await p.createCanvas(400, 400, p.WEBGPU);
fbo = p.createFramebuffer();

tex = p.createImage(100, 100);
tex.loadPixels();
Expand All @@ -43,6 +44,10 @@
}
}
tex.updatePixels();
fbo.draw(() => {
p.imageMode(p.CENTER);
p.image(tex, 0, 0, p.width, p.height);
});

sh = p.baseMaterialShader().modify({
uniforms: {
Expand Down Expand Up @@ -87,7 +92,7 @@
0, //p.width/3 * p.sin(t * 0.9 + i * Math.E + 0.2),
p.width/3 * p.sin(t * 1.2 + i * Math.E + 0.3),
)
p.texture(tex)
p.texture(fbo)
p.sphere(30);
p.pop();
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,11 @@ for (const k in constants) {
* If `setup()` is declared `async` (e.g. `async function setup()`),
* execution pauses at each `await` until its promise resolves.
* For example, `font = await loadFont(...)` waits for the font asset
* to load because `loadFont()` function returns a promise, and the await
* to load because `loadFont()` function returns a promise, and the await
* keyword means the program will wait for the promise to resolve.
* This ensures that all assets are fully loaded before the sketch continues.

*
*
* loading assets.
*
* Note: `setup()` doesn’t have to be declared, but it’s common practice to do so.
Expand Down
2 changes: 1 addition & 1 deletion src/image/pixels.js
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ function pixels(p5, fn){
*/
fn.loadPixels = function(...args) {
// p5._validateParameters('loadPixels', args);
this._renderer.loadPixels();
return this._renderer.loadPixels();
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/webgl/3d_primitives.js
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ function primitives3D(p5, fn){
if (typeof args[4] === 'undefined') {
// Use the retained mode for drawing rectangle,
// if args for rounding rectangle is not provided by user.
const perPixelLighting = this._pInst._glAttributes.perPixelLighting;
const perPixelLighting = this._pInst._glAttributes?.perPixelLighting;
const detailX = args[4] || (perPixelLighting ? 1 : 24);
const detailY = args[5] || (perPixelLighting ? 1 : 16);
const gid = `rect|${detailX}|${detailY}`;
Expand Down
Loading
Loading