1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//#![warn(missing_docs)]
//! # Pixar OpenSubdiv Wrapper
//!
//! This is a safe Rust wrapper around parts of [*Pixar's
//! OpenSubdiv*](https://graphics.pixar.com/opensubdiv/).
//!
//! *OpenSubdiv* is a set of open source libraries that implement high
//! performance/parallel [subdivision surface](https://en.wikipedia.org/wiki/Subdivision_surface)
//! (subdiv) evaluation on CPU and GPU architectures.
//!
//! The code is optimized for drawing deforming surfaces with static topology at
//! interactive framerates.
//!
//! ## Limitations
//!
//! The original library does make use of templates in quite a few places.
//! The wrapper has specializations that cover the most common use case.
//!
//! C++ factory classes have been collapsed into the `new()` method of the resp.
//! struct that mirrors the class the C++ factory was building.
//!
//! ## API Changes From C++
//!
//! Many methods have slightly different names on the Rust side.
//!
//! Renaming was done considering these constraints:
//! * Be verbose consistently (the original API is quite verbose but does make
//! use of abbreviations in some surprising places).
//! * Use canonical Rust naming – (`num_vertices()` becomes `vertex_count()`).
//! * Use canonically Rust constructs. Most option/configuration `struct`s use the
//! [init-`struct` pattern](https://xaeroxe.github.io/init-struct-pattern/). In
//! places where it’s not possible to easily map to a Rust `struct`, the builder
//! pattern (or anti-pattern, depending whom you ask) is used.
//! * Be brief when possible. Example: `StencilTable::numStencils()` in C++
//! becomes `StencilTable::len()` in Rust.
//! * Use unsigned integer types, specifically `usize` and `u32`, instead of
//! signed ones (`i32`) for anything that can only contain positive values
//! (indices, sizes/lengths/counts, valences, arities, etc.). Types should
//! express intent. See also
//! [here](https://github.com/PixarAnimationStudios/OpenSubdiv/issues/1222).
//!
//! ## OpenSubdiv Backend Support
//!
//! *OpenSubdiv* exposes several optional backends via CMake flags. The table
//! below shows which ones this wrapper supports today.
//!
//! | Backend | Feature flag | Status |
//! |---------|-------------|--------|
//! | CPU (single-threaded) | — | Always enabled |
//! | TBB (CPU parallel) | `tbb` | Supported |
//! | CUDA (NVIDIA GPU) | `cuda` | Supported |
//! | Metal (Apple GPU) | `metal` | Supported |
//! | OpenCL | `opencl` | Supported |
//! | wgpu/WGSL (compute) | `wgpu` | Supported (Rust-native, not from C++) |
//! | OpenMP (CPU parallel) | `omp` | Supported (broken on macOS) |
//! | CLEW (OpenCL loader) | `clew` | Build flag only — no Rust API |
//! | PTex | `ptex` | Build flag only — no Rust API |
//! | OpenGL | — | Not yet supported |
//! | DirectX 11 | — | Not yet supported |
//!
//! ### wgpu
//!
//! The `wgpu` feature enables a **pure-Rust** GPU compute path for stencil
//! evaluation using WGSL shaders. This is not an *OpenSubdiv* backend —
//! it uploads `StencilTable` data to `wgpu` storage buffers and
//! dispatches a WGSL compute shader.
//!
//! ```rust,ignore
//! use opensubdiv_petite::osd::wgpu::*;
//!
//! // Upload stencil table to GPU.
//! let gpu_stencils = StencilTableGpu::from_cpu(&device, &stencil_table)?;
//!
//! // Create the compute pipeline (once).
//! let pipeline = StencilEvalPipeline::new(&device, WgslModuleConfig::default());
//!
//! // Evaluate: src_buffer → dst_buffer.
//! evaluate_stencils(
//! &device, &queue, &pipeline, &gpu_stencils,
//! &src_buffer, &dst_buffer, src_desc, dst_desc,
//! 0..gpu_stencils.stencil_count,
//! )?;
//! ```
//!
//! ## Cargo Features
//!
//! ## Versions
//!
//! For now crate versions reflect code maturity on the Rust side. They are not
//! in any way related to the *OpenSubdiv* version that is wrapped.
//!
//! - `v0.3.x` – *OpenSubdiv* `v3.7.x`
//! - `v0.2.x` – *OpenSubdiv* `v3.5.x`
//! - `v0.1.x` – *OpenSubdiv* `v3.4.x`
// Re-export error types for convenience
pub use ;
/// A vertex, edge, or face index in the topology.
///
/// # Examples
///
/// ```
/// use opensubdiv_petite::Index;
///
/// // Create an index from a u32
/// let idx = Index::from(42u32);
/// assert_eq!(idx.0, 42);
///
/// // Convert back to u32
/// let value: u32 = idx.into();
/// assert_eq!(value, 42);
///
/// // Create from usize
/// let idx = Index::from(100usize);
/// let as_usize: usize = idx.into();
/// assert_eq!(as_usize, 100);
/// ```
;