OSDN Git Service

android-x86/external-swiftshader.git
5 years agoFix include paths.
Nicolas Capens [Mon, 5 Nov 2018 21:30:42 +0000 (16:30 -0500)]
Fix include paths.

Bug b/117152542

Change-Id: I341f03ad3fcc8d52723ec9575685eeb28519e7dc
Reviewed-on: https://swiftshader-review.googlesource.com/c/22328
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFix for unused-lambda-capture warning
Takuto Ikuta [Mon, 5 Nov 2018 14:32:02 +0000 (23:32 +0900)]
Fix for unused-lambda-capture warning

This is re-land of
https://swiftshader-review.googlesource.com/c/SwiftShader/+/21848

bug: chromium:681136
Change-Id: I11ca3b0f3ccd00ff93cf5eec0e342b49d2ce1f99
Reviewed-on: https://swiftshader-review.googlesource.com/c/22289
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Takuto Ikuta <tikuta@google.com>
5 years ago[MIPS] Add support for 64b MIPS architecture
Gordana Cmiljanovic [Mon, 5 Nov 2018 14:00:11 +0000 (15:00 +0100)]
[MIPS] Add support for 64b MIPS architecture

* LLVM reactor backend: requires LLVM 7.0
* Subzero reactor backend: not supported

Bug: b/117854176
Change-Id: I7b76ebf854f65c2d111552552bd5a81c049d3b50
Reviewed-on: https://swiftshader-review.googlesource.com/c/22308
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Gordana Cmiljanovic <gordana.cmiljanovic@mips.com>
5 years agoRevert "Fix for unused-lambda-capture warning"
Takuto Ikuta [Sat, 3 Nov 2018 10:43:22 +0000 (10:43 +0000)]
Revert "Fix for unused-lambda-capture warning"

This reverts commit d0d9928f376ccb88b83a03cf15eb5913e720663e.

Reason for revert: This broke build, NumElements needs to be captured in debug build

Change-Id: If5d8579a48229af9ff5a75dc7baeb544b195b746
Reviewed-on: https://swiftshader-review.googlesource.com/c/22288
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Takuto Ikuta <tikuta@google.com>
5 years agoFix for unused-lambda-capture warning
Takuto Ikuta [Tue, 23 Oct 2018 13:44:39 +0000 (22:44 +0900)]
Fix for unused-lambda-capture warning

We can use const local variables without capturing.

bug: chromium:681136
Change-Id: I2df60e02920841222b6e63aaa2be3ecbb8d6db2c
Reviewed-on: https://swiftshader-review.googlesource.com/c/21848
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Takuto Ikuta <tikuta@google.com>
5 years agoCompile only the target architecture LLVM backend.
Nicolas Capens [Wed, 31 Oct 2018 20:20:42 +0000 (16:20 -0400)]
Compile only the target architecture LLVM backend.

Reactor is a run-time code generator so it only needs to support the
CPU architecture for which it is being compiled. This reduces (static)
compile time and potentially the binary size.

Bug b/115344057

Change-Id: I925875e33e3c24dfc41abc1c055353a4099be618
Reviewed-on: https://swiftshader-review.googlesource.com/c/22208
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFix 'continue' in GLSL loops.
Nicolas Capens [Thu, 1 Nov 2018 20:53:36 +0000 (16:53 -0400)]
Fix 'continue' in GLSL loops.

The test expression of a loop is placed between the TEST and ENDWHILE
shader assembly instructions, and should no longer be affected by the
cleared execution mask of a continue statement. Thus TEST should always
be emitted, even for non-deterministic loops.

Other masks should still apply, and work recursively, so the
'whileTest' boolean to disable all masks during the test expression
evaluation has been replaced with a stack to restore the continue mask
at the TEST instruction.

Bug swiftshader:93
Bug b/118009174

Change-Id: I505c48f0344e61a6c31f81d26e93bc1217a105a2
Reviewed-on: https://swiftshader-review.googlesource.com/c/22248
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoRemove test setup headers.
Nicolas Capens [Wed, 31 Oct 2018 20:47:57 +0000 (16:47 -0400)]
Remove test setup headers.

These were moved to the Chromium repo in
https://chromium-review.googlesource.com/1311084

Change-Id: I1a0379cf5d28379fbde3d629b6beeaa9ac339841
Reviewed-on: https://swiftshader-review.googlesource.com/c/22209
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoUse two build jobs to speed up Travis CI.
Nicolas Capens [Thu, 1 Nov 2018 21:03:58 +0000 (17:03 -0400)]
Use two build jobs to speed up Travis CI.

Change-Id: I8f4dc30c4bace3c2a95c72b3fdd8b4eb200c80cd
Reviewed-on: https://swiftshader-review.googlesource.com/c/22249
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoDisable 'futimens' calls.
Nicolas Capens [Thu, 1 Nov 2018 16:10:43 +0000 (12:10 -0400)]
Disable 'futimens' calls.

It's not available on older versions of macOS.

Bug b/115344057

Change-Id: I220a26812e5d1bc1fd0bacae490a7bdbc6a7e6df
Reviewed-on: https://swiftshader-review.googlesource.com/c/22228
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFix symbol name mangling for LLVM 7.0.
Nicolas Capens [Wed, 31 Oct 2018 18:38:53 +0000 (14:38 -0400)]
Fix symbol name mangling for LLVM 7.0.

The Mach-O executable format, used on macOS/Darwin, stores function
names in mangled form, so we need to mangle it ourselves during
function pointer lookup.

Bug b/115344057

Change-Id: I8de5756c52b5af666826134fca8274b4467fa85a
Reviewed-on: https://swiftshader-review.googlesource.com/c/22188
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoCompile only the target architecture LLVM backend.
Nicolas Capens [Tue, 30 Oct 2018 20:36:52 +0000 (16:36 -0400)]
Compile only the target architecture LLVM backend.

Reactor is a run-time code generator so it only needs to support the
CPU architecture for which it is being compiled. This reduces (static)
compile time and potentially the binary size.

Bug b/115344057

Change-Id: Id25dd986a888af5175d43c33e4c60bb3e4733eda
Reviewed-on: https://swiftshader-review.googlesource.com/c/22128
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoAdd LLVM 7.0 config for macOS.
Nicolas Capens [Tue, 30 Oct 2018 17:49:46 +0000 (13:49 -0400)]
Add LLVM 7.0 config for macOS.

Bug b/115344057

Change-Id: I755f06f125fe0b7f170a0ec325f7e112b8cc789c
Reviewed-on: https://swiftshader-review.googlesource.com/c/22108
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years ago[MIPS] Update llvm 7.0 gn build file for mipsel
Gordana Cmiljanovic [Mon, 29 Oct 2018 16:14:16 +0000 (17:14 +0100)]
[MIPS] Update llvm 7.0 gn build file for mipsel

This enables LLVM reactor backend to be used for mipsel
in Chromium, though Subzero remains the default option.

Bug: b/117854176
Change-Id: I8c66017cd3a966202b61f8cbd65e065e3512e1e5
Reviewed-on: https://swiftshader-review.googlesource.com/c/22008
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Gordana Cmiljanovic <gordana.cmiljanovic@mips.com>
5 years agoFix Vulkan build.
Nicolas Capens [Tue, 30 Oct 2018 00:53:14 +0000 (20:53 -0400)]
Fix Vulkan build.

Initialization order mismatch is treated as an error with Clang/GCC:
-Werror=reorder

Bug b/118383648

Change-Id: I4e56aa3c61ce35d70a28dbdd1ab76d7ca8dae833
Reviewed-on: https://swiftshader-review.googlesource.com/c/22068
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoGenerate an error when trying to clear an incomplete Framebuffer
Alexis Hetu [Mon, 29 Oct 2018 18:56:42 +0000 (14:56 -0400)]
Generate an error when trying to clear an incomplete Framebuffer

Calling ClearBuffer* on an incomplete framebuffer was crashing
because a depth clear assumes 4 bytes per pixel and the type of
an incomplete framebuffer could be anything, which is potentially
smaller than 4 bytes, so memory was written out of bounds.

ClearBuffer* now also checks for completeness, just like clear
already does.

From the OpenGL ES 3.0 spec, section 4.4.4.4
"Effects of Framebuffer Completeness on Framebuffer Operations

 Attempting to render to or read from a framebuffer which is not
 framebuffer complete will generate an INVALID_FRAMEBUFFER_OPERATION
 error. This means that rendering commands (see section 2.6) ...
 will generate the error INVALID_FRAMEBUFFER_OPERATION if called
 while the framebuffer is not framebuffer complete"

And from the OpenGL ES 3.0 spec, section 2.6 Rendering Commands
"GL commands performing rendering into a framebuffer are called
 rendering commands, and include the drawing commands Draw* ...,
 as well as these additional commands:
• BlitFramebuffer
• Clear
• ClearBuffer*"

Bug b/117048995

Change-Id: I01fd2ad2829b4c9e0aac817620f65c789b11356e
Reviewed-on: https://swiftshader-review.googlesource.com/c/22048
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoDisable header-hygiene warnings on all platforms
Sergey Ulanov [Mon, 29 Oct 2018 18:11:55 +0000 (11:11 -0700)]
Disable header-hygiene warnings on all platforms

Previously -Wno-header-hygiene was added to cflags only on x64, so the
compiler was generating a lot of warnings when compiling for arm64.
Now this flag is added on all platforms.

Also removed -Wno-null-dereference - it doesn't generate any warnings.

Change-Id: Id145404dba169da64a6febdec2732aec681a11bd
Reviewed-on: https://swiftshader-review.googlesource.com/c/22028
Tested-by: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoDefault to LLVM 7.0 in CMake build.
Nicolas Capens [Mon, 15 Oct 2018 16:54:41 +0000 (12:54 -0400)]
Default to LLVM 7.0 in CMake build.

Bug b/115344057

Change-Id: Icda7cddb26f747c0ce9d4edc4972f9afa3a5e02b
Reviewed-on: https://swiftshader-review.googlesource.com/c/21509
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFix OGLES2HelloAPI and Vulkan build.
Nicolas Capens [Fri, 26 Oct 2018 14:34:20 +0000 (10:34 -0400)]
Fix OGLES2HelloAPI and Vulkan build.

Assigning string literals to char* has been deprecated since C++98 and
is now an error in Visual Studio. Also, a goto which skips variable
nationalizations is an error now.

std::min/max are defined in <algorithm>

Bug swiftshader:121

Change-Id: Ic087706de810e68849eb021c1e0a9d2f2a960260
Reviewed-on: https://swiftshader-review.googlesource.com/c/21988
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoBuffer, BufferView and DeviceMemory
Alexis Hetu [Thu, 18 Oct 2018 19:08:13 +0000 (15:08 -0400)]
Buffer, BufferView and DeviceMemory

This cl adds Buffer, BufferView and DeviceMemory.
- DeviceMemory contains the appropriate logic to allocate and map
  device memory.
- Buffer simply wraps a DeviceMemory and an offset for now.
- BufferView wraps a Buffer with a memory region and a Format.

Bug b/118383648

Change-Id: I6d53b9f0728d4cdec2696339cc6aa8ce2e05ca49
Reviewed-on: https://swiftshader-review.googlesource.com/c/21728
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoDefault to LLVM 7.0 JIT in Android build.
Nicolas Capens [Mon, 15 Oct 2018 16:55:02 +0000 (12:55 -0400)]
Default to LLVM 7.0 JIT in Android build.

Also fall back to LLVM 3.0 automatically if C++11 is not supported.

Bug b/115344057
Bug b/116540140

Change-Id: Ied0bfa17fcdc82f1181704fd63eda5c312b8380e
Reviewed-on: https://swiftshader-review.googlesource.com/c/21510
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoRemove Vulkan 32-bit Visual Studio configuration.
Nicolas Capens [Thu, 25 Oct 2018 18:12:06 +0000 (14:12 -0400)]
Remove Vulkan 32-bit Visual Studio configuration.

Bug swiftshader:121

Change-Id: I8c76a75e25c59ec8f71c5874dd0797202253f215
Reviewed-on: https://swiftshader-review.googlesource.com/c/21948
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFixes for extension enumeration
Chris Forbes [Thu, 25 Oct 2018 18:19:54 +0000 (11:19 -0700)]
Fixes for extension enumeration

- Version exposed with each extension is the revision of the extension
  itself, not the API version.

- Instance and device extensions must be exposed in the correct lists

- Handle VK_INCOMPLETE case

V2: Also handle excessive count

Bug: b/116336664
Change-Id: I97ad644359b761142f397855e49c0651181b3e77
Reviewed-on: https://swiftshader-review.googlesource.com/c/21968
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years ago[MIPS] Add LLVM 7.0 configs for Mips
Gordana Cmiljanovic [Thu, 25 Oct 2018 13:22:04 +0000 (15:22 +0200)]
[MIPS] Add LLVM 7.0 configs for Mips

Bug: b/117854176
Change-Id: I3732949af676a313e6ad284efcb91a90acd651ff
Reviewed-on: https://swiftshader-review.googlesource.com/c/21868
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Gordana Cmiljanovic <gordana.cmiljanovic@mips.com>
5 years agoFix validating glFramebuffer* attachment.
Nicolas Capens [Thu, 25 Oct 2018 01:01:17 +0000 (21:01 -0400)]
Fix validating glFramebuffer* attachment.

The OpenGL ES 3.0 spec states:
An INVALID_OPERATION error is generated if attachment is COLOR_-
ATTACHMENTm where m is greater than or equal to the value of MAX_COLOR_-
ATTACHMENTS.
An INVALID_ENUM error is generated if attachment is not one of the attachments
in table 4.6, and attachment is not COLOR_ATTACHMENTm where
m is greater than or equal to the value of MAX_COLOR_ATTACHMENTS.

Bug b/116776063

Change-Id: Iaabbcd3689d08ebdde2046440cf24554e9a160c2
Reviewed-on: https://swiftshader-review.googlesource.com/c/21908
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoSuppress warnings in subzero
Aurimas Liutikas [Thu, 25 Oct 2018 01:13:55 +0000 (01:13 +0000)]
Suppress warnings in subzero

There are no plans to fix them, so let's suppress it.

Bug: b/118397735
Change-Id: Ie2b621e1cf315a8e24c9b29b6e2bf8a7762e7b6e
Reviewed-on: https://swiftshader-review.googlesource.com/c/21889
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Aurimas Liutikas <aurimas@google.com>
5 years agoUse a trampoline for all GL entry functions.
Nicolas Capens [Thu, 2 Aug 2018 17:56:32 +0000 (13:56 -0400)]
Use a trampoline for all GL entry functions.

Bug swiftshader:64

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