Fix edge case scoped structures name conflict.

Structures with names ending in "_#" such as "_0" could conflict
with the internally rewritten scoped structures. Fix this by using
a prepending rule instead of appending.

Also includes a test, and fixes a WebGL test in Firefox. (Chrome is
not affected because of the variable hashing step.)

BUG=angle:618

Change-Id: I3d441f1de268b6d7e74a0834b43e889b7bfe578c
Reviewed-on: https://chromium-review.googlesource.com/201468
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Nicolas Capens <nicolascapens@chromium.org>
Fix missing bracket in translator source.

Broken in ed14b79dc8e9ec4f4a831bb5213ab67ef01af196.

BUG=angle:628

Change-Id: Ia6b92dd13362bb51f0aa17a14278039d568f5434
Reviewed-on: https://chromium-review.googlesource.com/202182
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Nicolas Capens <nicolascapens@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Refactor CopyTexImage validation.

Move the common validation code to a shared base function.

BUG=angle:571

Change-Id: Id70b413b408a21f0a8933cfd4a09e261e637bae1
Reviewed-on: https://chromium-review.googlesource.com/200559
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
Fix unused variable in validationES.cpp.

Broken in 560a8d889b6866d7d29d.

BUG=angle:571

Change-Id: Idb2414e11ad397cc45c2bdf5f357fd1b8e7fe6c2
Reviewed-on: https://chromium-review.googlesource.com/202602
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
Regenerate public projects.

Change-Id: I57817666faca834e075216e63d7b0353d7a4d72c
Reviewed-on: https://chromium-review.googlesource.com/202596
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
Redesign HLSL scoped structures to a unique ID.

A unique ID gives a more flexible renaming scheme than our
current method of using nested scope identifiers. The reduced
complexity allows for fewer points of breakage and fixes an
outstanding bug with scoped structures (with added test).

BUG=angle:618

Change-Id: I6551248bb9fa2d185ab67248721f898dd50151f0
Reviewed-on: https://chromium-review.googlesource.com/202183
Reviewed-by: Nicolas Capens <nicolascapens@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
Fix up some validation bugs in Texture functions.

In several places we weren't handling certain errors, or were
returning the wrong error code. Several dEQP negative API
tests are affected in functional.negative_api.texture.

BUG=angle:571

Change-Id: I19d7250aab2c15d709fd591b8df90ce883f9ac60
Reviewed-on: https://chromium-review.googlesource.com/201250
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
Rename Renderbuffer to FramebufferAttachment.

Part of the refactoring effort to clean up our classes for FBO
attachments and Renderbuffers.

BUG=angle:660

Change-Id: Id23df904f56499568159611b66c8922b9dce6a3d
Reviewed-on: https://chromium-review.googlesource.com/201832
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
Move FBO attachment code to new source file.

Since FBO attachments and Renderbuffers are semantically distinct,
make a new location for attachments to live.

BUG=angle:660

Change-Id: I51753f8a814e89641637c5d8293f7e9a573a7ba5
Reviewed-on: https://chromium-review.googlesource.com/201833
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
Prevents multisample depthstencil from being bound as an SRV

BUG=381413

Multisample textures can only be bound as both depth stencil
views and shader resource views at feature level 10_1 and above.
We don't need to bind textures as SRVs if they're multisample
depth targets, so we should avoid the SRV flag in that case.

Change-Id: I28ca98bdc4a86eb5442b39ea3cf2b42aa9216aab
Reviewed-on: https://chromium-review.googlesource.com/202921
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Shannon Woods <shannonwoods@chromium.org>
Refactor GLSL scoped structure handling.

With a unique ID, similar to how we handle scoped structures
in the HLSL translator, we can simplify the declared structure
check.

BUG=angle:618

Change-Id: I5fe61c8d353650ac67a7c7ecdf53a70b91a9b717
Reviewed-on: https://chromium-review.googlesource.com/202500
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
Store the std140 layout offsets in a pre-pass.

Instead of recording data and mutating a local table as we parse,
store all of the offsets for the std140 structs when we first
generate the struct. This should have no behavioural change, as
structs should always be defined first in any case.

BUG=angle:466

Change-Id: I1b732d67bd4f5b908211410e5e7796d72d836174
Reviewed-on: https://chromium-review.googlesource.com/202910
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Nicolas Capens <nicolascapens@chromium.org>
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Report zero bit sizes for channels that shouldn't exist.

If the actual format has more channels than the internal format of a
framebuffer, bits counts greater than zero will be returned for channels
that should not exist.  While it is not against the spec to return more
bits than exist in the format, it can be confusing for users or break
tests.  get*Bits will now only return greater than zero bit counts when
the format should have the given channel.

Since this is the only location that we return information about the
"real" internal format we're using, it's safe to only make the
modifications here.

BUG=angle:653

Change-Id: I43ef4c6290c8c70737d579d7e9a2dd30d653330b
Reviewed-on: https://chromium-review.googlesource.com/202594
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
Refactor platform related functionality into platform.h and tls.h.

Since libGLESv2 and libEGL will eventually be cross platform, it will be
useful to have platform defines and TLS functions that work everywhere.

BUG=angle:664

Change-Id: Ia357925a0992d82e8b446d88d32a1984d319e6e8
Reviewed-on: https://chromium-review.googlesource.com/202133
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
Restrict the size of shader arrays.

This prevents overflow issues in the HLSL translator and some drivers. The
limit it hard-coded to 65536 to be larger than the Shader Model 5 register
limit (4096) to account for register allocation optimizations and future
hardware.

BUG=379799

Change-Id: I20f05c9dd230fbfc1c92af52533cd2b50f2ff994
Reviewed-on: https://chromium-review.googlesource.com/202939
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Nicolas Capens <nicolascapens@chromium.org>
Fix constructing vectors from matrices.

BUG=380353

Change-Id: I3b0fe55b829602554bb63bbd281ad58d47364502
Reviewed-on: https://chromium-review.googlesource.com/202966
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Nicolas Capens <nicolascapens@chromium.org>
Add constant casting support.

BUG=380353

Change-Id: I5a350ca09e2b7e7abb9fa079365adb5aad5af607
Reviewed-on: https://chromium-review.googlesource.com/203450
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Nicolas Capens <nicolascapens@chromium.org>
Create constructors just once.

BUG=380353

Change-Id: I9828a3f193ccfdda2013fa3de0e41e6e28953ea2
Reviewed-on: https://chromium-review.googlesource.com/203451
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Nicolas Capens <nicolascapens@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Produce constructors instead of conversions.

GLSL only supports explicit conversion through constructors. Therefore the conversion
nodes are redundant.

BUG=380353

Change-Id: Id871c34750191dac431bf72aac9afed7b0db7f8e
Reviewed-on: https://chromium-review.googlesource.com/203452
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Nicolas Capens <nicolascapens@chromium.org>
Fix crash on zero size but non-NULL bufferData.

Could cause a crash when running the WebGL CTS with Firefox.

BUG=angle:675

Change-Id: I58bf9eed622660d4702b775f368ff9cbd693197a
Reviewed-on: https://chromium-review.googlesource.com/203456
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Nicolas Capens <nicolascapens@chromium.org>