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 Location Interpolation check #6002

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

spencer-lunarg
Copy link
Contributor

@spencer-lunarg spencer-lunarg commented Feb 19, 2025

I tried to quick apply https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/7183 but hit some issues (plan to add to KhronosGroup/Vulkan-Guide#292 after we settle on the answers)

I wrote tests, didn't try implementing it until I know what should fail or not

update - this is VU VUID-StandaloneSpirv-Input-10604 now

@spencer-lunarg spencer-lunarg force-pushed the spencer-lunarg-interpolation-cross branch from 92f3f10 to e382fb5 Compare March 7, 2025 20:02
@spencer-lunarg spencer-lunarg marked this pull request as ready for review March 7, 2025 20:02
@spencer-lunarg spencer-lunarg force-pushed the spencer-lunarg-interpolation-cross branch from e382fb5 to dc8cd21 Compare March 7, 2025 20:02
@spencer-lunarg spencer-lunarg force-pushed the spencer-lunarg-interpolation-cross branch from dc8cd21 to 22310bb Compare March 7, 2025 20:03
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0));
}

TEST_F(ValidateInterfacesTest, InterpolationOverlapBlockMixMembers) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have https://gitlab.khronos.org/vulkan/vulkan/-/issues/4200 open

Things like this "might" be invalid, but went more conservative with the validation in this PR because it is new, covering the "real" use case, and can always restrict more in the future (and we have tests already then!)

Copy link
Contributor

@alan-baker alan-baker left a comment

Choose a reason for hiding this comment

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

Needs a test for the following type of case:

OpDecorate %in1 Location 0
OpDecorate %in1 Component 0
OpDecorate %in2 Location 0
OpDecorate %in2 Component 1
OpDecorate %in2 Centroid

I think the code would correctly consider the above invalid, but center interpolation isn't covered here.

dec == spv::Decoration::Sample || dec == spv::Decoration::Centroid;
}

// Need to check Variables (or struct members) with explicit Locaiton decoration
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Need to check Variables (or struct members) with explicit Locaiton decoration
// Need to check Variables (or struct members) with explicit Location decoration

Comment on lines +613 to +616
std::unordered_map<uint32_t, std::vector<spv::Decoration>>
input_interpolation;
std::unordered_map<uint32_t, std::vector<spv::Decoration>>
output_interpolation;
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems unnecessary to have a vector of decorations. Just store the first interpolation decoration found for a location and if another is encountered issue an error immediately.

You may need to add tests for membership to delineate the center vs other interpolations.

location = dec.params()[0];
has_location = true;
} else if (IsInterpolationDecoration(decoration)) {
interpolation_decs.push_back(decoration);
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like it would allow:

OpMemberDecorate %struct 0 Location 0
OpMemberDecorate %struct 0 Sample
OpMemberDecorate %struct 0 Centroid

Is that caught elsewhere? Certainly it should be invalid.

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.

2 participants