OSDN Git Service

android-x86/external-swiftshader.git
5 years agoFix deterministic loops within conditional blocks.
Nicolas Capens [Sat, 20 Oct 2018 18:17:49 +0000 (14:17 -0400)]
Fix deterministic loops within conditional blocks.

Deterministic loops use the first scalar of the SIMD register used as
the loop index, for addressing arrays. This means that operations on the
index register should not be masked (i.e. it should be treated as a
scalar).

Previously we were still masking it based on conditional statements, and
we didn't disable the masking altogether (using the 'TEST' instruction)
for the loop initialization and initial test.

Also, non-deterministic loops should not have any execution masking
disabled, so don't emit 'TEST' for them.

Bug swiftshader:93
Bug b/118009174

Change-Id: I661de83df931d85f806d2ec5c9e1b2f20a9b5567
Reviewed-on: https://swiftshader-review.googlesource.com/c/21788
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoAdd support for 32b MIPS architecture
Gordana Cmiljanovic [Fri, 19 Oct 2018 09:36:15 +0000 (11:36 +0200)]
Add support for 32b MIPS architecture

* LLVM reactor backend: requires LLVM 7.0
* Subzero reactor backend: unittests hit unimplemented
  TargetMIPS32::lowerShuffleVector()

Bug: b/117854176
Change-Id: Ie58e3e438db6f1b442b05efecf9b645aff82321a
Reviewed-on: https://swiftshader-review.googlesource.com/c/21748
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Milko Leporis <milko.leporis@mips.com>
5 years agoFix signed integer overflow.
Nicolas Capens [Fri, 19 Oct 2018 20:35:05 +0000 (16:35 -0400)]
Fix signed integer overflow.

Signed integer overflow is undefined behavior in C++.

Change-Id: I12b7507a9624312a615826fd0a1d9cb30b8f8b58
Reviewed-on: https://swiftshader-review.googlesource.com/c/21768
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoFix clamping of NaN values.
Nicolas Capens [Thu, 18 Oct 2018 17:47:29 +0000 (13:47 -0400)]
Fix clamping of NaN values.

We pass integer uniforms as floating-point ones, which can cause an
exception when converting them to fixed-point values. For example an
integer value of -1 would be 0xFFFFFFFF which is Not-a-Number in
IEEE-754 floating-point and can't be cast to an integer.

In this case we don't actually care about the result because the fixed-
point number is only used by the fixed-function pipeline. A safe but
still fast way to compare floating-point numbers including NaNs is to
treat them as one's complement integers, which can easily be converted
into two's complement representation.

Also rename bitCast<> to bit_cast<> to match the C++20 function.

Change-Id: Id588d25ab70d31eda2800c24a8df539d6a3411d4
Reviewed-on: https://swiftshader-review.googlesource.com/c/21708
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoDevice and PhysicalDevice features and properties
Alexis Hetu [Tue, 16 Oct 2018 19:44:12 +0000 (15:44 -0400)]
Device and PhysicalDevice features and properties

This cl adds basic functionality to Device and PhysicalDevice
features and properties. Every setting and feature is either
set to the most basic setting, or disabled, when possible.

Bug b/117974925

Change-Id: Ib96630076b8e07e92c59fdf3ae902eeac00639bb
Reviewed-on: https://swiftshader-review.googlesource.com/c/21589
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoCommandBuffer skeleton
Alexis Hetu [Wed, 17 Oct 2018 12:00:43 +0000 (08:00 -0400)]
CommandBuffer skeleton

The CommandBuffer object is a large portion of the Vulkan API.
To make reviewing it's implementation easier, this cl simply adds
all the CommandBuffer function signatures and UNIMLPEMENTED functions.

Bug b/116336664

Change-Id: I25ad8e6b15f46f9c18717f6f147d7d794eb1da97
Reviewed-on: https://swiftshader-review.googlesource.com/c/21608
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoSynchonization objects
Alexis Hetu [Tue, 16 Oct 2018 18:40:19 +0000 (14:40 -0400)]
Synchonization objects

Vulkan has multiple synchronization objects:
- Events, which provide synchronization between commands submitted
  to the same queue, or between the host and a queue.
- Fences, which insert a dependency from a queue to the host
- Semaphores, which insert a dependency between batches submitted
  to queues

For now, SwiftShader will treat these synchronization primitives as noop, since:
- Commands will be executed in order
- SwiftShader currently only supports 1 queue

Change-Id: Ic335e2f7aa30ab7314bf7585e11f1f30a79f50d6
Reviewed-on: https://swiftshader-review.googlesource.com/c/21588
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoVulkan unit tests
Alexis Hetu [Thu, 18 Oct 2018 14:41:32 +0000 (10:41 -0400)]
Vulkan unit tests

Added small Vulkan unit tests:
1) Checks that all API functions are present
2) Verifies a few Physical Device properties

The tests are currently only for Visual Studio,
but should be easily ported to other platforms,
as the code is similar to the GLES unit tests.

Change-Id: Idb45d26734be80e352ba91544e6331c1192f9f3e
Reviewed-on: https://swiftshader-review.googlesource.com/c/21648
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoMove GLES unit tests
Alexis Hetu [Wed, 17 Oct 2018 14:10:23 +0000 (10:10 -0400)]
Move GLES unit tests

GLES unit tests were in the generic "unittests" directory.
In order to avoid confusion with Vulkan unit tests, the
GLES unit tests directory was renamed to GLESUnitTests.

Change-Id: Idc40f63daddc6f822207fc4a75dd037a46ae22a6
Reviewed-on: https://swiftshader-review.googlesource.com/c/21628
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoLinux build fix
Alexis Hetu [Wed, 17 Oct 2018 17:18:04 +0000 (13:18 -0400)]
Linux build fix

On linux, clang is unable to find the Cast() function used in the
templated destroy() function unless it has already been defined
before the template function. This forces us to make sure all
Cast() functions are available, but simply adding the vulkan objects'
header files in VkMemory.h would cause a circular dependency, which,
while it would be properly guarded by the preprocessor directives,
wouldn't guarantee any include order, due to the nature of circular
dependencies. So, to fix the issue, a new header file, called
VkDestroy.h was added, which can depend on all vulkan objects' header
files without creating a circular dependency.

Also fixed some warnings.

Change-Id: I1f343a8c476d6308d4555009848a234b0695661e
Reviewed-on: https://swiftshader-review.googlesource.com/c/21668
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoDetach transform feedback when deleted.
Nicolas Capens [Wed, 17 Oct 2018 20:35:55 +0000 (16:35 -0400)]
Detach transform feedback when deleted.

Bug b/116778367

Change-Id: Iff07e00a36669d10518b83a6bfdb1e6af4ffcef3
Reviewed-on: https://swiftshader-review.googlesource.com/c/21688
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFix compiler warnings when compiling swiftshader for Fuchsia
Sergey Ulanov [Thu, 18 Oct 2018 00:21:42 +0000 (17:21 -0700)]
Fix compiler warnings when compiling swiftshader for Fuchsia

LLVM_DEFAULT_TARGET_TRIPLE was defined in config.h and llvm-config.h,
which was causing warnings when compiling it for Fuchsia. Also made
some other cleanups in llvm-config.h, particularly removed i386 and arm
ifdefs.

There are still some other warnings not fixed in this CL
('using namespace' in headers), but these don't look Fuchsia-specific.

Bug: 881334
Change-Id: Iaf54e622e9d31553268afe960d6330dcb5920321
Reviewed-on: https://swiftshader-review.googlesource.com/c/21689
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Sergey Ulanov <sergeyu@chromium.org>
5 years agoAdd LLVM 7.0 config for Fuchsia.
Nicolas Capens [Mon, 15 Oct 2018 19:05:07 +0000 (15:05 -0400)]
Add LLVM 7.0 config for Fuchsia.

Bug b/115344057
Bug chromium:881334

Change-Id: Id3d673b8cf9ff3d3eea0675b1b58f0f6663ba074
Reviewed-on: https://swiftshader-review.googlesource.com/c/21528
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Sergey Ulanov <sergeyu@chromium.org>
5 years agoAdd an argument check for compressed formats in glCompressedTexSubImage2D
Merck Hung [Tue, 16 Oct 2018 05:28:26 +0000 (14:28 +0900)]
Add an argument check for compressed formats in glCompressedTexSubImage2D

The implementation of OpenGLES_v2 glCompressedTexSubImage2D() API
lacks of a sanity check for compressed formats. When a
non-compressed format is specified (e.g. GL_RGB), an unreachable
condition of SS's internal function, ComputeCompressedSize(), is
hit.

This patch is to add a check in CompressedTexSubImage2D() function
to prevent invalid formatd from being entered, in terms of
OpenGL_v2 API integrity in accordance with Khorons's specification

Bug: b/116776984
Test: Manual tests using OGLESHelloAPI by specifying GL_RGB format
Change-Id: Icc964ecb9dbbdef6c6bc82dab42c35290917159e
Reviewed-on: https://swiftshader-review.googlesource.com/c/21548
Reviewed-by: Merck Hung <merckhung@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Merck Hung <merckhung@google.com>
5 years agoTreat all non-zero GLboolean values as GL_TRUE.
Nicolas Capens [Mon, 15 Oct 2018 17:01:22 +0000 (13:01 -0400)]
Treat all non-zero GLboolean values as GL_TRUE.

Note that this is left undefined by the spec, but glGetBoolean converts
non-zero integers to GL_TRUE, so this makes things symmetric.

Bug swiftshader:90

Change-Id: Ie2d3b2b8d66e63f542f758ddc6482b451fb4140d
Reviewed-on: https://swiftshader-review.googlesource.com/c/21511
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoVulkan dispatchable objects
Alexis Hetu [Wed, 26 Sep 2018 15:25:46 +0000 (11:25 -0400)]
Vulkan dispatchable objects

Vulkan has a few dispatchable objects: Instance, Device, Physical Device,
Command Buffer and Queue. These objects, when loaded through an ICD, are
constrained to have a bit of memory allocated at the beginning of these
objects to contain loader data.

In order to do this, a wrapper class, DispatchableObject, was created to handle
pointing directly to the loader data when casting to the associated VK handle
and similarly back to a pointer to the internal object. Note that Queue, being
allocated within another object, and not directly through the API, simply have
the loader data at the beginning of the class, without requiring a wrapper class.

Also, since all these object are allocated through a custom placement new
operator, they have to be deallocated through an associated destroy() function,
so the DispatchableObject destructor is deleted, in order to prevent these
objects from being released any other way.

Bug b/116336664

Change-Id: Iac749f6adcba0eaf7557f0df876ac0474081d9cc
Reviewed-on: https://swiftshader-review.googlesource.com/c/20948
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoFix GN build.
Nicolas Capens [Mon, 15 Oct 2018 15:25:03 +0000 (11:25 -0400)]
Fix GN build.

Bug b/115344057
Bug chromium:881334

Change-Id: Ib54e43a106c17b4878780382c4a80415e8f3583b
Reviewed-on: https://swiftshader-review.googlesource.com/c/21508
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAdd GN build file for LLVM 7.0
Nicolas Capens [Fri, 12 Oct 2018 20:45:51 +0000 (16:45 -0400)]
Add GN build file for LLVM 7.0

This enables supporting ARM64 for Chromium.

Bug b/115344057
Bug chromium:881334

Change-Id: I45020e826684c6fa6e663a90b75703193ad670c3
Reviewed-on: https://swiftshader-review.googlesource.com/c/21451
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFix depth/stencil read format validation.
Nicolas Capens [Sat, 13 Oct 2018 03:42:21 +0000 (23:42 -0400)]
Fix depth/stencil read format validation.

Bug b/117564133
Bug swiftshader:104

Change-Id: I6e5c4aca219e344df7b113fe445c5f1faeb7dd4b
Reviewed-on: https://swiftshader-review.googlesource.com/c/21488
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoRemove libGL project.
Nicolas Capens [Wed, 10 Oct 2018 15:11:34 +0000 (11:11 -0400)]
Remove libGL project.

Change-Id: I36237afe7b01070cd665f4ab990e9d7cc87a6360
Reviewed-on: https://swiftshader-review.googlesource.com/c/21390
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoRename SWIFTSHADER_LLVM_VERSION to REACTOR_LLVM_VERSION.
Nicolas Capens [Wed, 10 Oct 2018 14:49:30 +0000 (10:49 -0400)]
Rename SWIFTSHADER_LLVM_VERSION to REACTOR_LLVM_VERSION.

Bug b/115344057
Bug swiftshader:16

Change-Id: I0e7d49cb5f66cef7d8ccd80506deeae8aab1824c
Reviewed-on: https://swiftshader-review.googlesource.com/c/21389
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoRename Reactor/Memory.* to Reactor/ExecutableMemory.*
Nicolas Capens [Wed, 10 Oct 2018 14:42:36 +0000 (10:42 -0400)]
Rename Reactor/Memory.* to Reactor/ExecutableMemory.*

Bug b/115344057
Bug swiftshader:16

Change-Id: I2ef387ee237e964c089d9a7a5eb156a8733cc77f
Reviewed-on: https://swiftshader-review.googlesource.com/c/21388
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoDelete unused functionality.
Nicolas Capens [Tue, 9 Oct 2018 21:32:47 +0000 (17:32 -0400)]
Delete unused functionality.

Core SwiftShader should no longer be able to allocate executable
memory. That responsibility now falls entirely on Reactor.

Bug b/115344057
Bug swiftshader:16

Change-Id: If5dad25e52e661331ef0555b2d9de743cbfd3173
Reviewed-on: https://swiftshader-review.googlesource.com/c/21369
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoMake Reactor build stand-alone.
Nicolas Capens [Mon, 6 Aug 2018 18:20:45 +0000 (14:20 -0400)]
Make Reactor build stand-alone.

This is accomplished by duplicating files from the Common directory
that Reactor (both with LLVM and Subzero back-end) depended on. They
will be minimized in the next change.

Bug b/115344057
Bug swiftshader:16

Change-Id: I2dc087e91b761cc4402ed8594022551e9246b855
Reviewed-on: https://swiftshader-review.googlesource.com/c/20108
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoOutput intermediate build files to project independent directories.
Nicolas Capens [Tue, 9 Oct 2018 18:22:04 +0000 (14:22 -0400)]
Output intermediate build files to project independent directories.

This prevents clashes between intermediates. Also update the D3D8
project to not depend on debug macro implementations in the
SwiftShader layer.

Bug b/29024574

Change-Id: I206b750bf752e3b47867f35379a82f32549a7843
Reviewed-on: https://swiftshader-review.googlesource.com/c/21348
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRename Reactor namespace to rr.
Nicolas Capens [Mon, 6 Aug 2018 18:20:45 +0000 (14:20 -0400)]
Rename Reactor namespace to rr.

We were using sw, the namespace used in the rest of SwiftShader, as the
namespace for Reactor. Putting Reactor code into its own namespace
makes it easier to untangle dependencies.

Bug swiftshader:16
Bug b/115344057

Change-Id: Iea4e049a4796323bf80b4f5e6e17778ccf17b995
Reviewed-on: https://swiftshader-review.googlesource.com/c/21308
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAdd LLVM 7.0 as git subtree
Nicolas Capens [Fri, 12 Oct 2018 02:08:06 +0000 (02:08 +0000)]
Add LLVM 7.0 as git subtree

Adds commit '65ce2e56889' from https://git.llvm.org/git/llvm as
'third_party/llvm-7.0/llvm'

Commands:
git remote add llvm https://git.llvm.org/git/llvm.git
git subtree add --prefix third_party/llvm-7.0/llvm llvm release_70 --squash

Bug b/115344057

Change-Id: I981f7e2fc47639ca8a8998b188e837bc3f268de5

5 years agoSquashed 'third_party/llvm-7.0/llvm/' content from commit 65ce2e56889
Nicolas Capens [Fri, 12 Oct 2018 02:08:06 +0000 (02:08 +0000)]
Squashed 'third_party/llvm-7.0/llvm/' content from commit 65ce2e56889

git-subtree-dir: third_party/llvm-7.0/llvm
git-subtree-split: 65ce2e56889af84e8be8e311f484a4dfe4b62d7a

5 years agoRemove LLVM 7.0 git submodule
Nicolas Capens [Thu, 11 Oct 2018 18:10:49 +0000 (14:10 -0400)]
Remove LLVM 7.0 git submodule

LLVM 7.0 will be added back as a subtree instead.

This reverts commit 1841c50cf0abab2a6d7b5e86b614fbcace7d57f7.

Bug b/115344057

Change-Id: I5fc51be1f107f3de0e97e8b53e282b0cc9557bed

5 years agoGrant more downstream SwiftShader approval rights.
Nicolas Capens [Tue, 9 Oct 2018 14:21:50 +0000 (10:21 -0400)]
Grant more downstream SwiftShader approval rights.

Change-Id: Idc041213e40c0650b52209de199a098bd26a1b39
Reviewed-on: https://swiftshader-review.googlesource.com/c/21328
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoDisable accidentally enabled OpenGL logging.
Nicolas Capens [Tue, 9 Oct 2018 19:56:12 +0000 (15:56 -0400)]
Disable accidentally enabled OpenGL logging.

This reverts part of https://swiftshader-review.googlesource.com/21108

Bug b/73656151

Change-Id: I35c91cb5b28ede65eadebcb5e8141be4cf3f2e0e
Reviewed-on: https://swiftshader-review.googlesource.com/c/21368
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Shannon Woods <shannonwoods@google.com>
5 years agoRemove unused preprocessor definitions.
Nicolas Capens [Wed, 3 Oct 2018 15:14:00 +0000 (11:14 -0400)]
Remove unused preprocessor definitions.

Bug b/116336664

Change-Id: I388b3c602d0b697ecedf19e390d8008ada0ea849
Reviewed-on: https://swiftshader-review.googlesource.com/c/21289
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoAdd renderer source to Vulkan project.
Nicolas Capens [Tue, 2 Oct 2018 18:35:57 +0000 (14:35 -0400)]
Add renderer source to Vulkan project.

Bug b/117152542

Change-Id: I8bfa40d0e912f90946109c6d80889889ef7c5c55
Reviewed-on: https://swiftshader-review.googlesource.com/c/21249
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoDuplicate source files for Vulkan.
Nicolas Capens [Tue, 2 Oct 2018 17:16:55 +0000 (13:16 -0400)]
Duplicate source files for Vulkan.

The Vulkan implementation needs a directory for each architectural
layer, similar to the OpenGL ES stack. The entire rendering stack is
duplicated, leaving only Reactor common between them:

Renderer -> Device
Shader -> Pipeline
Common -> System
Main -> WSI

Bug b/117152542

Change-Id: I9c26b23654016d637f88ec2416f019ef65b9afbd
Reviewed-on: https://swiftshader-review.googlesource.com/c/21248
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoChange build output directory to 'out'.
Nicolas Capens [Tue, 2 Oct 2018 16:40:12 +0000 (12:40 -0400)]
Change build output directory to 'out'.

Although we only produce libraries, 'lib' is confusing as an output
directory. We already used 'out' for the CMake build.

Bug b/116336664
Bug b/29024574

Change-Id: I2bc1015a72100f81f734fc969a32e9f5a967e17c
Reviewed-on: https://swiftshader-review.googlesource.com/c/21228
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoRemove environment-wide include paths.
Nicolas Capens [Mon, 1 Oct 2018 20:11:08 +0000 (16:11 -0400)]
Remove environment-wide include paths.

The Vulkan implementation shouldn't depend on any of the legacy
directories. Also, changes to the environment-wide include paths
may have undesired consequences.

Bug b/116336664

Change-Id: Ied3c8f4e56994379db3518a4fbf0268451d84079
Reviewed-on: https://swiftshader-review.googlesource.com/c/21188
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoFix CMake Subzero build.
Nicolas Capens [Tue, 2 Oct 2018 19:01:30 +0000 (15:01 -0400)]
Fix CMake Subzero build.

Bug swiftshader:116

Change-Id: I93208ea733cfe69474477ad2e00e52c8e86d1e25
Reviewed-on: https://swiftshader-review.googlesource.com/c/21268
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFix preprocessor error.
Nicolas Capens [Tue, 2 Oct 2018 14:49:22 +0000 (10:49 -0400)]
Fix preprocessor error.

##__VA_ARGS__ causes an error with clang if it's not preceded by a comma. The ## is
wholly unnecessary in this case so it can just be removed.

Bug b/73656151

Change-Id: Icc8a67a91b270d0e9b006cae7a438cdefa412f87
Reviewed-on: https://swiftshader-review.googlesource.com/21208
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
5 years agoMigrate to using <log/log.h> since Android O (API 27)
Merck Hung [Fri, 28 Sep 2018 21:21:57 +0000 (05:21 +0800)]
Migrate to using <log/log.h> since Android O (API 27)

Starting from Android O, <cutils/log.h> is planned to be deprecated in the
future. The use of the original <cutils/log.h> is split into 2 header files.

Per Treble team's (b/78370064) description, <log/log.h> is for native shared
libs or executables, and <android/log.h> is for app JNI.

So a conditional preprocessor is put in place to look at the
ANDROID_PLATFORM_SDK_VERSION definition. If the value is less than 27, means
it's Android N or older, and it ought to include <cutils/log.h>.

Otherwise, it should be 27 (Android O) or any greater version, and it's
supposed to include the new <log/log.h> file.

If ANDROID_PLATFORM_SDK_VERSION is not definied, Andorid build system catches
it and stops the building process with an error message.

Bug: b/116855807
Test: pi-dev(28), oc-mr1-dev(27), and nyc-mr2-dev(26) branches
Test: aosp_arm-eng target
Change-Id: I732803e900144bf291feeb2cba1d632301c4fa21
Reviewed-on: https://swiftshader-review.googlesource.com/21130
Tested-by: Merck Hung <merckhung@google.com>
Reviewed-by: Merck Hung <merckhung@google.com>
Reviewed-by: Alistair Strachan <astrachan@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRemove stray printfs.
Nicolas Capens [Fri, 28 Sep 2018 19:27:08 +0000 (15:27 -0400)]
Remove stray printfs.

SwiftShader shouldn't print anything to stdout in Release builds.

Also refactor UNIMPLEMENTED macro to be able to take a formatted string
with arguments.

Bug b/73656151

Change-Id: Ibadbfba3371324ba1bd608bd51bdac5e5923a20e
Reviewed-on: https://swiftshader-review.googlesource.com/21108
Reviewed-by: Merck Hung <merckhung@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRemove duplicates in LLVM 7.0 build.
Nicolas Capens [Mon, 1 Oct 2018 16:38:38 +0000 (12:38 -0400)]
Remove duplicates in LLVM 7.0 build.

Bug b/115344057

Change-Id: Iac34e89f56a1f67301beae3fcf492596522d08a2
Reviewed-on: https://swiftshader-review.googlesource.com/21168
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFix stencil buffer memory leak.
Nicolas Capens [Sat, 29 Sep 2018 15:58:42 +0000 (11:58 -0400)]
Fix stencil buffer memory leak.

Locking stencil buffers with a NULL format resulted in nullptr being
returned without acquiring the resource lock, while unlocking did
release the lock.

Instead of not releasing it on unlock, we must acquire it on lock
because otherwise the object could get destroyed before draw operations
end and attempt to unlock.

Bug b/116876483

Change-Id: Ie883115a1d6df3b40eb7c1feb5dcfde7316ec970
Reviewed-on: https://swiftshader-review.googlesource.com/21148
Reviewed-by: Krzysztof Kosiński <krzysio@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Krzysztof Kosiński <krzysio@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoNotify team on Travis CI failures.
Nicolas Capens [Fri, 28 Sep 2018 18:17:07 +0000 (14:17 -0400)]
Notify team on Travis CI failures.

Bug b/115784742

Change-Id: Id3225adcaf77e1d26560151c506e885318bd0ff6
Reviewed-on: https://swiftshader-review.googlesource.com/21088
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoExplicitly include Android.mk for only OpenGL
Merck Hung [Fri, 28 Sep 2018 08:08:14 +0000 (16:08 +0800)]
Explicitly include Android.mk for only OpenGL

Replace all-makefiles-under makefile-macro with explicitly including
Android.mk(s) from subdirectories that are related to OpenGL and are
only needed by Android builds.

The change are mainly made to the top-level Android.mk and the
src/Android.mk. The other three sub-Android.mk(s) are deprecated and
deleted. Soong compile-time is expected to shorten with no use of
all-makefiles-under macros.

Since the project co-existed with both Android.bp and Android.mk.
The test was performed in absence of Android.bp on oc-mr1-dev branch
against aosp_arm-eng and aosp_arm64-eng targets.

NOTE: Android Pie uses Android.bp only.

Bug: b/29023322
Test: oc-mr1-dev branch, aosp_arm-eng (LLVM3) & aosp_arm64-eng (LLVM7) targets
Change-Id: I05ac46213f849747621c7084bca2549a22513881
Reviewed-on: https://swiftshader-review.googlesource.com/21068
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Merck Hung <merckhung@google.com>
5 years agoSilently ignore attempts to delete default VAO.
Nicolas Capens [Thu, 27 Sep 2018 17:54:27 +0000 (13:54 -0400)]
Silently ignore attempts to delete default VAO.

The spec for glDeleteVertexArrays states that "Unused names in arrays
are silently ignored, as is the value zero."

b/116699321

Change-Id: I7cca0336dd9841b360f8fa20f6c0ac9677ec3ce1
Reviewed-on: https://swiftshader-review.googlesource.com/21048
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoReactor: Fix Trunc generic code generation
Logan Chien [Thu, 27 Sep 2018 13:05:53 +0000 (21:05 +0800)]
Reactor: Fix Trunc generic code generation

This commit fixes `Trunc(Float)` and `Trunc(Float4)` generic LLVM code
generation.  If `Trunc(x)` is implemented with `Float(Int(x))`, it will
result in quality warning in dEQP.

Bug: b/115344057
Test: dEQP-GLES3.functional.shaders.builtin_functions.precision.trunc
Test: dEQP-GLES3.functional.shaders.builtin_functions.precision.modf
Change-Id: I62d2dd1907e345fb00307b6c0d4d74613237f94b
Reviewed-on: https://swiftshader-review.googlesource.com/21029
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoReactor: Fix Frac generic code generation
Logan Chien [Wed, 26 Sep 2018 14:18:16 +0000 (22:18 +0800)]
Reactor: Fix Frac generic code generation

This commit fixes `Frac(Float)` and `Frac(Float4)` generic LLVM code
generation.

See also: https://bugs.chromium.org/p/swiftshader/issues/detail?id=74

Bug: b/115344057
Test: functional.shaders.builtin_functions.precision.fract.highp_vertex
Test: functional.shaders.builtin_functions.precision.fract.highp_fragment
Change-Id: I027b7ab44ba3060dc100a220ba19e5275f41d4c9
Reviewed-on: https://swiftshader-review.googlesource.com/20933
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoReactor: Fix RoundInt generic code generation
Logan Chien [Wed, 26 Sep 2018 11:59:32 +0000 (19:59 +0800)]
Reactor: Fix RoundInt generic code generation

This commit fixes `RoundInt(Float)` and `RoundInt(Float4)` generic LLVM
code generation.

Bug: b/115344057
Test: functional.shaders.builtin_functions.precision.sinh.highp_vertex
Test: functional.shaders.builtin_functions.precision.sinh.highp_fragment
Test: functional.shaders.builtin_functions.precision.cosh.highp_vertex
Test: functional.shaders.builtin_functions.precision.cosh.highp_fragment
Change-Id: I35de5cf6bec6607725523a10ebf098333957f39a
Reviewed-on: https://swiftshader-review.googlesource.com/20931
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoReactor: Fix Round (float) generic code generation
Logan Chien [Wed, 26 Sep 2018 14:14:00 +0000 (22:14 +0800)]
Reactor: Fix Round (float) generic code generation

This commit fixes `Round(Float)` and `Round(Float4)` generic LLVM code
generation.

Bug: b/115344057
Test: dEQP-GLES3.functional.shaders.builtin_functions.precision.sin
Test: dEQP-GLES3.functional.shaders.builtin_functions.precision.cos
Change-Id: I9758ac4ca69bb0f5a5b192b4be3310827625fac0
Reviewed-on: https://swiftshader-review.googlesource.com/20932
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoReactor: Add check to SSE-specifc code for UShort4
Logan Chien [Wed, 26 Sep 2018 11:22:54 +0000 (19:22 +0800)]
Reactor: Add check to SSE-specifc code for UShort4

Bug: b/115344057
Change-Id: I57d9cc936349c9f788a9bf791f55958caa6cbb73
Reviewed-on: https://swiftshader-review.googlesource.com/20930
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoReactor: Fix Floor generic code generation
Logan Chien [Wed, 26 Sep 2018 11:03:53 +0000 (19:03 +0800)]
Reactor: Fix Floor generic code generation

This commit fixes Floor() generic LLVM code generation.

Bug: b/115344057
Test: dEQP-GLES3.functional.shaders.builtin_functions.precision.floor
Change-Id: I70ec0babfe9778b7963296734f1901a73b1f696f
Reviewed-on: https://swiftshader-review.googlesource.com/20929
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoReactor: Fix add/sub sat generic code generation
Logan Chien [Wed, 26 Sep 2018 10:58:03 +0000 (18:58 +0800)]
Reactor: Fix add/sub sat generic code generation

This commit fixes saturated add/sub instructions in generic LLVM code
generation path.

Bug: b/115344057
Test: dEQP-GLES3.functional.texture.wrap.rgba8
Change-Id: Ie3e3b708565b3ad255804090e8a3ee5521f42982
Reviewed-on: https://swiftshader-review.googlesource.com/20928
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoReactor: Cleanup indentations
Logan Chien [Thu, 27 Sep 2018 10:45:58 +0000 (18:45 +0800)]
Reactor: Cleanup indentations

Use mixed indentations so that the code are aligned regardless the tab
width.

Bug: b/115344057
Change-Id: I9476c1b8ba5a518787dc76f50e1805b1b9d06e82
Reviewed-on: https://swiftshader-review.googlesource.com/21028
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoInclude <string> for fixing undefined template on Mac.
Merck Hung [Thu, 27 Sep 2018 00:14:11 +0000 (09:14 +0900)]
Include <string> for fixing undefined template on Mac.

Change-Id: I4e8a860446bde7f76ea289888bf592d78c59b9c4
Reviewed-on: https://swiftshader-review.googlesource.com/21008
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Merck Hung <merckhung@google.com>
5 years agoInitial cmake support for vulkan target
Chris Forbes [Wed, 26 Sep 2018 16:24:39 +0000 (09:24 -0700)]
Initial cmake support for vulkan target

Change-Id: I34b47a5327055f804951793d9a8a58f771d9b792
Bug: b/116336664
Reviewed-on: https://swiftshader-review.googlesource.com/20988
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoRemove exit-time destructors.
Nicolas Capens [Tue, 25 Sep 2018 15:46:27 +0000 (11:46 -0400)]
Remove exit-time destructors.

Bug chromium:101600
Bug swiftshader:118

Change-Id: Id167a84c4d8781989d4d903384c4e6fe6f45fb85
Reviewed-on: https://swiftshader-review.googlesource.com/20868
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoVulkan API (GetProcAddr only)
Alexis Hetu [Fri, 21 Sep 2018 19:14:43 +0000 (15:14 -0400)]
Vulkan API (GetProcAddr only)

This patch contains an empty Vulkan shell with only GetProcAddr implemented

Initial version of the VulkanAPI, empty and unimplemented.
Successfully builds vk_swiftshader.dll for all platforms/configuration in Visual Studio.

To test using dEQP:
- Edit environment variables
- Define VK_ICD_FILENAMES to <SwiftShader's source directory>\src\Vulkan\vk_swiftshader_icd.json
- If the location of vk_swiftshader.dll you're using is different than the one specified in
  src\Vulkan\vk_swiftshader_icd.json, modify it to point to the vk_swiftshader.dll file you want to use

Bug b/116336664

Change-Id: I560b53c3e4340b9c5ccd244a6693ff2f9f994a6f
Reviewed-on: https://swiftshader-review.googlesource.com/20788
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoUse lower case for internal Makefile variables
Logan Chien [Tue, 25 Sep 2018 09:59:20 +0000 (17:59 +0800)]
Use lower case for internal Makefile variables

This commit switches several internal (implied) Makefile variables to
lower cases.  This follows the variable naming convention recommended by
GNU Makefile Manual.

Change-Id: I79819ef0cfd3828107dab665118f1511ef8a8337
Reviewed-on: https://swiftshader-review.googlesource.com/20848
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Logan Chien <loganchien@google.com>
5 years agoMore thread safety in ES2 & EGL APIs
Chris Forbes [Wed, 12 Sep 2018 00:31:52 +0000 (17:31 -0700)]
More thread safety in ES2 & EGL APIs

Tweak ContextPtr to handle move construction/assignment correctly.
This was overlooked when I made the last minute change to use explicit lock/unlock.

Tweak LockGuard to allow construction from ptr to MutexLock, and behave
correctly if mutex == nullptr. This is required because the locking
machinery for EGL is /outside/ the error generation for bad EGLDisplay.

Add 'Big EGL Lock' around most of the EGL API

Bug: b/112184433
Change-Id: Ic4cd5fa9e6a16ae81cbb2b46e1cb881a850749c5
Reviewed-on: https://swiftshader-review.googlesource.com/20628
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoAdd support for constant folding of clamp()
Chris Forbes [Sat, 22 Sep 2018 01:40:53 +0000 (18:40 -0700)]
Add support for constant folding of clamp()

Fixes: dEQP-GLES3.functional.shaders.constant_expressions.other.complex*
Bug: b/116598062
Change-Id: Ife2dd2edad17d6ebbd02653f484637672ce6af0a
Reviewed-on: https://swiftshader-review.googlesource.com/20828
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoFix constant folding of nonsquare mat * vec and vec * mat
Chris Forbes [Fri, 21 Sep 2018 20:24:17 +0000 (13:24 -0700)]
Fix constant folding of nonsquare mat * vec and vec * mat

Bug: b/116263076
Change-Id: Id8657fdefb988827f0d78556884c4f55eb096ca3
Reviewed-on: https://swiftshader-review.googlesource.com/20808
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoAvoid emitting nonsquare scale matrix entries where there is no main diagonal element
Chris Forbes [Fri, 21 Sep 2018 18:57:51 +0000 (11:57 -0700)]
Avoid emitting nonsquare scale matrix entries where there is no main diagonal element

As mentioned in the patch itself, this is fairly benign, but still junk that a later pass has to be able to eliminate. Is easier to just not produce it in the first place.

Bug: b/116263076
Change-Id: I199672bb9b53eb4ee9d4a8e3a23fc2ce42f0dec6
Reviewed-on: https://swiftshader-review.googlesource.com/20770
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoFix nonsquare matrix construction from scalar
Chris Forbes [Fri, 21 Sep 2018 18:30:15 +0000 (11:30 -0700)]
Fix nonsquare matrix construction from scalar

Matrix is laid out in column-major order, so the stride between elements
on the main diagonal is #rows + 1, not #columns + 1.

Bug: b/116263076
Change-Id: I00994b663bc4229e24f8ae1b7fa518caa0e7ea71
Reviewed-on: https://swiftshader-review.googlesource.com/20768
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoFix missing case for declarations in glslang AST dump
Chris Forbes [Fri, 21 Sep 2018 18:34:36 +0000 (11:34 -0700)]
Fix missing case for declarations in glslang AST dump

Cleans up some noise that appears in dumps of pretty much every GLSL
shader.

Change-Id: I602a6356110803e30fcd8ba9818e56efa70bf5d6
Reviewed-on: https://swiftshader-review.googlesource.com/20769
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoFix code generation for vec.swiz *= mat
Chris Forbes [Thu, 20 Sep 2018 00:07:39 +0000 (17:07 -0700)]
Fix code generation for vec.swiz *= mat

Khronos test CL: https://gerrit.khronos.org/#/c/2944/
Bug: b/116259485

Change-Id: Ie10b3eb16da39f332966a5b957acb0232140a942
Reviewed-on: https://swiftshader-review.googlesource.com/20748
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoAdd SWIFTSHADER prefix to Android.mk variables
Logan Chien [Mon, 10 Sep 2018 14:14:20 +0000 (22:14 +0800)]
Add SWIFTSHADER prefix to Android.mk variables

This commit replaces use_subzero with SWIFTSHADER_USE_SUBZERO and
unsupported_build with SWIFTSHADER_UNSUPPORTED_BUILD in Android.mk so
that it can be consistent with other variables.

Change-Id: Ia22cc88bc5804d7d2bea942bbceb2fc30c88aa18
Reviewed-on: https://swiftshader-review.googlesource.com/20588
Tested-by: Logan Chien <loganchien@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoBuild fix
Alexis Hetu [Fri, 14 Sep 2018 20:53:21 +0000 (16:53 -0400)]
Build fix

Made sure both LLVM and Subzero has the /src directory in their
include directory list. Removed unused ../ in front of "Common"
includes as a cleanup.

Change-Id: Ib4a6fb772fa03a9a3cad82594db1b1650007e47f
Reviewed-on: https://swiftshader-review.googlesource.com/20728
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoDisable unsafe FP math optimizations for LLVM 7.0.
Nicolas Capens [Thu, 13 Sep 2018 18:20:06 +0000 (14:20 -0400)]
Disable unsafe FP math optimizations for LLVM 7.0.

Failures in dEQP using SwiftShader with LLVM 7.0 were caused by unsafe
floating point math optimizations, which are more aggressive than with
LLVM 3.0.

Bug b/115344057

Change-Id: Idf564d0193efba37cd1192a188b18a5f8b4ed4f7
Reviewed-on: https://swiftshader-review.googlesource.com/20708
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Shannon Woods <shannonwoods@google.com>
5 years agoWork around stack probe issue.
Nicolas Capens [Thu, 13 Sep 2018 18:30:56 +0000 (14:30 -0400)]
Work around stack probe issue.

LLVM fails to resolve the __chkstck function for probing the stack when
it's larger than 4 kB. We don't need it for SwiftShader because newly
created threads have 1 MB of committed stack memory.

Bug b/115344057
Bug swiftshader:25

Change-Id: Ic6097376052b07ed6af950dfdac8499b5fc83053
Reviewed-on: https://swiftshader-review.googlesource.com/20688
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoUpdated issue tracker URL
Shannon Woods [Wed, 12 Sep 2018 21:02:44 +0000 (17:02 -0400)]
Updated issue tracker URL

Change-Id: Ia4b0f5b7911ddc1f425430e2f6b2e2a7c80fb684
Reviewed-on: https://swiftshader-review.googlesource.com/20668
Tested-by: Shannon Woods <shannonwoods@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAdd Windows configs for LLVM 7.0.
Nicolas Capens [Tue, 11 Sep 2018 17:09:28 +0000 (13:09 -0400)]
Add Windows configs for LLVM 7.0.

These were created by creating a Visual Studio solution for LLVM
itself and building it so it generates include\llvm\Config files.

Bug b/115344057

Change-Id: I22c93d63395fa27b8d8515d65c6bf4e09b3c16bb
Reviewed-on: https://swiftshader-review.googlesource.com/20608
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
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>