Skip to content

Instantly share code, notes, and snippets.

View JusSn's full-sized avatar

Justin Fan JusSn

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
<script src="js/set-up-webgpu-contexts.js"></script>
<script id="library" type="x-shader/x-metal">
#include <metal_stdlib>
using namespace metal;
<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
<meta charset=utf-8>
<title>Create WebGPUBindGroupLayout.</title>
<body>
<script src="js/webgpu-functions.js"></script>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
function createBindGroupLayoutBinding() {
return {
function render() {
if (mappedBuffers.empty()) {
buffer, ab = device.createMappedBuffer();
bg = device.createBindGroup(buffer);
buffer.bindGroup = bg;
buffer.arrayBuffer = ab;
} else {
buffer = mappedBuffers.pop();
bg = buffer.bindGroup;
buffer.mapWriteAsync().then(arrayBuffer => {
fillArrayBuffer(arrayBuffer); // Is this pointer into memory still valid, or is this an error?
buffer.unmap(); // This is an error?
});
// Is buffer 'mapped' now, or is it not 'mapped' until callback is called?
buffer.destroy() // or buffer.unmap()?
/* Due to Promise/event loop, execution order is 1, 6, 2, 3 */
async function helloTriangle() {
if (!window.gpu) {
document.body.className = 'error';
return;
}
const adapter = await window.gpu.requestAdapter();
const device = await adapter.requestDevice();
/*** Shader Setup ***/