Commit Graph

3441 Commits

Author SHA1 Message Date
Spencer Fricke
c3f844aec4
spirv-val: Test file suffix consistency (#4925) 2022-09-16 14:05:07 -04:00
Greg Fischer
272e4b3d07
Fix missing and incorrect DebugValues (#4929)
Specificially, fixes DebugValues coming out of
eliminate-local-single-store and eliminate-local-multi-store AKA SSA
rewrite.
2022-09-13 14:41:07 +00:00
Hans-Kristian Arntzen
49deada730
Also consider EmitMeshTasksEXT terminator in spirv-opt. (#4930)
Not sure why this is repeated for validation and optimizer, but ...
2022-09-12 13:24:34 +00:00
Jeremy Hayes
fb27bbf307
Fix DebugInlinedAt Line operand (#4928)
Line instructions may be OpLine or DebugLine. This commit adds support
for DebugLine.
2022-09-09 13:56:35 -04:00
Spencer Fricke
f5b27b6513
spirv-diff: Allow no SpecId (#4904) 2022-09-07 15:14:26 -04:00
Spencer Fricke
59cf5b1346
spirv-val: consider OpEmitMeshTasksEXT a terminator instruction (#4923) 2022-09-07 15:12:07 -04:00
Spencer Fricke
934a059787
spirv-val: Label Builtin Array Test VUIDs (#4921) 2022-09-07 10:29:38 -04:00
Brad Smith
5f45f793ae
Support building on OpenBSD (#4912) 2022-09-02 19:30:09 +00:00
Steven Perron
529955e03d
Improve time to build dominators (#4916)
Changed a couple small parts of the algorithm to reduce time to build
the dominator trees.  There should be no visible changes.

Add a depth first search algorithm that does not run a function on
backedges.  The check if an edge is a back edge is time consuming, and
pointless if the function run on it is a nop.
2022-09-02 16:27:10 +00:00
Samuel Thibault
8eb8509834
build: cmake: Add support for GNU/Hurd (#4895) 2022-09-02 16:24:12 +00:00
Spencer Fricke
4386afb057
spirv-opt: Remove unused fold spec const code (#4906) 2022-09-02 16:24:02 +00:00
Pankaj Mistry
4c456f7da6
Implement tool changes for SPV_EXT_mesh_shader. (#4915)
- Added validation rule to support EXT_mesh_shader from SPIRV 1.4 onwards
2022-09-01 20:36:15 -04:00
jeremyg-lunarg
33113abf45
Instrument: Add OpNames to generated functions and variables (#4873)
Add name annotations to the generated instrumentation code to
make it easier to understand. Example spirv-cross output:

    vec4 _140;
    if (0u < inst_bindless_direct_read_4(0u, 0u, 1u, uint(_19)))
    {
        _140 = texture(textures[nonuniformEXT(_19)], inUV);
    }
    else
    {
        inst_bindless_stream_write_4(50u, 1u, uint(_19), 0u);
        _140 = vec4(0.0);
    }
2022-09-01 18:32:00 +00:00
Greg Fischer
b5d1040b94
Fix ADCE to mark scope and inlined_at of line instructions as live. (#4910) 2022-08-31 18:10:17 -04:00
Steven Perron
d51dc53d2c
Improve algorithm to reorder blocks in a function (#4911)
* Improve algorithm to reorder blocks in a function

In dead branch elimination, blocks can end up in a the wrong order, so
there is code to reorder the blocks in structured order.  The problem is
that the algorithm to do that is very poor.  It involves many searchs in
the function for the correct position to place the block, as well as
moving many block in the vector.

The solution is to write a specialized function in the function class
that will reorder the blocks in structured order.  After computing the
structured order, reordering the block can be done in linear time, with
very little overhead.
2022-08-31 11:06:15 -04:00
Spencer Fricke
fca39d5cb4
spirv-val: Better message for using OpTypeBool in input/output (#4901) 2022-08-29 12:47:16 -04:00
Spencer Fricke
66bdbacc9c
spirv-val: Use lookup table for Decoration string (#4903) 2022-08-29 11:09:20 -04:00
Spencer Fricke
f76431cbaf
spirv-val: Add SPV_KHR_ray_tracing storage class (#4868)
* Added VUID labels
2022-08-29 11:09:06 -04:00
jeremyg-lunarg
a98f05d02f
tests: Make InstrumentPass tests use SinglePassRunAndMatch<> and stateful pattern matching (#4897)
Using SinglePassRunAndMatch<> instead of SinglePassRunAndCheck<>
makes tests more concise and makes it possible to use pattern
matching features.

Using Effcee stateful pattern matching to make it less repetitive
to check for generated functions and global variables.

This approach isn't worth
it for DebugPrintf functions because the generated code will change
depending on how many parameters are passed to every debugPrintfEXT()
call.
2022-08-23 12:28:00 -06:00
Greg Fischer
b41e3e1311
Disable DebugInfoMgr during the entire CompactIds pass (#4905)
This is because the DebugInfo manager requires valid SPIR-V
which is not always true during this pass.

Add comment
2022-08-23 12:01:32 -06:00
Spencer Fricke
3c1a14b2b6
spirv-val: SBT Index for OpExecuteCallableKHR (#4900) 2022-08-18 13:42:25 -04:00
Spencer Fricke
0073a1fa36
spirv-val: Remove ImageWrite Texel todo (#4899) 2022-08-17 11:37:05 -04:00
Greg Fischer
71b2aee6c8
Add structs to eliminate dead input components (#4894)
Will eliminate all trailing members of input struct that are not
referenced.
2022-08-16 11:31:04 -04:00
Nathan Gauër
1728c1d40a
spirv-opt: fix copy-propagate-arrays index opti on structs. (#4891)
* spirv-opt: fix copy-propagate-arrays index opti on structs.

As per SPIR-V spec:
OpAccessChain indices must be OpConstant when indexing into a structure.

This optimization tried to remove load cascade. But in some scenario
failed:

```c
cbuffer MyStruct {
    uint my_field;
};

uint main(uint index) {
    const uint my_array[1] = { my_field };
    return my_array[index]
}
```

This is valid as the struct is indexed with a constant index, and then
the array is indexed using a dynamic index.
The optimization would consider the local array to be useless and
generated a load directly into the struct.

* spirv-opt: prevent creation of unused instructions

Copy-propagate-arrays optimization pass would create unused constants,
even if the optimization not completed.
This was caused by the way we handled OpAccessChain squashing: we
only referenced constants, and had to create them upfront.

Fixes #4887
Signed-off-by: Nathan Gauër <brioche@google.com>
2022-08-16 16:05:47 +02:00
Greg Fischer
9abacb34a5
Fix ADCE to not eliminate top level DebugInfo instructions (#4889)
Specifically, DebugSourceContinued, DebugCompilationUnit, and
DebugEntryPoint. These instructions are top-level instructions
which do not or may not have a user except for the tool and so
should not be eliminated.
2022-08-15 15:23:23 -06:00
Cassandra Beckley
3a8a961cff
Fix array copy propagation (#4890)
Array copy propagation was interpreting OpEntryPoint as a store
2022-08-11 09:59:37 -07:00
Nathan Gauër
afbb52b139 Start SPIRV-Tools v2022.4
Signed-off-by: Nathan Gauër <brioche@google.com>
2022-08-11 16:29:04 +00:00
Nathan Gauër
409e116795 Finalize SPIRV-Tools v2022.3
The previous amend to the CHANGES file mentioned v2022.4. That was a
mistake as v2022.3 was never released.

Signed-off-by: Nathan Gauër <brioche@google.com>
2022-08-11 16:25:53 +00:00
Steven Perron
0a43a84e02
Fix shuffle feeding shuffle with undef literal (#4883)
When folding a vector shuffle with an undef literal, it is possible that the
literal is adjusted so that it will then be interpreted as an index into
the input operands.  This is fixed by special casing that case, and not
adjusting those operands.

Fixes #4859
2022-08-10 09:04:35 -04:00
Nathan Gauër
0ebcdc4d19
Allow spirv-opt print-all to show pretty IDs (#4888)
Disassembler was called with non-default params, loosing FRIENDLY_NAMES.
This commit changes the call options to allow the spirv-opt to show
friendly names instead of raw-ids. Might be more helpful when reading
the SPIRV-opt output.

Fixes #4882

Signed-off-by: Nathan Gauër <brioche@google.com>
2022-08-09 14:10:36 -04:00
Steven Perron
ed3b9c83b1
Local access chain convert: check for negative indexes (#4884)
An access chain instruction interpretes its index operands as signed.
The composite insert and extract instruction interpret their index
operands as unsigned, so it is not possible to represent a negative
number.

This commit adds a check to the local-access-chain-convert pass to check
for a negative number in the access chain and to not do the conversion.

Fixes #4856
2022-08-09 17:33:04 +00:00
Spencer Fricke
f20e8d05f5
spirv-val: Add SPV_KHR_ray_tracing instructions (#4871) 2022-08-08 14:45:04 -04:00
Nathan Gauër
5e61ea2098
Update CHANGES (#4886) 2022-08-08 13:49:17 -04:00
jeremyg-lunarg
b362d2b7d4
spirv-diff: Fix asserts in ComparePreambleInstructions() (#4872)
These asserts are not valid for string literals, which may
contain several words:
  assert(a_operand.words.size() == 1);
  assert(b_operand.words.size() == 1);

It looks like they only make sense for the default case, which
assumes that both operands contain a single word.

Running a debug version of spirv-diff on any shader containing
a string literal will hit the original asserts.
2022-08-04 16:44:15 +00:00
Spencer Fricke
08c542d344
spirv-val: Label VUID 06997 (#4881) 2022-08-03 10:42:13 -04:00
Pankaj Mistry
54cd5e1963
spirv-opt : SPV_NV_bindless_texture related changes (#4870) 2022-07-29 19:28:27 +00:00
alan-baker
b5d0bf285f
Require ColMajor or RowMajor for matrices (#4878)
Fixes #4875

* Require that matrices in laid out structs have RowMajor or ColMajor
  set as per SPIR-V section 2.16.2 (shader validation)
2022-07-29 15:08:48 -04:00
Jamie Madill
a90ccc2405
Remove default copy constructor in header. (#4879)
A recent libc++ roll in Chrome warned of a deprecated copy. We're
still looking if this is a bug in libc++ or a valid warning, but
removing the redundant line is a safe workaround or fix in either
case.

See discussion in https://crrev.com/c/3791771
2022-07-29 18:26:37 +00:00
alan-baker
4773879b68
Update structure layout validation (#4876)
* Uniform block layout rules for matrices should use extended layouts by
  default
2022-07-29 10:16:54 -04:00
David Neto
8dc0030ecb
spirv-as: Avoid overflow when parsing exponents on hex floats (#4874)
* spirv-as: Avoid overflow when parsing exponents on hex floats

When an exponent is so large that it would overflow the int
type in the parser, saturate the exponent.
This allows extremely large exponents, and saturates
to infinity when the exponent is positive, and zero when the exponent
is negative.

Fixes #4721.

* Avoid unexpected narrowing conversions from arithmetic operations

Co-authored-by: Alastair F. Donaldson <alastair.donaldson@imperial.ac.uk>
2022-07-28 09:40:07 -04:00
Spencer Fricke
cc5fca057e
spirv-val: Fix Vulkan memory scope (#4869) 2022-07-26 15:14:21 -04:00
Alastair Donaldson
388ce0ee64
spirv-as: Avoid recursion when skipping whitespace (#4866)
Excessive whitespace can lead to stack overflow during parsing as each
character of skipped whitespace involves a recursive call. An
iterative solution avoids this.

Fixes #4729.
2022-07-26 10:56:04 -04:00
Spencer Fricke
e4cfa190df
spirv-val: Add SPV_KHR_ray_query (#4848) 2022-07-20 10:12:58 -04:00
Pankaj Mistry
60615b8ec6
Implement SPV_NV_bindless_texture related changes (#4847)
* Add validation for SPV_NV_bindless_texture
2022-07-19 14:41:19 -04:00
Spencer Fricke
93ebf698a0
spirv-val: Add OpConvertUToAccelerationStructureKHR (#4838) 2022-07-15 09:55:33 -04:00
Spencer Fricke
e2cf769302
spirv-val: Label VUID 06925 (#4852) 2022-07-13 10:05:52 -04:00
Greg Fischer
faa8d6a653
Revert "Optimize DefUseManager allocations (#4709)" (#4846)
This reverts commit d18d0d92e5.

This is reverted because it causes a 7X slowdown when legalizing
SPIR-V with NonSemantic.Shader.DebugInfo.100 instructions.
This is due to the creation of very large UseLists for several
heavily used operands for this extension combined with the fact
that the original commit changed the performance of Uselists to O(n).
2022-07-12 13:14:47 -06:00
Greg Fischer
69e1deabc1
Fix small bug traversing users in interface_var_sroa (#4850)
Fix code that is traversing def-use user structure at the same time
that it is changing it. This is dicey at best and error prone at worst.
This was uncovered making a change to the id_to_user representation.
2022-07-08 13:11:22 -04:00
Spencer Fricke
bc5c8760af
spirv-val: Add Vulkan decoration interface (#4831) 2022-07-07 13:03:52 -04:00
alan-baker
05de650371
Use structural reachability in CFG checks (#4849)
Fixes https://crbug.com/oss-fuzz48578

* Adds structural reachability to basic blocks
  * calculated in same manner as reachability, but using structural
    successors
* Change structured CFG validation to use structural reachability
  instead of reachability
* Fix some invalid reducer cases
2022-07-06 17:43:32 -04:00