mirror of
https://github.com/SK8-ENGINE/skate-3-rust-engine.git
synced 2026-10-26 19:47:44 +00:00
Tests: set VERTEX_POSITIONS when validating shaders
retail_sky.wgsl reads forward_io's Vertex.position, which Bevy only
declares under VERTEX_POSITIONS; the mesh pipeline sets it for every mesh
with positions, but the test's validate() helper did not, so
sky_shader_validates failed (also on upstream 60efdef). All six shader
validation tests pass.
This commit is contained in:
2 files changed
+48
No files matched your search
@@ -18,6 +18,9 @@ use std::collections::HashMap;
|
||||
fn validate(source: &str, extras: &[&str]) -> naga::Module {
|
||||
let mut defs = HashMap::from([("MATERIAL_BIND_GROUP".into(), ShaderDefValue::UInt(3))]);
|
||||
for &name in [
|
||||
// Bevy's mesh pipeline sets this for every mesh with positions
|
||||
// (bevy_pbr mesh.rs); forward_io's Vertex only declares it then.
|
||||
"VERTEX_POSITIONS",
|
||||
"VERTEX_UVS_A",
|
||||
"VERTEX_UVS_B",
|
||||
"VERTEX_TANGENTS",
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
# Sky shader validation test
|
||||
|
||||
Branch: `gameplay/water`. Status: **done**; test-only change, no game behaviour changes.
|
||||
|
||||
## Problem
|
||||
|
||||
`retail_render::shader_tests::sky_shader_validates` failed on untouched upstream
|
||||
(`60efdef`) and was listed as a known pre-existing failure:
|
||||
|
||||
```
|
||||
error: invalid field accessor `position`
|
||||
29 │ let world = v.position + vec3<f32>(view.world_position.x, ...
|
||||
```
|
||||
|
||||
## Root cause
|
||||
|
||||
`retail_sky.wgsl` takes `bevy_pbr::forward_io::Vertex`, whose `position` field is
|
||||
declared only under `#ifdef VERTEX_POSITIONS`
|
||||
(`vendor/bevy_pbr/src/render/forward_io.wgsl`). Bevy's mesh pipeline pushes
|
||||
`VERTEX_POSITIONS` for every mesh layout that has positions
|
||||
(`vendor/bevy_pbr/src/render/mesh.rs`, `shader_defs.push("VERTEX_POSITIONS")`), so
|
||||
the shader compiles in the game. The test's `validate` helper
|
||||
(`crates/skate-game/src/retail_shader_tests.rs`) composes shaders with its own
|
||||
def list, which included the UV/tangent/colour/normal defs but not
|
||||
`VERTEX_POSITIONS`. The world shader never reads `Vertex.position`, so only the
|
||||
sky test tripped over it.
|
||||
|
||||
## Change
|
||||
|
||||
Add `VERTEX_POSITIONS` to the shader defs in `validate`, matching what Bevy sets
|
||||
for real meshes. The shader is unchanged.
|
||||
|
||||
## Files
|
||||
|
||||
- `crates/skate-game/src/retail_shader_tests.rs`
|
||||
|
||||
## Verification
|
||||
|
||||
`cargo test --locked -p skate-game --release --bin skate3rust -- shader_tests`:
|
||||
all six pass (`sky_shader_validates`, world, depth in every shadow configuration,
|
||||
character, and both vertex-location checks).
|
||||
|
||||
## Open questions
|
||||
|
||||
None. The PR plan's list of known upstream failures notes this one as fixed.
|
||||
Reference in new issue
Block a user