OSDN Git Service

android-x86/external-swiftshader.git
5 years agoFix compilation error on android build.
Cody Schuffelen [Fri, 18 Jan 2019 02:12:47 +0000 (18:12 -0800)]
Fix compilation error on android build.

The error that appears when trying to build swiftshader master as part
of android is:
external/swiftshader/src/Shader/Shader.cpp:1886:51: error: expected '(' for function-style cast or type construction

Change-Id: I667f249e46ed99c3c598490182e495c0862c64a9
Reviewed-on: https://swiftshader-review.googlesource.com/c/23768
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agodrop c++ version for cmake build to 11
Chris Forbes [Fri, 18 Jan 2019 16:11:03 +0000 (08:11 -0800)]
drop c++ version for cmake build to 11

Change-Id: If4f1d021a19c7be43fa1996705a493bf33ec1dbe
Reviewed-on: https://swiftshader-review.googlesource.com/c/23809
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoremove remaining make_unique usage
Chris Forbes [Fri, 18 Jan 2019 16:33:15 +0000 (08:33 -0800)]
remove remaining make_unique usage

Change-Id: I2dfc8e09daaea0f93f9737b8738fdcd2c2fae539
Reviewed-on: https://swiftshader-review.googlesource.com/c/23808
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoReplaced std::make_unique with std::unique_ptr
Alexis Hetu [Mon, 7 Jan 2019 19:47:32 +0000 (14:47 -0500)]
Replaced std::make_unique with std::unique_ptr

std::make_unique is C++14, so for strict C++11, we have
to use std::unique_ptr. Added a new utility function,
CommandBuffer::addCommand, to make this change more
readable.

Change-Id: Icc62874a107543fa2c0599a338dbc6676047ad77
Reviewed-on: https://swiftshader-review.googlesource.com/c/23548
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoSplit types from other kinds of definitions
Chris Forbes [Mon, 14 Jan 2019 22:30:20 +0000 (14:30 -0800)]
Split types from other kinds of definitions

We always know from the context whether a particular id refers to a type
or something else. Split types out into their own map, and add an
accessor which ensures the type actually exists. This isn't so much
about checking for the provided code being valid, and more about
catching likely foul-ups in our own code.

Change-Id: If18831b1b604eed03fbbeaf352272b5ba15b37a9
Reviewed-on: https://swiftshader-review.googlesource.com/c/23608
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoAdd support for builtin blocks
Chris Forbes [Fri, 28 Dec 2018 20:03:10 +0000 (12:03 -0800)]
Add support for builtin blocks

Problem of supporting builtin blocks boils down to how you refer to them
from the API side -- if the reference is ONLY a SPIRV id, then block
members are difficult to work with. Instead, represent a builtin
variable binding as (id, first component, num components). For a single
variable, first component == 0 always.

Bug: b/120799499
Change-Id: If9e99f4c10f73a008e2f5071a95785920c7fbed1
Reviewed-on: https://swiftshader-review.googlesource.com/c/23488
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoAdd support for arrays to interface and size analyses
Chris Forbes [Fri, 28 Dec 2018 00:12:31 +0000 (16:12 -0800)]
Add support for arrays to interface and size analyses

Only missing piece here was the array size, which is available since
we support integer constants now.

Bug: b/120799499
Change-Id: I8c42aa2ced86e8358be1ffbfaa14ca87b58cc138
Reviewed-on: https://swiftshader-review.googlesource.com/c/23449
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoAdd minimal support for integer constants
Chris Forbes [Fri, 28 Dec 2018 00:02:58 +0000 (16:02 -0800)]
Add minimal support for integer constants

This is just enough support to be able to handle array sizes, etc.

Bug: b/120799499

Change-Id: I790d6accabe55efab9fd5e0c23c93b5d10b72e36
Reviewed-on: https://swiftshader-review.googlesource.com/c/23448
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoImplemented depth and stencil clear command
Alexis Hetu [Thu, 17 Jan 2019 19:51:43 +0000 (14:51 -0500)]
Implemented depth and stencil clear command

Added the ClearDepthStencilImage command and made some minor adjustments
to Image clear functions to make the depth and stencil clears work.

Passes all test in:
api.image_clearing.dedicated_allocation.clear_depth_stencil_image.*

Bug b/119620767

Change-Id: If4cfe6aa97b955c9bc7881bba89ab725897c36f9
Reviewed-on: https://swiftshader-review.googlesource.com/c/23728
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoAdded clear color image command
Alexis Hetu [Wed, 16 Jan 2019 20:54:55 +0000 (15:54 -0500)]
Added clear color image command

Added the command to send the clear color image command
to the Image object.

Bug b/118619338

Change-Id: Ic4e00fbd49e8e043df1d2e707e3c26dadf159790
Reviewed-on: https://swiftshader-review.googlesource.com/c/23653
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
5 years agoSupport for array layers and mip levels in VkImage objects
Alexis Hetu [Wed, 16 Jan 2019 19:21:33 +0000 (14:21 -0500)]
Support for array layers and mip levels in VkImage objects

Support for allocating, copying and clearing separate array
layers and/or mip levels in VkImage objects. As part of that,
most functions that compute memory offsets or sizes now all
take mip levels and array layers into account.

Also, since this can cause many consecutive calls to the
blitter, the blitter object is now a VkImage member rather
than being create in each function, in order to better use
the blitter cache.

Bug b/119620767

Change-Id: Ib29b66cc936b0734c8173a1b8b5b9ef157fc7956
Reviewed-on: https://swiftshader-review.googlesource.com/c/23648
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoAllow clearing image arrays in ImageView
Alexis Hetu [Wed, 16 Jan 2019 20:47:19 +0000 (15:47 -0500)]
Allow clearing image arrays in ImageView

Allow an image of type VK_IMAGE_VIEW_TYPE_(?)D with multiple array
layers to count as VK_IMAGE_VIEW_TYPE_(X)D_ARRAY in ImageView.

Bug b/119620767

Change-Id: I2d6ba3d960c531949529d72f5347442bb53990d6
Reviewed-on: https://swiftshader-review.googlesource.com/c/23651
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoCollect input/output interfaces
Chris Forbes [Tue, 11 Dec 2018 03:02:58 +0000 (19:02 -0800)]
Collect input/output interfaces

I'm still on the fence about leaving complex input/output definitions
intact. However, this provides enough support to walk such structures
all the way down to the leaves and determine exactly which components
are in use, what their types are, and what the interpolation qualifiers
etc should be.

Bug: b/120799499

Change-Id: Ia1e46a571126088e29bfdab6bc5ece0343e294e4
Reviewed-on: https://swiftshader-review.googlesource.com/c/23176
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoPort LLVM change rL350655
Tom Tan [Thu, 17 Jan 2019 00:27:58 +0000 (16:27 -0800)]
Port LLVM change rL350655

Chromium enabled warning -Wmicrosoft-include which complains the line "#include "Windows/WindowsSupport.h""
in lib/Support/Windows/Threading.inc because both files are under the same folder (see below error message). The fix was
merged to Clang master at https://reviews.llvm.org/rL350655. Port the change to unblock Windows ARM64 build before
a new rolling of LLVM to swiftshader.

error: #include resolved using non-portable Microsoft search rules as:
../../third_party/swiftshader/third_party/llvm-7.0/llvm/lib/Support/Windows/WindowsSupport.h [-Werror,-Wmicrosoft-include]

Bug: chromium:893460
Change-Id: I9eb32fd92e4d96f7d22a07a7c2da70b98eba19d3
Reviewed-on: https://swiftshader-review.googlesource.com/c/23669
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Tom Tan <Tom.Tan@microsoft.com>
5 years agoAdd support for SPIRV decorations
Chris Forbes [Mon, 10 Dec 2018 23:10:39 +0000 (15:10 -0800)]
Add support for SPIRV decorations

This works in a single pass, and supports both toplevel and member
decorations. Includes support for 5 new opcodes:

- OpDecorate introduces a single decoration for a toplevel id.

- OpMemberDecorate introduces a single decoration for a <id,
  memberIndex> pair.

- OpDecorationGroup introduces a new value category which has no
  representation downstream at all. This is safely implemented by
  doing nothing at all [we don't need to be able to introspect later].

- OpGroupDecorate applies all decorations in a decoration group to each
  of a list of other ids.

- OpGroupMemberDecorate applies all decorations in a decoration group to
  each of a list of members (<id>, memberIndex pairs).

Bug: b/120799499

Change-Id: Iaea970b23348e70d57ddb96a4df0726cfb511e03
Reviewed-on: https://swiftshader-review.googlesource.com/c/23174
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFixed all OOB accesses in VertexProgram and PixelProgram
Alexis Hetu [Thu, 10 Jan 2019 19:04:26 +0000 (14:04 -0500)]
Fixed all OOB accesses in VertexProgram and PixelProgram

A lot of arrays in VertexProgram and PixelProgram have fixed sizes,
so programs that have more nested loops or ifs or deeper call stacks
can cause OOB accesses, which causes security issues in Chromium.

Index clamping was added to prevent any OOB memory accesses here.

This could eventually be fixed properly by first verifying these sizes
and giving shader compile errors when these limits are exceeded.

Bug chromium:915197 chromium:915206 chromium:915218 b/116373662

Change-Id: I2d0710ed0ce6585f139cba49d5b5d8c909ae6391
Reviewed-on: https://swiftshader-review.googlesource.com/c/23568
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
5 years agoAdd builtin interface to spirv shader
Chris Forbes [Thu, 17 Jan 2019 18:10:09 +0000 (10:10 -0800)]
Add builtin interface to spirv shader

Initial structures to bridge the shader's use of particular builtins to
behavior of the "fixed function" logic wrapped around it.

Bug: b/120799499

Change-Id: I5cb360909c62615efab2e500f5c24109737e4ab7
Reviewed-on: https://swiftshader-review.googlesource.com/c/23709
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoMove AttribType enum to SpirvShader
Chris Forbes [Thu, 17 Jan 2019 17:51:39 +0000 (09:51 -0800)]
Move AttribType enum to SpirvShader

We're about to remove VertexShader, but we still care about types of
vertex attributes.

Bug: b/120799499

Change-Id: I80bed181479651e9d2470b81c7223e3381fbf4a7
Reviewed-on: https://swiftshader-review.googlesource.com/c/23708
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoAdd size calculation for spirv types
Chris Forbes [Sat, 8 Dec 2018 21:09:40 +0000 (13:09 -0800)]
Add size calculation for spirv types

SPIRV objects have arbitrary sizes -- they are not tied to previous
shader APIs' vec4-centric view of the world. In order to be able to
allocate space for both variables and ssavalues, we need to know how
many scalar components are present in each object.

Bug: b/120799499

Change-Id: I58551264eba5011be9bd01135cb35d541463993b
Reviewed-on: https://swiftshader-review.googlesource.com/c/23168
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFormatting-only change: conform better with swiftshader style
Chris Forbes [Thu, 17 Jan 2019 17:36:46 +0000 (09:36 -0800)]
Formatting-only change: conform better with swiftshader style

Change-Id: I5241cb398aa294a702c0f70980b80d399dfbc5b0
Reviewed-on: https://swiftshader-review.googlesource.com/c/23689
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoFix build
Chris Forbes [Thu, 17 Jan 2019 17:14:45 +0000 (09:14 -0800)]
Fix build

Half.hpp now requires <cmath>

Change-Id: Iab086681cfd3ed850ad184c77f88d13b5716e859
Reviewed-on: https://swiftshader-review.googlesource.com/c/23688
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoCollect type and variable definitions from SPIRV shader
Chris Forbes [Thu, 27 Dec 2018 19:48:21 +0000 (11:48 -0800)]
Collect type and variable definitions from SPIRV shader

Many other pieces will need an index of spirv-id to defining
instruction. Start building that up.

Bug: b/120799499

Change-Id: Ief6583f45c49fce02cb5dc40d12c6ba928e48fd7
Reviewed-on: https://swiftshader-review.googlesource.com/c/23428
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
5 years agoInitial stub implementation of SpirvShader
Chris Forbes [Fri, 7 Dec 2018 02:33:27 +0000 (18:33 -0800)]
Initial stub implementation of SpirvShader

This will eventually replace Shader and related subclasses. The
interesting bit here is the instruction iterator, which allows fairly
safe access to the instruction stream without needing the rest of the
code to care too much about the physical layout.

Bug: b/120799499

Change-Id: Id0d94c4b807ddb1e4325de147ca1f651171779b7
Reviewed-on: https://swiftshader-review.googlesource.com/c/23049
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoProduce correct error result for unsupported formats
Chris Forbes [Wed, 16 Jan 2019 23:17:24 +0000 (15:17 -0800)]
Produce correct error result for unsupported formats

vkGetPhysicalDeviceImageFormatProperties is required to return
VK_ERROR_FORMAT_NOT_SUPPORTED when the format is not supported.

CTS (validly) assumes that the format /is/ supported if this function
returns VK_SUCCESS.

Bug: b/119620767
Change-Id: I1f7d3ff8dbbfbc2dd100af7c3c4d7204f350dd06
Reviewed-on: https://swiftshader-review.googlesource.com/c/23668
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoMake the B10G11R11 and E5B9G9R9 formats fast clearable
Alexis Hetu [Wed, 16 Jan 2019 19:58:33 +0000 (14:58 -0500)]
Make the B10G11R11 and E5B9G9R9 formats fast clearable

Shamelessly copied the FP32 -> B10G11R11 and FP32 -> E5B9G9R9
conversion functions from Angle. This allows packing the clear
color for these formats into a single 32 bit integer, which can
then be used within the fast clear function.

Tested using:
api.image_clearing.core.clear_color_image.*.b10g11r11_ufloat_pack32
api.image_clearing.core.clear_color_image.*.e5b9g9r9_ufloat_pack32

Bug b/119620767

Change-Id: Ic268da62959582f084245e88181374213734760f
Reviewed-on: https://swiftshader-review.googlesource.com/c/23650
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
5 years agoAdded the ability to write to many new formats in the Blitter
Alexis Hetu [Wed, 16 Jan 2019 19:42:24 +0000 (14:42 -0500)]
Added the ability to write to many new formats in the Blitter

Added the missing 5_6_5, 2_10_10_10, 4, 8, 16 and 32 bit formats
that have integer based internal representation. Most of these
are the same as existing formats or trivial modification of
existing formats.

This only adds the ability to WRITE to these formats for now, as
these codepaths were tested using:
dEQP-VK.api.image_clearing.core.clear_color_image

If reading these formats becomes exercised by other tests, they
will be added at that point.

Bug b/119620767

Change-Id: I85317d7cfab6b1e708d6e6500ff44b83065a1d16
Reviewed-on: https://swiftshader-review.googlesource.com/c/23649
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
5 years agoFixed build on Arm 64
Alexis Hetu [Tue, 15 Jan 2019 21:14:38 +0000 (16:14 -0500)]
Fixed build on Arm 64

A few warnings were causing build errors on Arm 64.
Since we don't want to modify the LLVM code itself,
the warnings in the LLVM code are now suppressed.

Bug chromium:922089

Change-Id: I7e8827cda5117e8817342930dca8d7b7f90d339c
Reviewed-on: https://swiftshader-review.googlesource.com/c/23628
Tested-by: Alexis Hétu <sugoi@google.com>
Tested-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
5 years agoRemove VK support for GL-style symmetric clip space
Chris Forbes [Sat, 12 Jan 2019 00:51:12 +0000 (16:51 -0800)]
Remove VK support for GL-style symmetric clip space

Change-Id: Idb38063e6d8f7c6345118b2acddba4dcb99d0831
Reviewed-on: https://swiftshader-review.googlesource.com/c/23588
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agofix mismatched new/delete[] in BeginRenderPass
Chris Forbes [Sat, 29 Dec 2018 00:06:16 +0000 (16:06 -0800)]
fix mismatched new/delete[] in BeginRenderPass

Change-Id: I065e79f9ea676eaec25e89063908cae6f3854e4c
Reviewed-on: https://swiftshader-review.googlesource.com/c/23489
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years ago[Fuchsia] Implement ExecutableMemory support on Fuchsia.
Sergey Ulanov [Mon, 7 Jan 2019 18:29:18 +0000 (10:29 -0800)]
[Fuchsia] Implement ExecutableMemory support on Fuchsia.

Added fuchsia-specific versions of allocateExecutable() and
markExecutable().

Bug: chromium: 778467
Change-Id: I027f1409f7b0343e102f98fcc34f2e93c2d626e4
Reviewed-on: https://swiftshader-review.googlesource.com/c/23408
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Sergey Ulanov <sergeyu@chromium.org>
5 years agoAdd intrinsics and missing LLVM AsmParser files for Windows ARM64
Tom Tan [Thu, 3 Jan 2019 06:01:55 +0000 (22:01 -0800)]
Add intrinsics and missing LLVM AsmParser files for Windows ARM64

llvm::parseIR in llvm-7.0\llvm\lib\IRReader\IRReader.cpp calls parseAssembly
which is defined in lib/AsmParser/Parser.cpp, but the latter file is not
included in swiftshader_llvm which causes unresovled symbol for linking.
This CL added the necessary source files under llvm\AsmParser to
swiftshader_llvm.

This CL also changed __rdtsc() to use Windows ARM64 intrinsic _ReadStatusReg
to get cycle counter as alternative of __rdtsc().

Bug: chromium:893460
Change-Id: I269662f2e4249a3ec5495ecad02bc759139e1d4f
Reviewed-on: https://swiftshader-review.googlesource.com/c/23508
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Tom Tan <Tom.Tan@microsoft.com>
5 years agoRemove unnecessary ldflags.
Nico Weber [Fri, 4 Jan 2019 20:28:34 +0000 (15:28 -0500)]
Remove unnecessary ldflags.

The .def file is already in sources, which means GN will already add
this flag automatically (cf `gn help sources`).

No intended behavior change.

Bug: none
Change-Id: Ic8204bbdd9da47f3731d48e62ccfeb880ac9eddc
Reviewed-on: https://swiftshader-review.googlesource.com/c/23528
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nico Weber <thakis@chromium.org>
5 years ago[MIPS] Add support for mips32r1 arch variant
Milko Leporis [Tue, 18 Dec 2018 15:04:15 +0000 (16:04 +0100)]
[MIPS] Add support for mips32r1 arch variant

Change-Id: I37dfecd8c92f3f34c117432956d169f4b191c849
Reviewed-on: https://swiftshader-review.googlesource.com/c/23248
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Milko Leporis <milko.leporis@mips.com>
5 years agoFix for true integer blit to lower bit depth image
Alexis Hetu [Fri, 21 Dec 2018 17:03:31 +0000 (12:03 -0500)]
Fix for true integer blit to lower bit depth image

Blitting from a higher bit depth source to a lower bit depth
destination was not working properly because Vulkan expects
clamping, while the blitter was truncating the values.

From section 19.5. Image Copies with Scaling:
"Signed and unsigned integers are converted by first
 clamping to the representable range of the destination
 format, then casting the value."

This fixes all remaining failures in:
dEQP-VK.api.copy_and_blit.core.blit_image.all_formats.color.*

Bug b/119620767

Change-Id: Ibd1c1e4be4f5107e7d423781b46021f4c5df1070
Reviewed-on: https://swiftshader-review.googlesource.com/c/23368
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoSupport for reading low-bitdepth float formats in Blitter
Alexis Hetu [Thu, 20 Dec 2018 21:14:21 +0000 (16:14 -0500)]
Support for reading low-bitdepth float formats in Blitter

Added support for reading the following formats in the Blitter:
- VK_FORMAT_B10G11R11_UFLOAT_PACK32
- VK_FORMAT_E5B9G9R9_UFLOAT_PACK32

Fixes all failures in:
[dEQP-VK.api.copy_and_blit.core.blit_image.all_formats.color]
.b10g11r11_ufloat_pack32.*
.e5b9g9r9_ufloat_pack32.*

Bug b/119620767

Change-Id: Ie5824b59b0193115cc7d142efc41cc3ac516c05c
Reviewed-on: https://swiftshader-review.googlesource.com/c/23348
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoAdded support for half float in the Blitter
Alexis Hetu [Thu, 20 Dec 2018 19:00:49 +0000 (14:00 -0500)]
Added support for half float in the Blitter

Implemented Float <-> Half conversion. The conversion is copied from
Half.cpp and is the same as the C++ code, converted to Reactor code.
The conversion is NOT optimized. Optimizing this code path will be
done later, this cl only cares about correctness.

Passes all conversion tests to and from half float in the following
patterns:

[dEQP-VK.api.copy_and_blit.core.blit_image]
.all_formats.color.[supported format].r16_sfloat.*
.all_formats.color.[supported format].r16g16_sfloat.*
.all_formats.color.[supported format].r16g16b16a16_sfloat.*
.all_formats.color.r16_sfloat.*
.all_formats.color.r16g16_sfloat.*
.all_formats.color.r16g16b16a16_sfloat.*

Bug b/119620767

Change-Id: Icd725dcd2ddd8c54e6657a2c3210da270210a149
Reviewed-on: https://swiftshader-review.googlesource.com/c/23329
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoSupport for VK_FORMAT_A1R5G5B5_UNORM_PACK16 in Blitter
Alexis Hetu [Thu, 20 Dec 2018 18:18:18 +0000 (13:18 -0500)]
Support for VK_FORMAT_A1R5G5B5_UNORM_PACK16 in Blitter

Added support for VK_FORMAT_A1R5G5B5_UNORM_PACK16 in the Blitter.

Passes all tests in:
[dEQP-VK.api.copy_and_blit.core.blit_image.all_formats.color]
.b4g4r4a4_unorm_pack16.a1r5g5b5_unorm_pack16.*
.r8g8_snorm.a1r5g5b5_unorm_pack16.*
.a8b8g8r8_unorm_pack32.a1r5g5b5_unorm_pack16.*
.a8b8g8r8_snorm_pack32.a1r5g5b5_unorm_pack16.*

Bug b/119620767

Change-Id: I366cb5697b60b4f0fb51931a6be7b8732cf789ec
Reviewed-on: https://swiftshader-review.googlesource.com/c/23328
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoAdded missing formats to Blitter
Alexis Hetu [Wed, 19 Dec 2018 22:23:26 +0000 (17:23 -0500)]
Added missing formats to Blitter

Added enums for mostly implemented format, along
with the implementation for 2 new formats:
VK_FORMAT_B4G4R4A4_UNORM_PACK16
VK_FORMAT_A2B10G10R10_UINT_PACK32 (as a true integer format)

Bug b/119620767

Change-Id: I139408609cdbc35f7d9b0a8220e86a598c70a9e9
Reviewed-on: https://swiftshader-review.googlesource.com/c/23309
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
5 years agoAdded missing VkFormat entries to Surface utility functions
Alexis Hetu [Wed, 19 Dec 2018 22:17:04 +0000 (17:17 -0500)]
Added missing VkFormat entries to Surface utility functions

Added missing VkFormat entries to the following functions:
Surface::hasQuadLayout
Surface::isFloatFormat
Surface::isUnsignedComponent
Surface::isSRGBformat
Surface::isCompressed
Surface::isSignedNonNormalizedInteger
Surface::isUnsignedNonNormalizedInteger
Surface::componentCount
Surface::selectInternalFormat

Bug b/118429780

Change-Id: I46f8fb3f8a14f82a2b6615e129e4de0443666eca
Reviewed-on: https://swiftshader-review.googlesource.com/c/23308
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
5 years agoImplement image blitting
Alexis Hetu [Mon, 17 Dec 2018 22:00:28 +0000 (17:00 -0500)]
Implement image blitting

First simple implementation of image blitting.
Note that layers are not yet taken into account.

Passes almost all tests in (There are only 2 failures,
which both have an off by 1 error on a single pixel):
dEQP-VK.api.copy_and_blit.core.blit_image.simple_tests.*

Bug b/118619338 b/119620767

Change-Id: I1e0ac88089d6159924569099ea6345804a219d2c
Reviewed-on: https://swiftshader-review.googlesource.com/c/23268
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoImplement buffer to buffer copy command
Alexis Hetu [Fri, 14 Dec 2018 21:50:43 +0000 (16:50 -0500)]
Implement buffer to buffer copy command

Added buffer copy command and support for VkBufferCopy regions.

Passes all tests in:
dEQP-VK.api.copy_and_blit.core.buffer_to_buffer

Bug b/118619338

Change-Id: Id69cd3f089b07343a7209290808c11d4c17f1a49
Reviewed-on: https://swiftshader-review.googlesource.com/c/23229
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoSupport regions in Buffer to/from Image copy
Alexis Hetu [Fri, 14 Dec 2018 21:42:24 +0000 (16:42 -0500)]
Support regions in Buffer to/from Image copy

Added support for image regions and buffer rowLength/imageHeight
for Image to Buffer copies or Buffer to Image copies.

Passes all tests in:
dEQP-VK.api.copy_and_blit.core.image_to_buffer
dEQP-VK.api.copy_and_blit.core.buffer_to_image

Bug b/119620767

Change-Id: I2b2592c06d52609c3f9c51fa164a0335f58f361f
Reviewed-on: https://swiftshader-review.googlesource.com/c/23228
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoSupport for combined Depth and Stencil formats
Alexis Hetu [Fri, 14 Dec 2018 17:11:02 +0000 (12:11 -0500)]
Support for combined Depth and Stencil formats

Added implementation for Depth and Stencil which currently allocates
Depth and Stencil as 2 contiguous image planes in memory.

Copying to and from depth and stencil planes is now supported which
fixes all failures in:
dEQP-VK.api.copy_and_blit.core.image_to_image.all_formats.depth_stencil
Which were the last remaining failures in:
dEQP-VK.api.copy_and_blit.core.image_to_image

Bug b/119620767

Change-Id: Ie90737c219c70d9c8a68c024ed33292812a3b7f4
Reviewed-on: https://swiftshader-review.googlesource.com/c/23209
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoSupport for array layers in Image objects
Alexis Hetu [Fri, 14 Dec 2018 16:07:39 +0000 (11:07 -0500)]
Support for array layers in Image objects

Added basic support for array layers in Image objects.
This allows allocating the memory for multiple layers,
copying between a 2D image with multiple layers to and
from a 3D image.

Passes all tests in:
dEQP-VK.api.copy_and_blit.core.image_to_image.3d_images.*

Bug b/119620767

Change-Id: I305650ba89f90dcd527b484fc3ed095a309506d1
Reviewed-on: https://swiftshader-review.googlesource.com/c/23208
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoProperly dispose of the sw::Renderer object
Alexis Hetu [Wed, 12 Dec 2018 18:26:15 +0000 (13:26 -0500)]
Properly dispose of the sw::Renderer object

This fixes a memory leak in the Queue object. The sw::Renderer
object has a non trivial destructor, which means we need to call
it before deallocating the Queue objects.

Bug b/117974925

Change-Id: I1e13c6108e77d5cdcbea337d572f72fdd32530a1
Reviewed-on: https://swiftshader-review.googlesource.com/c/23188
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoFix CMake-based build
Chris Forbes [Sat, 8 Dec 2018 01:54:31 +0000 (17:54 -0800)]
Fix CMake-based build

Change-Id: I5feee7fb928a49762faa8154804fc4b0e86f60b8
Reviewed-on: https://swiftshader-review.googlesource.com/c/23169
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agovkCmdDraw implementation
Alexis Hetu [Fri, 7 Dec 2018 21:26:05 +0000 (16:26 -0500)]
vkCmdDraw implementation

Piped all the information from the vertex buffers and
the pipeline to the renderer to perform a draw.

In order for the renderer and the context to have proper
lifetimes, they both reside in the Queue object for now.

Bug b/118619338

Change-Id: Ifa03acd13ceb065a856b50f2cffadd4ee6b9a163
Reviewed-on: https://swiftshader-review.googlesource.com/c/23111
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoRenderPass begin and end
Alexis Hetu [Fri, 7 Dec 2018 21:13:34 +0000 (16:13 -0500)]
RenderPass begin and end

Implemented vkCmdBeginRenderPass and vkCmdEndRenderPass.
The RenderPass object begin and end are noop for now, but
the framebuffer gets cleared within vkCmdBeginRenderPass.

Bug b/119620965 b/118619338

Change-Id: I8e1f2932d9d52b3dcb5c10d4e60cba83b28bb95d
Reviewed-on: https://swiftshader-review.googlesource.com/c/23108
Reviewed-by: Corentin Wallez <cwallez@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoAdd missing checks in the GraphicsPipeline constructor
Alexis Hetu [Fri, 7 Dec 2018 21:26:05 +0000 (16:26 -0500)]
Add missing checks in the GraphicsPipeline constructor

Adjusted a few checks in the GraphicsPipeline constructor,
specifically stages' specialization info and sample mask,
which can either be null or default.

Also fixed destroying Pipeline objects, making sure there's
no confusion between GraphicsPipeline and ComputePipeline's
destroy() methods inherited from their 2 base classes
(Pipeline::destroy() and ObjectBase::destroy()).

Bug b/118386749

Change-Id: I78be9f0bbb735518e07d52f7372dbf08b9834abf
Reviewed-on: https://swiftshader-review.googlesource.com/c/23110
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoImplement Image clear
Alexis Hetu [Fri, 7 Dec 2018 21:20:44 +0000 (16:20 -0500)]
Implement Image clear

Use the blitter to implement Image::clear.

The image can be easily packed into a sw::Surface. For now,
the surface is a temporary, but it may become a member in
the future if it makes sense.

Bug b/119620767

Change-Id: I122a321509dc8cc5b624ddd776bd9059eee0cbc4
Reviewed-on: https://swiftshader-review.googlesource.com/c/23109
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoVkImageView initial implementation
Alexis Hetu [Mon, 19 Nov 2018 16:30:43 +0000 (11:30 -0500)]
VkImageView initial implementation

Added VkImageView object.
Added "clear" function to illustrate the link between VkFramebuffer
attachments, VkImageView and VkImage, along with the minimal set of
class members to allows the function arguments to be used properly.

Bug b/119620767 b/119621736

Change-Id: I0e7e6017979960bacbdf888d632c83edda3483cf
Reviewed-on: https://swiftshader-review.googlesource.com/c/22668
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoImage to Image copy command
Alexis Hetu [Fri, 7 Dec 2018 17:40:00 +0000 (12:40 -0500)]
Image to Image copy command

Implemented Image to Image copy, Image to Buffer copy and
Buffer to Image copy commands which are required in order
to run the dEQP-VK.api.copy_and_blit.core.image_to_image.*
tests.

Passes over 99.7% of the 10907 tests in:
dEQP-VK.api.copy_and_blit.core.image_to_image.*

Bug b/118619338 b/119620767

Change-Id: Id4d3aa5186bed84d0925e4424399716efbd241ee
Reviewed-on: https://swiftshader-review.googlesource.com/c/23071
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
5 years agoFixed command buffer reset and added implicit reset
Alexis Hetu [Mon, 10 Dec 2018 19:41:03 +0000 (14:41 -0500)]
Fixed command buffer reset and added implicit reset

A call to vkBeginCommandBuffer implicitly resets the command buffer.

Bug b/118619338

Change-Id: I020a2d15915cbb309dbcd012b2dbbf34ca2f63c6
Reviewed-on: https://swiftshader-review.googlesource.com/c/23148
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
5 years agoImage copy
Alexis Hetu [Fri, 7 Dec 2018 16:53:19 +0000 (11:53 -0500)]
Image copy

Image objects now have the ability to copy their content to another
image object. They can also copy their content to or from Buffer
objects.

Bug b\119620767

Change-Id: I047e9ecdcc11e264589de1d9461ef448f22a4d9e
Reviewed-on: https://swiftshader-review.googlesource.com/c/23070
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoImport snapshot of spirv headers
Chris Forbes [Fri, 7 Dec 2018 02:33:06 +0000 (18:33 -0800)]
Import snapshot of spirv headers

Includes only the include/spirv/unified1 subtree.

Based on git://github.com/KhronosGroup/spirv-tools revision 17da9f8231f78cf519b4958c2229463a63ead9e2

Bug: b/120799499
Change-Id: Ifb790bf95035d7feb2d54d07e1475013dfd298b1
Reviewed-on: https://swiftshader-review.googlesource.com/c/23048
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoFix implicit fallthrough warnings treated as errors
Nicolas Capens [Sat, 8 Dec 2018 20:35:32 +0000 (12:35 -0800)]
Fix implicit fallthrough warnings treated as errors

Ideally we'd use the [[fallthrough]] attribute to silence this, but that
isn't supported until C++17 and we're sticking with C++11 for now.

Bug b/120382288

Change-Id: I98f28e42505ed496b0b35c29a7dc03fca18cf4ff
Reviewed-on: https://swiftshader-review.googlesource.com/c/23128
Reviewed-by: Greg Hartman <ghartman@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
5 years agoBuffer copy
Alexis Hetu [Fri, 7 Dec 2018 16:36:34 +0000 (11:36 -0500)]
Buffer copy

Buffer now has the ability to copy its content to or from memory.

Bug b/118383648

Change-Id: Ic01bf049fe054559299830ca750263c2277e4d86
Reviewed-on: https://swiftshader-review.googlesource.com/c/23069
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoImplement waiting for fences as noop
Alexis Hetu [Fri, 7 Dec 2018 16:28:40 +0000 (11:28 -0500)]
Implement waiting for fences as noop

For the purpose of running dEQP tests, for now, fences can be
implemented as noop. Once more complex rendering tests exercise
this, we'll be able to implement and test fences.

Bug b/117835459

Change-Id: I2b54be816c83f7a626108f61bd14eb9c969a2b0f
Reviewed-on: https://swiftshader-review.googlesource.com/c/23068
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
5 years agoImplement pipeline barrier as noop
Alexis Hetu [Tue, 20 Nov 2018 16:47:18 +0000 (11:47 -0500)]
Implement pipeline barrier as noop

Because of existing synchronization mechanisms in SwiftShader,
pipeline barriers can be noop for now. If we do remove those
synchronization mechanisms, there's also a simple way of
implementing pipeline barriers, which is commented on here.

Bug b/118619338

Change-Id: If82d275c46f234e5549018115c9f19f21e2c09b2
Reviewed-on: https://swiftshader-review.googlesource.com/c/22708
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
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>