Repository navigation
Conversation
Implement VUID-StandaloneSpirv-XfbBuffer-04693: within the output interface of an entry point, everything decorated with the same XfbBuffer must have the same XfbStride. Only objects that explicitly have both decorations are compared. The universal rule, which is not limited to an entry point, is not checked. Contributes to KhronosGroup#6594
| // decorated with the same XfbBuffer is also decorated with the same XfbStride. | ||
| spv_result_t ValidateXfbStride(ValidationState_t& _, | ||
| const Instruction* entry_point) { | ||
| // Both XfbBuffer and XfbStride require this capability. |
There was a problem hiding this comment.
this should say
// To reason to spend time validating if there is no possible transform feedback
| return SPV_SUCCESS; | ||
| } | ||
|
|
||
| // Checks that, within the output interface of |entry_point|, everything |
There was a problem hiding this comment.
remove this and all other comment that come off as AI generated... if the comment is not telling "why" and "what" it is not a good comment IMO
| // Keyed by member index, with the variable itself as kInvalidMember. Direct | ||
| // duplicate decorations are rejected earlier, but not necessarily those | ||
| // introduced by a decoration group. | ||
| std::map<int, XfbInfo> infos; |
There was a problem hiding this comment.
comment doesn't explain why this needs to be ordered and not used unordered_map
| // duplicate decorations are rejected earlier, but not necessarily those | ||
| // introduced by a decoration group. | ||
| std::map<int, XfbInfo> infos; | ||
| auto collect = [&infos](const Decoration& dec) { |
There was a problem hiding this comment.
do we really need a lambda for something only used twice, or could this just all be rewritten better to handle both block/non-block variables
like this is now doing two loops over _.id_decorations which I feel we do a better job in other functions of similar checks
| // clear how a member that declares just one of the two decorations | ||
| // combines with what it inherits from the block, so don't check those. | ||
| const auto& info = entry.second; | ||
| if (!info.has_buffer || !info.has_stride) continue; |
There was a problem hiding this comment.
if feel like before we get here, we could have returned early or filtered this already
|
|
||
| for (uint32_t i = 3; i < entry_point->operands().size(); ++i) { | ||
| const auto variable = _.FindDef(entry_point->GetOperandAs<uint32_t>(i)); | ||
| if (variable->opcode() != spv::Op::OpVariable || |
There was a problem hiding this comment.
maybe leave a comment that we just assume SPV_KHR_untyped_pointer and TransformFeedback are not supported here currently, since doubt anyone is going to use those two together, but its is a gap in validation so should be documented
Contributes to #6594
Adds the check for
VUID-StandaloneSpirv-XfbBuffer-04693:Problem
spirv-val --target-env vulkan1.xaccepts this interface today:With this change:
Change
For each
OpEntryPoint, in Vulkan environments only, collectXfbBufferandXfbStridefrom theOutputinterface variables and, looking through arrays,from the members of their
Blockstructs. Report the first stride that differsfrom the one already seen for the same buffer.
Only objects that explicitly have both decorations are compared.
Not covered
other from its block. 04697 says "declared or inherited" and 04716 describes
inheriting from a block, but 04693 only says "decorated with", so I left that
case alone.
XfbBufferwithout anXfbStride.Block.decoration group. The existing duplicate check only looks at direct
decorations.
Question
This PR does not implement or change the enforcement of the similar rule in the
universal validation rules (2.16.1), which is not limited to an entry point or
to Vulkan:
I found no existing check for it in
spirv-val. So a module where two entrypoints use the same buffer with different strides, which breaks the universal
rule, is still accepted after this change.
I kept this PR to the VUID. Would you prefer the universal rule as a separate
validation in a follow-up PR?
Testing
ValidateInterfacesTest, three valid and three invalid. Withoutthe source change, the three invalid ones fail and the three valid ones pass.
The invalid arrayed block test also fails if the check does not look through
arrays.
test_val_*executables (69,121 tests) pass with GCC 15.2 on Ubuntu26.04 with
SPIRV_WERROR=ONand no warnings, and with Clang 23 (llvm-mingw)on Windows with
SPIRV_WERROR=OFF.test_opt,test_opt_loopsandtest_spirv_unit_testspassed with Clangonly, on an earlier revision with the same algorithm.
test.