OSDN Git Service

android-x86/external-swiftshader.git
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>
7 years agoFixed glGetIntegerv for OpenGL ES 2
Alexis Hetu [Fri, 17 Feb 2017 19:40:50 +0000 (14:40 -0500)]
Fixed glGetIntegerv for OpenGL ES 2

Many new OpenGL ES 3 specific entries in Context::getIntegerv
were not hidden when an OpenGL ES 2 context is created. The
switch statement was separated in 2 statements in order to
fix this.

Change-Id: Ib218b72e854f5857958cfa14ecdfef5ae03ee92b
Reviewed-on: https://swiftshader-review.googlesource.com/8851
Tested-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoUse rep stos x86 assembly for fast clears.
Nicolas Capens [Tue, 14 Feb 2017 22:23:54 +0000 (17:23 -0500)]
Use rep stos x86 assembly for fast clears.

Change-Id: I20b385c316f24b703da1d3071e393b4cde450173
Reviewed-on: https://swiftshader-review.googlesource.com/8811
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 for Subzero compilation on x86
Alexis Hetu [Wed, 15 Feb 2017 16:44:14 +0000 (11:44 -0500)]
Fix for Subzero compilation on x86

Silence a few warnings within the LLVM code used by Subzero
which ended up being treated as errors when compiling
Chromium for x86.

Change-Id: If4d3c13ce0b01185d59a2cd064b2bad537639b94
Reviewed-on: https://swiftshader-review.googlesource.com/8813
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoFix external surface pitch/slice retrieval.
Nicolas Capens [Wed, 15 Feb 2017 03:42:58 +0000 (22:42 -0500)]
Fix external surface pitch/slice retrieval.

Change-Id: I21ec9c20a594fd322d17f2bcd1c58b298d4c0ce9
Reviewed-on: https://swiftshader-review.googlesource.com/8812
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoEnabling Subzero compilation on Windows
Alexis Hetu [Mon, 13 Feb 2017 19:45:12 +0000 (14:45 -0500)]
Enabling Subzero compilation on Windows

Once Subzero is pulled by Chromium (see
https://codereview.chromium.org/2695813002/),
we'll enable Subzero compilation on Windows.

Change-Id: I3464dbd98224b3ac602aef3c4a27596366d275b3
Reviewed-on: https://swiftshader-review.googlesource.com/8772
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoRemoving a few UNIMPLEMENTED cases
Alexis Hetu [Mon, 13 Feb 2017 21:05:35 +0000 (16:05 -0500)]
Removing a few UNIMPLEMENTED cases

A few remaining cases in Context.cpp are actually
implemented, so we can remove the UNIMPLEMENTED()
calls in these cases: Primitive restart, uniform
blocks, fragment inputs and vertex outputs are all
implemented. Also, the implementation can legally
support 0 program binary formats.

Change-Id: I74b51b511c66170e284ac5d82f573453332872cc
Reviewed-on: https://swiftshader-review.googlesource.com/8788
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoDisable OpenGL ES 3.0 in Chromium builds.
Nicolas Capens [Tue, 14 Feb 2017 15:03:08 +0000 (10:03 -0500)]
Disable OpenGL ES 3.0 in Chromium builds.

Change-Id: I6077e9f439dc20217e9e7fb6c6f98f969e7d0b51
Reviewed-on: https://swiftshader-review.googlesource.com/8790
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 min/max signed zero and NaN handling.
Nicolas Capens [Mon, 13 Feb 2017 17:39:18 +0000 (12:39 -0500)]
Fix min/max signed zero and NaN handling.

Make min(x, y) equal to (x < y ? x : y) and max(x, y) equal to
(x > y ? x : y), including the behavior for signed zeros and NaNs.
This also enables optimizing them into min and max SSE2 instructions
on x86.

Bug swiftshader:19

Change-Id: I047b90e9da9f3c72657ab7c619bc91b92a700a45
Reviewed-on: https://swiftshader-review.googlesource.com/8771
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 for Chromium linux official build
Alexis Hetu [Mon, 13 Feb 2017 16:26:09 +0000 (11:26 -0500)]
Fix for Chromium linux official build

Bug chromium:691427

The official build uses the LLVM gold linker, which seems
to have an issue with some visibility settings. Restoring
these settings for now to solve the issue.

Change-Id: I4f448c38bb7c964b2a53d19e064ecb23c119ab61
Reviewed-on: https://swiftshader-review.googlesource.com/8770
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
7 years agoFixing the Linux build without breaking the Mac build
Alexis Hetu [Fri, 10 Feb 2017 21:08:39 +0000 (16:08 -0500)]
Fixing the Linux build without breaking the Mac build

This change adds 2 platform specific files for Linux, which
are used to define the typeinfo() functions used in some
classes in order to satisfy the ubsan compiler on Linux.
Unfortunately, adding those definitions on all platforms
breaks the build on Mac. Those aren't necessary on Windows,
so the Linux specific files are enough to make the build
work properly on all platforms.

Change-Id: If731ab2e5df47731695412da04f9b2db576ea140
Reviewed-on: https://swiftshader-review.googlesource.com/8768
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoFixed Mac build
Alexis Hetu [Thu, 9 Feb 2017 22:14:34 +0000 (17:14 -0500)]
Fixed Mac build

The Linux build fix had broken the Mac build, so the new
"typeinfo" virtual function were moved from the header files
to the source files to fix both builds simultaneously.

Change-Id: I37f5ef4bd5ec4da34a19531dcb85df6a98728aa1
Reviewed-on: https://swiftshader-review.googlesource.com/8748
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
7 years agoFixing Chromium build all
Alexis Hetu [Thu, 9 Feb 2017 16:23:23 +0000 (11:23 -0500)]
Fixing Chromium build all

To prevent Chromium from building the "swiftshader_subzero"
source set when building all, the source set is now located
within an "if (use_swiftshader_with_subzero)" statement.

Change-Id: I4363487103ec8cd6856b1afb0dd861146a3e56bd
Reviewed-on: https://swiftshader-review.googlesource.com/8728
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoFix ignored gn local variable
Alexis Hetu [Wed, 8 Feb 2017 20:01:45 +0000 (15:01 -0500)]
Fix ignored gn local variable

The current way "use_subzero" was used seems to fail when
compiling with goma (I don't see why, honestly). Anyway,
most build configuration related booleans are declared in
a declare_args() section, so I moved the setting there,
which will hopefully solve the issue.

Change-Id: I063d9938d04bfdf8140878a740f3710309f8bf1e
Reviewed-on: https://swiftshader-review.googlesource.com/8714
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoPull out SWIFTSHADER_OPTIM
Greg Hartman [Wed, 8 Feb 2017 18:55:05 +0000 (10:55 -0800)]
Pull out SWIFTSHADER_OPTIM

Bug b/34268167
Change-Id: Id2200a9c7d6fea522e3405829447e031e2da15b3
Reviewed-on: https://swiftshader-review.googlesource.com/8711
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Greg Hartman <ghartman@google.com>
7 years agoFix predicating instructions before return in loops.
Nicolas Capens [Fri, 22 Apr 2016 18:58:52 +0000 (14:58 -0400)]
Fix predicating instructions before return in loops.

Only the instructions following a return statement were being marked as
affected by it so predication would be applied. But in a loop the instructions
above the return statement are also affected by it.

Bug b/25220690

Change-Id: If2490a6e0b4e9cf8b6e28b33cbbbcec8b4ebfdaa
Reviewed-on: https://swiftshader-review.googlesource.com/5183
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoCleaning up BUILD.gn file before Chromium DEPS update
Alexis Hetu [Tue, 7 Feb 2017 20:47:27 +0000 (15:47 -0500)]
Cleaning up BUILD.gn file before Chromium DEPS update

Cleaned up a few things before updating SwiftShader's version
in Chromium's DEPS file:
- Added Windows Subzero fix
- Removed commented out sysroot related lines
- Fixed formatting using git
- Temporarily disabled Subzero compilation for now

Change-Id: Ib6ae75c20869522675d28086ab170f01fd730f93
Reviewed-on: https://swiftshader-review.googlesource.com/8709
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoAdd dummy key methods for UBSan RTTI.
Nicolas Capens [Tue, 7 Feb 2017 18:44:24 +0000 (13:44 -0500)]
Add dummy key methods for UBSan RTTI.

Chromium UBSan builds require RTTI, for which GCC/Clang requires each
class' first non-inline virtual method (the "key method") to have a known
definition so that its address can be used as a unique type identifier:
https://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html

libEGL and libGLESv2 each use objects who's full definition only exists
within one or the other. Methods for which the definition is unknown can
still be called if they are virtual, because the compiler/linker only needs
to know the vtable entry offset. But because of the GCC/Clang requirement
of having the first non-inline virtual method be fully defined, we need to
add dummy virtual methods and their definitions.

Bug swiftshader:31

Change-Id: Ib146cac811388086b29dbb099266c43795d6ed31
Reviewed-on: https://swiftshader-review.googlesource.com/8708
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoModified MutexLock to use a pthread mutex on Android.
Jorge E. Moreira [Sat, 3 Dec 2016 01:03:54 +0000 (17:03 -0800)]
Modified MutexLock to use a pthread mutex on Android.

The BackoffLock spins idle for a while when waiting for a locked mutex
before yielding the core, thus wasting many CPU cycles. Modern pthread
implementations have low overhead mutexes which make the thread sleep
if the lock is already held, and efficiently resume them it becomes
available.

Change-Id: I26b64c86db620739671373fd0d82085744d34fa8
Reviewed-on: https://swiftshader-review.googlesource.com/8648
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoOptimize replication.
Nicolas Capens [Fri, 27 Jan 2017 10:55:44 +0000 (02:55 -0800)]
Optimize replication.

Since floating-point scalars are stored in vector registers, Subzero
allows us to just bitcast between them, eliminating a load and insert
before shuffling.

Change-Id: Ibccf242fd4cfc28604f35f420a04fd4ee6eabe52
Reviewed-on: https://swiftshader-review.googlesource.com/8575
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoUse unsigned index array accesses for texture sampling.
Nicolas Capens [Fri, 27 Jan 2017 05:49:04 +0000 (21:49 -0800)]
Use unsigned index array accesses for texture sampling.

Array accesses with unsigned indices can be faster on x86-64 because
we can take advantage of implicit zero-extension of 32-bit integers to
64-bit during pointer arithmetic.

Change-Id: I17d531d9ad05c2d2994f007d5444b2a514a591b8
Reviewed-on: https://swiftshader-review.googlesource.com/8571
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoAdd README files
Greg Hartman [Fri, 19 Aug 2016 22:33:55 +0000 (22:33 +0000)]
Add README files

BUG: 30979264

Change-Id: I315bc6e6b64a012896542667d7db58f3516b29de
Reviewed-on: https://swiftshader-review.googlesource.com/8649
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Greg Hartman <ghartman@google.com>
7 years agoRemove obsolete vendor rules
Greg Hartman [Fri, 3 Feb 2017 09:11:40 +0000 (01:11 -0800)]
Remove obsolete vendor rules

Test: foo
Change-Id: I27a139266d34d26f5d3468e3993a502f0596ae7d
Reviewed-on: https://swiftshader-review.googlesource.com/8650
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Greg Hartman <ghartman@google.com>
7 years agoGuard against threads joining twice.
Nicolas Capens [Thu, 2 Feb 2017 18:54:09 +0000 (13:54 -0500)]
Guard against threads joining twice.

After a pthread_join() call the handle becomes invalid or could be
recycled by another thread, leading to undefined behavior when
attempting to join it again. Also, on Windows the handle has to be
closed to free it.

Bug b/34883464

Change-Id: Ib20d0539b6b46e331c6378b3a9f0c2a334d34892
Reviewed-on: https://swiftshader-review.googlesource.com/8612
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoAdding Subzero to Chromium on Windows
Alexis Hetu [Wed, 1 Feb 2017 16:23:30 +0000 (11:23 -0500)]
Adding Subzero to Chromium on Windows

Modified the BUILD.gn files in order to be able to easily switch
between Subzero and LLVM back ends. Note that Subzero
compilation should already work on Linux, as soon as the Wheezy
to Jessie update lands. For now, only Windows will build Subzero.

Also removed linux hack from libEGL build file.

Change-Id: Ic584b604496c4b4f745b05d72a752f056495055b
Reviewed-on: https://swiftshader-review.googlesource.com/8630
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoRemoved extra / from DEPS file
Alexis Hetu [Wed, 1 Feb 2017 16:17:20 +0000 (11:17 -0500)]
Removed extra / from DEPS file

Linux handled the extra / properly, but Windows did not,
so it had to be removed.

Change-Id: Ie42d8777aef83c0024bc9b3e5c631ece7e87e236
Reviewed-on: https://swiftshader-review.googlesource.com/8629
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoSupport TARGET_TRANSLATE_2ND_ARCH case
Victor Khimenko [Fri, 30 Sep 2016 19:31:01 +0000 (21:31 +0200)]
Support TARGET_TRANSLATE_2ND_ARCH case

When second arch is translated we don't have 32-bit platform and
64-bit platform.  Instead we have two 32-bit ones, just one is
translated.

Test: Build system refactoring CL. Existing unit tests still pass.

BUG=31422117
BUG=27526885

Change-Id: Ia5fdd2f485dd5e4e8bc6799f0691cd03c2bff1a0
Reviewed-on: https://swiftshader-review.googlesource.com/8609
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
(cherry picked from commit f24b1b445274b0dbb4ffc860847a26d0b33d3a21)
Reviewed-on: https://swiftshader-review.googlesource.com/8611

7 years agoSupport HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED as RGBX8888
Greg Hartman [Fri, 27 Jan 2017 17:22:31 +0000 (09:22 -0800)]
Support HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED as RGBX8888

The 3.0 camera HAL makes extensive use of
HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, which Android defines as the
format that is best for the hardware. The fake camera implementation
decided that that was RGBX8888, so it seem like that is what we should
use.

Test: untested
Change-Id: Ia02ebbefd015f9ca099b4393daf5d464f38fe8fc
Reviewed-on: https://swiftshader-review.googlesource.com/8588
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoFix using sized internal formats for EGL images.
Nicolas Capens [Mon, 30 Jan 2017 20:45:44 +0000 (15:45 -0500)]
Fix using sized internal formats for EGL images.

Bug b/34799114

Change-Id: Id42d3b784946291d8754774a7916a186a4694ba1
Reviewed-on: https://swiftshader-review.googlesource.com/8591
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 Byte4 unpacking.
Nicolas Capens [Thu, 26 Jan 2017 23:13:36 +0000 (15:13 -0800)]
Refactor Byte4 unpacking.

Change-Id: I82f8215ce4366e0795ce249b4d8f6c8e391af96c
Reviewed-on: https://swiftshader-review.googlesource.com/8568
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoMacOS build fix
Alexis Hetu [Mon, 30 Jan 2017 18:46:08 +0000 (13:46 -0500)]
MacOS build fix

Fixed MacOS build after the recent Linux fix caused an issue on
MacOS. Removed a few flags and changed visibility to fix it.

Change-Id: Ic9d08d8ec0ccf8a2002f2787c3ec79861bb59139
Reviewed-on: https://swiftshader-review.googlesource.com/8589
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoSupport unsigned array indices.
Nicolas Capens [Fri, 27 Jan 2017 01:44:37 +0000 (17:44 -0800)]
Support unsigned array indices.

Change-Id: I4136781005cbd0551461adecdd94d8e3cc8688d0
Reviewed-on: https://swiftshader-review.googlesource.com/8570
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 array addressing of emulated vector types.
Nicolas Capens [Fri, 27 Jan 2017 00:05:18 +0000 (16:05 -0800)]
Fix array addressing of emulated vector types.

operator[] on a pointer was using the vector register size (16 bytes)
instead of the size of the (emulated) vector type.

Change-Id: Ice8677b41a3af81176fe9495fd02ede9f8b0482f
Reviewed-on: https://swiftshader-review.googlesource.com/8569
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoGeneralize dead stores.
Nicolas Capens [Fri, 27 Jan 2017 10:29:00 +0000 (02:29 -0800)]
Generalize dead stores.

Stores are dead if the address is from an alloca and all uses of the
address are stores, not just when it's a single store.

Change-Id: I5b65a64e21b9e398922e5440c35f0d318c03e911
Reviewed-on: https://swiftshader-review.googlesource.com/8574
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 eliminating stores to pointer arguments.
Nicolas Capens [Fri, 27 Jan 2017 10:26:12 +0000 (02:26 -0800)]
Fix eliminating stores to pointer arguments.

If a store address has no definition, it must be a pointer argument.
Unlike stores to alloca's, these are not dead.

Change-Id: I66e50b14ffea1cfc61fc756b5545ab8ae28b4bf8
Reviewed-on: https://swiftshader-review.googlesource.com/8573
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoAdding Subzero in Chromium
Alexis Hetu [Thu, 19 Jan 2017 15:59:25 +0000 (10:59 -0500)]
Adding Subzero in Chromium

In order to add Subzero as a dependency in Chromium, Chromium's
DEPS file will be modified to use SwiftShader's DEPS file in
order to pull SwiftShader's desired revision of Subzero. This
will ensure that SwiftShader and Subzero are always in sync.

Change-Id: I0b24845c0ddbf974baac4ef6cc3ff6ab397d5f69
Reviewed-on: https://swiftshader-review.googlesource.com/8529
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoUpdate to Linux build files for Chromium
Alexis Hetu [Fri, 27 Jan 2017 16:38:59 +0000 (11:38 -0500)]
Update to Linux build files for Chromium

Although SwiftShader was building properly on the build bots, it
wasn't exporting its symbols properly. I compared the flags used in
the BUILD.gn files and in the CMakeLists.txt file and attempted to
get both build systems to use the same flags and options.

Change-Id: Idc73d4ad5b45311881e88720bf611e25110dcc70
Reviewed-on: https://swiftshader-review.googlesource.com/8576
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoOptimize constant operand order.
Nicolas Capens [Wed, 25 Jan 2017 19:35:00 +0000 (11:35 -0800)]
Optimize constant operand order.

Constant operands of commutative operations preferably go on the right
hand side to avoid requiring an extra register for two operand
instructions. Also, Subzero assumes constants in pointer arithmetic are
on the right hand side to consider optimizing it into an addressing
mode.

Change-Id: Ife5a471903d5f4bef0c19b6c908d75715f06bfec
Reviewed-on: https://swiftshader-review.googlesource.com/8548
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoVectorize R5G6B5 framebuffer present.
Nicolas Capens [Tue, 24 Jan 2017 16:53:47 +0000 (08:53 -0800)]
Vectorize R5G6B5 framebuffer present.

Change-Id: I40922c89056cacd00f9d728dfe1f3f12824c81a1
Reviewed-on: https://swiftshader-review.googlesource.com/3253
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 a mutex around SyncSet operations
Greg Hartman [Fri, 26 Aug 2016 03:18:01 +0000 (20:18 -0700)]
Add a mutex around SyncSet operations

BUG: 31072273
Change-Id: I037505ad3ab1ba80aecab4e24ec8d1932df2dcf7
Reviewed-on: https://swiftshader-review.googlesource.com/7030
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Lingfeng Yang <lfy@google.com>
7 years agoUse MAP_ANON if MAP_ANONYMOUS is not defined.
Nicolas Capens [Fri, 20 Jan 2017 22:11:41 +0000 (17:11 -0500)]
Use MAP_ANON if MAP_ANONYMOUS is not defined.

MAP_ANON has been deprecated in favor of MAP_ANONYMOUS, but Mac OS only
defines MAP_ANON.

Bug chromium:630728

Change-Id: I7345a5f9227acbc0caa29d8103855ab531f16499
Reviewed-on: https://swiftshader-review.googlesource.com/8531
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoFixed warnings in Reactor
Alexis Hetu [Thu, 19 Jan 2017 15:49:19 +0000 (10:49 -0500)]
Fixed warnings in Reactor

Fixed:
- type comparison mismatch
- redefined macros
- unused functions
- line endings

Change-Id: I965ca4b887aee968e6cf95feb36c3cbf90b85580
Reviewed-on: https://swiftshader-review.googlesource.com/8528
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoSupport building with Subzero on Mac OS.
Nicolas Capens [Wed, 18 Jan 2017 21:24:09 +0000 (16:24 -0500)]
Support building with Subzero on Mac OS.

Change-Id: I7979eb2557a6103ad10b7be3c274fadf12d27ae7
Reviewed-on: https://swiftshader-review.googlesource.com/8508
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoEmit SSE2 compatible operations if SSE4.1 is not supported.
Nicolas Capens [Sat, 14 Jan 2017 17:52:55 +0000 (12:52 -0500)]
Emit SSE2 compatible operations if SSE4.1 is not supported.

Bug swiftshader:20

Change-Id: I67818bfe10cb29211559fb2ee047f6bec6ce46d4
Reviewed-on: https://swiftshader-review.googlesource.com/8451
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoDetect SSE4.1 support for Subzero.
Nicolas Capens [Sat, 14 Jan 2017 17:52:55 +0000 (12:52 -0500)]
Detect SSE4.1 support for Subzero.

Bug swiftshader:20

Change-Id: I20c2ab7cb4c00c365520ff8b8500f7594127498b
Reviewed-on: https://swiftshader-review.googlesource.com/8468
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 loading uninitialized data in loops.
Nicolas Capens [Wed, 18 Jan 2017 15:18:03 +0000 (10:18 -0500)]
Fix loading uninitialized data in loops.

When we have an uninitialized variable that is declared outside of a
loop and is read and written to inside the loop, we should not eliminate
the load and replace it with an undefined value, because in the next
iteration we want the value from the previous iteration.

Change-Id: Ic996c796307f62fc835079af6c58adf1eb288259
Reviewed-on: https://swiftshader-review.googlesource.com/8488
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 packusdw SSE2 fallback.
Nicolas Capens [Tue, 17 Jan 2017 19:01:33 +0000 (14:01 -0500)]
Fix packusdw SSE2 fallback.

Bug swiftshader:20

Change-Id: I81ad267d450713ffe2a5a84e1d7f7f140b515c85
Reviewed-on: https://swiftshader-review.googlesource.com/8454
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoRefactor Reactor type constructors.
Nicolas Capens [Mon, 16 Jan 2017 22:19:00 +0000 (17:19 -0500)]
Refactor Reactor type constructors.

Provide default constructors for each type, and initialize the swizzle
parent in a less bug prone manner.

Change-Id: Ia7f406a66274c7b1737cbe82db733e2e3ab65175
Reviewed-on: https://swiftshader-review.googlesource.com/8453
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 the vector element extraction type for Short4.
Nicolas Capens [Mon, 16 Jan 2017 21:25:08 +0000 (16:25 -0500)]
Fix the vector element extraction type for Short4.

Change-Id: Ic8785bd56ac7303b0502f0303f9270a6999a1df9
Reviewed-on: https://swiftshader-review.googlesource.com/8452
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoAvoid vector element insert type mismatch.
Nicolas Capens [Fri, 13 Jan 2017 22:37:45 +0000 (17:37 -0500)]
Avoid vector element insert type mismatch.

Subzero silently allows inserting a 32-bit integer into a vector with
16-bit elements. This generates a pinsrd instruction, which requires
SSE4.1, even when specifying to only support SSE2. This change emits
a pinsrw instruction instead, which is SSE2.

Bug swiftshader:20

Change-Id: I37bd0ebb6d9cfdd2cdef4788e89e9672386c685e
Reviewed-on: https://swiftshader-review.googlesource.com/8450
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 Subzero vector comparison.
Nicolas Capens [Fri, 13 Jan 2017 20:09:21 +0000 (15:09 -0500)]
Fix Subzero vector comparison.

Subzero returns vNi1 type results for vector comparisons, which we were
sign-extending to v4i32, even for smaller fields. We don't actually
ever have to sign-extend these results.

Change-Id: Ifdd30edd498d66fc4c557804035794a659eacd87
Reviewed-on: https://swiftshader-review.googlesource.com/8449
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoManually convert unsigned integer to floating-point.
Nicolas Capens [Thu, 15 Dec 2016 19:45:13 +0000 (14:45 -0500)]
Manually convert unsigned integer to floating-point.

Subzero uses a helper function to convert uint to float. It's faster to
just emit a sequence of operations to perform the cast manually.
This implementation converts the lower 31 bits as a signed integer, and
adds 0x80000000 as a floating-point value when the upper bit is set.
This approach does not produce the correct rounding in rare cases, but
should still be adequate. For consistency, we're also using this method
with the LLVM back-end.

Change-Id: Ic5d7b73cd2a9e154056365cdbe9af0962bdbe1cb
Reviewed-on: https://swiftshader-review.googlesource.com/8312
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 resource include file path capitalization.
Nicolas Capens [Fri, 13 Jan 2017 17:34:41 +0000 (12:34 -0500)]
Fix resource include file path capitalization.

Change-Id: I01d1e3a5464ba81440cc144ac50beae2c8b3f3c8
Reviewed-on: https://swiftshader-review.googlesource.com/8448
Reviewed-by: Nico Weber <thakis@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoAdding OWNERS file for Chromium
Alexis Hetu [Thu, 12 Jan 2017 14:41:49 +0000 (09:41 -0500)]
Adding OWNERS file for Chromium

Whenever we land a SwiftShader related change in Chromium,
it will look for owners of SwiftShader to make sure the cl
is properly LGTMed before landing, so the file was added
here.

Also fixed a case typo in an rc file.

Change-Id: I282a39764654a08b06320360dd66a5d877f368d3
Reviewed-on: https://swiftshader-review.googlesource.com/8428
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
7 years agoFix SubzeroTest compilation.
Nicolas Capens [Tue, 10 Jan 2017 21:41:11 +0000 (16:41 -0500)]
Fix SubzeroTest compilation.

Change-Id: Ie5f7d782764fbc40d4e3ed9cdce0110bbb9da80d
Reviewed-on: https://swiftshader-review.googlesource.com/8408
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
7 years agoAdding swiftshader unittests to chromium
Alexis Hetu [Tue, 10 Jan 2017 21:58:04 +0000 (16:58 -0500)]
Adding swiftshader unittests to chromium

Chromium does not allow any third_party code to depend on base,
so the main test runner for swiftshader's tests in chromium can't
live inside the swiftshader repo. To solve this:

1) Added a test environment for swiftshader that will be used
for testing in chromium. Currently, it is simply empty.
2) Split unit tests in 2 files, unittests.cpp, which will
contain the tests ran by both chromium and swiftshader and
main.cpp, which will be used as the swiftshader test runner,
but NOT as the chromium test runner (that one will be added
in chromium at the same time I do the swiftshader update).
3) The BUILD.gn file was updated to make the chromium version
of the test depend on base and on the chromium version of the
swiftshader test runner (swiftshader_tests_main.cc, to be added).

Change-Id: I1128bb482565908bc285dcd6818d90d1d881a50e
Reviewed-on: https://swiftshader-review.googlesource.com/8409
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoExplicitly use the Microsoft ABI on Win32 builds.
Nicolas Capens [Mon, 9 Jan 2017 18:35:14 +0000 (13:35 -0500)]
Explicitly use the Microsoft ABI on Win32 builds.

PNaCl does not use the Microsoft x86-64 calling convention on Windows,
so the System V convention is the new default for Subzero. We need to
set a compile definition to explicitly request the use of the
Microsoft convention.

Change-Id: Ic70f5015d4b5753aa08a1247b6ac73eb9a9d278c
Reviewed-on: https://swiftshader-review.googlesource.com/8378
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoTry resolving existing X11 symbols before loading libX11.
Nicolas Capens [Thu, 22 Dec 2016 03:50:26 +0000 (22:50 -0500)]
Try resolving existing X11 symbols before loading libX11.

libX11 may have already been loaded (dynamically or statically) by the
application. Attempting to load it again could result in a different
version being loaded, causing various compatibility issues.

Bug b/32880157

Change-Id: Ica8e6b1c85b82469885a20dcef31e25e6b598132
Reviewed-on: https://swiftshader-review.googlesource.com/8348
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoSet the CMake default build type to Release.
Nicolas Capens [Mon, 9 Jan 2017 16:48:31 +0000 (11:48 -0500)]
Set the CMake default build type to Release.

CMake considers built-in configuration variables to be predefined, thus
setting CMAKE_BUILD_TYPE with a default value doesn't work because it
already exists. The FORCE attribute overrides it, but we have to guard
against overriding user-specified values.

Change-Id: Icf1cad6af15e788c5ae9ac8424f1ef0d29f9a1ff
Reviewed-on: https://swiftshader-review.googlesource.com/8377
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 determining the loop iteration count.
Nicolas Capens [Fri, 6 Jan 2017 22:22:13 +0000 (17:22 -0500)]
Fix determining the loop iteration count.

Bug b/34128224

Change-Id: I4aebcda840baa8ceef2ae99c98a80a83e32b89b3
Reviewed-on: https://swiftshader-review.googlesource.com/8376
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 a CMake option to build with Subzero.
Nicolas Capens [Fri, 6 Jan 2017 17:47:46 +0000 (12:47 -0500)]
Add a CMake option to build with Subzero.

This enables building with either LLVM or Subzero as the Reactor JIT
compiler back-end, on both Linux and Windows.

Change-Id: I4c052d224cd1302b7de412df58b07ee275ba924f
Reviewed-on: https://swiftshader-review.googlesource.com/8375
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
7 years agoImplement executable memory allocation for Subzero on Unix.
Nicolas Capens [Thu, 5 Jan 2017 21:31:06 +0000 (16:31 -0500)]
Implement executable memory allocation for Subzero on Unix.

Change-Id: I82b6a3f5336ca64dea30a8d9541fcf43c7ead81a
Reviewed-on: https://swiftshader-review.googlesource.com/8373
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 LLVM dependencies for Subzero on Android and Linux.
Nicolas Capens [Mon, 5 Dec 2016 22:30:34 +0000 (17:30 -0500)]
Add LLVM dependencies for Subzero on Android and Linux.

Change-Id: I3ad40f5c0f9faf8aa27356b72b4d98763b9711d7
Reviewed-on: https://swiftshader-review.googlesource.com/8372
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
7 years agoUpdate Subzero LLVM dependencies to 759dd39154f0bbf1adc87bf613c95f9564f64aa8
Nicolas Capens [Tue, 3 Jan 2017 19:02:05 +0000 (14:02 -0500)]
Update Subzero LLVM dependencies to 759dd39154f0bbf1adc87bf613c95f9564f64aa8

Change-Id: I03c5ebf799af288558d08190058d03f1ac2922b7
Reviewed-on: https://swiftshader-review.googlesource.com/8355
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 sample include directory and libraries.
Nicolas Capens [Wed, 26 Oct 2016 20:57:35 +0000 (16:57 -0400)]
Fix CMake sample include directory and libraries.

Change-Id: Ib1339f5a40523007ca5832ed1bc7b7d096e6c1f2
Reviewed-on: https://swiftshader-review.googlesource.com/8374
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoOnly add non-conformant configs on Android.
Nicolas Capens [Fri, 6 Jan 2017 14:41:21 +0000 (09:41 -0500)]
Only add non-conformant configs on Android.

This silences a benign assert in the config sorting operator which
checks for unique configs. On platforms other than Android, all of the
configs are marked as conformant.

Bug b/34029810

Change-Id: I600d67747ba24f153a0316609e5a783991093ebd
Reviewed-on: https://swiftshader-review.googlesource.com/8388
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
7 years agoFix clamping viewport dimensions on specification.
Nicolas Capens [Thu, 5 Jan 2017 19:37:22 +0000 (14:37 -0500)]
Fix clamping viewport dimensions on specification.

The spec states that glViewport() silently clamps the viewport
width and height to GL_MAX_VIEWPORT_DIMS[0] and
GL_MAX_VIEWPORT_DIMS[1], respectively.

Bug b/34078120

Change-Id: Ifeec0d6b601ce8a3825796fa551eea1f46150002
Reviewed-on: https://swiftshader-review.googlesource.com/8371
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 integer overflow in rasterization.
Nicolas Capens [Thu, 5 Jan 2017 18:18:39 +0000 (13:18 -0500)]
Fix integer overflow in rasterization.

Rasterization of very large triangles was causing signed 32-bit
integer overflow due to multiplying two unsigned 12.4 fixed-point
coordinates. The equations have been reworked to only require
multiplication of 12.4 by 0.4 fixed-point.

Bug b/34078120

Change-Id: I227b81254559af04baf50fbfec6a7f123bd230e3
Reviewed-on: https://swiftshader-review.googlesource.com/8370
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
7 years agoOptimize flat triangle edge rasterization.
Nicolas Capens [Thu, 5 Jan 2017 15:11:01 +0000 (10:11 -0500)]
Optimize flat triangle edge rasterization.

Change-Id: Ibfd483ce3cba6ec036327b32cba1460d68f8c9e8
Reviewed-on: https://swiftshader-review.googlesource.com/3542
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
7 years agoFix the type used for structure field write masks.
Nicolas Capens [Wed, 4 Jan 2017 16:30:45 +0000 (11:30 -0500)]
Fix the type used for structure field write masks.

The index used to index into a structure (a scalar) used to have the
vector size of the resulting type. This changed recently to always be
1, so the field type size needs to be determined from the fields
themselves, which is also the type of the indexing result.

Change-Id: I2dc373d8d31b02c0f69879cb0a3feacd83d6e473
Reviewed-on: https://swiftshader-review.googlesource.com/8368
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
7 years ago[emulator] Delete VAOs starting from highest
Lingfeng Yang [Fri, 23 Dec 2016 02:00:35 +0000 (18:00 -0800)]
[emulator] Delete VAOs starting from highest

If VAOs are deleted starting from 0, then the
following happens when an app's context has
genned two VAO's that are both != 0,
and the first of the two nonzero VAOs
is the current one:

VAO 0
VAO 1 <- current
VAO 2

in context dtor loop over vao map:
delete vao 0 (done)
delete vao 1:
is current, so bind 0:
in bind 0, we create a new map entry since 0 was deleted
next loop iter deletes vao 0 again (done)
*** at this point, vao 0 pointer refers to freed memory ***
next loop iter wants to delete vao 2,
but the current vao is 0 and refers to freed memory.
then, in Context::deleteVertexArray:
if (getCurrentVertexArray()->name...) <- Segmentation fault (core dumped)

This CL deletes VAO 0 last.

Change-Id: Ifa606ad7517cd213f21606577d3bdd8d810b640d
Reviewed-on: https://swiftshader-review.googlesource.com/8350
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Lingfeng Yang <lfy@google.com>