Commit Graph

31 Commits

Author SHA1 Message Date
alan-baker
456cc598af
Validate usage of 8- and 16-bit types with only storage capabilities (#2704)
Fixes #2669

* Check capabilities when validating variables
* validate load and store types
* Constant check
* Don't checks pointers for stores, constants and loads
* Validate composite instructions
* Validate conversions for 8- and 16-bit limited types
* Unified tests and expanded them
* Disallow OpCopyMemory
* new tests and update old tests
2019-07-08 14:10:13 -04:00
alan-baker
2b84d25f10
Fix store to uniform Vulkan check (#2688)
* Wrong operands were used for pointer and array types
* added tests to catch the wierd number corner
2019-06-20 14:22:41 -04:00
alan-baker
400dbde0ba
Disallow stores to UBOs (#2651)
Fixes #2638

* Adds a check that errors out if there is a store to a UBO in the
Vulkan environment
  * tests
* Function to trace pointers
2019-06-17 13:13:07 -04:00
alan-baker
59983a6010 Validate variable initializer type (#2668)
Fixes #249

* The pointed to type of Result Type must match the initializer type
* Had to update some opt tests to be valid
2019-06-15 00:34:18 -04:00
David Neto
63f57d95d6
Support SPIR-V 1.4 (#2550)
* SPIR-V 1.4 headers, add SPV_ENV_UNIVERSAL_1_4

* Support --target-env spv1.4 in help for command line tools

* Support asm/dis of UniformId decoration

* Validate UniformId decoration

* Fix version check on instructions and operands

Also register decorations used with OpDecorateId

* Extension lists can differ between enums that match

Example: SubgroupMaskEq vs SubgroupMaskEqKHR

* Validate scope value for Uniform decoration, for SPIR-V 1.4

* More unioning of exts

* Preserve grammar order within an enum value

* 1.4: Validate OpSelect over composites

* Tools default to 1.4

* Add asm/dis test for OpCopyLogical

* 1.4: asm/dis tests for PtrEqual, PtrNotEqual, PtrDiff

* Basic asm/Dis test for OpCopyMemory

* Test asm/dis OpCopyMemory with 2-memory access

Add asm/dis tests for OpCopyMemorySized

Requires grammar update to add second optional memory access operand
to OpCopyMemory and OpCopyMemorySized

* Validate one or two memory accesses on OpCopyMemory*

* Check av/vis on CopyMemory source and target memory access

This is a proposed rule. See
https://gitlab.khronos.org/spirv/SPIR-V/issues/413

* Validate operation for OpSpecConstantOp

* Validate NonWritable decoration

Also permit NonWritable on members of UBO and SSBO.

* SPIR-V 1.4: NonWrtiable can decorate Function and Private vars

* Update optimizer CLI tests for SPIR-V 1.4

* Testing tools: Give expected SPIR-V version in message

* SPIR-V 1.4 validation for entry point interfaces

* Allow only unique interfaces
* Allow all global variables
* Check that all statically used global variables are listed
* new tests

* Add validation fixture CompileFailure

* Add 1.4 validation for pointer comparisons

* New tests

* Validate with image operands SignExtend, ZeroExtend

Since we don't actually know the image texel format, we can't fully
validate.  We need more context.

But we can make sure we allow the new image operands in known-good
cases.

* Validate OpCopyLogical

* Recursively checks subtypes
* new tests

* Add SPIR-V 1.4 tests for NoSignedWrap, NoUnsignedWrap

* Allow scalar conditions in 1.4 with OpSelect

* Allows scalar conditions with vector operands
* new tests

* Validate uniform id scope as an execution scope

* Validate the values of memory and execution scopes are valid scope
values
* new test

* Remove SPIR-V 1.4 Vulkan 1.0 environment

* SPIR-V 1.4 requires Vulkan 1.1

* FIX: include string for spvLog

* FIX: validate nonwritable

* FIX: test case suite for member decorate string

* FIX: test case for hlsl functionality1

* Validation test fixture: ease debugging

* Use binary version for SPIR-V 1.4 specific features

* Switch checks based on the SPIR-V version from the target environment
to instead use the version from the binary
* Moved header parsing into the ValidationState_t constructor (where
version based features are set)
* Added new versions of tests that assemble a 1.3 binary and validate a
1.4 environment

* Fix test for update to SPIR-V 1.4 headers

* Fix formatting

* Ext inst lookup: Add Vulkan 1.1 env with SPIR-V 1.4

* Update spirv-val help

* Operand version checks should use module version

Use the module version instead of the target environment version.

* Fix comment about two-access form of OpCopyMemory
2019-05-07 12:27:18 -04:00
Alan Baker
9244e6ff62 Reverting commit da5a780ff9 2019-03-18 15:14:41 -04:00
SarahM0
da5a780ff9 Variable pointers cannot be an operand to OpArrayLength 2019-03-18 14:07:36 -04:00
Jeff Bolz
002ef361ca Add validation for SPV_NV_cooperative_matrix (#2404) 2019-02-25 17:43:11 -05:00
Ryan Harrison
b1be6763f6
Add helper for 'is Vulkan or WebGPU' (#2324)
Fixes #2323
2019-01-23 13:07:03 -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
Jeff Bolz
5eab6df648 SPV_EXT_physical_storage_buffer (#2267) 2019-01-07 13:19:24 -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
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
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
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
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
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
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
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
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
b407163ef3
Checks for variable pointers (#1976)
In logical addressing mode, we are not allowed to generate variables
pointers.  There is already a check for OpSelect.  However, OpPhi 
and OpPtrAccessChain are not checked to make sure it does not 
generate an variable pointer.  I've added those checks.

Fixes #1957.
2018-10-16 14:57:55 -04:00
alan-baker
72bac04d73
Memory access checks for vulkan mem model (#1909)
* MakePointerVisibleKHR cannot be used with OpStore
* MakePointerAvailableKHR cannot be used with OpLoad
* MakePointerAvailableKHR and MakePointerVisibleKHR both require
NonPrivatePointerKHR
* NonPrivatePointerKHR is limited to a subset of storage classes
* many tests
2018-10-15 09:30:47 -04:00
alan-baker
ad0232dee5 Unify memory instruction validation style (#1934)
* Rename ValidateMemoryInstructions to MemoryPass
* Changed functions to take pointer to an instruction instead of
reference
2018-09-27 12:34:14 -04:00
Jaebaek Seo
2c2fee7979 Validator: check OpTypeBool inside Blocks (#1405)
OpTypeBool can only be used with non-externally visible shader
Storage Classes: Workgroup, CrossWorkgroup, Private, and Function.
2018-09-10 13:33:13 -04:00
Alan Baker
3a20879f4d Unify validation of OpCopyMemory*
Fixes #1800

* Refactored duplication of code between OpCopyMemory and
OpCopyMemorySized validation
* Fixed some bugs in OpCopyMemorySized validation
* Replaced asserts with checks
* Added new tests
2018-08-07 19:01:58 -04:00
dan sinclair
eda2cfbe12
Cleanup includes. (#1795)
This Cl cleans up the include paths to be relative to the top level
directory. Various include-what-you-use fixes have been added.
2018-08-03 15:06:09 -04:00
dan sinclair
53afb3b77b
Combine ordered_instruction loops in validation. (#1782)
There are several validation passes which loop over all ordered
instructions. This CL combines those into a single loop, calling each
pass as needed.
2018-08-02 10:00:52 -04:00
Alan Baker
d49bedcaa6 Move memory class instructions to new pass
* Refactored the Memory class of instructions in the spec out Id
validation and into a new pass
 * Tests unmodified
 * some minor disassembly changes
 * minor style changes
2018-08-01 16:10:11 -04:00