OSDN Git Service

android-x86/external-swiftshader.git
5 years agoRemove src/Vulkan directory from CMake include path
Nicolas Capens [Fri, 1 Mar 2019 18:39:57 +0000 (13:39 -0500)]
Remove src/Vulkan directory from CMake include path

This change requires include directives to include the Vulkan/ path so
it's clearer when we have dependencies across layers/folders.

This was already the case for the other build files, so it avoids
build breakage as well.

Bug b/126557661

Change-Id: I4d8773e8c28e6677fd1e93ca9c9d2d843431343c
Reviewed-on: https://swiftshader-review.googlesource.com/c/25948
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoSpirvShader: Begin unary and binary ops.
Ben Clayton [Thu, 28 Feb 2019 19:59:15 +0000 (19:59 +0000)]
SpirvShader: Begin unary and binary ops.

Far from a complete set, but both Chris and I are looking at tests that require these opcodes.

Bug: b/126870789
Bug: b/126873455
Change-Id: Idb2109cfc3352da83aa38d42eed5d15537dfb6b7
Reviewed-on: https://swiftshader-review.googlesource.com/c/25868
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoSpirvShader: Fix variable construction of non input/output storage.
Ben Clayton [Thu, 28 Feb 2019 18:42:10 +0000 (18:42 +0000)]
SpirvShader: Fix variable construction of non input/output storage.

I incorrectly (9a16248) added an UNIMPLEMENTED to variables that have a storage type that is neither Input or Output.  However, other storage types do actually work.

Revert that change.

Change-Id: I5ec36e9d6d536dcdd085c93e9f00782310e118d4
Reviewed-on: https://swiftshader-review.googlesource.com/c/25848
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agoAdvertise support for VK_KHR_swapchain
Hernan Liatis [Mon, 25 Feb 2019 23:56:36 +0000 (15:56 -0800)]
Advertise support for VK_KHR_swapchain

Bug: b/124265819
Change-Id: I19bbaeefe19ade1afeb6764d4f5576a29334d8bd
Reviewed-on: https://swiftshader-review.googlesource.com/c/25490
Tested-by: Hernan Liatis <hliatis@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoAdd basic VkSurfaceKHR (Xlib only for now)
Hernan Liatis [Fri, 22 Feb 2019 19:12:59 +0000 (11:12 -0800)]
Add basic VkSurfaceKHR (Xlib only for now)

Should pass the following deqp tests:
dEQP-VK.wsi.xlib.surface.create
dEQP-VK.wsi.xlib.surface.query_supportS
dEQP-VK.wsi.xlib.surface.query_capabilities
dEQP-VK.wsi.xlib.surface.query_formatsW
dEQP-VK.wsi.xlib.surface.query_present_modes
dEQP-VK.wsi.xlib.surface.destroy_null_handle
dEQP-VK.wsi.xlib.surface.initial_size
dEQP-VK.wsi.xlib.surface.resizeSW

Bug: b/124265819
Change-Id: I92da1cc8d60923ea97aa26d3d6a098274c6e06b7
Reviewed-on: https://swiftshader-review.googlesource.com/c/25308
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Tested-by: Hernan Liatis <hliatis@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoRemove partial logic op support
Chris Forbes [Thu, 28 Feb 2019 18:29:55 +0000 (10:29 -0800)]
Remove partial logic op support

Pastel 1.0 does not need to implement logic ops. From discussion with
capn@, the existing support was only ever partial, and covered the exact
needs of a special project.

Change-Id: I3003227c4d29ab5d39e0ae6385207c87d22931e2
Reviewed-on: https://swiftshader-review.googlesource.com/c/25828
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoUse sample count from multisample state, not from attachment 0
Chris Forbes [Thu, 28 Feb 2019 18:07:55 +0000 (10:07 -0800)]
Use sample count from multisample state, not from attachment 0

Color attachment 0 (or any color attachments!) may not exist;
rasterizer behavior is supposed to be completely independent of this.

Bug: b/126417154
Change-Id: If16307a7964c267af254e2a62822ac38cf58c48c
Reviewed-on: https://swiftshader-review.googlesource.com/c/25809
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoFix Context::colorWriteActive to consider all rendertargets
Chris Forbes [Thu, 28 Feb 2019 17:03:38 +0000 (09:03 -0800)]
Fix Context::colorWriteActive to consider all rendertargets

Even in the GLES backend, we support RENDERTARGETS=8. This check only
ever considered the first 4.

Bug: b/126719156
Change-Id: I0084aa005f342f06373c53c007bee33268466b92
Reviewed-on: https://swiftshader-review.googlesource.com/c/25808
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoRemove remnants of non-descriptor-backed textures
Chris Forbes [Fri, 22 Feb 2019 21:42:51 +0000 (13:42 -0800)]
Remove remnants of non-descriptor-backed textures

All texture access in Vulkan is through descriptors. We don't need any
of the context-side state for this.

Bug: b/125909515
Change-Id: I7d0846d2fdcc03504e2dd3f44580fb5c09188c1a
Reviewed-on: https://swiftshader-review.googlesource.com/c/25331
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoAdd regres test lists.
Ben Clayton [Sat, 16 Feb 2019 01:05:23 +0000 (01:05 +0000)]
Add regres test lists.

Regres will pick up these lists instead of using its builtin fallback lists.
These lists include additional wsi tests

Change-Id: Iec77d56bb2fc79153c090226e668e613b7969bff
Reviewed-on: https://swiftshader-review.googlesource.com/c/25788
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Hernan Liatis <hliatis@google.com>
5 years agoSpirvShader: Move emit() instructions to their own functions
Ben Clayton [Tue, 26 Feb 2019 12:19:48 +0000 (12:19 +0000)]
SpirvShader: Move emit() instructions to their own functions

These are only going to grow.

Bug: b/126126820
Change-Id: I03a2b214e9968c31dabc4814b505c1f8c22349ae
Reviewed-on: https://swiftshader-review.googlesource.com/c/25552
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agoSpirvShader: Debug print human readable opcode names
Ben Clayton [Tue, 26 Feb 2019 11:54:34 +0000 (11:54 +0000)]
SpirvShader: Debug print human readable opcode names

My memory isn't good enough to remember all opcodes by number.

Enum string list stripped in release builds.

Change-Id: Ifa9b9585ee6294a26db5676a34f8ad9c90f527b8
Reviewed-on: https://swiftshader-review.googlesource.com/c/25551
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agoSpirvShader: Move type declaration out to its own function
Ben Clayton [Tue, 26 Feb 2019 11:41:07 +0000 (11:41 +0000)]
SpirvShader: Move type declaration out to its own function

Reduces function size, increases readability.

Bug: b/126126820
Change-Id: I073dd40114d3c5e6e7c6088db9fc8f2a0b9d8bac
Reviewed-on: https://swiftshader-review.googlesource.com/c/25550
Tested-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoSpirvShader: Add support for DescriptorSet and Binding decorations
Ben Clayton [Tue, 26 Feb 2019 11:06:50 +0000 (11:06 +0000)]
SpirvShader: Add support for DescriptorSet and Binding decorations

Bug: b/126330097
Change-Id: Id705dc19bb3a114bf703ddc37b529d6ac89b4d52
Reviewed-on: https://swiftshader-review.googlesource.com/c/25549
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoSpirvShader: Add SIMD namespace.
Ben Clayton [Tue, 26 Feb 2019 11:02:42 +0000 (11:02 +0000)]
SpirvShader: Add SIMD namespace.

This namespace declares typedefs that represent per-lane-scalars.

Once we start mixing per-lane storage with linear external memory, this will help readability.

Bug: b/126126820
Change-Id: Ia128c3cc97dd77b3d5c4b7bd9537c19427a9ac3f
Reviewed-on: https://swiftshader-review.googlesource.com/c/25548
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agoAdd support for OpVectorShuffle
Chris Forbes [Wed, 27 Feb 2019 06:16:07 +0000 (22:16 -0800)]
Add support for OpVectorShuffle

Bug: b/126472836
Change-Id: I0e7afc53e863540fb5bd76ec8737f4b2aa3a015b
Reviewed-on: https://swiftshader-review.googlesource.com/c/25649
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoAdd support for OpCompositeExtract
Chris Forbes [Fri, 22 Feb 2019 02:53:58 +0000 (18:53 -0800)]
Add support for OpCompositeExtract

Bug: b/126475423
Change-Id: Ia74e5c6b253a5d3ac5de51c3667062405989d641
Reviewed-on: https://swiftshader-review.googlesource.com/c/25191
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoAdd support for OpCompositeInsert
Chris Forbes [Fri, 22 Feb 2019 02:40:33 +0000 (18:40 -0800)]
Add support for OpCompositeInsert

Most of the subtlety here comes from needing to deal with either the old
parts or the new being possibly a constant object.

Uses WalkLiteralAccessChain combined with the size of the "new part"
to determine the range within the object which should be replaced.

Bug: b/126475423
Change-Id: I81f58d0de5dcacc74ffbd155708996c23dbe388e
Reviewed-on: https://swiftshader-review.googlesource.com/c/25214
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoAdd complex type walker for literal indexes
Chris Forbes [Fri, 22 Feb 2019 02:39:31 +0000 (18:39 -0800)]
Add complex type walker for literal indexes

This will be used by OpCompositeInsert and OpCompositeExtract. All
indices are known at compile time, and are specified as literals rather
than ids of constants, (as in Op*AccessChain)

Bug: b/126475423
Change-Id: Ic29e2f988fb6b9bdab4b722b368e51db929c8bd3
Reviewed-on: https://swiftshader-review.googlesource.com/c/25213
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoAdd support for OpCompositeConstruct
Chris Forbes [Fri, 22 Feb 2019 00:51:42 +0000 (16:51 -0800)]
Add support for OpCompositeConstruct

Bug: b/126475423
Change-Id: I69d05db8eaf0825893210424496dc6c9ad793d0d
Reviewed-on: https://swiftshader-review.googlesource.com/c/25190
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoAdd GenericValue wrapper for either an Intermediate or a constant
Chris Forbes [Wed, 27 Feb 2019 05:53:56 +0000 (21:53 -0800)]
Add GenericValue wrapper for either an Intermediate or a constant

This does automatic widening to per-lane so callers don't have to
scatter "is constant?" checks everywhere. This is mostly the right
thing to do -- loads and stores will want to continue specializing
on whether values and offsets are uniform across lanes, but most
other things don't care.

Bug: b/126475489
Change-Id: I1b8693a75e93b00a7972ec06777fbaaa599d2a52
Reviewed-on: https://swiftshader-review.googlesource.com/c/25668
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoFix push & pop of XMM registers.
Stephen White [Wed, 27 Feb 2019 19:39:14 +0000 (14:39 -0500)]
Fix push & pop of XMM registers.

Microsoft's x86-64 calling convention ABI requires registers XMM6-15 to
be preserved by the callee:
https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=vs-2017#calling-convention-defaults

Implement a _pop_reg() analog to _push_reg(), so we can specialize
the XMM treatment. Pass the RegNum all the way down to the specialized
class, because we don't know which registers should be 128-bit at the call site.

Bug chromium:931926
Bug swiftshader:22

Change-Id: I57637c852f0f3bb9a374d61a16a7aaa434ac908d
Reviewed-on: https://swiftshader-review.googlesource.com/c/25468
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Stephen White <senorblanco@chromium.org>
5 years agoVkDebug.hpp: Call abort() after assert(false)
Ben Clayton [Tue, 26 Feb 2019 17:59:24 +0000 (17:59 +0000)]
VkDebug.hpp: Call abort() after assert(false)

For debug builds this should be a nop, as the assert should call abort(), however for NDEBUG + DCHECK_ALWAYS_ON builds, assert is a nop and we still want to terminate.

Bug: b/126329018
Change-Id: I45291be05dfa2cce8ea5623c8af8900049d5e855
Reviewed-on: https://swiftshader-review.googlesource.com/c/25558
Tested-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoCMake: Add DCHECK_ALWAYS_ON flag
Ben Clayton [Tue, 26 Feb 2019 16:52:12 +0000 (16:52 +0000)]
CMake: Add DCHECK_ALWAYS_ON flag

Enables macros like ASSERT, UNIMPLEMENTED even in release builds.

Bug: b/126329018
Change-Id: I7d810862b16d85b0a4ffc6b39a655cc73d4c669a
Reviewed-on: https://swiftshader-review.googlesource.com/c/25557
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agoFix warnings raised during release builds
Ben Clayton [Tue, 26 Feb 2019 17:24:46 +0000 (17:24 +0000)]
Fix warnings raised during release builds

Bug: b/123933266
Change-Id: If4dc4858c8a81dd5e7b3510a08e7dbae74051483
Reviewed-on: https://swiftshader-review.googlesource.com/c/25556
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agoSuppress LLVM warnings raised during release builds.
Ben Clayton [Tue, 26 Feb 2019 16:50:31 +0000 (16:50 +0000)]
Suppress LLVM warnings raised during release builds.

Made these suppressions only apply to LLVM as they're scary to be ignored generally.

Bug: b/123933266
Change-Id: I23c01f4cad0bac706f515642ce482703a1161d67
Reviewed-on: https://swiftshader-review.googlesource.com/c/25555
Tested-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoReturn newly-created value from SpirvRoutine::createIntermediate
Chris Forbes [Wed, 27 Feb 2019 05:22:32 +0000 (21:22 -0800)]
Return newly-created value from SpirvRoutine::createIntermediate

All the callers needed to fetch this immediately afterward; save some
effort.

Bug: b/126475489
Change-Id: I622d30aa955c27df8e12fdf87762c0db96133666
Reviewed-on: https://swiftshader-review.googlesource.com/c/25648
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoImplement indexed draws
Chris Forbes [Tue, 26 Feb 2019 02:14:42 +0000 (18:14 -0800)]
Implement indexed draws

Adds support for vkBindIndexBuffer and vkDrawIndexed.
There is significant duplication currently between Draw::play and
DrawIndexed::play, but most of it is going to evaporate when we
solve the context stomping problems.

Bug: b/118619338
Change-Id: If8e9f7b1f11a3c763e73663733697fddd3e1fcac
Reviewed-on: https://swiftshader-review.googlesource.com/c/25508
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoDescriptor sets binding
Alexis Hetu [Fri, 15 Feb 2019 19:56:22 +0000 (14:56 -0500)]
Descriptor sets binding

This cl partially implements vkCmdBindDescriptorSets. It allows
binding descriptor sets to the proper pipeline bind point and
descriptor set binding location. Dynamic offsets are not yet
supported.

Bug b/123244275 b/118619338

Change-Id: I91b14b79cb6cf00a4fabb6962938e7f55d5b6c22
Reviewed-on: https://swiftshader-review.googlesource.com/c/24909
Tested-by: Alexis Hétu <sugoi@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoSimple PipelineBarrier implementation
Alexis Hetu [Tue, 26 Feb 2019 22:03:00 +0000 (17:03 -0500)]
Simple PipelineBarrier implementation

The simplest PipelineBarrier implementation is to call Renderer::synchronize().
This removes the synchronization mechanism from the draw commands, while still
allowing the tests to pass successfully.

Bug b/118619338

Change-Id: If7d9c14170db6f9a74a54c45a978d3ce78a1cdca
Reviewed-on: https://swiftshader-review.googlesource.com/c/25608
Tested-by: Alexis Hétu <sugoi@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoFix REACTOR_USE_SUBZERO flag
Logan Chien [Tue, 26 Feb 2019 05:39:52 +0000 (13:39 +0800)]
Fix REACTOR_USE_SUBZERO flag

This commit fixes REACTOR_USE_SUBZERO flag.  The commit fde88d96a5 sets
REACTOR_USE_SUBZERO to `false` to disable the SubZero backend.  However,
other Android.mk uses `ifdef` to check whether the SubZero backend is
enabled.  As a result, the SubZero backend is always selected because
both `REACTOR_USE_SUBZERO := true` and `REACTOR_USE_SUBZERO := false`
are considered as defined.

This commit replaces `ifdef REACTOR_USE_SUBZERO` with
`ifeq ($(REACTOR_USE_SUBZERO),true)` to fix the problem.

Bug: b/115344057
Test: Build libEGL_swiftshader and libGLES_swiftshader for Android
Change-Id: I83f2dc5018857c630a71a1b7eae636983283783a
Reviewed-on: https://swiftshader-review.googlesource.com/c/25528
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Cody Schuffelen <schuffelen@google.com>
Tested-by: Logan Chien <loganchien@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoAdd Print helpers to reactor
Ben Clayton [Thu, 14 Feb 2019 18:43:22 +0000 (18:43 +0000)]
Add Print helpers to reactor

New tools for debugging JITed code.

rr::Print() is a new function that emits a call to printf() using the provided message and optional values. There is also an overload that accepts additional file, line, and function parameters to help identify the call site.

Format values passed to rr::Print() are implicity cast to a new rr::PrintValues type which does the work of dispatching the value type to the correct printf() format specifier(s) and argument value(s). A single rr::Print() format value can automatically be expanded into multiple printf values - for example an rr::Float4 will expand to "%f %f %f %f" and four scalar float values.

rr::Print() format values can be any of the following types:
  * Reactor LValues, RValues, Pointers.
  * Standard Plain-Old-Value types (int, float, bool, etc)
  * Custom types that specialize the PrintValue::Ty template struct.
  * Static arrays in the form T[N] where T can be any of the above.

The sw::Vector4f and sw::Vector4s types have already had custom formatters written.

These new functions and types described above are typically not called directly. Instead there are two helper macros which simplifies usage:

RR_LOG() is a new macro that wraps rr::Print(), automatically populating the function, file and line parameters and appending a newline to the string.

RR_WATCH() is a new helper macro that prints the name and value of all the supplied arguments. For example, if you had the Int and bool variables 'foo' and 'bar' that you want to print, you can simply write:

    RR_WATCH(foo, bar)

When this JIT compiled code is executed, it will print:
    "foo: 1, bar: true"

All of this code is disabled in non-debug builds, or if the reactor backend is not LLVM 7+.

Change-Id: Ia39b1e507b6afaa3bb1d33e40b1333017f4b4f21
Reviewed-on: https://swiftshader-review.googlesource.com/c/24768
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoVS build fix
Alexis Hetu [Tue, 26 Feb 2019 22:11:23 +0000 (17:11 -0500)]
VS build fix

Change-Id: I7e6589870b539e775371e8941a07a48ca9e0cad7
Reviewed-on: https://swiftshader-review.googlesource.com/c/25628
Tested-by: Alexis Hétu <sugoi@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoFix point rendering
Chris Forbes [Mon, 25 Feb 2019 21:35:59 +0000 (13:35 -0800)]
Fix point rendering

- Point size limits were left at [0,0], forcing all points to zero coverage.
  Introduce a config value for the maximum, and plumb this through to drive
  physical device limits query.

- Fix all interpolants being replaced with pointcoord

Bug: b/124177079

Change-Id: I281dd3214537f15858afbd3890cf70f8850fa4aa
Reviewed-on: https://swiftshader-review.googlesource.com/c/25489
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoOpAccessChain: Remove pointer walking inside loop
Chris Forbes [Mon, 25 Feb 2019 21:34:59 +0000 (13:34 -0800)]
OpAccessChain: Remove pointer walking inside loop

This cannot occur. The initial stripping of <base>'s pointer type is
already handled outside the loop.

Bug: b/124388146

Change-Id: I55ea64e868308bfbab72aaefca0fd367916f6e69
Reviewed-on: https://swiftshader-review.googlesource.com/c/25488
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoReplace uses of sw::Surface with vk::ImageView in the Renderer
Alexis Hetu [Tue, 26 Feb 2019 19:42:36 +0000 (14:42 -0500)]
Replace uses of sw::Surface with vk::ImageView in the Renderer

sw::Surface contains a locking mechanism which is no longer required
in Vulkan. The app is now responsible for making sure the lifetime of
the objects is long enough for the driver to be able to use them in
any operation where they are required.

A few shortcuts were taken here:
- ImageView::getSampleCount() currently always returns the largest
  available sample count.
- ImageView::subresourceRange.levelCount is not taken into account
- Context::getMultiSampleCount() still uses attachment 0 to get
  the samples count, which may be incorrect.

Bug b/118619338

Change-Id: I8cd49926a1537c0f2bc20e6516f12d7de67d6c65
Reviewed-on: https://swiftshader-review.googlesource.com/c/25588
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoFix various issues in vertex fetch setup
Chris Forbes [Sat, 23 Feb 2019 01:21:23 +0000 (17:21 -0800)]
Fix various issues in vertex fetch setup

There are still some minor sins in here -- we should really unfuse
attributes from buffers completely -- but this is enough to have vertex
fetch work for all per-vertex attribute scenarios.

Bug: b/124177079

Change-Id: I2a7a1a6f049aa80c1a527e9fa9643bb33701d165
Reviewed-on: https://swiftshader-review.googlesource.com/c/25448
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoFix fuzzer build
Nicolas Capens [Tue, 26 Feb 2019 15:47:20 +0000 (10:47 -0500)]
Fix fuzzer build

VertexProcessor multiSampling state was eliminated.

Change-Id: I0507c80faff9e00b36d26ea96e3bc3a8e837d574
Reviewed-on: https://swiftshader-review.googlesource.com/c/25569
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoWork around x86-64 calling convention bug
Nicolas Capens [Fri, 15 Feb 2019 19:41:03 +0000 (14:41 -0500)]
Work around x86-64 calling convention bug

Microsoft's x86-64 calling convention ABI requires registers XMM6-15 to
be preserved by the callee:
https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=vs-2017#calling-convention-defaults
Currently only the System V calling convention's behavior is supported,
which does not have any callee-saved XMM registers.

Fixing this properly is non-trivial and this bug is blocking other
projects, so a temporary workaround is to limit Subzero to use only
scratch registers XMM0-XMM5.

Bug chromium:931926
Bug swiftshader:22

Change-Id: If3fde2295fc65fc52042124afe7dfc46873cce3f
Reviewed-on: https://swiftshader-review.googlesource.com/c/25568
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoSpirvShader: Decouple SPIR-V type attributes from object representation
Ben Clayton [Mon, 25 Feb 2019 11:54:43 +0000 (11:54 +0000)]
SpirvShader: Decouple SPIR-V type attributes from object representation

StorageClass, sizeInComponents, isBuiltInBlock are all attributes of the Type, not the Object.

Add 'type' field to Object so type information can easily be looked up regardless of definition opcode.

Add 'element' field to Type, simplifying the likes of WalkAccessChain.

Fixes the weird edge case of OpVariable's sizeInComponents being the size of the pointee, not its type (the pointer).

Bug: b/126126820
Change-Id: I2d1d93e03ee0253a87f831031c3b2806b1d80de0
Reviewed-on: https://swiftshader-review.googlesource.com/c/25408
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agoStrongly type object / type identifiers.
Ben Clayton [Wed, 20 Feb 2019 14:36:27 +0000 (14:36 +0000)]
Strongly type object / type identifiers.

Prevents you from mixing them up by mistake, and provides better self-documentation on function signatures.

Bug: b/126126820
Change-Id: I21ce20ded434ca3d5d03ebf3f9027cf6f6b5386f
Reviewed-on: https://swiftshader-review.googlesource.com/c/25068
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agoRemove VertexProcessor::multisampling state bit
Chris Forbes [Fri, 22 Feb 2019 21:43:46 +0000 (13:43 -0800)]
Remove VertexProcessor::multisampling state bit

The vertex processor doesn't need to know.

V3: also remove from GL side, which didn't use it either.

Change-Id: Id0624fb2700222be6238a8449b32b334755a45e7
Reviewed-on: https://swiftshader-review.googlesource.com/c/25332
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoWrong macro being #undef'd in VkGetProcAddress
Hernan Liatis [Mon, 25 Feb 2019 23:50:26 +0000 (15:50 -0800)]
Wrong macro being #undef'd in VkGetProcAddress

MAKE_VULKAN_INSTANCE_ENTRY never got undefined

Bug: b/125417927
Change-Id: I0fd5d8054748ff6279a65a5086e9a717441e583f
Reviewed-on: https://swiftshader-review.googlesource.com/c/25469
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Hernan Liatis <hliatis@google.com>
5 years agoFix minor issue in vkCreateInstance extension loop
Hernan Liatis [Sat, 23 Feb 2019 01:46:19 +0000 (17:46 -0800)]
Fix minor issue in vkCreateInstance extension loop

Extension checking in vkCreateInstance would simply
loop through the first extension requested. This
bug did not show up earlier (or at all) because
erroneous situations would cause early exits in
the loader.

Bug: b/125943360
Change-Id: Id664f46d09dce1b3530670ae826314b26797b5be
Reviewed-on: https://swiftshader-review.googlesource.com/c/25368
Tested-by: Hernan Liatis <hliatis@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoPipelineLayout implementation
Alexis Hetu [Fri, 15 Feb 2019 21:41:12 +0000 (16:41 -0500)]
PipelineLayout implementation

Initial basic implementation of PipelineLayout. The information
stored in the PipelineLayout will be used, among other things,
to properly bind descriptor sets affected by a dynamic offset.

Bug b/118386749

Change-Id: I05fa6f9c7740cf79a802a5276e2d88f6e6e4ebe7
Reviewed-on: https://swiftshader-review.googlesource.com/c/24948
Tested-by: Alexis Hétu <sugoi@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
5 years agoSuppress warnings for more instructions that require no work
Chris Forbes [Sat, 23 Feb 2019 01:39:57 +0000 (17:39 -0800)]
Suppress warnings for more instructions that require no work

Change-Id: Iacb323b4cc0c0b0373791b3aa3a5f0b4dcaffa44
Reviewed-on: https://swiftshader-review.googlesource.com/c/25428
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoAssert there are no unmatched eglBindTexImage/eglReleaseTexImage
Alexis Hetu [Wed, 20 Feb 2019 22:02:14 +0000 (17:02 -0500)]
Assert there are no unmatched eglBindTexImage/eglReleaseTexImage

Two consecutive eglBindTexImage calls on the same buffer (texture)
would eventually result in a crash if the texture is released before
the egl surfaces, so this assert is meant to perform an early
detection of a harder to detect future issue.

Bug chromium:932986 chromium:929088

Change-Id: I10b3892fe06d491c8a0a09dec84678b25f49c6ab
Reviewed-on: https://swiftshader-review.googlesource.com/c/25128
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoFix CMake build documentation
Ben Clayton [Thu, 7 Feb 2019 18:13:16 +0000 (18:13 +0000)]
Fix CMake build documentation

4c9f04bbebc added the build directory, so drop the docs for `mkdir`.

Change-Id: Idc7437c0c72666f2c115bb0ddbd753a3179dba79
Reviewed-on: https://swiftshader-review.googlesource.com/c/24508
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoRemove remnants of non-descriptor UBO support
Chris Forbes [Fri, 22 Feb 2019 21:39:52 +0000 (13:39 -0800)]
Remove remnants of non-descriptor UBO support

All vulkan resource access will be through descriptors. We don't need
any of this context-side state.

Bug: b/125909515
Change-Id: Id6d1da0f8a851e057dd3a16fc844b6a70cf9b935
Reviewed-on: https://swiftshader-review.googlesource.com/c/25330
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoRemove remnants of GL-style user clip planes
Chris Forbes [Fri, 22 Feb 2019 21:35:21 +0000 (13:35 -0800)]
Remove remnants of GL-style user clip planes

Vulkan doesn't have user clip planes in the legacy GL sense -- there is
an optional feature to supply GLSL1.30-style clip distances out of the
vertex shader, but the actual plane handling is the shader's problem.

We also don't support this optional feature.

Bug: b/125909515
Change-Id: I6dfc3eda613982112786a52517d1cd126146c590
Reviewed-on: https://swiftshader-review.googlesource.com/c/25329
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoRemove transform feedback remnants
Chris Forbes [Fri, 22 Feb 2019 21:31:32 +0000 (13:31 -0800)]
Remove transform feedback remnants

Bug: b/125909515
Change-Id: I18f1ed398d85a914863f4b93a2795637e20028b6
Reviewed-on: https://swiftshader-review.googlesource.com/c/25328
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoSet render targets correctly when drawing
Chris Forbes [Thu, 21 Feb 2019 22:58:28 +0000 (14:58 -0800)]
Set render targets correctly when drawing

There are some horrible hacks in here -- the draw command should not be
doing anywhere near this much work -- but this gets us to first
triangle.

Passes: dEQP-VK.api.smoke.triangle

Bug: b/124177079
Change-Id: I4240cb8cdce2f4bbb804e88e66d1695ab0b0e41e
Reviewed-on: https://swiftshader-review.googlesource.com/c/25212
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoWire up cull mode handling to Vulkan pipeline
Chris Forbes [Fri, 22 Feb 2019 17:45:06 +0000 (09:45 -0800)]
Wire up cull mode handling to Vulkan pipeline

Bug: b/124177079
Change-Id: I8e55607c8ff7f9c2d2356268bedf170cf27eeb99
Reviewed-on: https://swiftshader-review.googlesource.com/c/25268
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoKokoro: Run unit tests.
Ben Clayton [Thu, 21 Feb 2019 15:55:54 +0000 (15:55 +0000)]
Kokoro: Run unit tests.

Change-Id: I88d914d9aa30291e938b65519ebfecb577c5d33e
Reviewed-on: https://swiftshader-review.googlesource.com/c/25170
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Raymond Chiu <chiur@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agoSilence emit-time warnings for many instructions
Chris Forbes [Fri, 22 Feb 2019 00:49:51 +0000 (16:49 -0800)]
Silence emit-time warnings for many instructions

These instructions don't require any work in the emit phase.

Change-Id: I1f82e785afe9a3e3871637349fca3eac3435ab6c
Reviewed-on: https://swiftshader-review.googlesource.com/c/25189
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
5 years agoRemove alpha test plumbing
Chris Forbes [Fri, 22 Feb 2019 17:43:30 +0000 (09:43 -0800)]
Remove alpha test plumbing

Vulkan does not have alpha test. Apps are expected to use discard in the
shader instead.

Change-Id: Idc1d8d2a74f5728cf70c653a5139a0ca1674ca37
Reviewed-on: https://swiftshader-review.googlesource.com/c/25211
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoRestore vertex fetch state update from context -> state
Chris Forbes [Thu, 21 Feb 2019 18:20:26 +0000 (10:20 -0800)]
Restore vertex fetch state update from context -> state

This is required to have the vertex fetch state actually available at
JIT time.

Bug: b/124177079
Change-Id: Ibb548c372ee349d3a5312bb46dddcf13257dc294
Reviewed-on: https://swiftshader-review.googlesource.com/c/25188
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
5 years agoImplement proper handling of constants
Chris Forbes [Wed, 20 Feb 2019 21:00:54 +0000 (13:00 -0800)]
Implement proper handling of constants

Previously we had only supported simple integer constants, as that was
enough to parse array declarations etc. Fully implement constants,
including large null objects, and constant composites constructed out
of other constants.

Bug: b/124934655
Change-Id: Ia1087f62a2bd75a3ca2f784ea24b0b3f01984ad9
Reviewed-on: https://swiftshader-review.googlesource.com/c/25148
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
5 years agoAdd CMake flag to treat warnings as errors
Ben Clayton [Tue, 19 Feb 2019 17:08:56 +0000 (17:08 +0000)]
Add CMake flag to treat warnings as errors

Disabled by default by the request of Nicolas.

Bug: b/123933266
Change-Id: Ie1217dc6c96ec85c9daf8246de785c8729386634
Reviewed-on: https://swiftshader-review.googlesource.com/c/25015
Tested-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agovkGetDescriptorSetLayoutSupportKHR listed wrong
Hernan Liatis [Thu, 21 Feb 2019 21:46:36 +0000 (13:46 -0800)]
vkGetDescriptorSetLayoutSupportKHR listed wrong

The above function, while listed with the device
functions, was using MAKE_VULKAN_INSTANCE_ENTRY()
instead of MAKE_VULKAN_DEVICE_ENTRY()

Bug: b/125417927
Change-Id: I66865468f50b2db3f6904fab40f79db3346431a2
Reviewed-on: https://swiftshader-review.googlesource.com/c/25209
Kokoro-Presubmit: Hernan Liatis <hliatis@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Hernan Liatis <hliatis@google.com>
5 years agoUpdate ICD version to 3.0
Hernan Liatis [Thu, 21 Feb 2019 20:57:52 +0000 (12:57 -0800)]
Update ICD version to 3.0

Needed to call VkCreateXXXSurfaceKHR() functions,
where XXX is the platform name.

Bug: b/125405086
Change-Id: Id0de2ee02bd3b7d5b37eda202fb26e4ad3265bf3
Reviewed-on: https://swiftshader-review.googlesource.com/c/25208
Kokoro-Presubmit: Hernan Liatis <hliatis@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Hernan Liatis <hliatis@google.com>
5 years agoGLES: Fix race in Renderer destruction
Ben Clayton [Tue, 12 Feb 2019 11:24:29 +0000 (11:24 +0000)]
GLES: Fix race in Renderer destruction

The clipper and blitter were being destructed before the worker threads were stopped.

Also nullify after deleting other fields - this would have been much harder to detect if the clipper and blitter were not already being nullified after destruction.

Tested with:
./unittests --gtest_repeat=100 --gtest_filter=SwiftShaderTest.TransformFeedback_DrawArraysInstanced

Bug: b/124288179
Change-Id: Iefea829dfb8556c877c0a086253c5924c54aa638
Reviewed-on: https://swiftshader-review.googlesource.com/c/24748
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agoSilence warnings: Ignore pedantic warnings with compiler flags
Ben Clayton [Tue, 19 Feb 2019 17:08:14 +0000 (17:08 +0000)]
Silence warnings: Ignore pedantic warnings with compiler flags

Addressing this one toolchain at a time, as not all warning names are the same across toolchains.

Bug: b/123933266
Change-Id: I618ebafb5ff18a885c71a8e2fa1943befc6786b6
Reviewed-on: https://swiftshader-review.googlesource.com/c/25014
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agoGLES: Fix OOB access of labelBlock.
Ben Clayton [Thu, 21 Feb 2019 11:05:27 +0000 (11:05 +0000)]
GLES: Fix OOB access of labelBlock.

This was being incorrectly sized by the number of functions, not the highest label in use.

While investigating this, I've realized that the sanity checks to ensure there are no dead functions was never going to fire as the function list was built from the list of called functions. Instead I've changed the function scanning pass to look for labels starting a LABEL-RET pair.

Bug: b/125183107
Change-Id: Ic921097ed42a96b52f1ab7c9590c02fb3552b565
Reviewed-on: https://swiftshader-review.googlesource.com/c/25168
Tested-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoGLES: Add tests to exersise sparse labels.
Ben Clayton [Thu, 21 Feb 2019 12:37:53 +0000 (12:37 +0000)]
GLES: Add tests to exersise sparse labels.

Reproduces the issues reported by b/125183107.

Bug: b/125183107
Change-Id: If0f2ab3fcc8c065409fdbbc6df670f78a78fa3f7
Reviewed-on: https://swiftshader-review.googlesource.com/c/25169
Tested-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoConnect fragment shader outputs to raster operations stage
Chris Forbes [Wed, 20 Feb 2019 01:19:48 +0000 (17:19 -0800)]
Connect fragment shader outputs to raster operations stage

Bug: b/124177079
Change-Id: I0dbcd154c2a28c43d9895e264cc794fc2ed289f2
Reviewed-on: https://swiftshader-review.googlesource.com/c/25029
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoAdd epilog pass to copy outputs out to pipeline
Chris Forbes [Wed, 20 Feb 2019 01:01:28 +0000 (17:01 -0800)]
Add epilog pass to copy outputs out to pipeline

Bug: b/124177079
Change-Id: I1779ed78ccfdb6c77bcf55ba109ae93fc75171ff
Reviewed-on: https://swiftshader-review.googlesource.com/c/24989
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoFix WalkAccessChain to actually walk type tree properly
Chris Forbes [Wed, 20 Feb 2019 01:41:41 +0000 (17:41 -0800)]
Fix WalkAccessChain to actually walk type tree properly

This was completely broken -- we weren't walking down the type tree at
all.

Bug: b/124388146
Change-Id: I359d121403c3413e74427fadf57fd4c3d52f7661
Reviewed-on: https://swiftshader-review.googlesource.com/c/25088
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoRemove needless unique_ptr wrapping from inputs/outputs
Chris Forbes [Wed, 20 Feb 2019 00:40:57 +0000 (16:40 -0800)]
Remove needless unique_ptr wrapping from inputs/outputs

Bug: b/124534397
Change-Id: Icfe0d83b0e8df648c90ba7f250924ad28dd06b55
Reviewed-on: https://swiftshader-review.googlesource.com/c/25108
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoSeparate intermediate values from lvalues
Chris Forbes [Sat, 16 Feb 2019 00:00:08 +0000 (16:00 -0800)]
Separate intermediate values from lvalues

The vast majority of values in a SPIRV program are intermediates -- they
are guaranteed written to exactly once, by the instruction which defines
them.

Initially we had treated these the same as mutable (stack) variables, but
that produces wasteful code full of loads and stores.

Instead, represent intermediate values as a bundle of RValue<Float4>,
representing an rvalue float-sized value per SIMD lane. Introduce the
new type Intermediate to hold these bundles to allow incremental
construction of the individual RValue<Float4> objects within the bundle.

Bug: b/124534397
Change-Id: Ibb663773100d017de117111705b530b092f87ea2
Reviewed-on: https://swiftshader-review.googlesource.com/c/24968
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoSpirvShader: Split objects from types.
Ben Clayton [Wed, 20 Feb 2019 10:22:09 +0000 (10:22 +0000)]
SpirvShader: Split objects from types.

Change-Id: Ifbcb30da30b912a1a60f5799717869c8d56cd90b
Reviewed-on: https://swiftshader-review.googlesource.com/c/25018
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agoSilence warnings: Add override to overriden virtual functions
Ben Clayton [Wed, 20 Feb 2019 08:53:50 +0000 (08:53 +0000)]
Silence warnings: Add override to overriden virtual functions

Bug: b/123933266
Change-Id: I3e5f028ab323f361840a6326a1b7834995e8b8e3
Reviewed-on: https://swiftshader-review.googlesource.com/c/25017
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agoSilence warnings: Remove bit-packing of Vulkan state
Ben Clayton [Tue, 19 Feb 2019 17:06:30 +0000 (17:06 +0000)]
Silence warnings: Remove bit-packing of Vulkan state

This produces a non-silenceable warning about enum fields being too small to store all enum values.

Nicolas agreed we can just drop the bitpacking for vulkan state.

Bug: b/123933266
Change-Id: Idf09be3ef122fca70da8d877a211368b7fd8a995
Reviewed-on: https://swiftshader-review.googlesource.com/c/25013
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoswiftshader: Remove semicolons.
Nico Weber [Wed, 20 Feb 2019 14:23:05 +0000 (09:23 -0500)]
swiftshader: Remove semicolons.

Bug: chromium:926235
Change-Id: I9d5a28e1dd2ee6619ee0fefcd9f3798ca22be45b
Reviewed-on: https://swiftshader-review.googlesource.com/c/25048
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Tested-by: Nico Weber <thakis@chromium.org>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoSilence warnings: Remove all unused local variables
Ben Clayton [Tue, 19 Feb 2019 16:50:48 +0000 (16:50 +0000)]
Silence warnings: Remove all unused local variables

Bug: b/123933266
Change-Id: If8fa478aa65f5c0046ca635a8d133911f8a59977
Reviewed-on: https://swiftshader-review.googlesource.com/c/25010
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agoFix mismatch of enum types in equality test
Ben Clayton [Tue, 19 Feb 2019 17:04:37 +0000 (17:04 +0000)]
Fix mismatch of enum types in equality test

Lost in the noise of other warnings

Bug: b/123933266
Change-Id: I4c4eecb55a364c9afacf52b790f43f9d5c9640cb
Reviewed-on: https://swiftshader-review.googlesource.com/c/25012
Tested-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoSilence warnings: Add default cases to partial enum switches.
Ben Clayton [Tue, 19 Feb 2019 16:39:36 +0000 (16:39 +0000)]
Silence warnings: Add default cases to partial enum switches.

Fixes warnings about switch statements not handling all enum values.

Bug: b/123933266
Change-Id: I0372ebf2412452622eb99ea7bba7ebc5cedd385c
Reviewed-on: https://swiftshader-review.googlesource.com/c/25009
Tested-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoGLES: Add unit tests for compile time limits
Ben Clayton [Tue, 12 Feb 2019 09:38:02 +0000 (09:38 +0000)]
GLES: Add unit tests for compile time limits

Compiles and links shaders that perform deep nesting of control blocks and calls.

Bug: b/123587120
Change-Id: I8f19611cbe6d36990ad368a600d2d5be20b1ea07
Reviewed-on: https://swiftshader-review.googlesource.com/c/24728
Tested-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
5 years agoRemove sw::BoundedIndex
Ben Clayton [Tue, 19 Feb 2019 18:50:29 +0000 (18:50 +0000)]
Remove sw::BoundedIndex

Not longer needed after https://swiftshader-review.googlesource.com/c/SwiftShader/+/24668

Change-Id: Ib345e5f288123387d44d230438da899120be830a
Reviewed-on: https://swiftshader-review.googlesource.com/c/25016
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agoGLES: Remove hardcoded shader limits
Ben Clayton [Mon, 11 Feb 2019 20:59:19 +0000 (20:59 +0000)]
GLES: Remove hardcoded shader limits

Perform whole-shader analysis to determine usage limits.
Use these limits to allocate compile time and runtime arrays.

Removes the constants:
MAX_SHADER_NESTED_LOOPS
MAX_SHADER_NESTED_IFS
MAX_SHADER_CALL_STACK_SIZE

Also switched to using dynamic containers to remove the MAX_SHADER_CALL_SITES limit, which I believe to have been buggy and broken.

Bug: b/123587120
Change-Id: I89be80072183ac2aac28124df236888309e7207c
Reviewed-on: https://swiftshader-review.googlesource.com/c/24668
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agoAccumulate compile-time constant and runtime offsets separately
Chris Forbes [Sat, 16 Feb 2019 00:39:17 +0000 (16:39 -0800)]
Accumulate compile-time constant and runtime offsets separately

This makes WalkAccessChain slightly easier on the backend -- there is
less constant folding to do.

Bug: b/124388146

Change-Id: I4e76c3e494278e1399b8a86134b652c2a6d96d8c
Reviewed-on: https://swiftshader-review.googlesource.com/c/24988
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoGLES: Fix for crashes when sampling certain textures.
Ben Clayton [Thu, 14 Feb 2019 19:31:30 +0000 (19:31 +0000)]
GLES: Fix for crashes when sampling certain textures.

There was an optimization that skipped a [0, 1] clamp for a particular sampling mode as it assumed
the input coordinates were always within these bounds.

However, if the texture sample coordinates were inf or NaN, this assumption broke, causing the
returned address to be outside the bounds of the image data.

Bug: b/123731195
Bug: b/124368982
Change-Id: I0af34ee4c2792b19081d9270fd0b1e0d0559287e
Reviewed-on: https://swiftshader-review.googlesource.com/c/24868
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agovkCmdBlitImage: Make a copy of the VkImageBlit structure
Ben Clayton [Tue, 19 Feb 2019 11:42:31 +0000 (11:42 +0000)]
vkCmdBlitImage: Make a copy of the VkImageBlit structure

Don't hold a pointer to the structure - there's no guarantees it'll still be vaild by command buffer execution time.

Fixes flakiness of the dEQP-VK.memory.pipeline_barrier.transfer_dst_storage_image.* tests

Bug: b/124729778
Change-Id: I747512b1a34c5d4d7dff227b15b08c69d07b298d
Reviewed-on: https://swiftshader-review.googlesource.com/c/25008
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
5 years agovkGetRenderAreaGranularity implementation
Alexis Hetu [Fri, 15 Feb 2019 19:42:38 +0000 (14:42 -0500)]
vkGetRenderAreaGranularity implementation

There's no reason to have any limitation on granularity in
SwiftShader, so the granularity is always 1 pixel.

Passes all tests in:
dEQP-VK.api.granularity

Bug b/119620965

Change-Id: Ie2f09737c0054da1b6806b9572e515446a8b1263
Reviewed-on: https://swiftshader-review.googlesource.com/c/24890
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
5 years agoPrevent Pipeline crashing on missing non mandatory structures
Alexis Hetu [Fri, 15 Feb 2019 20:56:14 +0000 (15:56 -0500)]
Prevent Pipeline crashing on missing non mandatory structures

When constructing a Graphics pipeline, some structures may or may
not exist, depending on what will be used by the render pass. These
structures (viewportState, multisampleState, depthStencilState and
colorBlendState) are now checked before being used, since it is
allowed for these to be null.

Bug b/118386749

Change-Id: If2759ae2554a98143b30e70624a0dc8d88c5bd43
Reviewed-on: https://swiftshader-review.googlesource.com/c/24911
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoSupport loads and stores of interface variables
Chris Forbes [Wed, 13 Feb 2019 20:24:35 +0000 (12:24 -0800)]
Support loads and stores of interface variables

Bug: b/124388146
Change-Id: I2c422dc2f85730f4c4bef45388e77028465ea9ba
Reviewed-on: https://swiftshader-review.googlesource.com/c/24828
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoAdd SpirvRoutine::getValue helper
Chris Forbes [Tue, 12 Feb 2019 20:38:26 +0000 (20:38 +0000)]
Add SpirvRoutine::getValue helper

- Provides a point to complain if something is not yet defined.
- Allows avoiding ugly syntax from use of unique_ptr

Bug: b/124388146
Change-Id: Ib55023fff5c90b71a41c5f558544be65250bb67d
Reviewed-on: https://swiftshader-review.googlesource.com/c/24791
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
5 years agoImplement some common forms of OpAccessChain
Chris Forbes [Tue, 12 Feb 2019 20:10:05 +0000 (20:10 +0000)]
Implement some common forms of OpAccessChain

Bug: b/124388146
Change-Id: I948ad5607c1e41be920006aaa4b7d18d210af4a3
Reviewed-on: https://swiftshader-review.googlesource.com/c/24790
Tested-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoImplement some common forms of OpStore
Chris Forbes [Tue, 12 Feb 2019 18:56:38 +0000 (18:56 +0000)]
Implement some common forms of OpStore

Bug: b/124388146
Change-Id: Ia3c4e6c81432dcfbca5bdd21c857108ee14bda9b
Reviewed-on: https://swiftshader-review.googlesource.com/c/24788
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoImplement some common forms of OpLoad
Chris Forbes [Mon, 11 Feb 2019 00:20:16 +0000 (00:20 +0000)]
Implement some common forms of OpLoad

Bug: b/124388146
Change-Id: I79b4c3bc59631332f4748394a166612ad5d975de
Reviewed-on: https://swiftshader-review.googlesource.com/c/24600
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoTemplatize PopulateInterface & friends
Chris Forbes [Wed, 13 Feb 2019 19:45:27 +0000 (11:45 -0800)]
Templatize PopulateInterface & friends

I need to also walk interface objects in shader prolog & epilog; will
reuse this logic.

Bug: b/124388146
Change-Id: Ida735f58aa1bc36d83e4a6ea3c16925a9c5656b0
Reviewed-on: https://swiftshader-review.googlesource.com/c/24808
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoSplit out decoration application helpers to avoid some iterator noise
Chris Forbes [Tue, 12 Feb 2019 19:24:50 +0000 (19:24 +0000)]
Split out decoration application helpers to avoid some iterator noise

Bug: b/124388146
Change-Id: I17531e47fc6fc4b296f893f94beb75f471847fd3
Reviewed-on: https://swiftshader-review.googlesource.com/c/24789
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoFix handling of pointer sizes; we want them to be 1
Chris Forbes [Sun, 10 Feb 2019 23:03:12 +0000 (23:03 +0000)]
Fix handling of pointer sizes; we want them to be 1

Bug: b/124388146
Change-Id: Id528368106eb0d09930ff4fccbe94704b585a531
Reviewed-on: https://swiftshader-review.googlesource.com/c/24599
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoAdd analysis pass support for OpLoad and OpAccessChain
Chris Forbes [Sun, 10 Feb 2019 22:42:42 +0000 (22:42 +0000)]
Add analysis pass support for OpLoad and OpAccessChain

These are our first instructions which yield ssavalues.
For OpAccessChain, also track the base pointer (which we always know at
compile time, until we do full variable pointers support).

The value representation for OpAccessChain's result has two parts:
- per-lane Int offset into whatever the thing is
- shared (and statically known) base reference.

Bug: b/124388146
Change-Id: I364375719b6e396b802de06093454c8f0e76adb6
Reviewed-on: https://swiftshader-review.googlesource.com/c/24598
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoHandle more instructions in spirv analysis pass
Chris Forbes [Sun, 10 Feb 2019 22:41:21 +0000 (22:41 +0000)]
Handle more instructions in spirv analysis pass

Most of these are "we know we can just ignore this instruction", but
also sanity check for the lowering passes applied before this -- if any
of those instructions remain, then we're very likely to do the wrong
thing.

Bug: b/124388146
Change-Id: I3f8f66121f57f20cc93abdbd26c575baf03d9c94
Reviewed-on: https://swiftshader-review.googlesource.com/c/24597
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoRemove more obsolete machinery from PixelProcessor
Chris Forbes [Sun, 10 Feb 2019 22:09:15 +0000 (22:09 +0000)]
Remove more obsolete machinery from PixelProcessor

Bug: b/124177079
Change-Id: Ibe657d802c38b84bf2017a8aeaf38f887910bc60
Reviewed-on: https://swiftshader-review.googlesource.com/c/24596
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoRemove depthOverride pixel state bit
Chris Forbes [Sun, 10 Feb 2019 22:04:56 +0000 (22:04 +0000)]
Remove depthOverride pixel state bit

This can be queried directly from the shader

Bug: b/124177079
Change-Id: I08aac7f77fb59f005295de3d417d24bf61fb3906
Reviewed-on: https://swiftshader-review.googlesource.com/c/24595
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
5 years agoCorrectly determine whether we need to compute centroids
Chris Forbes [Sun, 10 Feb 2019 21:26:27 +0000 (21:26 +0000)]
Correctly determine whether we need to compute centroids

Bug: b/124177079
Change-Id: I20132ffd5f73c19715393740c27f77e71a3c3c88
Reviewed-on: https://swiftshader-review.googlesource.com/c/24594
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoWire up FS input to the shader
Chris Forbes [Sun, 10 Feb 2019 21:03:00 +0000 (21:03 +0000)]
Wire up FS input to the shader

Bug: b/124177079
Change-Id: I8dac28d2c55ce1c4eb9a815bfad56ba917be32c5
Reviewed-on: https://swiftshader-review.googlesource.com/c/24593
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>

5 years agoRemove VertexProcessor shader constants mechanism
Chris Forbes [Sun, 10 Feb 2019 20:58:46 +0000 (20:58 +0000)]
Remove VertexProcessor shader constants mechanism

Bug: b/124177079
Change-Id: I5293ed6c564219f7a47baea7b62240b3104bd1f9
Reviewed-on: https://swiftshader-review.googlesource.com/c/24592
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>