KroMignon / angleproject

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

Unify operand type validation in shader compiler #952

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Right now validation of operand types is split among several different places 
in the code:

1. Built-in function call parameters are checked against the function 
signatures in the symbol table.
2. In ParseContext.
3. In Intermediate member functions, which have the main task of helping to 
build the intermediate representation: tying together nodes etc.
4. IntermUnary/Binary::promote(), functions which have the main task of setting 
the type of the node and changing the type of the operation when the operands 
require that.

I propose gradually moving validation from 3. and 4. to ParseContext, so that 
all the validation is in one place and Intermediate and promote() are left with 
clearly defined roles in the system. This has several advantages: the code is 
easier to understand and check for errors, and there's no need to pass data out 
of ParseContext when checks depend on for example shading language version. 
Asserts can be added to Intermediate and promote() to ensure that nothing 
regresses when doing this refactoring.

Original issue reported on code.google.com by oetu...@nvidia.com on 19 Mar 2015 at 12:21

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

Code-Review  0 : Nicolas Capens, Olli Etuaho
Code-Review  +1: Zhenyao Mo
Code-Review  +2: Jamie Madill
Verified     0 : Jamie Madill, Nicolas Capens, Zhenyao Mo
Verified     +1: Olli Etuaho
Commit Queue   : Chumped
Change-Id      : Idb2de927d872e46210d71cf6de06a6f8c1fc5da1
Reviewed-at    : https://chromium-review.googlesource.com/260803

Move some validation from IntermBinary::promote to ParseContext

This makes the role of promote() in the system clearer and helps to make
the code more understandable, since more of the checks are in the same
logical place.

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

src/compiler/translator/IntermNode.cpp
src/compiler/translator/ParseContext.cpp
src/compiler/translator/ParseContext.h

Original comment by bugdro...@chromium.org on 20 Mar 2015 at 6:11