OSDN Git Service

android-x86/external-swiftshader.git
5 years agoUpdate BUILD.gn configs to support ARM[64] builds.
Stephen Lanham [Fri, 7 Sep 2018 18:59:54 +0000 (11:59 -0700)]
Update BUILD.gn configs to support ARM[64] builds.

Bug: b/114402930
Change-Id: Id7eedc6b01f40d24188d514755d5c89689b24abb
Reviewed-on: https://swiftshader-review.googlesource.com/20568
Tested-by: Stephen Lanham <slan@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAdd LLVM 7.0 Android.mk
Logan Chien [Mon, 27 Aug 2018 02:49:24 +0000 (10:49 +0800)]
Add LLVM 7.0 Android.mk

Change-Id: Ic1ae2c2872cc9f270557a6d4b701f870f82bd3cf
Reviewed-on: https://swiftshader-review.googlesource.com/20479
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Logan Chien <loganchien@google.com>
5 years agoAdd LLVM 7.0 ARM/AArch64 backend to CMakeLists.txt
Logan Chien [Tue, 21 Aug 2018 07:14:16 +0000 (15:14 +0800)]
Add LLVM 7.0 ARM/AArch64 backend to CMakeLists.txt

Change-Id: Id4209bfe44d9040e36fe4ea654197211aa1c7ead
Reviewed-on: https://swiftshader-review.googlesource.com/20478
Tested-by: Logan Chien <loganchien@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoMove atomicExchange under PERF_PROFILE
Logan Chien [Mon, 27 Aug 2018 02:44:42 +0000 (10:44 +0800)]
Move atomicExchange under PERF_PROFILE

Change-Id: Id5ae40d4b072c57cac1a8e6e7767d3ca03deebe1
Reviewed-on: https://swiftshader-review.googlesource.com/20477
Tested-by: Logan Chien <loganchien@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAdd the unimplemented non-x86 code generator
Logan Chien [Fri, 24 Aug 2018 14:01:50 +0000 (22:01 +0800)]
Add the unimplemented non-x86 code generator

This commit fills in the unimplemented non-x86 (generic) code generator.

Change-Id: I189b0ea523ecd9b18c29ad6ed6fa3f798382295b
Reviewed-on: https://swiftshader-review.googlesource.com/20476
Tested-by: Logan Chien <loganchien@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoPort SwiftShader to LLVM 7.0
Logan Chien [Tue, 21 Aug 2018 01:34:28 +0000 (09:34 +0800)]
Port SwiftShader to LLVM 7.0

Change-Id: I89601ef9e42e56cfaeb1cd5ece4daa3f32b39950
Reviewed-on: https://swiftshader-review.googlesource.com/20475
Tested-by: Logan Chien <loganchien@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAdd LLVM 7.0 configs for Linux and Android
Logan Chien [Mon, 3 Sep 2018 09:54:14 +0000 (17:54 +0800)]
Add LLVM 7.0 configs for Linux and Android

Change-Id: Icbacb2f63402b1d1c42fc4287b50ed0a3010cd4d
Reviewed-on: https://swiftshader-review.googlesource.com/20474
Tested-by: Logan Chien <loganchien@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAdd LLVM 7.0 config generation script
Logan Chien [Tue, 21 Aug 2018 06:56:45 +0000 (14:56 +0800)]
Add LLVM 7.0 config generation script

Change-Id: Ic67a43f5090c5004324ab300ce799c1206f3c4e3
Reviewed-on: https://swiftshader-review.googlesource.com/20473
Tested-by: Logan Chien <loganchien@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAdd LLVM 7.0 git submodule
Logan Chien [Tue, 21 Aug 2018 02:05:15 +0000 (10:05 +0800)]
Add LLVM 7.0 git submodule

Change-Id: I80b675f939f7eae95ad2fa637e77fc8d988bed3a
Reviewed-on: https://swiftshader-review.googlesource.com/20472
Tested-by: Logan Chien <loganchien@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRefactor LLVM initialization code
Logan Chien [Mon, 3 Sep 2018 11:37:57 +0000 (19:37 +0800)]
Refactor LLVM initialization code

Change-Id: Ie944a14c1d4ae30d7e30f84408c598c9e021ea66
Reviewed-on: https://swiftshader-review.googlesource.com/20471
Tested-by: Logan Chien <loganchien@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoWrap call arguments with ARGS macro
Logan Chien [Fri, 31 Aug 2018 09:19:45 +0000 (17:19 +0800)]
Wrap call arguments with ARGS macro

Change-Id: I239c906851412a667d2ab241eb20d8045baffb8f
Reviewed-on: https://swiftshader-review.googlesource.com/20470
Tested-by: Logan Chien <loganchien@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRemove sw::Value, sw::BasicBlock, and sw::SwitchCases
Logan Chien [Fri, 31 Aug 2018 08:57:15 +0000 (16:57 +0800)]
Remove sw::Value, sw::BasicBlock, and sw::SwitchCases

This commit removes `sw::Value`, `sw::BasicBlock`, and
`sw::SwitchCases`.  In LLVM 7.0, `llvm::Value`, `llvm::BasicBlock`, and
`llvm::SwitchCases` become final classes, thus we cannot derive from
those classes.  Fortunately, we don't have to derive from them.  We can
explicitly cast the pointers instead.

Change-Id: I2dc74485ebf4b399f8a41bb8fa94b7d8d299009e
Reviewed-on: https://swiftshader-review.googlesource.com/20469
Tested-by: Logan Chien <loganchien@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRemove stale LLVM include path
Logan Chien [Fri, 31 Aug 2018 04:02:18 +0000 (12:02 +0800)]
Remove stale LLVM include path

This commit removes stale LLVM include path in D3D8.vcxproj and it
seems that D3D8 does not rely on this include path.

Change-Id: Ieea962ccede9174ef190e1023722f65382cd6ce3
Reviewed-on: https://swiftshader-review.googlesource.com/20468
Tested-by: Logan Chien <loganchien@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoFix Visual Studio SubzeroTest build.
Nicolas Capens [Fri, 7 Sep 2018 03:55:17 +0000 (23:55 -0400)]
Fix Visual Studio SubzeroTest build.

Bug swiftshader:116

Change-Id: I34a86262817a7892c8e717d76fe30adf492d99d9
Reviewed-on: https://swiftshader-review.googlesource.com/20528
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoGuard against out of bounds accesses caused by a large base level
Alexis Hetu [Tue, 4 Sep 2018 15:30:22 +0000 (11:30 -0400)]
Guard against out of bounds accesses caused by a large base level

A texture's base level can be any positive integer, but SwiftShader
stores texture levels in a array that has an implementation
dependent size (IMPLEMENTATION_MAX_TEXTURE_LEVELS). To avoid
accessing this array out of bounds, a class was added to make sure
all accesses to the array are done within its bounds.

Change-Id: I9b439018f209a47371bd2959ba847345326964dd
Reviewed-on: https://swiftshader-review.googlesource.com/20488
Tested-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoFix texture completeness test when using sampler objects.
Nicolas Capens [Fri, 7 Sep 2018 04:03:22 +0000 (00:03 -0400)]
Fix texture completeness test when using sampler objects.

When a sampler object is bound to a texture unit, it overrides the
texture's filter modes. A texture without mipmaps can thus be complete
even if it has a filter mode which requires mipmaps, if there's a
sampler object with a filter mode which doesn't require mipmaps.

Fixes https://github.com/google/filament/pull/220

Change-Id: I200c0bba467d904ac0fd6d93b935e052c47b2030
Reviewed-on: https://swiftshader-review.googlesource.com/20529
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Jeff McGlynn <jwmcglynn@google.com>
Tested-by: Jeff McGlynn <jwmcglynn@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoUse custom executable memory allocator.
Nicolas Capens [Thu, 6 Sep 2018 19:34:46 +0000 (15:34 -0400)]
Use custom executable memory allocator.

On Linux this enables using named memory maps to assist profiling.

Change-Id: I96c36cf7b892237f4f7ed921d01f33454a9398f0
Reviewed-on: https://swiftshader-review.googlesource.com/20508
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFix GL resource access thread safety
Chris Forbes [Fri, 31 Aug 2018 02:41:59 +0000 (19:41 -0700)]
Fix GL resource access thread safety

Add resource manager lock, and ContextPtr to automatically take it

Affects: Everything, dEQP-EGL.functional.sharing.gles2.multithread.*
Bug: b/112184433
Change-Id: Ifdc5b18c738f92bbab08217f672a8ed6093e1672
Reviewed-on: https://swiftshader-review.googlesource.com/20388
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoFix eglChooseConfig behavior to match CTS expectation
Chris Forbes [Sat, 1 Sep 2018 01:26:20 +0000 (18:26 -0700)]
Fix eglChooseConfig behavior to match CTS expectation

When multiple instances of the same attribute are provided, CTS expects
the last instance to win. Achieve this by:
1/ Reducing the attribute list in getConfigs()
2/ Adjusting the sort order's consideration of which color
components are "required" to allow a later 0 or EGL_DONT_CARE to
remove a component from consideration again.

Affects: dEQP-EGL.functional.choose_config.*
Bug: b/113679786

V2: Fix up the alignment I broke
V4: Style fix

Change-Id: If9375c9dc5aaadb0ee7b77ecf1e1098c82fa30ca
Reviewed-on: https://swiftshader-review.googlesource.com/20448
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoMove ConvertReadFormatType to utilities.
Nicolas Capens [Mon, 9 Apr 2018 20:27:20 +0000 (16:27 -0400)]
Move ConvertReadFormatType to utilities.

Bug swiftshader:104

Change-Id: Ifcdffd3f960d7bb4982495381465da15ef671c3f
Reviewed-on: https://swiftshader-review.googlesource.com/18429
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRemove quad-layout depth formats from sampler.
Nicolas Capens [Thu, 29 Mar 2018 18:50:24 +0000 (14:50 -0400)]
Remove quad-layout depth formats from sampler.

We can't sample from buffers with linear layout.

Bug swiftshader:104

Change-Id: I622786e9dac8faafeb7ef1745f02587bf43d67bd
Reviewed-on: https://swiftshader-review.googlesource.com/18168
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoImplement GL_NV_read_depth_stencil.
Nicolas Capens [Thu, 29 Mar 2018 18:29:55 +0000 (14:29 -0400)]
Implement GL_NV_read_depth_stencil.

Bug swiftshader:104

Change-Id: I9fcea0c76875de735c3bad0a5c587875d0ca4e26
Reviewed-on: https://swiftshader-review.googlesource.com/18089
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRefactor glReadPixels validation.
Nicolas Capens [Tue, 27 Mar 2018 21:24:38 +0000 (17:24 -0400)]
Refactor glReadPixels validation.

Bug swiftshader:104

Change-Id: I2e5ab18f400035ec3f2125fb001643ca1125c565
Reviewed-on: https://swiftshader-review.googlesource.com/18148
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoImplement GL_OES_fbo_render_mipmap.
Nicolas Capens [Fri, 23 Mar 2018 14:13:06 +0000 (10:13 -0400)]
Implement GL_OES_fbo_render_mipmap.

This enables binding any texture mipmap level as a framebuffer
attachment.

Bug swiftshader:104

Change-Id: I3d4ea637ddd38bb62ca1363fe2c69c569eea36e9
Reviewed-on: https://swiftshader-review.googlesource.com/18008
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoDocument build and test instructions.
Nicolas Capens [Fri, 3 Aug 2018 20:01:48 +0000 (16:01 -0400)]
Document build and test instructions.

Also automatically download git submodules with CMake.

Change-Id: I3da095f49d0a9c577ea5dbb50d3db951417f4755
Reviewed-on: https://swiftshader-review.googlesource.com/20088
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoConsider context promotion when validating share context
Chris Forbes [Fri, 31 Aug 2018 00:28:59 +0000 (17:28 -0700)]
Consider context promotion when validating share context

We were comparing a pre-promotion version with the post-promotion
version stored in the share context. This doesn't work.

Affects: dEQP-EGL.functional.sharing.*

Change-Id: I02c14681b7743c6aaef4404291ac52a48890832c
Reviewed-on: https://swiftshader-review.googlesource.com/20368
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoResolve conflicts on Android.bp/.mk when building with O
Greg Hartman [Thu, 30 Aug 2018 03:21:34 +0000 (20:21 -0700)]
Resolve conflicts on Android.bp/.mk when building with O

BUG: 113551166
Change-Id: I0646638710abfc84707ca42faea10f94c87c1f4b
Test: oc and pi build and boot
Reviewed-on: https://swiftshader-review.googlesource.com/20329
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Greg Hartman <ghartman@google.com>
5 years agoAllow SwiftShader to be moved to a non-default location
Greg Hartman [Thu, 30 Aug 2018 01:58:40 +0000 (18:58 -0700)]
Allow SwiftShader to be moved to a non-default location

BUG: 77218110
Change-Id: Iddaacc2d5fb826ad8b38b46cc9e7ef406b2cd01b
Test: oc and pi builds with I0646638710abfc84707ca42faea10f94c87c1f4b
Reviewed-on: https://swiftshader-review.googlesource.com/20328
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Greg Hartman <ghartman@google.com>
5 years agoChecking in Vulkan headers
Alexis Hetu [Thu, 30 Aug 2018 18:49:34 +0000 (14:49 -0400)]
Checking in Vulkan headers

These vulkan headers are copied directly from their repo:
https://github.com/KhronosGroup/Vulkan-Headers
commit db09f95ac00e44149f3894bf82c918e58277cfdb
Version 1.1.83
Apache License 2.0

Change-Id: I593b6267dd35092fc9be243ac5209d47103c9a9d
Reviewed-on: https://swiftshader-review.googlesource.com/20348
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoAndroid: Add Android.bp files for a host build.
Alistair Strachan [Fri, 23 Mar 2018 00:37:55 +0000 (17:37 -0700)]
Android: Add Android.bp files for a host build.

This makes it possible to build swiftshader for the host.

The target build also works but it has been disabled.

Change-Id: I8aecf931f4ebf72c06d4e3423e2eafea6bfa7f6c
Reviewed-on: https://swiftshader-review.googlesource.com/17988
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alistair Strachan <astrachan@google.com>
5 years agoAndroid: Add host versions of the Android platform headers.
Alistair Strachan [Sat, 24 Mar 2018 19:30:28 +0000 (12:30 -0700)]
Android: Add host versions of the Android platform headers.

These host versions will be used by a future change to enable
the build of SwiftShader on the host, using Android extensions,
without needing to pull in non-host-ported parts of the Android
framework.

These headers are derived from the framework versions, but modified
slightly to minimize their dependency on other headers, and to reduce
code size. If a feature is introduced in the platform that SwiftShader
needs, it will need to be added to these headers (however, even if these
headers were copies, they would still need to be updated.)

Change-Id: I51bf7a01fd782f724d98ff05930117ecacdcefb4
Reviewed-on: https://swiftshader-review.googlesource.com/18030
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alistair Strachan <astrachan@google.com>
5 years agoAndroid: Introduce ANDROID_HOST_BUILD and rework logging.
Alistair Strachan [Sat, 24 Mar 2018 19:24:00 +0000 (12:24 -0700)]
Android: Introduce ANDROID_HOST_BUILD and rework logging.

Avoid using the Android logger directly. Instead, use the Common/Debug
and OpenGL/common/debug paths instead, which abstracts away use of the
logger.

Add ANDRIOD_HOST_BUILD to tell the build we are building an Android
swiftshader, but minimizing the use of platform features such as the
logger.

Change-Id: Ic6c70843d947c568d0e29fe66c55af74b8559a59
Reviewed-on: https://swiftshader-review.googlesource.com/18028
Tested-by: Alistair Strachan <astrachan@google.com>
Reviewed-by: Greg Hartman <ghartman@google.com>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoUpdate googletest to latest revision.
Nicolas Capens [Fri, 17 Aug 2018 16:57:43 +0000 (12:57 -0400)]
Update googletest to latest revision.

Fixes Visual Studio build issues.

Bug swiftshader:115

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

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

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

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

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

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

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

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

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

Passes all tests in content_unittests.

Bug: chromium:739182

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

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

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

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

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

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

Bug swiftshader:114

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

Bug swiftshader:113

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

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

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

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

Also move uniform block index validation to the entry functions.

Bug b/111803744

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

malloc/free are being used if SWIFTSHADER_TRANSLATOR_DISABLE_POOL_ALLOC
is defined.

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

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

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

Bug chromium:863682

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

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

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

Bug chromium:861882
Bug chromium:824522

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

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

Bug chromium:860533

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

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

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

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

Bug chromium:860533

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

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

Bug chromium:860533

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

Avoid accessing null pointers when an X11 call fails.

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

Bug chromium:833229
Bug chromium:824522

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

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

Bug chromium:848035 chromium:860533

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

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

The spec states that:
If an effective internal format exists that has
   * the same component sizes as,
   * component sizes greater than or equal to, or
   * component sizes smaller than or equal to
 those of the source buffer's effective internal format (for all
 matching components in <internalformat>), that format is chosen for
 the new image array and this is the effective internal format of the
 new texel array.

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

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

Bug chromium:853424

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

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

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

Bug chromium:852537
Bug swiftshader:64

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

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

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

Bug chromium:720933

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

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

This prevents a potential null dereference.

Bug chromium:859775

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

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

Bug b/110884149

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

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

Bug b/110884149

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

EQUAL compares numeric values. Use STREQUAL instead.

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

Bug b/110884149

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

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

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

Bug swiftshader:45

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

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

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

Bug swiftshader:104

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

Bug chromium:853424

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

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

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

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

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

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

Bug swiftshader:45

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

Early returns were erroneous and were causing memory leaks

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

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

Bug swiftshader:69
Bug b/67872293

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

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

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

Bug b/110407478

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

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

Bug swiftshader:108

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

BUG=chromium:854817

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

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

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

Bug b/110185979
Bug b/72330874

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

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

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

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

Bug chromium:852641, chromium:851707

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

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

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

BUG=chromium:845700
R=capn

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

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

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

Bug b/67872293

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

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

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

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

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

Bug swiftshader:56

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

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

Bug chromium:846693

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

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

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

Bug chromium:849217

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

Added missing function declaration.

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

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

Bug chromium:847094

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

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

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

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

Bug chromium:848238

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

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

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

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

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

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

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

Change-Id: I73e3c11244a07e269684323ce76cc9700fe9c1aa
Reviewed-on: https://swiftshader-review.googlesource.com/19088
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
6 years agoUse official headers to define GL_ARB_texture_rectangle.
Nicolas Capens [Wed, 21 Mar 2018 18:25:19 +0000 (14:25 -0400)]
Use official headers to define GL_ARB_texture_rectangle.

Fixing https://github.com/KhronosGroup/OpenGL-Registry/pull/149 and
https://github.com/KhronosGroup/OpenGL-Registry/pull/183 enabled
including desktop OpenGL headers without conflicts, so we no longer
have to define enums for ARB extensions ourselves.

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

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

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

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

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

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

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

Bug chromium:845103

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

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

Bug chromium:845103

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

Previously only dynamic indexing of uniforms was supported.

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

Bug chromium:845103
Bug skia:7846

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

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

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

Bug chromium:845103
Bug skia:7846

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

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

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

Also remove some UNIMPLEMENTED's that were benign.

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

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

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

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

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

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

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

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

Use 1 GiB as the soft limit in OpenGL.

Bug chromium:835299

Change-Id: I9c5184002c1710e3923b549f8c21e7f6a516e1c7
Reviewed-on: https://swiftshader-review.googlesource.com/18869
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>