BlamKiwi / angleproject

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

HLSL output has a lot of extra semicolons and braces #1013

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Translate any shader with if statements, ternary operators or loops into 
HLSL.

What is the expected output? What do you see instead?
Expected: HLSL code is relatively clean of any extra tokens.
Actual: HLSL code contains a lot of unnecessary semicolons and braces, making 
it hard to read.

Recently switching to AST transformations to handle ternary operators instead 
of outputting shader code directly made this problem worse.

Original issue reported on code.google.com by oetu...@nvidia.com on 28 May 2015 at 9:35

GoogleCodeExporter commented 9 years ago
The following revision refers to this bug:
  https://chromium.googlesource.com/angle/angle/+/4d59f3c6b7906eae344076dfc5a37870f1e489a2

commit 4d59f3c6b7906eae344076dfc5a37870f1e489a2
Author: Olli Etuaho <oetuaho@nvidia.com>
Date: Thu May 28 14:33:53 2015

Make false blocks produced by RewriteElseBlocks sequence nodes

All child nodes of selection should be sequence nodes, so that they will
output braces and extra braces can be removed from HLSL output.

Also make RewriteElseBlocks to reuse common IntermTraverser functionality
to simplify the code.

TEST=WebGL conformance tests on D3D9
BUG=angleproject:1013

Change-Id: Iafdc05468b22d110abcd020cf52c646dd98fb4a0
Reviewed-on: https://chromium-review.googlesource.com/273608
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Zhenyao Mo <zmo@chromium.org>

[modify] 
http://crrev.com/4d59f3c6b7906eae344076dfc5a37870f1e489a2/src/compiler/translato
r/TranslatorHLSL.cpp
[modify] 
http://crrev.com/4d59f3c6b7906eae344076dfc5a37870f1e489a2/src/compiler/translato
r/RewriteElseBlocks.cpp
[modify] 
http://crrev.com/4d59f3c6b7906eae344076dfc5a37870f1e489a2/src/compiler/translato
r/RewriteElseBlocks.h
[modify] 
http://crrev.com/4d59f3c6b7906eae344076dfc5a37870f1e489a2/src/compiler/translato
r/OutputHLSL.cpp

Original comment by bugdroid1@chromium.org on 28 May 2015 at 4:50

GoogleCodeExporter commented 9 years ago
The following revision refers to this bug:
  https://chromium.googlesource.com/angle/angle/+/4785fec97aa95bffb8e3a7c2dd20da112238923d

commit 4785fec97aa95bffb8e3a7c2dd20da112238923d
Author: Olli Etuaho <oetuaho@nvidia.com>
Date: Mon May 18 13:09:37 2015

Clean up most common extra semicolons and braces in HLSL output

Clean up extra semicolons and braces from loops and conditional statements
and extra braces from function definitions.

This makes the HLSL output considerably easier to read.

TEST=angle_unittests, angle_end2end_tests, dEQP-GLES3.functional.shaders.*,
     WebGL conformance tests
BUG=angleproject:1013

Change-Id: I8180bab7b3d4bda1cdb8e4fb51cf9d8e384dd797
Reviewed-on: https://chromium-review.googlesource.com/273607
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>

[modify] 
http://crrev.com/4785fec97aa95bffb8e3a7c2dd20da112238923d/src/compiler/translato
r/OutputHLSL.cpp

Original comment by bugdroid1@chromium.org on 28 May 2015 at 5:43