Commit Graph

1851 Commits

Author SHA1 Message Date
David Neto
6df6194db8
Validate Uniform decoration (#2181) 2018-12-07 09:32:57 -05:00
Ryan Harrison
cf37ab7213
Merge two implementations of ValidateMemorySemantics (#2175)
Fixes #2170
2018-12-06 14:38:15 -05:00
Steven Perron
aa270e568a
Be more explicit about SPIRV_WERROR option. (#2141)
There was some confusion about the SPIRV_WERROR option when it is turned
off.  When the option is off nothing is done.  That is, we do not add
-Wno-error.  This means that if the parent project added -Werorr to the
C flags or CXX flags, then warnings will still be treated as errors.

I've updated the README.md to make this explicit.

Fixes #2121.
2018-12-06 11:31:47 -05:00
Steven Perron
2e4563d94f
Document in the context what happens with id overflow. (#2159)
Added documentation to the ir context to indicates that TakeNextId()
returns 0 when the max id is reached.  TODOs were added to each call
sight so that we know where we have to start to handle this case.

Handle id overflow in |SplitLoopHeader|.

Handle id overflow in |GetOrCreatePreHeaderBlock|.

Handle failure to create preheader in LICM.

Part of https://github.com/KhronosGroup/SPIRV-Tools/issues/1841.
2018-12-06 09:07:00 -05:00
Alejandro Lopez
03afee3b90 Test for WorkgroupId not being a uvec3 (#2173)
Test for WorkgroupId not being a uvec3

Fixes #1545

Make %workgroup_id an Input variable as required by spec
2018-12-05 16:34:57 -05:00
Ryan Harrison
d9a972210f
Fix broken recurison validation tests (#2174)
This fixes tests that were broken by adding in validation of the order
of function definitions.
2018-12-05 15:33:55 -05:00
Ryan Harrison
378b7f3a29
Check for recursion in Vulkan and WebGPU entry points (#2161)
Fixes #2061
Fixes #2160
2018-12-05 13:58:43 -05:00
Alejandro Lopez
2f5f5308b6 Validate that there is at most one push constant block (#2163)
Fixes #2006

Validates that there is at most one PushConstant interface per entry point for Vulkan environment.
2018-12-05 13:30:04 -05:00
Ryan Harrison
3e645b9d67
Check that if A calls B, B is defined before A for WebGPU (#2169)
Fixes #2067
2018-12-05 11:47:24 -05:00
alan-baker
68d1dc66d2
Loosen binding and descriptor check (#2167)
* Only check for binding and descriptor set on variables that are
statically used by an entry point
 * updated tests and added a couple new ones
 * new method for collecting entry points that statically reference an
 id
2018-12-05 08:10:02 -05:00
Steven Perron
a0816d03e9
Validate OpForwardPointer (#2156)
* Validate OpForwardPointer

The validator does not have a a check that OpForwardPointer is giving
a forward reference to a pointer type.  We add that check.

https://crbug.com/910852

* Remove more specialized check.

There was a check that the forward pointer is actually a poiner type,
but it was only done if it was used in a struct.  This was too specific.
Remove it in favour of the more general check that was added.

* Format

* Check the storage type in OpTypeForwardPointer

* Fix typo is test case epxected results.
2018-12-04 13:35:49 -05:00
Alejandro Lopez
a1439604ea Check binding annotations in resource variables (#2151)
Fixes #2007

Add checks that all uniform, uniform constant and storage buffer variables have descriptor set and binding decorations
2018-12-04 10:05:41 -05:00
Steven Perron
17cba4695c
Remove undefined behaviour when folding shifts. (#2157)
We currently simulate all shift operations when the two operand are
constants.  The problem is that if the shift amount is larger than
32, the result is undefined.

I'm changing the folder to return 0 if the shift value is too high.
That way, we will have defined behaviour.

https://crbug.com/910937.
2018-12-04 10:04:02 -05:00
David Neto
d81a0c0ec4 Fix WebGPU barrier test: Use QueueFamilyKHR scope (#2162) 2018-12-04 08:35:08 -05:00
alan-baker
b1ff8ba5b9
Check device scope for Vulkan memory model (#2149)
Fixes #2147

* Checks that device scope is not used for availability and visibility
operations unless VulkanMemoryModelDeviceScopeKHR capability is present
* implemented for atomics, barriers and memory instructions currently
2018-12-03 17:15:47 -05:00
dan sinclair
d835d664bd
[val] Fixup id name output (#2158)
This CL changes the id/name output from the validator to always use a
consistent id[%name] style. This removes the need for getIdOrName. The
name lookup is changed to use the NameMapper so the output is consistent
with what the disassembler will produce.

Fixes #2137
2018-12-03 17:01:30 -05:00
David Neto
0c172a6b74
Allow Float16/Int8 for Vulkan 1.0 (#2153) 2018-12-03 12:50:12 -05:00
Steven Perron
ae1826154e
Validate uses of ids defined in unreachable blocks. (#2146)
* Validate uses of ids defined in unreachable blocks.

For some reason we do not make sure the uses of ids that are defined
in unreachable blocks are dominated by their def.  This is causing
invalid code to pass the validator.

Fixes #2143

* Add test for unreachable code after a return.

We want to allow code like:

```
void foo() {
  a = ...;
  ...
    return; // for debugging
  <use of a>;
  ...
}
```

I added a test to make sure that something like this is still accepted
by the validator.

* Add test for unreachable def used in phi.
2018-12-03 12:49:27 -05:00
David Neto
3596b3838e
Set expected version number for cpp interface test (#2154) 2018-12-03 12:48:51 -05:00
alan-baker
d80259d35e
Strict validation of where type ids are acceptable (#2142)
Fixes https://crbug.com/910239

* IdPass catches many instances of invalid references to types
* Test updates
* Added test to catch OpArrayLength issue
2018-12-03 11:03:52 -05:00
Ryan Harrison
b9f9a3bc9f
Add WebGPU Execution scope check (#2148)
Fixes #2069
2018-12-03 10:56:55 -05:00
dan sinclair
67b2e1555a
Fixup BUILD.gn from addtion of upgrade_memory_model (#2152) 2018-12-03 09:11:56 -05:00
alan-baker
e510b1bac5
Update memory model (#1904)
Upgrade to VulkanKHR memory model

* Converts Logical GLSL450 memory model to Logical VulkanKHR
* Adds extension and capability
* Removes deprecated decorations and replaces them with appropriate
flags on downstream instructions
* Support for Workgroup upgrades
* Support for copy memory
* Adding support for image functions
* Adding barrier upgrades and tests
* Use QueueFamilyKHR scope instead of device
2018-11-30 14:15:51 -05:00
alan-baker
6af3c5cbe4
Clean uses of EvalInt32IfConst (#2145)
Fixes #2133

* Don't return OpSpecConstant* as constants in that method
 * cleaned up uses
* added tests to catch shader semantics and scope bugs
2018-11-30 14:00:56 -05:00
Alejandro Lopez
b8e2a9f258 Validate PushConstants annotation and type (#2140)
* Validate PushConstants have Block annotation and are struct or array of structs
* Add passing test and split into universal/vulkan environment tests
2018-11-30 13:12:05 -05:00
Ryan Harrison
625db3890d
Add check for QueueFamilyKHMR memory scope (#2144)
This also fixes a small typo that was causing my test case to fail.

Fixes #2136
2018-11-30 12:52:31 -05:00
Ryan Harrison
2cd040b0d3
Merging two ValidateMemoryScope implementations (#2132)
Fixes #2125
2018-11-29 14:51:17 -05:00
Steven Perron
2d2a512691
Don't inline recursive functions. (#2130)
* Move ProcessFunction* function from pass to the context.

There are a few functions that are used to traverse the call tree.
They currently live in the Pass class, but they have nothing to do with
a pass, and may be needed outside of a pass.  They would be better in
the ir context, or in a specific call tree class if we ever have a need
for it.

* Don't inline recursive functions.

Inlining does not check if a function is recursive or not.  This has
been fine as long as the shader was a Vulkan shader, which forbid
recursive functions.  However, not all shaders are vulkan, so either
we limit inlining to Vulkan shaders or we teach it to look for recursive
functions.

I prefer to keep the passes as general as is reasonable.  The change
does not require much new code in inlining and gives a reason to refactor
some other code.

The changes are to add a member function to the Function class that
checks if that function is recursive or not.

Then this is used in inlining to not inlining a function call if it calls
a recursive function.

* Add id to function analysis

There are a few places that build a map from ids to Function whose
result is that id.  I decided to add an analysis to the context for this
to reduce that code, and simplify some of the functions.

* Add missing file.
2018-11-29 14:24:58 -05:00
Ryan Harrison
8ce3dbabb8
Merge two implementations of ValidateExecutionScope (#2131) 2018-11-29 13:48:42 -05:00
Ryan Harrison
3ee605d7cc
Ensure that only whitelisted extensions are used in WebGPU (#2127)
Fixes #2058
2018-11-28 10:49:05 -05:00
dan sinclair
703305b1a5
Fixup BUILD.gn file (#2129) 2018-11-28 09:17:13 -05:00
dan sinclair
af3dc70a55
[ndk-build] Make SPIRV-Headers location configurable (#2126) 2018-11-28 09:13:38 -05:00
Ryan Harrison
525e36d1cd
Move OpExtInst validation into validate_extensions.cpp (#2124)
Fixes #2123
2018-11-27 17:05:54 -05:00
alan-baker
3d56cddb75
Validate pointer variables (#2111)
Fixes #2104

* Checks the rules for logical addressing and variable pointers
 * Has an out for relaxed logical pointers
* Updated PassFixture to expose validator options
 * enabled relaxed logical pointers for some tests
* New validator tests
2018-11-27 16:47:10 -05:00
Ryan Harrison
4759082bbc
Ensure that imported extended instructions for WebGPU are only "GLSL.std.450" (#2119)
Ensure that imported extended instructions for WebGPU are GLSL.std.450

Fixes #2059
2018-11-27 16:20:01 -05:00
Ryan Harrison
dab634da93
Ensure that function parameter's type is not void (#2118)
Fixes #2094
2018-11-27 09:40:19 -05:00
Ryan Harrison
48d923907b
Restrict capabilities to WebGPU spec (#2113)
Restrict capabilities to WebGPU spec

This covers whitelisting Matrix, Shader, Sampled1D, Image1D,
DerivativeControl, and ImageQuery. These are the allowed capabilities
that don't require an extension. Whitelisting VulkanMemoryModelKHR
will be handled by whitelisting its extension in a seperate patch.

Fixes #2101
2018-11-27 09:39:37 -05:00
alelenv
f989b2dbd7 Add precise check for allowing use of gl_InstanceID for specific vulkan raytracing stages . (#2096)
* Checks that gl_InstanceID is only used in specific execution models
2018-11-27 08:35:29 -05:00
Steven Perron
4e22b60122
Add validation for OpArrayLength. (#2117)
The validation rules for OpArrayLength are not checked by the validator.
This with add them.

Fixes https://crbug.com/907451.
2018-11-26 19:46:08 -05:00
Alastair Donaldson
3b13040cf9 New spirv-reduce reduction pass: operand to dominating id. (#2099)
* Added a reduction pass to replace ids with ids of the same type that dominate them.
* Introduce helper method for querying whether an operand type is an input id.
2018-11-26 17:06:21 -05:00
alan-baker
e799bfb923
Prevent diagnostic memory leak (#2110)
Fixes https://crbug.com/906669

* Don't free diagnostics in spvBinaryParse
* When invoking the parser we wish to ignore the error messages from,
instead create a hijacked context and replace the message consumer with
a null consumer
2018-11-26 16:58:09 -05:00
Steven Perron
72d4e5414b
Change HexFloat to work with gcc8. (#2109)
When we want to set a the value of a HexFloat to inf or nan, we
construct the specific bit pattern in an appropriately sized integer.
That integer is copied to a FloatProxy object through a memcpy.  GCC8
complains about the memcpy because it is overwriting a private member of
the class.

The original solution worked well because the template to the HexFloat
could be anything.  However, we only used some instantiation of FloatProxy,
which has a construction from that takes its uint_type, so I decided to use
that constructor instead of the memcpy.  This puts an extra requirement
on the templace for HexFloat, but it will be fine for us.

Part of #1541.
2018-11-26 15:47:48 -05:00
Michał Janiszewski
d543f7dfed Don't use CMake's own property as variable name (#2112)
```
$ cmake --help-property-list | grep ^VERSION$
VERSION
```
2018-11-26 10:37:30 -05:00
Baldur Karlsson
9e71de132f Add cmake option to turn off SPIRV_TIMER_ENABLED (#2103) 2018-11-23 11:47:37 -05:00
Daniel Koch
3b210d6a63 Add basic support for EXT_fragment_invocation_density (#2100)
Whitelisting the extension in optimizations
* copying what was done for NV_shading_rate
2018-11-23 10:21:19 -05:00
Minmin Gong
095cc6722f Fix the missing pch files in spirv-reduce (#2097) 2018-11-22 18:00:08 -05:00
dan sinclair
78c951b3f6
Add newline at end of file (#2098) 2018-11-22 14:35:40 -05:00
Ryan Harrison
7a3493e887
Make sure that initialized variable have correct storage class (#2092)
Make sure that initialized variable have correct storage class

For WebGPU and Vulkan environments, variables must have the storage
class; Output, Private, or Function, if they have an initializer.

Fixes #2071
2018-11-22 12:52:04 -05:00
Ryan Harrison
981763ec74
Ensure correct Addressing and Memory model set for WebGPU (#2093)
Adding validation that the addressing declared by OpMemoryModel is
Logical and the memory model declared is VulkanKHR. Updating a bunch
of tests that were broken by this.

Fixes #2060
2018-11-21 16:41:59 -05:00
Alastair Donaldson
f3acb955c2 Initial commit for spirv-reduce. (#2056)
Creates a new tool that can be used to reduce failing testcases, similar to creduce.
2018-11-21 14:03:09 -05:00