Skip to content

Commit

Permalink
README
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Jul 21, 2023
1 parent e1fb315 commit 24ec1fe
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

![](https://img.shields.io/npm/v/webgpu-utils)

## [Docs](https://greggman.github.io/webgpu-utils/docs)
## Docs

See [here](https://greggman.github.io/webgpu-utils/docs)

## Random useful things for WebGPU

Expand All @@ -12,7 +14,7 @@ less tedious. These are the result. I expect I'll add more over time.
Note: At the moment, minified and gzipped this is only 9k! It's also
possible to tree shake so you'll only get what you use.

### Create easy to set uniform and storage `ArrayBuffer` views.
### Easily set Uniforms (based on your WGSL structs/types)

Example:

Expand All @@ -35,6 +37,12 @@ struct MyUniforms {
const defs = makeShaderDataDefinitions(code);
const myUniformValues = makeStructuredView(defs.uniforms.myUniforms);

// create the correct sized buffer
const uniformBuffer = device.createBuffer({
size: myUniformBuffer.arrayBuffer.byteLength,
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
});

// Set some values via set
myUniformValues.set({
color: [1, 0, 1, 1],
Expand All @@ -58,6 +66,8 @@ mat4.perspective(
device.queue.writeBuffer(uniformBuffer, 0, myUniformValues.arrayBuffer);
```

[Live Example]

### Load an image URL as a texture (with mips)

```js
Expand Down Expand Up @@ -98,14 +108,28 @@ const texture = device.createTexture({
generateMipmap(device, texture);
```

## Using from here
## Usage

```
* include from the net

```js
import { createTextureFromImage } from 'https://greggman.github.io/webgpu-utils/dist/0.x/webgpu-utils.module.js'

...
```

* npm

```sh
npm install webgpu-utils
```

```js
import { createTextureFromImage } from 'webgpu-utils';

...
```

## Development

```
Expand Down

0 comments on commit 24ec1fe

Please sign in to comment.