Commit Graph

279 Commits

Author SHA1 Message Date
alan-baker
9b6ba4d1c5
Allow arrayed storage images for NonWritable decoration (#2358)
Fixes #2354

* Storage image pointer registration allows optional level of arraying
* Added a test
2019-02-06 15:20:19 -05:00
alan-baker
117a1fd11f
Validate variable pointer related function call rules (#2270)
Fixes #2105

* Check storage class validity
* Check memory object declaration validity
2019-02-06 14:10:40 -05:00
Ryan Harrison
846d12afed
Add whitelist for decorations in WebGPU (#2346)
Fixes #2273
2019-01-31 16:25:46 -05:00
Ryan Harrison
2acbf488b8
Add WebGPU specific validation for WorkgroupSize BuiltIn decoration (#2334)
Part of resolving #2276
2019-01-30 17:01:17 -05:00
Ryan Harrison
e2f4622627
Add WebGPU specific validation for multiple BuiltIn decorations (#2333)
Covers NumWorkgroups, LocalInvocationId & GlobalInvocationId

Part of resolving #2276
2019-01-30 17:00:58 -05:00
Ryan Harrison
3d2afb78c2
Add whitelist of allowed BuiltIn decorations for WebGPU (#2337)
Part of resolving #2276
2019-01-30 15:46:02 -05:00
Ryan Harrison
d17fcf8abd
Add WebGPU validation for LocalInvocationIndex BuiltIn decoration (#2335)
Part of resolving #2276
2019-01-30 15:45:31 -05:00
Ryan Harrison
837153ccdd
Add WebGPU specific validation for FragDepth BuiltIn decoration (#2332)
Part of resolving #2276
2019-01-30 15:27:04 -05:00
Ryan Harrison
0c14583f15
Add WebGPU specific validation for FragCoord BuiltIn decoration (#2331)
Part of resolving #2276
2019-01-30 14:53:43 -05:00
Ryan Harrison
b6698e0d83
Add WebGPU specific validation for FrontFacing BuiltIn decoration (#2330)
Part of resolving #2276
2019-01-30 14:48:43 -05:00
Ryan Harrison
734def1447
Add WebGPU specific validation for InstanceIndex BuiltIn decoration (#2329)
Part of resolving #2276
2019-01-30 14:20:55 -05:00
Ryan Harrison
b947ecfe79
Add WebGPU specific validation for VertexIndex BuiltIn decoration (#2328)
Part of resolving #2276
2019-01-30 12:22:30 -05:00
David Neto
7f3679a8b6
Validate NonWritable decoration (#2263)
Also permit NonWritable on members of structs used for UBO and SSBO.
(That seems inadvertently removed in recent revisions of the spec.)
2019-01-28 12:44:13 -08:00
alan-baker
cf011f9901 More layout check fixes (#2315)
* check array strides for multidimensional arrays
* check layouts of structs in arrays for multiple indices
* new tests
2019-01-24 14:24:31 -08:00
Steven Perron
e2279da714
Remove the static maps from CheckDecorationsCompatibility (#2327)
* Remove the static maps from CheckDecorationsCompatibility

There are a few data structures in the function
`CheckDecorationsCompatibility` that are allocated using `new` and their
address is stored in a static pointer.  This code pattern causes the
MSVC memory leak checker to say there is a memory leak.  Some people
are interested in keeping that clean.

To work around it, I have replaced them with either a function or an
array of POD types.  The array can be kept as a static directly because
it has a trivial destructor, and we don't have to worry about it being
destroyed too early.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/2317.
2019-01-24 14:50:58 -05:00
JasperNV
8915a7c8f1 spirv-val: Emit an error when an OpSwitch target is not an OpLabel (#2298)
Fixes #1628.

* spirv-val: Emit an error when an OpBranch target is not an OpLabel
2019-01-24 12:11:49 -05:00
Ryan Harrison
1e3c589a6d
Add WebGPU specific validation for Position BuiltIn decoration (#2309)
This CL adds in the specific checks required for WebGPU, enables
running the builtin checks for WebGPU, and refactors the existing
testing infrastructure to support testing the new checks.

This PR is part of resolving #2276
2019-01-24 12:08:25 -05:00
Ryan Harrison
b1be6763f6
Add helper for 'is Vulkan or WebGPU' (#2324)
Fixes #2323
2019-01-23 13:07:03 -05:00
David Neto
4a405eda53
Fix layout checks for nested struct in relaxed layout; and descriptor arrays (#2312)
* Fixed layout checks for nested structures

Fixes #2303

* Incoming offsets accumulate through nested structures

* Check layouts through arrays

* Perform layout checks in the presence of descriptor arrays (and
runtime arrays)

* Fix formatting
2019-01-22 15:15:24 -08:00
Ryan Harrison
3a3ad2ec50
Add utility to generate a logging string for a given environment (#2314)
Fixes #2313
2019-01-22 15:18:14 -05:00
Steven Perron
eab06d669e
Check forward reference in OpTypeArray. (#2307)
In a recent PR, we allowed a forward reference for the element type in
an array declaration.  However, we do not have other check to make sure
the forward reference is a pointer type first reference in
OpTypeForawrdPointer.  We add that check.

Fixes https://crbug.com/920074.
2019-01-21 12:10:25 -05:00
Ryan Harrison
7577415cc7
Add in WebGPU specific memory scope validation (#2288)
Fixes #2278
2019-01-17 10:39:35 -05:00
Ryan Harrison
b6150e5170
Add WebGPU specific RTA validation rules (#2287)
Fixes #2066
2019-01-17 10:39:12 -05:00
Ryan Harrison
cb27ffdcd8
Ensure that required storage classes have initializer for WebGPU (#2285)
Fixes #2279
2019-01-15 10:24:58 -05:00
Ryan Harrison
9d8534e329
Enforce rules for OpTypeRuntimeArray on Vulkan (#2191)
Fixes #1936
2019-01-14 16:44:44 -05:00
Ryan Harrison
68f2af9f7d
Removing unused const version of id_decorations (#2283)
Fixes #2282
2019-01-14 13:52:50 -05:00
Ryan Harrison
16a0da370b
Ensure that entry point names are unique for WebGPU (#2281)
Fixes #2275
2019-01-14 13:52:28 -05:00
David Neto
6958d11bc2
Validate decorations from SPV_KHR_no_integer_wrap (#2271)
Validates NoSignedWrap, NoUnsignedWrap.

We are permissive by allowing any extended instruction.
2019-01-09 10:36:17 -05:00
David Neto
df5bd2d05a
Permit UConvert spec-constant op for SPV_AMD_gpu_shader_int16 (#2264)
See https://github.com/KhronosGroup/glslang/issues/848
2019-01-08 19:00:18 -05:00
Jeff Bolz
5eab6df648 SPV_EXT_physical_storage_buffer (#2267) 2019-01-07 13:19:24 -05:00
David Neto
a87d3ce48e
Validate operation for OpSpecConstantOp (#2260) 2019-01-03 14:28:00 -05:00
alan-baker
a900bacb58 Broader check for ids that require a type (#2259)
Broader check for ids that require a type

Fixes https://crbug.com/911700

* Adds a broader check for when id operands require a type
* updated a few tests
* added a test to catch the original issue
2019-01-03 13:55:43 -05:00
kholtnv
980ae1d1cd Added NVIDIA ray tracing storage classes in ValidateVariable. (#2254)
* Added additional changes for the new AccelerationStructureNV type.

* Added NVIDIA ray tracing storage classes for checking in ValidateVariable.

* For NVIDIA ray tracing storage classes added test to load bool type (allowed) in new storage class.
2018-12-27 15:08:11 -05:00
Ryan Harrison
7f57887e05
Remove check for SpvCapabilityAtomicStorage (#2243)
Per conversation on
https://github.com/KhronosGroup/glslang/issues/1618 and other places.
2018-12-18 13:34:30 -05:00
Ryan Harrison
a719fc18a5 Disable checking that AtomicStorage capability is present (#2193)
There is inconsistencies between the different specs about whether or
not this capability is required/allowed, so tooling like glslang
currently ignores it. Once this is resolved the check and test can be
re-enabled.
2018-12-11 14:19:44 -05:00
Alejandro Lopez
de797ddcb5 Check that certain decorations cannot be used more than once and/or are mutually exclusive (#2171)
Fixes #1636

* Add a hash functor for decoration types for c++11 compliance
* Change non-POD static variables and add test for Block+BufferBlock
2018-12-07 12:46:27 -05:00
Ryan Harrison
7c38fee64a
Restrict mask bits for memory semantics in WebGPU (#2180)
Fail to validate memory semantics value if it includes set bits that
are not on the whitelist from the spec.

Fixes #2070
2018-12-07 10:38:52 -05:00
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
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
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
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