mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[glsl-in] Add glsl-validate and sampling qualifier
This commit is contained in:
committed by
Dzmitry Malyshau
parent
565c27292a
commit
7165a06fbf
@@ -163,6 +163,7 @@ impl<'a> Program<'a> {
|
||||
)
|
||||
}
|
||||
|
||||
#[allow(dead_code)] // FIXME: Remove after implementing structs
|
||||
pub fn type_size(&self, ty: Handle<Type>) -> Result<u8, ErrorKind> {
|
||||
Ok(match self.module.types[ty].inner {
|
||||
crate::TypeInner::Scalar { width, .. } => width,
|
||||
@@ -310,11 +311,6 @@ impl<'function> Context<'function> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear_scopes(&mut self) {
|
||||
self.scopes.clear();
|
||||
self.scopes.push(FastHashMap::default());
|
||||
}
|
||||
|
||||
/// Add variable to current scope
|
||||
pub fn add_local_var(&mut self, name: String, expr: Handle<Expression>) {
|
||||
if let Some(current) = self.scopes.last_mut() {
|
||||
|
||||
@@ -5,8 +5,6 @@ use crate::{FastHashMap, Module, ShaderStage};
|
||||
|
||||
mod lex;
|
||||
|
||||
// TODO: Remove later
|
||||
#[allow(dead_code)]
|
||||
mod ast;
|
||||
use ast::Program;
|
||||
|
||||
|
||||
@@ -163,6 +163,7 @@ impl<'source, 'program, 'options> Parser<'source, 'program, 'options> {
|
||||
fn peek_type_qualifier(&mut self) -> bool {
|
||||
self.lexer.peek().map_or(false, |t| match t.value {
|
||||
TokenValue::Interpolation(_)
|
||||
| TokenValue::Sampling(_)
|
||||
| TokenValue::Const
|
||||
| TokenValue::In
|
||||
| TokenValue::Out
|
||||
@@ -192,6 +193,7 @@ impl<'source, 'program, 'options> Parser<'source, 'program, 'options> {
|
||||
TokenValue::Uniform => TypeQualifier::StorageQualifier(
|
||||
StorageQualifier::StorageClass(StorageClass::Uniform),
|
||||
),
|
||||
TokenValue::Sampling(s) => TypeQualifier::Sampling(s),
|
||||
|
||||
_ => unreachable!(),
|
||||
})
|
||||
|
||||
@@ -346,6 +346,11 @@ impl Program<'_> {
|
||||
name: String,
|
||||
init: Option<Handle<Constant>>,
|
||||
) -> Result<Handle<Expression>, ErrorKind> {
|
||||
#[cfg(feature = "glsl-validate")]
|
||||
if ctx.lookup_local_var_current_scope(&name).is_some() {
|
||||
return Err(ErrorKind::VariableAlreadyDeclared(name));
|
||||
}
|
||||
|
||||
// FIXME: this should be removed after
|
||||
// fixing the lack of constant qualifier support
|
||||
#[allow(clippy::never_loop)]
|
||||
|
||||
Reference in New Issue
Block a user