Skip to content

Commit

Permalink
Deploying to gh-pages from @ 7b47283 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Dec 15, 2023
1 parent c7809ad commit 50509ea
Show file tree
Hide file tree
Showing 117 changed files with 1,732 additions and 620 deletions.
20 changes: 20 additions & 0 deletions CHANGELIST.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Change List

### 1.0.0

* switch primitive functions to use named parameters.

### 0.15.0

* add `setIntrinsicsToView`

### 0.14.3

* Fixes for vec2 typos

### 0.14.2

* Handle bool issue fix

### 0.14.0

* Use latest wgsl_reflect

### 0.13.0

* Support making views of unsized arrays
Expand Down
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

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

* [ChangeList](https://github.com/greggman/webgpu-utils/CHANGELIST.md)
* [Migration Notes](https://github.com/greggman/webgpu-utils/migration.md)

## Random useful things for WebGPU

As I do more WebGPU I find I need more and more helpers to make things
Expand Down Expand Up @@ -39,7 +42,7 @@ const myUniformValues = makeStructuredView(defs.uniforms.myUniforms);

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

Expand Down Expand Up @@ -246,7 +249,7 @@ The reason it's this way is it's common to make large arrays of `f32`, `u32`,
`vec2f`, `vec3f`, `vec4f` etc. We wouldn't want every element of an array to
have its own typedarray view.

You can configure this per type by calling `setIntrinsicsToView`.
You can configure this per type by calling `setIntrinsicsToView`.
The configuration is global. Given th example above

```js
Expand Down Expand Up @@ -311,7 +314,7 @@ const uni1 = makeStructuredView(defs.uniforms.uni1, new ArrayBuffer(4 * 16));
* include from the net

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

...
```
Expand All @@ -330,6 +333,14 @@ import { createTextureFromImage } from 'webgpu-utils';
...
```

## <a id="examples"></a> Examples

* [2d-array texture](examples/2d-array.html)
* [cube](examples/cube.html)
* [cube-map](examples/cube-map.html)
* [instancing](examples/instancing.html)
* [primitives](examples/primitives.html)

## Development

```
Expand All @@ -340,7 +351,7 @@ npm start
```

This will run rollup in watch mode, building from typescript into
`dist/0.x/webgpu-utils.js`.
`dist/1.x/webgpu-utils.js`.

```
npx servez
Expand All @@ -355,4 +366,3 @@ Super thanks to Brendan Duncan for [wgsl-reflect](https://github.com/brendan-dun
## License

[MIT](LICENSE.md)

214 changes: 0 additions & 214 deletions dist/0.x/primitives.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion dist/0.x/webgpu-utils.js.map

This file was deleted.

1 change: 0 additions & 1 deletion dist/0.x/webgpu-utils.min.js.map

This file was deleted.

1 change: 0 additions & 1 deletion dist/0.x/webgpu-utils.module.js.map

This file was deleted.

34 changes: 34 additions & 0 deletions dist/0.x/attribute-utils.d.ts → dist/1.x/attribute-utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,38 @@ export declare function interleaveVertexData(attributes: GPUVertexAttribute[], t
* Also see the cube and instancing examples.
*/
export declare function createBuffersAndAttributesFromArrays(device: GPUDevice, arrays: Arrays, options?: ArraysOptions): BuffersAndAttributes;
/**
* Calls `passEncoder.setVertexBuffer` and optionally `passEncoder.setIndexBuffer`
* for the buffers specified in `buffersAndAttributes`.
*
* This is extremely simple function. It is equivalent to
*
* ```js
* buffersAndAttributes.buffers.forEach((buffer, i) => {
* passEncoder.setVertexBuffer(firstVertexBufferIndex + i, buffer);
* });
*
* if (buffersAndAttributes.indexBuffer) {
* passEncoder.setIndexBuffer(buffersAndAttributes.indexBuffer, buffersAndAttributes.indexFormat!);
* }
* ```
*
* It exists solely for simple cases. If you have a complex case, call the passEncoder
* yourself as appropriate.
*
* @param passEncoder a render pass encoder
* @param buffersAndAttributes As returned from {@link createBuffersAndAttributesFromArrays}
* @param firstVertexBufferIndex The first vertex buffer index. default = 0.
*/
export declare function setVertexAndIndexBuffers(passEncoder: GPURenderPassEncoder, buffersAndAttributes: BuffersAndAttributes, firstVertexBufferIndex?: number): void;
/**
* Calls {@link setVertexAndIndexBuffers} and then calls either `draw` or `drawIndexed`
*
* This is an extremely simple function. See {@link setVertexAndIndexBuffers}.
* If you need something more complex, call pass encoder functions yourself as appropriate.
*
* @param passEncoder a render pass encoder
* @param buffersAndAttributes As returned from {@link createBuffersAndAttributesFromArrays}
*/
export declare function drawArrays(passEncoder: GPURenderPassEncoder, buffersAndAttributes: BuffersAndAttributes): void;
export {};
4 changes: 3 additions & 1 deletion dist/0.x/buffer-views.d.ts → dist/1.x/buffer-views.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export declare const kTypes: readonly kType[];
* the second call
*
* You can pass in `true` as the 2nd parameter to make it set which types
* to flatten and all others will be set to have views created.
* to flatten and all others will be set to have views created. For example
* to expand all types would be `setIntrinsicsToView([], true)`. To expand
* all except `f32` would be `setIntrinsicsToView(['f32'], true)`.
*
* To reset all types to the default call it with no arguments
*
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 50509ea

Please sign in to comment.