Commit Graph

412 Commits

Author SHA1 Message Date
sfricke-samsung
650acb575b
spirv-val: Label Layer and ViewportIndex VUIDs (#4013) 2020-11-05 13:04:07 -05:00
Sidney Just
5edb328e81
spirv-val: Allow the ViewportIndex and Layer built-ins on SPIR-V 1.5 (#3986)
* spirv-val: Allow the ViewportIndex and Layer built-ins when their corresponding SPIR-V 1.5 capabilities are present
* Added tests for OpCapability ShaderViewportIndex and OpCapability ShaderLayer
2020-10-28 14:05:06 -04:00
Tobski
ebe0ea09f0
Add SPV_EXT_shader_image_int64 (#3852)
* Add SPV_EXT_shader_image_atomic_int64
* Added 64-bit image tests


Co-authored-by: Arkadiusz Sarwa <arkadiusz.sarwa@amd.com>
2020-10-20 11:55:26 -04:00
Tobski
a1d38174b1
Support SPV_KHR_fragment_shading_rate (#3943) 2020-10-20 08:00:13 -04:00
Alastair Donaldson
6fac705e76
spirv-val: Fix validation of OpPhi instructions (#3919)
Fixes #3918.
2020-10-19 17:36:21 +01:00
dan sinclair
11d5924227
Update val to handle reversed instruction sections. (#3887)
Currently the validator, when checking an instruction is in the correct
section, always advances the current section. This means if we have an
instruction from a previous section we'll end up reporting it as invalid
in a function definition. This error is confusing.

This CL updates the validator to check if the given opcode is from a
previous layout section before advancing the current section. If it is
from a previous layout section an error is emitted.
2020-10-08 13:10:12 -04:00
Maksim Ivanov
446adb05ff
Fix use-after-move in val/validate.cpp (#3848)
Fix a use-after-move (potential) bug found by the
"bugprone-use-after-move" clang-tidy check.

This is part of a Chromium-related effort (see
https://crbug.com/1122844).
2020-09-28 10:49:24 -04:00
sfricke-samsung
937a757f04
spirv-val: Add DeviceIndex (#3812) 2020-09-17 08:27:40 -04:00
sfricke-samsung
5df9300549
spirv-val: Add BaseInstance, BaseVertex, DrawIndex, and ViewIndex (#3782)
* spirv-val: Add BaseInstance and BaseVertex

* spirv-val: Add DrawIndex

* spirv-val: Add ViewIndex
2020-09-14 10:23:44 -04:00
sfricke-samsung
2c60d16a64
spirv-val: Add Vulkan VUID labels to BuiltIn (#3756)
The Vulkan 1.2.152 headers/spec now include Valid Usage IDs (VUID)
for every BuiltIn. This change adds labeling to help aid tracking
the coverage gap in Vulkan targeted validation. This is done with
a script in the Validation Layers that parses the source for VUID
strings, both that there is an implementation and a test for it.

There are 2 main changes:

1. A VUID string is added where applicable. It is wrapped in a function
that at runtimes checks if Vulkan is the target so that other targets
will not be effected as the output error only changes for Vulkan and
the overhead only occurs if there is an error at all.

2. For unit test, a new parameter value was added to allow make sure
that for each VUID there is a matching test. There are cases where the
same unit test checks multiple VUs via the parameter feature of gtest.
For this, I added a custom gMock Matcher to simply loop over a list
of VUID strings
2020-09-02 14:02:13 -04:00
Jaebaek Seo
b8de4f57e9
Allow DebugTypeTemplate for Type operand (#3702)
Some OpenCL.DebugInfo.100 instructions such as DebugGlobalVariable
and DebugLocalVariable have the Type operand. This commit allows them to
use DebugTypeTemplate for the Type operand.
2020-08-16 23:42:59 -04:00
Jaebaek Seo
0d629b903a
Validate more OpenCL.DebugInfo.100 instructions (#3684)
- DebugTypeTemplate
- DebugTypeTemplateParameter
- DebugGlobalVariable
- DebugInlinedAt
- DebugValue
2020-08-12 09:37:32 -04:00
alan-baker
13a65b1aee
Only validation locations for appropriate execution models (#3656)
Fixes #3653

* Only validate locations for fragment, vertex, geometry and
  tessellation shaders
2020-08-11 18:51:49 -04:00
Jaebaek Seo
5fd92a7e0c
OpenCL.DebugInfo.100 DebugTypeArray with variable size (#3549)
The updated OpenCL.DebugInfo.100 spec says that we can use
variable for "Component Count" operand of DebugTypeArray i.e.,
DebugLocalVariable or DebugGlobalVariable. This commit updates spirv-val
based on the spec update.
2020-08-05 17:08:37 -04:00
alan-baker
50300450af
Validator support for non-semantic clspv reflection (#3618)
* Generate ext inst table for reflection
* Change build to use grammar files from SPIRV-Headers instead of
  SPIRV-Tools
* Add enum for clspv reflection extended instruction set
  * count it as non-semantic
* validate clspv reflection extended instruction set
* Remove local extended inst sets
* update headers deps
* Update nbuilds to use grammars from SPIRV-Headers instead of
  local duplicates
2020-07-30 12:08:53 -04:00
dan sinclair
a1ea15c902
Update some language usage. (#3611)
This CL updates various bits of language in line with the guidelines
provided by Android
(https://source.android.com/setup/contribute/respectful-code)
2020-07-29 13:50:58 -04:00
Pierre Moreau
2796840d20
Update OpenCL capabilities validation (#3149)
* spirv-val: Pipes are no longer required for OpenCL 1.2 EP

This was removed from the OpenCL SPIR-V Environment Specification via
https://github.com/KhronosGroup/OpenCL-Docs/pull/56.

* spirv-val: Sort headers according to clang-format

* spirv-val: Groups capability is required since OpenCL 2.0
2020-07-27 13:01:45 -04:00
alan-baker
f3cec93665
Support SPV_KHR_terminate_invocation (#3568)
Covers:
- assembler
- disassembler
- validator
- optimizer

Co-authored-by: David Neto <dneto@google.com>
2020-07-22 11:45:02 -04:00
vkushwaha-nv
e4aebf99fa
Add changes for SPV_EXT_shader_atomic_float (#3562) 2020-07-21 10:31:05 -04:00
alan-baker
717e7877ca
Store location values sparsely (#3488)
Fixes http://crbug.com/1102149

* Switch from boolean vectors to unordered sets for location storage
2020-07-17 12:25:39 -04:00
David Neto
d5766f2801
Permit Simple and GLSL450 memory model in WEBGPU_0 (#3463)
Now that WebGPU ingests WGSL instead of SPIR-V,
there is no need to be so strict about the memory model.

Allow any memory model that is already allowed by Vulkan 1.0,
either directly or via an existing.
2020-07-17 12:23:11 -04:00
alan-baker
7221ccf85e
Fix reachability in the validator (#3541)
Fixes #3529

* Make BasicBlock::reachable() only consider static reachability
* Fix reachability calculation to be independent of block order
* add tests
2020-07-15 21:27:03 -04:00
alan-baker
a1fb255a2a
Validate location assignments (#3308)
* Add validation that input/output locations are assigned correctly
* Account for component assignment
* Account for 4 components per location and track the combined
coordinate
* Account for multiple output indexes
* handle specifically arrayed variables
* Arrayed variables that specify a component get locations determined
per index of the array for the sub type
  * Added tests that check locations and components can be assigned
  to interleave an array's locations and components
* Fix up which interfaces are allowed to be arrayed for various shader
stages based on glslang
2020-06-25 13:22:45 -04:00
Jaebaek Seo
9cb2571a18
spirv-val: allow DebugInfoNone for DebugTypeComposite.Size (#3374) 2020-05-25 10:02:39 -04:00
Ricardo Garcia
4386ef4234
Add validation support for ImageGatherBiasLodAMD (#3363)
ImageGatherBiasLodAMD makes it possible to use the Bias and Lod image
operands with OpImageGather and OpImageSparseGather. This commit makes
sure the validator checks for that capability before reporting errors
and adds a few positive tests.
2020-05-25 09:41:34 -04:00
Anastasia Stulova
b0264b87ff
Fix validation failure on OpDecorationGroup (#3365) 2020-05-21 13:15:41 -04:00
Jeff Bolz
d2b4862194
Validate ShaderCallKHR memory scope (#3332) 2020-05-05 13:08:28 -04:00
alan-baker
2a2bdbd5d7
Remove implicit fallthrough (#3298)
Fixes #3296

* Make OpReturn its own case fully
2020-04-14 12:57:48 -04:00
Caio Marcelo de Oliveira Filho
c37c94929b
Validate Buffer and BufferBlock apply only to struct types (#3259) 2020-03-31 10:06:29 -04:00
alan-baker
1346dd5de1
Disallow phis of images, samplers and sampled images (#3246)
* Disallow phis of sampled images always
* Disallow phis of samplers and images for shaders
* Add tests
* Gate check to only occur post-legalization
2020-03-23 16:59:37 -04:00
Daniel Koch
5a97e3a391
Add support for KHR_ray_{query,tracing} extensions (#3235)
Update validator for SPV_KHR_ray_tracing.

* Added handling for new enum types
* Add SpvScopeShaderCallKHR as a valid scope
* update spirv-headers

Co-authored-by: alelenv <alele@nvidia.com>
Co-authored-by: Torosdagli <ntorosda@amd.com>
Co-authored-by: Tobias Hector <tobias.hector@amd.com>
Co-authored-by: Steven Perron <stevenperron@google.com>
2020-03-17 15:30:19 -04:00
Jeff Bolz
dd3d91691f
Allow sampledimage types as operand of OpCopyObject (#3222) 2020-03-09 15:03:39 -04:00
Ryan Harrison
661e79eec8
Adding WebGPU specific Workgroup scope rule (#3204)
Fixes #3075
2020-02-28 16:42:49 -05:00
Jaebaek Seo
70f888131e
Add validation rules for OpenCL.DebugInfo.100 extension (#3133)
Add validation rules for DebugCompilationUnit, DebugSource,
DebugTypeBasic, DebugTypeVector, DebugTypeArray, DebugTypedef,
DebugTypeFunction, DebugTypeEnum, DebugTypeComposite,
DebugTypeMember, DebugTypeInheritance, DebugFunction,
DebugFunctionDeclaration, DebugLexicalBlock, DebugScope,
DebugLocalVariable, DebugDeclare, DebugExpression.
2020-02-25 16:47:03 -05:00
Nico Weber
8910ea5f1c
Fix Wrange-loop-analysis warnings in SPIRV-Tools. (#3201) 2020-02-23 18:50:59 -05:00
Samuel Iglesias Gonsálvez
4d912f4e60
spirv-val: Add support for SPV_AMD_shader_image_load_store_lod (#3186)
According to SPV_AMD_shader_image_load_store_lod spec, Lod operand is
valid with OpImageRead, OpImageWrite, or OpImageSparseRead if the
extension is enabled.
2020-02-18 08:23:41 -05:00
alan-baker
6729c4a7ce
Fix structured exit validation (#3141)
Fixes #3139

* If the header of the construct is also a merge block, jump to the
associated header instead of the immediate dominator
  * prevents spurious failures from unrelated constructs
* new tests
2020-01-23 18:04:21 -05:00
Jaebaek Seo
dd37d73c5e Handle conflict between debug info and existing validation rule (#3104)
* Allow OpExtInst for DebugInfo between secion 9 and 10

Fixes #3086

* Handle spirv-opt errors on DebugInfo Ext

* Add IR Loader test

* Fix ir loader bug

* Handle DebugFunction/DebugTypeMember forward reference

* Add test cases (forward reference to function)

* Support old DebugInfo extension

* Validate local debug info out of function
2020-01-23 17:04:30 -05:00
Alan Baker
323a81fc5e Validate Vulkan 1.2 capabilities 2020-01-14 20:06:19 -05:00
David Neto
d46a1b0487 Add basic support for Vulkan 1.2: SPV_ENV_VULKAN_1_2 2020-01-14 20:06:19 -05:00
Kai Burjack
fad92f1e7e Fix typo in validation message (#3122) 2019-12-27 10:47:16 -05:00
David Neto
e70b009b0f
Add support for SPV_KHR_non_semantic_info (#3110)
Add support for SPV_KHR_non_semantic_info

This entails a couple of changes:

- Allowing unknown OpExtInstImport that begin with the prefix `NonSemantic.`
- Allowing OpExtInst that reference any of those sets to contain unknown
  ext inst instruction numbers, and assume the format is always a series of IDs
  as guaranteed by the extension.
- Allowing those OpExtInst to appear in the types/variables/constants section.
- Not stripping OpString in the --strip-debug pass, since it may be referenced
  by these non-semantic OpExtInsts.
- Stripping them instead in the --strip-reflect pass.

* Add adjacency validation of non-semantic OpExtInst

- We validate and test that OpExtInst cannot appear before or between
  OpPhi instructions, or before/between OpFunctionParameter
  instructions.

* Change non-semantic extinst type to single value

* Add helper function spvExtInstIsNonSemantic() which will check if the extinst
  set is non-semantic or not, either the unknown generic value or any future
  recognised non-semantic set.

* Add test of a complex non-semantic extinst

* Use DefUseManager in StripDebugInfoPass to strip some OpStrings

* Any OpString used by a non-semantic instruction cannot be stripped, all others
  can so we search for uses to see if each string can be removed.
* We only do this if the non-semantic debug info extension is enabled, otherwise
  all strings can be trivially removed.

* Silence -Winconsistent-missing-override in protobufs
2019-12-18 18:10:29 -05:00
David Neto
e82a428605
WebGPU: Array size at most max signed int + 1 (#3077)
This makes it easier to clamp indices for robust-buffer-access
behaviour.

See https://github.com/gpuweb/spirv-execution-env/issues/47
2019-12-03 11:55:28 -05:00
alan-baker
b334829a91 Validate nested constructs (#3068)
* Validate that if a construct contains a header and it's merge is
reachable, the construct also contains the merge
* updated block merging to not merge into the continue
* update inlining to mark the original block of a single block loop as
the continue
* updated some tests
* remove dead code
* rename kBlockTypeHeader to kBlockTypeSelection for clarity
2019-11-27 16:45:57 -05:00
Sarah
8312c523ee Permit the debug instructions in WebGPU SPIR-V (#3063)
Add tests
2019-11-26 14:04:57 -05:00
alan-baker
1a18d491f2 Validate array stride does not cause overlap (#3028)
Fixes #3027

* Disallow array stride 0
* Check array stride against element size
* Fix up tests
* Add new tests
2019-11-12 13:36:53 -05:00
alan-baker
528c00c016 Re-enable OpReadClockKHR validation (#3013)
Re-enable OpReadClockKHR validation

Fixes #2952

* Refactor some common scope validation
* Perform correct validation for scope in OpReadClockKHR
  * Scope must be Subgroup or Device
* new tests
2019-11-07 09:51:38 -05:00
alan-baker
2a3cbe7c3f
Check that derivatives operate on 32-bit values (#2983)
* Add a check that derivative functions only operate on scalar or vector
32-bit floating point values
* Added tests to disallow half derivatives
2019-10-18 09:02:25 -04:00
Jakub Kuderski
e3da3143b2
Disallow use of OpCompositeExtract/OpCompositeInsert with no indices (#2980) 2019-10-17 13:53:34 -04:00
alan-baker
2276e59788 Validate that selections are structured (#2962)
* Validate that selections are structured

WIP

* new checks that switch and conditional branch are proceeded by a
selection merge where necessary

* Don't consider unreachable blocks

* Add some tests

* Changed how labels are marked as seen

* Moved check to more appropriate place
* Labels are now marked as seen when there are encountered in a
terminator instead of when the block is checked
* more tests

* more tests

* Method comment

* new test for a bad case
2019-10-11 17:01:30 -04:00