OSDN Git Service

android-x86/external-swiftshader.git
5 years agoImplement GL_MAX_PROGRAM_TEXEL_OFFSET and GL_MAX_TEXTURE_LOD_BIAS
Alexis Hetu [Wed, 16 Aug 2017 17:43:33 +0000 (13:43 -0400)]
Implement GL_MAX_PROGRAM_TEXEL_OFFSET and GL_MAX_TEXTURE_LOD_BIAS

- GL_MAX_PROGRAM_TEXEL_OFFSET and GL_MIN_PROGRAM_TEXEL_OFFSET were
  technically already properly implemented, since the spec mentions
  that the behavior outside of these limits is undefined, and
  SwiftShader has no actual hard limit for these parameters.
- GL_MAX_TEXTURE_LOD_BIAS also has no hard limit in SwiftShader,
  other than the limit imposed on LOD itself, so that limit was
  used for GL_MAX_TEXTURE_LOD_BIAS.

Change-Id: I60b15b7f7a0febbc3e6582caff6c6a414a5d4964
Reviewed-on: https://swiftshader-review.googlesource.com/11709
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoRemove /RTC1 for Windows Debug Builds
Robert Liao [Mon, 14 Aug 2017 17:51:58 +0000 (10:51 -0700)]
Remove /RTC1 for Windows Debug Builds

SwiftShader requests the optimized flags for debug buidls for
performance. This leads to an incompatible use of /O1 and /RTC1.

BUG=chromium:755195

Change-Id: I53b6f99a67d0b8d5fc5932b677ee278aca300702
Reviewed-on: https://swiftshader-review.googlesource.com/11594
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Robert Liao <robliao@chromium.org>
5 years agoBuild with a newer version of XCode.
Nicolas Capens [Sat, 12 Aug 2017 12:49:04 +0000 (08:49 -0400)]
Build with a newer version of XCode.

Travis CI by default uses XCode 7.3 on Mac OS X, which does not support
the C++11 thread_local keyword expected by Subzero. Request XCode 8 GM
instead.

Change-Id: I0afa7804997ff5b5a6bbfe7829ba6134fe3d54ca
Reviewed-on: https://swiftshader-review.googlesource.com/11548
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRestrict the Travis CI Linux distro to Trusty.
Nicolas Capens [Sat, 12 Aug 2017 03:21:29 +0000 (23:21 -0400)]
Restrict the Travis CI Linux distro to Trusty.

matrix.include adds to the default builds which use Ubuntu Precise
which doesn't come with C++11 support by default.

Change-Id: I3c009bedc62aefd3363f749bb3cb22e9bc36fb9a
Reviewed-on: https://swiftshader-review.googlesource.com/11528
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoEnable Travis CI builds on Mac OS X.
Nicolas Capens [Fri, 11 Aug 2017 21:07:51 +0000 (17:07 -0400)]
Enable Travis CI builds on Mac OS X.

Change-Id: I36a39720b34ccc58276f9943bf6ef289b1af9b1e
Reviewed-on: https://swiftshader-review.googlesource.com/11511
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRestrict building Subzero to Marshmallow and up.
Nicolas Capens [Thu, 10 Aug 2017 20:57:25 +0000 (16:57 -0400)]
Restrict building Subzero to Marshmallow and up.

Subzero requires full C++11 support, which isn't available on Android
versions prior to Marshmallow.

Change-Id: Icf09a51b525a1503f72441c969a9e364306096bd
Reviewed-on: https://swiftshader-review.googlesource.com/11488
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAlways produce an optimized library on Chromium
Alexis Hetu [Thu, 10 Aug 2017 17:52:42 +0000 (13:52 -0400)]
Always produce an optimized library on Chromium

The SwiftShader library, when used to render Layout Tests in Debug,
causes too many timeouts. For that reason, we need the Debug version
of the library have better overall performance. In Debug, the
"default_optimization" defaults to "no_optimization". See:
https://cs.chromium.org/chromium/src/build/config/compiler/BUILD.gn?l=1698
In Release, "default_optimization" defaults to "optimize", so in
order to at least use the same optimization flags in both case, we
replace "default_optimization" by "optimize" in Debug.

The Win 7 (dbg) bot ran successfully with this change (the
telemetry_tests were failing when building the full Release version
of the SwiftShader library with the Debug version of Chromium).

Change-Id: I3529160b539319e26f9898d2588536d378c3ee01
Reviewed-on: https://swiftshader-review.googlesource.com/11469
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoRestrict GLSL globals to be initialized with constant expressions.
Nicolas Capens [Thu, 7 Apr 2016 05:03:14 +0000 (01:03 -0400)]
Restrict GLSL globals to be initialized with constant expressions.

This follows the GLSL ES 1.0 and 3.0 specs more strictly.

Change-Id: I323e90ef0a1588109e2cb7988136a9520e501a6d
Reviewed-on: https://swiftshader-review.googlesource.com/5065
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoEliminate unnecessary inverse masks.
Nicolas Capens [Tue, 26 May 2015 06:09:27 +0000 (02:09 -0400)]
Eliminate unnecessary inverse masks.

~mask[i % size] is the same as mask[~i % size] because it's just an
expansion of i, so there's no need for invMask[] to store the former.

Change-Id: I754732a2c4978281d35037941ecb74448ab78a8e
Reviewed-on: https://swiftshader-review.googlesource.com/3258
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoFixed D3DQUERYTYPE_TIMESTAMP behaviour.
Branimir Karadžić [Fri, 1 Jul 2016 16:34:28 +0000 (09:34 -0700)]
Fixed D3DQUERYTYPE_TIMESTAMP behaviour.

A timestamp query records the current time when it's issued, not when
the data is being retrieved.

Change-Id: Idb6e7fe6736a5b54bd23ef1613eaf953da86aa08
Reviewed-on: https://swiftshader-review.googlesource.com/5771
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoSkeleton for Ozone FrameBuffer implementation
Alexis Hetu [Tue, 8 Aug 2017 15:31:11 +0000 (11:31 -0400)]
Skeleton for Ozone FrameBuffer implementation

This cl simply makes the code compile on Ozone. It does not implement
the FrameBufferOzone class, but provides a skeleton for it, which can
be implemented by people on the ChromeOS team.

Change-Id: Ib77e20b00e8208d992c80f47b5ba55e00254c812
Reviewed-on: https://swiftshader-review.googlesource.com/11348
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRollback debug specific changes to build files
Alexis Hetu [Tue, 8 Aug 2017 12:31:13 +0000 (08:31 -0400)]
Rollback debug specific changes to build files

There's an issue with the new debug specific path in the build files.
Rolling back these changes in order to do the DEPS roll while the
investigation on this issue continues.

Change-Id: I9c2174d3ec2ab4e8f817c7cae32f69af1728c6c2
Reviewed-on: https://swiftshader-review.googlesource.com/11328
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoGeneralize 4x32-bit vector swizzling.
Nicolas Capens [Fri, 20 Jan 2017 16:34:37 +0000 (11:34 -0500)]
Generalize 4x32-bit vector swizzling.

This enables swizzling of Int4 and UInt4 types using swizzle operators.

Change-Id: I83fe5b472433d84a7b092e18eb78a919fb39b03b
Reviewed-on: https://swiftshader-review.googlesource.com/8530
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoLog an error when unsupported Android pixel formats are used.
Nicolas Capens [Fri, 4 Aug 2017 21:19:08 +0000 (17:19 -0400)]
Log an error when unsupported Android pixel formats are used.

Known projects avoid using HAL_PIXEL_FORMAT_RGB_888 because we have no
immediate desire to support it (for performance reasons), but other
users may run into unexpected issues that previously would leave no
trace.

Change-Id: Idc606809117f8e0b200b4b38c58ba24696e7193c
Reviewed-on: https://swiftshader-review.googlesource.com/11311
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoCheck against sRGB formats for eglBindTexImage().
Nicolas Capens [Fri, 4 Aug 2017 13:13:37 +0000 (09:13 -0400)]
Check against sRGB formats for eglBindTexImage().

We currently don't support EGL configs/surfaces with sRGB formats.

Change-Id: Ie23a5121bec784fe807c03feae19442fece3f1d7
Reviewed-on: https://swiftshader-review.googlesource.com/11268
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoEGL header fix for OZONE
Alexis Hetu [Fri, 4 Aug 2017 17:26:44 +0000 (13:26 -0400)]
EGL header fix for OZONE

This should allow to compile on the OZONE platform
without hitting the X11 include library problem.

The change is imported from:
https://cs.chromium.org/chromium/src/third_party/khronos/EGL/eglplatform.h

Change-Id: I3b3acc139865797ce6c4173991f15840e91f5935
Reviewed-on: https://swiftshader-review.googlesource.com/11308
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoUpdate EGL and KHR headers to Khronos's current version
Alexis Hetu [Fri, 4 Aug 2017 18:13:01 +0000 (14:13 -0400)]
Update EGL and KHR headers to Khronos's current version

Updated EGL and KHR headers as is, with one minor patch
applied in the ANDROID section of the eglplatform.h files.
Other files are unmodified from their Khronos version.

Change-Id: I2147df6bf36c7ec4c5cd6d32f8863b512a356112
Reviewed-on: https://swiftshader-review.googlesource.com/11310
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoEnable Subzero on ChromeOS
Alexis Hetu [Fri, 4 Aug 2017 17:29:28 +0000 (13:29 -0400)]
Enable Subzero on ChromeOS

Switching SwiftShader on ChromeOS from LLVM to Subzero.

Change-Id: Ica9ac278272f99b94d365f03fbd7a4860ad3503d
Reviewed-on: https://swiftshader-review.googlesource.com/11309
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoFixed some function signatures
Alexis Hetu [Thu, 2 Jun 2016 15:50:47 +0000 (11:50 -0400)]
Fixed some function signatures

Fixed a few types in function signatures so that base and
derived classes signatures match.

Change-Id: Ide9b9c78ff05be785b512451a36c836f35bd1f3d
Reviewed-on: https://swiftshader-review.googlesource.com/5463
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoFixed 'truncation of constant value' warning
Alexis Hetu [Fri, 4 Aug 2017 15:48:17 +0000 (11:48 -0400)]
Fixed 'truncation of constant value' warning

Change-Id: I4e0e956bd34f5ec2a3c38208cb99ac476ec26623
Reviewed-on: https://swiftshader-review.googlesource.com/11290
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAdd libnativewindow dependency.
Nicolas Capens [Thu, 3 Aug 2017 19:53:25 +0000 (15:53 -0400)]
Add libnativewindow dependency.

The functions relating to ANativeWindow have been split off from
libandroid into libnativewindow as part of project Treble.

Change-Id: I59850e4ba4145e49735698901dc2ba3480c68509
Reviewed-on: https://swiftshader-review.googlesource.com/11229
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoSuppress attributes warnings.
Nicolas Capens [Fri, 4 Aug 2017 13:40:46 +0000 (09:40 -0400)]
Suppress attributes warnings.

Older compiler versions warned about unknown attributes with
-Wattributes instead of -Wunknown-attributes. Use both and suppress
warnings about unknown warnings options too.

Change-Id: I22252426e73d4984471b9b8415479bd7b57ba0c5
Reviewed-on: https://swiftshader-review.googlesource.com/11289
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRefactor Android includes.
Nicolas Capens [Fri, 4 Aug 2017 13:36:32 +0000 (09:36 -0400)]
Refactor Android includes.

Forward declare ANativeWindow, and remove <hardware/gralloc.h> where
GrallocAndroid.hpp already includes it.

Change-Id: Idebd4c40280960ff00cd51b6633c1c84a8cf7de2
Reviewed-on: https://swiftshader-review.googlesource.com/11288
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoWork around stlport build bug.
Nicolas Capens [Fri, 4 Aug 2017 13:33:04 +0000 (09:33 -0400)]
Work around stlport build bug.

Older versions of Android using stlport were failing to compile with an
"assert has been defined before inclusion of assert.h header" error.

Change-Id: If8e13eb08c35a34d082d99f8f57188bc55697f59
Reviewed-on: https://swiftshader-review.googlesource.com/11270
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoUpdate eglplatform.h to match Android NDK.
Nicolas Capens [Fri, 4 Aug 2017 13:18:52 +0000 (09:18 -0400)]
Update eglplatform.h to match Android NDK.

This change has been part of the Android NDK since API 18, corresponding
with Android 4.3 Jelly Bean MR2.

Change-Id: I6df06f46c286ce89ea56913684e43d558917d1a8
Reviewed-on: https://swiftshader-review.googlesource.com/11269
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoMerge recent changes from LLVM's lib/Support/Atomic.cpp
Nico Weber [Thu, 3 Aug 2017 20:13:45 +0000 (16:13 -0400)]
Merge recent changes from LLVM's lib/Support/Atomic.cpp

In particular, https://reviews.llvm.org/D36281

Bug: chromium:495204
Change-Id: I48afb5b8dd594ce1b43c6ca9fb20638d40119236
Reviewed-on: https://swiftshader-review.googlesource.com/11248
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nico Weber <thakis@google.com>
5 years agoChanged 'optimize_max' for 'optimize' compile option on Chromium
Alexis Hetu [Thu, 3 Aug 2017 19:15:58 +0000 (15:15 -0400)]
Changed 'optimize_max' for 'optimize' compile option on Chromium

The 'optimize_max' option is not meant to be used by default for
Release builds. These use the 'optimize' config. See comment here
for explanation:
https://cs.chromium.org/chromium/src/build/config/compiler/BUILD.gn?l=1572

Change-Id: I7af8e3e4c7e92c60f38841b75998e2b488a5ffde
Reviewed-on: https://swiftshader-review.googlesource.com/11228
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoImplement GL_OES_vertex_half_float.
Nicolas Capens [Thu, 3 Aug 2017 16:53:47 +0000 (12:53 -0400)]
Implement GL_OES_vertex_half_float.

This enables using half-float vertex data for OpenGL ES 2.0.
Note that GL_HALF_FLOAT_OES does not have the same value as
GL_HALF_FLOAT.

Change-Id: I0a7a55b7904fe797cdbb86627c8d0a1cc07d2d0a
Reviewed-on: https://swiftshader-review.googlesource.com/1500
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAttempt to fix the MacOS build
Alexis Hetu [Wed, 2 Aug 2017 21:00:55 +0000 (17:00 -0400)]
Attempt to fix the MacOS build

On the mac_optional_gpu_tests_rel bot, a -Wall flag cancels out the
-Wno-unused-local-typedef warning suppression and causes the build
to fail. Attempting to reorder the configs order to solve the issue.

Change-Id: Ic790f5cb7803be4749616d826e1368ef76e2c889
Reviewed-on: https://swiftshader-review.googlesource.com/11212
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoGL_R11F_G11F_B10F is a color renderable format in OpenGL ES 3.0
Alexis Hetu [Wed, 2 Aug 2017 20:36:30 +0000 (16:36 -0400)]
GL_R11F_G11F_B10F is a color renderable format in OpenGL ES 3.0

GL_R11F_G11F_B10F was missing from a utility function, causing some
dEQP tests to fail. Simply adding it fixes most R11F_G11F_B10F
related tests in:
functional.fbo.*
functional.fragment_out.*
functional.pbo.*

Change-Id: I0d77f1c9c01aff106e266853e81b4cf45f748bc1
Reviewed-on: https://swiftshader-review.googlesource.com/11211
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoExtra warnings suppression for Chromium
Alexis Hetu [Wed, 2 Aug 2017 20:06:29 +0000 (16:06 -0400)]
Extra warnings suppression for Chromium

A few more warnings suppression were missing after the last build
file change. Added them here to hopefully fix build issues.

Change-Id: I80371a3ae59920dccf9c64a36c96d0341e7e39f5
Reviewed-on: https://swiftshader-review.googlesource.com/11210
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRemoved extra '-Wall' flag
Alexis Hetu [Wed, 2 Aug 2017 17:25:10 +0000 (13:25 -0400)]
Removed extra '-Wall' flag

The '-Wall' flag is already specified in Chromium and this '-Wall'
flag invalidates any previous '-Wno-*' flags. Removing it solves
the compilation issue.

Change-Id: Iceefb63ff7e04c55884cf26bbde0d62ffb74b217
Reviewed-on: https://swiftshader-review.googlesource.com/11208
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoSwiftShader always builds its release version in Chromium
Alexis Hetu [Wed, 2 Aug 2017 12:40:37 +0000 (08:40 -0400)]
SwiftShader always builds its release version in Chromium

SwiftShader's debug version was too slow for Chromium's debug
trybots. To solve this issue, SwiftShader now always builds
its release version in Chromium.

'git cl format' was ran in Chromium to ensure proper formatting
of the gn files.

Change-Id: I346045b68b566813ab6ab739aaa6eeb243d51853
Reviewed-on: https://swiftshader-review.googlesource.com/11188
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRefactor sampleTexel() to use a return value.
Nicolas Capens [Tue, 1 Aug 2017 21:00:36 +0000 (17:00 -0400)]
Refactor sampleTexel() to use a return value.

We can rely on return value optimization to return Reactor types at the
same cost as passing them by reference.

Change-Id: I9f092bcefd17131a07bef32032c5f2ab98392328
Reviewed-on: https://swiftshader-review.googlesource.com/10569
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoFixed loading GL_RGB10_A2UI texture format
Alexis Hetu [Tue, 1 Aug 2017 20:49:17 +0000 (16:49 -0400)]
Fixed loading GL_RGB10_A2UI texture format

The GL_RGB10_A2UI was being unpacked as a double sized version of
GL_UNSIGNED_SHORT_5_5_5_1, which it is not. The channels are not
stored in the same order for these 2 formats.

This fixes all "rgb10_a2ui" related test in:
dEQP-GLES3.functional.texture.format.sized.*
dEQP-GLES3.functional.texture.specification.*

Change-Id: I0d398d0537a440906e9ef3aeb01fe4e782f778b6
Reviewed-on: https://swiftshader-review.googlesource.com/11168
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRemove recursive Chromium DEPS file.
Nicolas Capens [Thu, 4 May 2017 16:09:19 +0000 (12:09 -0400)]
Remove recursive Chromium DEPS file.

Chromium pulled Subzero into third_party/pnacl-subzero using the recursive
DEPS file. We now have the Subzero source code in the SwiftShader repository
using Git subtree.

Bug swiftshader:47

Change-Id: I2c4c5e8c3413ccd187e4da11fbd014fb76ec572f
Reviewed-on: https://swiftshader-review.googlesource.com/9628
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoUse unorderer_map<> for def/use information.
Nicolas Capens [Tue, 1 Aug 2017 03:12:19 +0000 (23:12 -0400)]
Use unorderer_map<> for def/use information.

Bug swiftshader:69

Change-Id: Ib4611e2326741688969137f0610980f899b8ee48
Reviewed-on: https://swiftshader-review.googlesource.com/11148
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoEmulate 64-bit vectors using 128-bit vectors.
Nicolas Capens [Fri, 28 Jul 2017 21:30:51 +0000 (17:30 -0400)]
Emulate 64-bit vectors using 128-bit vectors.

This effectively eliminates all use of MMX instructions, using SSE ones
instead.

Bug swiftshader:78

Change-Id: I3e519a0c5172688ff711654bf430a9d1dd058d0b
Reviewed-on: https://swiftshader-review.googlesource.com/11049
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAssume SSE2 support is available.
Nicolas Capens [Fri, 28 Jul 2017 21:26:14 +0000 (17:26 -0400)]
Assume SSE2 support is available.

Chrome and many other products require SSE2 support as a minimum. Note
that MMX checks are left in place for now. Dead code paths are removed.

Bug swiftshader:78

Change-Id: Iabd8b1dc2092949d5dba29a78e75d014e808f12c
Reviewed-on: https://swiftshader-review.googlesource.com/11068
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAbstract LLVM types to enable emulation.
Nicolas Capens [Wed, 26 Jul 2017 21:26:17 +0000 (17:26 -0400)]
Abstract LLVM types to enable emulation.

This is just a refactoring, where the 'emulated' types still map to
the same types as before. They are represented using small integer
values reinterpret-casted as sw::Type*, while non-emulated types
correspond directly to llvm::Type pointers.

Bug swiftshader:78

Change-Id: I88c0b932a45119ce500821068d8fb5faa2ccbb92
Reviewed-on: https://swiftshader-review.googlesource.com/11048
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAssume local variables are naturally aligned.
Nicolas Capens [Wed, 26 Jul 2017 17:34:36 +0000 (13:34 -0400)]
Assume local variables are naturally aligned.

Using alignment = 0 to signify natural alignment will allow to discern
between loads/stores for stack variables, and dereferencing generic
pointers.

Bug swiftshader:78

Change-Id: I6d9c1728fb9858ca57380bc6bfafc7fb2fa5feae
Reviewed-on: https://swiftshader-review.googlesource.com/10968
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRemove sub-vector load/store address hack.
Nicolas Capens [Thu, 27 Jul 2017 18:21:46 +0000 (14:21 -0400)]
Remove sub-vector load/store address hack.

The Optimizer used to assume that loads and stores using the same
address are of the same tpe. This is false for emulated sub-vector
load/store, and thus we tricked it into thinking the addresses are
different by performing some redundant arithmetic. This is no longer
necessary now that the Optimizer checks the types being loaded/stored.

Bug swiftshader:48

Change-Id: Ic212d67fefd9e8dd902ff576b69458208c3c379d
Reviewed-on: https://swiftshader-review.googlesource.com/11088
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoGLSL bitwise NOT implementation
Alexis Hetu [Fri, 28 Jul 2017 17:43:25 +0000 (13:43 -0400)]
GLSL bitwise NOT implementation

The bitwise NOT operation is supported for integer types in GLSL.
All the plumbing was already there, only the actual call was missing.

In dEQP, all shaders.operator.unary_operator.bitwise_not tests pass.

Change-Id: I938104b860441f6b2df6c807d578f651e5cd2516
Reviewed-on: https://swiftshader-review.googlesource.com/11108
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agogl_VertexID implementation
Alexis Hetu [Tue, 25 Jul 2017 21:48:00 +0000 (17:48 -0400)]
gl_VertexID implementation

This cl implements support for gl_VertexID.

Passes the functional.shaders.builtin_variable.vertex_id test.

Change-Id: I5550e3ecba30e29f1e38ace608d730833a1e9598
Reviewed-on: https://swiftshader-review.googlesource.com/10958
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoFix sign masks of narrow vectors.
Nicolas Capens [Wed, 26 Jul 2017 17:50:04 +0000 (13:50 -0400)]
Fix sign masks of narrow vectors.

The SignMask intrinsic returns the most significant bit of each byte in
a 128-bit vector. For 'emulated' 8-byte vectors we expect the upper
half to be ignored.

Change-Id: I994e35fb9c21710c35a89add42297c3c9bad07a4
Reviewed-on: https://swiftshader-review.googlesource.com/10988
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoEmulate vector square root intrinsic.
Nicolas Capens [Tue, 25 Jul 2017 21:26:14 +0000 (17:26 -0400)]
Emulate vector square root intrinsic.

Bug b/64034197

Change-Id: I2d77dcb2f93b21abeb0eac1dcb8ca02ef6e5796b
Reviewed-on: https://swiftshader-review.googlesource.com/10957
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoEmulate MultiplyAddPairs intrinsic.
Nicolas Capens [Tue, 25 Jul 2017 19:32:12 +0000 (15:32 -0400)]
Emulate MultiplyAddPairs intrinsic.

Bug b/37496078

Change-Id: I2940cee7a7b174c98f28282831c414c1f524702d
Reviewed-on: https://swiftshader-review.googlesource.com/10933
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoEmulate MultiplyHigh intrinsics.
Nicolas Capens [Tue, 25 Jul 2017 19:32:12 +0000 (15:32 -0400)]
Emulate MultiplyHigh intrinsics.

Bug b/37496856

Change-Id: Ifea992edcb97d178e079a39d2a1b6b604cfa657e
Reviewed-on: https://swiftshader-review.googlesource.com/10956
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoEmulate vector packing intrinsics.
Nicolas Capens [Tue, 25 Jul 2017 19:32:12 +0000 (15:32 -0400)]
Emulate vector packing intrinsics.

Bug b/37496082

Change-Id: I993f34baf6169b0bc3c37742f6238dba38a67d0a
Reviewed-on: https://swiftshader-review.googlesource.com/10955
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoEmulate saturated vector add/subtract.
Nicolas Capens [Tue, 25 Jul 2017 19:32:12 +0000 (15:32 -0400)]
Emulate saturated vector add/subtract.

Bug b/37495545

Change-Id: I767f7b5555706cd42b80863fe1ae04b36f4f1189
Reviewed-on: https://swiftshader-review.googlesource.com/10932
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoEmulate SignMask intrinsics.
Nicolas Capens [Tue, 25 Jul 2017 19:32:12 +0000 (15:32 -0400)]
Emulate SignMask intrinsics.

Bug b/37496809

Change-Id: I34d0d511bd50890c36d292ab431115f5d2e65a58
Reviewed-on: https://swiftshader-review.googlesource.com/9492
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoEmulate vector shift by immediate intrinsics.
Nicolas Capens [Tue, 25 Jul 2017 19:32:12 +0000 (15:32 -0400)]
Emulate vector shift by immediate intrinsics.

Bug b/37496338

Change-Id: I01e4aaf49e86d9c2f11647a0e84bf1ee388a90cf
Reviewed-on: https://swiftshader-review.googlesource.com/10931
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoEmulate sub-vector load/store intrinsics.
Nicolas Capens [Wed, 26 Apr 2017 17:36:33 +0000 (13:36 -0400)]
Emulate sub-vector load/store intrinsics.

Bug b/37496321

Change-Id: I173b458a0d1d477ad75deaa33508ae1766c182c0
Reviewed-on: https://swiftshader-review.googlesource.com/9491
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoDefault to Subzero for ARM CMake build.
Nicolas Capens [Tue, 25 Jul 2017 19:31:45 +0000 (15:31 -0400)]
Default to Subzero for ARM CMake build.

Change-Id: I4eaee73caca1e2552cd63901a6c9107efbeaa2f8
Reviewed-on: https://swiftshader-review.googlesource.com/10930
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoSupport bitcasts between scalars and short vectors.
Nicolas Capens [Tue, 25 Jul 2017 17:56:46 +0000 (13:56 -0400)]
Support bitcasts between scalars and short vectors.

Subzero only supports 128-bit vectors currently, but we need to support
bitcasting between scalars and (emulated) short vectors of the same
size. Subzero implicitly supports it on x86 by using movd instructions,
but on ARM we have to emulate it in Reactor until support for it is
added in Subzero.

Bug swiftshader:48

Change-Id: I95accbc3665815a46dac8e52ce30939ac64aaf44
Reviewed-on: https://swiftshader-review.googlesource.com/10929
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoReplace only loads matching the store type.
Nicolas Capens [Tue, 25 Jul 2017 17:24:40 +0000 (13:24 -0400)]
Replace only loads matching the store type.

If a load uses the same address as a previous store, we can only
replace it with the store's data when their types match. Also,
stores can only be eliminated when all the loads following them have
been replaced.

Bug swiftshader:48

Change-Id: I5968b256cb295243c30df3598e49015bccb5bff1
Reviewed-on: https://swiftshader-review.googlesource.com/10950
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoDon't eliminate wide store followed by a narrow one.
Nicolas Capens [Tue, 25 Jul 2017 16:57:12 +0000 (12:57 -0400)]
Don't eliminate wide store followed by a narrow one.

If the previous store operation is wider than the next one, we can't
eliminate it because there could be a subsequent wide load reading its
non-overwritten data.

Bug swiftshader:48

Change-Id: Iccb9cabad8ab8503140061ec4ce711a2959de33d
Reviewed-on: https://swiftshader-review.googlesource.com/10948
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRefactor checking for sub-vector intrinsics.
Nicolas Capens [Wed, 26 Jul 2017 15:30:33 +0000 (11:30 -0400)]
Refactor checking for sub-vector intrinsics.

Bug swiftshader:48

Change-Id: I05352fd64cb2e5a929295ff6a8f6196da7fdbb4b
Reviewed-on: https://swiftshader-review.googlesource.com/10949
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoFix RValue<T> construction from incorrect types.
Nicolas Capens [Mon, 24 Jul 2017 20:54:44 +0000 (16:54 -0400)]
Fix RValue<T> construction from incorrect types.

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

Bug swiftshader:48

Change-Id: I5073091524d2f56681dab052c9f84a06b3be7b4f
Reviewed-on: https://swiftshader-review.googlesource.com/10908
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAdd license badge.
Nicolas Capens [Wed, 26 Jul 2017 17:55:52 +0000 (13:55 -0400)]
Add license badge.

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

glGetString wasn't returning es3 specific extensions.

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

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

Bug chromium:746914

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

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

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

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

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

Bug swiftshader:77

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

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

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

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

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

Bug swiftshader:76

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

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

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

Bug swiftshader:76

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

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

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

Bug swiftshader:76

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

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

Bug swiftshader:71

Change-Id: Ie7a1da6b93cb5fbed018b61cf8510393964b5aa4
Reviewed-on: https://swiftshader-review.googlesource.com/10450
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAdd texture filtering precision hint
Alexis Hetu [Tue, 18 Jul 2017 18:33:04 +0000 (14:33 -0400)]
Add texture filtering precision hint

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

Bug swiftshader:76

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

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

Bug chromium:737384

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

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

Bug swiftshader:76

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

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

Bug swiftshader:75

Change-Id: Ia45e49e77a6076e8f9f12ad74c6ad50dbdbf2dbd
Reviewed-on: https://swiftshader-review.googlesource.com/10688
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoFix Frac() returning 1.0.
Nicolas Capens [Mon, 17 Jul 2017 14:27:33 +0000 (10:27 -0400)]
Fix Frac() returning 1.0.

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

Bug swiftshader:74

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

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

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

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

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

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

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

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

Bug b/63147516

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

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

Bug chromium:738298

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

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

Bug b/25629882

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

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

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

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

Bug chromium:737875

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

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

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

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

Bug chromium:732739

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

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

Bug chromium:732691

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

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

Bug swiftshader:70

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

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

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

Bug chromium:732691

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

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

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

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

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

Bug chromium:736639

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

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

Bug swiftshader:65

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

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

Bug chromium:735920

Change-Id: Icb4f484970ec75b8c5e7e784ce37e05ee4fbc7db
Reviewed-on: https://swiftshader-review.googlesource.com/10288
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
5 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>
5 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>
5 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>