Skip to content

Commit

Permalink
fixup! docs: add warning about stack size for WGSL compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed Apr 3, 2024
1 parent 6dcd12d commit 8cdd967
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
10 changes: 5 additions & 5 deletions naga/src/front/wgsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ impl Frontend {
// NOTE: Keep this in sync with `wgpu::Device::create_shader_module`!
// NOTE: Keep this in sync with `wgpu_core::Global::device_create_shader_module`!
///
/// Compiler-enforced limits for WGSL parsing recursion exist; if shader compilation runs into
/// them, it will return an error gracefully. However, on some build profiles and platforms, the
/// default stack size for a thread may be exceeded before this limit is reached during parsing.
/// Callers should ensure that there is enough stack space for this, particularly if calls to this
/// method are exposed to user input.
/// This function may consume a lot of stack space. Compiler-enforced limits for parsing recursion
/// exist; if shader compilation runs into them, it will return an error gracefully. However, on
/// some build profiles and platforms, the default stack size for a thread may be exceeded before
/// this limit is reached during parsing. Callers should ensure that there is enough stack space
/// for this, particularly if calls to this method are exposed to user input.
///
/// </div>
pub fn parse_str(source: &str) -> Result<crate::Module, ParseError> {
Expand Down
11 changes: 6 additions & 5 deletions wgpu-core/src/device/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1176,11 +1176,12 @@ impl Global {
// NOTE: Keep this in sync with `naga::front::wgsl::parse_str`!
// NOTE: Keep this in sync with `wgpu::Device::create_shader_module`!
///
/// Compiler-enforced limits for parsing recursion exist; if shader compilation runs into them,
/// it will return an error gracefully. However, on some build profiles and platforms, the
/// default stack size for a thread may be exceeded before this limit is reached during
/// parsing. Callers should ensure that there is enough stack space for this, particularly if
/// calls to this method are exposed to user input.
/// This function may consume a lot of stack space. Compiler-enforced limits for parsing
/// recursion exist; if shader compilation runs into them, it will return an error gracefully.
/// However, on some build profiles and platforms, the default stack size for a thread may be
/// exceeded before this limit is reached during parsing. Callers should ensure that there is
/// enough stack space for this, particularly if calls to this method are exposed to user
/// input.
///
/// </div>
pub fn device_create_shader_module<A: HalApi>(
Expand Down
11 changes: 6 additions & 5 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2301,11 +2301,12 @@ impl Device {
// NOTE: Keep this in sync with `naga::front::wgsl::parse_str`!
// NOTE: Keep this in sync with `wgpu_core::Global::device_create_shader_module`!
///
/// Compiler-enforced limits for WGSL parsing recursion exist; if shader compilation runs into
/// them, it will return an error gracefully. However, on some build profiles and platforms for
/// native targets, the default stack size for a thread may be exceeded before this limit is
/// reached during parsing. Callers should ensure that there is enough stack space for this,
/// particularly if calls to this method are exposed to user input.
/// This function may consume a lot of stack space. Compiler-enforced limits for parsing
/// recursion exist; if shader compilation runs into them, it will return an error gracefully.
/// However, on some build profiles and platforms, the default stack size for a thread may be
/// exceeded before this limit is reached during parsing. Callers should ensure that there is
/// enough stack space for this, particularly if calls to this method are exposed to user
/// input.
///
/// </div>
pub fn create_shader_module(&self, desc: ShaderModuleDescriptor<'_>) -> ShaderModule {
Expand Down

0 comments on commit 8cdd967

Please sign in to comment.