Skip to content

Commit e9ee0c2

Browse files
authored
Merge pull request #364 from Luracasmus/patch-5
fix/mod: Compute Clarifications & Corrections
2 parents db4cd8b + cce9807 commit e9ee0c2

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

src/content/docs/current/Reference/Constants/workGroups.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: workGroups
3-
description: Used to define a fixed number of work groups in a compute shader.
3+
description: Defines a fixed number of compute shader work groups to be dispatched.
44
sidebar:
55
label: workGroups
66
order: 4
@@ -15,4 +15,4 @@ sidebar:
1515

1616
---
1717

18-
Used to define a fixed number of work groups in a compute shader. Replace `<groups_x>`, `<groups_y>`, and `<groups_z>` with the number of work groups in each dimension. For more info, see the [compute shader](/current/reference/programs/overview/#compute-shaders) section.
18+
Defines a fixed number of compute shader work groups to be dispatched. Replace `<groups_x>`, `<groups_y>`, and `<groups_z>` with the number of work groups in each dimension. For more info, see the [compute shader](/current/reference/programs/overview/#compute-shaders) section.

src/content/docs/current/Reference/Constants/workGroupsRender.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: workGroupsRender
3-
description: Used to define number of work groups in a compute shader based on a multiple of the screen resolution.
3+
description: Defines a variable number of compute shader work groups to be dispatched based on a multiple of screen resolution.
44
sidebar:
55
label: workGroupsRender
66
order: 4
@@ -15,4 +15,10 @@ sidebar:
1515

1616
---
1717

18-
Used to define number of work groups in a compute shader based on a multiple of the screen resolution. Replace `<x_mult>` and `<y_mult>` with a multiplier for each screen dimension. For example, `1.0` would mean there would be the same number of work groups in that dimension as pixels in the screen in that dimension. For more info, see the [compute shader](/current/reference/programs/overview/#compute-shaders) section.
18+
Defines a variable number of compute shader work groups to be dispatched based on a multiple of screen resolution. If neither this directive nor [`workGroups`](/current/reference/constants/workGroups/) is defined, work groups will be dispatched as if `workGroupsRender == vec2(1.0, 1.0)`, which means that the smallest number of work groups will be dispatched to completely cover the screen with one shader invocation per pixel when arranged in a grid. If the screen resolution isn't a multiple of `vec2(gl_WorkGroupSize.xy) / workGroupsRender`, the number of invocations dispatched will be greater than the amount of pixels on the screen.
19+
20+
```glsl
21+
gl_NumWorkGroups == uvec3(ceil(vec2(viewWidth, viewHeight) * workGroupsRender / vec2(gl_WorkGroupSize.xy)), 1u)
22+
```
23+
24+
For more info, see the [compute shader](/current/reference/programs/overview/#compute-shaders) section.

src/content/docs/current/Reference/Programs/overview.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ Composite-style programs render a single quad covering the output texture (unles
5555
Composite-style programs support vertex, fragment, geometry, and compute stages. Usually composite-style programs require vertex and fragment shaders, however if a compute shader is present these are optional. Compute shaders (if present) will be executed before the vertex stage of a given program.
5656

5757
#### Compute-only
58-
As the name suggests, compute-only programs only support compute shaders. The only such programs are in the [setup](/current/reference/programs/setup/) pass, which are executed once after shader load and during window resize. Like composite passes, [setup](/current/reference/programs/setup/) supports suffixes (1 to 99) in addition to a program with no suffix.
58+
As the name suggests, compute-only programs only support compute shaders. The only such programs are in the [setup](/current/reference/programs/setup/) pass, which are executed once after shader pack load and during window resize. Like composite passes, [setup](/current/reference/programs/setup/) supports suffixes (1 to 99) in addition to a program with no suffix.
5959

6060
## Compute Shaders
6161
Compute shaders break the OpenGL fixed pipeline and allow more direct access to graphics hardware. For more information, see the [Khronos Wiki](https://www.khronos.org/opengl/wiki/Compute_Shader).
6262

6363
:::caution[Warning]
64-
Compute shaders require OpenGL 4.3 support, which macOS does not have. For more information, see the [macOS](/current/reference/miscellaneous/macos/) page.
64+
Compute shaders require OpenGL 4.3 support, which macOS does not provide. For more information, see the [macOS](/current/reference/miscellaneous/macos/) page.
6565
:::
6666

67-
In Iris, compute shaders can be used in compute only pass, or included in composite-style passes, using the `.csh` file extension. In composite-style passes, compute shaders will always execute first (before the vertex stage if present). Up to 27 compute shaders files can be included in a single pass by appending the `_a` through `_z` suffixes to the filename in addition to a shader file with no suffix. These shaders will execute one after the other in alphabetical order (starting with the no-suffix file if present), unless [`allowConcurrentCompute`](/current/reference/shadersproperties/ordering/#allowconcurrentcompute) is used (in which case they will execute potentially simultaneously but will all finish before starting the vertex stage).
67+
In Iris, compute shaders can be used in compute only passes, or included in composite-style passes, and are stored with the `.csh` file extension. In composite-style passes, compute shaders will always execute first (before the vertex stage if present). Up to 27 compute shaders can be included in a single pass, by appending `_a` through `_z` suffixes to the filename, in addition to a shader file with no suffix. These shaders will execute one after the other in alphabetical order (starting with the suffixless file if present), unless [`allowConcurrentCompute`](/current/reference/shadersproperties/ordering/#allowconcurrentcompute) is enabled, in which case they will execute potentially simultaneously but will all finish before the vertex stage begins execution.
6868

6969
Local size is defined as follows: `layout (local_size_x = <size_x>, local_size_y = <size_x>, local_size_z = <size_z>) in;`.
7070

@@ -73,9 +73,9 @@ Work group count can be defined one of three ways:
7373
2. [`const vec2 workGroupsRender`](/current/reference/constants/workgroupsrender/)
7474
3. [`indirect.pass`](/current/reference/shadersproperties/ordering/#indirectpass)
7575

76-
If no work group count is provided, the default value of one work group per pixel will be used (`const vec2 workGroupsRender = vec2(1.0, 1.0);`).
76+
If no work group count is provided, a default value of (`const vec2 workGroupsRender = vec2(1.0, 1.0);`) will be used.
7777

78-
Unlike fragment shaders, compute shaders cannot directly write to color attachments, instead they can only write to [colortex](/current/reference/buffers/colortex/) and [shadowcolor](/current/reference/programs/shadowcolor/) buffers through [`imageStore`](https://www.khronos.org/opengl/wiki/Image_Load_Store). Additionally, if multiple shader invocations are writing/reading to the same location in memory simultaneously, atomic operations (on [images](https://www.khronos.org/opengl/wiki/Image_Load_Store#Atomic_operations) and/or [shared memory](https://www.khronos.org/opengl/wiki/Compute_Shader#Atomic_operations)) or [memory barriers](https://www.khronos.org/opengl/wiki/Compute_Shader#Shared_memory_coherency) should be used.
78+
Unlike fragment shaders, compute shaders cannot directly write to color attachments. Writing to [colortex](/current/reference/buffers/colortex) and [shadowcolor](/current/reference/programs/shadowcolor/) buffers needs to be done with [`imageStore`](https://www.khronos.org/opengl/wiki/Image_Load_Store).
7979

8080

8181
## Tessellation Shaders

0 commit comments

Comments
 (0)