Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spirv-val: Add Vulkan Location VUID #4608

Conversation

sfricke-samsung
Copy link
Contributor

Labeled and added tests for

  • VUID-StandaloneSpirv-Location-04915
  • VUID-StandaloneSpirv-Location-04917
  • VUID-StandaloneSpirv-Location-04918
  • VUID-StandaloneSpirv-Location-04919

Added logic to track interface variables to check for

  • VUID-StandaloneSpirv-Location-04916

@sfricke-samsung sfricke-samsung force-pushed the sfricke-samsung-location branch from a62967c to afbea88 Compare November 1, 2021 19:19
@alan-baker
Copy link
Contributor

Something definitely seems wrong with this change. I haven't dug into it completely, but one of the errors being flagged in the glslang test suite is:

error: [VUID-StandaloneSpirv-Location-04916] Location decorations must be used on user-defined variables.
%vec4Out = OpVariable %_ptr_Function_v4float Function

This shouldn't require a Location decoration. Only Input, Output and some ray tracing stages should use location.

@dneto0
Copy link
Collaborator

dneto0 commented Dec 15, 2021

This shouldn't require a Location decoration. Only Input, Output and some ray tracing stages should use location.

Agreed. Those VUIDs should be limited to applying to variables in certain storage classes (Input/Output is what I'm familiar with.) See Khronos-internal Vulkan issue 2737

@dneto0
Copy link
Collaborator

dneto0 commented Dec 15, 2021

SPV_NV_ray_tracing allows / requires Location decorations for variables in certain storage classes.
SPV_KHR_ray_tracing does not allow it; it uses a different mechanism.

@dneto0 dneto0 assigned dneto0 and unassigned alan-baker Dec 16, 2021
Copy link
Collaborator

@dneto0 dneto0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some of this is wrong. I'm reworking this PR now.

for (size_t j = 3; j < inst->operands().size(); ++j) {
const auto id = inst->word(inst->operand(j).offset);
desc.interfaces.push_back(id);
vstate->registerInterfaceVariable(id);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also capturing interface variables in raytracing-related storage classes.

SPV_NV_ray_tracing allows Location decorations on certain storage classes:

Add RayPayloadKHR, IncomingRayPayloadKHR, CallableDataKHR, and IncomingCallableDataKHR to the list of Storage Classes that Location is valid on.

The OpTraceNV instruction references payloads by numeric location. That's the clear motivation for decorating variables there with Location.

There are no Location-related validation rules described in the extension, or that I can find in the Vulkan spec related to the extension.

In SPV_KHR_ray_tracing:

  • the mechanism is changed: the payload is referenced by pointer instead of integer location
  • there are no mentions of variables having Locations.

So I think the validator should only check locations for Input and Output variables.

"of a structure type";
}

if (spvIsVulkanEnv(vstate.context()->target_env)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only check location if the variable is Input or Output.

%v4float = OpTypeVector %float 4
%ptr_v4float = OpTypePointer Output %v4float
%fragCoord = OpVariable %ptr_v4float Output
%non_interface = OpVariable %ptr_v4float Output
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is unused. So it's not part of the interface of any entry point, and so it should not produce an error because it's not in scope of the rules for "user defined variable" shader interface.

%fragCoord = OpVariable %outvar_ptr Output
%block = OpTypeStruct %vec3
%invar_ptr = OpTypePointer Input %block
%non_interface = OpVariable %invar_ptr Input
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, this is not used.

@dneto0
Copy link
Collaborator

dneto0 commented Dec 16, 2021

Replaced by #4664

@dneto0 dneto0 closed this Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants