Commit Graph

117 Commits

Author SHA1 Message Date
Geoff Lang
c316fb15fb
Add missing dependencies when generating spvtools_core_tables (#3199) 2020-02-21 17:23:42 -05:00
Shahbaz Youssefi
1b3441036a Fix chromium build (#3152)
Signed-off-by: Shahbaz Youssefi <syoussefi@google.com>
2020-01-24 17:14:16 -05:00
Shahbaz Youssefi
b97057e7f7 Use spirv-headers' BUILD.gn (#3148)
* Roll external/spirv-headers/ af64a9e82..dc77030ac (4 commits)

$ git log af64a9e82..dc77030ac --date=short --no-merges --format='%ad %ae %s'
2020-01-20 dneto Fix the license to match LICENSE
2020-01-20 syoussefi Add BUILD.gn
2019-11-20 Tobias.Hector Off-by-one errors
2019-11-20 Tobias.Hector Reserve a new block of 64 opcodes

Created with:
  roll-dep external/spirv-headers

* Use BUILD.gn from spirv-headers
2020-01-23 13:40:12 -05:00
David Neto
fb2e819819
Fix GN build for OpenCL.DebugInfo.100 update (#3134)
The utils/generate_grammar_tables.py vendor-operand-kind-prefix
can now take a value of "...nil..." to signify the empty string.
That's needed because GN doesn't quote empty string arguments
correctly down into its action commands.

Fixes #3120
2020-01-08 17:27:38 -05:00
David Neto
64f36ea529
Support OpenCL.DebugInfo.100 extended instruction set (#3080)
* Clone opencl.debuginfo.100 grammar from debuginfo grammar

Update version number to 200 revision 2

* Apply content from OpenCL.DebugInfo.100 extension text

* Rename grammar file

* Support OpenCL.DebugInfo.100 extended instructions

Add support for prefixing operand type names, to disambiguate
them between different instruction sets.

* Add tests for OpenCL.DebugInfo.100

* Support lookup of OpenCL.DebugInfo.100 extinst

* Add tests for enum values

* Recognize 2017-2019 as copyright date range

* Android.mk: support OpenCL.DebugInfo.100 extended instruction set

Also, stop generating core instruction tables for non-unified1 versions
of the grammar.

* Imported entity operand type is concrete

* Bazel: Suppoort OpenCL.DebugInfo.100

* BUILD.gn: Support OpenCL.DebugInfo.100
2019-12-19 17:16:26 -05:00
Jamie Madill
e0d5544c98 Add missing headers to GN. (#3009)
Detected via ANGLE's export_targets.py.

Fixes #3008
2019-11-04 21:01:57 -05:00
Ryan Harrison
c705032b2b
Remove non-existent files from BUILD.gn (#2955)
Fixes #2954
2019-10-09 15:46:36 -04:00
alan-baker
527a689307
Remove validate_datarules.cpp (#2911)
* Checks moved into individual opcode validation
  * removes duplicated checks
* Add check that forward pointer points to struct
2019-09-24 17:55:12 -04:00
dan sinclair
3a762d54f6
Add missing GN dependency (#2899) 2019-09-23 12:56:29 -04:00
David Turner
36c1c0e22f Fix Fuchsia build. (#2868)
Most auto-generated files included by the SPIRV-Tools sources
do not have a proper newline at the end of file, creating a
hundred of compiler warnings, and even some build failures
when BUILD.gn is used for the Fuchsia build.

This fixes the issue by disabling the warning entirely.
2019-09-17 15:57:15 -04:00
Steven Perron
35c9518c4e
Handle id overflow in the ssa rewriter. (#2845)
* Handle id overflow in the ssa rewriter.

Remove LocalSSAElim pass at the same time.  It does the same thing as the SSARewrite pass. Then even share almost all of the same code.

Fixes crbug.com/997246
2019-09-10 09:38:23 -04:00
Jamie Madill
635b583cf1 GN: Add Chromium GoogleTest deps. (#2832)
This fixes a GN header check in the Chromium integration.
2019-09-04 12:43:26 -04:00
greg-lunarg
d11725b1d4 Add --relax-float-ops and --convert-relaxed-to-half (#2808)
The first pass applies the RelaxedPrecision decoration to all executable
instructions with float32 based type results. The second pass converts
all executable instructions with RelaxedPrecision result to the equivalent
float16 type, inserting converts where necessary.
2019-09-03 13:22:13 -04:00
Jamie Madill
1c9ca422dd GN: Make SPIRV-Tools target use public_deps. (#2828)
Should prevent invalid header usage warnings in dependent targets.

See http://anglebug.com/3876 for context.
2019-09-03 12:57:32 -04:00
Corentin Wallez
4ae9b71651 Fix gn check (#2821)
spriv-opt was missing a dependency on the AMD ballot extension that was
needed because it uses a header in the AMD ext to KHR ext pass.
2019-08-30 09:09:34 -04:00
Steven Perron
35d98be3bc
Amd ext to khr (#2811)
Add the first steps to removing the AMD extension VK_AMD_shader_ballot.
Splitting up to make the PRs smaller.

Adding utilities to add capabilities and change the version of the
module.

Replaces the instructions:

OpGroupIAddNonUniformAMD = 5000
OpGroupFAddNonUniformAMD = 5001
OpGroupFMinNonUniformAMD = 5002
OpGroupUMinNonUniformAMD = 5003
OpGroupSMinNonUniformAMD = 5004
OpGroupFMaxNonUniformAMD = 5005
OpGroupUMaxNonUniformAMD = 5006
OpGroupSMaxNonUniformAMD = 5007

and extentend instructions

WriteInvocationAMD = 3
MbcntAMD = 4

Part of #2814
2019-08-29 12:48:17 -04:00
jonahryandavis
1eb89172a8 Add missing files to BUILD.gn (#2809)
New files missing from BUILD.gn caused build failures in Chromium and
ANGLE:
remove_relaxed_precision_decoration_opportunity_finder.cpp
remove_relaxed_precision_decoration_opportunity_finder.h
2019-08-23 13:14:34 -04:00
greg-lunarg
06407250a1 Instrument: Add support for Buffer Device Address extension (#2792) 2019-08-16 09:18:34 -04:00
Steven Perron
60043edfa1
Replace OpKill With function call. (#2790)
We are no able to inline OpKill instructions into a continue construct.
See #2433.  However, we have to be able to inline to correctly do
legalization.  This commit creates a pass that will wrap OpKill
instructions into a function of its own.  That way we are able to inline
the rest of the code.

The follow up to this will be to not inline any function that contains
an OpKill.

Fixes #2726
2019-08-14 09:27:12 -04:00
Steven Perron
4b64beb1ae
Add descriptor array scalar replacement (#2742)
Creates a pass that will replace a descriptor array with individual variables.  See #2740 for details.

Fixes #2740.
2019-08-08 10:53:19 -04:00
David Neto
31590104ec
Add pass to inject code for robust-buffer-access semantics (#2771)
spirv-opt: Add --graphics-robust-access

Clamps access chain indices so they are always
in bounds.

Assumes:
- Logical addressing mode
- No runtime-array-descriptor-indexing
- No variable pointers

Adds stub code for clamping coordinate and samples
for OpImageTexelPointer.

Adds SinglePassRunAndFail optimizer test fixture.

Android.mk: add source/opt/graphics_robust_access_pass.cpp

Adds Constant::GetSignExtendedValue, Constant::GetZeroExtendedValue
2019-07-30 19:52:46 -04:00
greg-lunarg
92c41ff1e7 Remove Common Uniform Elimination Pass (#2731)
Remove Common Uniform Elimination Pass

Fixes #2520.
2019-07-12 11:02:10 -04:00
Corentin Wallez
59de04ad68 BUILD.gn: Add deps and move files for gn check (#2735)
This makes SPIRV-Tools produce no GN check errors when used in Dawn and
ANGLE.
2019-07-12 10:35:59 -04:00
alan-baker
1a2de48a12 Extra small storage validation (#2732)
Fixes #2729

* Check acceptable uses of small type generators
2019-07-11 13:05:14 -04:00
David Turner
5081512502 BUILD.gn: Add targets to build all command-line tools (#2727)
This adds all the command-line tools from the CMakeLists.txt
file to the BUILD.gn used by Chromium and Fuchsia.

+ Add a convenient "all_spirv_tools" GN target to rebuild
  all command-line tools at once.

+ "gn format" pass to fix a few minor issues in the file.

Tested on Chromium with the following procedure:

 1) Have a clean Chromium checkout

 2) # Update to upstream spirv-headers (otherwise spirv-tools build fails)
    cd $CHROMIUM_SRC/third_party/spirv-headers/src &&
    git remote add upstream https://github.com/KhronosGroup/SPIRV-Headers.git &&
    git fetch upstream &&
    git checkout upstream/master

 3) # Update to upstream spirv-tools (Chromium is tracking older revision)
    cd $CHROMIUM_SRC/third_party/SPIRV-Tools/src &&
    git remote add upstream https://github.com/KhronosGroup/SPIRV-Tools.git &&
    git fetch upstream &&
    git checkout -tb check-patch upstream/master &&
    git cherry-pick <patch>

 3) # Rebuild Chromium and all SPIR-V tools for the host
    cd $CHROMIUM_SRC/src &&
    gn gen out/Linux --args 'use_goma = true' &&
    ninja -C out/Linux -j1000 -l30 gn_all all_spirv_tools

 4) Run the command-line tools, e.g.:

    out/Linux/spirv-link --help
2019-07-10 16:37:10 -04:00
David Turner
a6bfc26e5f Fix BUILD.gn for Fuchsia platform build. (#2692)
In order for the Fuchsia source tree to update its
version of SPIRV-Tools to a newer upstream, the
BUILD.gn needs to be slightly altered to take care
of the fact that it can be used with a different
GN //build set of rules and configs than the
Chromium one.

This is done by using |build_with_chromium|, already
defined by //build_overrides/build.gni, to guard
Chromium-specific statements.

+ Add a target to generate spirv-opt which is used by
  Fuchsia to optimize shaders at build time for some
  of its graphics libraries.
2019-07-03 16:26:06 -04:00
Jeff Bolz
2c0111e6eb Add validation for SPV_EXT_fragment_shader_interlock (#2650) 2019-06-03 10:55:07 -04:00
Ryan Harrison
f6d9a17843
Add pass to fix some invalid unreachable blocks for WebGPU (#2563)
Attempts to split up unreachable blocks that are used both as a
merge-block and a continue-target.

Fixes #2429
2019-05-09 12:56:10 -04:00
Ryan Harrison
048dcd38ce
Implement WebGPU->Vulkan initializer conversion for 'Function' variables (#2513)
WebGPU requires certain variables to be initialized, whereas there are
known issues with using initializers in Vulkan. This PR is the first
of three implementing a pass to decompose initialized variables into
a variable declaration followed by a store. This has been broken up
into multiple PRs, because there 3 distinct cases that need to be
handled, which require separate implementations.

This first PR implements the basic infrastructure that is needed, and
handling of Function storage class variables. Private and Output will
be handled in future PRs.

This is part of resolving #2388
2019-04-16 14:31:36 -04:00
Ryan Harrison
102e430a88
Add pass to legalize OpVectorShuffle for WebGPU (#2509)
In WebGPU, the component operand 0xFFFFFFFF is forbidden, but in
Vulkan it is used to indicate a value is undefined. When converting to
WebGPU, 0xFFFFFFFF needs to converted to a legal value, though the
specific one does not matter, since it was used to indicate an
undefined entry in the original code. Choosing to use 0, since the
operands are required to be on [0, N-1], so 0 is guaranteed to always
be valid.

Fixes #2349
2019-04-12 12:14:23 -04:00
Steven Perron
3a0bc9e724
Add fix storage class code. (#2434)
This pass tries to fix validation error due to a mismatch of storage classes
in instructions.  There is no guarantee that all such error will be fixed,
and it is possible that in fixing these errors, it could lead to other
errors.

Fixes #2430.
2019-04-05 13:12:08 -04:00
Shahbaz Youssefi
e8c2d95ed4 Fix webgpu header file name in BUILD.gn (#2493)
A .h file was specified as .hpp file, causing `gn gen path/ --check` to
fail.
2019-04-04 11:46:51 -04:00
Ryan Harrison
01964e325f
Add pass to generate needed initializers for WebGPU (#2481)
Fixes #2387
2019-04-03 11:44:09 -04:00
Ryan Harrison
e545522146
Add --strip-atomic-counter-memory (#2413)
Adds an optimization pass to remove usages of AtomicCounterMemory
bit. This bit is ignored in Vulkan environments and outright forbidden
in WebGPU ones.

Fixes #2242
2019-03-14 13:34:33 -04:00
Jamie Madill
4b42cd19d3 BUILD.gn: Only build tests in Chromium. (#2392)
The prior GoogleTest integration was incomplete and produced errors
when building with 'gn check' enabled. Fix this by scoping the test
integration to Chromium.

Fixes Issue #2382
2019-02-19 10:38:38 -05:00
Steven Perron
1b0047f210
Add pass to remove dead members. (#2379)
Add a pass that looks for members of structs whose values do not affects
the output of the shader. Those members are then removed and just
treated like padding in the struct.
2019-02-14 13:42:35 -05:00
Takuto Ikuta
0187c190b5 Fix BUILD.gn (#2381)
extensions_enum.inc is included from source/table.h.
So spvtools_core_enums_unified1 target should be in public_deps of
spvtools target.

This is for crbug.com/931596
2019-02-13 10:24:06 -05:00
Alastair Donaldson
34c5ac614c
Fixes #2358. Added to the reducer the ability to remove a function t… (#2361)
* Fixes #2358.  Added to the reducer the ability to remove a function that is not directly called.  Factored out some code from the optimizer to help with this.
2019-02-08 16:20:29 +00:00
David Neto
cf78346230 Add source/opt/block_merge_util.* to BUILD.gn (#2344) 2019-01-28 21:42:35 -05:00
Steven Perron
dd4157dcee
Sink (#2284)
Add code sinking pass. It will move OpLoad and OpAccessChain instructions as close as possible to their uses.

Part of #1611.
2019-01-17 15:56:36 -05:00
Ryan Harrison
cf37ab7213
Merge two implementations of ValidateMemorySemantics (#2175)
Fixes #2170
2018-12-06 14:38:15 -05:00
dan sinclair
67b2e1555a
Fixup BUILD.gn from addtion of upgrade_memory_model (#2152) 2018-12-03 09:11:56 -05:00
Ryan Harrison
8ce3dbabb8
Merge two implementations of ValidateExecutionScope (#2131) 2018-11-29 13:48:42 -05:00
dan sinclair
703305b1a5
Fixup BUILD.gn file (#2129) 2018-11-28 09:17:13 -05:00
greg-lunarg
c37388f1ad Add passes to propagate and eliminate redundant line instructions (#2027). (#2039)
These are bookend passes designed to help preserve line information
across passes which delete, move and clone instructions. The propagation
pass attaches a debug line instruction to every instruction based on
SPIR-V line propagation rules. It should be performed before optimization.
The redundant line elimination pass eliminates all line instructions
which match the previous line instruction. This pass should be performed
at the end of optimization to reduce physical SPIR-V file size.

Fixes #2027.
2018-11-15 14:06:17 -05:00
greg-lunarg
1e9fc1aac1 Add base and core bindless validation instrumentation classes (#2014)
* Add base and core bindless validation instrumentation classes

* Fix formatting.

* Few more formatting fixes

* Fix build failure

* More build fixes

* Need to call non-const functions in order.

Specifically, these are functions which call TakeNextId(). These need to
be called in a specific order to guarantee that tests which do exact
compares will work across all platforms. c++ pretty much does not
guarantee order of evaluation of operands, so any such functions need to
be called separately in individual statements to guarantee order.

* More ordering.

* And more ordering.

* And more formatting.

* Attempt to fix NDK build

* Another attempt to address NDK build problem.

* One more attempt at NDK build failure

* Add instrument.hpp to BUILD.gn

* Some name improvement in instrument.hpp

* Change all types in instrument.hpp to int.

* Improve documentation in instrument.hpp

* Format fixes

* Comment clean up in instrument.hpp

* imageInst -> image_inst

* Fix GetLabel() issue.
2018-11-08 13:54:54 -05:00
Steven Perron
5f599e700e
Fix infinite loop in dead-branch-elimination (#1891)
* Create structed cfg analysis.

There are lots of optimization that have to traverse the CFG in a
structured order just because it wants to know which constructs a
basic block in contained in.  This adds extra complexity to these
optimizations, for causes too much refactoring of older optimizations.

To help with this problem, I have written an analysis that can give this
information.

* Identify branches breaking from loops.

Dead branch elimination does a search for a conditional branch to the
end of the current selection construct.  This search assumes that the
only way to leave the construct is through the merge node.  But that is
not true.  The code can jump to the merge node of a loop that contains
the construct.

The search needs to take this into consideration.
2018-09-17 13:00:24 -04:00
dan sinclair
324be76b9c Fixup BUILD.gn file (#1886) 2018-09-11 09:34:42 -04:00
Corentin Wallez
21bcb9d8b9 BUILD.gn: Make a better interface with dependents. (#1877)
This splits the spvtools_config into a public and private part to avoid
leaking internal bits to dependents. A new target is added for the
public headers so that "gn check" works for dependents.

Also formats test/fuzzers/BUILD.gn
2018-09-06 10:50:27 -04:00
dan sinclair
b27d084b01
Revert "BUILD.gn: Make a better interface with dependents. (#1875)" (#1876)
This reverts commit 3cddf9131d.

This breaks the Chrome roll:

ERROR Unresolved dependencies.
//third_party/SPIRV-Tools/src/test/fuzzers:fuzzer_config(//build/toolchain/linux:clang_x64)
needs //third_party/SPIRV-Tools/src:spvtools_config(//build/toolchain/linux:clang_x64)
GN gen failed: 1
2018-09-05 14:21:01 -04:00
Corentin Wallez
3cddf9131d BUILD.gn: Make a better interface with dependents. (#1875)
This splits the spvtools_config into a public and private part to avoid
leaking internal bits to dependents. A new target is added for the
public headers so that "gn check" works for dependents.
2018-09-05 13:37:12 -04:00
Alan Baker
c5b38062ec Moving constant opcode validation into a new file
* Split constant opcode validation out of idUsage and into
validate_constants.cpp
 * minor style fixes
 * reduced duplication
 * fixed an issue with array sizing
2018-08-21 17:30:26 -04:00
dan sinclair
1bdade77ea
Add GN rules to build spriv-as (#1842) 2018-08-15 15:26:28 -04:00
dan sinclair
ef678672fb
Remove source/message.h (#1838)
The code in source/message was only used in a single set of tests to
format the output results. This CL changes the test to verify the
message instead of all the error values and removes the source/message
code.
2018-08-14 15:41:21 -04:00
dan sinclair
1553025f4c
Move make_unique to source/util. (#1836)
This MakeUnique code is used in places other then source/opt so move it
to source/utils.
2018-08-14 12:44:54 -04:00
dan sinclair
5fc011b453
Move bit_stream, move_to_front and huffman_codec. (#1833)
bit_stream, move_to_front and huffman_codec are only used by
source/tools. Move into that directory to make the usage clearer.
2018-08-14 09:52:05 -04:00
Alan Baker
e7fdcdba75 Split function opcode validation into new files.
* Moved function opcode validation out of idUsage and into new files
 * minor style changes
 * General opcode checking is in validate_function.cpp
 * Execution limitation checking is in
 validate_execution_limitations.cpp
* Execution limitations was split into a new pass as it requires other
validation to register those limitations first.
2018-08-13 17:04:57 -04:00
Alan Baker
714bf84e58 Split mode setting opcode validation into new file.
* Moved mode setting opcode validation out of idUsage and into a new
pass
 * minor style updates
2018-08-08 15:45:53 -04:00
Alan Baker
7d4b0464a3 Split annotation opcode validation into new file.
* Moves annotation opcode checks from idUsage into a new pass
 * minor style updates
2018-08-08 15:43:11 -04:00
Alan Baker
ca7278cff7 Split debug opcode validation into new file
* Removes debug opcode validation from idUsage and puts it in a separate
file
 * minor updates
2018-08-08 13:47:09 -04:00
Alan Baker
f2a990022a Move type instruction validation into separate file
* Moved type instruction validation out of validation idUsage into a new
file
* Consolidate type unique pass into new file
* Removed one bad test
* Reworked validation ordering
2018-08-08 12:55:39 -04:00
dan sinclair
eda2cfbe12
Cleanup includes. (#1795)
This Cl cleans up the include paths to be relative to the top level
directory. Various include-what-you-use fixes have been added.
2018-08-03 15:06:09 -04:00
Corentin Wallez
2d9a325264 Refactor BUILD.gn so can easily be embedded in other projects
1.
BUILD.gn: Don't use the extra Chromium clang warnings

Also removes the unused .gn secondary_sources.

2.

Move fuzzers in test/ instead of testing/

This frees up testing/ to be the git subtree of Chromium's src/testing/
that contains test.gni, gtest, gmock and libfuzzer

3.

DEPS: get the whole testing/ subtree of Chromium

4.

BUILD.gn: Simplify the standalone gtest targets

These targets definitions are inspired from ANGLE's and add a variable
that is the path of the googletest directory so that it can be made
overridable in future commits.

6.

BUILD.gn: Add overridable variables for deps dirs

This avoids hardcoded paths to dependencies that make it hard to
integrate SPIRV-Tools in other GN projects.
2018-08-03 10:06:11 -04:00
dan sinclair
de9496e9f1
Add more fuzzers for Optimizer. (#1788)
This Cl adds the legalization and size fuzzers for the optimizer. The
main optimizer is renamed to the performance optimizer.
2018-08-02 14:36:43 -04:00
Alan Baker
d49bedcaa6 Move memory class instructions to new pass
* Refactored the Memory class of instructions in the spec out Id
validation and into a new pass
 * Tests unmodified
 * some minor disassembly changes
 * minor style changes
2018-08-01 16:10:11 -04:00
dan sinclair
a97c1d911a
Fixup BUILD.gn to use a group for SPIRV-Tools (#1779)
The SPIRV-Tools target doesn't build anything, it just depends on the other libraries. As such, there is no static_library generated and this should be a group() instead.
2018-08-01 14:28:10 -04:00
Dan Sinclair
a114e1f30c Add support for Chromium GN build
Build test

Add Fuzzer group

Add libfuzzer
2018-07-24 11:31:14 -04:00