shairai / angleproject

Automatically exported from code.google.com/p/angleproject
Other
0 stars 0 forks source link

Uniform declarations following empty declaration with an uniform block layout qualifier are accepted #969

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try to compile the following shader using ANGLE:

#version 300 es
precision mediump float;
layout(packed) uniform mat2, x;
out vec4 my_FragColor;
void main() {
   my_FragColor = vec4(1.0);
}

What is the expected output? What do you see instead?
Expected: Compilation fails due to incorrect qualifier (only uniform blocks 
should be able to have uniform block qualifiers such as "packed")
Actual: Compilation succeeds.

This is because some checks in ParseContext are skipped when a declarator 
follows an empty declaration.

There are at least two possible reasonable solutions:
-Add checks on empty declarations (this might make ANGLE fail some shaders that 
are intuitively nonsensical but not that clearly wrong according to the spec, 
like ones that use "varying struct S {...};")
-Add necessary checks that are currently run on single declarations also on 
declarators (possibly only those that follow empty declarations, if feasible).

Original issue reported on code.google.com by oetu...@nvidia.com on 9 Apr 2015 at 3:38

GoogleCodeExporter commented 9 years ago
Project: angle/angle
Branch : master
Author : Olli Etuaho <oetuaho@nvidia.com>
Commit : e16eae36717459107370171b1c569fae64d80eed

Code-Review  0 : Nicolas Capens, Olli Etuaho
Code-Review  +1: Jamie Madill
Code-Review  +2: Geoff Lang
Verified     0 : Geoff Lang, Jamie Madill, Nicolas Capens
Verified     +1: Olli Etuaho
Commit Queue   : Chumped
Change-Id      : Ib43233e275fbf4db7e5fda6df6b45a655bdee8a2
Reviewed-at    : https://chromium-review.googlesource.com/265200

Fix structQualifierErrorCheck calls in glslang.y

structQualifierErrorCheck is called incorrectly in glslang.y. Remove one
unnecessary call entirely and change another call to samplerErrorCheck.
This will enable further changes to merge structQualifierErrorCheck into
singleDeclarationErrorCheck.

TEST=angle_unittests
BUG=angleproject:969

src/compiler/translator/glslang.y
src/compiler/translator/glslang_lex.cpp
src/compiler/translator/glslang_tab.cpp

Original comment by bugdro...@chromium.org on 15 Apr 2015 at 7:34

GoogleCodeExporter commented 9 years ago
Project: angle/angle
Branch : master
Author : Olli Etuaho <oetuaho@nvidia.com>
Commit : fa33d58085c442d1d0e687a3cb40d338bf44f7f8

Code-Review  0 : Jamie Madill, Olli Etuaho
Code-Review  +2: Geoff Lang
Verified     0 : Geoff Lang, Jamie Madill
Verified     +1: Olli Etuaho
Commit Queue   : Chumped
Change-Id      : Idcb0673e3bcf64087744ff0d260f51a7546f024a
Reviewed-at    : https://chromium-review.googlesource.com/264812

Improve handling of declarator lists with empty declarations

The code previously failed to check for correctness of layout qualifiers
in case a declarator followed an empty declaration, like so:

layout(packed) uniform float, a;

Fix this by running all necessary declaration checks also for declarators
which follow an empty declaration.

structQualifierErrorCheck is merged into singleDeclarationErrorCheck.

TEST=angle_unittests, WebGL conformance tests
BUG=angleproject:969

src/compiler/translator/ParseContext.cpp
src/compiler/translator/ParseContext.h
src/tests/compiler_tests/MalformedShader_test.cpp

Original comment by bugdro...@chromium.org on 15 Apr 2015 at 7:36

GoogleCodeExporter commented 9 years ago

Original comment by oetu...@nvidia.com on 22 Apr 2015 at 12:52