@@ -1767,14 +1767,19 @@ spv_result_t CheckFPRoundingModeForShaders(ValidationState_t& vstate,
1767
1767
return SPV_SUCCESS;
1768
1768
}
1769
1769
1770
- // Returns SPV_SUCCESS if validation rules are satisfied for the NonWritable
1770
+ // Returns SPV_SUCCESS if validation rules are satisfied for the NonReadable or
1771
+ // NonWritable
1771
1772
// decoration. Otherwise emits a diagnostic and returns something other than
1772
1773
// SPV_SUCCESS. The |inst| parameter is the object being decorated. This must
1773
1774
// be called after TypePass and AnnotateCheckDecorationsOfBuffers are called.
1774
- spv_result_t CheckNonWritableDecoration (ValidationState_t& vstate,
1775
- const Instruction& inst,
1776
- const Decoration& decoration) {
1775
+ spv_result_t CheckNonReadableWritableDecorations (ValidationState_t& vstate,
1776
+ const Instruction& inst,
1777
+ const Decoration& decoration) {
1777
1778
assert (inst.id () && " Parser ensures the target of the decoration has an ID" );
1779
+ const bool is_non_writable =
1780
+ decoration.dec_type () == spv::Decoration::NonWritable;
1781
+ assert (is_non_writable ||
1782
+ decoration.dec_type () == spv::Decoration::NonReadable);
1778
1783
1779
1784
if (decoration.struct_member_index () == Decoration::kInvalidMember ) {
1780
1785
// The target must be a memory object declaration.
@@ -1786,7 +1791,10 @@ spv_result_t CheckNonWritableDecoration(ValidationState_t& vstate,
1786
1791
opcode != spv::Op::OpFunctionParameter &&
1787
1792
opcode != spv::Op::OpRawAccessChainNV) {
1788
1793
return vstate.diag (SPV_ERROR_INVALID_ID, &inst)
1789
- << " Target of NonWritable decoration must be a memory object "
1794
+ << " Target of "
1795
+ << (is_non_writable ? " NonWritable" : " NonReadable" )
1796
+ << " decoration must be a "
1797
+ " memory object "
1790
1798
" declaration (a variable or a function parameter)" ;
1791
1799
}
1792
1800
const auto var_storage_class =
@@ -1797,20 +1805,27 @@ spv_result_t CheckNonWritableDecoration(ValidationState_t& vstate,
1797
1805
: spv::StorageClass::Max;
1798
1806
if ((var_storage_class == spv::StorageClass::Function ||
1799
1807
var_storage_class == spv::StorageClass::Private) &&
1800
- vstate.features ().nonwritable_var_in_function_or_private ) {
1808
+ vstate.features ().nonwritable_var_in_function_or_private &&
1809
+ is_non_writable) {
1801
1810
// New permitted feature in SPIR-V 1.4.
1802
1811
} else if (var_storage_class == spv::StorageClass::TileAttachmentQCOM) {
1803
1812
} else if (
1804
1813
// It may point to a UBO, SSBO, storage image, or raw access chain.
1805
1814
vstate.IsPointerToUniformBlock (type_id) ||
1806
1815
vstate.IsPointerToStorageBuffer (type_id) ||
1807
1816
vstate.IsPointerToStorageImage (type_id) ||
1817
+ vstate.IsPointerToTensor (type_id) ||
1808
1818
opcode == spv::Op::OpRawAccessChainNV) {
1809
1819
} else {
1810
1820
return vstate.diag (SPV_ERROR_INVALID_ID, &inst)
1811
- << " Target of NonWritable decoration is invalid: must point to a "
1812
- " storage image, uniform block, "
1813
- << (vstate.features ().nonwritable_var_in_function_or_private
1821
+ << " Target of "
1822
+ << (is_non_writable ? " NonWritable" : " NonReadable" )
1823
+ << " decoration is invalid: "
1824
+ " must point to a "
1825
+ " storage image, tensor variable in UniformConstant storage "
1826
+ " class, uniform block, "
1827
+ << (vstate.features ().nonwritable_var_in_function_or_private &&
1828
+ is_non_writable
1814
1829
? " storage buffer, or variable in Private or Function "
1815
1830
" storage class"
1816
1831
: " or storage buffer" );
@@ -2098,8 +2113,10 @@ spv_result_t CheckDecorationsFromDecoration(ValidationState_t& vstate) {
2098
2113
PASS_OR_BAIL (
2099
2114
CheckFPRoundingModeForShaders (vstate, *inst, decoration));
2100
2115
break ;
2116
+ case spv::Decoration::NonReadable:
2101
2117
case spv::Decoration::NonWritable:
2102
- PASS_OR_BAIL (CheckNonWritableDecoration (vstate, *inst, decoration));
2118
+ PASS_OR_BAIL (
2119
+ CheckNonReadableWritableDecorations (vstate, *inst, decoration));
2103
2120
break ;
2104
2121
case spv::Decoration::Uniform:
2105
2122
case spv::Decoration::UniformId:
0 commit comments