OSDN Git Service

android-x86/external-swiftshader.git
6 years agoFix RValue<T> construction from incorrect types.
Nicolas Capens [Mon, 24 Jul 2017 20:54:44 +0000 (16:54 -0400)]
Fix RValue<T> construction from incorrect types.

When constructing an RValue<T> from a Value, the types should match.
Else a bitcast is required.

Bug swiftshader:48

Change-Id: I5073091524d2f56681dab052c9f84a06b3be7b4f
Reviewed-on: https://swiftshader-review.googlesource.com/10908
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 license badge.
Nicolas Capens [Wed, 26 Jul 2017 17:55:52 +0000 (13:55 -0400)]
Add license badge.

Change-Id: I0d25174bc92b6228f433f5d6840d3d94223c683e
Reviewed-on: https://swiftshader-review.googlesource.com/11008
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoglGetString fix
Alexis Hetu [Tue, 25 Jul 2017 20:04:45 +0000 (16:04 -0400)]
glGetString fix

glGetString wasn't returning es3 specific extensions.

Change-Id: Ief89eb448b3e821bfb7919ece97c03976569060c
Reviewed-on: https://swiftshader-review.googlesource.com/10954
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoSuppress UBSan false positives.
Nicolas Capens [Mon, 24 Jul 2017 15:30:55 +0000 (11:30 -0400)]
Suppress UBSan false positives.

Function pointers from exported functions are wrongly flagged as being
of incorrect type. This happens both on libEGL and libGLESv2 entry
functions, as well as functions called between them.

Bug chromium:746914

Change-Id: I2bf5a8f06546c233ede7a4820c0cda3e997f096e
Reviewed-on: https://swiftshader-review.googlesource.com/10868
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdded UInt to FP cast
Alexis Hetu [Mon, 24 Jul 2017 18:44:33 +0000 (14:44 -0400)]
Added UInt to FP cast

UInt4 -> Float4 already existed, but not UInt -> Float.

Added the scalar conversion code and used it in the
Blitter where appropriate.

Change-Id: I9ebf63fdf8b139b960237b269f2da088f6ecac86
Reviewed-on: https://swiftshader-review.googlesource.com/10888
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix clearing all samples of multisample render targets.
Nicolas Capens [Thu, 20 Jul 2017 18:14:09 +0000 (14:14 -0400)]
Fix clearing all samples of multisample render targets.

Only libGLESv2 was clearing all the samples of a multisample buffer.
Since all known APIs always clear all the samples, this could be
handled in the Renderer.

Bug swiftshader:77

Change-Id: Ib9adc3c61d263420ed0a0ae4828a693bd360b076
Reviewed-on: https://swiftshader-review.googlesource.com/10788
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFixed default color values for R and RG types
Alexis Hetu [Fri, 21 Jul 2017 15:41:13 +0000 (11:41 -0400)]
Fixed default color values for R and RG types

By default, in D3D, R, G or B channels default to 1 when no
value is assigned to them. In OpenGL, these channels default
to 0. Added an entry to Conventions to fix this issue.

In dEQP, this fixes all R and RG types tests from:
functional.texture.format.*

Change-Id: Ib5552aa36eaf4e3e1132f016f002250b40436227
Reviewed-on: https://swiftshader-review.googlesource.com/10828
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFP32 linear filtering computation now available to most formats
Alexis Hetu [Thu, 20 Jul 2017 20:56:30 +0000 (16:56 -0400)]
FP32 linear filtering computation now available to most formats

All texture formats, except YUV or sRGB formats, now have access
to the floating point path for texture filtering. High precision
filtering can be enabled using:
glHint(GL_TEXTURE_FILTERING_HINT_CHROMIUM, GL_NICEST)

Bug swiftshader:76

Change-Id: Iabbe86d1bbf43070bfc5f61254c101a75c744401
Reviewed-on: https://swiftshader-review.googlesource.com/10808
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUnnormalized integer formats now all use the same path
Alexis Hetu [Tue, 18 Jul 2017 17:03:42 +0000 (13:03 -0400)]
Unnormalized integer formats now all use the same path

Integer formats are: UInt32/Int32/UInt16/Int16/UInt8/Int8
The 32 bit formats required using the floating point path for precision,
while the 16 bit and 8 bit formats were going through the short integer
path. Since all formats need to be treated as Int within a 32 bit Float
in the end, this cl unifies all integer formats under the same path.

Related dEQP tests are: functional.texture.format.sized.2d.*

Bug swiftshader:76

Change-Id: Ia2e0972243290e8b1139081222a3f19ab9e65c9f
Reviewed-on: https://swiftshader-review.googlesource.com/10748
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoFix file descriptor leak.
Nicolas Capens [Thu, 20 Jul 2017 13:53:31 +0000 (09:53 -0400)]
Fix file descriptor leak.

Change-Id: Ie02591ba84ba8a4b204a2cb05179718e397e5c21
Reviewed-on: https://swiftshader-review.googlesource.com/10768
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoCompute texture coordinates using floating point operations
Alexis Hetu [Fri, 14 Jul 2017 18:17:14 +0000 (14:17 -0400)]
Compute texture coordinates using floating point operations

Modified the texture coordinate computation to use floating
point operations when sampling floating point textures to
increase accuracy and remove useless type conversions.

Bug swiftshader:76

Change-Id: I76e5fd9a68aa6ba5eb21524edb8c6c6183e5430e
Reviewed-on: https://swiftshader-review.googlesource.com/10628
Tested-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoImprove mipmap LOD calculation precision.
Nicolas Capens [Fri, 7 Jul 2017 16:46:21 +0000 (12:46 -0400)]
Improve mipmap LOD calculation precision.

Our approximation for log2() linearly interpolates between powers of
two. This is not accurate enough for some use cases. Squaring the input
effectively doubles the number of piecewise linear segments.

Bug swiftshader:71

Change-Id: Ie7a1da6b93cb5fbed018b61cf8510393964b5aa4
Reviewed-on: https://swiftshader-review.googlesource.com/10450
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 texture filtering precision hint
Alexis Hetu [Tue, 18 Jul 2017 18:33:04 +0000 (14:33 -0400)]
Add texture filtering precision hint

A new extension will be added to SwiftShader in order to allow
Chromium to trigger high precision filtering when necessary.
This extension is documented in:
extensions/CHROMIUM_texture_filtering_hint.txt

Bug swiftshader:76

Change-Id: I7c5b5c5fd01afbd7079e7949ecbd9c18fc539f2b
Reviewed-on: https://swiftshader-review.googlesource.com/10708
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoExport type-info symbols.
Nicolas Capens [Wed, 19 Jul 2017 15:39:28 +0000 (11:39 -0400)]
Export type-info symbols.

Sanitizer tools require type information to catch undefined behavior and
other issues. This wasn't available accross libraries due to the version
script giving them hidden visibility, leading to false positives.

Bug chromium:737384

Change-Id: Iab3e25f4da3672f694e32c1c89278a3fe677d51a
Reviewed-on: https://swiftshader-review.googlesource.com/10728
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
6 years agoAdded support for most formats to FP sampleTexel
Alexis Hetu [Mon, 17 Jul 2017 15:19:12 +0000 (11:19 -0400)]
Added support for most formats to FP sampleTexel

This change is effectively noop by itself, but allows the
floating point path to read all texture formats (except YUV).
This is required by the floating point path to be able to
perform higher precision filtering on all formats (except YUV).

Bug swiftshader:76

Change-Id: I5d0d24c00357b4b77cca2ca8a65d082db7635b40
Reviewed-on: https://swiftshader-review.googlesource.com/10668
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUse real snprintf when available.
Nicolas Capens [Mon, 17 Jul 2017 18:34:55 +0000 (14:34 -0400)]
Use real snprintf when available.

Visual C++ 2015 provides an actual snprintf implementation, so we
shouldn't use _snprintf, which does not guarantee null-termination.

Bug swiftshader:75

Change-Id: Ia45e49e77a6076e8f9f12ad74c6ad50dbdbf2dbd
Reviewed-on: https://swiftshader-review.googlesource.com/10688
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 Frac() returning 1.0.
Nicolas Capens [Mon, 17 Jul 2017 14:27:33 +0000 (10:27 -0400)]
Fix Frac() returning 1.0.

Frac() should always produce results in the range [0.0, 1.0), and thus
never produce a 1.0. However, the current implementation uses
x - floor(x) and this returns 1.0 for very small negative values due to
catastrophic cancellation.

Bug swiftshader:74

Change-Id: I942dd7cfb1f7ee3a260070e748704f005eed0b13
Reviewed-on: https://swiftshader-review.googlesource.com/10648
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoRemove redundant R5G6R5 conversions
Alexis Hetu [Fri, 14 Jul 2017 14:44:10 +0000 (10:44 -0400)]
Remove redundant R5G6R5 conversions

The code to compute the final RGB565 conversion is now
generated once instead of being generated 4 times.

Change-Id: Id90ddd28d6ec4fb957d8093e6b9689462751002b
Reviewed-on: https://swiftshader-review.googlesource.com/10609
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoMaking debug object tracking thread safe.
Ben Vanik [Mon, 10 Jul 2017 23:18:41 +0000 (16:18 -0700)]
Making debug object tracking thread safe.
Currently in debug builds swiftshader is not thread safe because of this
tracking code. This change makes it safe to create/delete objects from
multiple threads.

Change-Id: I9c8d3efc370687891b1acc786499bda02c86ad01
Reviewed-on: https://swiftshader-review.googlesource.com/10528
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Ben Vanik <benvanik@google.com>
6 years agoMaking Program use the currently active context device.
Ben Vanik [Mon, 10 Jul 2017 21:08:12 +0000 (14:08 -0700)]
Making Program use the currently active context device.
Fixes bug swiftshader:73.

Change-Id: I6d36348996d22cf507a4badc3af90ce8d654eb71
Reviewed-on: https://swiftshader-review.googlesource.com/10510
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
6 years agoUnbinding uniform buffers on context shutdown.
Ben Vanik [Mon, 10 Jul 2017 21:21:01 +0000 (14:21 -0700)]
Unbinding uniform buffers on context shutdown.
Fixes bug swiftshader:72.

Change-Id: I4fcc6c47ec8561150c88fea200aeb6baf9534c00
Reviewed-on: https://swiftshader-review.googlesource.com/10511
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Ben Vanik <benvanik@google.com>
6 years agoFix signed/unsigned comparison warning.
Nicolas Capens [Tue, 11 Jul 2017 17:49:26 +0000 (13:49 -0400)]
Fix signed/unsigned comparison warning.

Change-Id: Ibec89dd4463274db4ed7381cf20320a0c9f46a57
Reviewed-on: https://swiftshader-review.googlesource.com/10549
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoRemove @chromium.org accounts from OWNERS.
Nicolas Capens [Tue, 11 Jul 2017 17:19:01 +0000 (13:19 -0400)]
Remove @chromium.org accounts from OWNERS.

Android now also uses OWNERS files for commit approval in Gerrit (see
b/33166666). But they don't recognize the @chromium.org accounts. We
shouldn't need them for Chromium if we just use our @google.com
accounts, so they can be removed. Also use full account names instead
of aliases.

Bug b/63147516

Change-Id: Ic5dfab1aad0025ec20f5a0f79b612c893fece8fc
Reviewed-on: https://swiftshader-review.googlesource.com/10548
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoFix retrieving the current Display.
Nicolas Capens [Mon, 10 Jul 2017 18:26:17 +0000 (14:26 -0400)]
Fix retrieving the current Display.

eglGetCurrentDisplay() returned a pointer to the concrete egl::Display
object, instead of the opaque identifier obtained from eglGetDisplay.
This was a regression caused by
https://swiftshader-review.googlesource.com/10188

Bug chromium:738298

Change-Id: Id3a87fc3978f8f4efdc77d6c5eaa85743fa3672c
Reviewed-on: https://swiftshader-review.googlesource.com/10508
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoFix TLS for platforms without library constructors.
Nicolas Capens [Fri, 7 Jul 2017 21:01:16 +0000 (17:01 -0400)]
Fix TLS for platforms without library constructors.

Some platforms don't support constructors that get called when the
shared library gets loaded. This results in the thread-local-storage
key to never be allocated. Instead we can check if it was allocated on
each use. Also prevent creating new 'current' state if it already
exists, and avoid pthreads undefined behavior.

Bug b/25629882

Change-Id: I5e2486f88185150b976d88d0144e4d13a349eb79
Reviewed-on: https://swiftshader-review.googlesource.com/10451
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoMinor fix for log2
Alexis Hetu [Thu, 6 Jul 2017 21:12:47 +0000 (17:12 -0400)]
Minor fix for log2

No behavior is modified in this cl. log2() was calling logarithm2()
with the wrong options, but logarithm2() currently ignores all
options, so this had no consequence. Fixing to prevent future errors.

Change-Id: I6518d9d90fc1f34cadab2de12657064b2510b463
Reviewed-on: https://swiftshader-review.googlesource.com/10429
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoIntialize memory to zero to silence MSan.
Nicolas Capens [Fri, 7 Jul 2017 09:00:00 +0000 (05:00 -0400)]
Intialize memory to zero to silence MSan.

The MemorySanitizer tool can't instrument JIT-compiled code, so it's
unaware that the vertex processing routine writes the clip flags before
they're being read by triangle setup. This false positive can be
silenced by zeroing the memory at allocation. For good measure, zero
out all intermediate buffers.

Bug chromium:737875

Change-Id: Ic37ff5c64cb63bbddb151744af1d7dff0a254c2d
Reviewed-on: https://swiftshader-review.googlesource.com/10431
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoFix checking dimensions of surfaces.
Nicolas Capens [Wed, 5 Jul 2017 21:00:23 +0000 (17:00 -0400)]
Fix checking dimensions of surfaces.

We were only checking depth stencil surface height against
OUTLINE_RESOLUTION. Instead both color buffers and depth stencil
buffers should be checked against the GL implementation's limits.

Change-Id: I3784f80df4ea950760db7273185fb9312802bdd3
Reviewed-on: https://swiftshader-review.googlesource.com/10410
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoFix memory leak of Subzero global inits.
Nicolas Capens [Wed, 5 Jul 2017 19:04:00 +0000 (15:04 -0400)]
Fix memory leak of Subzero global inits.

getGlobalInits() moves ownership of a unique_ptr<>, which we released
to obtain the raw pointer, but we didn't delete it afterwards. This is
fixed by keeping the unique_ptr<> and having it freed at the end of the
scope.

Bug chromium:732739

Change-Id: I4d8c9367f34790944daabc0417af08eb4b4c7c2e
Reviewed-on: https://swiftshader-review.googlesource.com/10409
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoFix memory leak when aborting routine generation.
Nicolas Capens [Wed, 5 Jul 2017 18:10:46 +0000 (14:10 -0400)]
Fix memory leak when aborting routine generation.

The blitter aborts generating a Reactor routine when a less common
format is being used (causing fallback to statically compiled code). But
the intermediate Reactor and Subzero structures were not being freed. It
is fixed by deleting the global routine when the Function<> goes out of
scope and it hasn't been acquired yet.

Bug chromium:732691

Change-Id: I4904a467454e8e8d2ff0dbf64545823c9fd15802
Reviewed-on: https://swiftshader-review.googlesource.com/10408
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoFix allowing to make null EGL surfaces current.
Nicolas Capens [Fri, 30 Jun 2017 21:07:33 +0000 (17:07 -0400)]
Fix allowing to make null EGL surfaces current.

eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, context)
resulted in a null dereference. It should be supported and is a common
idiom for detaching the surfaces from the context before destroying
them.

Bug swiftshader:70

Change-Id: I5b4406c8d594bc5db34c51bd08371ce69bbd471b
Reviewed-on: https://swiftshader-review.googlesource.com/10389
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoPrettify documentation.
Nicolas Capens [Wed, 28 Jun 2017 15:13:55 +0000 (11:13 -0400)]
Prettify documentation.

Change-Id: Ief18bd1e251f84128660fd559d997e0d094c7abf
Reviewed-on: https://swiftshader-review.googlesource.com/10348
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoMake Blitter part of Renderer.
Nicolas Capens [Tue, 27 Jun 2017 21:08:08 +0000 (17:08 -0400)]
Make Blitter part of Renderer.

This fixes two issues. We had a global 'blitter' instance which doesn't
get destroyed until the library us unloaded. This is reported as a
memory leak (albeit benign). Potentially worse is that the singleton was
shared between all threads, and the Routine cache isn't thread safe.

Bug chromium:732691

Change-Id: I7b90d7d2bc67b4a9f78cdf4f54a76fa2f798b7cc
Reviewed-on: https://swiftshader-review.googlesource.com/10128
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoRefactor texture method overrides.
Nicolas Capens [Tue, 27 Jun 2017 21:03:24 +0000 (17:03 -0400)]
Refactor texture method overrides.

This also removes binding an EGL surface to a 3D texture image, which
is not supported by the API and which is unreachable.

Change-Id: I4a6cd17d731c28769e976b21ac46fe855d1c7b1c
Reviewed-on: https://swiftshader-review.googlesource.com/8351
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoAdd AppVeyor build status.
Nicolas Capens [Wed, 28 Jun 2017 04:58:48 +0000 (00:58 -0400)]
Add AppVeyor build status.

Change-Id: I97583d5b70bd0f9a2edf2e46943d6db58f326f68
Reviewed-on: https://swiftshader-review.googlesource.com/10328
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoDon't crash when using a buffer with no data.
Nicolas Capens [Tue, 27 Jun 2017 16:57:22 +0000 (12:57 -0400)]
Don't crash when using a buffer with no data.

It's undefined behavior when an application attempts to use a buffer
for which no data has been allocated yet, but this is trivial for us to
check for and produce a non-fatal error.

Bug chromium:736639

Change-Id: I795c22363ada1b5e325d1fb5061a9e7673609879
Reviewed-on: https://swiftshader-review.googlesource.com/10309
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoAdd Subzero documentation.
Nicolas Capens [Tue, 27 Jun 2017 14:24:22 +0000 (10:24 -0400)]
Add Subzero documentation.

Change-Id: I47fa608e8923605bd090d6216c9ccf7d5c4051e2
Reviewed-on: https://swiftshader-review.googlesource.com/10308
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoFix resetting current display when no current context.
Nicolas Capens [Thu, 15 Jun 2017 21:15:30 +0000 (14:15 -0700)]
Fix resetting current display when no current context.

Bug swiftshader:65

Change-Id: I8454538d144ed37a56b98c46ed1e88ffdced387e
Reviewed-on: https://swiftshader-review.googlesource.com/10188
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoRename libraries on Mac OS to prevent conflicts.
Nicolas Capens [Fri, 23 Jun 2017 19:44:37 +0000 (15:44 -0400)]
Rename libraries on Mac OS to prevent conflicts.

ANGLE and SwiftShader produce libraries with the same name, which causes
conflicts for Chrome on Mac OS when creating unstripped libraries and
dSYM debug information. Renaming them temporarily works around the build
tools issue.

Bug chromium:735920

Change-Id: Icb4f484970ec75b8c5e7e784ce37e05ee4fbc7db
Reviewed-on: https://swiftshader-review.googlesource.com/10288
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoadd support for gralloc1 mapper
Jaesung Chung [Thu, 22 Jun 2017 11:02:09 +0000 (20:02 +0900)]
add support for gralloc1 mapper

Since N MR1, gralloc1 is newly arrived. In order to use gralloc1, the
caller should retrieve its functions via the getFunction method.
GrallocModule now supports for the gralloc0 and gralloc1 mappers both.
Also it makes FrameBufferAndroid to use common GrallocAndroid
implementation.

Bug b/62897956
Test: no errors on locking and unlocking via gralloc1
Change-Id: I1dbb5acd9a36775c642e0282b9b5017ebcec99ec
Reviewed-on: https://swiftshader-review.googlesource.com/10248
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Jaesung Chung <jaesung@google.com>
6 years agoFix non-component unittests on Mac OS.
Nicolas Capens [Thu, 22 Jun 2017 04:31:47 +0000 (00:31 -0400)]
Fix non-component unittests on Mac OS.

Component builds automatically set the rpath to include dependent libraries,
but with a non-component build these are assumed to be linked statically so the
rpath of where to find the libraries to collect install_name info from is
missing. Thus we set the rpath explicitly.

Related articles and documentation:
https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/RunpathDependentLibraries.html
http://log.zyxar.com/blog/2012/03/10/install-name-on-os-x
https://wincent.com/wiki/@executable_path,_@load_path_and_@rpath

Bug swiftshader:68

Change-Id: I0cfe0d26fccf80ff7911846ef013d47daaeb09fd
Reviewed-on: https://swiftshader-review.googlesource.com/10228
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoRevert workarounds for ThinLTO linker builds.
Nicolas Capens [Wed, 14 Jun 2017 23:45:12 +0000 (16:45 -0700)]
Revert workarounds for ThinLTO linker builds.

Fixing Issue swiftshader:31 makes the workarounds obsolete and since
they disabled some link-time optimizations they should be reverted.

This reverts commit 628a8496e44ec8a096125cb0cdc3e63bb7dd8380.
This reverts commit 158dcfc13fe3e36217f1bf0d4ccbd8bd80f6d5f1.
This reverts commit ad675fa1d6617ff7fe5965845152ba71f33caf61.

Bug chromium:686980
Bug chromium:735508

Change-Id: I4c4e2466fdfcddd12854b87e5a62d6ec8c823a05
Reviewed-on: https://swiftshader-review.googlesource.com/10168
Reviewed-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoFix Mac OS library loading for unittests.
Nicolas Capens [Wed, 21 Jun 2017 17:12:42 +0000 (13:12 -0400)]
Fix Mac OS library loading for unittests.

On Mac OS there is no rpath to set for the executable to locate
libraries. Instead, dylibs themselves have an install_name which is the
path where executables can load them from (added to the executable at
link time).

Bug swiftshader:68

Change-Id: Ia72eba0076ec83fc4492a5c118b4f5420d03a640
Reviewed-on: https://swiftshader-review.googlesource.com/10208
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoTest build with LLVM and Subzero backend.
Nicolas Capens [Wed, 14 Jun 2017 21:03:38 +0000 (14:03 -0700)]
Test build with LLVM and Subzero backend.

Change-Id: Ic8e2360c044aac47447f6a7ae7071d4e3b181678
Reviewed-on: https://swiftshader-review.googlesource.com/10148
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoAdd OpenGL ES 2.0 initialization unit tests.
Nicolas Capens [Tue, 13 Jun 2017 18:37:07 +0000 (14:37 -0400)]
Add OpenGL ES 2.0 initialization unit tests.

Create an OpenGL ES 2.0 context and verify the renderer string. This
ensures the expected libGLESv2 get loaded and initialized correctly.
Also add unittests to the Visual Studio solution.

Change-Id: I848079215434ce1fb9a18564ce47de5b598b21d2
Reviewed-on: https://swiftshader-review.googlesource.com/10108
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoMake the EGL surface class abstract.
Nicolas Capens [Wed, 14 Jun 2017 03:44:13 +0000 (23:44 -0400)]
Make the EGL surface class abstract.

gl::Surface is now the pure abstract interface for egl::Surface, which
can be used by libGLESv2 without requiring typeinfo.

Bug chromium:732667
Bug swiftshader:31

Change-Id: I7d8a5892c5b6186541f84c3cf39e72ac1d6c613d
Reviewed-on: https://swiftshader-review.googlesource.com/10129
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoAdd Travis CI build status.
Nicolas Capens [Tue, 13 Jun 2017 14:10:22 +0000 (10:10 -0400)]
Add Travis CI build status.

Change-Id: Ia0ad3b10fc3e2617945fd0ca763f134ef7276fa4
Reviewed-on: https://swiftshader-review.googlesource.com/10088
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoAdd Travis CI configuration file.
Nicolas Capens [Tue, 13 Jun 2017 04:19:12 +0000 (00:19 -0400)]
Add Travis CI configuration file.

Change-Id: I07d3125d0d3b48f18b5752cdb8bd11869324bff0
Reviewed-on: https://swiftshader-review.googlesource.com/10068
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoFix D3D8, D3D9, and GL builds.
Nicolas Capens [Mon, 12 Jun 2017 16:43:48 +0000 (12:43 -0400)]
Fix D3D8, D3D9, and GL builds.

Bug swiftshader:63
Bug swiftshader:31

Change-Id: I59d08cbc8379e2c30984b9ec0ed4d49317633ce8
Reviewed-on: https://swiftshader-review.googlesource.com/10048
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoSynchronize in ~ImageImplementation
Antoine Labour [Sat, 10 Jun 2017 01:14:05 +0000 (18:14 -0700)]
Synchronize in ~ImageImplementation

The egl::Image destructor synchronizes with the threads accessing that image.
However, that is too late because by the time ~Image runs, ImageImplementation
has already been destructed - concurrently with the other threads running, i.e.
data race. In particular, since those threads access virtual member functions on
Image, they may end up calling the base class ones (which are pure) instead of
the derived class ones.

So make sure to synchronize in ~ImageImplementation instead.

Bug: swiftshader:62

Change-Id: I91240d1dbb45dd126c65d86f9aecf77833b4488d
Reviewed-on: https://swiftshader-review.googlesource.com/10029
Reviewed-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoFix CMake build for Mac OS X.
Nicolas Capens [Fri, 9 Jun 2017 15:21:48 +0000 (11:21 -0400)]
Fix CMake build for Mac OS X.

Recent versions of CMake omit adding Info.plist to the application
bundle due to an error attempting to parse a symbolic reference as a
CMake one. It is fixed by adding escape characters.
Also set CMAKE_MACOSX_RPATH to silence a warning.

Bug b/62380447

Change-Id: I6464fce7e3d4812d872343806138e44c269dd2da
Reviewed-on: https://swiftshader-review.googlesource.com/10008
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoFix symbol visibility for preemption.
Nicolas Capens [Fri, 9 Jun 2017 21:34:07 +0000 (17:34 -0400)]
Fix symbol visibility for preemption.

Entry functions need to have default visibility instead of protected
visibility to allow symbol preemption during linking (i.e. when not
using dlsym() to explicitly obtain pointers to entry functions). See:
https://bugs.llvm.org//show_bug.cgi?id=30960

Bug swiftshader:64

Change-Id: Ia2d3ae8fb4faec9a75d811c643e3164bfb7d0423
Reviewed-on: https://swiftshader-review.googlesource.com/10028
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoExpose EGL_EXT_platform_base on all platforms.
Nicolas Capens [Mon, 5 Jun 2017 21:43:46 +0000 (17:43 -0400)]
Expose EGL_EXT_platform_base on all platforms.

We're already exporting the entry functions (eglGetPlatformDisplayEXT(), etc.).
Valid platform enums are defined by separate KHR_platform_* extensions.

Bug swiftshader:58

Change-Id: I1eb030f76cd800be9ecb37bad36dd004aceeb1af
Reviewed-on: https://swiftshader-review.googlesource.com/9953
Reviewed-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoAdd Chromium global build dependency.
Nicolas Capens [Wed, 24 May 2017 21:41:30 +0000 (17:41 -0400)]
Add Chromium global build dependency.

All build targets must depend on //build/config:exe_and_shlib_deps.

Bug chromium:723069
Bug swiftshader:54

Change-Id: I7aaecd681ece1ed773239a88a5c4c93a75f7cd1f
Reviewed-on: https://swiftshader-review.googlesource.com/9829
Reviewed-by: Tom Anderson <thomasanderson@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoAvoid dummy key methods by using pure abstract classes.
Nicolas Capens [Tue, 30 May 2017 19:25:50 +0000 (15:25 -0400)]
Avoid dummy key methods by using pure abstract classes.

Sanitizer tools desire having the vtables of any class with non-pure
virtual methods, even when none of them are called in the current
linkage unit. Work around this by making the affected classes pure
abstract and implementing them in a derived class in the respective
library responsible for creating them.

Bug swiftshader:31

Change-Id: I40046f605731eb1cc3825c1ede2d8d9b5826d0f5
Reviewed-on: https://swiftshader-review.googlesource.com/9914
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoMake the FrameBuffer class pure abstract.
Nicolas Capens [Mon, 29 May 2017 21:20:36 +0000 (17:20 -0400)]
Make the FrameBuffer class pure abstract.

Sanitizer tools desire having the vtables of any class with non-pure
virtual methods, even when none of them are called in the current
linkage unit. In the case of sw::FrameBuffer, to work around this we can
make the class pure abstract by making the destructor pure virtual. Note
that the destructor still has a non-empty definition, since all non-
default destructors need a defintion, and it will get called as part of
the destructor chain.

Bug swiftshader:31

Change-Id: I7601b1a725c513ff484cd34a8965636b7f21513c
Reviewed-on: https://swiftshader-review.googlesource.com/9912
Reviewed-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoFixed R8 and RG8 frambuffers for GLES2
Alexis Hetu [Wed, 7 Jun 2017 20:50:12 +0000 (16:50 -0400)]
Fixed R8 and RG8 frambuffers for GLES2

These were already available for GLES3 and exposed as texturable
formats for GLES2 when the GL_EXT_texture_rg extension was exposed,
but it should also have enabled these formats as renderable formats.

Bug swiftshader:60

Change-Id: I598d7645b04737dae19dc88b4229fa3d7d231714
Reviewed-on: https://swiftshader-review.googlesource.com/9990
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoIncrease OUTLINE_RESOLUTION to 8192
Alexis Hetu [Wed, 7 Jun 2017 17:47:08 +0000 (13:47 -0400)]
Increase OUTLINE_RESOLUTION to 8192

This is required by chromium tests. There is another cl
(https://swiftshader-review.googlesource.com/9952) which
will change internal uses of OUTLINE_RESOLUTION to adapt
to the rendertarget's height which will reduce the memory
usage increase caused by the current cl.

Change-Id: Iaabbbff07db9c3251ddf49cc534a1a91bab4e5f2
Reviewed-on: https://swiftshader-review.googlesource.com/9988
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoImplement EGL_EXT_client_extensions
Alexis Hetu [Mon, 5 Jun 2017 14:29:14 +0000 (10:29 -0400)]
Implement EGL_EXT_client_extensions

In EGLQueryString, it is now valid to query EGL_EXTENSIONS
with a display set to EGL_NO_DISPLAY, so the function
should proceed without returning an error in these cases.

Change-Id: I76ccd4f98f3d4180268b6b85b5b04a19bea59977
Reviewed-on: https://swiftshader-review.googlesource.com/9948
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoExpose GL_EXT_texture_rg extension
Alexis Hetu [Mon, 5 Jun 2017 14:32:46 +0000 (10:32 -0400)]
Expose GL_EXT_texture_rg extension

The extension was already implemented for GLES3, but simply required
a few cases to be added for support in GLES2.

Note that this extension is required to process filters using masks
with GLES2 in skia.

Change-Id: I196901ca19a4fd40a5a1ebd87040519b0de6eb5f
Reviewed-on: https://swiftshader-review.googlesource.com/9949
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoFix missing include for use_gold.
Nicolas Capens [Mon, 5 Jun 2017 17:59:55 +0000 (13:59 -0400)]
Fix missing include for use_gold.

Change-Id: I60096b0e70049d490ba8bd3c7514f19e8de0017b
Reviewed-on: https://swiftshader-review.googlesource.com/9951
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoWork around gold linker bug for 32-bit code.
Nicolas Capens [Mon, 5 Jun 2017 17:24:09 +0000 (13:24 -0400)]
Work around gold linker bug for 32-bit code.

Bug chromium:729532

Change-Id: Ie10edb39fdc61557f394cddca981f55e89b63cc4
Reviewed-on: https://swiftshader-review.googlesource.com/9950
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoAdded missing integer query
Alexis Hetu [Mon, 29 May 2017 20:46:42 +0000 (16:46 -0400)]
Added missing integer query

Recently, ES3 specific getIntegerv queries were removed from ES2.
Unfortunately, GL_MAX_COLOR_ATTACHMENTS was moved to the ES3
section, but was still supposed to be in the ES2 section,
since the GL_EXT_draw_buffers exposes it.

Change-Id: I2272ccf282558e10ee6cfb1be9d124cc59df14fa
Reviewed-on: https://swiftshader-review.googlesource.com/9911
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoSet permissions after loading image.
Nicolas Capens [Mon, 29 May 2017 14:00:32 +0000 (10:00 -0400)]
Set permissions after loading image.

Bug b/38514001

Change-Id: I6d2d891545840beee54db95a7456b6ede293d0eb
Reviewed-on: https://swiftshader-review.googlesource.com/9908
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoFix Linux build - remove TableGen from CMakeLists.txt
Lingfeng Yang [Thu, 25 May 2017 15:30:59 +0000 (08:30 -0700)]
Fix Linux build - remove TableGen from CMakeLists.txt

TableGen uses exceptions, but is not used.

Change-Id: I3a54c2f72784169804b3305c26f17c63c313931e
Reviewed-on: https://swiftshader-review.googlesource.com/9851
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Lingfeng Yang <lfy@google.com>
6 years agoFix floating-point sampling of YUV formats.
Nicolas Capens [Wed, 24 May 2017 21:39:49 +0000 (17:39 -0400)]
Fix floating-point sampling of YUV formats.

Bug b/38268007

Change-Id: I5a75b7ea475848739ca5f3717e2b42c89088dafb
Reviewed-on: https://swiftshader-review.googlesource.com/9828
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoDon't dynamically recurse when analyzing functions
Lingfeng Yang [Fri, 19 May 2017 21:00:38 +0000 (14:00 -0700)]
Don't dynamically recurse when analyzing functions

bug: 38257724

With this CL, dEQP-GLES3.functional.shaders.functions.invalid no longer results
in a stack overflow and system crash.

The fix is to explicitly loop over switch cases in the function call
depth analysis.

Later on, we probably want to change TIntermSwitch traversal to loop
over all cases of the switch statement as well, but that requires
a lot of changes; all traversers need to be changed to not have to loop over
switch statements themselves, which will break expectations and
perhaps functionality that critically depends on seeing/controlling iteration
over switch statement cases.

Not tested for regressions in dEQP-GLES2.functional.shaders.*

Test: dEQP-GLES3.functional.shaders.functions.invalid.dynamic_switch_recursion_vertex:
system crash, hang, or fail -> Pass

Change-Id: I5d13a5f3296579c8818975e103f5ed6e03a47b68
Reviewed-on: https://swiftshader-review.googlesource.com/9789
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Lingfeng Yang <lfy@google.com>
6 years agoAllow GL_TEXTURE_MAX_ANISOTROPY_EXT from sampler object.
Lingfeng Yang [Sat, 13 May 2017 00:28:04 +0000 (17:28 -0700)]
Allow GL_TEXTURE_MAX_ANISOTROPY_EXT from sampler object.

Bug b/38257724

Change-Id: I4157ef825ed4ed8f805e9dad35b43bb5780877b6
Reviewed-on: https://swiftshader-review.googlesource.com/9788
Reviewed-by: Nicolas Capens <capn@google.com>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Tested-by: Lingfeng Yang <lfy@google.com>
6 years agoRemove unused return value.
Nicolas Capens [Wed, 24 May 2017 19:46:48 +0000 (15:46 -0400)]
Remove unused return value.

Bug b/17893069

Change-Id: I78d582455192456625523d7bf2bdc5d16c88d68e
Reviewed-on: https://swiftshader-review.googlesource.com/9814
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoAdded EGL display validity check
Alexis Hetu [Wed, 24 May 2017 18:06:27 +0000 (14:06 -0400)]
Added EGL display validity check

If the EGLDisplay input parameter to eglInitialize isn't
PRIMARY_DISPLAY or HEADLESS_DISPLAY, egl::Display::get()
will return null. Instead of crashing, we should return
an EGL_BAD_DISPLAY error.

Change-Id: Ie1e39f2807db5a38f8d21fd6e22270c02cbeba3a
Reviewed-on: https://swiftshader-review.googlesource.com/9813
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoRemoved offending flags for Chromium
Alexis Hetu [Wed, 24 May 2017 15:16:26 +0000 (11:16 -0400)]
Removed offending flags for Chromium

Removed flags and verified Linux build / execution still works properly.

Change-Id: Ibad4ec5d1b89d8e9b826c57bf2d6dbd0d18b7a2e
Reviewed-on: https://swiftshader-review.googlesource.com/9812
Reviewed-by: Nico Weber <thakis@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
6 years agoImplement unrolling of loops using > or >=.
Nicolas Capens [Wed, 24 May 2017 14:45:56 +0000 (10:45 -0400)]
Implement unrolling of loops using > or >=.

Bug swiftshader:53

Change-Id: I20500e567e58ed29caa0a0ad9ad7884e66e96cb9
Reviewed-on: https://swiftshader-review.googlesource.com/9811
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoFix null dereference on uninitialized loop variable.
Nicolas Capens [Wed, 24 May 2017 14:20:24 +0000 (10:20 -0400)]
Fix null dereference on uninitialized loop variable.

Bug swiftshader:52

Change-Id: I972c769551acf19898f10579685f45f3192612c4
Reviewed-on: https://swiftshader-review.googlesource.com/9810
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoTransform feedback varyings no longer linked when unused
Alexis Hetu [Tue, 23 May 2017 21:10:09 +0000 (17:10 -0400)]
Transform feedback varyings no longer linked when unused

In OpenGL ES 3.0, varyings declared in the vertex shader may be
used by transform feedback, regardless of whether or not they are
also declared in the fragment shader. In OpenGL ES 2.0, these
unmatched varyings are usually discarded. In order to preserve
the OpenGL ES 2.0 behavior and to not burden the Open GL ES 3.0
implementation with new unused varyings, only the unmatched
varyings which may be used as transform feedback inputs will be
added to the vertex shader, instead of always adding all of them.

Change-Id: I35f37b6ee77181b5d3a47605ef246c7d1ecf904d
Reviewed-on: https://swiftshader-review.googlesource.com/9808
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoFix locking a destroyed mutex.
Nicolas Capens [Fri, 19 May 2017 14:57:28 +0000 (10:57 -0400)]
Fix locking a destroyed mutex.

Surface should not lock the resource of a parent texture at destruction, because
it can already have been destroyed. For example when a texture's image was bound
as a render target, and the texture is deleted by the app, then the image holds
the last reference to the texture. When the render target image gets deleted, it
first releases its parent texture, and then the underlying surface gets
destroyed.

This is fixed by synchronizing, by locking and unlocking the (parent) resource,
earlier. The derived class is responsible for calling Surface::sync() before
releasing the parent resource.

Bug chromium:716803

Change-Id: Ifc3685dcf9e25e8419000af65d4bb7407f26bbcb
Reviewed-on: https://swiftshader-review.googlesource.com/9750
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoImplement eglQueryContext.
Nicolas Capens [Fri, 19 May 2017 13:31:35 +0000 (09:31 -0400)]
Implement eglQueryContext.

Bug b/37991302

Change-Id: I8a1c28d4a9c8968be3a04da64a19ddd3f5274dd6
Reviewed-on: https://swiftshader-review.googlesource.com/9768
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
6 years agoAdd Subzero documentation.
Nicolas Capens [Thu, 18 May 2017 15:22:26 +0000 (11:22 -0400)]
Add Subzero documentation.

Change-Id: I383c7b3f18f9dd80c37eea8a4b06a024a060cfd1
Reviewed-on: https://swiftshader-review.googlesource.com/9749
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoFix assert on using GLSL sampler function arguments.
Nicolas Capens [Wed, 17 May 2017 19:16:51 +0000 (15:16 -0400)]
Fix assert on using GLSL sampler function arguments.

Bug b/31651425

Change-Id: Ic6c1f16b1ec3ef039e15e72e70a1daee711fba2f
Reviewed-on: https://swiftshader-review.googlesource.com/9748
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoReset pointer to null after delete.
Nicolas Capens [Tue, 16 May 2017 15:21:26 +0000 (11:21 -0400)]
Reset pointer to null after delete.

Fixes a double free.

Change-Id: Ieb71dff4476132b9b2fb624223e26af49a4131ee
Reviewed-on: https://swiftshader-review.googlesource.com/9728
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
6 years agoReplace unique_ptr with a raw pointer.
Nicolas Capens [Fri, 12 May 2017 04:25:50 +0000 (00:25 -0400)]
Replace unique_ptr with a raw pointer.

Fixes Android Lollipop (and older) build failures.

Change-Id: I30481a59562854b9891a2ac82ac2e7aab8ff570c
Reviewed-on: https://swiftshader-review.googlesource.com/9709
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoPrevent LTO from eliminating cross-library virtual methods.
Nicolas Capens [Thu, 11 May 2017 15:25:00 +0000 (11:25 -0400)]
Prevent LTO from eliminating cross-library virtual methods.

libEGL has to call virtual methods on objects created withing libGLESv2,
and vice-versa. Clang's aggressive link-time-optimization considers
calls to these methods unreachable, because they're not defined within
the same linkage unit. So when they do get called, we're hitting UD
instructions. It can be fixed by marking these classes with
[[clang::lto_visibility_public]] attributes:
https://clang.llvm.org/docs/LTOVisibility.html

Bug chromium:720933

Change-Id: I87f9b09921a1b2d443121efcdb5525ff4cb5797b
Reviewed-on: https://swiftshader-review.googlesource.com/9688
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoFix buffer overflow.
Nicolas Capens [Mon, 8 May 2017 21:06:11 +0000 (17:06 -0400)]
Fix buffer overflow.

Bug chromium:719291

Change-Id: I5ddf6d45d3a66a4b626ec1d73995a2a4fd4b28b9
Reviewed-on: https://swiftshader-review.googlesource.com/9668
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoRemove EGL dependency on LLVM.
Nicolas Capens [Wed, 3 May 2017 20:07:14 +0000 (16:07 -0400)]
Remove EGL dependency on LLVM.

EGL does not and should not depend on LLVM.

Change-Id: I36ef1d67e67cdf7625ca8c1a6f1bf3214c39ee4c
Reviewed-on: https://swiftshader-review.googlesource.com/9611
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoDon't needlessly generate cursor drawing code.
Nicolas Capens [Tue, 2 May 2017 19:14:58 +0000 (15:14 -0400)]
Don't needlessly generate cursor drawing code.

Direct3D 9 provides support for a "hardware" cursor. There is no such thing
in newer APIs, so we shouldn't waste time dynamically generating code for it.

Change-Id: I8d54c3500966ce075afb83c98c5013024062eed8
Reviewed-on: https://swiftshader-review.googlesource.com/9629
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoFixed -1 to implicitly unsigned char narrowing error.
Nicolas Capens [Thu, 4 May 2017 18:48:55 +0000 (14:48 -0400)]
Fixed -1 to implicitly unsigned char narrowing error.

C++11 does not allow narrowing a constant expression value to a type
that can't fully represent it. So when char is considered unsigned,
we can't store -1 in it. Explicitly using signed char fixes it.

Change-Id: I5c0e9fe0025659e06291655a12220ab589d5f5bd
Reviewed-on: https://swiftshader-review.googlesource.com/9630
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoRemove the Subzero submodule.
Nicolas Capens [Wed, 3 May 2017 18:24:03 +0000 (14:24 -0400)]
Remove the Subzero submodule.

Bug swiftshader:47
Bug b/37478805

Change-Id: I7519eb7c743530a7bf6a4253244011c29d7ed7c5
Reviewed-on: https://swiftshader-review.googlesource.com/9609
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoBuild Subzero from the subtree directory.
Nicolas Capens [Wed, 3 May 2017 18:23:06 +0000 (14:23 -0400)]
Build Subzero from the subtree directory.

The submodule is at /third-party/pnacl-subzero
The subtree is at /third-party/subzero

Bug swiftshader:47
Bug b/37478805

Change-Id: I2da86151f111448e962b6b24c085a2f288de18b4
Reviewed-on: https://swiftshader-review.googlesource.com/9608
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoUnconditionally compile relocation code.
Nicolas Capens [Wed, 3 May 2017 19:33:49 +0000 (15:33 -0400)]
Unconditionally compile relocation code.

This fixes a pedantic warning about 'patchSite' being an unused variable.

Change-Id: I2540461fb3da98cebf94350f731fe452e9768b8f
Reviewed-on: https://swiftshader-review.googlesource.com/9610
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoAdd Subzero as a Git subtree.
Nicolas Capens [Wed, 3 May 2017 17:37:29 +0000 (13:37 -0400)]
Add Subzero as a Git subtree.

Add 'third_party/subzero/' from commit 'fb705a6d55003b2c32772ae49e25b0babcff5acc'
from repository https://chromium.googlesource.com/native_client/pnacl-subzero

Bug swiftshader:47
Bug b/37478805

Change-Id: I9cc7a7f3d788059984102c8275ec7b28c4b0aad0
git-subtree-dir: third_party/subzero
git-subtree-mainline: 1ba2611b653dc7db5513608995bc4353363e111f
git-subtree-split: fb705a6d55003b2c32772ae49e25b0babcff5acc

7 years agoBuild with Subzero for Android on ARM.
Nicolas Capens [Tue, 2 May 2017 15:57:06 +0000 (11:57 -0400)]
Build with Subzero for Android on ARM.

Bug b/37478805

Change-Id: I3a452410d44c0da1cb01c80e3e4fcade221f7304
Reviewed-on: https://swiftshader-review.googlesource.com/9569
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoFix lowering ARM shift by zero as a move.
Nicolas Capens [Mon, 1 May 2017 19:31:29 +0000 (15:31 -0400)]
Fix lowering ARM shift by zero as a move.

ARM does not support shifting by 0. An immediate value of 0 is interpreted as
shifting by 32. See section A8.4.1 Constant shifts of the ARMv7-A/R reference
manual.

Change-Id: I289a7c6091c04387700dc2e9b3f959639bd919ce
Reviewed-on: https://chromium-review.googlesource.com/491949
Reviewed-by: Jim Stichnoth <stichnot@chromium.org>
7 years agoEmulate rounding to the nearest integer.
Nicolas Capens [Wed, 26 Apr 2017 13:30:47 +0000 (09:30 -0400)]
Emulate rounding to the nearest integer.

This implementation works by adding a large value which makes the
fractional part no longer fit in the mantissa, and then subtracting it
again. It matches nearbyint() for values up to 2^22, positive or
negative.

The 'magic number' of 0x00C00000 is derived by first observing that the
integer values 0x00800000 to 0x00FFFFFF can be represented exactly in
single-precision floating-point format but can't have a fractional part
because there are 24 mantissa bits (the top one being hidden). So when
adding 0x00800000 to for example 0.6, it forces the hardware to round it
to the nearest representable integer, being 0x00800001. Subtracting
0x00800000 again gives us 1.0. This works for rounding any value from
0.0 to 0x007FFFFF. However, it doesn't work for negative values, because
the intermediate result would be less than 0x00800000 and thus leave
some room for fractional bits in the mantissa. The solution is to use
0x00C00000 instead so the range gets split between positive and negative
values.

Note that values greater than the upper bound will still round to
integers, but not the nearest ones, while values less than the lower
bound can result in fractional values.

Bug b/37495485

Change-Id: I1aed2d831269fcf21b8d3313856a9b9756a532ef
Reviewed-on: https://swiftshader-review.googlesource.com/9488
Reviewed-by: Nicolas Capens <capn@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoFix memory alignment of outline spans.
Nicolas Capens [Fri, 28 Apr 2017 16:50:58 +0000 (12:50 -0400)]
Fix memory alignment of outline spans.

Some CPU architectures require all memory accesses to be naturally aligned.
We read polygon outline spans in pairs, so we need two underflow spans.

b/37478805

Change-Id: If74fd59654fb6fa56cbed93122b496b9e86dda06
Reviewed-on: https://swiftshader-review.googlesource.com/9528
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoFix CMake build.
Nicolas Capens [Wed, 26 Apr 2017 01:31:07 +0000 (21:31 -0400)]
Fix CMake build.

Bug swiftshader:41

Change-Id: I4ece1a7aff5cb431ebb80452be0b6698163b7081
Reviewed-on: https://swiftshader-review.googlesource.com/9468
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoAdd Visual Studio Code build and debug configurations.
Nicolas Capens [Wed, 26 Apr 2017 15:52:47 +0000 (11:52 -0400)]
Add Visual Studio Code build and debug configurations.

Change-Id: I57b57f49490b711b9e5d6598a9224f02d5cfa93a
Reviewed-on: https://swiftshader-review.googlesource.com/9490
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoSupport ARM compilation with Subzero.
Nicolas Capens [Tue, 25 Apr 2017 19:17:25 +0000 (15:17 -0400)]
Support ARM compilation with Subzero.

Bug b/37478805

Change-Id: Ib3af3edfcc24308b2a0f37cb0f534226aa83e446
Reviewed-on: https://swiftshader-review.googlesource.com/9448
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoAdd Subzero unit tests to CMake build.
Nicolas Capens [Wed, 26 Apr 2017 14:01:37 +0000 (10:01 -0400)]
Add Subzero unit tests to CMake build.

Bug b/37478805

Change-Id: Idb44b05cea24eed8a46d267c3de9fc769ac58977
Reviewed-on: https://swiftshader-review.googlesource.com/9489
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoFix potential null pointer dereference.
Nicolas Capens [Tue, 25 Apr 2017 20:41:00 +0000 (16:41 -0400)]
Fix potential null pointer dereference.

When the compiler does not perform return value optimization, the
LockPtr<> destructor of the temporary object is called after the move
constructor has set the Lock to null, thus causing a null pointer
dereference in the destructor. This can be replicated using the
-fno-elide-constructors build flag.

Change-Id: Ie00c3f93364fdf78ea1993469b9a606b3c87ebdc
Reviewed-on: https://chromium-review.googlesource.com/486985
Reviewed-by: Jim Stichnoth <stichnot@chromium.org>
7 years agoFix ARM compilation.
Nicolas Capens [Tue, 25 Apr 2017 16:54:39 +0000 (12:54 -0400)]
Fix ARM compilation.

This does not provide full support for ARM,
but merely makes things (statically) compile.

Bug b/37478805

Change-Id: I01d1d84e396c04c84e74d521946595014d2eafb5
Reviewed-on: https://swiftshader-review.googlesource.com/9430
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoFlush the instruction cache after loading JIT compiled code.
Nicolas Capens [Tue, 25 Apr 2017 14:52:16 +0000 (10:52 -0400)]
Flush the instruction cache after loading JIT compiled code.

x86 does not strictly require this because it performs snooping to ensure
consistency, but it is essential on ARM and some other architectures.

Bug b/37478805

Change-Id: I9fad94571ec65b67132ba40c3e1814c63d6af468
Reviewed-on: https://swiftshader-review.googlesource.com/9429
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>