Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for incorrect GLSL validation on witeonly image uniforms #2061

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/front/glsl/parser_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,20 @@ fn declarations() {
#version 450
precision highp float;

void main() {}
"#,
)
.unwrap();

parser
.parse(
&Options::from(ShaderStage::Compute),
r#"
#version 450
precision highp float;

layout(binding = 0) uniform writeonly image2D image;

void main() {}
"#,
)
Expand Down
23 changes: 13 additions & 10 deletions src/front/glsl/variables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use super::{
};
use crate::{
AddressSpace, Binding, Block, BuiltIn, Constant, Expression, GlobalVariable, Handle,
Interpolation, LocalVariable, ResourceBinding, ScalarKind, ShaderStage, SwizzleComponent, Type,
TypeInner, VectorSize,
Interpolation, LocalVariable, ResourceBinding, ScalarKind, ShaderStage, StorageAccess,
SwizzleComponent, Type, TypeInner, VectorSize,
};

pub struct VarDeclaration<'a, 'key> {
Expand Down Expand Up @@ -518,14 +518,17 @@ impl Parser {

match qualifiers.layout_qualifiers.remove(&QualifierKey::Format) {
Some((QualifierValue::Format(f), _)) => format = f,
// TODO: glsl supports images without format qualifier
// if they are `writeonly`
None => self.errors.push(Error {
kind: ErrorKind::SemanticError(
"image types require a format layout qualifier".into(),
),
meta,
}),
None => {
if access.contains(StorageAccess::LOAD) {
self.errors.push(Error {
kind: ErrorKind::SemanticError(
"image types require a format layout qualifier"
.into(),
),
meta,
})
}
}
_ => unreachable!(),
}

Expand Down