Skip to content

Commit

Permalink
fix index triangle digram (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman authored Aug 21, 2024
1 parent 68563b6 commit 82e505d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
6 changes: 3 additions & 3 deletions webgpu/lessons/ko/webgpu-vertex-buffers.md
Original file line number Diff line number Diff line change
Expand Up @@ -896,12 +896,12 @@ function createCircleVertices({
+ let ndx = 0;
+
+ // 1st tri 2nd tri 3rd tri 4th tri
+ // 0 1 2 2 1 3 4 5 6 6 5 7
+ // 0 1 2 2 1 3 2 3 4 4 3 5
+ //
+ // 0--2 2 4--6 6 .....
+ // 0--2 2 2--4 4 .....
+ // | / /| | / /|
+ // |/ / | |/ / |
+ // 1 1--3 5 5--7 .....
+ // 1 1--3 3 3--5 .....
+ for (let i = 0; i < numSubdivisions; ++i) {
+ const ndxOffset = i * 2;
+
Expand Down
49 changes: 48 additions & 1 deletion webgpu/lessons/webgpu-bind-group-layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,52 @@ Title: WebGPU Bind Group Layouts
Description: Explicit Bind Group Layouts
TOC: Bind Group Layouts

TBD
Bind Group Layouts are used to make it easy and efficient
for WebGPU to match Bind Groups to Compute and Render Pipelines.

How it works:

A Pipeline, like a `GPUComputePipeline` or `GPURenderPipeline`
uses a `GPUPipelineLayout` which defines 0 or more
`GPUBindGroupLayout`s. Each `GPUBindGroupLayout` is assigned
to a specific group index.

Bind Groups are created with a specific `GPUBindGroupLayout`
as well.

When you go to `draw` or to `dispatchWorkgroups`, WebGPU only
needs to check, does the `GPUBindGroupLayout` for each group index
on the current pipeline's `GPUPipelineLayout` match the
currently bound bind groups, the ones set with `setBindGroup`.
This check is trivially simple. Most of the detailed checking
happens when you create the bind group. That way, when you're
actually drawing or computing, there's almost nothing left to
check.

Pipelines with generate their own `GPUPipelineLayout` and
populate it with `GPUBindGroupLayouts` automatically if you
create the pipeline with `layout: 'auto'` which is what
most of the samples on this website do.

There are 2 main reasons to **NOT** use `layout: 'auto'`.

1. **You want to use a bind group with more than 1 pipeline**

You can not use a bind group made with from a bindGroupLayout
that was made from a pipeline with `layout: 'auto'` with a
different pipeline.

2. **You want a layout that's different than the default `'auto'` layout**

## Using a bind group with more than 1 pipeline

--- need a good example - problem is, drawing twice in 2 different locations
--- requires 2 different uniform buffers which means it requires 2 bind groups
--- which means sharing doesn't matter.

Let's made a toy example. We'll make 2 render pipelines and try
to draw a cube with both pipelines.




0 comments on commit 82e505d

Please sign in to comment.