OSDN Git Service

android-x86/external-swiftshader.git
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 years agoUse pthread mutexes on all Linux platforms.
Nicolas Capens [Tue, 18 Apr 2017 15:20:01 +0000 (11:20 -0400)]
Use pthread mutexes on all Linux platforms.

Bug chromium:710753

Change-Id: Ie74d86de027417579c9c6949aabad1c3ae89ebfc
Reviewed-on: https://swiftshader-review.googlesource.com/9329
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoFix potential data race in mutex lock implementation.
Nicolas Capens [Tue, 18 Apr 2017 15:14:37 +0000 (11:14 -0400)]
Fix potential data race in mutex lock implementation.

Writing or reading an ordinary volatile boolean does not provide memory
ordering guarantees. Use atomic<bool> with release and acquire semantics
instead. On x86 this should have no impact on the generated code, since
it architecturally offers strong memory ordering guarantees.

Bug chromium:710753

Change-Id: I5aa2a6eeecfcd691a0aa8d06fd067f9d59ab13c3
Reviewed-on: https://swiftshader-review.googlesource.com/9328
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoAlso fix libGLESv2.
Ivan Krasin [Mon, 17 Apr 2017 21:23:23 +0000 (14:23 -0700)]
Also fix libGLESv2.

BUG=chromium:686980

Change-Id: I5f22f57288246c262a0fdb0ca1b0b321e4a58c1b
Reviewed-on: https://swiftshader-review.googlesource.com/9310
Tested-by: Ivan Krasin <krasin@chromium.org>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoDisable CFI on SwiftShader's libEGL.
Ivan Krasin [Mon, 17 Apr 2017 21:16:17 +0000 (14:16 -0700)]
Disable CFI on SwiftShader's libEGL.

BUG=chromium:686980

Change-Id: I0224093fbbffb2bac8a84c95a8370617c4df6978
Reviewed-on: https://swiftshader-review.googlesource.com/9309
Tested-by: Ivan Krasin <krasin@chromium.org>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoFix SwiftShader's libEGL build under ThinLTO.
Ivan Krasin [Mon, 17 Apr 2017 21:08:34 +0000 (14:08 -0700)]
Fix SwiftShader's libEGL build under ThinLTO.

Linking libEGL.so of the SwiftShader's flavor requires
the linker to be too smart (there's a heavy reliance on
garbage collecting unused symbols, for which there is
no guarantees in the general case). In ThinLTO case,
garbage collection is still not as sofisticated, as in
other cases, so it fails to link the target complaining
about undefined symbols.

The workaround is to prevent Clang from splitting the
bitcode files in the question into two, and making the
GC problem a bit easier.

Eventually, ThinLTO might get a better GC, but it might
be a good idea to not rely on this feature in the source
code. At least, no other targets in Chromium do.

BUG=chromium:686980

Change-Id: Ib44f65c4825cc3f6cd24695738a71ca4661f0bfb
Reviewed-on: https://swiftshader-review.googlesource.com/9308
Tested-by: Ivan Krasin <krasin@chromium.org>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoFix buffer overflow.
Nicolas Capens [Tue, 18 Apr 2017 17:03:47 +0000 (13:03 -0400)]
Fix buffer overflow.

Bug chromium:712624

Change-Id: I8e7813aac44c9fef1a2311be550da8cea5a65d16
Reviewed-on: https://swiftshader-review.googlesource.com/9330
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoImplement GL_CURRENT_COLOR/NORMAL/TEXTURE_COORDS for glGetFloatv().
Nicolas Capens [Thu, 13 Apr 2017 17:35:09 +0000 (13:35 -0400)]
Implement GL_CURRENT_COLOR/NORMAL/TEXTURE_COORDS for glGetFloatv().

Bug b/31913614
Bug b/32087196

Change-Id: I45c06c7cb907ae1f1efc57c6302044334159c828
Reviewed-on: https://swiftshader-review.googlesource.com/7734
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoClarify when we set the EGL_FRAMEBUFFER_TARGET_ANDROID attribute.
Nicolas Capens [Mon, 13 Mar 2017 19:08:39 +0000 (15:08 -0400)]
Clarify when we set the EGL_FRAMEBUFFER_TARGET_ANDROID attribute.

The EGL_ANDROID_framebuffer_target extension description is vague about
which configs are supposed to have the EGL_FRAMEBUFFER_TARGET_ANDROID
attribute set. The HWComposer isn't supposed to do format conversions,
nor should we have to blit or convert on eglSwapBuffers, so the flag
is only set when the config's format matches the framebuffer format.

Bug b/21804123

Change-Id: Ie348750fbf1b2f096cdf36358d5c90b6f42e30c1
Reviewed-on: https://swiftshader-review.googlesource.com/8933
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoFix setting depth+stencil texture attachment.
Nicolas Capens [Thu, 16 Mar 2017 21:32:43 +0000 (17:32 -0400)]
Fix setting depth+stencil texture attachment.

Change-Id: I97f30a38f2f78ae5c4e2be8899dae3c8ff8bc748
Reviewed-on: https://swiftshader-review.googlesource.com/8968
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoFix floating-point color buffer support.
Nicolas Capens [Wed, 29 Mar 2017 18:40:14 +0000 (14:40 -0400)]
Fix floating-point color buffer support.

- Implemented GL_EXT_color_buffer_float.
- Removed duplicate glRenderbufferStorageMultisample implementation.
- Refactored internalformat validation.
- Removed GL_R11F_G11F_B10F as renderable format. OpenGL ES 3.0 only supports
  this as a texture format.

Change-Id: I83ce8225c1b310006f5ce983349ea8cb8b2f7c29
Reviewed-on: https://swiftshader-review.googlesource.com/9048
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
7 years agoDisable filtering on 1x1 textures.
Nicolas Capens [Thu, 30 Mar 2017 14:30:56 +0000 (10:30 -0400)]
Disable filtering on 1x1 textures.

Textures with just one texel don't require filtering. This also avoids precision
issues for pedantic tests which expect exact values.

Bug swiftshader:39

Change-Id: I52c5697e277523e2b8cb2c879ba0a7b2296ee7c5
Reviewed-on: https://swiftshader-review.googlesource.com/9068
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoIncreased varyings limit
Alexis Hetu [Tue, 4 Apr 2017 20:46:55 +0000 (16:46 -0400)]
Increased varyings limit

For OpenGL ES 3.0, the varyings limit must be increased in order
to meet the new lower limit. This doesn't solve how the varyings
count is still verified at compile time instead of link time, but
it allows us to remove an UNIMPLEMENTED() call.

Bug b/37069434

Change-Id: Ib6641352b625d56c7c3cab119fadcdc19f794a5b
Reviewed-on: https://swiftshader-review.googlesource.com/9188
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoRemove Chromium unit tests from standalone solution.
Nicolas Capens [Mon, 10 Apr 2017 12:27:26 +0000 (08:27 -0400)]
Remove Chromium unit tests from standalone solution.

These tests rely on the SwiftShader libraries to be loaded from a swiftshader/
subdirectory. The PowerVR samples are a better smoke test for the standalone
build, so we can just remove the Chromium unit tests from the Visual Studio
solution.

Bug swiftshader:42

Change-Id: Ia7d73a62aac4a202750e630666143c920fec65b7
Reviewed-on: https://swiftshader-review.googlesource.com/9268
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoFix pedantic pointer comparison.
Nicolas Capens [Thu, 6 Apr 2017 12:37:33 +0000 (08:37 -0400)]
Fix pedantic pointer comparison.

Change-Id: Idc8f54ac36e59640b93af83293dc2339a25336d6
Reviewed-on: https://swiftshader-review.googlesource.com/9208
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoAdd EGL initialization unit test.
Nicolas Capens [Tue, 4 Apr 2017 18:14:08 +0000 (14:14 -0400)]
Add EGL initialization unit test.

This test verifies that the swiftshader EGL libraries exists, can be loaded, has
its entry functions accessible, and we get the expected vendor/version strings.

Change-Id: Ifc29286cfaa83fa4c2412c073d383f2c1b58766f
Reviewed-on: https://swiftshader-review.googlesource.com/9168
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoFix libEGL symbol visibility.
Nicolas Capens [Mon, 3 Apr 2017 19:03:35 +0000 (15:03 -0400)]
Fix libEGL symbol visibility.

Change-Id: Ie546d41b0205c7bd963a56af209652fd41fbe3ca
Reviewed-on: https://swiftshader-review.googlesource.com/9128
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoSwitch to Subzero instead of LLVM on Linux.
Nicolas Capens [Mon, 27 Mar 2017 16:09:44 +0000 (12:09 -0400)]
Switch to Subzero instead of LLVM on Linux.

Change-Id: Ib13af2fb929df98e0bb0e5af33a935942d854706
Reviewed-on: https://swiftshader-review.googlesource.com/9008
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
(cherry picked from commit 2aeaa6f445b1878a1ee3986c3b08ffa50323b366)
Reviewed-on: https://swiftshader-review.googlesource.com/9108
Reviewed-by: Alexis Hétu <sugoi@google.com>
7 years agoFix CMake build when Subzero submodule is missing.
Nicolas Capens [Fri, 31 Mar 2017 14:34:20 +0000 (10:34 -0400)]
Fix CMake build when Subzero submodule is missing.

By default we build SwiftShader with the LLVM backend, so the build
shouldn't fail because of missing the Subzero submodule's code. Run
git submodule update --init
To pull the submodule if you do want to build with Subzero.

Change-Id: Ib752edf891a6dd18fff8ce0dfae79ff5a1b7e011
Reviewed-on: https://swiftshader-review.googlesource.com/9088
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoGcc: Suppress some warnings in src/OpenGL
Tom Anderson [Tue, 28 Mar 2017 20:58:52 +0000 (13:58 -0700)]
Gcc: Suppress some warnings in src/OpenGL

This CL removes some warning spam on a gcc build.

Bug chromium:697528
R=capn@google.com

Change-Id: I6909d30e3fcafc8ab7e3a98efe8d180a686781d8
Reviewed-on: https://swiftshader-review.googlesource.com/9031
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Tom Anderson <thomasanderson@google.com>
7 years agoFix not returning GL_BGRA_EXT for incompatible format types.
Nicolas Capens [Mon, 27 Mar 2017 20:15:20 +0000 (16:15 -0400)]
Fix not returning GL_BGRA_EXT for incompatible format types.

The EXT_read_format_bgra extension specifies that GL_BGRA_EXT can only be
returned for GL_UNSIGNED_BYTE, UNSIGNED_SHORT_4_4_4_4_REV_EXT, and
UNSIGNED_SHORT_1_5_5_5_REV_EXT types.

Bug swiftshader:38

Change-Id: I54d7b6bbb0954fce87ee7622207fe32a308a43d9
Reviewed-on: https://swiftshader-review.googlesource.com/9030
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoSupport GL_BGRA_EXT readback for all normalized formats.
Nicolas Capens [Mon, 27 Mar 2017 18:52:58 +0000 (14:52 -0400)]
Support GL_BGRA_EXT readback for all normalized formats.

Bug swiftshader:38

Change-Id: Ice466d96e4d71d546e5770551cc4188f8364edd0
Reviewed-on: https://swiftshader-review.googlesource.com/9029
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoRefactor read pixel format/type validation.
Nicolas Capens [Mon, 27 Mar 2017 18:50:51 +0000 (14:50 -0400)]
Refactor read pixel format/type validation.

Bug swiftshader:38

Change-Id: I74c642b3c7346541d042acde78aa2e0213beb5f6
Reviewed-on: https://swiftshader-review.googlesource.com/9028
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoFix GCC build
Tom Anderson [Mon, 20 Mar 2017 18:54:29 +0000 (11:54 -0700)]
Fix GCC build

This CL fixes building the 'all' target in a Chromium checkout with the following args.gn:
is_debug = false
is_clang = false
use_sysroot = false
proprietary_codecs = true
ffmpeg_branding = "Chrome"
is_component_build = true
enable_nacl = false
use_goma = true

Bug chromium:697528
Change-Id: Ie725988e8a1cb9ee672eb1e8e20d718ac91004fa

Change-Id: Ie725988e8a1cb9ee672eb1e8e20d718ac91004fa
Reviewed-on: https://swiftshader-review.googlesource.com/8888
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Tom Anderson <thomasanderson@google.com>
7 years agoFix C++11 strict string literal const correctness.
Nicolas Capens [Mon, 20 Mar 2017 15:29:52 +0000 (11:29 -0400)]
Fix C++11 strict string literal const correctness.

String literals are const in C++11, and should only be assigned to
const pointers.

Bug swiftshader:33

Change-Id: Iefe0a1c06d58dffb69d7fbe199a2f0aa8bf3bcb1
Reviewed-on: https://swiftshader-review.googlesource.com/8990
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
7 years agoFix Visual Studio 2017 compilation.
Nicolas Capens [Wed, 15 Mar 2017 18:17:33 +0000 (14:17 -0400)]
Fix Visual Studio 2017 compilation.

When building with VC++ 2017 RC and its default header files the
intrin.h header file is less aggressively included by Windows headers.
This causes build breaks on Chrome x64 builds with VC++ 2017 RC when
X86MCTargetDesc.cpp uses __cpuid without first including its header.

https://github.com/google/swiftshader/pull/2

Change-Id: I664d7b509e0517b7621d41312ccdd0d3de60de84
Reviewed-on: https://swiftshader-review.googlesource.com/8951
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoBuild fix
Alexis Hetu [Thu, 16 Mar 2017 15:46:16 +0000 (11:46 -0400)]
Build fix

WaitForDebugger function was undefined.

Change-Id: I578e99638bddc40c56817cfc66ed5787f1cdc6e7
Reviewed-on: https://swiftshader-review.googlesource.com/8953
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
7 years agoMade debugger wait dialog Visual Studio only
Alexis Hetu [Thu, 16 Mar 2017 14:53:01 +0000 (10:53 -0400)]
Made debugger wait dialog Visual Studio only

The debugger wait dialog hinders tests on debug builds
on chromium bots, so this change sets the debugger wait
dialog to only be allowed only on Visual Studio builds
within the SwiftShader solution.

Change-Id: I0b126f9b0d0451d0fa8941fcb3f9097100488f45
Reviewed-on: https://swiftshader-review.googlesource.com/8952
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
7 years agoAllows SwiftShader to identify the Android version
Greg Hartman [Tue, 14 Mar 2017 22:23:41 +0000 (15:23 -0700)]
Allows SwiftShader to identify the Android version

Bug b/36232368

Change-Id: I0a62629db6737134771861710ee0b18826807008
Reviewed-on: https://swiftshader-review.googlesource.com/8949
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Greg Hartman <ghartman@google.com>
7 years agoFixed defines from BUILD.gn files
Alexis Hetu [Tue, 14 Mar 2017 19:11:15 +0000 (15:11 -0400)]
Fixed defines from BUILD.gn files

Rather than specifying defines using explicit commands in "cflags"
sections, all defines were moved to generic "defines" sections.

Change-Id: Ica6ee2a2447aae4f8fc6decc3a4f6b40af7ce9fd
Reviewed-on: https://swiftshader-review.googlesource.com/8948
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
7 years agoOnly support main thread rendering in debug builds.
Nicolas Capens [Mon, 13 Mar 2017 21:20:39 +0000 (17:20 -0400)]
Only support main thread rendering in debug builds.

Rendering on the main thread can cause segmentation faults on Windows
due to uncommitted stack memory, since Subzero does not currently call
__chkstk. In practice this would have mainly been an issue on VMs with
a single virtual CPU.

Bug swiftshader:25

Change-Id: Ic3be7e5a41ef09b7e056d3c3df2983c225101fe4
Reviewed-on: https://swiftshader-review.googlesource.com/8934
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoFix calling stack probe through a register on Win64.
Nicolas Capens [Mon, 13 Mar 2017 14:43:56 +0000 (10:43 -0400)]
Fix calling stack probe through a register on Win64.

The __chkstk function can be at a greater than 4 GiB offset from our
generated function. Fix derived from https://reviews.llvm.org/D7267

Change-Id: Ife87dcd42541676828c4a0ca77dcded6649ce278
Reviewed-on: https://swiftshader-review.googlesource.com/8932
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoRemove clobber registers conflicting with input variables.
Nicolas Capens [Fri, 10 Mar 2017 13:40:06 +0000 (08:40 -0500)]
Remove clobber registers conflicting with input variables.

https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Clobbers specifies
that the clobber list should not overlap with the input or output.

Change-Id: I77fc2bfc6209ed325355193758f00fc171c8aebf
Reviewed-on: https://swiftshader-review.googlesource.com/8930
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoDisable LLVM ABI-breaking checks mismatch check.
Nicolas Capens [Thu, 9 Mar 2017 21:44:21 +0000 (16:44 -0500)]
Disable LLVM ABI-breaking checks mismatch check.

Subzero doesn't actually use any ABI breaking LLVM functionality, so
we compile a minimized version of LLVMSupport which does not include
the symbol used to detect a mismatch in the ABI-breaking check at link-
time. Hence we need to disable this check.

Change-Id: I04c37deb359b81c21954ad92a6665d44fe2312a5
Reviewed-on: https://swiftshader-review.googlesource.com/8929
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoWork around unsuppressable GCC error.
Nicolas Capens [Thu, 9 Mar 2017 20:32:31 +0000 (15:32 -0500)]
Work around unsuppressable GCC error.

GCC warns against bitfields not fitting the entire range of an enum
with a fixed underlying type of unsigned int, which gets promoted to
an error with -Werror and cannot be suppressed. However, GCC already
defaults to using unsigned int as the underlying type of an unscoped
enum without a fixed underlying type. So we can just omit it.

Bug chromium:697528

Change-Id: I8db8fef09e3397d4ec5ebe9f7c3c5e4ae9c0edff
Reviewed-on: https://swiftshader-review.googlesource.com/8928
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoMake chromium_git in DEPS conform to other Chromium submodules
Csaba Osztrogonác [Tue, 21 Feb 2017 16:59:33 +0000 (17:59 +0100)]
Make chromium_git in DEPS conform to other Chromium submodules
to be able to override chromium_git.

Change-Id: I11419a81fb492affcfa92ba69661cc90ad88ae98
Reviewed-on: https://swiftshader-review.googlesource.com/8868
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
7 years agoglGetSynciv implementation
Alexis Hetu [Fri, 17 Feb 2017 22:07:50 +0000 (17:07 -0500)]
glGetSynciv implementation

Added the missing part of the FenceSync object
implementation based on the assumption that all
fence operations are always signaled before
calling any sync related wait functions.

Passes all related dEQP tests.

Change-Id: I2fd2ac160dfd1250f55240fc3f696f00579d12d4
Reviewed-on: https://swiftshader-review.googlesource.com/8855
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoRemove superfluous incRef/decRef on graphics buffer.
Nicolas Capens [Fri, 17 Feb 2017 01:35:59 +0000 (20:35 -0500)]
Remove superfluous incRef/decRef on graphics buffer.

Dequeuing and queuing the graphics buffer takes care of ownership, and
a previous patch ensured the buffer is unlocked before we queue it so
we don't need to hold a reference for longer.

Bug b/34981145
Bug b/35443034

Change-Id: I6cbaeff08f5d930dde8bdd1522052ac33a6ae9ac
Reviewed-on: https://swiftshader-review.googlesource.com/8849
Reviewed-by: Greg Hartman <ghartman@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Greg Hartman <ghartman@google.com>
7 years agoUnlock the graphics buffer before queuing it.
Nicolas Capens [Fri, 17 Feb 2017 01:32:45 +0000 (20:32 -0500)]
Unlock the graphics buffer before queuing it.

The buffer changes ownership after queuing it, so unlock it first.
The decRef() gets removed in a subsequent patch.

Bug b/34981145

Change-Id: I4710699af46a7cbde12e97bc444ad35747509b07
Reviewed-on: https://swiftshader-review.googlesource.com/8848
Reviewed-by: Greg Hartman <ghartman@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Greg Hartman <ghartman@google.com>
7 years agoFix not canceling an already queued graphics buffer.
Nicolas Capens [Thu, 16 Feb 2017 14:00:06 +0000 (09:00 -0500)]
Fix not canceling an already queued graphics buffer.

cancelBuffer() returns a graphics buffer to the buffer queue but
doesn't pass it on to the consumer side. There's currently no reason
for us to call it when the EGL surface gets destroyed or resized, since
we only briefly dequeue the buffer to blit the already rendered result
and immediately queue it again. Even if the queuing fails, we shouldn't
try to cancel the buffer because that's essentially the same as a
queueing but without valid content. It would fail with the same error,
or worse, transfer ownership twice and mess up the reference counting.

Bug b/34981145

Change-Id: Ia37a711db5ebd61bcde14cf4bc45097d4e2d33e8
Reviewed-on: https://swiftshader-review.googlesource.com/8814
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Greg Hartman <ghartman@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Greg Hartman <ghartman@google.com>