OSDN Git Service

4 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>
4 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>
4 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>
4 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>
4 years agoExpose suffixed versions of VertexAttribDivisor
Adrienne Walker [Wed, 20 Jun 2018 22:43:05 +0000 (15:43 -0700)]
Expose suffixed versions of VertexAttribDivisor


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>
4 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>
4 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>
4 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>
4 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

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>
4 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


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>
4 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>
4 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>
4 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.


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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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.


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>
4 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>
4 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>
4 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

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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 years agoAccept GL_TEXTURE_MAX_ANISOTROPY_EXT for samplers.
Krzysztof Kosiński [Fri, 18 May 2018 02:20:47 +0000 (19:20 -0700)]

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>
4 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>
4 years agoRefactor surface buffer size calculation.
Nicolas Capens [Tue, 8 May 2018 21:20:50 +0000 (17:20 -0400)]
Refactor surface buffer size calculation.

This eliminates the duplication between pitchB() and size(), and
ensures that the latter is the full allocation size.

Bug chromium:835299

Change-Id: Icf555ad497fb3b92fd00e9a3e6ced6810b2d310d
Reviewed-on: https://swiftshader-review.googlesource.com/18789
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoRefactor maximum texture dimensions.
Nicolas Capens [Tue, 8 May 2018 20:03:16 +0000 (16:03 -0400)]
Refactor maximum texture dimensions.

OpenGL has separate implementation-defined texture size limits, for
3D textures and array textures. For now just give them the same value.

Bug chromium:835299

Change-Id: Ifaf537511f016e21992388f56598d5ec12a393b8
Reviewed-on: https://swiftshader-review.googlesource.com/18788
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoIgnore glGenerateMipmap for unspecified or zero-sized textures.
Nicolas Capens [Tue, 15 May 2018 20:31:10 +0000 (16:31 -0400)]
Ignore glGenerateMipmap for unspecified or zero-sized textures.

https://gitlab.khronos.org/opengl/API/issues/72 was resolved to treat
these cases as a no-op and not generate an error.

Bug chromium:825545

Change-Id: Ic4cfbc728156bb88a6dc70486ae57c3e12ea43ae
Reviewed-on: https://swiftshader-review.googlesource.com/18870
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoFix glBlitFramebuffer validation for BGRA8 IOSurfaces
Alexis Hetu [Wed, 16 May 2018 17:03:41 +0000 (13:03 -0400)]
Fix glBlitFramebuffer validation for BGRA8 IOSurfaces

The format comparison for blitting from a multisampled buffer
was not ES2 specific, so the ES3 check was removed. That had
been added to fix blitting to the backbuffer on MacOS, which
is now instead fixed by allowing BGRA8 and RGBA8 to be
accepted interchangeably as draw and read formats.

Fixes dEQP-GLES3.functional.negative_api.buffer.blit_framebuffer_multisample

Change-Id: Id577372791007a780c542b0986378147e1e7bc1b
Reviewed-on: https://swiftshader-review.googlesource.com/18888
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
4 years agoFixed atan corner case
Alexis Hetu [Tue, 15 May 2018 18:07:19 +0000 (14:07 -0400)]
Fixed atan corner case

atan(0, <negative>) was returning 0 instead of PI. Did a simple
fix in the arctan() function and added an associated unit test.

Change-Id: Idbbdaf099b5104e3aaa2868ca8fd806c6c735981
Reviewed-on: https://swiftshader-review.googlesource.com/18868
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoImplement OES_vertex_array_object.
Krzysztof Kosiński [Fri, 11 May 2018 04:55:05 +0000 (21:55 -0700)]
Implement OES_vertex_array_object.

This extension works the same as OpenGL ES 3.0 vertex arrays, but requires
entry points with the OES suffix.

Change-Id: I82b92bbcec078f88becee6f3b37eb7e8256a1233
Reviewed-on: https://swiftshader-review.googlesource.com/18808
Tested-by: Krzysztof Kosiński <krzysio@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoRevert part of "Fix Linux build." to fix swiftshader_unittests
Alexis Hetu [Mon, 14 May 2018 12:16:05 +0000 (08:16 -0400)]
Revert part of "Fix Linux build." to fix swiftshader_unittests

The cl "Fix Linux build." broke swiftshader_unittests on Linux and
MacOS. Reverting part of that cl to fix swiftshader_unittests, and
hopefully keep the part of the cl that fixed the build originally.

Change-Id: I3126a12f12ca7337f18c758db16dd3542dcfc226
Reviewed-on: https://swiftshader-review.googlesource.com/18848
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoPitch fix for IO surfaces
Alexis Hetu [Fri, 11 May 2018 19:31:12 +0000 (15:31 -0400)]
Pitch fix for IO surfaces

On MacOS, a Surface constructor receiving the 'pitchPprovided'
parameter wasn't using it for the surface's external pitch,
which was causing an error when using the Image::getPitch()
function, which returns getExternalPitchB(). Image::getPitch()
is used within Image::loadImageData(), which is used by gl
functions like glTexImage2D() and glTexSubImage2D(). Both the
internal and external buffers now use the parameter to solve
this issue.

Bug b/19979104

Change-Id: I9762ed53b535ae9eb052f57ee1ceed8ee87cb29c
Reviewed-on: https://swiftshader-review.googlesource.com/18828
Tested-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoRectangle texture addressing fix
Alexis Hetu [Tue, 8 May 2018 18:25:40 +0000 (14:25 -0400)]
Rectangle texture addressing fix

Texture rectangle coordinates were clamped in the [0, dim - 1] range,
but should have been sampled in the [0.5, dim - 0.5 range] according
to the spec (a related comment was added in the code).

Also, by having getAddressingModeW() return ADDRESSING_LAYER for
rectangle textures, the 3rd texture coordinate computation will be
skipped entirely, preventing the temporary variable 'fv' from being

Change-Id: I4bbc30b2a2b747eae2f2a1dfb710a986bff7849b
Reviewed-on: https://swiftshader-review.googlesource.com/18768
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoAllocate executable memory backed by named mmaps on Linux.
Ian Rogers [Wed, 14 Feb 2018 23:39:25 +0000 (15:39 -0800)]
Allocate executable memory backed by named mmaps on Linux.

Executable heap memory can confuse profiling tools. Use memfd_create
on Linux, if possible, to create a named anonymous memory region.

Only enabled if LINUX_ENABLE_NAMED_MMAP is defined.

Bug b/73721724

Change-Id: I420711e4f64725ae834ab54264038683e4c445fe
Reviewed-on: https://swiftshader-review.googlesource.com/17208
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
4 years agoDon't flag temporary registers as used samplers.
Nicolas Capens [Fri, 4 May 2018 19:49:53 +0000 (15:49 -0400)]
Don't flag temporary registers as used samplers.

This fixes a undefined shift if the temporary register has an index
higher than 32 (also, we only have 16 samplers currently). For GLSL
we declare all actual sampler units during ASM output, so we don't
have to rely on analyzing the instructions afterwards (that is only
still relevant for Direct3D 8/9 shaders).

Change-Id: I11a58964d53fcc2c29e0ad923d9a4a4161a545f4
Reviewed-on: https://swiftshader-review.googlesource.com/18748
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoSkip ignored EGL config attributes.
Nicolas Capens [Wed, 18 Apr 2018 18:46:17 +0000 (14:46 -0400)]
Skip ignored EGL config attributes.

The EGL 1.4 spec description of eglChooseConfig states:
PIXELS, or EGL_NATIVE_VISUAL_ID are specified in attrib_list, then they
are ignored"

Change-Id: I9ec90eff692f9759aa54a0a10f1e57f2c244db7f
Reviewed-on: https://swiftshader-review.googlesource.com/18608
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoAccept GL_HALF_FLOAT and GL_HALF_FLOAT_OES interchangeably.
Nicolas Capens [Thu, 26 Apr 2018 20:38:05 +0000 (16:38 -0400)]
Accept GL_HALF_FLOAT and GL_HALF_FLOAT_OES interchangeably.

These enums don't have the same value, but this is only because of
desktop OpenGL and OpenGL ES having evolved separately. OpenGL ES 3.0
reconverged to use the enum name and value of desktop OpenGL.

Apps choosing between OpenGL ES 2.0 and 3.0 strictly speaking have to
use different enums, but many drivers already accept either enum so the
apps don't bother to differentiate them. Running them on a driver which
adheres more strictly to the (extension) specs would cause parameter
validation errors.

Additionally, native platform pixel formats such as
HAL_PIXEL_FORMAT_RGBA_FP16 on Android couldn't be mapped to GL_RGBA16F
with GL_HALF_FLOAT component types on an OpenGL ES 2.0 context if the
latter are considered OpenGL ES 3.0 only.

Change-Id: Ib66cba7444fe438c0e4a8a6454460773cf02236d
Reviewed-on: https://swiftshader-review.googlesource.com/18728
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoFix Linux build.
Nicolas Capens [Wed, 25 Apr 2018 20:26:17 +0000 (16:26 -0400)]
Fix Linux build.

We don't need protected visibility because we now have a version script
which hides all symbols except the ones we want to export.

Fixes ld linker errors:
 relocation R_X86_64_PC32 against protected symbol `libEGL_swiftshader' can not be used when making a shared object
 relocation R_X86_64_PC32 against protected symbol `libGLESv2_swiftshader' can not be used when making a shared object

Change-Id: I059c4b03f2523bf8caf08180b02a349d3cf7b2f2
Reviewed-on: https://swiftshader-review.googlesource.com/18708
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoUse the correct constant name for the Android SDK version
Jorge E. Moreira [Wed, 25 Apr 2018 00:05:10 +0000 (17:05 -0700)]
Use the correct constant name for the Android SDK version

Bug b/78194651

Change-Id: Iafe8728a3593b0bd48b9633261df4035d2e94117
Reviewed-on: https://swiftshader-review.googlesource.com/18668
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
4 years agoUse override for overridden function
Takuto Ikuta [Wed, 25 Apr 2018 13:57:42 +0000 (22:57 +0900)]
Use override for overridden function

Bug: chromium:428099
Change-Id: Ib070a540a3ef245e2828b277dcdabd5b973322f0
Reviewed-on: https://swiftshader-review.googlesource.com/18688
Tested-by: Takuto Ikuta <tikuta@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoFixed sampler within struct uniform used as function argument
Alexis Hetu [Tue, 24 Apr 2018 15:13:33 +0000 (11:13 -0400)]
Fixed sampler within struct uniform used as function argument

The sampler was simply not declared in that case, as if the uniform
was unused in the shader, so making sure structures containing
samplers call samplerRegister solves this issue. It was working
properly if the sampler was used anywhere else in the shader, but
failed when the only use in the shader was being passed as an
argument to a function through a containing structure.

Added a unit test since this isn't covered by dEQP.

Fixes 2 WebGL tests:

Change-Id: I81767d7c6415de7aefefecffcc66265d944a94ab
Reviewed-on: https://swiftshader-review.googlesource.com/18628
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoLoad sibling libraries from the same directory
Alexis Hetu [Mon, 16 Apr 2018 19:38:40 +0000 (15:38 -0400)]
Load sibling libraries from the same directory

When libEGL and either libGLESv2 or libGLES_CM are in a different
folder from the executable's folder, libEGL wasn't successfully
finding libGLESv2/libGLES_CM (or vice versa). Since these libraries
are generally in the same folder, using the current library's folder
as a starting location to find another library solves this issue.

Change-Id: Ice9217411de4e269d511549411297b57fc1a4bbb
Reviewed-on: https://swiftshader-review.googlesource.com/18548
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoImplement missing EGL surface queries.
Nicolas Capens [Thu, 12 Apr 2018 16:50:21 +0000 (12:50 -0400)]
Implement missing EGL surface queries.

Fixes dEQP-EGL.functional.query_surface.* tests.

Change-Id: I9d0d2dee83140613af24471d350777959ee37565
Reviewed-on: https://swiftshader-review.googlesource.com/18488
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoRemove unstructured metadata files.
Nicolas Capens [Tue, 17 Apr 2018 18:59:54 +0000 (14:59 -0400)]
Remove unstructured metadata files.

This information is now part of internal structured metadata.

Change-Id: Idb8c1ce256133d9857b96c2a3152e333606f4fbd
Reviewed-on: https://swiftshader-review.googlesource.com/18568
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
4 years agoGuard against clearing null depth/stencil buffers.
Nicolas Capens [Thu, 12 Apr 2018 20:31:32 +0000 (16:31 -0400)]
Guard against clearing null depth/stencil buffers.

Change-Id: Ic0a16ac68582e398a02eef722d52a77a1ebde877
Reviewed-on: https://swiftshader-review.googlesource.com/18508
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoAdded check for temporary register overflow
Alexis Hetu [Mon, 9 Apr 2018 17:47:34 +0000 (13:47 -0400)]
Added check for temporary register overflow

Currently, when overflowing the number of temporary registers
allowed, SwiftShader will crash somewhere in the generated
code. This cl adds an early check to prevent the crash and
instead output an error message to the user.

Bug chromium:814987

Change-Id: Idadda21ee14298662763d986ee1283a5114c1c01
Reviewed-on: https://swiftshader-review.googlesource.com/18388
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoRelease thread local storage on thread exit.
David Rim [Fri, 6 Apr 2018 08:48:41 +0000 (17:48 +0900)]
Release thread local storage on thread exit.

Calls to the EGL API from different threads may exit without releasing
their current TLS storage. This patch adds a destructor to release
them if they have not been released already. Prevents memory leakage in
processes where many threads are created.

Bug b/63434079
Bug swiftshader:80

Test: cts-tradefed run commandAndExit  cts -m CtsMediaTestCases -t \
Change-Id: I6e94a6d04ce84b884571248ab89b3b1a4e71998b
Reviewed-on: https://swiftshader-review.googlesource.com/18328
Tested-by: David Rim <davidrim@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoChromium build fix
Alexis Hetu [Tue, 10 Apr 2018 14:46:47 +0000 (10:46 -0400)]
Chromium build fix

Adding a getPlane() function in order to not have the "plane" private
member unused, which causes a warning and makes compilation fail.

Change-Id: I3ec08d3439c7e8f3d4314f3b4864d12e9c34d6f4
Reviewed-on: https://swiftshader-review.googlesource.com/18468
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoFix CMake build
Alexis Hetu [Tue, 10 Apr 2018 14:48:42 +0000 (10:48 -0400)]
Fix CMake build

Added the missing libraries (CoreFoundation
and IOSurface) to the CMakeLists.txt file.

Change-Id: I6db6b3d2396f557296bbf670d152cc421b6727dd
Reviewed-on: https://swiftshader-review.googlesource.com/18469
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoFix build failure due to missing forward declaration.
Nicolas Capens [Mon, 9 Apr 2018 21:38:12 +0000 (17:38 -0400)]
Fix build failure due to missing forward declaration.

Strict compilation requires symbols used in template functions to have
been declared, which will be enforced in future compilers.

Bug swiftshader:103

Change-Id: Ibfc05011b1a2938e958dfacf6792477362699dc6
Reviewed-on: https://swiftshader-review.googlesource.com/18448
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
4 years agoAdd -Wno-sentinel that is needed on Android K
Greg Hartman [Sat, 17 Mar 2018 05:46:21 +0000 (22:46 -0700)]
Add -Wno-sentinel that is needed on Android K

Bug b/75229322
Test: Local build of K
Fixes build break ab/4660759
Change-Id: Ib2cb43594b331c4415650517df65e8ccd497f820
Reviewed-on: https://swiftshader-review.googlesource.com/18190
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoFix makefiles for Andoid K
Greg Hartman [Fri, 16 Mar 2018 18:50:19 +0000 (11:50 -0700)]
Fix makefiles for Andoid K

It's not safe to rely on LOCAL_MODULE_RELATIVE_PATH on all branches

Cleaned up some unnecessary ifdef's

Bug b/75229322
Test: Local build of K
Fixes build break ab/4660124
Change-Id: I48d3400a2109cd5a2cf593e03f9e234f490c8252
Reviewed-on: https://swiftshader-review.googlesource.com/18189
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoAdd work-arounds for missing C++11 features.
Nicolas Capens [Mon, 9 Apr 2018 19:12:15 +0000 (15:12 -0400)]
Add work-arounds for missing C++11 features.

Android versions before M did not have:


This is fixed by extending stlport with custom implementations for
these features. This works by using 'string' and 'memory' header
files in a path searched before stlport itself, in which the new
features are implemented, and including stport's original headers for
all other functionality.

Bug b/75229322

Change-Id: Icd05c072c366381155e086c3f14f805bc4f104d6
Reviewed-on: https://swiftshader-review.googlesource.com/18408
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoCorrect confusion between Android O and O MR1
Greg Hartman [Fri, 16 Mar 2018 07:02:23 +0000 (00:02 -0700)]
Correct confusion between Android O and O MR1

libnativebase and liblog_headers didn't exist until O MR1

Bug b/75229322
Test: Local builds K through P DP1
Change-Id: I07361e4ef8a98108536319428741554b937eda1a
Reviewed-on: https://swiftshader-review.googlesource.com/17768
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
4 years agoeglCreatePbufferFromClientBuffer implementation
Alexis Hetu [Tue, 13 Feb 2018 20:02:40 +0000 (15:02 -0500)]
eglCreatePbufferFromClientBuffer implementation

Added support for eglCreatePbufferFromClientBuffer(), using an
IOSurface on MacOS, or just a straight buffer pointer on other

Added new unit tests (IOSurfaceClientBufferTest class), which
pass on both Windows and MacOS.

Change-Id: I79a6b420d85fb1f3ae505e0c0067bad2e27510d4
Reviewed-on: https://swiftshader-review.googlesource.com/17168
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoInitialize array size on error.
Nicolas Capens [Mon, 9 Apr 2018 15:53:41 +0000 (11:53 -0400)]
Initialize array size on error.

The array size is set using the value returned by arraySizeErrorCheck,
even when an error occurred, so don't leave it uninitialized.

Bug chromium:801648

Change-Id: If2af27c5f61dca2931796f1681dce61ab6a44341
Reviewed-on: https://swiftshader-review.googlesource.com/18368
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoWebGL test fix for MacOS
Alexis Hetu [Mon, 9 Apr 2018 15:43:58 +0000 (11:43 -0400)]
WebGL test fix for MacOS

On MacOS, the BGRA format is used for framebuffers. Because of that,
copying from the BGRA format must be allowed in the same places the
RGBA format is allowed.

This fixes the following WebGL test on MacOS:

Change-Id: I45c6b81a894dd8d55c4ab5cff0cf9ad1a08c8303
Reviewed-on: https://swiftshader-review.googlesource.com/18348
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoFixed buffer offset when primitive restart is enabled
Alexis Hetu [Thu, 5 Apr 2018 19:09:32 +0000 (15:09 -0400)]
Fixed buffer offset when primitive restart is enabled

The data pointer 'buffer->data()' was being used without the
offset applied, which means we were using the wrong part of
the index buffer when primitive restart is enabled. 'indices'
should already contain the properly offset buffer pointer,
so using it directly should work.

Bug chromium:823096

Change-Id: If70634f63d40d8efde9b1336370c1a63b1faa19f
Reviewed-on: https://swiftshader-review.googlesource.com/18268
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
4 years agoAlso look for sibling libraries in /system
Greg Hartman [Thu, 5 Apr 2018 17:10:34 +0000 (10:10 -0700)]
Also look for sibling libraries in /system

This cleans up a problem that was introduced by

LOCAL_VENDOR_MODULE was first supported on O, so when we build
SwiftShader on earlier branches the libraries land in /system.
The fix in the Android.mk files would be complicated and would revert
some of the cleanup, and would cause issues for 64 bit only builds.
While it would be possible to extend the original approach, it just
seems cleaner to check in /system at runtime.

Bug b/76437145
Test: Local build and boot of Cloud Android N
Change-Id: I86e0363a8cbd7b8f2ba744f14a67dfe457f3725f
Reviewed-on: https://swiftshader-review.googlesource.com/18288
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
4 years ago[ozone] swiftshader ozone
Mustafa Çamurcu [Fri, 23 Mar 2018 20:39:02 +0000 (16:39 -0400)]
[ozone] swiftshader ozone

Windows implementation for FrameBuffer needs priority over Ozone.

When building Chrome for Windows using Ozone, since use_ozone=true,
some required windows definitions don't get defined.

Change-Id: I6b8475c036dc88f7e3cb118a7db286afc75857fe
Reviewed-on: https://swiftshader-review.googlesource.com/17968
Tested-by: Mustafa Çamurcu <camurcu@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoGuard against copying from a zero-sized 3D image.
Nicolas Capens [Thu, 29 Mar 2018 05:16:50 +0000 (01:16 -0400)]
Guard against copying from a zero-sized 3D image.

Bug chromium:825545

Change-Id: I37d6192bf65115938943f45d43e153196a7d569a
Reviewed-on: https://swiftshader-review.googlesource.com/18128
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoExpose surfaceless context extension strings
Alexis Hetu [Thu, 22 Mar 2018 12:29:31 +0000 (08:29 -0400)]
Expose surfaceless context extension strings

It seems like SwiftShader already supports surfaceless contexts properly in
eglMakeCurrent, so we might as well expose the extension strings.

Change-Id: I3c1b85296c46536df9a8bd754856d825307181d0
Reviewed-on: https://swiftshader-review.googlesource.com/17948
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoRevert "Use official headers to define GL_ARB_texture_rectangle."
Nicolas Capens [Tue, 27 Mar 2018 13:39:37 +0000 (09:39 -0400)]
Revert "Use official headers to define GL_ARB_texture_rectangle."

This reverts commit 9869bedb56822d19c9bfbdb33f6af061da8e6106.

It broke 32-bit builds on Windows because GLsizeiptr and GLintptr are
defined as different types (int vs. long) in gl2.h and glcorearb.h.
See also https://github.com/KhronosGroup/OpenGL-Registry/issues/162

Change-Id: Ia7bd4accb1671529ce6da6849a1df76dceddcdee
Reviewed-on: https://swiftshader-review.googlesource.com/18068
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoFix missing sized internal formats.
Nicolas Capens [Mon, 26 Mar 2018 14:13:21 +0000 (10:13 -0400)]
Fix missing sized internal formats.

Change-Id: Ifeee2d5c637586e6b843080aaceb446bd0b5af11
Reviewed-on: https://swiftshader-review.googlesource.com/18048
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoSupport more glCopyTexImage unsized formats.
Nicolas Capens [Thu, 22 Mar 2018 17:22:20 +0000 (13:22 -0400)]
Support more glCopyTexImage unsized formats.

Convert packed types to the next greater non-packed component type.
Specifically, when the red component has fewer than 8 bits, use the
corresponding sized internal format with 8-bit components.

Note that this is still not fully compliant.
The OpenGL ES 3.0 spec section 3.8.5 states that:

If internalformat is unsized, the internal format of the new texel array is determined
by the following rules, applied in order. If an effective internal format exists
that has
1. the same component sizes as,
2. component sizes greater than or equal to, or
3. 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 also
the new texel array’s effective internal format.

This means that in theory when copying an RGBA4 framebuffer into an RGB
texture, the effective internal format should be RGB565, not RGB8.
However, dEQP does not enforce this, and ANGLE always assumes
UNSIGNED_BYTE components.

Change-Id: Id243b963779108e205c275499ddfb6e041a873d6
Reviewed-on: https://swiftshader-review.googlesource.com/17969
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoDon't upload array texture images six times.
Nicolas Capens [Thu, 22 Mar 2018 04:55:23 +0000 (00:55 -0400)]
Don't upload array texture images six times.

Change-Id: I5be0cc629477b6cfb3ede6b4484f067d1c30b0ec
Reviewed-on: https://swiftshader-review.googlesource.com/17929
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoValidate pixel unpack buffer offset.
Nicolas Capens [Thu, 22 Mar 2018 04:44:07 +0000 (00:44 -0400)]
Validate pixel unpack buffer offset.

When a pixel unpack buffer is bound, glTexImage calls interpret the
<pixels> parameter as an offset into the pixel buffer. We weren't
validating that the accessed data falls within the buffer, when taking
the offset into account.

Bug chromium:822976

Change-Id: I3ab23e3b135fd4ad1e55555eec95d584684f5d82
Reviewed-on: https://swiftshader-review.googlesource.com/17928
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 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 enabled
including desktop OpenGL headers without conflicts, so we no longer
have to define enums for ARB extensions ourselves.

Change-Id: Ifa05112f1e1d21bb8a22b83519babbbb3e4d6462
Reviewed-on: https://swiftshader-review.googlesource.com/17909
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoUpdate OpenGL headers.
Nicolas Capens [Wed, 21 Mar 2018 17:55:23 +0000 (13:55 -0400)]
Update OpenGL headers.

Using revision

Change-Id: I0e48ff5d700a2f21c9b52f992e90ca37b9800630
Reviewed-on: https://swiftshader-review.googlesource.com/17908
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoAllow Blitter::fastClear to directly write to external buffer
Alexis Hetu [Mon, 26 Mar 2018 01:02:17 +0000 (21:02 -0400)]
Allow Blitter::fastClear to directly write to external buffer

When the external buffer is the one that is dirty, avoid a useless
copy from external to internal before fast clearing the buffer by
clearing the external buffer directly.

Change-Id: I469243ba8a2b8617f9a0f8b6e2a089f667b8ae63
Reviewed-on: https://swiftshader-review.googlesource.com/18033
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoMultisampled blitter clear fix
Alexis Hetu [Mon, 26 Mar 2018 00:32:22 +0000 (20:32 -0400)]
Multisampled blitter clear fix

When clearing a multisampled buffer, the reactor blitter was only
clearing the first sample. This cl makes the reactor blitter
effectively clear all samples of a multisampled buffer.

Change-Id: I7ce1af401bf537fe85e1c8393a2c57144641ad8e
Reviewed-on: https://swiftshader-review.googlesource.com/18032
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoFix multisampled line rendering.
Nicolas Capens [Sat, 17 Mar 2018 03:23:06 +0000 (23:23 -0400)]
Fix multisampled line rendering.

Bug swiftshader:99
Bug chromium:820461

Change-Id: I2232c27d57aedff03293b37607f97ead56c056c9
Reviewed-on: https://swiftshader-review.googlesource.com/17808
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
4 years agoMoving Chromium's version of the libraries first
Alexis Hetu [Tue, 20 Mar 2018 18:06:12 +0000 (14:06 -0400)]
Moving Chromium's version of the libraries first

On MacOS, libraries have a couple of minor issues and, as a safety,
let's make sure no other library than the required library is loaded.

Change-Id: I376b77b3cf3f635ff57c12ccde2b9e84d4105adc
Reviewed-on: https://swiftshader-review.googlesource.com/17888
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoFix output directory creation.
Nicolas Capens [Tue, 20 Mar 2018 15:16:09 +0000 (11:16 -0400)]
Fix output directory creation.

Change-Id: Ib6e656a7913cf245c73c096376241f6e1f567b6b
Reviewed-on: https://swiftshader-review.googlesource.com/17869
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
4 years agoSplit output binaries by platform.
Nicolas Capens [Tue, 20 Mar 2018 14:46:14 +0000 (10:46 -0400)]
Split output binaries by platform.

Change-Id: I7388b3f5d17e35e55726797ba40631fd8590fb24
Reviewed-on: https://swiftshader-review.googlesource.com/17868
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoFix Travis CI deploy directory.
Nicolas Capens [Tue, 20 Mar 2018 13:28:12 +0000 (09:28 -0400)]
Fix Travis CI deploy directory.

Change-Id: I501b72e5d33b26075488c0af999713c192c4ac0b
Reviewed-on: https://swiftshader-review.googlesource.com/17848
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoAdd support for RGBA16F external images.
Nicolas Capens [Tue, 20 Mar 2018 03:38:49 +0000 (23:38 -0400)]
Add support for RGBA16F external images.

Bug b/75778024

Change-Id: Idf17c094ef858b3712839ffe335dc943cd0bd084
Reviewed-on: https://swiftshader-review.googlesource.com/17828
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoUpload binaries to Google Cloud Storage.
Nicolas Capens [Fri, 16 Mar 2018 19:19:19 +0000 (15:19 -0400)]
Upload binaries to Google Cloud Storage.

Change-Id: I92c4c203433c8dc92887c5470631926c3cac1d27
Reviewed-on: https://swiftshader-review.googlesource.com/17788
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
4 years agoFix glTexSubImage support of half-float extension formats.
Nicolas Capens [Wed, 14 Mar 2018 21:15:39 +0000 (17:15 -0400)]
Fix glTexSubImage support of half-float extension formats.

GL_HALF_FLOAT_OES and GL_HALF_FLOAT have different enum values, and we
weren't handling the case where a half-float texture was already
created (e.g. with an effective internal format of GL_RGBA16F) and then
updated with a glTexSubImage call using GL_HALF_FLOAT_OES type. In
other words, we assumed the OpenGL ES 3.0 sized internal format could
only be used with the OpenGL ES 3.0 half-float type, but this hasn't
been true since we started storing only the effective internal format
for all versions.

Note that GL_OES_texture_half_float, which defines GL_HALF_FLOAT_OES,
does not clarify whether HALF_FLOAT images can be updated using FLOAT,
or vice-versa. We're assuming the equivalent combinations of OpenGL ES
3.0 table 3.3 are valid. That is, FLOAT can be used to update,
HALF_FLOAT, but not the other way around.

Bug b/74609191

Change-Id: Ib8548cd37065820eb59a0943fd39647edc5e9f1b
Reviewed-on: https://swiftshader-review.googlesource.com/17748
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoGL_CHROMIUM_color_buffer_float_rgba extension support
Alexis Hetu [Thu, 18 Jan 2018 21:17:54 +0000 (16:17 -0500)]
GL_CHROMIUM_color_buffer_float_rgba extension support

GL_CHROMIUM_color_buffer_float_rgba (OpenGL ES 2.0) is a subset of
GL_EXT_color_buffer_float (OpenGL ES 3.0), which SwiftShader already

Fixes 1 webgl conformance tests:

Change-Id: Ic1451187db219af74ba41fa7634bd5bcb6fb0b44
Reviewed-on: https://swiftshader-review.googlesource.com/16470
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
4 years agoCheck X11 return status.
Nicolas Capens [Tue, 13 Mar 2018 14:54:18 +0000 (10:54 -0400)]
Check X11 return status.

We weren't checking the return status of an XGetWindowAttributes() call
while checking for a resized window. It appears that it can start to
fail possibly due to an out-of-memory situation or the window being
destroyed before the EGL surface.

Note that the EGL spec does not have a recommendation on how to handle
this situation. Generating EGL_BAD_ALLOC is intended for eglCreate*
call failures, while EGL_BAD_NATIVE_WINDOW appears to be reserved for
calls that take a native window as a parameter. eglSwapBuffers is

Bug chromium:819481

Change-Id: I270730567b5179ee43b814e8bd017b601dfbe079
Reviewed-on: https://swiftshader-review.googlesource.com/17708
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoBuild fix: Unit test code cleanup
Alexis Hetu [Thu, 8 Mar 2018 16:33:17 +0000 (11:33 -0500)]
Build fix: Unit test code cleanup

- Added EXPECT_GLENUM_EQ to solve signed/unsigned comparisons
- Added createProgram and drawQuad utility functions to reduce
  code duplication

Change-Id: I8a62110346de501a1a77ec9688cf06b321385661
Reviewed-on: https://swiftshader-review.googlesource.com/17668
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
4 years agoAdded support for sampler2DRect in ESSL3
Alexis Hetu [Fri, 2 Mar 2018 20:10:16 +0000 (15:10 -0500)]
Added support for sampler2DRect in ESSL3

Being able to sample from sampler2DRect using the "texture" function is required for Chromium on Mac.

Change-Id: Iea8970aaec29734a251bcfc19a03223d0ebfbc7e
Reviewed-on: https://swiftshader-review.googlesource.com/17572
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
4 years agoFix Subzero build on Android.
Nicolas Capens [Wed, 7 Mar 2018 20:19:58 +0000 (15:19 -0500)]
Fix Subzero build on Android.

Change-Id: If560b8b41b869458ff4b3a6a314f389c8e7a22f9
Reviewed-on: https://swiftshader-review.googlesource.com/17648
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
4 years agoUse -Werror in Android builds.
Chih-Hung Hsieh [Wed, 11 Oct 2017 21:23:57 +0000 (14:23 -0700)]
Use -Werror in Android builds.

Suppress existing warnings.

Bug b/66996870

Change-Id: I9b78f840638a57c2559ccc4dbc583cc6a6e21c14
Reviewed-on: https://swiftshader-review.googlesource.com/17630
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
4 years agoBuild SwiftShader with BOARD_VNDK_VERSION=current
Jiyong Park [Fri, 8 Sep 2017 01:47:30 +0000 (10:47 +0900)]
Build SwiftShader with BOARD_VNDK_VERSION=current

This is using cutils/log.h which is deprecated in O (in favor of
log/log.h) and this is causing build error when building with
BOARD_VNDK_VERSION=current set. However, since SwiftShader should be
able to be built with older versions Android some of which don't have
log/log.h, we can't simply change cutils/log.h to log/log.h.

Instead, liblog_headers is added to the header lib dependency (only for
O and beyond) so that log/log.h can be correctly included via

Bug b/63135587

Change-Id: I763250e7410025b1dcd7ae210693e3d6bffdb6f1
Reviewed-on: https://swiftshader-review.googlesource.com/17629
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
4 years agoPrevent crashing when no current program is set.
Nicolas Capens [Tue, 6 Mar 2018 14:55:35 +0000 (09:55 -0500)]
Prevent crashing when no current program is set.

This fixes a regression caused by

Context::applyVertexBuffer() expects a valid program, so we need to
check for it sooner. Not having a current program is not an error and
makes the draw call a no-op, but
dEQP-GLES3.functional.negative_api.vertex_array.* still expects
validation to happen before leaving the function. In particular,
the framebuffer completeness check has to be performed. Note that
ConvertPrimitiveType() should never return an error because we already
check the primitive type in the entry function, sampler validation
can only be done when we have a valid program, and likewise
applyVertexBuffer() requires a program, so these validations can still
happen after the early-out.

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