Skip to content

Commit

Permalink
docs(core): RenderPass (#2081)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibgreen committed Apr 29, 2024
1 parent 94e45c2 commit 450f308
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 111 deletions.
68 changes: 25 additions & 43 deletions docs/api-reference/core/resources/framebuffer.md
Expand Up @@ -78,17 +78,15 @@ model2.draw({renderPass: screenRenderPass, ...});

### Framebuffer Attachment Values

:::info
This system is expected to be replaced with a `TextureView` class in a future release.
:::

The following values can be provided for each attachment point

- `Texture` - attaches at mipmapLevel 0 of the supplied `Texture2D`.
- [`Texture`, 0, mipmapLevel] - attaches the specified mipmapLevel from the supplied `Texture2D`, or cubemap face. The second element in the array must be `0`.
- [`Texture` (cube), face (number), mipmapLevel=0 (number)] - attaches the specifed cubemap face from the `Texture`, at the specified mipmap level.
- [`Texture`, layer (number), mipmapLevel=0 (number)] - attaches the specifed layer from the `Texture2DArray`, at the specified mipmap level.
- [`Texture3D`, layer (number), mipmapLevel=0 (number)] - attaches the specifed layer from the `Texture3D`, at the specified mipmap level.
- `Texture` - attaches at mipmapLevel 0 (the the supplied `Texture`'s default `TextureView`.
- `TextureView`
- `2d`: attaches the specified mipmapLevel from the supplied `Texture`, or cubemap face. The second element in the array must be `0`.
- `cube`: face (depth), mipmapLevel=0 - attaches the specifed cubemap face from the `Texture`, at the specified mipmap level.
- `2d-array`, layer (number), mipmapLevel=0 (number)] - attaches the specifed layer from the `Texture`, at the specified mipmap level.
- `3d`, layer (number), mipmapLevel=0 (number)] - attaches the specifed layer from the `Texture3D`, at the specified mipmap level.

## Framebuffer Attachments

A `Framebuffer` holds:
Expand Down Expand Up @@ -118,47 +116,31 @@ This data loss is usually a non-issue as resizes are usually performed between r
| `colorAttachments` | `ColorAttachment\|Texture[]` | Array of render target textures. |
| `depthStencilAttachment?` | `DepthStencilAttachment\|Texture[]` | Depth/stencil texture. |

### `ColorAttachment`
## Members

- `device`: `Device` - holds a reference to the `Device` that created this `Framebuffer`.
- `handle`: `unknown` - WebGL: holds the underlying `WebGLFramebuffer`. No underlying object on WebGPU.
- `props`: `FramebufferProps` - holds a copy of the `FramebufferProps` used to create this `Buffer`.

### `colorAttachments`

```ts
colorAttachments: TextureView)[]
```

Framebuffer attachments lets the user specify the textures that will be used for a RenderPass,
together with some additional options for how to clear color textures.

| Property | Type | Description |
| ----------- | ---------------------- | -------------------------------------------------------------------------------------------------------------- |
| `texture` | `Texture` | Describes the texture subresource that will be output to for this color attachment. |
| `clearValue`? | `number[]` | Value to clear to prior to executing the render pass. Default: [0, 0, 0, 0]. Ignored if loadOp is not "clear". |
| `loadOp`? | `'load'`, `'clear'` | Load operation to perform on texture prior to executing the render pass. Default: 'clear'. |
| `storeOp`? | `'store'`, `'discard'` | The store operation to perform on texture after executing the render pass. Default: 'store'. |

- Clearing can be disabled by setting `loadOp='load'` however this may have a small performance cost as GPUs are optimized for clearing.
- WebGL does not support setting `storeOp: 'discard'` for just some attachments, it is all or nothing.

### `DepthStencilAttachment`

```ts
depthStencilAttachments: TextureView[]
```

Framebuffer attachments lets the user specify the depth stencil texture that will be used for a RenderPass,
together with some additional options for how to clear depth and stencil buffers.

| Property | Type | Description |
| -------------------- | ---------------------- | -------------------------------------------------------------------------------------------------------------- |
| `texture` | `Texture` | Describes the texture subresource that will be output to and read from for this depth/stencil attachment. |
| `depthClearValue`? | `number` | Value to clear depth component to prior to executing the render pass, if depthLoadOp is "clear". 0.0-1.0. |
| `depthLoadOp`? | `'load'`, `'clear'` | Load operation to perform on depth component prior to executing the render pass. Default 'clear'. |
| `depthStoreOp`? | `'store'`, `'discard'` | Store operation` to perform on depth component after executing the render pass. Default 'store'. |
| `depthReadOnly`? | `boolean` | Depth component is read only. |
| `stencilClearValue`? | `number ` | Value to clear stencil component to prior to executing the render pass, if stencilLoadOp is "clear". |
| `stencilLoadOp`? | `'clear'`, `'load'` | Load operation to perform on stencil component prior to executing the render pass. Prefer clearing. |
| `stencilStoreOp`? | `'store'`, `'discard'` | Store operation to perform on stencil component after executing the render pass. |
| `stencilReadOnly`? | `boolean` | Stencil component is read only. |

- Clearing can be disabled by setting `loadOp='load'` however this may have a small performance cost as GPUs are optimized for clearing.
- WebGL does not support setting `storeOp: 'discard'` for just some attachments, it is all or nothing.

## Members

- `device`: `Device` - holds a reference to the `Device` that created this `Framebuffer`.
- `handle`: `unknown` - WebGL: holds the underlying `WebGLFramebuffer`. No underlying object on WebGPU.
- `props`: `FramebufferProps` - holds a copy of the `FramebufferProps` used to create this `Buffer`.

## Methods

### constructor
Expand Down Expand Up @@ -187,11 +169,11 @@ Note the `framebuffer.resize()` method has been designed so that it can be calle

## Remarks

WebGPU
**WebGPU**
- The `Framebuffer` class is a pure luma.gl class as this concept does not exist natively in WebGPU (attachment information has to be provided through the `GPURenderPassDescriptor` `colorAttachments` and the `depthStencilAttachment` fields every frame when a render pass is created).`.
- `resize()` will destroy and recreate textures (meaning the the underlying `GPUTexture` / `GPUTextureView` handles are no longer the same after a `resize()`

WebGL
- The `Framebuffer` class wraps the `WebGLFramebuffer` object exists, see e.g. [Framebuffer](https://www.khronos.org/opengl/wiki/Framebuffer)
**WebGL**
- The `Framebuffer` class wraps the `WebGLFramebuffer` object, see e.g. [Framebuffer](https://www.khronos.org/opengl/wiki/Framebuffer)
and [Framebuffer Object](https://www.khronos.org/opengl/wiki/Framebuffer_Object) in the OpenGL Wiki.
- `resize()` will erase the current content of any attachments, but not actually recreate them (The underlying`WebGLTexture` handles are not changed).
26 changes: 19 additions & 7 deletions docs/api-reference/core/resources/render-pass.md
Expand Up @@ -49,13 +49,25 @@ Depth and stencil buffers are also cleared to default values:

### `RenderPassProps`

| Property | Type | Default | Description |
| --------------- | -------------------- | -------------- | --------------------------------------------------------- |
| `framebuffer?` | `Framebuffer` | | Provides render target textures and depth/stencil texture |
| `parameters?` | `Parameters` | | GPU pipeline parameters |
| `clearColor?` | `number[]`, `'load'` | `[0, 0, 0, 0]` | |
| `clearDepth?` | `number`, `'load'` | `1` | |
| `clearStencil?` | `number`, `'load'` | `0` | |
| Property | Type | Default | Description |
| -------------------- | ---------------------- | -------------- | --------------------------------------------------------------------------------------------------------- |
| `framebuffer?` | `Framebuffer` | N/A | Provides render target textures and depth/stencil texture |
| `parameters?` | `Parameters` | | GPU pipeline parameters |
| `clearColor?` | `number[] \| false` | `[0, 0, 0, 0]` | |
| `loadOp`? | `'load'`, `'clear'` | `'clear'` | Load operation to perform on texture prior to executing the render pass. Default: 'clear'. |
| `storeOp`? | `'store'`, `'discard'` | `'store'` | The store operation to perform on texture after executing the render pass. Default: 'store'. |
| `depthClearValue`? | `number` | `1` | Value to clear depth component to prior to executing the render pass, if depthLoadOp is "clear". 0.0-1.0. |
| `depthLoadOp`? | `'load'`, `'clear'` | | Load operation to perform on depth component prior to executing the render pass. Default 'clear'. |
| `depthStoreOp`? | `'store'`, `'discard'` | | Store operation` to perform on depth component after executing the render pass. Default 'store'. |
| `depthReadOnly`? | `boolean` | | Depth component is read only. |
| `stencilClearValue`? | `number ` | | Value to clear stencil component to prior to executing the render pass, if stencilLoadOp is "clear". |
| `stencilLoadOp`? | `'clear'`, `'load'` | | Load operation to perform on stencil component prior to executing the render pass. Prefer clearing. |
| `stencilStoreOp`? | `'store'`, `'discard'` | | Store operation to perform on stencil component after executing the render pass. |
| `stencilReadOnly`? | `boolean` | | Stencil component is read only. |

- Clearing can be disabled by setting `loadOp='load'` however this may have a small performance cost as GPUs are optimized for clearing.
- WebGL does not support setting `storeOp: 'discard'` for just some attachments, it is all or nothing.
- Currently luma.gl doesn't support specifying per-rendertarget properties

## Members

Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/core/resources/texture-view.md
@@ -1,4 +1,4 @@
## TextureView
# TextureView

A `TextureView` is a view onto some subset of the texture subresources defined by a particular `Texture`.

Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/engine/model.md
Expand Up @@ -12,7 +12,7 @@ The `Model` class is the centerpiece of the luma.gl API. It brings together all

The `Model` class integrates with
- The `@luma.gl/shadertools` shader module system: [see `Shader Assembly`]( /docs/api-reference/shadertools/shader-assembler).
- The `Geometry` classes - accepts a [`Mesh`] or a [`Geometry`](/docs/modules/engine/api-reference/geometry) instance, plus any additional attributes for instanced rendering)
- The `Geometry` classes - accepts a [`Mesh`] or a [`Geometry`](/docs/api-reference/engine/geometry) instance, plus any additional attributes for instanced rendering)

## Usage

Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/shadertools/shader-module.md
Expand Up @@ -3,7 +3,7 @@
In luma.gl, reusable shader modules are defined by objects that conform to the `ShaderModule` type.
For more information see [Shader Module System Guide](/docs/api-guide/shaders/shader-modules).

`ShaderModule`s are used by the luma.gl [shader assembler](.shader-module). The shader assembler imports chunks of reusable shader code from the module into your shader program source code.
`ShaderModule`s are used by the luma.gl [shader assembler](./shader-assembler). The shader assembler imports chunks of reusable shader code from the module into your shader program source code.

## Usage

Expand Down
8 changes: 6 additions & 2 deletions docs/sidebar.json
Expand Up @@ -87,15 +87,19 @@
"api-reference/core/shader-layout",
"api-reference/core/texture-formats",
"api-reference/core/resources/buffer",
"api-reference/core/resources/compute-pass",
"api-reference/core/resources/compute-pipeline",
"api-reference/core/resources/framebuffer",
"api-reference/core/resources/render-pass",
"api-reference/core/resources/render-pipeline",
"api-reference/core/resources/sampler",
"api-reference/core/resources/shader",
"api-reference/core/shader-logs",
"api-reference/core/resources/texture",
"api-reference/core/resources/vertex-array",
"api-reference/core/resources/query-set"
"api-reference/core/resources/texture-view",
"api-reference/core/resources/transform-feedback",
"api-reference/core/resources/query-set",
"api-reference/core/resources/vertex-array"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/whats-new.md
Expand Up @@ -11,7 +11,7 @@ Target Date: Q2 2024
**@luma.gl/core**

- `Texture` class has been refactored. Textures no longer accept promises, use `AsyncTexture` class instead.
- New [`luma.attachDevice()`](/docs/api-reference/core/luma#attachdevice) method - A `Device` can now be attached to a `WebGL2RenderingContext` without calling `WebGLDevice.attach()`.
- New [`luma.attachDevice()`](/docs/api-reference/core/luma#lumaattachdevice) method - A `Device` can now be attached to a `WebGL2RenderingContext` without calling `WebGLDevice.attach()`.

**@luma.gl/engine**

Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -32,10 +32,11 @@
"publish": "ocular-publish",
"version": "npm run build",
"test": "ocular-test",
"test-ci": "ocular-lint && ocular-test node && ocular-test cover",
"test-ci": "ocular-lint && ocular-test node && ocular-test cover && yarn test-website",
"test-fast": "ocular-test fast",
"test-browser": "ocular-test browser",
"test-browser-headless": "ocular-test browser-headless | tap-spec",
"test-website": "cd website && yarn && yarn build && cd ..",
"perf": "ocular-test perf-browser",
"bench": "ocular-test bench",
"bench-browser": "ocular-test bench-browser",
Expand Down

0 comments on commit 450f308

Please sign in to comment.