mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[wgsl] early depth test attribute
This commit is contained in:
committed by
Dzmitry Malyshau
parent
de39e7f4d1
commit
94bd97c0fb
@@ -184,3 +184,13 @@ pub fn map_standard_fun(word: &str) -> Option<crate::MathFunction> {
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn map_conservative_depth(word: &str) -> Result<crate::ConservativeDepth, Error<'_>> {
|
||||
use crate::ConservativeDepth as Cd;
|
||||
match word {
|
||||
"greater_equal" => Ok(Cd::GreaterEqual),
|
||||
"less_equal" => Ok(Cd::LessEqual),
|
||||
"unchanged" => Ok(Cd::Unchanged),
|
||||
_ => Err(Error::UnknownConservativeDepth(word)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,8 @@ pub enum Error<'a> {
|
||||
UnknownFunction(&'a str),
|
||||
#[error("unknown storage format: `{0}`")]
|
||||
UnknownStorageFormat(&'a str),
|
||||
#[error("unknown conservative depth: `{0}`")]
|
||||
UnknownConservativeDepth(&'a str),
|
||||
#[error("array stride must not be 0")]
|
||||
ZeroStride,
|
||||
#[error("not a composite type: {0:?}")]
|
||||
@@ -1932,6 +1934,7 @@ impl Parser {
|
||||
let mut stage = None;
|
||||
let mut is_block = false;
|
||||
let mut workgroup_size = [0u32; 3];
|
||||
let mut early_depth_test = None;
|
||||
|
||||
if lexer.skip(Token::DoubleParen('[')) {
|
||||
let (mut bind_index, mut bind_group) = (None, None);
|
||||
@@ -1994,6 +1997,16 @@ impl Parser {
|
||||
}
|
||||
}
|
||||
}
|
||||
"early_depth_test" => {
|
||||
let conservative = if lexer.skip(Token::Paren('(')) {
|
||||
let value = conv::map_conservative_depth(lexer.next_ident()?)?;
|
||||
lexer.expect(Token::Paren(')'))?;
|
||||
Some(value)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
early_depth_test = Some(crate::EarlyDepthTest { conservative });
|
||||
}
|
||||
word => return Err(Error::UnknownDecoration(word)),
|
||||
}
|
||||
match lexer.next() {
|
||||
@@ -2103,7 +2116,7 @@ impl Parser {
|
||||
.insert(
|
||||
(stage, name.to_string()),
|
||||
crate::EntryPoint {
|
||||
early_depth_test: None,
|
||||
early_depth_test,
|
||||
workgroup_size,
|
||||
function,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user