OSDN Git Service

android-x86/external-swiftshader.git
6 years agoFix marking all cube faces as clean after update.
Nicolas Capens [Fri, 2 Mar 2018 17:59:36 +0000 (12:59 -0500)]
Fix marking all cube faces as clean after update.

Change-Id: I85886ea83f4d748dce98d79acff204bf855da1ad
Reviewed-on: https://swiftshader-review.googlesource.com/17569
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoRefactor texture binding.
Nicolas Capens [Fri, 2 Mar 2018 17:37:47 +0000 (12:37 -0500)]
Refactor texture binding.

Also remove traces of cube texture support for OpenGL ES 1.1. We don't
support the OES_texture_cube_map extension, and it would be non-trivial
due to requiring reflective texture coordinate generation.

Change-Id: I5c224f925fc9c03053acaf33e126dae4f3ffe4d9
Reviewed-on: https://swiftshader-review.googlesource.com/16750
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRefactor exp2().
Nicolas Capens [Fri, 12 Jan 2018 02:19:34 +0000 (21:19 -0500)]
Refactor exp2().

Change-Id: I491411ba77addcb514944717b19918e4d1b98898
Reviewed-on: https://swiftshader-review.googlesource.com/16228
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRelease surface on releaseTexImage
Alexis Hetu [Thu, 1 Mar 2018 19:51:20 +0000 (14:51 -0500)]
Release surface on releaseTexImage

The surface set during bindTexImage should be unset during
releaseTexImage. Failing to do so may keep a dangling pointer
to the surface, which can cause a crash later on (this was hit
during the testing of new unit tests which  will be added soon).

Change-Id: Ic258fff8c880d449add825c5e9185435cc4ea419
Reviewed-on: https://swiftshader-review.googlesource.com/17548
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAccept GL_RGB/GL_RGBA for glGetInternalformativ.
Nicolas Capens [Wed, 17 Jan 2018 18:39:58 +0000 (13:39 -0500)]
Accept GL_RGB/GL_RGBA for glGetInternalformativ.

The spec mentions them as color-renderable, but our IsColorRenderable()
function only handles sized internal format, and adding them there
might hide bugs in our renderbuffer implementation since they can only
be constructed using sized internal formats.

dEQP also has a note about this inconsistency, and consequently these
formats are not part of the 'mustpass' set for
dEQP-GLES3.functional.state_query.internal_format.
So it might be a spec oversight.

Change-Id: I08ca3dad4c0b5686536dafd3ade1e855e3968aa0
Reviewed-on: https://swiftshader-review.googlesource.com/16410
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoMake swiftshader build files produce libs in correct folders.
Tomasz Wiszkowski [Mon, 12 Feb 2018 17:05:31 +0000 (09:05 -0800)]
Make swiftshader build files produce libs in correct folders.

Current build system assumes single arch targets to be 32bit and produces 64bit libraries
in an incorrect folder.

The change allows build system to determine proper location of the libraries.

Change-Id: Ic95a36f7108fcae8e6f120f0853ee00e9a8926c1
Reviewed-on: https://swiftshader-review.googlesource.com/17188
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRe-implement GL_APPLE_texture_format_BGRA8888.
Nicolas Capens [Tue, 27 Feb 2018 21:45:43 +0000 (16:45 -0500)]
Re-implement GL_APPLE_texture_format_BGRA8888.

GL_APPLE_texture_format_BGRA8888 specifies that when using the BGRA_EXT
format, it "must have an RGBA internal format". Note that
GL_EXT_texture_format_BGRA8888 also allows BGRA_EXT as internalformat.

Change-Id: I27e032054240efe96c32e27ebbdfb3c28213b1d8
Reviewed-on: https://swiftshader-review.googlesource.com/16248
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix floating-point luminance/alpha pixel upload.
Nicolas Capens [Wed, 28 Feb 2018 15:02:07 +0000 (10:02 -0500)]
Fix floating-point luminance/alpha pixel upload.

We were expecting R or RG internal formats, instead of L, A, or LA.

Change-Id: I6ee145341819460dda262b017db6d8105860f49a
Reviewed-on: https://swiftshader-review.googlesource.com/17508
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoTexture rectangle related fixes and associated tests
Alexis Hetu [Fri, 2 Feb 2018 22:23:48 +0000 (17:23 -0500)]
Texture rectangle related fixes and associated tests

Imported texture rectangle tests from angle and fixed all
texture rectangle related failures:
- Rectangle textures can be rendered to
- Rectangle textures only support level 0
- Rectangle textures can't be compressed
- glTexStorage2D can no longer create a texture larger
  than the maximum size allowed

Change-Id: I089291c94aad79e244782a8d56dd224c7510d237
Reviewed-on: https://swiftshader-review.googlesource.com/16908
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoUse a relative URL for SwiftConfig.
Nicolas Capens [Wed, 24 Jan 2018 21:33:52 +0000 (21:33 +0000)]
Use a relative URL for SwiftConfig.

This makes it easier to use a different address,
in particular the port.

Also add a missing header for std::max.

Change-Id: I454dd6f4a92b5d8b97625e4cb50796e9f0940009
Reviewed-on: https://swiftshader-review.googlesource.com/16668
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix renderbuffer binding for OpenGL ES 1.1.
Nicolas Capens [Mon, 26 Feb 2018 22:47:06 +0000 (17:47 -0500)]
Fix renderbuffer binding for OpenGL ES 1.1.

glBindRenderbufferOES() doesn't require anything except a
non-zero renderbuffer to create a new Renderbuffer object (it is not
required to use GenRenderbuffers before using BindRenderbuffer).
This had been fixed for GLES 3.0 and 2.0, but the same also applies
to GLES 1.1. Note that the Context already properly handles the case
where renderbuffer is zero.

Bug b/25983901

Change-Id: If5e97be8027fca7c97cce5c44d063cd054443700
Reviewed-on: https://swiftshader-review.googlesource.com/17490
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDon't perform component swizzling on a null texture.
Nicolas Capens [Tue, 27 Feb 2018 18:29:26 +0000 (13:29 -0500)]
Don't perform component swizzling on a null texture.

When sampling from an incomplete texture, the OpenGL spec states that
(0, 0, 0, 1) will be returned to the shader from the texture lookup
function. Swizzling is only described for filtered texture values.

Change-Id: Ie8a02b3b0b9e571fd2f86302e777a4ff985da022
Reviewed-on: https://swiftshader-review.googlesource.com/17488
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix internal format handling for OpenGL ES 1.1.
Nicolas Capens [Mon, 26 Feb 2018 22:47:06 +0000 (17:47 -0500)]
Fix internal format handling for OpenGL ES 1.1.

With the egl::Image class now only storing the sized internal format,
some OpenGL ES 1.1 functionality broke because it was still expecting a
base format.

Change-Id: Ib41e91f371a06b2a09471ea45dd1f8f56b94091f
Reviewed-on: https://swiftshader-review.googlesource.com/17468
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoReplace GL_NONE with GL_NO_ERROR when used as error.
Nicolas Capens [Mon, 26 Feb 2018 22:47:06 +0000 (17:47 -0500)]
Replace GL_NONE with GL_NO_ERROR when used as error.

GL_NONE is primarily a renderbuffer format, and GL_NO_ERROR more
clearly conveys the meaning when used as a validation return code.
Also, GL_NONE is not defined in OpenGL ES 1.1 (but GL_NONE_OES is,
as a renderbuffer format).

Change-Id: Ie1c00009c30c8d2717de15c7e27db295ecd9de1e
Reviewed-on: https://swiftshader-review.googlesource.com/17489
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoRestrict multisampling to normalized unsigned and float formats.
Nicolas Capens [Wed, 17 Jan 2018 19:02:55 +0000 (14:02 -0500)]
Restrict multisampling to normalized unsigned and float formats.

Surface::resolve() currently only supports these formats. Also this
change reuses the GetColorComponentType() utility function instead of
using a separate switch. Effectively, signed normalized formats now
return 0 samples.

Change-Id: I839ffa89a63d8e1b0a40913d3b1ad13e2ce0b5a8
Reviewed-on: https://swiftshader-review.googlesource.com/16389
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix texture upload and internalformat handling.
Nicolas Capens [Fri, 23 Feb 2018 01:14:07 +0000 (20:14 -0500)]
Fix texture upload and internalformat handling.

We weren't handling several of the format/type/internalformat combos
from table 3.2 of the OpenGL ES 3.0.5 spec. In particular those where
the format/type of a glTexSubImage2D() call can be used to update
images with an internal format not directly corresponding to it. Some
of these cases were handled using the blitter, but not all GL formats
have a SwiftShader equivalent. Also, the blitter is slower than
specialized C++ pixel transfer code, and the blitter's fallback path is
even slower.

This patch provides specialized pixel rectangle transfer code for each
combination of formats. We also now only store the effective sized
internal format of the images. Validation also happens using the sized
internal format wherever feasible, instead of unsized formats or
SwiftShader formats.

Change-Id: Id55db490002ab8fc2f16f766c43b43f121e5768e
Reviewed-on: https://swiftshader-review.googlesource.com/17429
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd debug macro for returning on assert.
Nicolas Capens [Thu, 22 Feb 2018 21:39:20 +0000 (16:39 -0500)]
Add debug macro for returning on assert.

While in general one should strive to never hit an assert, and thus we
should not worry about what happens in release mode when the condition
is false, there are cases in which it becomes very hard to prove that a
condition will always be true. For instance when another layer is
responsible for validation, but the code experiences a lot of change,
it could inadvertently expose an untested bad edge case which is only
detected much later. For these cases, it is wise to still perform a
less harmful action than just continue.

The ASSERT_OR_RETURN macro will cause a return from the calling
function when the condition is false.

Bug b/73656151

Change-Id: I36953bb5c477ecca67647ae1a7e2fb97e7e4fca6
Reviewed-on: https://swiftshader-review.googlesource.com/17428
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix assert while updating surface buffers.
Nicolas Capens [Thu, 22 Feb 2018 21:13:01 +0000 (16:13 -0500)]
Fix assert while updating surface buffers.

When the external buffer of a surface is dirty, and we're trying to
lock the internal buffer (or vice-versa), an 'update' needs to happen.
This resulted in us locking the internal buffer for writing, thereby
marking it as dirty. This triggered an assert which checks that both
buffers can't be dirty at the same time. Also, in release mode this
could result in redundant updates when the external buffer is locked
again.

We should mark the destination buffer dirty when we're about to make
sure it's up to date, so a new lock type was added which is equivalent
to a write lock but without setting the dirty flag.

Also, we were allocating memory for a 0x0 stencil buffer for each
render target, when there's no stencil component. So return nullptr
when the format is NULL.

Change-Id: Ie7b5528e3eedc3c3efdf8461047e6284b7bdfc84
Reviewed-on: https://swiftshader-review.googlesource.com/16828
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix glCopyTexImage support for BGRA color buffers.
Nicolas Capens [Fri, 23 Feb 2018 02:53:39 +0000 (21:53 -0500)]
Fix glCopyTexImage support for BGRA color buffers.

Neither GL_EXT_texture_format_BGRA8888 nor
GL_APPLE_texture_format_BGRA8888 make mention of GL_BGRA_EXT
or GL_BGRA8_EXT being accepted as the internalformat parameter of
glCopyTexImage2D, but there's a reasonable assumption that textures
with BGRA format can be used as the read color buffer.
GL_EXT_texture_format_BGRA8888 does mention that the format is
color-renderable, and GL_APPLE_texture_format_BGRA8888 adds it to table
3.2 (but fails to mention changes to table 3.16).

Bug swiftshader:96

Change-Id: I6d18faeaded73164a2c6af87ae6109fc77825964
Reviewed-on: https://swiftshader-review.googlesource.com/17448
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix more warnings treated as errors.
Nicolas Capens [Wed, 14 Feb 2018 19:52:49 +0000 (14:52 -0500)]
Fix more warnings treated as errors.

Fixes building SubzeroTest on Mac.

Change-Id: I8ca1f2ea8101bec496b8e9741c38025ff932b3d6
Reviewed-on: https://swiftshader-review.googlesource.com/17189
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix warnings treated as errors.
Nicolas Capens [Thu, 8 Feb 2018 15:26:10 +0000 (10:26 -0500)]
Fix warnings treated as errors.

Change-Id: I0c186ddd43c28a3f2c49321da23d5db44abe9dbf
Reviewed-on: https://swiftshader-review.googlesource.com/17148
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFuzzer fix
Alexis Hetu [Thu, 8 Feb 2018 14:53:46 +0000 (09:53 -0500)]
Fuzzer fix

Added missing resource initialization in order to prevent getting
"uninitialized value" errors when running the fuzzer.

Change-Id: I342441832a159b79cbf036d7ce87f05fcaf15e8c
Reviewed-on: https://swiftshader-review.googlesource.com/17128
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix Chromium build.
Nicolas Capens [Wed, 7 Feb 2018 22:18:00 +0000 (17:18 -0500)]
Fix Chromium build.

Change-Id: If8871d9286ef7c4d09fd075ad5c7b707079158dd
Reviewed-on: https://swiftshader-review.googlesource.com/17108
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUse of uninitialized value fixed
Alexis Hetu [Wed, 7 Feb 2018 19:17:15 +0000 (14:17 -0500)]
Use of uninitialized value fixed

TParseContext::addConstVectorNode() was returning a
TIntermTyped* variable of the wrong type if a swizzle
was of a different size than the vector's size. When
parseVectorFields() fails, fields.num is reset to 1,
which no longer matches fieldString.size(), so
fieldString.size() should not have been used. To
avoid future errors, the proper type is now set
directly within TParseContext::addConstVectorNode().

Bug chromium:796776

Change-Id: Id5e8d1b94d0a03fcf5ef6f5deeb77581bc070288
Reviewed-on: https://swiftshader-review.googlesource.com/17089
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRefactor pixel storage modes.
Nicolas Capens [Wed, 7 Feb 2018 21:29:06 +0000 (16:29 -0500)]
Refactor pixel storage modes.

Change-Id: Ida0a270c1e0ab0900109b7d3bce90dfee9a01960
Reviewed-on: https://swiftshader-review.googlesource.com/17091
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSupport loading of multiple compressed texture slices.
Nicolas Capens [Wed, 7 Feb 2018 19:18:52 +0000 (14:18 -0500)]
Support loading of multiple compressed texture slices.

Change-Id: I53def31f6e63a9cf0884715078bbf236f00f3c51
Reviewed-on: https://swiftshader-review.googlesource.com/17090
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRefactor texture pixel upload offsets.
Nicolas Capens [Wed, 7 Feb 2018 04:14:45 +0000 (23:14 -0500)]
Refactor texture pixel upload offsets.

Apply xoffset, yoffset, and zoffset at image buffer lock so we don't
have to pass them down to the row loading functions as parameters.

Change-Id: I055549c80b1b207df4c49f6f59ecfb8286736040
Reviewed-on: https://swiftshader-review.googlesource.com/17068
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRemove redundant compressed format lookup.
Nicolas Capens [Tue, 6 Feb 2018 21:49:36 +0000 (16:49 -0500)]
Remove redundant compressed format lookup.

glCompressedTexSubImage2D() takes an internalformat parameter which
is already always a sized internal format.

Change-Id: Iaf783e019e08d941053d5f347ee495bdd179f1ce
Reviewed-on: https://swiftshader-review.googlesource.com/17050
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix the source buffer used by CopyTex[Sub]Image.
Nicolas Capens [Tue, 6 Feb 2018 19:44:47 +0000 (14:44 -0500)]
Fix the source buffer used by CopyTex[Sub]Image.

We were passing the framebuffer to the texture's copying method, where
the first render target was used, instead of the read buffer.

Change-Id: I344b4082f675b7e5fc6a73af31a6764ab4d3b6a3
Reviewed-on: https://swiftshader-review.googlesource.com/17049
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFragment output fix
Alexis Hetu [Tue, 6 Feb 2018 15:54:49 +0000 (10:54 -0500)]
Fragment output fix

Allow not specifying a fragment output location.

Change-Id: I76c6e6efdff3161586f5d5422e97731969b9396c
Reviewed-on: https://swiftshader-review.googlesource.com/17028
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRefactor the copy validation matrix.
Nicolas Capens [Mon, 5 Feb 2018 20:04:51 +0000 (15:04 -0500)]
Refactor the copy validation matrix.

We were enumerating the color buffer formats by sized internal format,
which is simplified and made less fragile by retrieving the base
internal format and implementing the spec's validation tables more
directly.

Change-Id: I46d244b9ed738e927b0cb5fe6d1deebf6f0cbae5
Reviewed-on: https://swiftshader-review.googlesource.com/16988
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix using base internal format for CopyTexImage validation.
Nicolas Capens [Mon, 5 Feb 2018 19:18:10 +0000 (14:18 -0500)]
Fix using base internal format for CopyTexImage validation.

Change-Id: Iddd32408b090f00cbae15a76cab064d699f5098b
Reviewed-on: https://swiftshader-review.googlesource.com/16968
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoIn-class initialize all TType members.
Nicolas Capens [Mon, 5 Feb 2018 16:12:10 +0000 (11:12 -0500)]
In-class initialize all TType members.

Also remove default constructors and unused members.

Bug chromium:801648

Change-Id: I822ca1e1569708ca661796ee9252bae68a0a284a
Reviewed-on: https://swiftshader-review.googlesource.com/16948
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSwap format/type in image upload.
Nicolas Capens [Tue, 23 Jan 2018 20:32:46 +0000 (20:32 +0000)]
Swap format/type in image upload.

This refactoring makes the code for texture image upload significantly
smaller. It also aligns better with the layout of table 3.2 in the
OpenGL ES 3.0 specification which lists valid format/type combinations.

Custom RGB565 format handling was removed because it corresponds with a
regular 2-byte per pixel memcpy.

Sized internal formats were removed because a recent change fixed not
using the internalformat parameter as upload format.

Change-Id: Ief6c6e60c3d9a734cac241022bc95ffc88d752c8
Reviewed-on: https://swiftshader-review.googlesource.com/16568
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix pixel size calculation from upload format.
Nicolas Capens [Tue, 23 Jan 2018 22:24:22 +0000 (22:24 +0000)]
Fix pixel size calculation from upload format.

We were using the internal format to compute the size of the pixels
provided for texture image upload. They can differ in size from the
format/type combination.

Change-Id: I7f3cd535cdefefc3c7ec4695d35d181b43ae20a4
Reviewed-on: https://swiftshader-review.googlesource.com/16629
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRefactor CopyTexImage format validation.
Nicolas Capens [Fri, 2 Feb 2018 18:25:53 +0000 (13:25 -0500)]
Refactor CopyTexImage format validation.

Deduplicate common functions and remove unsized color buffer formats.

Change-Id: I76b3b507c27c8bfa932aab64a9338e2a124a25da
Reviewed-on: https://swiftshader-review.googlesource.com/16289
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRefactor compressed texture format validation.
Nicolas Capens [Thu, 1 Feb 2018 22:28:32 +0000 (17:28 -0500)]
Refactor compressed texture format validation.

We were generating GL_INVALID_OPERATION when a non-compressed format
is used where a compressed one is expected or a compressed one is used
where a non-compressed one is expected. Instead we can generate
GL_INVALID_ENUM since these enums are never valid for these calls
(GL_INVALID_OPERATION is for when the enum is valid in some situations
but it's currently used incorrectly).

Change-Id: I9ee92a92cda0574284e709a5a745d5bb8b825a31
Reviewed-on: https://swiftshader-review.googlesource.com/16888
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFragment output location fix
Alexis Hetu [Mon, 5 Feb 2018 15:41:47 +0000 (10:41 -0500)]
Fragment output location fix

The previous fix wasn't handling the case where the same fragment
output variable would go through declareFragmentOutput() multiple
times, so this cl fixes it.

Fixes all dEQP-GLES3.functional.shaders.random failures.
Still fixes original WebGL2 conformance tests failures in:
all/deqp/functional/gles3/fragmentoutput

Change-Id: Ia9c4f5ed5c444ab0c020cac8be511fcaad23c55d
Reviewed-on: https://swiftshader-review.googlesource.com/16928
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUnsigned int GLSL parsing fixed
Alexis Hetu [Wed, 24 Jan 2018 20:58:05 +0000 (15:58 -0500)]
Unsigned int GLSL parsing fixed

Unsigned integers in GLSL were being parsed using the regular
integer parser, so it was limited to INT_MAX. All values from
INT_MAX + 1 to UINT_MAX could not be parsed properly.

Also, added constant folding for the 4 bit conversion glsl
functions.

Fixes shader compilation issue in the Epic Zen Garden example:
https://s3.amazonaws.com/mozilla-games/ZenGarden/EpicZenGarden.html
(unfortunately, the screen is still black, so there are other
 issues left)

Fixes WebGL 2 test: conformance2/glsl3/float-parsing.html

Change-Id: Iae52b2c8e083f0e1a22599e5a583297b9850444d
Reviewed-on: https://swiftshader-review.googlesource.com/16648
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSupport compressed textures unconditionally.
Nicolas Capens [Wed, 31 Jan 2018 20:12:03 +0000 (15:12 -0500)]
Support compressed textures unconditionally.

Change-Id: Ifd2c846c274840f19c1ea8c75fda42bf5640caa4
Reviewed-on: https://swiftshader-review.googlesource.com/16808
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoPrimitive restart fixed
Alexis Hetu [Tue, 23 Jan 2018 19:37:38 +0000 (14:37 -0500)]
Primitive restart fixed

SwiftShader wasn't correctly handling having no restart indices
in the index buffer while having primitive restart enabled. In
the WebGL 2 conformance tests, the reference image is also
computed while primitive restart is on, which means that
Context::drawElements() may modify the internal primitive type,
so indices must be adjusted to reflect that change, even if no
restart indices are present in the index buffer.

Fixes all WebGL 2 tests in:
all/deqp/functional/gles3/primitiverestart

Change-Id: I24f129e0f7bd42b5037b74617b48a32621440ddb
Reviewed-on: https://swiftshader-review.googlesource.com/16548
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdded missing entry from GL_ARB_texture_rectangle
Alexis Hetu [Thu, 1 Feb 2018 17:32:16 +0000 (12:32 -0500)]
Added missing entry from GL_ARB_texture_rectangle

GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB was getting queried by Chromium
since GL_ARB_texture_rectangle is exposed, and if this query fails,
WebGL does not get enabled.

Change-Id: Ie6b40f35f0cfc4547079e303609afa3778010dd1
Reviewed-on: https://swiftshader-review.googlesource.com/16849
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoFixed warnings treated as errors
Alexis Hetu [Thu, 1 Feb 2018 17:17:52 +0000 (12:17 -0500)]
Fixed warnings treated as errors

Change-Id: I19de1f5e4e8a690afed2ac7fb2050659a90fa670
Reviewed-on: https://swiftshader-review.googlesource.com/16848
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoConstruct non matrices from matrix in GLSL
Alexis Hetu [Thu, 18 Jan 2018 20:53:36 +0000 (15:53 -0500)]
Construct non matrices from matrix in GLSL

GLSL supports constructing vectors from matrices. In the case
of vec3(mat2), vec4(mat2) or vec4(mat3), a second instruction
is required to copy the remaining matrix elements from the
2nd row of the matrix into the rest of the vector.

Fixes 6 webgl conformance tests:
conformance/glsl/constructors/glsl-construct-vec3.html
conformance/glsl/constructors/glsl-construct-vec4.html
conformance/glsl/constructors/glsl-construct-ivec3.html
conformance/glsl/constructors/glsl-construct-ivec4.html
conformance/glsl/constructors/glsl-construct-bvec3.html
conformance/glsl/constructors/glsl-construct-bvec4.html

Change-Id: I85ffd3b60623d0dce2bd7c0027748e1829a27dbc
Reviewed-on: https://swiftshader-review.googlesource.com/16469
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoRow major matrix packing fix
Alexis Hetu [Tue, 23 Jan 2018 21:53:41 +0000 (16:53 -0500)]
Row major matrix packing fix

Row major matrix packing wasn't properly detected when the layout
qualifier was on the block member rather than on the block itself
or when a nested structure had a matrix packing qualifier.

Fixes all failing tests in:
deqp/functional/gles3/uniformbuffers*

No regressions in:
dEQP-GLES3.functional.ubo*

Change-Id: I1549a70c4286a8a84b695bc876d71d9cf636b306
Reviewed-on: https://swiftshader-review.googlesource.com/16588
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoTexture Rectangle implementation
Alexis Hetu [Wed, 17 Jan 2018 03:09:28 +0000 (22:09 -0500)]
Texture Rectangle implementation

This adds support for GL_ARB_texture_rectangle, as it is used in Chromium.
This is required in order to use EGL/GLES on MacOS using IOSurface,
in order to be able to run Chromium on top of SwiftShader on MacOS.

Change-Id: I3c0b6a137892583bbfbc68149874d5bec3026b4a
Reviewed-on: https://swiftshader-review.googlesource.com/16368
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSupport for fragment output location
Alexis Hetu [Tue, 30 Jan 2018 21:54:13 +0000 (16:54 -0500)]
Support for fragment output location

Fragment output layout qualifiers may contain location,
which was currently ignored by SwiftShader. Pre-declared
fragment outputs that have a valid location at the correct
location within the fragmentOutputs array to solve this.

Fixes all failures in WebGL 2 tests:
all/deqp/functional/gles3/fragmentoutput/*

Change-Id: I30e004449fb90713984b3481abb24c5d0cd6e867
Reviewed-on: https://swiftshader-review.googlesource.com/16788
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFlex update
Alexis Hetu [Fri, 26 Jan 2018 15:16:21 +0000 (10:16 -0500)]
Flex update

Updated Flex version from 2.6.0 to 2.6.4 and regenerated files.

Change-Id: I7bae30e1f0e1dc16de2bc27f908a1114449d756c
Reviewed-on: https://swiftshader-review.googlesource.com/16768
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRemove unnecessary pointer checks.
Nicolas Capens [Fri, 26 Jan 2018 01:55:31 +0000 (01:55 +0000)]
Remove unnecessary pointer checks.

VertexProgram and PixelProgram always have a shader.

Bug chromium:805881

Change-Id: I0a27b4e7a0bc0ae591d89eb295e215bd421416fb
Reviewed-on: https://swiftshader-review.googlesource.com/16749
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix memory leak on error.
Nicolas Capens [Fri, 26 Jan 2018 01:35:42 +0000 (01:35 +0000)]
Fix memory leak on error.

Bug chromium:805881

Change-Id: I2729fd81dbf2ac40bcfb5a0781cf57daefc4f75a
Reviewed-on: https://swiftshader-review.googlesource.com/16748
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix missing comparison operators.
Nicolas Capens [Fri, 26 Jan 2018 01:24:57 +0000 (01:24 +0000)]
Fix missing comparison operators.

The types can differ for many opcodes where the right-hand side is a
constant, and this assert isn't that useful, so just remove the opcode
checks.

Bug chromium:805881

Change-Id: Ibcbda5123aaeaaf5753732d7cad4b5a3b331e963
Reviewed-on: https://swiftshader-review.googlesource.com/16730
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix checking each cube face for changes.
Nicolas Capens [Fri, 26 Jan 2018 01:19:32 +0000 (01:19 +0000)]
Fix checking each cube face for changes.

Bug chromium:805881

Change-Id: I4b63d6415e87f32cc1402649486b2e4d821db546
Reviewed-on: https://swiftshader-review.googlesource.com/16729
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd missing break in switch.
Nicolas Capens [Fri, 26 Jan 2018 01:14:34 +0000 (01:14 +0000)]
Add missing break in switch.

Also replace some extension enums with core ones.

Bug chromium:805881

Change-Id: I80a9b658fb8dda9c759c4d79b89fbe71b8b91ae1
Reviewed-on: https://swiftshader-review.googlesource.com/16728
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoCherry-pick r322885 from LLVM.
Peter Collingbourne [Thu, 18 Jan 2018 20:51:47 +0000 (12:51 -0800)]
Cherry-pick r322885 from LLVM.

This fixes a build issue when building with libc++ on Windows.

Bug: chromium:801780
Change-Id: I8fa84cefa272c2f3b096b2aada793192a47cc0e3
Reviewed-on: https://swiftshader-review.googlesource.com/16468
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Peter Collingbourne <pcc@google.com>
6 years agoDon't define _HAS_EXCEPTIONS to 0 with libc++.
Peter Collingbourne [Thu, 25 Jan 2018 02:42:02 +0000 (18:42 -0800)]
Don't define _HAS_EXCEPTIONS to 0 with libc++.

libc++ uses a predefined macro to control whether to use exceptions, so
defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also
breaks libc++ because it depends on MSVC headers that only provide
certain declarations if _HAS_EXCEPTIONS is 1.

Bug: chromium:801780
Change-Id: I0d0c04e55e1e91c3ce7fe90d15b55de0cd7a21ac
Reviewed-on: https://swiftshader-review.googlesource.com/16688
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Peter Collingbourne <pcc@google.com>
6 years agoUNIFORM_BUFFER_OFFSET_ALIGNMENT set to 4
Alexis Hetu [Tue, 23 Jan 2018 22:11:05 +0000 (17:11 -0500)]
UNIFORM_BUFFER_OFFSET_ALIGNMENT set to 4

We previously had UNIFORM_BUFFER_OFFSET_ALIGNMENT set to 1. That
value was arbitrary, and WebGL expects that value to be 4, so I
made the change.

Fixes WebGL 2 test:
deqp/functional/gles3/negativebufferapi.html

Change-Id: I7ab654cce629ac2a5dffc9a9d3bff3c1fb1ec8c7
Reviewed-on: https://swiftshader-review.googlesource.com/16608
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoMake it possible to build SwiftShader for Fuchsia.
Sergey Ulanov [Wed, 10 Jan 2018 23:12:42 +0000 (15:12 -0800)]
Make it possible to build SwiftShader for Fuchsia.

With this change SwiftShader is buildable for Fuchsia. Integration with
Mozard for EGL will be implemented in a separate CL.

Bug: chromium:800951
Change-Id: I60160c91aecaa6cdc6b07de688ff54b686613ab3
Reviewed-on: https://swiftshader-review.googlesource.com/16148
Tested-by: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix texture upload format.
Nicolas Capens [Thu, 18 Jan 2018 05:04:26 +0000 (00:04 -0500)]
Fix texture upload format.

We were using the effective sized internal format as the upload format
of glTexImage*() calls. This caused issues when using e.g.
GL_RGBA16F with GL_RGBA / GL_FLOAT.

Change-Id: I2dbd7142447c5330eec1895b1a9652ac20f8414a
Reviewed-on: https://swiftshader-review.googlesource.com/16448
Tested-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoBump the major version number.
Nicolas Capens [Wed, 17 Jan 2018 17:45:40 +0000 (12:45 -0500)]
Bump the major version number.

With OpenGL ES 3.0 now fully supported, this will help discern between
older and newer builds.

Change-Id: I2506d09cf8c9bc59e3c60918ce3d758b0f20586a
Reviewed-on: https://swiftshader-review.googlesource.com/16409
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix Android build.
Nicolas Capens [Wed, 17 Jan 2018 17:29:33 +0000 (12:29 -0500)]
Fix Android build.

Linux builds can assume to use X11, except if it's Android.

Change-Id: I1dc11b5fea73f198ea63d39ca924e95c1d150336
Reviewed-on: https://swiftshader-review.googlesource.com/16408
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agocreateDepthStencilSurface stencil fix
Alexis Hetu [Tue, 16 Jan 2018 20:02:03 +0000 (15:02 -0500)]
createDepthStencilSurface stencil fix

Stencil formats were prohibited from createDepthStencilSurface
in debug builds due to an assert, so fixed the assert.

Change-Id: I5777a081371be4f43810de4450b415c55f04a8d7
Reviewed-on: https://swiftshader-review.googlesource.com/16348
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoMaximum call stack depth increase
Alexis Hetu [Mon, 15 Jan 2018 21:16:27 +0000 (16:16 -0500)]
Maximum call stack depth increase

dEQP requires a stack depth of at least 33 for all tests to
pass. Since the stack depth in swiftshader is arbitrary and
doesn't actually depend on hardware, the maximum stack depth
was increased from 16 to 64.

Also added a bit of log info to make debugging easier.

Fixes 2 dEQP tests:
dEQP-GLES3.performance.compiler.optimization.function_inlining.32_nested_*

Change-Id: I95ae335977d4eb3b21a54296b7fc5e6019595e66
Reviewed-on: https://swiftshader-review.googlesource.com/16328
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix varying validation.
Nicolas Capens [Thu, 11 Jan 2018 19:46:12 +0000 (14:46 -0500)]
Fix varying validation.

glGetFragDataLocation() should only query fragment output varyings.
Also fix checking for too many varyings.

Change-Id: I0981fb69a28762b6d41a22e0544d63c76510000c
Reviewed-on: https://swiftshader-review.googlesource.com/16209
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoeglWaitClient, eglWaitGL and eglWaitNative implementation
Alexis Hetu [Mon, 15 Jan 2018 20:49:42 +0000 (15:49 -0500)]
eglWaitClient, eglWaitGL and eglWaitNative implementation

Chrome tests apparently require these now, so implement
these to avoid Linux (debug) related crashes.

Change-Id: I603e69eeee166affaf6d456039d75b71d33c3914
Reviewed-on: https://swiftshader-review.googlesource.com/16329
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoGLSL mix implementation
Alexis Hetu [Fri, 12 Jan 2018 16:59:35 +0000 (11:59 -0500)]
GLSL mix implementation

Added mix implementation with a bvec as a 3rd argument,
which is basically a select.

Fixes 18 failures in dEQP-GLES3.

Change-Id: Ifaf4a27e1a25fbaad979a7d26ad4a424631acd08
Reviewed-on: https://swiftshader-review.googlesource.com/16288
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRemove GL_APPLE_texture_format_BGRA8888 from gl strings
Alexis Hetu [Fri, 12 Jan 2018 15:32:58 +0000 (10:32 -0500)]
Remove GL_APPLE_texture_format_BGRA8888 from gl strings

Exposing "GL_APPLE_texture_format_BGRA8888" fully enables BGRA8 in
Chromium and it seems like SwiftShader isn't properly supporting it
yet, so removing the string for now in order to do the DEPS roll.

Change-Id: I72f57899b820c22ac76a59b0b7a5e3d2a920e2b3
Reviewed-on: https://swiftshader-review.googlesource.com/16268
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoEnable OpenGL ES 3.0 unconditionally.
Nicolas Capens [Thu, 11 Jan 2018 17:53:57 +0000 (12:53 -0500)]
Enable OpenGL ES 3.0 unconditionally.

We are now passing all of dEQP-GLES3 mustpass tests.

Change-Id: I98a4e57c4cf90a3b193e220e75a97b9657c746e7
Reviewed-on: https://swiftshader-review.googlesource.com/16208
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix validation of statically referenced varyings.
Nicolas Capens [Wed, 10 Jan 2018 17:46:52 +0000 (12:46 -0500)]
Fix validation of statically referenced varyings.

Varyings and in/out variables that are passed between shader pipeline
stages are verified to have matching types at link-time, even when only
statically referenced (this includes trivially optimized out branches)
or even just declared.

GLSL ES 3.00 - 4.3.10 Linking of Vertex Outputs and Fragment Inputs

Change-Id: I122b1cdcc4630c86a8ebfb4d4e37f3a7a335afbe
Reviewed-on: https://swiftshader-review.googlesource.com/16070
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix exp2 for integer input.
Nicolas Capens [Thu, 11 Jan 2018 03:34:19 +0000 (22:34 -0500)]
Fix exp2 for integer input.

exp2(x) should be exact for integer values of x. For example exp(1.0)
should produce 2.0.

Change-Id: I9d6d1d388c23e813e09b7b5788c929ff07189357
Reviewed-on: https://swiftshader-review.googlesource.com/16188
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFixed more BGRA failures
Alexis Hetu [Wed, 10 Jan 2018 22:33:02 +0000 (17:33 -0500)]
Fixed more BGRA failures

BGRA8 was missing from the list of valid internal formats

Change-Id: Id5c08267e04cefaf621edecb963d65a45d40e041
Reviewed-on: https://swiftshader-review.googlesource.com/16128
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoExpose GL_APPLE_texture_format_BGRA8888.
Nicolas Capens [Wed, 10 Jan 2018 15:53:33 +0000 (10:53 -0500)]
Expose GL_APPLE_texture_format_BGRA8888.

GL_APPLE_texture_format_BGRA8888 is similar to
GL_EXT_texture_format_BGRA8888 but explicitly mentions texture storage
support for OpenGL ES 3.0. It adds the format as texture-only (i.e.
non-renderable), but GL_EXT_texture_format_BGRA8888 makes it color-
renderable.

Also allow a sized internalformat of GL_BGRA8_EXT. Previously we were
only allowing unsized internalformat GL_BGRA.

Change-Id: Ieb3a4f85847035392445d0a924591f5531e424d9
Reviewed-on: https://swiftshader-review.googlesource.com/16069
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRestore BGRA support
Alexis Hetu [Wed, 10 Jan 2018 15:27:56 +0000 (10:27 -0500)]
Restore BGRA support

BGRA support was removed in recent refactoring, since no dEQP
must pass test required it, but Chrome still requires it.

Change-Id: I638adce7dfeeaf85bb1f6d9889103fb4fde26d96
Reviewed-on: https://swiftshader-review.googlesource.com/16068
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDetect redefinition of function name as variable.
Nicolas Capens [Wed, 10 Jan 2018 02:39:21 +0000 (21:39 -0500)]
Detect redefinition of function name as variable.

We were previously already detecting when a variable name was redefined
as a function, but not the inverse. The fix involves inserting the
unmangled function name into the symbol table.

Change-Id: I0efd1309d45f004c8d1c5ceb864e08c2ebe22f1d
Reviewed-on: https://swiftshader-review.googlesource.com/16048
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoBuild fix
Alexis Hetu [Tue, 9 Jan 2018 21:44:59 +0000 (16:44 -0500)]
Build fix

Bug swiftshader:94

Change-Id: I4214270b4ee0dad3f13a8e1556ce0c6366bb045b
Reviewed-on: https://swiftshader-review.googlesource.com/16029
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUse exact-at-power-of-two reciprocal for texture projection.
Nicolas Capens [Tue, 9 Jan 2018 21:27:15 +0000 (16:27 -0500)]
Use exact-at-power-of-two reciprocal for texture projection.

Change-Id: I1b3a4bb977ea5d311be6af9b6b8f04235b002dbe
Reviewed-on: https://swiftshader-review.googlesource.com/16028
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix multisample line rasterization.
Nicolas Capens [Tue, 9 Jan 2018 20:34:26 +0000 (15:34 -0500)]
Fix multisample line rasterization.

Multisampled lines should be rasterized as rectangles, even when we
don't support wide lines (i.e. they are one pixel wide).

Change-Id: I4960ea7347f826b3af1ff6830ebde46d3065aea9
Reviewed-on: https://swiftshader-review.googlesource.com/16008
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix depth format assert.
Nicolas Capens [Mon, 8 Jan 2018 22:11:37 +0000 (17:11 -0500)]
Fix depth format assert.

Recently added depth formats were not recognized and caused an assert.

Change-Id: Ide1c783f183770d40673051ccd48b3f8e689f8db
Reviewed-on: https://swiftshader-review.googlesource.com/15969
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFiltering fix for out of bounds blit
Alexis Hetu [Tue, 9 Jan 2018 13:31:02 +0000 (08:31 -0500)]
Filtering fix for out of bounds blit

Removed a conversion to integer which was removing all subpixel
precision from coordinates when using clampToEdge.

Passes all out of bounds cases (this cl should only affect these cases).

Fixes:
dEQP-GLES3.functional.fbo.blit.default_framebuffer.srgb8_alpha8_linear_out_of_bounds_blit_from_default

Change-Id: Id7cef212ea2b739ef22148779dbc1228628e4440
Reviewed-on: https://swiftshader-review.googlesource.com/15988
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix sRGB linear filtering in blitter
Alexis Hetu [Mon, 8 Jan 2018 22:22:15 +0000 (17:22 -0500)]
Fix sRGB linear filtering in blitter

Fixed sRGB filtering by performing the conversion
pre-filtering when appropriate.

Change-Id: Id24898feed7e9a7dadff45431198771af25efed7
Reviewed-on: https://swiftshader-review.googlesource.com/15409
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoStructure field type validation
Alexis Hetu [Fri, 5 Jan 2018 20:48:12 +0000 (15:48 -0500)]
Structure field type validation

Uniforms and varyings structures were simply validating
that both versions in fragment and vertex shaders were
structures, without validating that the fields actually
matched.

All the structures and data required to perform the
validation at link time was added.

Fixes:
dEQP-GLES3.functional.shaders.linkage.uniform.struct.type_conflict_1

Change-Id: Icbf888bbebf4ccf7d27f48cb98d4cd7ea5b42ca3
Reviewed-on: https://swiftshader-review.googlesource.com/15848
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix break statement.
Nicolas Capens [Mon, 8 Jan 2018 17:57:52 +0000 (12:57 -0500)]
Fix break statement.

The break 'depth' was used to indicate the number of if/else execution
enable mask's stack levels we need to discard when jumping from a break
statement to its enclosing switch or loop. However, each switch and
loop resets this depth at the end, which isn't correct for nested loops
and/or switches (note that switches contain if/else statements, and
loops use the same 'enable' masks as if/else).

This can be fixed either by using a stack to keep track of the break
depths of nested switch/loop statements, or by simply not jumping
directly from the break statement to the end of it's enclosing switch
or loop. The latter fix was chosen for this change, which assumes that
that it's uncommon for all vector lanes to become disabled at the break
statement and skip many instructions. An important exception to this is
breaking out of an infinite or long-running loop, but this is handled
by checking the break enable mask as part of the loop condition.

Change-Id: I57d2e03941e855faefd997442931ff8619eca73f
Reviewed-on: https://swiftshader-review.googlesource.com/15968
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix restoring the break execution enable mask.
Nicolas Capens [Mon, 8 Jan 2018 19:09:51 +0000 (14:09 -0500)]
Fix restoring the break execution enable mask.

Switch statements and loops should not reset the execution enable mask
to all lanes at the end, because they can be nested. Instead we can
just restore them to the mask value before the switch/loop.

Change-Id: I4089cbf637c28f39a536de1e68e2e513ead1ec7f
Reviewed-on: https://swiftshader-review.googlesource.com/15908
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix loops with dynamic iteration count.
Nicolas Capens [Sat, 6 Jan 2018 09:28:51 +0000 (04:28 -0500)]
Fix loops with dynamic iteration count.

The 'enable' execution mask for if/else, which is also used by loops,
was not being applied to predicate the instructions within a loop.

Bug b/28710510

Change-Id: Ibd8e962ef60de76ec1c018ca064a791abf214c94
Reviewed-on: https://swiftshader-review.googlesource.com/15948
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix switch statements in loops.
Nicolas Capens [Fri, 5 Jan 2018 20:34:00 +0000 (15:34 -0500)]
Fix switch statements in loops.

Switch statements were resetting the 'enable' execution mask stack to
all lanes, which caused us to execute the switch operations even for
lanes that were already done looping.

Change-Id: Ie5a525e8de8d5e61d4c61bcee81bd81fa862d917
Reviewed-on: https://swiftshader-review.googlesource.com/15828
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUniform block instance name validation
Alexis Hetu [Fri, 5 Jan 2018 21:17:56 +0000 (16:17 -0500)]
Uniform block instance name validation

This cl adds validation that uniform block instance names aren't
reserved names.

Fixes 2 tests:
dEQP-GLES3.functional.shaders.uniform_block.invalid.invalid_identifier_instance_name_*

Change-Id: I4a39c734cdf4d11ea4221c73c1f639fa2f56921d
Reviewed-on: https://swiftshader-review.googlesource.com/15868
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAllow blitting with out of bounds source coordinates
Alexis Hetu [Tue, 19 Dec 2017 20:37:46 +0000 (15:37 -0500)]
Allow blitting with out of bounds source coordinates

Removed early return on source rectangle validation, in order
to allow out of bounds coordinates as an input to the blitter.

Fixes 31 *out_of_bounds* failures in:
dEQP-GLES3.functional.fbo.blit.default_framebuffer

Also fixes 3 scissored blit failures in:
dEQP-GLES3.functional.fragment_ops.scissor

Change-Id: I0751678153aa0fc58bb7aa3a0270c358efb61330
Reviewed-on: https://swiftshader-review.googlesource.com/15388
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoError messages for uniform block validation
Alexis Hetu [Thu, 4 Jan 2018 22:39:15 +0000 (17:39 -0500)]
Error messages for uniform block validation

Many error messages related to uniform block validation were missing,
so there was no output message when linking failed.
Also, the rowMajor validation was missing and was also not set properly
when individual block members were overriding this layout qualifier.

Fixes:
dEQP-GLES3.functional.shaders.linkage.uniform.block.layout_qualifier_mismatch_5

Change-Id: I97309c3ead6e541d6cd9054ecfd29d08206de7da
Reviewed-on: https://swiftshader-review.googlesource.com/15808
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoVarying interpolation qualifier check
Alexis Hetu [Thu, 4 Jan 2018 16:54:55 +0000 (11:54 -0500)]
Varying interpolation qualifier check

Made sure varyings had the same interpolation qualifier in fragment
shader and vertex shader (either both flat or both smooth ).

Fixes:
dEQP-GLES3.functional.shaders.linkage.varying.rules.interpolation_mismatch_1

Change-Id: I7f68490dc19a3365e492b666acda6f5db91d10ab
Reviewed-on: https://swiftshader-review.googlesource.com/15768
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSampler allocation fix
Alexis Hetu [Wed, 3 Jan 2018 21:36:14 +0000 (16:36 -0500)]
Sampler allocation fix

Because samplers can be stored within structures, register
allocation of entire structures within the samplers registers
was pushing sampler indices outside of the allowed limit.
In order to solve this, sampler registers now exclusively
contain samplers, and utility functions to compute sampler
only type size were added to make this possible.

Bug chromium:797264

Change-Id: Ic5a6f09665c39661944444cd736547bce4dff2ab
Reviewed-on: https://swiftshader-review.googlesource.com/15728
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoImplement EGL_KHR_get_all_proc_addresses.
Krzysztof Kosiński [Wed, 3 Jan 2018 22:17:52 +0000 (23:17 +0100)]
Implement EGL_KHR_get_all_proc_addresses.

This also improves GetProcAddress performance by using binary search
instead of linear search.

Fixes bug b/20110899

Change-Id: I6c58e17f0580904338e4d806e310cccbec398f28
Reviewed-on: https://swiftshader-review.googlesource.com/15748
Tested-by: Krzysztof Kosiński <krzysio@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix Chrome build.
Nicolas Capens [Wed, 3 Jan 2018 19:24:15 +0000 (14:24 -0500)]
Fix Chrome build.

Change-Id: I25567211a4603713ad89a1eb58aa3306b11be0ab
Reviewed-on: https://swiftshader-review.googlesource.com/15689
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoDon't generate (S)SSE3 instructions in static code.
Nicolas Capens [Wed, 3 Jan 2018 19:06:30 +0000 (14:06 -0500)]
Don't generate (S)SSE3 instructions in static code.

-march=core2 implies support for both the SSE3 and SSSE3 instruction
set extensions. Chrome should run on CPUs with only SSE2 as well.

Also, make use of SSE on x86-32 for floating-point operations, to be
consistent with x86-64, and don't favor any specific architecture for
tuning.

Bug chromium:797763

Change-Id: Ia17428734460ed855f3aa0f83c6d2f6b3775094c
Reviewed-on: https://swiftshader-review.googlesource.com/15688
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix clamping depth output to [0, 1] range.
Nicolas Capens [Tue, 2 Jan 2018 20:55:11 +0000 (15:55 -0500)]
Fix clamping depth output to [0, 1] range.

OpenGL ES 3.0 specifies that "For fixed-point depth buffers, the final
fragment depth written by a fragment shader is first clamped to [0, 1]
and then converted to fixed-point as if it were a window z value (see
section 2.13.1). For floating-point depth buffers, conversion is not
performed but clamping is."

Change-Id: Ic7f22f7e47106aaa86c4916fbbbe23ad9c52e186
Reviewed-on: https://swiftshader-review.googlesource.com/15628
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDon't perform very early depth test when overridden by shader.
Nicolas Capens [Tue, 2 Jan 2018 20:10:56 +0000 (15:10 -0500)]
Don't perform very early depth test when overridden by shader.

When the pixel shader writes the depth value, we can't use the
interpolated implicit depth to perform a depth buffer test before the
pixel shader executes.

Change-Id: Icf80de50f4aa79f73b43e341c18478e7fd928b8d
Reviewed-on: https://swiftshader-review.googlesource.com/15608
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix initializing LOD for 3D sampling.
Nicolas Capens [Tue, 2 Jan 2018 19:22:23 +0000 (14:22 -0500)]
Fix initializing LOD for 3D sampling.

The LOD value was not being computed for 3D texture sampling when no
mipmapping is done. We still need the LOD in case the minification and
magnification filters differ.

Change-Id: If32d7aaf8a92ace33bcc6ca6f0b60fe33c7e771b
Reviewed-on: https://swiftshader-review.googlesource.com/15588
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoOnly try folding constant array indexing if propagated.
Nicolas Capens [Fri, 22 Dec 2017 22:28:33 +0000 (17:28 -0500)]
Only try folding constant array indexing if propagated.

The array folding logic generated an error when a constant array didn't
have an array of literal constants.

Change-Id: I48f58936cfa7e19e0f4026fb940654f20d9a9d5e
Reviewed-on: https://swiftshader-review.googlesource.com/15551
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAllow length() method on any array expression.
Nicolas Capens [Fri, 22 Dec 2017 22:24:20 +0000 (17:24 -0500)]
Allow length() method on any array expression.

GLSL ES 3.00 spec says that length is only allowed on "array names",
but according to
https://bugs.chromium.org/p/angleproject/issues/detail?id=2142 that
was not intended to be interpreted strictly and it has been clarified
in GLSL ES 3.20.

Change-Id: Id8944346908e1c122230fd2f94c9a26cf389498b
Reviewed-on: https://swiftshader-review.googlesource.com/15550
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoImplement support for arrays of constants.
Nicolas Capens [Fri, 22 Dec 2017 13:54:18 +0000 (08:54 -0500)]
Implement support for arrays of constants.

Arrays of constants can be dynamically indexed, so they can't be
propagated by value and handled as literals like other constants.
Instead we store them in the constant register file.

Change-Id: Idcee033d694b20d047c70e2d13974e5a6dce127b
Reviewed-on: https://swiftshader-review.googlesource.com/15488
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix using linear layout for depth readback.
Nicolas Capens [Fri, 22 Dec 2017 19:57:05 +0000 (14:57 -0500)]
Fix using linear layout for depth readback.

We were using a quad-layout depth format as the destination format for
glReadPixels calls with GL_DEPTH_COMPONENT / GL_FLOAT format. Upload to
a texture was also affected.

Bug b/64542192

Change-Id: I8ad700bf86737debe3268ec6a3dbd237cd85ea1a
Reviewed-on: https://swiftshader-review.googlesource.com/15548
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoRevert "Fixed sampler allocation"
Alexis Hétu [Wed, 3 Jan 2018 13:04:09 +0000 (13:04 +0000)]
Revert "Fixed sampler allocation"

This reverts commit a141a0755a1a463894bbe22990c1d9286e493e0b.

Reason for revert: We need a different solution to fix this issue which doesn't
                   require having a different sampler index and register index.

Change-Id: If08a0fc4713e2bd8277630ca760bb8686a2effd2
Reviewed-on: https://swiftshader-review.googlesource.com/15649
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>