Skip to content

Commit b98c9ea

Browse files
committed
expand on InstanceFlags::VALIDATION_INDIRECT_CALL docs
1 parent 342c42e commit b98c9ea

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

wgpu-types/src/instance.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,26 @@ bitflags::bitflags! {
101101

102102
/// Validate indirect buffer content prior to issuing indirect draws/dispatches.
103103
///
104+
/// This validation will transform indirect calls into no-ops if they are not valid:
105+
///
106+
/// - When calling `dispatch_workgroups_indirect`, all 3 indirect arguments encoded in the buffer
107+
/// must be less than the `max_compute_workgroups_per_dimension` device limit.
108+
/// - When calling `draw_indirect`/`draw_indexed_indirect`/`multi_draw_indirect`/`multi_draw_indexed_indirect`:
109+
/// - If `Features::INDIRECT_FIRST_INSTANCE` is not enabled on the device, the `first_instance` indirect argument must be 0.
110+
/// - The `first_instance` & `instance_count` indirect arguments must form a range that fits within all bound vertex buffers with `step_mode` set to `Instance`.
111+
/// - When calling `draw_indirect`/`multi_draw_indirect`:
112+
/// - The `first_vertex` & `vertex_count` indirect arguments must form a range that fits within all bound vertex buffers with `step_mode` set to `Vertex`.
113+
/// - When calling `draw_indexed_indirect`/`multi_draw_indexed_indirect`:
114+
/// - The `first_index` & `index_count` indirect arguments must form a range that fits within the bound index buffer.
115+
///
116+
/// __Behavior is undefined if this validation is disabled and the rules above are not satisfied.__
117+
///
118+
/// Disabling this will also cause the following built-ins to not report the right values on the D3D12 backend:
119+
///
120+
/// - the 3 components of `@builtin(num_workgroups)` will be 0
121+
/// - the value of `@builtin(vertex_index)` will not take into account the value of the `first_vertex`/`base_vertex` argument present in the indirect buffer
122+
/// - the value of `@builtin(instance_index)` will not take into account the value of the `first_instance` argument present in the indirect buffer
123+
///
104124
/// When `Self::from_env()` is used takes value from `WGPU_VALIDATION_INDIRECT_CALL` environment variable.
105125
const VALIDATION_INDIRECT_CALL = 1 << 5;
106126

0 commit comments

Comments
 (0)