mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-09 20:31:29 +11:00
1dea6c0ef0
Fixed several other shader validation errors caught when running vello_shaders natively on Metal. These were primarily caused by reading an invalid drawtag while accessing the scene buffer. Scene buffer access in the offending pipelines now initialize the draw tag to DRAWTAG_NOP if an invocation ID would land beyond the valid index range of encoded draw objects.
24 lines
927 B
WebGPU Shading Language
24 lines
927 B
WebGPU Shading Language
// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
|
|
|
|
// This file defines utility functions that interact with host-shareable buffer objects. It should
|
|
// be imported once following the resource binding declarations in the shader module that access
|
|
// them.
|
|
|
|
// Reads a draw tag from the scene buffer, defaulting to DRAWTAG_NOP if the given `ix` is beyond the
|
|
// range of valid draw objects (e.g this can happen if `ix` is derived from an invocation ID in a
|
|
// workgroup that partially spans valid range).
|
|
//
|
|
// This function depends on the following global declarations:
|
|
// * `scene`: array<u32>
|
|
// * `config`: Config (see config.wgsl)
|
|
fn read_draw_tag_from_scene(ix: u32) -> u32 {
|
|
let tag_ix = config.drawtag_base + ix;
|
|
var tag_word: u32;
|
|
if tag_ix < config.drawtag_base + config.n_drawobj {
|
|
tag_word = scene[tag_ix];
|
|
} else {
|
|
tag_word = DRAWTAG_NOP;
|
|
}
|
|
return tag_word;
|
|
}
|