Commit graph

5 commits

Author SHA1 Message Date
Bruce Mitchener 75b27d65f5 vello_shaders: Use naga 0.12, not git rev.
The git revision being used was from `0.11` while the current
release is `0.12`. `0.12` is used in `wgpu`, so this lets us
have a single `naga` crate being built.
2023-07-05 10:18:50 +07:00
Raph Levien 3774928b24 Enforce clippy lints
This turns on clippy checking and also fixes all lints in the code.

Many lints are obvious improvements. Only a small number are slightly annoying, so I think overall worth having a vanilla default config.
2023-05-18 16:13:32 -07:00
Arman Uguray d82bd409ff [shaders] Shader path look up fixes for hermetic builds
* Bazel builds seem to fail to open relative paths to parent directories
  due to hermetic sandboxing of third-party repositories. This adds a
  WORKSPACE_MANIFEST_FILE environment variable that allows the caller to
  optionally provide an absolute path to the workspace root manifest
  file.
* The existing code processed a shader file only if
  `FileType::is_file` returns true for it. This is not the case when
  sources are accessed via symbolic links, which is possible in a Bazel
  sandbox. The code now filters for the ".wgsl" file extension instead
  of the file type which should generally be safe.
2023-05-16 15:08:54 -07:00
Arman Uguray b4ffb88494 [shaders] Revise access to backend-agnostic metadata
Previously the generated shader data structures were rooted in
backend-specific top-level mods (`mod wgsl`, `mod msl`, etc). This made
access to per-shader information that is common to all backends (e.g.
workgroup sizes, shader name etc) awkward to access from backend
agnostic code, especially when feature-gated conditional compilation is
used on the client side.

The data structures have been rearranged such that there is a top-level
`ComputeShader` declaration for each stage under a `gen` mod. The
`ComputeShader` struct declares feature-gated fields for backend shader
sources, such that backend specific data is now a leaf node in the
structure rather than the root. This has some additional benefits:

1. Common data doesn't have to be redeclared, saving on code size when
   multiple backends are enabled.

2. The backend specific source code was previously encoded as a `[u8]`.
   We can now use types that more closely match the expected format, for
   example `&str` for WGSL and MSL, `[u32]` for SPIR-V, etc.

3. If we ever need to expose additional backend-specific metadata in the
   future, we can bundle them alongside the source code in a
   backend-specific data structure at this level of the tree.
2023-05-10 14:12:13 -07:00
Arman Uguray 0a6a6e2c21 [vello_shaders] Move vello_shaders to crates/shaders 2023-03-29 12:24:28 -07:00