OSDN Git Service

android-x86/external-swiftshader.git
6 years agoUpdate googletest to latest revision.
Nicolas Capens [Fri, 17 Aug 2018 16:57:43 +0000 (12:57 -0400)]
Update googletest to latest revision.

Fixes Visual Studio build issues.

Bug swiftshader:115

Change-Id: Ibd09f4de84a115ed1b264b36985d2d4f31fb3a97
Reviewed-on: https://swiftshader-review.googlesource.com/20269
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix braces warning treated as error.
Nicolas Capens [Tue, 14 Aug 2018 14:46:16 +0000 (14:46 +0000)]
Fix braces warning treated as error.

On some platforms, nested braces are required for nested initializers,
or a warning will be produced which is treated as an error.

Change-Id: I4806ee13869bfe5c5c41505552cd03ff6bdde85e
Reviewed-on: https://swiftshader-review.googlesource.com/20248
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix attribute layout location linking.
Nicolas Capens [Wed, 8 Aug 2018 03:57:21 +0000 (23:57 -0400)]
Fix attribute layout location linking.

When a vertex attribute has a GLSL layout location qualifier, it takes
precedence over the binding location provided through the
glBindAttribLocation API call.

OpenGL ES 3.0.5 spec:
"If an active attribute has a binding explicitly set within the shader
text and a different binding assigned by BindAttribLocation, the
assignment in the shader text is used."

Change-Id: If0bc0dc01a8ff6189703f2be26f1938fbff5f5ae
Reviewed-on: https://swiftshader-review.googlesource.com/20168
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoNon libX11 build fix
Alexis Hetu [Fri, 10 Aug 2018 15:48:33 +0000 (11:48 -0400)]
Non libX11 build fix

Reverted the portion of the following cl which broke the build:
https://swiftshader-review.googlesource.com/c/SwiftShader/+/15909

Change-Id: I4a0e7ef5507dd5502861ccf34c400f1feb54b0cc
Reviewed-on: https://swiftshader-review.googlesource.com/20228
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoSwiftShader on Fuchsia x64
Alexis Hetu [Thu, 9 Aug 2018 21:24:51 +0000 (17:24 -0400)]
SwiftShader on Fuchsia x64

This cl contains the necessary config and build changes
to make SwiftShader work on Fuchsia x64.

Passes all tests in content_unittests.

Bug: chromium:739182

Change-Id: I7df44bd6b12b2560f18e4375f16ada3850f1d8a5
Reviewed-on: https://swiftshader-review.googlesource.com/20208
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoFix platform display retrieval.
Nicolas Capens [Tue, 7 Aug 2018 16:24:10 +0000 (12:24 -0400)]
Fix platform display retrieval.

We were checking if the attrib_list was NULL to verify that no
unsupported attributes are provides, but a single EGL_NONE attribute
should also be allowed.

Also use operator& to avoid confusing implicit conversion to a pointer.

Change-Id: I3c30968fddfd4d1dfbdff9c4ff291abb258e304c
Reviewed-on: https://swiftshader-review.googlesource.com/20148
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoAdd EGL 1.5 entry points.
Nicolas Capens [Mon, 8 Jan 2018 18:07:14 +0000 (13:07 -0500)]
Add EGL 1.5 entry points.

This enables running dEQP on Linux when it was built against an EGL 1.5
capable driver. Note that this is not a complete EGL 1.5 implementation.

Change-Id: Ie29d9ec61e7e3694eb8862aad7432b77fe7c7bae
Reviewed-on: https://swiftshader-review.googlesource.com/15909
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix Direct3D 8 build.
Nicolas Capens [Mon, 6 Aug 2018 14:22:17 +0000 (10:22 -0400)]
Fix Direct3D 8 build.

Bug swiftshader:114

Change-Id: I4e69b85ff3fdf59cc340d3c149964d21bc4b1dd9
Reviewed-on: https://swiftshader-review.googlesource.com/20089
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix gl_FrontFacing to take GL_FRONT_FACE into account.
Nicolas Capens [Tue, 31 Jul 2018 19:33:28 +0000 (15:33 -0400)]
Fix gl_FrontFacing to take GL_FRONT_FACE into account.

Bug swiftshader:113

Change-Id: Ia1cbcdbb396eaabaa79e4c8651d7c025f73d028a
Reviewed-on: https://swiftshader-review.googlesource.com/20068
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoTSAN fix
Alexis Hetu [Mon, 30 Jul 2018 19:09:01 +0000 (15:09 -0400)]
TSAN fix

leadingVertexFirst is used within rendering threads and assigned in
the Renderer's constructor, so TSAN detects this as a data race. In
order to fix this, we can make sure any of these global rendering
settings are only set once (since they never change).

Change-Id: Ib4b43d181b140e500ca31e1ce48340c7f4ce500d
Reviewed-on: https://swiftshader-review.googlesource.com/20008
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix validation of uniform block size.
Nicolas Capens [Mon, 30 Jul 2018 20:42:49 +0000 (16:42 -0400)]
Fix validation of uniform block size.

Uniform block members should not be validated against the
GL_MAX_VERTEX_UNIFORM_VECTORS and GL_MAX_FRAGMENT_UNIFORM_VECTORS
limits. Instead, block sizes should not exceed MAX_UNIFORM_BLOCK_SIZE.

Also move uniform block index validation to the entry functions.

Bug b/111803744

Change-Id: I0ea530813d1f2c29141dc64a93aa10f50460885b
Reviewed-on: https://swiftshader-review.googlesource.com/20028
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd missing header.
Nicolas Capens [Fri, 20 Jul 2018 14:41:02 +0000 (10:41 -0400)]
Add missing header.

malloc/free are being used if SWIFTSHADER_TRANSLATOR_DISABLE_POOL_ALLOC
is defined.

Change-Id: I213c9d614b38fecdc673be5058d5f6f2bc579ca6
Reviewed-on: https://swiftshader-review.googlesource.com/19968
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix leaking uniforms.
Nicolas Capens [Mon, 16 Jul 2018 15:13:49 +0000 (11:13 -0400)]
Fix leaking uniforms.

We were leaking memory for uniforms that were previously defined but
don't have a location, e.g. structures.

This change also verifies that such uniforms have the same type in both
shaders. Also, simplify uniform lookup.

Bug chromium:863682

Change-Id: I468aace4df6f5329dc7bb9f33bf9bf533a743ae1
Reviewed-on: https://swiftshader-review.googlesource.com/19928
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
6 years agoRemove X11 window validation.
Nicolas Capens [Fri, 13 Jul 2018 17:51:20 +0000 (13:51 -0400)]
Remove X11 window validation.

Despite being a 'client resource', the window can become invalid due to
events outside of the client code's control, which causes
XGetWindowAttributes to fail because it retrieves servers-side data
that is no longer available. Hence it is something we should expect to
see happen, and not (always) an indication of a bug that needs fixing.
Also, we should be able to safely continue with an invalid window.

At this point it's up to the client code to catch the X error and
handle it appropriately. The EGL spec does not indicate that it should
catch it instead and generate an error (eglSwapBuffers can generate
EGL_CONTEXT_LOST but that's reserved for power management events).

Bug chromium:861882
Bug chromium:824522

Change-Id: I78a364516b9466f652c94de68553369935590bde
Reviewed-on: https://swiftshader-review.googlesource.com/19868
Reviewed-by: Antoine Labour <piman@chromium.org>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRemove invalid assert.
Nicolas Capens [Mon, 9 Jul 2018 14:15:56 +0000 (10:15 -0400)]
Remove invalid assert.

Subzero x86-64 call instruction operands can be 64-bit now and require
a register.

Bug chromium:860533

Change-Id: I4446be34f57ef73e24718252210bdaa81995c8be
Reviewed-on: https://swiftshader-review.googlesource.com/19848
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
6 years agoSupport MSAN with Subzero JIT compiled code.
Nicolas Capens [Fri, 6 Jul 2018 19:54:07 +0000 (15:54 -0400)]
Support MSAN with Subzero JIT compiled code.

MemorySanitizer doesn't automatically work with dynamically generated
code or inline assembly, since it can't instrument it to know what
memory it touches. We can help it by marking all the memory that is
written to by Reactor with the Subzero back-end as initialized by
calling __msan_unpoison.

Note that writes to memory don't guarantee proper initialization. It
could be copying or writing other uninitialized values.

See also https://sites.google.com/a/chromium.org/dev/developers/testing/memorysanitizer

Bug chromium:860533

Change-Id: Idf64e43c6ab9b8f71f64723fc7e3653f6ea2fb30
Reviewed-on: https://swiftshader-review.googlesource.com/19789
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoSupport 64-bit call targets.
Nicolas Capens [Fri, 6 Jul 2018 03:43:48 +0000 (23:43 -0400)]
Support 64-bit call targets.

The x86-64 call instruction only supports 32-bit IP-relative direct
calls or 64-bit indirect calls. So handle 64-bit direct calls by
storing the value into a register and making an indirect call.

Bug chromium:860533

Change-Id: I3781d1e8a489ce9ab7c17b098ffe830cae62477e
Reviewed-on: https://swiftshader-review.googlesource.com/19828
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoHarden against X11 instability.
Nicolas Capens [Thu, 5 Jul 2018 17:11:03 +0000 (13:11 -0400)]
Harden against X11 instability.

Avoid accessing null pointers when an X11 call fails.

Since EGL doesn't own the X11 window, we expect it to be valid
for the duration of the EGL surface. Fail hard if that's not the case.

Bug chromium:833229
Bug chromium:824522

Change-Id: Iba5e3832fe312fb50232a13e2163a022f5048a76
Reviewed-on: https://swiftshader-review.googlesource.com/19788
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix for MSAN issues
Alexis Hetu [Thu, 5 Jul 2018 18:47:26 +0000 (14:47 -0400)]
Fix for MSAN issues

Chromium's memory sanitizer doesn't work with JIT compiled code, so
we have to skip blitReactor when using MSAN, otherwise most uses of
glReadPixels() will cause MSAN to detect a false use-of-uninitialized-value,
since it doesn't instrument the inside of JIT compiled code.

Bug chromium:848035 chromium:860533

Change-Id: Idfa194ce0fcd41eb7acf7868cbcebfc04d598f5b
Reviewed-on: https://swiftshader-review.googlesource.com/19808
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoReject copying from GL_RGB10_A2 to unsized formats.
Nicolas Capens [Thu, 5 Jul 2018 16:13:56 +0000 (12:13 -0400)]
Reject copying from GL_RGB10_A2 to unsized formats.

glCopyTexImage2D() with an framebuffer format of GL_RGB10_A2 and
internalformat of GL_LUMINANCE_ALPHA was hitting the UNIMPLEMENTED()
assert.

The spec states that:
If an effective internal format exists that has
   * the same component sizes as,
   * component sizes greater than or equal to, or
   * 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 the effective internal format of the
 new texel array.

There is no unorm luminance+alpha format that has all components either
greater or smaller, so this operation is invalid.

Also see https://www.khronos.org/members/login/bugzilla/show_bug.cgi?id=9807#c56

Bug chromium:853424

Change-Id: Ia79a50bf7411a3f2aa87cf7f9bdbcbf971bdd7ce
Reviewed-on: https://swiftshader-review.googlesource.com/19768
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoProtect exported symbols from overrides.
Nicolas Capens [Wed, 4 Jul 2018 13:33:21 +0000 (09:33 -0400)]
Protect exported symbols from overrides.

While all symbols except for the ones in the version script are hidden,
the exported ones can still be overridden by other libraries which
export the same symbols. Using -fvisibility=protected or the equivalent
attribute fixes this.

Protected visibility used to not work because of
https://bugs.llvm.org//show_bug.cgi?id=30960, but that doesn't appear
to be an issue any more.

Bug chromium:852537
Bug swiftshader:64

Change-Id: Id0b1197b90baa5f5c68bf2aa107d12f8a9856796
Reviewed-on: https://swiftshader-review.googlesource.com/19728
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoPrevent LTO from eliminating releaseTexImage() calls.
Nicolas Capens [Tue, 3 Jul 2018 19:45:43 +0000 (15:45 -0400)]
Prevent LTO from eliminating releaseTexImage() calls.

Texture::releaseTexImage() is a virtual method called by libEGL but
defined by libGLESv2, so prevent LTO from treating it as undefined.

This fixes running Chromium swiftshader_unittests with an 'is_official'
build.

Bug chromium:720933

Change-Id: I58c4441f9bd32b96703a28267837cc79b6087659
Reviewed-on: https://swiftshader-review.googlesource.com/19708
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoRemove invalid glGetIntegerv() enums.
Nicolas Capens [Wed, 4 Jul 2018 17:23:08 +0000 (13:23 -0400)]
Remove invalid glGetIntegerv() enums.

GL_UNIFORM_BUFFER_SIZE and GL_UNIFORM_BUFFER_START can't be queried
using glGetIntegerv(). They're only valid for glGetInteger64i_v().

This prevents a potential null dereference.

Bug chromium:859775

Change-Id: Ic66f33a582805b021a2d4bd08ff627f704d42aa7
Reviewed-on: https://swiftshader-review.googlesource.com/19748
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix protecting exported symbols from overrides.
Nicolas Capens [Fri, 29 Jun 2018 17:30:57 +0000 (13:30 -0400)]
Fix protecting exported symbols from overrides.

While all symbols except for the ones in the version script are hidden,
the exported ones can still be overridden by other libraries which
export the same symbols. Using -fvisibility=protected fixes this. We can
only apply it to the shared library targets because of ld linker issues.

Bug b/110884149

Change-Id: I98222420eabbb9ea0873816f52e1354625b9a3a8
Reviewed-on: https://swiftshader-review.googlesource.com/19688
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoUse an internal symbol to determine library directory.
Nicolas Capens [Tue, 3 Jul 2018 20:13:28 +0000 (16:13 -0400)]
Use an internal symbol to determine library directory.

Exported symbols with protected visibility (change made in the next
patch) have a relocation type that is incompatible with passing their
address to dladdr(). Instead we can use a static local variable.

Bug b/110884149

Change-Id: I3e38280276ec00913b28ff97b007490619a99f58
Reviewed-on: https://swiftshader-review.googlesource.com/19710
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix CMake architecture string comparison.
Nicolas Capens [Fri, 29 Jun 2018 17:30:57 +0000 (13:30 -0400)]
Fix CMake architecture string comparison.

EQUAL compares numeric values. Use STREQUAL instead.

Also clarify the macro for setting the export map / version script.

Bug b/110884149

Change-Id: If30c31d17ad35684a8c637b3619bdd0b90be6f2d
Reviewed-on: https://swiftshader-review.googlesource.com/19709
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix using pitch for compressed format decoding.
Nicolas Capens [Thu, 28 Jun 2018 15:28:40 +0000 (11:28 -0400)]
Fix using pitch for compressed format decoding.

For seamless cube maps the pitch (in pixels) differs from the width,
due to the border.

Also renamed identicalFormats() to identicalBuffers() since much more
than the format is compared to determine if the buffers should be
identical.

Bug swiftshader:45

Change-Id: I295557b2cb039615a624c106be3e74588463b102
Reviewed-on: https://swiftshader-review.googlesource.com/19668
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix pedantic narrowing conversion error.
Nicolas Capens [Wed, 27 Jun 2018 21:15:10 +0000 (17:15 -0400)]
Fix pedantic narrowing conversion error.

Clang treats conversion of an unsigned constant to a signed one that
doesn't fit its range as an error. Make Visual Studio also produce an
error.

Change-Id: I2d392d5ba7765b72aa9e9478c5eee02102bdf286
Reviewed-on: https://swiftshader-review.googlesource.com/19648
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoSupport reading of half-float formats.
Nicolas Capens [Wed, 27 Jun 2018 17:15:40 +0000 (13:15 -0400)]
Support reading of half-float formats.

Bug swiftshader:104

Change-Id: I037fcb69131906b52e0c1919f36fea61b2e1c621
Reviewed-on: https://swiftshader-review.googlesource.com/19628
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoSupport glCopyTexImage2D for float formats.
Nicolas Capens [Fri, 22 Jun 2018 17:57:37 +0000 (13:57 -0400)]
Support glCopyTexImage2D for float formats.

Bug chromium:853424

Change-Id: I9b2de054baf6b042bcd04c5d023099a39ca20d2a
Reviewed-on: https://swiftshader-review.googlesource.com/19569
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoAlways create an OpenGL ES 3.0 context.
Nicolas Capens [Wed, 13 Jun 2018 03:55:16 +0000 (23:55 -0400)]
Always create an OpenGL ES 3.0 context.

The EGL spec allows that on context creation, a newer, compatible
version is returned. OpenGL ES 3.0 is stated to be backward compatible
with OpenGL ES 2.0, so we can stop creating a context that is limited to
OpenGL ES 2.0 features, and always return an OpenGL ES 3.0 context.

This simplifies our code and maintenance a bit and reduces the risk of
incorrect validation.

Note that Appendix F of the OpenGL ES 3.0 specification lists changes
in behavior that aren't entirely backward compatible with OpenGL ES 2.0:
* OpenGL ES 3.0 requires that all cube map filtering be seamless. OpenGL
  ES 2.0 specified that a single cube map face be selected and used for
  filtering. See section 3.8.9.1.
* OpenGL ES 3.0 specifies a zero-preserving mapping when converting back
  and forth between signed normalized fixed-point values and floating-
  point values. OpenGL ES 2.0 specified a mapping by which zeros are not
  preserved. See section 2.1.6.
* OpenGL ES 3.0 requires that framebuffer objects not be shared between
  contexts. OpenGL ES 2.0 left it undefined whether framebuffer objects
  could be shared. See appendix D.

Additional differences can stem from new extensions being exposed (e.g.
GL_EXT_color_buffer_float), and framebuffer configurations that are
newly supported or no longer supported (in particular we allowed
separate depth and stencil attachments, which OpenGL ES 3.0 expressly
disallows).

See also https://gitlab.khronos.org/opengl/API/issues/82

Bug swiftshader:45

Change-Id: I90d72698d509b4f03263edcf7c67e44fcef0beb6
Reviewed-on: https://swiftshader-review.googlesource.com/19388
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoMemory leak fix nougat-x86 oreo-x86 android-x86-7.1-r3 android-x86-7.1-r4 android-x86-7.1-r5 android-x86-8.1-r1 android-x86-8.1-r2 android-x86-8.1-r3 android-x86-8.1-r4 android-x86-8.1-r5 android-x86-8.1-r6
Alexis Hetu [Fri, 22 Jun 2018 20:02:55 +0000 (16:02 -0400)]
Memory leak fix

Early returns were erroneous and were causing memory leaks

Change-Id: Ifd6e37d79b6abd3f7d8d8899c951f1a0b4a66fb0
Reviewed-on: https://swiftshader-review.googlesource.com/19588
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoStd:unordered_map removed from Optimizer for improved performance
Alexis Hetu [Wed, 20 Jun 2018 19:35:53 +0000 (15:35 -0400)]
Std:unordered_map removed from Optimizer for improved performance

The use of std::unordered_map was the main source of slowdowns in
the optimizer code, so it was re-written without any maps. In order
to do so, the information originally carried by the maps was moved
to user-defined information stored within Subzero classes. The
optimizer now manages the memory used to store this information.

Bug swiftshader:69
Bug b/67872293

Change-Id: I2757169f0d3d467766317af6e00e149b4317fb9c
Reviewed-on: https://swiftshader-review.googlesource.com/19508
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoNewly load sibling library from the same directory.
Nicolas Capens [Thu, 21 Jun 2018 05:42:30 +0000 (01:42 -0400)]
Newly load sibling library from the same directory.

Previously we were only attempting to obtain a handle to an already
loaded sibling library residing in the same directory. If it wasn't
already pre-loaded, we only loaded the library by name without any
directory prefix. This could lead to not finding the correct library.

Also, it's fine if the directory prefix is empty, so there's no need for
duplicate loops.

Bug b/110407478

Change-Id: Ia55b426e58b9f4039064bba9253dae80e4fdf5cf
Reviewed-on: https://swiftshader-review.googlesource.com/19549
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoSupport Sanitizer builds with CMake.
Nicolas Capens [Thu, 21 Jun 2018 04:42:00 +0000 (00:42 -0400)]
Support Sanitizer builds with CMake.

Added MSAN, ASAN, TSAN, and UBSAN build options. Disabled use of
--no-undefined if a Santizer is used, since by design they leave some
symbols unresolved until run time. UBSAN required blacklisting of our
old copy of LLVM.

Bug swiftshader:108

Change-Id: Iab94b6815bc188c2a7f07d5b7a461234fb1035f3
Reviewed-on: https://swiftshader-review.googlesource.com/19548
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoExpose suffixed versions of VertexAttribDivisor
Adrienne Walker [Wed, 20 Jun 2018 22:43:05 +0000 (15:43 -0700)]
Expose suffixed versions of VertexAttribDivisor

BUG=chromium:854817

Change-Id: Icd81848fbbf3691eca46c9582b3c053ba1b00353
Reviewed-on: https://swiftshader-review.googlesource.com/19528
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Adrienne Walker <enne@chromium.org>
6 years agoAllow Linux build without X11 dependency
Alexis Hetu [Tue, 19 Jun 2018 18:50:41 +0000 (14:50 -0400)]
Allow Linux build without X11 dependency

ChromeOS runs tests on some bots which run on Linux, but do not support X11.
In order to allow SwiftShader to successfully build on these bots, all X11
dependencies are #ifdefed behind the USE_X11 flag, which is already supplied
by the Chromium build system.

Change-Id: I6b914b1e662d9fbf101eb7caea7ac59e43cc7b56
Reviewed-on: https://swiftshader-review.googlesource.com/19488
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDisable mixed enum types warning for Subzero.
Nicolas Capens [Wed, 13 Jun 2018 03:55:16 +0000 (23:55 -0400)]
Disable mixed enum types warning for Subzero.

Bug b/110185979
Bug b/72330874

Change-Id: I593e975dca0798d027c8c5476e384eeca0fd1f7f
Reviewed-on: https://swiftshader-review.googlesource.com/19428
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFixed size verification assert to include border
Alexis Hetu [Mon, 18 Jun 2018 19:19:55 +0000 (15:19 -0400)]
Fixed size verification assert to include border

Whenever a cube map was being used, these asserts would fire as soon
as any border computation would happen. Fixed the asserts to allow
cube maps to work properly.

Change-Id: Iedc2661e63db37e5b4e77e08f97ce044e9f88837
Reviewed-on: https://swiftshader-review.googlesource.com/19468
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoFix clearing of dirty textures.
Nicolas Capens [Fri, 15 Jun 2018 15:41:28 +0000 (11:41 -0400)]
Fix clearing of dirty textures.

When clear operations fall back to the slow path (i.e. neither fastClear
nor blitReactor is used), we were copying a rectangle the size of the
destination image. It should only sample within the 1x1 source pixel
instead.

Bug chromium:852641, chromium:851707

Change-Id: I9f247483f6167f92be8308b8470c021f5641b657
Reviewed-on: https://swiftshader-review.googlesource.com/19448
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRemove manual references to exe_and_shlib_deps
Tom Anderson [Tue, 12 Jun 2018 23:41:46 +0000 (16:41 -0700)]
Remove manual references to exe_and_shlib_deps

After [1], a manual dependency on exe_and_shlib_deps is no longer necessary
since it's automatically added.  This CL removes all remaining manual references
to exe_and_shlib_deps.

[1] https://chromium.googlesource.com/chromium/src.git/+/d7ed1f0a9c28c932fddc834ca5de44f28266c7f5

BUG=chromium:845700
R=capn

Change-Id: I20a88d716ed4cddd55047529f87267b5383366bc
Reviewed-on: https://swiftshader-review.googlesource.com/19348
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Tom Anderson <thomasanderson@google.com>
6 years agoOptimizer optimization
Alexis Hetu [Wed, 13 Jun 2018 20:21:34 +0000 (16:21 -0400)]
Optimizer optimization

Optimizer::optimizeStoresInSingleBasicBlock() was taking an extremely long time due to
looping through all the instructions of a single basic block at every iteration. By
creating a much smaller list of only load/store operations the first time a single basic
block is encountered and reusing that list when the same block is encountered again,
this function now runs ~10X faster.

In my test case:
out/Default/cc_unittests --gtest_filter=ImageBackgroundFilter.BackgroundFilterRotated_GL
The sw::optimize function went from taking almost 16s to roughly 1.5s.

Bug b/67872293

Change-Id: I7e2e2aa8dc1bf2663988fb59b58d72d9ee986e36
Reviewed-on: https://swiftshader-review.googlesource.com/19408
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAllow SwiftShader to compile on Fuchsia
Alexis Hetu [Tue, 12 Jun 2018 18:57:58 +0000 (14:57 -0400)]
Allow SwiftShader to compile on Fuchsia

SwiftShader should be able to build on Fuchsia, but it would
hit a collision error if added as a dependency in Fuchsia,
so the same logic currently used on MacOS could also be used
to avoid the collision on Fuchsia.

Change-Id: I9ac216dfc2180165a82bd5ae81c843ee4aea7ce6
Reviewed-on: https://swiftshader-review.googlesource.com/19328
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix GLSL struct with single matrix.
Nicolas Capens [Wed, 6 Jun 2018 17:47:19 +0000 (13:47 -0400)]
Fix GLSL struct with single matrix.

The parameters of the matrix constructor form an aggregate node that
was passed directly to the constructor of the structure, instead of
creating a one-element aggregate containing the matrix.

https://github.com/mc-imperial/shader-compiler-bugs/issues/74

Bug swiftshader:56

Change-Id: Iff9a2d8dc60d79a0dde28f2aad76407028486ec8
Reviewed-on: https://swiftshader-review.googlesource.com/19308
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix IOSurface synchronization issues
Alexis Hetu [Tue, 5 Jun 2018 21:05:17 +0000 (17:05 -0400)]
Fix IOSurface synchronization issues

It appears that not only render targets, but also samplers that use
IOSurfaces require SwiftShader to perform synchronized draws,
otherwise it seems like using a shared IOSurface's CPU memory is
unsafe and can cause crashes in Layout Tests.

Bug chromium:846693

Change-Id: I0ce24700d34c657ac2447ceb2f6f837bfa3a9a58
Reviewed-on: https://swiftshader-review.googlesource.com/19288
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRun unittests on Travis CI.
Nicolas Capens [Mon, 4 Jun 2018 20:25:59 +0000 (16:25 -0400)]
Run unittests on Travis CI.

Change-Id: If953be0cce3cd11b833d9646e10ede0b31732729
Reviewed-on: https://swiftshader-review.googlesource.com/19248
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoAdd CMake target for unittests.
Nicolas Capens [Mon, 4 Jun 2018 19:55:45 +0000 (15:55 -0400)]
Add CMake target for unittests.

Change-Id: I0984f43de3846428c30232192c7ba83342b1debd
Reviewed-on: https://swiftshader-review.googlesource.com/19228
Reviewed-by: Krzysztof Kosiński <krzysio@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDon't acquire image for copying until needed.
Nicolas Capens [Tue, 5 Jun 2018 14:47:46 +0000 (10:47 -0400)]
Don't acquire image for copying until needed.

Bug chromium:849217

Change-Id: I69d2269c117500d21e5d0860aed0acea212948ba
Reviewed-on: https://swiftshader-review.googlesource.com/19268
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoQuick build fix
Alexis Hetu [Mon, 4 Jun 2018 16:58:42 +0000 (12:58 -0400)]
Quick build fix

Added missing function declaration.

Change-Id: I52ddb666d70733187242906d298fb986f413756a
Reviewed-on: https://swiftshader-review.googlesource.com/19208
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoFixed synchronization issue on MacOS
Alexis Hetu [Mon, 4 Jun 2018 15:38:17 +0000 (11:38 -0400)]
Fixed synchronization issue on MacOS

Because of the way SwiftShader is integrated into Chromium on MacOS,
a synchronization issue exists when Chromium attempts to use an
IOSurface before SwiftShader is done rendering into it. In order to
solve this, all draw calls that end up rendering into an IOSurface
must be synchronized within SwiftShader and can't yield to Chromium
until rendering is complete.

Bug chromium:847094

Change-Id: If2dba4fa998e7437ec414d3b4aff9e8b19ecc128
Reviewed-on: https://swiftshader-review.googlesource.com/19188
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix CLang build.
Nicolas Capens [Sat, 2 Jun 2018 02:02:13 +0000 (22:02 -0400)]
Fix CLang build.

Fixes "error: conditional expression is ambiguous; 'sw::Float' can be
converted to 'RValue<sw::Float>' and vice versa".

Change-Id: I2bd21036803dc54ce212df61a7520b7276b94b2a
Reviewed-on: https://swiftshader-review.googlesource.com/19168
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoPrevent floating-point error accumulation during blitting.
Nicolas Capens [Fri, 1 Jun 2018 14:39:50 +0000 (10:39 -0400)]
Prevent floating-point error accumulation during blitting.

The numeric imprecision can accumulate quickly and cause visible
sampling errors.

Bug chromium:848238

Change-Id: Ie41c10a0462e5b5e5c3ed5f7329ece00dab3f7f9
Reviewed-on: https://swiftshader-review.googlesource.com/19148
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix the unittests Ninja build.
Nicolas Capens [Fri, 1 Jun 2018 01:05:52 +0000 (21:05 -0400)]
Fix the unittests Ninja build.

On Windows, GLAPI defaults to __declspec(dllimport), while GLAPICALL is
empty, leading to declaration mismatches. Either should be empty for
the unit tests since we link statically, for all platforms.

Change-Id: I2dde0ca35108678fd9767895e0120ee4b0d7030f
Reviewed-on: https://swiftshader-review.googlesource.com/19128
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoDefine GLAPI the same way as GL_APICALL.
Nicolas Capens [Thu, 31 May 2018 20:21:02 +0000 (16:21 -0400)]
Define GLAPI the same way as GL_APICALL.

GLAPI is the desktop OpenGL equivalent of OpenGL ES's GL_APICALL macro.
They need to be consistent to prevent CLang from producing errors when
compiling with -Werror,-Winconsistent-dllimport.

Change-Id: Iceb73f42f52628a31aba7ce18fe60221529f890c
Reviewed-on: https://swiftshader-review.googlesource.com/19108
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoDon't use X11 on Mac OS.
Nicolas Capens [Thu, 31 May 2018 17:16:58 +0000 (13:16 -0400)]
Don't use X11 on Mac OS.

https://github.com/KhronosGroup/EGL-Registry/pull/43 made eglplatform.h
include X11 headers on Mac OS, which aren't pre-installed and breaks
the Chrome build.

https://github.com/KhronosGroup/EGL-Registry/issues/52

Change-Id: I73e3c11244a07e269684323ce76cc9700fe9c1aa
Reviewed-on: https://swiftshader-review.googlesource.com/19088
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 and
https://github.com/KhronosGroup/OpenGL-Registry/pull/183 enabled
including desktop OpenGL headers without conflicts, so we no longer
have to define enums for ARB extensions ourselves.

Change-Id: I4f2e2d3b79a6f5cacf53f2a8ace78b6d124cb5d1
Reviewed-on: https://swiftshader-review.googlesource.com/19029
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoUpdate Khronos headers to latest version.
Nicolas Capens [Wed, 30 May 2018 13:46:45 +0000 (09:46 -0400)]
Update Khronos headers to latest version.

Change-Id: If56e711f15236397ac0f8b15f4ca182a7b1e7c49
Reviewed-on: https://swiftshader-review.googlesource.com/19028
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoMove the declaration of DrawCall after Renderer.
Peter Collingbourne [Wed, 30 May 2018 19:53:07 +0000 (12:53 -0700)]
Move the declaration of DrawCall after Renderer.

This allows compilers targeting the MS ABI to select the
correct inheritance model for the member function pointer field
DrawCall::setupPrimitives using the complete type of Renderer. It
will allow us to enable the new Clang flag -fcomplete-member-pointers
globally.

Bug: chromium:847724
Change-Id: Ied5859ec2f5d38b3ccf51608527506caec53f470
Reviewed-on: https://swiftshader-review.googlesource.com/19068
Tested-by: Peter Collingbourne <pcc@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix new[] / delete mismatch.
Nicolas Capens [Wed, 30 May 2018 17:27:12 +0000 (13:27 -0400)]
Fix new[] / delete mismatch.

delete[] should be called on memory allocated with new[].

Change-Id: Ic21e270a7aa0e6e15132cbc3c454ea4f1e0222ea
Reviewed-on: https://swiftshader-review.googlesource.com/19048
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix loop unrolling.
Nicolas Capens [Tue, 29 May 2018 21:11:37 +0000 (17:11 -0400)]
Fix loop unrolling.

Loops were no longer getting unrolled because we analyzed the entire
loop, not just the body, for changes to the index variable. Also, the
logic was inverted. Also, be conservative about loops with return
statements not being unrollable.

Bug chromium:845103

Change-Id: I5957e17f7b985ae90b10053216b6945f3f64338e
Reviewed-on: https://swiftshader-review.googlesource.com/19008
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoAlso copy shader info log on success.
Nicolas Capens [Tue, 29 May 2018 21:11:37 +0000 (17:11 -0400)]
Also copy shader info log on success.

Previously we only copied the GLSL shader compiler's info log on
failure. This hid any warnings or debug info from the application.

Bug chromium:845103

Change-Id: Ia1877a405db2017d327dfc68037596fbda1579fa
Reviewed-on: https://swiftshader-review.googlesource.com/19009
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoImplement dynamic indexing of temporaries.
Nicolas Capens [Mon, 28 May 2018 17:22:07 +0000 (13:22 -0400)]
Implement dynamic indexing of temporaries.

Previously only dynamic indexing of uniforms was supported.

Since this is essentially a gather operation within the register file,
it is slow. We optimize the common case of using the loop index
variable as relative address, where the index value would be the same
for all shader invocations running in lock-step across SIMD lanes.

Bug chromium:845103
Bug skia:7846

Change-Id: Idb36b512dd560d740ac9088691b633ff3a1561c1
Reviewed-on: https://swiftshader-review.googlesource.com/18968
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoImplement gather/scatter operations for shader register files.
Nicolas Capens [Mon, 28 May 2018 17:18:59 +0000 (13:18 -0400)]
Implement gather/scatter operations for shader register files.

This allows to address the registers with a vector of indices.

Also rename 'dynamic' register files to 'indirect addressable', to
disambiguate from 'dynamic indexing' at the shader level. Indexing with
a uniform does not require gather/scatter operations, but does require
indirect addressing.

Bug chromium:845103
Bug skia:7846

Change-Id: I3c42be33def66328688f2900c61c80246bf1e584
Reviewed-on: https://swiftshader-review.googlesource.com/18989
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoDetect loop index modifications in loop body.
Nicolas Capens [Mon, 28 May 2018 16:25:57 +0000 (12:25 -0400)]
Detect loop index modifications in loop body.

Loops can only be unrolled if their loop index variable is not being
modified in the loop body.

Also check that the increment step of the loop operates on the initial
index variable.

Also remove some UNIMPLEMENTED's that were benign.

Bug chromium:845103
Bug chromium:843867
Bug skia:7846

Change-Id: Ib2b39f2d58763f0299ce7f6f75a8a75e6bdc7963
Reviewed-on: https://swiftshader-review.googlesource.com/18988
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd MSVC project for reproducing fuzzer testcases.
Nicolas Capens [Wed, 23 May 2018 03:26:59 +0000 (23:26 -0400)]
Add MSVC project for reproducing fuzzer testcases.

Change-Id: Icdeb96a3044ddf215a59ab832703bb447d85c3ab
Reviewed-on: https://swiftshader-review.googlesource.com/18948
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoUpdate issue tracker information.
Nicolas Capens [Tue, 22 May 2018 18:49:35 +0000 (14:49 -0400)]
Update issue tracker information.

Change-Id: I3cd5b2514149c5bf44dfab483eda415082da7793
Reviewed-on: https://swiftshader-review.googlesource.com/18928
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoAccept GL_TEXTURE_MAX_ANISOTROPY_EXT for samplers.
Krzysztof Kosiński [Fri, 18 May 2018 02:20:47 +0000 (19:20 -0700)]
Accept GL_TEXTURE_MAX_ANISOTROPY_EXT for samplers.

This usage is not explicitly specified in EXT_texture_filter_anisotropic,
but in practice all notable ES 3.0 implementations treat maximum anisotropy
as sampler state. Furthermore, it's already accepted as a valid sampler
parameter by ValidateSamplerObjectParameter in Context.cpp.

This avoids a crash when calling
glSamplerParameteri(sampler, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f);

Bug: b/79951966
Change-Id: I4013f621781fc74a0fbfbf14ab326871fbb87b7c
Reviewed-on: https://swiftshader-review.googlesource.com/18908
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Krzysztof Kosiński <krzysio@google.com>
6 years agoPrevent 32-bit numeric overflow on image allocation.
Nicolas Capens [Tue, 8 May 2018 21:20:50 +0000 (17:20 -0400)]
Prevent 32-bit numeric overflow on image allocation.

We assume the pixels of an image can be addressed with a signed 32-bit
offset, including any padding. For a 3D image it's possible to exceed
this without exceeding the per-dimension limits. Lowering the per-
dimension limit so the allocation is always less than 2 GiB makes them
unreasonably small, so instead we must check the total size.

Use 1 GiB as the soft limit in OpenGL.

Bug chromium:835299

Change-Id: I9c5184002c1710e3923b549f8c21e7f6a516e1c7
Reviewed-on: https://swiftshader-review.googlesource.com/18869
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRefactor surface buffer size calculation.
Nicolas Capens [Tue, 8 May 2018 21:20:50 +0000 (17:20 -0400)]
Refactor surface buffer size calculation.

This eliminates the duplication between pitchB() and size(), and
ensures that the latter is the full allocation size.

Bug chromium:835299

Change-Id: Icf555ad497fb3b92fd00e9a3e6ced6810b2d310d
Reviewed-on: https://swiftshader-review.googlesource.com/18789
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoRefactor maximum texture dimensions.
Nicolas Capens [Tue, 8 May 2018 20:03:16 +0000 (16:03 -0400)]
Refactor maximum texture dimensions.

OpenGL has separate implementation-defined texture size limits, for
3D textures and array textures. For now just give them the same value.

Bug chromium:835299

Change-Id: Ifaf537511f016e21992388f56598d5ec12a393b8
Reviewed-on: https://swiftshader-review.googlesource.com/18788
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoIgnore glGenerateMipmap for unspecified or zero-sized textures.
Nicolas Capens [Tue, 15 May 2018 20:31:10 +0000 (16:31 -0400)]
Ignore glGenerateMipmap for unspecified or zero-sized textures.

https://gitlab.khronos.org/opengl/API/issues/72 was resolved to treat
these cases as a no-op and not generate an error.

Bug chromium:825545

Change-Id: Ic4cfbc728156bb88a6dc70486ae57c3e12ea43ae
Reviewed-on: https://swiftshader-review.googlesource.com/18870
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix glBlitFramebuffer validation for BGRA8 IOSurfaces
Alexis Hetu [Wed, 16 May 2018 17:03:41 +0000 (13:03 -0400)]
Fix glBlitFramebuffer validation for BGRA8 IOSurfaces

The format comparison for blitting from a multisampled buffer
was not ES2 specific, so the ES3 check was removed. That had
been added to fix blitting to the backbuffer on MacOS, which
is now instead fixed by allowing BGRA8 and RGBA8 to be
accepted interchangeably as draw and read formats.

Fixes dEQP-GLES3.functional.negative_api.buffer.blit_framebuffer_multisample

Change-Id: Id577372791007a780c542b0986378147e1e7bc1b
Reviewed-on: https://swiftshader-review.googlesource.com/18888
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoFixed atan corner case
Alexis Hetu [Tue, 15 May 2018 18:07:19 +0000 (14:07 -0400)]
Fixed atan corner case

atan(0, <negative>) was returning 0 instead of PI. Did a simple
fix in the arctan() function and added an associated unit test.

Change-Id: Idbbdaf099b5104e3aaa2868ca8fd806c6c735981
Reviewed-on: https://swiftshader-review.googlesource.com/18868
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoImplement OES_vertex_array_object.
Krzysztof Kosiński [Fri, 11 May 2018 04:55:05 +0000 (21:55 -0700)]
Implement OES_vertex_array_object.

This extension works the same as OpenGL ES 3.0 vertex arrays, but requires
entry points with the OES suffix.

Change-Id: I82b92bbcec078f88becee6f3b37eb7e8256a1233
Reviewed-on: https://swiftshader-review.googlesource.com/18808
Tested-by: Krzysztof Kosiński <krzysio@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRevert part of "Fix Linux build." to fix swiftshader_unittests
Alexis Hetu [Mon, 14 May 2018 12:16:05 +0000 (08:16 -0400)]
Revert part of "Fix Linux build." to fix swiftshader_unittests

The cl "Fix Linux build." broke swiftshader_unittests on Linux and
MacOS. Reverting part of that cl to fix swiftshader_unittests, and
hopefully keep the part of the cl that fixed the build originally.

Change-Id: I3126a12f12ca7337f18c758db16dd3542dcfc226
Reviewed-on: https://swiftshader-review.googlesource.com/18848
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoPitch fix for IO surfaces
Alexis Hetu [Fri, 11 May 2018 19:31:12 +0000 (15:31 -0400)]
Pitch fix for IO surfaces

On MacOS, a Surface constructor receiving the 'pitchPprovided'
parameter wasn't using it for the surface's external pitch,
which was causing an error when using the Image::getPitch()
function, which returns getExternalPitchB(). Image::getPitch()
is used within Image::loadImageData(), which is used by gl
functions like glTexImage2D() and glTexSubImage2D(). Both the
internal and external buffers now use the parameter to solve
this issue.

Bug b/19979104

Change-Id: I9762ed53b535ae9eb052f57ee1ceed8ee87cb29c
Reviewed-on: https://swiftshader-review.googlesource.com/18828
Tested-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRectangle texture addressing fix
Alexis Hetu [Tue, 8 May 2018 18:25:40 +0000 (14:25 -0400)]
Rectangle texture addressing fix

Texture rectangle coordinates were clamped in the [0, dim - 1] range,
but should have been sampled in the [0.5, dim - 0.5 range] according
to the spec (a related comment was added in the code).

Also, by having getAddressingModeW() return ADDRESSING_LAYER for
rectangle textures, the 3rd texture coordinate computation will be
skipped entirely, preventing the temporary variable 'fv' from being
overwritten.

Change-Id: I4bbc30b2a2b747eae2f2a1dfb710a986bff7849b
Reviewed-on: https://swiftshader-review.googlesource.com/18768
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAllocate executable memory backed by named mmaps on Linux.
Ian Rogers [Wed, 14 Feb 2018 23:39:25 +0000 (15:39 -0800)]
Allocate executable memory backed by named mmaps on Linux.

Executable heap memory can confuse profiling tools. Use memfd_create
on Linux, if possible, to create a named anonymous memory region.

Only enabled if LINUX_ENABLE_NAMED_MMAP is defined.

Bug b/73721724

Change-Id: I420711e4f64725ae834ab54264038683e4c445fe
Reviewed-on: https://swiftshader-review.googlesource.com/17208
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoDon't flag temporary registers as used samplers.
Nicolas Capens [Fri, 4 May 2018 19:49:53 +0000 (15:49 -0400)]
Don't flag temporary registers as used samplers.

This fixes a undefined shift if the temporary register has an index
higher than 32 (also, we only have 16 samplers currently). For GLSL
we declare all actual sampler units during ASM output, so we don't
have to rely on analyzing the instructions afterwards (that is only
still relevant for Direct3D 8/9 shaders).

Change-Id: I11a58964d53fcc2c29e0ad923d9a4a4161a545f4
Reviewed-on: https://swiftshader-review.googlesource.com/18748
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoSkip ignored EGL config attributes.
Nicolas Capens [Wed, 18 Apr 2018 18:46:17 +0000 (14:46 -0400)]
Skip ignored EGL config attributes.

The EGL 1.4 spec description of eglChooseConfig states:
"If EGL_MAX_PBUFFER_WIDTH, EGL_MAX_PBUFFER_HEIGHT, EGL_MAX_PBUFFER_-
PIXELS, or EGL_NATIVE_VISUAL_ID are specified in attrib_list, then they
are ignored"

Change-Id: I9ec90eff692f9759aa54a0a10f1e57f2c244db7f
Reviewed-on: https://swiftshader-review.googlesource.com/18608
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoAccept GL_HALF_FLOAT and GL_HALF_FLOAT_OES interchangeably.
Nicolas Capens [Thu, 26 Apr 2018 20:38:05 +0000 (16:38 -0400)]
Accept GL_HALF_FLOAT and GL_HALF_FLOAT_OES interchangeably.

These enums don't have the same value, but this is only because of
desktop OpenGL and OpenGL ES having evolved separately. OpenGL ES 3.0
reconverged to use the enum name and value of desktop OpenGL.

Apps choosing between OpenGL ES 2.0 and 3.0 strictly speaking have to
use different enums, but many drivers already accept either enum so the
apps don't bother to differentiate them. Running them on a driver which
adheres more strictly to the (extension) specs would cause parameter
validation errors.

Additionally, native platform pixel formats such as
HAL_PIXEL_FORMAT_RGBA_FP16 on Android couldn't be mapped to GL_RGBA16F
with GL_HALF_FLOAT component types on an OpenGL ES 2.0 context if the
latter are considered OpenGL ES 3.0 only.

Change-Id: Ib66cba7444fe438c0e4a8a6454460773cf02236d
Reviewed-on: https://swiftshader-review.googlesource.com/18728
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix Linux build.
Nicolas Capens [Wed, 25 Apr 2018 20:26:17 +0000 (16:26 -0400)]
Fix Linux build.

We don't need protected visibility because we now have a version script
which hides all symbols except the ones we want to export.

Fixes ld linker errors:
 relocation R_X86_64_PC32 against protected symbol `libEGL_swiftshader' can not be used when making a shared object
 relocation R_X86_64_PC32 against protected symbol `libGLESv2_swiftshader' can not be used when making a shared object

Change-Id: I059c4b03f2523bf8caf08180b02a349d3cf7b2f2
Reviewed-on: https://swiftshader-review.googlesource.com/18708
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoUse the correct constant name for the Android SDK version
Jorge E. Moreira [Wed, 25 Apr 2018 00:05:10 +0000 (17:05 -0700)]
Use the correct constant name for the Android SDK version

Bug b/78194651

Change-Id: Iafe8728a3593b0bd48b9633261df4035d2e94117
Reviewed-on: https://swiftshader-review.googlesource.com/18668
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUse override for overridden function
Takuto Ikuta [Wed, 25 Apr 2018 13:57:42 +0000 (22:57 +0900)]
Use override for overridden function

Bug: chromium:428099
Change-Id: Ib070a540a3ef245e2828b277dcdabd5b973322f0
Reviewed-on: https://swiftshader-review.googlesource.com/18688
Tested-by: Takuto Ikuta <tikuta@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFixed sampler within struct uniform used as function argument
Alexis Hetu [Tue, 24 Apr 2018 15:13:33 +0000 (11:13 -0400)]
Fixed sampler within struct uniform used as function argument

The sampler was simply not declared in that case, as if the uniform
was unused in the shader, so making sure structures containing
samplers call samplerRegister solves this issue. It was working
properly if the sampler was used anywhere else in the shader, but
failed when the only use in the shader was being passed as an
argument to a function through a containing structure.

Added a unit test since this isn't covered by dEQP.

Fixes 2 WebGL tests:
conformance/glsl/bugs/sampler-array-struct-function-arg.html
conformance/glsl/bugs/sampler-struct-function-arg.html

Change-Id: I81767d7c6415de7aefefecffcc66265d944a94ab
Reviewed-on: https://swiftshader-review.googlesource.com/18628
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoLoad sibling libraries from the same directory
Alexis Hetu [Mon, 16 Apr 2018 19:38:40 +0000 (15:38 -0400)]
Load sibling libraries from the same directory

When libEGL and either libGLESv2 or libGLES_CM are in a different
folder from the executable's folder, libEGL wasn't successfully
finding libGLESv2/libGLES_CM (or vice versa). Since these libraries
are generally in the same folder, using the current library's folder
as a starting location to find another library solves this issue.

Change-Id: Ice9217411de4e269d511549411297b57fc1a4bbb
Reviewed-on: https://swiftshader-review.googlesource.com/18548
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoImplement missing EGL surface queries.
Nicolas Capens [Thu, 12 Apr 2018 16:50:21 +0000 (12:50 -0400)]
Implement missing EGL surface queries.

Fixes dEQP-EGL.functional.query_surface.* tests.

Change-Id: I9d0d2dee83140613af24471d350777959ee37565
Reviewed-on: https://swiftshader-review.googlesource.com/18488
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoRemove unstructured metadata files.
Nicolas Capens [Tue, 17 Apr 2018 18:59:54 +0000 (14:59 -0400)]
Remove unstructured metadata files.

This information is now part of internal structured metadata.

Change-Id: Idb8c1ce256133d9857b96c2a3152e333606f4fbd
Reviewed-on: https://swiftshader-review.googlesource.com/18568
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
6 years agoGuard against clearing null depth/stencil buffers.
Nicolas Capens [Thu, 12 Apr 2018 20:31:32 +0000 (16:31 -0400)]
Guard against clearing null depth/stencil buffers.

Change-Id: Ic0a16ac68582e398a02eef722d52a77a1ebde877
Reviewed-on: https://swiftshader-review.googlesource.com/18508
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoAdded check for temporary register overflow
Alexis Hetu [Mon, 9 Apr 2018 17:47:34 +0000 (13:47 -0400)]
Added check for temporary register overflow

Currently, when overflowing the number of temporary registers
allowed, SwiftShader will crash somewhere in the generated
code. This cl adds an early check to prevent the crash and
instead output an error message to the user.

Bug chromium:814987

Change-Id: Idadda21ee14298662763d986ee1283a5114c1c01
Reviewed-on: https://swiftshader-review.googlesource.com/18388
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoRelease thread local storage on thread exit.
David Rim [Fri, 6 Apr 2018 08:48:41 +0000 (17:48 +0900)]
Release thread local storage on thread exit.

Calls to the EGL API from different threads may exit without releasing
their current TLS storage. This patch adds a destructor to release
them if they have not been released already. Prevents memory leakage in
processes where many threads are created.

Bug b/63434079
Bug swiftshader:80

Test: cts-tradefed run commandAndExit  cts -m CtsMediaTestCases -t \
      android.media.cts.DecodeAccuracyTest
Change-Id: I6e94a6d04ce84b884571248ab89b3b1a4e71998b
Reviewed-on: https://swiftshader-review.googlesource.com/18328
Tested-by: David Rim <davidrim@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoChromium build fix
Alexis Hetu [Tue, 10 Apr 2018 14:46:47 +0000 (10:46 -0400)]
Chromium build fix

Adding a getPlane() function in order to not have the "plane" private
member unused, which causes a warning and makes compilation fail.

Change-Id: I3ec08d3439c7e8f3d4314f3b4864d12e9c34d6f4
Reviewed-on: https://swiftshader-review.googlesource.com/18468
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix CMake build
Alexis Hetu [Tue, 10 Apr 2018 14:48:42 +0000 (10:48 -0400)]
Fix CMake build

Added the missing libraries (CoreFoundation
and IOSurface) to the CMakeLists.txt file.

Change-Id: I6db6b3d2396f557296bbf670d152cc421b6727dd
Reviewed-on: https://swiftshader-review.googlesource.com/18469
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix build failure due to missing forward declaration.
Nicolas Capens [Mon, 9 Apr 2018 21:38:12 +0000 (17:38 -0400)]
Fix build failure due to missing forward declaration.

Strict compilation requires symbols used in template functions to have
been declared, which will be enforced in future compilers.

Bug swiftshader:103

Change-Id: Ibfc05011b1a2938e958dfacf6792477362699dc6
Reviewed-on: https://swiftshader-review.googlesource.com/18448
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd -Wno-sentinel that is needed on Android K
Greg Hartman [Sat, 17 Mar 2018 05:46:21 +0000 (22:46 -0700)]
Add -Wno-sentinel that is needed on Android K

Bug b/75229322
Test: Local build of K
Fixes build break ab/4660759
Change-Id: Ib2cb43594b331c4415650517df65e8ccd497f820
Reviewed-on: https://swiftshader-review.googlesource.com/18190
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix makefiles for Andoid K
Greg Hartman [Fri, 16 Mar 2018 18:50:19 +0000 (11:50 -0700)]
Fix makefiles for Andoid K

It's not safe to rely on LOCAL_MODULE_RELATIVE_PATH on all branches

Cleaned up some unnecessary ifdef's

Bug b/75229322
Test: Local build of K
Fixes build break ab/4660124
Change-Id: I48d3400a2109cd5a2cf593e03f9e234f490c8252
Reviewed-on: https://swiftshader-review.googlesource.com/18189
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdd work-arounds for missing C++11 features.
Nicolas Capens [Mon, 9 Apr 2018 19:12:15 +0000 (15:12 -0400)]
Add work-arounds for missing C++11 features.

Android versions before M did not have:

std::shared_ptr
std::unique_ptr
std::to_string

This is fixed by extending stlport with custom implementations for
these features. This works by using 'string' and 'memory' header
files in a path searched before stlport itself, in which the new
features are implemented, and including stport's original headers for
all other functionality.

Bug b/75229322

Change-Id: Icd05c072c366381155e086c3f14f805bc4f104d6
Reviewed-on: https://swiftshader-review.googlesource.com/18408
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoCorrect confusion between Android O and O MR1
Greg Hartman [Fri, 16 Mar 2018 07:02:23 +0000 (00:02 -0700)]
Correct confusion between Android O and O MR1

libnativebase and liblog_headers didn't exist until O MR1

Bug b/75229322
Test: Local builds K through P DP1
Change-Id: I07361e4ef8a98108536319428741554b937eda1a
Reviewed-on: https://swiftshader-review.googlesource.com/17768
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoeglCreatePbufferFromClientBuffer implementation
Alexis Hetu [Tue, 13 Feb 2018 20:02:40 +0000 (15:02 -0500)]
eglCreatePbufferFromClientBuffer implementation

Added support for eglCreatePbufferFromClientBuffer(), using an
IOSurface on MacOS, or just a straight buffer pointer on other
platforms.

Added new unit tests (IOSurfaceClientBufferTest class), which
pass on both Windows and MacOS.

Change-Id: I79a6b420d85fb1f3ae505e0c0067bad2e27510d4
Reviewed-on: https://swiftshader-review.googlesource.com/17168
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoInitialize array size on error.
Nicolas Capens [Mon, 9 Apr 2018 15:53:41 +0000 (11:53 -0400)]
Initialize array size on error.

The array size is set using the value returned by arraySizeErrorCheck,
even when an error occurred, so don't leave it uninitialized.

Bug chromium:801648

Change-Id: If2af27c5f61dca2931796f1681dce61ab6a44341
Reviewed-on: https://swiftshader-review.googlesource.com/18368
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>