Commit Graph

1877 Commits

Author SHA1 Message Date
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
Ryan Harrison
fe39a6f342
Add tests coverage for OpTypeVector column count validation (#2087)
Add tests coverage for OpTypeVector column count validation

Fixes #2064
Fixes #2086
2018-11-21 11:13:28 -05:00
Ryan Harrison
3adb7977da
Check forbidden Annotation instructions for WebGPU env (#2090)
Check forbidden Annotation instructions for WebGPU env

From the WebGPU SPIR-V Execution Enviroment spec:
  OpDecorationGroup, OpGroupDecorate, OpGroupMemberDecorate are not
  allowed.

Fixes #2062
2018-11-20 16:40:38 -05:00
Ryan Harrison
11c7a9e067
Validate that debugging instructions are not present for WebGPU (#2089)
Validate that debugging instructions are not present for WebGPU

For WebGPU execution environments, check that all of the debug
instructions have already been stripped before validation.

Fixes #2063
2018-11-20 16:12:28 -05:00
alan-baker
d41ff27f17
Add support for VK_EXT_Transform_feedback capabilities (#2088)
* Added support for Transform Feedback capabilities.
* Fix tests
2018-11-20 12:41:03 -05:00
Hugues Evrard
66f8f645e9 Update build instructions: add effcee, re2 (#2085)
Both effcee and re2 are now required dependencies, add their checkout in build instructions.
2018-11-20 11:10:19 -05:00
Steven Perron
101c113f64 Remove long running cfg limit test.
We had a test that checks that a spirv binary where the depth of the
deepest nested construct is just below the default limit.  This test
would take a long time causing a timeout in some builds.  We are
questioning the value of the test since we already have a test that can
tell us if we are within a custom limit.  We will remove the test.
2018-11-19 21:46:07 -05:00
dan sinclair
15fdcf94d7 Add missing override to ProcessLinesPass 2018-11-19 19:24:48 -05:00
Ryan Harrison
b0c143c8eb
Add tests for matrix type data rule validation (#2082)
Add tests for matrix type data rule validation

This covers the data rules for matrix types specified in the SPIR-V
spec, section 2.16.1, and the WebGPU SPIR-V Execution Environment
spec.

Fixes #2065 
Fixes #2080
2018-11-19 17:04:03 -05:00
alan-baker
f5b4a8eee3
Catch invalid input type to OpConvertUToPtr (#2078)
Fixes https://crbug.com/906426

* Fails validation if the input operand is a type
* Added a test
2018-11-19 15:08:38 -05:00
Ryan Harrison
8cd2a9d187
Validate component literals for OpVectorShuffle in WebGPU environment (#2077)
Validate component literals for OpVectorShuffle in WebGPU environment

Fixes #2072
2018-11-19 14:32:18 -05:00
Alan Baker
d652ed3029 Vulkan memory model: semantics validation
Ban sequentially consistent with VulkanKHR

* Added validation check that SequentiallyConsistent memory semantics
are not used if the memory model is VulkanKHR
 * Added tests
* Fixed a bug in evaluating constant 32-bit integers and updated some
handling to avoid inferring a value from a spec constant default

Remaining memory semantics validation

* Adds checks that OutputMemoryKHR, MakeAvailableKHR and MakeVisibleKHR
are only used if the VulkanMemoryModelKHR capabailty is present
* Added checks that MakeAvailableKHR requires release semantics
* Added checks that MakeVisibleKHR requires acquire semantics
* Added checks that MakeAvailableKHR and MakeVisibleKHR require a
storage class
2018-11-19 11:44:20 -05:00
Alan Baker
cd22b31557 Catch branch condition being a type
Fixes https://crbug.com/903691

* Added a test
2018-11-16 16:40:39 -05:00
David Neto
8e9be303b0 Validator: Support VK_EXT_scalar_block_layout
Adds validator option to specify scalar block layout rules.

Both VK_KHR_relax_block_layout and VK_EXT_scalar_block_layout can be
enabled at the same time.  But scalar block layout is as permissive
as relax block layout.

Also, scalar block layout does not require padding at the end of a
struct.

Add test for scalar layout testing ArrayStride 12 on array of vec3s

Cleanup: The internal getSize method does not need a round-up argument,
so remove it.
2018-11-16 15:55:30 -05:00
alan-baker
28d8d7bc67
Fix min base alignment (#2075)
Fixes #2073

* Added a test
2018-11-16 14:22:42 -05:00
Ryan Harrison
d7cd1203a4 Ensure for OpVariable that result type and storage class operand agree (#2052)
From SPIR-V spec, section 3.32.8 on OpVariable:
  Its Storage Class operand must be the same as the Storage Class
  operand of the result type.

Fixes #941
2018-11-16 11:22:11 -05:00
alan-baker
6a7b164f0c
Add shaderc smoketest configuration (#2057)
* Build scripts to build shaderc against specific SPIRV-Tools
* Kokoro configuration files
2018-11-16 09:14:22 -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
fjhenigman
ab76e332de
Validate uniform variable type in Vulkan (#1949) (#2055)
From the Vulkan 1.1 spec 14.5.2:
  Variables identified with the Uniform storage class are used to access
  transparent buffer backed resources. Such variables must be typed as
  OpTypeStruct, or an array of this type.

Fixes #1949
2018-11-15 13:42:17 -05:00
David Neto
a29a9947ac UniformConstant variables can have RuntimeArray, TypeAccelerationStructureNV 2018-11-14 21:50:09 -05:00
Greg Fischer
d4a10590b7 Fix Instruction::IsFloatingPointFoldingAllowed()
Was looking for decorations based on opcode. Should use result_id.
2018-11-14 15:25:51 -07:00
alan-baker
5c334514d6
Allow InstanceId for NV ray tracing (#2049)
* Allow InstanceId for NV ray tracing

Fixes #2046

* Allows InstanceId in the Vulkan environment if RayTracingNV
capability is specified
2018-11-14 15:03:40 -05:00
Ryan Harrison
a362e60d5a
Validate variable types for UniformConstant storage in Vulkan (#2008) (#2044)
Validate variable types for UniformConstant storage in Vulkan (#2008)

From the Vulkan 1.1 spec 14.5.2:
  Variables identified with the UniformConstant storage class are used
  only as handles to refer to opaque resources. Such variables must be
  typed as OpTypeImage, OpTypeSampler, OpTypeSampledImage, or an array
  of one of these types.

Fixes #2008
2018-11-14 15:00:03 -05:00
Steven Perron
dc9d155d62
Fix folding of volatile store. (#2048)
When looking for the Volatile mask on a store, the instruction folder
accesses an out-of-bounds element.  We fix that up.

Fixes crbug.com/903530.
2018-11-14 13:52:18 -05:00
Steven Perron
a6150a3fe7
Don't assert on void function parameters. (#2047)
The type manager in spirv-opt currently asserts if a function parameter
has type void.  It is not exactly clear from the spec that this is
disallowed, even if it probably will be disallowed.  In either case,
asserts should be used to verify assumptions that will actually make a
difference to the code.  As far as the optimizer is concerned, a void
parameter does not matter.  I don't see the point of the assert.  I'll
just remove it and let the validator decide whether to accept it or not.

No test was added because it is not clear that it is legal, and should
not force us to accept it in the future unless the spec make it clear
that it is legal.

Fixes crbug.com/903088.
2018-11-14 12:43:43 -05:00