Skip to content

Commit 10d323d

Browse files
Small improvements to Robustness chapter (#286)
1 parent f99f390 commit 10d323d

File tree

3 files changed

+103
-11
lines changed

3 files changed

+103
-11
lines changed

chapters/robustness.adoc

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2022 The Khronos Group, Inc.
1+
// Copyright 2019-2025 The Khronos Group, Inc.
22
// SPDX-License-Identifier: CC-BY-4.0
33

44
ifndef::chapters[:chapters:]
@@ -15,7 +15,11 @@ image::{images}robustness_flow.png[robustness_flow.png]
1515

1616
== When to use
1717

18-
The nature of some Vulkan applications requires the ability run shader code that cannot be guaranteed to avoid bad memory accesses. Robustness is needed for these applications.
18+
Some common cases for using robustness are
19+
20+
1. Need to prevent malicious memory accesses (ex. WebGPU).
21+
2. Can't guarantee your shader will not be out-of-bounds
22+
3. Mimic out-of-bounds behavior observed elsewhere
1923

2024
[NOTE]
2125
.Important
@@ -27,12 +31,33 @@ Turning on robustness may incur a runtime performance cost. Application writers
2731

2832
All Vulkan implementations are required to support the `robustBufferAccess` feature. The link:https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#features-robustBufferAccess[spec describes what is considered out-of-bounds] and also how it should be handled. Implementations are given some amount of flexibility for `robustBufferAccess`. An example would be accessing a `vec4(x,y,z,w)` where the `w` value is out-of-bounds as the spec allows the implementation to decide if the `x`, `y`, and `z` are also considered out-of-bounds or not.
2933

30-
If dealing with the update after bind functionality found in `VK_EXT_descriptor_indexing` (which is core as of Vulkan 1.2) it is important to be aware of the link:https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#limits-robustBufferAccessUpdateAfterBind[robustBufferAccessUpdateAfterBind] which indicates if an implementation can support both `robustBufferAccess` and the ability to update the descriptor after binding it.
31-
3234
The `robustBufferAccess` feature has some limitations as it only covers buffers and not images. It also allows out-of-bounds writes and atomics to modify the data of the buffer being accessed. For applications looking for a stronger form of robustness, there is link:https://registry.khronos.org/vulkan/specs/latest/man/html/VK_EXT_robustness2.html[VK_EXT_robustness2].
3335

3436
When images are out-of-bounds core Vulkan link:https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#textures-output-coordinate-validation[provides the guarantee] that stores and atomics have no effect on the memory being accessed.
3537

38+
== robustBufferAccess
39+
40+
The following is an example of using `robustBufferAccess`. (link:https://godbolt.org/z/d5rqK1aqK[Try Online])
41+
42+
[source,glsl]
43+
----
44+
#version 450
45+
layout(set = 0, binding = 0) buffer SSBO {
46+
// The VkBuffer is only 64 bytes large
47+
// indexing from [0:63] is valid, rest is OOB
48+
uint data[128];
49+
};
50+
51+
void main() {
52+
// will be OOB at runtime
53+
// will be discarded with robustBufferAccess
54+
data[96] = 0;
55+
56+
// will return zero with robustBufferAccess
57+
uint x = data[127];
58+
}
59+
----
60+
3661
== VK_EXT_image_robustness
3762

3863
=== robustImageAccess
@@ -74,3 +99,7 @@ Because robustness can come at a performance cost for some implementations, the
7499
At `VkPipeline` creation time one or more `VkPipelineRobustnessCreateInfoEXT` structures can be passed to specify the desired robustness behavior of accesses to buffer, image, and vertex input resources, either for the pipeline as a whole or on a per-pipeline-stage basis.
75100

76101
This extension also provides `VkPhysicalDevicePipelineRobustnessPropertiesEXT` which queries the implementation for what behavior it provides as default when no robustness features are enabled.
102+
103+
== VK_EXT_descriptor_indexing
104+
105+
If dealing with the update after bind functionality found in `VK_EXT_descriptor_indexing` (which is core as of Vulkan 1.2) it is important to be aware of the link:https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#limits-robustBufferAccessUpdateAfterBind[robustBufferAccessUpdateAfterBind] which indicates if an implementation can support both `robustBufferAccess` and the ability to update the descriptor after binding it.

lang/jp/chapters/robustness.adoc

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2022 The Khronos Group, Inc.
1+
// Copyright 2019-2025 The Khronos Group, Inc.
22
// SPDX-License-Identifier: CC-BY-4.0
33

44
ifndef::chapters[:chapters:]
@@ -14,7 +14,11 @@ image::../../../chapters/images/robustness_flow.png[robustness_flow.png]
1414

1515
== いつ使うのか
1616

17-
一部の Vulkan アプリケーションでは、悪質なメモリアクセスの回避を保証できないシェーダコードを実行する必要があります。このようなアプリケーションには堅牢性が必要です。
17+
堅牢性を使用する一般的なケースは以下の通りである。
18+
19+
1. 悪意のあるメモリーアクセスを防ぐ必要がある(例:WebGPU)。
20+
2. シェーダがアウトオブバウンズにならないことを保証できない。
21+
3. 他の場所で観察されたアウトオブバウンズ動作を模倣する。
1822

1923
[NOTE]
2024
.important
@@ -26,12 +30,33 @@ image::../../../chapters/images/robustness_flow.png[robustness_flow.png]
2630

2731
すべての Vulkan の実装は `robustBufferAccess` 機能をサポートする必要があります。仕様では、link:https://www.khronos.org/registry/vulkan/specs/latest/html/vkspec.html#features-robustBufferAccess[何が境界を越えたとみなされるか]、またどのように処理されるべきかが説明されています。`robustBufferAccess` については、実装にある程度の柔軟性が与えられています。たとえば、`vec4(x,y,z,w)` へのアクセスで `w` の値が境界を越えた場合、仕様では `x`、`y`、`z` も境界を越えたとみなすかどうかを実装が決定できるようになっています。
2832

29-
`VK_EXT_descriptor_indexing`(Vulkan 1.2のコア)にあるバインド機能の後の更新を扱う場合は、実装が `robustBufferAccess` とディスクリプタのバインド後の更新機能の両方をサポートするかどうかを示す link:https://www.khronos.org/registry/vulkan/specs/latest/html/vkspec.html#limits-robustBufferAccessUpdateAfterBind[robustBufferAccessUpdateAfterBind] を確認することが重要です。
30-
3133
`robustBufferAccess` 機能は、バッファのみを対象としており、イメージは対象外であるため、いくつかの制限があります。また、アクセスされているバッファのデータを変更する境界を越えた書き込みやアトミックを許可してしまいます。より強力な堅牢性を求めるアプリケーションのために、link:https://www.khronos.org/registry/vulkan/specs/latest/man/html/VK_EXT_robustness2.html[VK_EXT_robustness2] があります。
3234

3335
イメージが境界を越えた場合、コア Vulkan では、ストアやアトミックがアクセスされるメモリに影響を与えないことがlink:https://www.khronos.org/registry/vulkan/specs/latest/html/vkspec.html#textures-output-coordinate-validation[保証されています]。
3436

37+
== robustBufferAccess
38+
39+
以下は、robustBufferAccessの使用例である。(link:https://godbolt.org/z/d5rqK1aqK[オンラインで試す])
40+
41+
[source,glsl]
42+
----
43+
#version 450
44+
layout(set = 0, binding = 0) buffer SSBO {
45+
// VkBufferは64バイトしかない。
46+
// [0:63]からのインデックスは有効で、残りはOOBです。
47+
uint data[128];
48+
};
49+
50+
void main() {
51+
// 実行時にはOOBになります。
52+
// robustBufferAccessでは破棄されます。
53+
data[96] = 0;
54+
55+
// robustBufferAccessではゼロを返す。
56+
uint x = data[127];
57+
}
58+
----
59+
3560
== VK_EXT_image_robustness
3661

3762
=== robustImageAccess
@@ -65,3 +90,16 @@ link:https://www.khronos.org/registry/vulkan/specs/latest/html/vkspec.html#featu
6590
link:https://www.khronos.org/registry/vulkan/specs/latest/html/vkspec.html#features-nullDescriptor[nullDescriptor] 機能が有効になっていない場合、`VkDescriptorSet` を更新するときには、たとえディスクリプタがシェーダで静的に使用されていなくても、対応するすべてのリソースは非ヌルでなければなりません。この機能により、ディスクリプタをヌルのリソースまたはビューと対応させることができます。ヌルディスクリプタからのロードはゼロ値を返し、ヌルディスクリプタへのストアとアトミックは破棄されます。
6691

6792
`nullDescriptor` 機能は、`vkCmdBindVertexBuffers::pBuffers` がヌルの場合にも、頂点入力バインディングへのアクセスを可能にします。
93+
94+
== VK_EXT_pipeline_robustness
95+
96+
堅牢性は実装によってはパフォーマンスコストとなることがあるため、link:https://registry.khronos.org/vulkan/specs/latest/man/html/VK_EXT_pipeline_robustness.html[VK_EXT_pipeline_robustness] 拡張が追加され、開発者は必要な部分のみ堅牢性を要求できるようになりました。
97+
98+
`VkPipeline`` の作成時に、1 つまたは複数の `VkPipelineRobustnessCreateInfoEXT` 構造体を渡すことで、パイプライン全体またはパイプラインステージ単位で、バッファ、イメージ、および頂点入力リソースへのアクセスの堅牢性動作を指定できます。
99+
100+
この拡張は、堅牢性機能が有効でない場合にデフォルトで提供される動作を実装に問い合わせる `VkPhysicalDevicePipelineRobustnessPropertiesEXT` も提供します。
101+
102+
== VK_EXT_descriptor_indexing
103+
104+
`VK_EXT_descriptor_indexing`(Vulkan 1.2のコア)にあるバインド機能の後の更新を扱う場合は、実装が `robustBufferAccess` とディスクリプタのバインド後の更新機能の両方をサポートするかどうかを示す link:https://www.khronos.org/registry/vulkan/specs/latest/html/vkspec.html#limits-robustBufferAccessUpdateAfterBind[robustBufferAccessUpdateAfterBind] を確認することが重要です。
105+

lang/kor/chapters/robustness.adoc

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2022 The Khronos Group, Inc.
1+
// Copyright 2019-2025 The Khronos Group, Inc.
22
// SPDX-License-Identifier: CC-BY-4.0
33

44
ifndef::chapters[:chapters:]
@@ -27,12 +27,33 @@ image::../../../chapters/images/robustness_flow.png[robustness_flow.png]
2727

2828
모든 Vulkan 구현은 `robustBufferAccess` 기능을 지원해야 합니다. link:https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#features-robustBufferAccess[사양서는 어떤 것이 범위를 벗어난 것으로 간주되는지] 그리고 어떻게 처리해야 하는지를 설명합니다.구현에는 `robustBufferAccess` 에 대해 어느 정도의 유연성이 부여됩니다. 예를 들어 `w` 값이 범위를 벗어난 `vec4(x,y,z,w)` 에 접근하는 경우, `x`, `y`, `z` 도 범위를 벗어난 것으로 간주할지 여부를 구현에서 결정할 수 있도록 사양에서 허용하고 있기 때문입니다.
2929

30-
(Vulkan 1.2의 핵심인) `VK_EXT_descriptor_indexing` 에 있는 바인딩 후 업데이트 기능을 다루는 경우, 구현이 `robustBufferAccess` 와 바인딩 후 디스크립터를 업데이트하는 기능을 모두 지원할 수 있는지를 나타내는 link:https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#limits-robustBufferAccessUpdateAfterBind[robustBufferAccessUpdateAfterBind]를 알아두는 것이 중요합니다.
31-
3230
`robustBufferAccess` 기능은 이미지가 아닌 버퍼만 다루기 때문에 몇 가지 제한이 있습니다. 또한 접근 중인 버퍼의 데이터를 수정하기 위해 범위를 벗어난 쓰기나 아토믹을 허용해버립니다. 더 강력한 형태의 견고성을 원하는 애플리케이션의 경우, link:https://registry.khronos.org/vulkan/specs/latest/man/html/VK_EXT_robustness2.html[VK_EXT_robustness2]가 있습니다.
3331

3432
이미지가 범위를 벗어난 경우, 코어 Vulkan에서는 스토어나 아토믹이 접근하려는 메모리에 영향을 주지 않는 것이 link:https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#textures-output-coordinate-validation[보장되어 있습니다].
3533

34+
== robustBufferAccess
35+
36+
다음은 `robustBufferAccess`를 사용하는 예제입니다. (link:https://godbolt.org/z/d5rqK1aqK[온라인 체험])
37+
38+
[source,glsl]
39+
----
40+
#version 450
41+
layout(set = 0, binding = 0) buffer SSBO {
42+
// Vk버퍼의 크기는 64바이트에 불과합니다.
43+
// [0:63]부터의 인덱싱이 유효하고 나머지는 OOB입니다.
44+
uint data[128];
45+
};
46+
47+
void main() {
48+
// 런타임에 OOB가 됩니다.
49+
// robustBufferAccess와 함께 버려집니다.
50+
data[96] = 0;
51+
52+
// robustBufferAccess를 사용하면 0을 반환합니다.
53+
uint x = data[127];
54+
}
55+
----
56+
3657
== VK_EXT_image_robustness
3758

3859
=== robustImageAccess
@@ -74,3 +95,7 @@ link:https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#features-
7495
`VkPipeline` 생성 시 파이프라인 전체 또는 파이프라인 스테이지별로 버퍼, 이미지 및 정점 입력 리소스에 접근하려는 견고성 동작을 지정하기 위해 하나 이상의 `VkPipelineRobustnessCreateInfoEXT` 구조체를 전달할 수 있습니다.
7596

7697
이 확장 기능은 견고성 기능이 활성화되지 않았을 때 어떤 동작을 기본으로 제공하는지 구현에 쿼리하는 `VkPhysicalDevicePipelineRobustnessPropertiesEXT` 도 제공합니다.
98+
99+
== VK_EXT_descriptor_indexing
100+
101+
(Vulkan 1.2의 핵심인) `VK_EXT_descriptor_indexing` 에 있는 바인딩 후 업데이트 기능을 다루는 경우, 구현이 `robustBufferAccess` 와 바인딩 후 디스크립터를 업데이트하는 기능을 모두 지원할 수 있는지를 나타내는 link:https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#limits-robustBufferAccessUpdateAfterBind[robustBufferAccessUpdateAfterBind]를 알아두는 것이 중요합니다.

0 commit comments

Comments
 (0)