OSDN Git Service

android-x86/external-swiftshader.git
5 years agoFix unaligned access undefined behavior.
Nicolas Capens [Thu, 22 Nov 2018 16:13:45 +0000 (11:13 -0500)]
Fix unaligned access undefined behavior.

Unaligned accesses are undefined behavior, but they're common in our
ELF binary patching code for variable length instruction sets (namely
x86).

We can use memcpy() and rely on target-specific compiler optimizations
to make it efficient. Utility functions and classes were added to aid
readability.

Bug b/119823623

Change-Id: I8a82672a0d18d1e1783f580eb629f8cc09a009cd
Reviewed-on: https://swiftshader-review.googlesource.com/c/22828
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFix undefined behavior in OFFSET().
Nicolas Capens [Thu, 22 Nov 2018 15:32:35 +0000 (10:32 -0500)]
Fix undefined behavior in OFFSET().

Accessing members of a null pointer is undefined behavior, even when
only used to obtain the address again. So use a non-zero value as the
base pointer address instead. 32 was chosen to provide sufficient
alignment guarantees.

Bug b/119823623

Change-Id: Ia6d24dd6c2740261948860c45eb35cc489a3a827
Reviewed-on: https://swiftshader-review.googlesource.com/c/22788
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoRemoved SwiftShader's custom LogicalOperation enum
Alexis Hetu [Thu, 22 Nov 2018 20:55:59 +0000 (15:55 -0500)]
Removed SwiftShader's custom LogicalOperation enum

Replaced LogicalOperation with VkLogicOp.

Bug b/118386749

Change-Id: I9776dd112e2a742cd73fba241e0659813cc974e7
Reviewed-on: https://swiftshader-review.googlesource.com/c/22849
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoPlaceholder object for VkPipelineCache
Alexis Hetu [Mon, 19 Nov 2018 16:30:43 +0000 (11:30 -0500)]
Placeholder object for VkPipelineCache

While implementing Pipeline Cache is optional, we still need a
placeholder object in order to return have a valid handle for
this object.

b/118386749

Change-Id: I18abb4196fbc99d3f639c1ba14ceb570ac11b365
Reviewed-on: https://swiftshader-review.googlesource.com/c/22729
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoInitial implementation of CommandPool
Alexis Hetu [Tue, 20 Nov 2018 21:26:10 +0000 (16:26 -0500)]
Initial implementation of CommandPool

Basic shell class for CommandPool

Bug b/119827933

Change-Id: Ibbc8ac641b168a15974fd4ff1803b5aff51f48a3
Reviewed-on: https://swiftshader-review.googlesource.com/c/22730
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoVulkan Sampler implementation
Alexis Hetu [Mon, 19 Nov 2018 16:30:43 +0000 (11:30 -0500)]
Vulkan Sampler implementation

The Vulkan sampler is simply a state, similar to the existing
sw::Sampler::State(), which will eventually be used by the
texture sampling code.

Bug b/119823006

Change-Id: Ib2f09683f82dbf5b5aacde1555ee850c76cda9e2
Reviewed-on: https://swiftshader-review.googlesource.com/c/22728
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRemoved SwiftShader's custom Depth/Stencil comparison enums
Alexis Hetu [Thu, 15 Nov 2018 21:25:38 +0000 (16:25 -0500)]
Removed SwiftShader's custom Depth/Stencil comparison enums

- Replaced DepthCompareMode, StencilCompareMode and AlphaCompareMode
  by VkCompareOp.
- Replaced StencilOperation by VkStencilOp.

Bug b/118386749

Change-Id: I7dec0cff119012345865eb164599f086edf2c88a
Reviewed-on: https://swiftshader-review.googlesource.com/c/22768
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAdd support for all vulkan formats in Surface::bytes()
Alexis Hetu [Wed, 14 Nov 2018 20:17:16 +0000 (15:17 -0500)]
Add support for all vulkan formats in Surface::bytes()

Surface::bytes() now supports all non-extension vulkan image formats.
Compressed formats are partially supported, the same way they were
for the OpenGL ES 3.0 implementation.

Bug b/118429780

Change-Id: Ica7f7d7184e9e00eeedfc76bc6b5c19e07aa3caf
Reviewed-on: https://swiftshader-review.googlesource.com/c/22568
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoReplaced sw::Format with VkFormat
Alexis Hetu [Wed, 14 Nov 2018 18:39:28 +0000 (13:39 -0500)]
Replaced sw::Format with VkFormat

To avoid format conversion issues and simplify the code, sw::Format
was replaced with VkFormat. sw::Format only contained formats with
exact 1:1 correspondence with an equivalent VkFormat, with the
exception of YUV formats, which will require a minor adjustment in
SamplerCore::sampleTexel().

Bug b/119620767

Change-Id: I8124cbc40e1031a5b233156a10e87c35f1334eef
Reviewed-on: https://swiftshader-review.googlesource.com/c/22549
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoInitial implementation of RenderPass
Alexis Hetu [Thu, 15 Nov 2018 20:18:41 +0000 (15:18 -0500)]
Initial implementation of RenderPass

Basic shell class for RenderPass

Bug b/119620965

Change-Id: Ice98943587f363f8cf03eddd3cc4c504b899d682
Reviewed-on: https://swiftshader-review.googlesource.com/c/22612
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoInitial implementation of Framebuffer
Alexis Hetu [Thu, 15 Nov 2018 20:11:36 +0000 (15:11 -0500)]
Initial implementation of Framebuffer

Basic shell class for Framebuffer

Bug b/119621736

Change-Id: Iaf5466d311efe011ea7bbd4a6e3ab2802474f98e
Reviewed-on: https://swiftshader-review.googlesource.com/c/22611
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoInitial implementation of Image
Alexis Hetu [Thu, 15 Nov 2018 19:51:15 +0000 (14:51 -0500)]
Initial implementation of Image

Basic shell class for Image

Bug b/119620767

Change-Id: I75d37dd8c1a9b98264fe6dae68cd4753d6942103
Reviewed-on: https://swiftshader-review.googlesource.com/c/22610
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoInitial implementation of ShaderModule
Alexis Hetu [Thu, 15 Nov 2018 18:44:31 +0000 (13:44 -0500)]
Initial implementation of ShaderModule

Basic shell class for ShaderModule

Bug b/118386749

Change-Id: Ia41957ba1ef3be179d20c37cea0227a9a4509c7b
Reviewed-on: https://swiftshader-review.googlesource.com/c/22609
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoInitial implementation of Pipeline, PipelineLayout
Alexis Hetu [Wed, 24 Oct 2018 19:22:41 +0000 (15:22 -0400)]
Initial implementation of Pipeline, PipelineLayout

Basic shell classes for Pipeline, PipelineLayout

b/118386749

Change-Id: I1ec82d1bf2334d5e2cd338d96eff63f3714db198
Reviewed-on: https://swiftshader-review.googlesource.com/c/21888
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoSwitch to c++11 for swiftshader.
Stephen Hines [Fri, 16 Nov 2018 01:53:50 +0000 (17:53 -0800)]
Switch to c++11 for swiftshader.

This library depends on a snapshot of LLVM that only works with C++11.

Bug: http://b/111067277
Test: Build with default cpp_std as C++17.
Change-Id: I40de7e2357afa3c16ceac7f50241a6d0437aba09
Reviewed-on: https://swiftshader-review.googlesource.com/c/22628
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Stephen Hines <srhines@google.com>
5 years agoAdded missing frameworks on MacOs for vertex routine fuzzer
Alexis Hetu [Thu, 15 Nov 2018 15:28:50 +0000 (10:28 -0500)]
Added missing frameworks on MacOs for vertex routine fuzzer

Moved MacOS specific frameworks from swiftshader_libGLESv2 to
swiftshader_libGLESv2_static to make sure the static version
also links properly.

Bug chromium:905648

Change-Id: I7736009abc378d634313028eb51aa0bb221c6419
Reviewed-on: https://swiftshader-review.googlesource.com/c/22608
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoPrevent glDeleteQueries from deleting a live Query
Alexis Hetu [Wed, 14 Nov 2018 15:54:53 +0000 (10:54 -0500)]
Prevent glDeleteQueries from deleting a live Query

glDeleteQueries() instantly deletes all the es2::Query objects
passed as arguments to this function. If some of these queries
are still being used by the renderer, this will result in a use
after free error. To solve this issue, sw::Query is now a also
ref counted object.

Bug chromium:904714

Change-Id: Ic1d5781bbf1724d8d07936fd49c8a172dc3d9fd4
Reviewed-on: https://swiftshader-review.googlesource.com/c/22548
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRefactor physical device feature query.
Nicolas Capens [Tue, 13 Nov 2018 19:06:37 +0000 (14:06 -0500)]
Refactor physical device feature query.

VkPhysicalDeviceFeatures only contains VkBool32 members, and is also
described by the spec as a "structure that contains boolean indicators
of all the features to be enabled", as well as "For each feature, a
value of VK_TRUE specifies that the feature is supported on this
physical device, and VK_FALSE specifies that the feature is not
supported". Hence we can safely process it as an array of VkBool32.

This is also more likely to return false early when a requested feature
is not supported.

Bug b/117974925

Change-Id: I106ba6abf5f29874cde91fdaafd1dd9560aabfa9
Reviewed-on: https://swiftshader-review.googlesource.com/c/22512
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFix feature query infinite loop.
Nicolas Capens [Tue, 13 Nov 2018 20:17:16 +0000 (15:17 -0500)]
Fix feature query infinite loop.

When an unsupported structure type was encountered this would lead to an
infinite loop.

Bug b/117974925

Change-Id: I0ba68e80a162ee631ae122b765cf8ea1149b3a3b
Reviewed-on: https://swiftshader-review.googlesource.com/c/22510
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoRemove unsupported functionality.
Nicolas Capens [Tue, 13 Nov 2018 20:03:35 +0000 (15:03 -0500)]
Remove unsupported functionality.

Bug b/117974925

Change-Id: I9c4553a1586e4f9e4a193b24f6c1b07749a7702a
Reviewed-on: https://swiftshader-review.googlesource.com/c/22509
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoDefine generic memory type.
Nicolas Capens [Tue, 13 Nov 2018 19:06:37 +0000 (14:06 -0500)]
Define generic memory type.

Generic system memory is cached on all known ARMv8 and x86 CPUs, so
advertise it as such.

Bug b/118383648

Change-Id: Ic757206a497fc299e1e76a939220092f7c0a124d
Reviewed-on: https://swiftshader-review.googlesource.com/c/22448
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoBase the driver version on Version.h.
Nicolas Capens [Tue, 13 Nov 2018 19:18:26 +0000 (14:18 -0500)]
Base the driver version on Version.h.

Also always clear the UUIDs first so that shorter strings don't leave
data undefined.

Bug b/116336664

Change-Id: I77d5ae1514db5d68d540614b7c57c4872695ecca
Reviewed-on: https://swiftshader-review.googlesource.com/c/22490
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoExport Vulkan API entry functions.
Nicolas Capens [Tue, 13 Nov 2018 18:40:29 +0000 (13:40 -0500)]
Export Vulkan API entry functions.

This enables running the unit tests without manually querying each entry
function. The compiler generates a .lib file for us which load the .dll
file and retrieves the entry functions.

Also fix project dependencies and DLL path.

Bug b/116336664

Change-Id: I4cbd80bd071a20058b034db8fb12e31f9af2e081
Reviewed-on: https://swiftshader-review.googlesource.com/c/22489
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFix debugger wait dialog.
Nicolas Capens [Wed, 14 Nov 2018 05:19:12 +0000 (00:19 -0500)]
Fix debugger wait dialog.

The popup dialog for waiting for the debugger was missing a resource,
causing DllMain to fail and thus failure to load the DLL.

Bug b/116336664

Change-Id: Ic12af87f3eb272a1f1ba27917926dcd845d86977
Reviewed-on: https://swiftshader-review.googlesource.com/c/22528
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFixed lineWidth and pointSize limits
Alexis Hetu [Tue, 13 Nov 2018 20:24:15 +0000 (15:24 -0500)]
Fixed lineWidth and pointSize limits

Changed limits for lineWidth and pointSize so that they're unsupported.
This fixes all remaining failures in dEQP-VK.api.info.device

b/117974925

Change-Id: I228dcb5305f2bfe5bb053aa968cebcbb7afaee98
Reviewed-on: https://swiftshader-review.googlesource.com/c/22511
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoDisabling the debugger wait dialog by default with Vulkan
Alexis Hetu [Tue, 13 Nov 2018 18:28:20 +0000 (13:28 -0500)]
Disabling the debugger wait dialog by default with Vulkan

For some reason, the Vulkan Loader prevents any dialog window from
popping up, which means that loading the SwiftShader Vulkan DLL in
Debug was always failing, unless a debugger was already attached
(as is the case when running from within Visual Studio). The
debugger wait dialog can still be easily enabled locally by setting
the DEBUGGER_WAIT_DIALOG environment variable.

Bug b/116336664

Change-Id: I7ce596c753506c806bf6b159685a72d0372f949a
Reviewed-on: https://swiftshader-review.googlesource.com/c/22488
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoCompile host specific files when cross-compiling
Gordana Cmiljanovic [Thu, 8 Nov 2018 11:56:07 +0000 (12:56 +0100)]
Compile host specific files when cross-compiling

This fixes Chromium (mips64el) cross-comile failure
for v8 snapshot for host.

Bug: b/115344057, b/117854176
Change-Id: I0a348701151b9db288a3de84ef22c23bbd007a80
Reviewed-on: https://swiftshader-review.googlesource.com/c/22408
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Milko Leporis <milko.leporis@mips.com>
5 years agoPrevent repeatedly trying to load a non-existent library
Alexis Hetu [Mon, 12 Nov 2018 19:21:27 +0000 (14:21 -0500)]
Prevent repeatedly trying to load a non-existent library

A hang in Chromium on MacOS seems related to attempting to load
libGLES_CM repeatedly, since it doesn't exist. While dlopen()
probably shouldn't be this slow, it could also be related to a
sandboxing issue. In any case, this cl attempts to go around the
issue by never trying to load a library twice.

Bug chromium:904346

Change-Id: I65122f0fc9acb4f8db2a606437c61796464f72ad
Reviewed-on: https://swiftshader-review.googlesource.com/c/22468
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoFixed warnings in the Vulkan project
Alexis Hetu [Thu, 8 Nov 2018 21:11:50 +0000 (16:11 -0500)]
Fixed warnings in the Vulkan project

Some classes were given the following attribute:
[[clang::lto_visibility_public]]

This produces a warning in Visual Studio.

This was meant to allow these base classes to be visible
to both libEGL and libGLESv2. Vulkan will be a single DLL,
so this won't be an issue, so I simply removed both
instances of this attribute in the Vulkan project.

Change-Id: I6d1b0bb0ab5351d6b788917c0b876e9355505404
Reviewed-on: https://swiftshader-review.googlesource.com/c/22428
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoVulkan image formats
Alexis Hetu [Mon, 22 Oct 2018 18:54:09 +0000 (14:54 -0400)]
Vulkan image formats

4 basic things here:
- Set SwiftShader formats to match the equivalent Vulkan format,
  when available
- Removed SwiftShader formats with no exact match in Vulkan formats
- Added all currently unavailable Vulkan formats in comments in the
  list, possibly to be added later, when necessary
- Marked all mandatory sampled formats in the list (in comments)

Bug b/118429780

Change-Id: I7d7b661e64cb4aee9eb724c64664cee8271cc48c
Reviewed-on: https://swiftshader-review.googlesource.com/c/21808
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoOnly enable Clang-specific errors on Clang.
Nicolas Capens [Wed, 7 Nov 2018 04:50:05 +0000 (23:50 -0500)]
Only enable Clang-specific errors on Clang.

-W[error=]unused-lambda-capture is not recognized by GCC.

Change-Id: I6d1bfc470c4afc0e72b76d2a26efb85eb8d8c8fb
Reviewed-on: https://swiftshader-review.googlesource.com/c/22368
Reviewed-by: Takuto Ikuta <tikuta@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Takuto Ikuta <tikuta@google.com>
5 years agoFix deterministic loops within conditional blocks, again.
Nicolas Capens [Tue, 6 Nov 2018 16:56:21 +0000 (11:56 -0500)]
Fix deterministic loops within conditional blocks, again.

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 for the loop initialization and
initial test. A new shader assembly instruction 'SCALAR' was added for
doing this.

Previously this was conflated with the 'TEST' instruction, which should
independently disable/restore the 'continue' mask.

Bug swiftshader:93
Bug b/118009174

Change-Id: I4add1a6d74231f463217e57adfabdc81faf489ae
Reviewed-on: https://swiftshader-review.googlesource.com/c/22348
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoEliminate legacy functionality.
Nicolas Capens [Wed, 31 Oct 2018 15:25:15 +0000 (11:25 -0400)]
Eliminate legacy functionality.

Vulkan doesn't require any fixed-function vertex and pixel processing.

Bug b/117152542

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