Commit Graph

2576 Commits

Author SHA1 Message Date
Chris Oattes
e803fe6717
Don't convert struct members to half (#5201) 2023-05-08 12:14:42 -04:00
Steven Perron
8993f9f52f
Apply scalar replacement on vars with Pointer decorations (#5208)
We want to be able to apply scalar replacement on variables that have
the AliasPointer and RestrictPointer decorations.

This exposed a bug that needs to be fixed as well.

Scalar replacement sometimes uses the type manager to get the type id for the
variables it is creating. The variable type is a pointer to a pointee
type. Currently, scalar replacement uses the type manager when only if
the pointee type has to be unique in the module. This is done to try to avoid the case where two type hash to the same
value in the type manager, and it returns the wrong one.

However, this check is not the correct check. Pointer types still have to be
unique in the spir-v module. However, two unique pointer types can hash
to the same value if their pointee types are isomorphic. For example,

%s1 = OpTypeStruct %int
%s2 = OpTypeStruct %int
; %p1 and %p2 will hash to the same value even though they are still
; considered "unique".
%p1 = OpTypePointer Function %s1
%p2 = OpTypePointer Function %s2
To fix this, we now use FindPointerToType, and we modified TypeManager::IsUnique to refer to the whether or not a type will hash to a unique value and say that pointers are not unique.

Fixes #5196
2023-05-08 09:39:14 -04:00
Jeremy Gebben
0ce36ad785
instrument: Add set and binding to bindless error records (#5204)
Add set and binding fields to the error records so that it is
easier for users to figure out which descriptor caused an error.
2023-05-01 14:23:30 -04:00
Jeremy Gebben
d4c0abdcad
instrument: Change descriptor state storage format (#5178)
Split per-DescriptorSet state into separate memory blocks
which are accessed via an array of buffer device addresses.
This is being done to make it easier to update state for a
single DescriptorSet without rebuilding the old giant flat
buffer.

The new data format is documented as comments in
include/spirv-tools/instrument.hpp
2023-04-26 14:28:01 -06:00
Steven Perron
25ad5e19f1
Do not define GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE if it is already defined. (#5200) 2023-04-18 15:47:10 -04:00
Ben Clayton
bec566a32b
opt: Fix null deref in OpMatrixTimesVector and OpVectorTimesMatrix (#5199)
When some (not all) of the matrix columns are OpConstantNull
2023-04-18 14:58:12 -04:00
alan-baker
d5f69dba55
Remove dead code (#5195)
* Execution model limitation was never executed and the check actually
  belongs with other opcodes
2023-04-14 10:59:01 -04:00
janharaldfredriksen-arm
6f276e05cc
Add support for SPV_EXT_shader_tile_image (#5188)
* Update DEPS file to pull in header changes for SPV_EXT_shader_tile_image
2023-04-13 16:58:00 -04:00
James Price
1877a7f909
Fix vector OpConstantComposite type validation (#5191)
The constituent types much fully match, not just the opcode.
2023-04-13 12:50:16 -04:00
Corentin Wallez
f449fb4ad9
Add default case for spv::Dim for TileImageEXT (#5194)
Without this the switch statement must be updated at the same time as
the SPIR-V headers, which makes rolls impossible.
2023-04-13 16:10:02 +01:00
Steven Perron
9a4e7a1eb5
Update protobuf to v21.12 (#5189)
* Update protobuf to v21.12

We need to update because the current version was not buliding with gcc 12.2. I
could not move upda to v22.x because there was an odd use of some defines that
were causing failures.

* Disable clang warnings for protobuf headers
2023-04-12 19:37:07 +02:00
Steven Perron
048faf2e53
Remove use of deprecated std::aligned_storage (#5183)
* Remove use of deprecated std::aligned_storage

Fixes #4806.
2023-04-06 17:22:28 +02:00
LDeakin
dd03c1fca4
Fix LICMPass (#5087)
Do not move loads out of the loop unless the memory is readonly.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/5075
2023-04-05 11:48:14 -04:00
Steven Perron
6b72fe20c5
Add missing header guard (#5181)
Fixes #5018
2023-03-29 15:52:47 -04:00
Steven Perron
7ab0a2781a
Remove non-ascii char from comments. (#5182)
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/4851
2023-03-29 15:48:15 -04:00
Steven Perron
a0fcd06f8f
Add Vulkan memory model to allow lists (#5173)
Fixes #5086
2023-03-28 16:57:45 -04:00
Spencer Fricke
d8a8af8e6d
spirv-val: Remove unused includes and code (#5176) 2023-03-28 14:18:19 -04:00
Spencer Fricke
fa69b09cff
spirv-opt: Remove unused includes and code (#5177) 2023-03-28 12:40:30 -04:00
Steven Perron
d24a39a7f0
Do not remove control barrier after spv1.3 (#5174)
The control barrier instruction was allowed in a limiteted set of shader types.
Part of the HLSL legalization, we use to remove the instructions when it was is
a shader in which it was not allowed. As of spv1.3 that restriction is not long
there.

This change modifies replaced invalid opc to no longer remove it.

Fixes #4999.
2023-03-27 11:04:40 -04:00
Jeremy Hayes
b4e0850ef7
Ignore NonSemanticInstructions (#5171)
Fix #5163.

Ignore NonSemanticInstructions in DoDeadOutputStoresElimination and
ComputeLiveness.
2023-03-24 10:46:52 -06:00
Spencer Fricke
8e6563b913
spirv-val: Label new Vulkan VUID 07951 (#5154) 2023-03-18 01:01:50 +00:00
Alan Zhao
9743701ed5
Explicitly #include <utility> in spirv_target_env.cpp (#5159)
spirv_target_env.cpp uses std::pair, which is defined in utility.
Right now, this compiles because utility is provided via transitive
includes in other C++ standard library headers provided by the
implementation. However, these transitive includes are not guaranteed to
exist, and won't exist in certain cases (e.g. compiling against LLVM's
libc++ with modules enabled.)
2023-03-15 13:15:29 +01:00
Nathan Gauër
b029037aaa
Revert changes around CHANGES file. (#5143)
* Revert "build: allow update_build to generate fake version (#5098)"

This reverts commit 7823b8ff4a.

* Revert "build: stop parsing CHANGES file. (#5067)"

This reverts commit fcfc3c580c.
2023-03-09 18:24:20 +01:00
Laura Hermanns
bd83b772c3
Fix operand index out of bounds when folding OpCompositeExtract. (#5107)
GetExtractOperandsForElementOfCompositeConstruct() states "Returns the
empty vector if |result_index| is out-of-bounds", but violates that
contract for non-vector result types.
2023-03-03 15:52:49 +00:00
alan-baker
b955c468b1
Add missing header include (#5124)
* Found during an internal build
2023-02-24 13:21:53 -05:00
alan-baker
5d2bc6f064
Fix removal of dependent non-semantic instructions (#5122)
Fixes #5121

* If the non-semantic info instructions depended on other moved
  instructions the def/use manager would get corrupted.
2023-02-24 01:10:35 +00:00
Dave Airlie
956114df28
opt: fix spirv ABI on Linux again. (#5113)
Breaking the ABI for this API isn't worth it when the fix is so simple.
2023-02-15 20:11:30 +00:00
Kévin Petit
f4343515ad
Remove duplicate lists of constant and type opcodes (#5106)
Adding a new type instruction required making the same change in two
places.

Also remove IsCompileTimeConstantInst that was used in a single place
and replace its use by an expression that better conveys the intent.

Change-Id: I49330b74bd34a35db6369c438c053224805c18e0

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
2023-02-15 20:09:55 +00:00
Nathan Gauër
b84c86f718
libspirv.cpp: adds c++ api for spvBinaryParse (#5109)
This commit adds a C++ wrapper above the current spvBinaryParse
function. I tried to match it 1:1, except for 2 things:
 - std::function<>& are used. No more function pointers, allowing
   context capture.
 - spv_result_t replaced with a boolean, to match other C++ apis.

Callbacks still return a spv_result_t because the underlying implem
relies on that. The convertion from spv_result_t to boolean is only done
at the boundary.

Signed-off-by: Nathan Gauër <brioche@google.com>
2023-02-14 14:08:20 -05:00
Caio Oliveira
0ce2bc4ce0
spirv-val: Conditional Branch without an exit is invalid in loop header (#5069)
* Update fuzz tests to not use invalid combinations of LoopMerge + BranchConditional

New IDs were selected to make clear the transformation being done here, instead
of reordering all IDs in between or refactoring the SPIR-V in the test.

* spirv-val: Conditional Branch without an exit is invalid in loop header

From 2.16.2, for CFG:

    Selections must be structured. That is, an OpSelectionMerge
    instruction is required to precede:

    - an OpSwitch instruction

    - an OpBranchConditional instruction that has different True Label
      and False Label operands where neither are declared merge blocks
      or Continue Targets.
2023-02-06 10:31:47 -05:00
Laura Hermanns
cac9a5a3ee
Fix null pointer in FoldInsertWithConstants. (#5093)
* Fix null pointer in FoldInsertWithConstants.

Struct types are not supported in constant folding yet.

* Added 'Test case 16' to fold_test.

Tests OpCompositeInsert not to be folded on a struct type.
2023-02-03 15:03:15 +00:00
Maciej
fd1e650cfe
Validate decoration of structs with RuntimeArray (#5094)
Contributes to https://github.com/KhronosGroup/glslang/issues/2439

* When OpTypeStruct is used in Vulkan env and its last member
  is a RuntimeArray, check if the struct is decorated with
  Block or BufferBlock, as required by VUID-...-04680.
2023-02-03 08:58:51 -05:00
Jeremy Gebben
5890763734
instrument: Clean up generation code (#5090)
-Make more use of InstructionBuilder instruction helper methods
-Use MakeUnique<>() rather than new
-Add InstrumentPass::GenReadFunctionCall() which optimizes function
calls in a loop with constant arguments and no side effects.

This is a prepatory change for future work on the instrumentation
code which will add more generated functions.
2023-02-03 00:39:09 +00:00
Daniel Story
0994ca45b6
Add C interface for Optimizer (#5030) 2023-02-01 13:58:52 +00:00
alan-baker
b230a7c7d1
Validate operand type before operating on it (#5092)
Fixes https://crbug.com/oss-fuzz/52921

* Validate the data operand of OpBitCount before trying to get its
  dimension
2023-01-31 15:40:22 -05:00
Nathan Gauër
fcfc3c580c
build: stop parsing CHANGES file. (#5067)
The CHANGES file was an alternative source of truth that was trying
to duplicate/replace the git history truth.
This allow us to change the way we handle releases so we don't have to make
sure our CHANGES PR are linked to the tag and tested PR, simplifying the
process.
2023-01-30 13:23:41 -05:00
Steven Perron
5db6c38e65
Revert "spirv-val: Initial SPV_EXT_mesh_shader builtins (#5080)" (#5084)
This reverts commit f0b900ed9a.
2023-01-24 19:51:39 +00:00
Nathan Gauër
7f9184a5b2
kokoro: fix dubious ownership (#5082)
Kokoro clones repos with a different user used to run the build steps,
meaning if some git command must be run at build time, they will fail
because of this dubious ownership issue.
Running some git commands makes only sense with history, so changing
checkout depth so we can run them and get the true result.

This is a known Kororo issue.
Fixing this is required to generate the version file using git history.

Signed-off-by: Nathan Gauër <brioche@google.com>

Signed-off-by: Nathan Gauër <brioche@google.com>
2023-01-23 15:32:39 +00:00
Steven Perron
fe087cd5f0
Revert "kokoro: fix dubious ownership (#5078)" (#5081)
This reverts commit 8fbb53dae4.
2023-01-23 14:36:33 +00:00
Spencer Fricke
f0b900ed9a
spirv-val: Initial SPV_EXT_mesh_shader builtins (#5080) 2023-01-23 14:30:45 +00:00
Nathan Gauër
8fbb53dae4
kokoro: fix dubious ownership (#5078)
Kokoro clones repos with a different user used to run the build steps,
meaning if some git command must be run at build time, they will fail
because of this dubious ownership issue.
Running some git commands makes only sense with history, so changing
checkout depth so we can run them and get the true result.

This is a known Kororo issue.
Fixing this is required to generate the version file using git history.

Signed-off-by: Nathan Gauër <brioche@google.com>
2023-01-23 14:22:40 +00:00
Jeremy Gebben
ba4c9fe534
Instrument: Fix bindless checking for BufferDeviceAddress (#5049)
Avoid using OpConstantNull with types that do not allow it.

Update existing tests for slight changes in code generation.

Add new tests based on the Vulkan Validation layer test case
that exposed this problem.
2023-01-16 20:57:37 +00:00
Juan Ramos
1dad991441
cmake: Modernize install(TARGET) usage (#5056) 2023-01-16 10:55:35 -05:00
alan-baker
7e8813bb4c
Validate version 5 of clspv reflection (#5050)
* Validate version 5 of clspv reflection

* Add validation for instructions in versions 2 through 5
* Change the instruction reported for remaining indices on an access
  chain to the access chain itself for clarity

* update spirv-headers
2023-01-11 16:58:53 -05:00
Caio Oliveira
f62e121b0d
spirv-val: Use more specific term 'switch header' in error message (#5048)
* spirv-val: Add tests for OpSwitch directly breaking/continuing outer loop

These are not valid, tests verify the validator catches the issue.
2023-01-09 18:39:02 -05:00
David Neto
bbdd0fefda
Update minimum required CMake to 3.17.2 (#5041)
* Update minimum required CMake to 3.17.2

- For Wasm build, update to emscripten/emsdk:3.1.28 which has 3.22.1
- Move the docker-compose.yml down to the source/wasm directory.

Fixes: #5040

* Fix working directory for invocation of wasm build
2022-12-21 16:22:17 -05:00
David Neto
2937538210
Fix undef behaviour in hex float parsing (#5025)
When the parser saw more significant hex digits than fit in
the target type, it would compute a nonsensical shift amount, resulting
in undefined behaviour.

Now, drop the excess bits, effectively truncating the significand.

Also guard against overflow of the exponent in the extraordinary (and untested)
case where we see more than, for example, 2**(32-4+1) significant hex digits
for a 32-bit float, or 2**(16-4+1) significant hex digits for a 16-bit
float.

Also guard against overflow of the indexing counting the number of
significant bits.  When that would occur silently drop any further
significant bits.  (Untested)

Avoid hex floats in C++ code. It's a C++17 feature.

Fixes: #4724
2022-12-19 15:46:57 -05:00
Jeremy Gebben
025ea891fa
Optimize allocation of spvtools::opt::Instruction::operands_ (#5024)
Reserve space for the entire operand list rather than adding them
one a time.
2022-12-19 13:08:01 -05:00
Greg Fischer
f64a4b64b7
[spirv-opt] Clone names for new struct in EliminateIODeadComponents (#5016) 2022-12-19 10:20:44 -07:00
alan-baker
5a78d798f7
Fix layout validation (#5015)
* Fix layout validation

Fixes #5010

* Unless scalar block layout is enabled, no member can reside at an
  offset between the end of the previous member that is a struct or
  array and the next multiple of that alignment

* Remove a dead if that was introduced

Co-authored-by: David Neto <dneto@google.com>
2022-12-15 21:38:09 -05:00