Commit Graph

1711 Commits

Author SHA1 Message Date
Khronos Group Webmaster
6ff2f64702
Update LICENSE
Change Apache 2.0 to Khronos Apache 2.0 CLA
2018-09-27 16:38:01 -04:00
alan-baker
ad0232dee5 Unify memory instruction validation style (#1934)
* Rename ValidateMemoryInstructions to MemoryPass
* Changed functions to take pointer to an instruction instead of
reference
2018-09-27 12:34:14 -04:00
Steven Perron
d3738be347 Update CHANGES 2018-09-27 10:11:52 -04:00
Jaebaek Seo
4b4bd4c53a Validator: Validate OpImageTexelPointer (#487)
Checked all instructions whose object is OpTypeSampledImage or
OpTypeImage as suggested in #487. OpImageTexelPointer instruction
is missing and others look good. This commit adds only
OpImageTexelPointer.
2018-09-27 09:53:30 -04:00
alan-baker
a78fa0978d Set the C++ version to C++11 (#1933)
This reverts commit bfcdc913c4.
2018-09-27 09:44:01 -04:00
Steven Perron
80564a56ec
Keep analyses live in unrolling (#1929)
Add code to keep the def-use manger and the inst-to-block mapping up-to-date. This means we do not have to rebuild them later.

To make this work, we will have to have to find places to update the
def-use manager. Updating the def-use manager is not straight forward
because we are unrolling loops, and we have circular references.

This forces one pass to register all of the definitions. A second one
to analyze the uses. Also because there will be references to the new
instructions in the old code, we want to register the definitions of the
new instructions early, so we can update the uses of the older code as
we go along.

The inst-to-block mapping is not too difficult. It can be done as instructions are created.

Fixes #1928.
2018-09-26 17:36:27 -04:00
Lei Zhang
1225324ae2
VK_KHR_shader_atomic_int64 covers OpAtomic{Load|Store} 2018-09-26 16:45:37 -04:00
dan sinclair
45784eb2c8
Remove use of SetContextMessageConsumer from binary_parse_test (#1925)
This CL removes the use of SetContextMessageConsumer from the
binary_parse_test tests and creates a Context object and uses
SetMessageConsumer instead.
2018-09-26 13:17:36 -07:00
Jaebaek Seo
026309ab27 Validator: OpGroupNonUniformBallotBitCount validation (#1486) 2018-09-26 15:52:39 -04:00
Lei Zhang
bfcdc913c4
[ci] Checkout a specific Google Test commit (#1931) 2018-09-26 15:19:54 -04:00
dan sinclair
b07993ebf4
Remove SetContextMessageConsumer from markv_codec_test (#1926)
This CL removes the use of SetContextMessageConsumer from
markv_codec_test and replaces it with a spvtools::Context instead.
2018-09-26 10:33:16 -07:00
dan sinclair
7249506b73
Remove stats use of internal API (#1924)
Instead of using the source/table.h methods, this CL switches the stats
tool to use the spvtools::Context class and assign the message consumer
through the public API.
2018-09-26 10:32:05 -07:00
Steven Perron
0e5fc7d75e
Allow 0 as argument to scalar replacement. (#1917)
A limit of 0 for the scalar replacement options it used to indicate that
there is no limit.  The current implementation does not allow 0.  This
should be fixed.
2018-09-26 09:58:28 -04:00
dan sinclair
903514f954
Roll DEPS for spirv-headers (#1920) 2018-09-25 11:04:51 -07:00
Steven Perron
b85fb4a300
Get KillNameAndDecorates to handle group decorations. (#1919)
It seems like the current implementation of KillNameAndDecorates does
not handle group decorations correctly.  The id being removed is not
removed from the OpGroupDecorate instructions.  Even worst, any
decorations that apply to that group are removed.

The solution is to use the function in the decoration manager that will
remove the decorations and update the instructions instead of doing the
work itself.
2018-09-25 12:57:44 -04:00
Alan Baker
90a12b3d4d Decoration validation for Vulkan memory model
* Adds a check that using Coherent or Volatile decorations with the
Vulkan memory model is a validation error
 * Adds tests
2018-09-21 21:55:01 -04:00
Alan Baker
1492111332 Validate vulkan mem model capabilty
* Check that if the VulkanMemoryModelKHR capability is specified that
the memory model must be VulkanKHR
 * added tests
2018-09-21 21:50:20 -04:00
Lei Zhang
575af7ecfc
[kokoro] Add test job for disabling effcee (#1911) 2018-09-21 08:25:26 -04:00
Lei Zhang
9bfe0eb25e Wrap tests needing effcee inside SPIRV_EFFCEE 2018-09-20 11:51:40 -04:00
Chao Chen
6e2dab2ffd Add support for Nvidia Turing extensions 2018-09-19 20:46:14 -04:00
Steven Perron
9fbcce4ca1
Add unrolling to the legalization passes (#1903)
Adds unrolling to the legalization passes.

After enabling unrolling I found a bug when there is a self-referencing
phi node.  That has been fixed.

The test that checks for that the order of optimizations is correct also
needed to be updated.
2018-09-19 16:40:09 -04:00
Jaebaek Seo
9e99d8b691 Specified clang-format version in README.md 2018-09-18 10:35:28 -04:00
Jaebaek Seo
0cd3e599ae Validator: correct out of bound check for OpMemberDecorate (#1881)
The number that indicates a member in OpMemberDecorate must be less
than the number of total members of struct.
2018-09-18 10:16:46 -04:00
Steven Perron
7f0a8877a2
Move the registration of decorations. (#1895)
We currently register decorations in the first pass through the
instructions.  This is a problem because the validator has not even
checked if the decoration instructions are valid yet.  This can lead to
unexpected behaviour from these side table.  For example, in
https://github.com/KhronosGroup/SPIRV-Tools/issues/1882, we use 5GB of
data to store 1 decoration for ids that are not even defined.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/1882.
2018-09-18 08:53:09 -04:00
Steven Perron
7075c49923
Add dummy loop in merge-return. (#1896)
The current implementation of merge return can create bad, but correct,
code.  When it is not in a loop construct, it will insert a lot of
extra branch around code.  The potentially large number of branches are
bad.  At the same time, it can separate code store to variables from
its uses hiding the fact that the store dominates the load.

This hurts the later analysis because the compiler thinks that multiple
values can reach a load, when there is really only 1.  This poorer
analysis leads to missed optimizations.

The solution is to create a dummy loop around the entire body of the
function, then we can break from that loop with a single branch.  Also
only new merge nodes would be those at the end of loops meaning that
most analysies will not be hurt.

Remove dead code for cases that are no longer possible.

It seems like some drivers expect there the be an OpSelectionMerge
before conditional branches, even if they are not strictly needed.
So we add them.
2018-09-18 08:52:47 -04: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
Diego Novillo
4a4632264e Add IR dumping functions to use during debugging.
When using lldb and/or gdb I frequently get odd std::string failures
when using the IR printing instructions we have now.  This adds the
methods  Instruction::Dump(), BasicBlock::Dump() and Function::Dump() to
emit the output of the pretty print to stderr.

With this I can now reliably print IR from gdb and lldb sessions.
2018-09-14 14:28:34 -04:00
Lei Zhang
63265097e5
Add support for VK_KHR_shader_atomic_int64 in validator 2018-09-14 14:07:25 -04:00
Steven Perron
6d5f1bc2e8
Allow merge blocks to merge two header blocks in some cases. (#1890)
In merge blocks, we do not allow the merging of two blocks with merge
instructions.  This is because if the two block are merged only 1 of
those instructions can exists.  However, if the successor block is the
merge block of the predecessor, then we can delete the merge instruction
in the predecessor.  In this case, we are able to merge the blocks.
2018-09-14 13:37:18 -04:00
Lei Zhang
0f4c772ee2
Respect --skip-validation in spirv-opt (#1887)
Previously a field in OptimizerOptions was set for --skip-validation,
but the OptimizerOptions was never used when calling optimizer.Run().
2018-09-12 13:41:50 -04:00
dan sinclair
324be76b9c Fixup BUILD.gn file (#1886) 2018-09-11 09:34:42 -04:00
Jaebaek Seo
2c2fee7979 Validator: check OpTypeBool inside Blocks (#1405)
OpTypeBool can only be used with non-externally visible shader
Storage Classes: Workgroup, CrossWorkgroup, Private, and Function.
2018-09-10 13:33:13 -04:00
Steven Perron
75c1bf2843
Add option for the max id bound. (#1870)
* Create a new entry point for the optimizer

Creates a new struct to hold the options for the optimizer, and creates
an entry point that take the optimizer options as a parameter.

The old entry point that takes validator options are now deprecated.
The validator options will be one of the optimizer options.

Part of the optimizer options will also be the upper bound on the id bound.

* Add a command line option to set the max value for the id bound.  The default is 0x3FFFFF.

* Modify `TakeNextIdBound` to return 0 when the limit is reached.
2018-09-10 11:49:41 -04:00
Steven Perron
f62d7978fc
Add validation check for arrays of void type. (#1880)
In the definition of an array
(https://www.khronos.org/registry/spir-v/specs/1.2/SPIRV.html#Array),
it specfically mentions that array elements have non-void type.  I've
added a check for that in this PR.

http://crbug.com/879016
2018-09-10 09:21:32 -04:00
dan sinclair
40a68547dc
Roll spirv-headers in DEPS (#1884) 2018-09-07 12:58:32 -04:00
David Neto
3e38c99f5d Start SPIRV-Toosl v2018.6-dev 2018-09-07 11:42:12 -04:00
David Neto
b4cb01c7c4 Finalize SPIRV-Tools v2018.5 2018-09-07 11:40:56 -04:00
David Neto
03896b05c1 Update CHANGES 2018-09-07 11:40:14 -04:00
David Neto
7600fc0e19 Update Dim capabilities
Corresponds to grammar changes for SPIR-V 1.3 Rev4.
2018-09-06 13:41:31 -04:00
David Neto
571251c8f8 Support SPV_KHR_vulkan_memory_model rev2
Support collapsed into one commit:
- Asm/Dis support for SPV_KHR_vulkan_memory_model
- Add Vulkan mem model image operands to switch
- Add TODO for source/validate_image.cpp
- val: Image operands NonPrivateTexelKHR, VolatileTexelKHR have no operands
  This is required for memory model tests to pass SPIR-V validation.
- Round trip tests: Test new flags on OpCopyMemory*
2018-09-06 13:30:32 -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
Tobin Ehlis
58e53ea82f Fix sign mismatch warning
Cast negative ints to uint32_t to avoid int/uint comparison warning.
2018-08-31 17:51:43 -04:00
Alan Baker
cb0f1f565b Remove struct member offset monotonicity check
Fixes #1822

* Remove check that struct member offsets must be monotonic
 * All environments match Vulkan behaviour now
 * updated offending tests
2018-08-31 09:45:45 -04:00
Steven Perron
482b1744ca
Validate all type ids. (#1868)
* Validate all type ids.

The validator does not check if the type of an instruction is actually
a type unless the OpCode has a specific requirement.  For example,
OpFAdd is checked, but OpUndef is not.

The commit add a generic check that if there is a type id then the id
defines a type.

http://crbug.com/876694

* Merge other checks for type into new one.

There are a couple check that the type id is a type for specific
opcodes.  Those have been mereged into 1.

Small changes to other test cases to make them valid enough for the
purpose of the test.
2018-08-27 23:45:32 -04:00
Steven Perron
06b42949b6
Validate uses of OpTypeFunction. (#1867)
In the specification of `OpTypeFunction`, it says

> OpFunction is the only valid use of OpTypeFunction.

This commit add a check in the validator for this rule.

A test started to fail because the new check happens before the check
the test case is testing.  Updated the test case to still fail the
check it was suppose to fail originally.

http://crbug.com/874571
2018-08-27 11:41:25 -04:00
alan-baker
d94a2077d6
Remove idUsage
* Moved remaining validation out of idUsage and deleted it
* Deleted unused functions
2018-08-27 11:06:09 -04:00
Steven Perron
416b1ab4f3
Have the constant manager take ownership of constants. (#1866)
* Have the constant manager take ownership of constants.

Right now the owner of an object of type contant that is in the
|const_pool_| of the constant manager is unclear.  The constant
manager does not delete them, there is no other reasonable owner.  This
causes memory leaks.

This change fixes the memory leaks by having the constant manager
take ownership of the constant that is stores in |const_pool_|.  Other
changes include interface changes to make it explicit that the constant
manager takes ownership of the object when a constant is registered
with the constant manager.

Fixes #1865.
2018-08-27 09:53:47 -04:00
Steven Perron
47ee776a2c Revert "Have the constant manager take ownership of constants."
This reverts commit b938b74bac.
2018-08-24 15:12:49 -04:00