Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald committed Nov 20, 2023
1 parent f451249 commit 475bae6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
6 changes: 6 additions & 0 deletions wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,12 @@ impl super::Adapter {
extensions.contains("GL_KHR_texture_compression_astc_hdr"),
);
}
if let Some(full_ver) = full_ver {
// Desktop 4.2 and greater specify the first instance parameter.
//
// For all other versions, the behavior is undefined.
features.set(wgt::Features::INDIRECT_FIRST_INSTANCE, full_ver >= (4, 2));
}

// We *might* be able to emulate bgra8unorm-storage but currently don't attempt to.

Expand Down
25 changes: 25 additions & 0 deletions wgpu-hal/src/gles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,31 @@ To address this, we invalidate the vertex buffers based on:
- whether or not `start_instance` is used
- stride has changed
## Handling of BaseVertex, BaseInstance, and FirstVertex
Between indirect, the lack of "base instance" semantics, and the availablity of gl_BaseInstance
in shaders, getting buffers and builtins to work correctly is a bit tricky.
We never emulate `base_vertex` and gl_VertexID behaves as `@builtin(vertex_index)` does, so we
never need to do anything about that.
We always advertise support for `VERTEX_AND_INSTANCE_INDEX_RESPECTS_RESPECTIVE_INDIRECT_FIRST`.
### GL 4.2+ with ARB_shader_draw_parameters
- `@builtin(instance_index)` translates to `gl_InstanceID + gl_BaseInstance`
- We bind instance buffers without any offset emulation.
- We advertise support for the `INDIRECT_FIRST_INSTANCE` feature.
While we can theoretically have a card with 4.2+ support but without ARB_shader_draw_parameters,
we don't bother with that combination.
### GLES & GL 4.1
- `@builtin(instance_index)` translates to `gl_InstanceID + naga_vs_base_instance`
- We bind instance buffers with offset emulation.
- We _do not_ advertise support for `INDIRECT_FIRST_INSTANCE` and cpu-side pretend the base instance is 0 on indirect calls.
*/

///cbindgen:ignore
Expand Down
11 changes: 10 additions & 1 deletion wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,16 @@ bitflags::bitflags! {
///
/// DX11 on FL10 level hardware, WebGL2, and GLES 3.0 devices do not support indirect.
const INDIRECT_EXECUTION = 1 << 2;
/// Supports non-zero `base_vertex` parameter to indexed draw calls.
/// Supports non-zero `base_vertex` parameter to direct indexed draw calls.
///
/// Indirect calls, if supported, always support non-zero `base_vertex`.
///
/// Supported by:
/// - Vulkan
/// - DX12
/// - Metal
/// - OpenGL 3.2+
/// - OpenGL ES 3.2
const BASE_VERTEX = 1 << 3;
/// Supports reading from a depth/stencil texture while using it as a read-only
/// depth/stencil attachment.
Expand Down

0 comments on commit 475bae6

Please sign in to comment.