OSDN Git Service

android-x86/external-swiftshader.git
5 years agoFix the CMake build
Chris Forbes [Thu, 6 Dec 2018 21:25:59 +0000 (13:25 -0800)]
Fix the CMake build

One part of this might change -- master contains some uses of
std::make_unique which Alexis might get rid of.

Change-Id: I40ae17f4e88920c4d60b79e1d4b117a7800fcd82
Reviewed-on: https://swiftshader-review.googlesource.com/c/23028
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoFixed link time warnings on MacOS
Alexis Hetu [Mon, 26 Nov 2018 22:25:23 +0000 (17:25 -0500)]
Fixed link time warnings on MacOS

MacOS' linker dislikes local static variables that are used
in two separate libraries. Removing them from the header files
fixes all the warnings.

Bug b/chromium:907088

Change-Id: I7b8ed44bf9a3180489a7407980740fd3f3863046
Reviewed-on: https://swiftshader-review.googlesource.com/c/22889
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoBasic commands required to draw a simple triangle test
Alexis Hetu [Wed, 31 Oct 2018 15:41:25 +0000 (11:41 -0400)]
Basic commands required to draw a simple triangle test

This cl adds the code needed to record and submit the minimal
subset of commands required to run a simple triangle example.

The commands themselves are still unimplemented.

Bug b/116336664

Change-Id: Id0109980225a64a2bb3599a89a5495091926c635
Reviewed-on: https://swiftshader-review.googlesource.com/c/22168
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoVkPipeline simple implementation
Alexis Hetu [Thu, 15 Nov 2018 21:25:38 +0000 (16:25 -0500)]
VkPipeline simple implementation

Added a few class members and adjusted the VkPipeline constructor
to extract basic parameters which will be used for rendering, like:
- Basic sw::Context parameters
- Scissor
- Viewport
- BlendConstants

Note: sw::Context should eventually be replaced by VkPipeline and be
      used directly by sw::Renderer once all existing OpenGL ES 3.0
      has been converted from VkPipeline.

(Chris: rebase + build system fixes for CMake path)

Change-Id: I7e7a9ff3c768da8e8c1e9461e140af4986429602
Reviewed-on: https://swiftshader-review.googlesource.com/c/22613
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
5 years agoFix cmake-based build
Chris Forbes [Thu, 6 Dec 2018 00:48:33 +0000 (16:48 -0800)]
Fix cmake-based build

Change-Id: I45349cd6530814efa0c466beb0df7d53b4e17948
Reviewed-on: https://swiftshader-review.googlesource.com/c/23008
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoEnable ARM32 in src/Reactor/BUILD.gn
Kevin Schoedel [Wed, 28 Nov 2018 21:35:20 +0000 (16:35 -0500)]
Enable ARM32 in src/Reactor/BUILD.gn

Bug b/114402930

Change-Id: I228222003e5f015e4966eacc32094a48a7054d0f
Reviewed-on: https://swiftshader-review.googlesource.com/c/22988
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Kevin Schoedel <kpschoedel@google.com>
5 years agoAllow Command Buffers to be allocated and freed
Alexis Hetu [Mon, 19 Nov 2018 16:30:43 +0000 (11:30 -0500)]
Allow Command Buffers to be allocated and freed

Added functionality so that the CommandPool can allocate and
free command buffer objects.

Bug b/119827933

Change-Id: I190ba3cd7738f2b5e37b196a0abba6d07cfae173
Reviewed-on: https://swiftshader-review.googlesource.com/c/22748
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoAllow swiftshader to be used as a subproject.
Erwin Jansen [Tue, 20 Nov 2018 00:01:37 +0000 (16:01 -0800)]
Allow swiftshader to be used as a subproject.

We basically replace all references to CMAKE_SOURCE_DIR and
CMAKE_BINARY_DIR with CMAKE_CURRENT_SOURCE_DIR and
CMAKE_CURRENT_BINARY_DIR.

This enables other cmake projects to take a direct dependency on this
project.

Test: cmake . still shows error for in source builds.
Test: mkdir build && cd build && cmake .. -G Ninja && ninja succeeds
Change-Id: Ibb8366f8e7fd3b3152634c71324a5182d269e647
Reviewed-on: https://swiftshader-review.googlesource.com/c/22692
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Erwin Jansen <jansene@google.com>
Tested-by: Erwin Jansen <jansene@google.com>
5 years agoWork around Subzero constant folding limitation.
Nicolas Capens [Wed, 28 Nov 2018 22:33:24 +0000 (17:33 -0500)]
Work around Subzero constant folding limitation.

The Subzero JIT only supports constants in the second operand of
arithmetic operations, not the first. It assumes constant folding
already took place (true for NaCl which takes LLVM IR as input).
Reactor has constant folding as part of the static C++ compilation,
but the Optimizer may substitute the first operand for a constant
(i.e. constant propagation).

Addressing it in the Optimizer by not performing the substitution
is not trivial because we'd have to check each use. And it would
cost run-time performance. Ideally we'd have a pass for
legalization/optimization which performs constant folding.

For now, avoid hitting 'unreachable' code in Subzero by multiplying
constants at the Reactor level.

Fixes regression caused by https://swiftshader-review.googlesource.com/22910

Bug chromium:904265
Bug swiftshader:14

Change-Id: Ifdc72ac997ad5d71c1f7006259f54f3d715cb613
Reviewed-on: https://swiftshader-review.googlesource.com/c/22930
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoFix textureSize for non-uniform samplers.
Nicolas Capens [Tue, 27 Nov 2018 22:07:49 +0000 (17:07 -0500)]
Fix textureSize for non-uniform samplers.

GLSL textureSize() calls that use a sampler that is not a uniform,
should not use the index of the register as the texture unit index.
Instead the index is the value stored in the register itself.

Bug chromium:904265

Change-Id: Iee1058e789daae15248ae5ffa940a0155dca61b5
Reviewed-on: https://swiftshader-review.googlesource.com/c/22910
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoRemoved SwiftShader's custom Viewport structure
Alexis Hetu [Tue, 27 Nov 2018 21:16:39 +0000 (16:16 -0500)]
Removed SwiftShader's custom Viewport structure

- Replaced sw::Viewport with VkViewport

Bug b/118386749

Change-Id: I2446883ba9e5623753322fc417386394a3fe370c
Reviewed-on: https://swiftshader-review.googlesource.com/c/22909
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoExpose the minimal subset of required supported formats
Alexis Hetu [Mon, 26 Nov 2018 19:10:44 +0000 (14:10 -0500)]
Expose the minimal subset of required supported formats

This cl exposes the bare minimum in terms of format requirements
in order to support Vulkan 1.1.

Fixes all failures in: dEQP-VK.api.info.format_properties.*

Bug b/117974925

Change-Id: Ia84b1b13430faffeb840e118b09b9f3e352c8cc9
Reviewed-on: https://swiftshader-review.googlesource.com/c/22888
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoRemoved SwiftShader's custom Blending enums
Alexis Hetu [Thu, 22 Nov 2018 21:40:52 +0000 (16:40 -0500)]
Removed SwiftShader's custom Blending enums

- Replaced BlendFactor with VkBlendFactor
- Replaced BlendOperation with VkBlendOp

Bug b/118386749

Change-Id: I25031c044af05b1922d031db9e82c52bb785def5
Reviewed-on: https://swiftshader-review.googlesource.com/c/22850
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoImplement extended vkCreateDevice features support.
Nicolas Capens [Mon, 19 Nov 2018 21:02:36 +0000 (16:02 -0500)]
Implement extended vkCreateDevice features support.

Implements support for VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 and
other structure types used during Vulkan 1.1 device creation.

Bug b/117974925

Change-Id: Ic23067f145322a814ccda7dd44a087d7a4020e3d
Reviewed-on: https://swiftshader-review.googlesource.com/c/22689
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFix entry function pointer queries.
Nicolas Capens [Mon, 19 Nov 2018 20:50:18 +0000 (15:50 -0500)]
Fix entry function pointer queries.

vkGetInstanceProcAddr must return NULL when the instance parameter is
NULL, except for a few global functions.

vkGetDeviceProcAddr must return NULL for any non-device-level functions.

Fixes dEQP-VK.api.version_check.entry_points

Bug b/116336664

Change-Id: I446edb0b8c4b94938e0ab77913c8ad391d490f4f
Reviewed-on: https://swiftshader-review.googlesource.com/c/22688
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoReplace <memory.h> with <cstring>.
Nicolas Capens [Fri, 16 Nov 2018 19:28:36 +0000 (14:28 -0500)]
Replace <memory.h> with <cstring>.

<memory.h> isn't actually an official standard C header.
memcpy() is defined in <string.h> / <cstring>.

Change-Id: I578e3a8ea741934e594049e359b906665de80134
Reviewed-on: https://swiftshader-review.googlesource.com/c/22649
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoUpdate Vulkan headers to version 1.1.93.
Nicolas Capens [Fri, 16 Nov 2018 18:54:44 +0000 (13:54 -0500)]
Update Vulkan headers to version 1.1.93.

This adds the Pastel driver ID.

https://github.com/KhronosGroup/Vulkan-Docs
revision 256a1ef66182b2d458148f2fdea183557ea3f507

Bug b/116336664

Change-Id: I3d227eaff99b6bd8402b0808cfad7501438e9e65
Reviewed-on: https://swiftshader-review.googlesource.com/c/22648
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoUpdate Vulkan dEQP testing documentation.
Nicolas Capens [Fri, 23 Nov 2018 15:29:44 +0000 (10:29 -0500)]
Update Vulkan dEQP testing documentation.

SwiftShader can now be tested directly with dEQP, without using the
system's Vulkan loader or layers.

Bug b/116336664

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