OSDN Git Service

android-x86/external-swiftshader.git
6 years agoExpose surfaceless context extension strings
Alexis Hetu [Thu, 22 Mar 2018 12:29:31 +0000 (08:29 -0400)]
Expose surfaceless context extension strings

It seems like SwiftShader already supports surfaceless contexts properly in
eglMakeCurrent, so we might as well expose the extension strings.

Change-Id: I3c1b85296c46536df9a8bd754856d825307181d0
Reviewed-on: https://swiftshader-review.googlesource.com/17948
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRevert "Use official headers to define GL_ARB_texture_rectangle."
Nicolas Capens [Tue, 27 Mar 2018 13:39:37 +0000 (09:39 -0400)]
Revert "Use official headers to define GL_ARB_texture_rectangle."

This reverts commit 9869bedb56822d19c9bfbdb33f6af061da8e6106.

It broke 32-bit builds on Windows because GLsizeiptr and GLintptr are
defined as different types (int vs. long) in gl2.h and glcorearb.h.
See also https://github.com/KhronosGroup/OpenGL-Registry/issues/162

Change-Id: Ia7bd4accb1671529ce6da6849a1df76dceddcdee
Reviewed-on: https://swiftshader-review.googlesource.com/18068
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix missing sized internal formats.
Nicolas Capens [Mon, 26 Mar 2018 14:13:21 +0000 (10:13 -0400)]
Fix missing sized internal formats.

Change-Id: Ifeee2d5c637586e6b843080aaceb446bd0b5af11
Reviewed-on: https://swiftshader-review.googlesource.com/18048
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoSupport more glCopyTexImage unsized formats.
Nicolas Capens [Thu, 22 Mar 2018 17:22:20 +0000 (13:22 -0400)]
Support more glCopyTexImage unsized formats.

Convert packed types to the next greater non-packed component type.
Specifically, when the red component has fewer than 8 bits, use the
corresponding sized internal format with 8-bit components.

Note that this is still not fully compliant.
The OpenGL ES 3.0 spec section 3.8.5 states that:

If internalformat is unsized, the internal format of the new texel array is determined
by the following rules, applied in order. If an effective internal format exists
that has
1. the same component sizes as,
2. component sizes greater than or equal to, or
3. component sizes smaller than or equal to
those of the source buffer’s effective internal format (for all matching components
in internalformat), that format is chosen for the new image array, and this is also
the new texel array’s effective internal format.

This means that in theory when copying an RGBA4 framebuffer into an RGB
texture, the effective internal format should be RGB565, not RGB8.
However, dEQP does not enforce this, and ANGLE always assumes
UNSIGNED_BYTE components.

Change-Id: Id243b963779108e205c275499ddfb6e041a873d6
Reviewed-on: https://swiftshader-review.googlesource.com/17969
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoDon't upload array texture images six times.
Nicolas Capens [Thu, 22 Mar 2018 04:55:23 +0000 (00:55 -0400)]
Don't upload array texture images six times.

Change-Id: I5be0cc629477b6cfb3ede6b4484f067d1c30b0ec
Reviewed-on: https://swiftshader-review.googlesource.com/17929
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoValidate pixel unpack buffer offset.
Nicolas Capens [Thu, 22 Mar 2018 04:44:07 +0000 (00:44 -0400)]
Validate pixel unpack buffer offset.

When a pixel unpack buffer is bound, glTexImage calls interpret the
<pixels> parameter as an offset into the pixel buffer. We weren't
validating that the accessed data falls within the buffer, when taking
the offset into account.

Bug chromium:822976

Change-Id: I3ab23e3b135fd4ad1e55555eec95d584684f5d82
Reviewed-on: https://swiftshader-review.googlesource.com/17928
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoUse official headers to define GL_ARB_texture_rectangle.
Nicolas Capens [Wed, 21 Mar 2018 18:25:19 +0000 (14:25 -0400)]
Use official headers to define GL_ARB_texture_rectangle.

Fixing https://github.com/KhronosGroup/OpenGL-Registry/pull/149 enabled
including desktop OpenGL headers without conflicts, so we no longer
have to define enums for ARB extensions ourselves.

Change-Id: Ifa05112f1e1d21bb8a22b83519babbbb3e4d6462
Reviewed-on: https://swiftshader-review.googlesource.com/17909
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoUpdate OpenGL headers.
Nicolas Capens [Wed, 21 Mar 2018 17:55:23 +0000 (13:55 -0400)]
Update OpenGL headers.

Using revision
https://github.com/KhronosGroup/OpenGL-Registry/commit/6565c242fbdad6258a73f506b0baa61f62edd67c

Change-Id: I0e48ff5d700a2f21c9b52f992e90ca37b9800630
Reviewed-on: https://swiftshader-review.googlesource.com/17908
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoAllow Blitter::fastClear to directly write to external buffer
Alexis Hetu [Mon, 26 Mar 2018 01:02:17 +0000 (21:02 -0400)]
Allow Blitter::fastClear to directly write to external buffer

When the external buffer is the one that is dirty, avoid a useless
copy from external to internal before fast clearing the buffer by
clearing the external buffer directly.

Change-Id: I469243ba8a2b8617f9a0f8b6e2a089f667b8ae63
Reviewed-on: https://swiftshader-review.googlesource.com/18033
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoMultisampled blitter clear fix
Alexis Hetu [Mon, 26 Mar 2018 00:32:22 +0000 (20:32 -0400)]
Multisampled blitter clear fix

When clearing a multisampled buffer, the reactor blitter was only
clearing the first sample. This cl makes the reactor blitter
effectively clear all samples of a multisampled buffer.

Change-Id: I7ce1af401bf537fe85e1c8393a2c57144641ad8e
Reviewed-on: https://swiftshader-review.googlesource.com/18032
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix multisampled line rendering.
Nicolas Capens [Sat, 17 Mar 2018 03:23:06 +0000 (23:23 -0400)]
Fix multisampled line rendering.

Bug swiftshader:99
Bug chromium:820461

Change-Id: I2232c27d57aedff03293b37607f97ead56c056c9
Reviewed-on: https://swiftshader-review.googlesource.com/17808
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoMoving Chromium's version of the libraries first
Alexis Hetu [Tue, 20 Mar 2018 18:06:12 +0000 (14:06 -0400)]
Moving Chromium's version of the libraries first

On MacOS, libraries have a couple of minor issues and, as a safety,
let's make sure no other library than the required library is loaded.

Change-Id: I376b77b3cf3f635ff57c12ccde2b9e84d4105adc
Reviewed-on: https://swiftshader-review.googlesource.com/17888
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix output directory creation.
Nicolas Capens [Tue, 20 Mar 2018 15:16:09 +0000 (11:16 -0400)]
Fix output directory creation.

Change-Id: Ib6e656a7913cf245c73c096376241f6e1f567b6b
Reviewed-on: https://swiftshader-review.googlesource.com/17869
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSplit output binaries by platform.
Nicolas Capens [Tue, 20 Mar 2018 14:46:14 +0000 (10:46 -0400)]
Split output binaries by platform.

Change-Id: I7388b3f5d17e35e55726797ba40631fd8590fb24
Reviewed-on: https://swiftshader-review.googlesource.com/17868
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix Travis CI deploy directory.
Nicolas Capens [Tue, 20 Mar 2018 13:28:12 +0000 (09:28 -0400)]
Fix Travis CI deploy directory.

Change-Id: I501b72e5d33b26075488c0af999713c192c4ac0b
Reviewed-on: https://swiftshader-review.googlesource.com/17848
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd support for RGBA16F external images.
Nicolas Capens [Tue, 20 Mar 2018 03:38:49 +0000 (23:38 -0400)]
Add support for RGBA16F external images.

Bug b/75778024

Change-Id: Idf17c094ef858b3712839ffe335dc943cd0bd084
Reviewed-on: https://swiftshader-review.googlesource.com/17828
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoUpload binaries to Google Cloud Storage.
Nicolas Capens [Fri, 16 Mar 2018 19:19:19 +0000 (15:19 -0400)]
Upload binaries to Google Cloud Storage.

Change-Id: I92c4c203433c8dc92887c5470631926c3cac1d27
Reviewed-on: https://swiftshader-review.googlesource.com/17788
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix glTexSubImage support of half-float extension formats.
Nicolas Capens [Wed, 14 Mar 2018 21:15:39 +0000 (17:15 -0400)]
Fix glTexSubImage support of half-float extension formats.

GL_HALF_FLOAT_OES and GL_HALF_FLOAT have different enum values, and we
weren't handling the case where a half-float texture was already
created (e.g. with an effective internal format of GL_RGBA16F) and then
updated with a glTexSubImage call using GL_HALF_FLOAT_OES type. In
other words, we assumed the OpenGL ES 3.0 sized internal format could
only be used with the OpenGL ES 3.0 half-float type, but this hasn't
been true since we started storing only the effective internal format
for all versions.

Note that GL_OES_texture_half_float, which defines GL_HALF_FLOAT_OES,
does not clarify whether HALF_FLOAT images can be updated using FLOAT,
or vice-versa. We're assuming the equivalent combinations of OpenGL ES
3.0 table 3.3 are valid. That is, FLOAT can be used to update,
HALF_FLOAT, but not the other way around.

Bug b/74609191

Change-Id: Ib8548cd37065820eb59a0943fd39647edc5e9f1b
Reviewed-on: https://swiftshader-review.googlesource.com/17748
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoGL_CHROMIUM_color_buffer_float_rgba extension support
Alexis Hetu [Thu, 18 Jan 2018 21:17:54 +0000 (16:17 -0500)]
GL_CHROMIUM_color_buffer_float_rgba extension support

GL_CHROMIUM_color_buffer_float_rgba (OpenGL ES 2.0) is a subset of
GL_EXT_color_buffer_float (OpenGL ES 3.0), which SwiftShader already
supports.

Fixes 1 webgl conformance tests:
conformance/extensions/oes-texture-float.html

Change-Id: Ic1451187db219af74ba41fa7634bd5bcb6fb0b44
Reviewed-on: https://swiftshader-review.googlesource.com/16470
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoCheck X11 return status.
Nicolas Capens [Tue, 13 Mar 2018 14:54:18 +0000 (10:54 -0400)]
Check X11 return status.

We weren't checking the return status of an XGetWindowAttributes() call
while checking for a resized window. It appears that it can start to
fail possibly due to an out-of-memory situation or the window being
destroyed before the EGL surface.

Note that the EGL spec does not have a recommendation on how to handle
this situation. Generating EGL_BAD_ALLOC is intended for eglCreate*
call failures, while EGL_BAD_NATIVE_WINDOW appears to be reserved for
calls that take a native window as a parameter. eglSwapBuffers is
neither.

Bug chromium:819481

Change-Id: I270730567b5179ee43b814e8bd017b601dfbe079
Reviewed-on: https://swiftshader-review.googlesource.com/17708
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoBuild fix: Unit test code cleanup
Alexis Hetu [Thu, 8 Mar 2018 16:33:17 +0000 (11:33 -0500)]
Build fix: Unit test code cleanup

- Added EXPECT_GLENUM_EQ to solve signed/unsigned comparisons
- Added createProgram and drawQuad utility functions to reduce
  code duplication

Change-Id: I8a62110346de501a1a77ec9688cf06b321385661
Reviewed-on: https://swiftshader-review.googlesource.com/17668
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoAdded support for sampler2DRect in ESSL3
Alexis Hetu [Fri, 2 Mar 2018 20:10:16 +0000 (15:10 -0500)]
Added support for sampler2DRect in ESSL3

Being able to sample from sampler2DRect using the "texture" function is required for Chromium on Mac.

Change-Id: Iea8970aaec29734a251bcfc19a03223d0ebfbc7e
Reviewed-on: https://swiftshader-review.googlesource.com/17572
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoFix Subzero build on Android.
Nicolas Capens [Wed, 7 Mar 2018 20:19:58 +0000 (15:19 -0500)]
Fix Subzero build on Android.

Change-Id: If560b8b41b869458ff4b3a6a314f389c8e7a22f9
Reviewed-on: https://swiftshader-review.googlesource.com/17648
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUse -Werror in Android builds.
Chih-Hung Hsieh [Wed, 11 Oct 2017 21:23:57 +0000 (14:23 -0700)]
Use -Werror in Android builds.

Suppress existing warnings.

Bug b/66996870

Change-Id: I9b78f840638a57c2559ccc4dbc583cc6a6e21c14
Reviewed-on: https://swiftshader-review.googlesource.com/17630
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoBuild SwiftShader with BOARD_VNDK_VERSION=current
Jiyong Park [Fri, 8 Sep 2017 01:47:30 +0000 (10:47 +0900)]
Build SwiftShader with BOARD_VNDK_VERSION=current

This is using cutils/log.h which is deprecated in O (in favor of
log/log.h) and this is causing build error when building with
BOARD_VNDK_VERSION=current set. However, since SwiftShader should be
able to be built with older versions Android some of which don't have
log/log.h, we can't simply change cutils/log.h to log/log.h.

Instead, liblog_headers is added to the header lib dependency (only for
O and beyond) so that log/log.h can be correctly included via
cutils/log.h

Bug b/63135587

Change-Id: I763250e7410025b1dcd7ae210693e3d6bffdb6f1
Reviewed-on: https://swiftshader-review.googlesource.com/17629
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoPrevent crashing when no current program is set.
Nicolas Capens [Tue, 6 Mar 2018 14:55:35 +0000 (09:55 -0500)]
Prevent crashing when no current program is set.

This fixes a regression caused by
https://swiftshader-review.googlesource.com/14489

Context::applyVertexBuffer() expects a valid program, so we need to
check for it sooner. Not having a current program is not an error and
makes the draw call a no-op, but
dEQP-GLES3.functional.negative_api.vertex_array.* still expects
validation to happen before leaving the function. In particular,
the framebuffer completeness check has to be performed. Note that
ConvertPrimitiveType() should never return an error because we already
check the primitive type in the entry function, sampler validation
can only be done when we have a valid program, and likewise
applyVertexBuffer() requires a program, so these validations can still
happen after the early-out.

Change-Id: I7036ca59d37ea0385f79bf87afd1eeeb9728f7af
Reviewed-on: https://swiftshader-review.googlesource.com/17228
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
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>