Skip to content

[SPIRV] Fix decoration attributes on members. - #7137

Merged
Steven Perron (s-perron) merged 1 commit into
microsoft:mainfrom
s-perron:member_offset
Feb 28, 2025
Merged

Steven Perron (s-perron) merged 1 commit into
microsoft:mainfrom
s-perron:member_offset

Conversation

@s-perron

Copy link
Copy Markdown
Collaborator

This commit implements adding the vk::ext_decorate on a field. It also
adds an error in sema if vk::ext_decorate_id or
vk::ext_decorate_string are used on members.

For vk::ext_decorate_id, there is no OpMemberDecorateId instruction,
so we cannot add apply these decorations to members.

For vk::ext_decorate_string, there is only one decoration that uses
OpDecorateString or OpMemberDecorateString, UserSemantic. However, that
decoration could have used OpDecorate or OpMemberDecorate because those
instructions accept string literals. I do not expect any new decorations
to use OpDecorateString or OpMemberDecorateString. I may eventually want
to deprecate vk::ext_decorate_string.

Fixes #4195

This commit implements adding the `vk::ext_decorate` on a field. It also
adds an error in sema if `vk::ext_decorate_id` or
`vk::ext_decorate_string` are used on members.

For `vk::ext_decorate_id`, there is no `OpMemberDecorateId` instruction,
so we cannot add apply these decorations to members.

For `vk::ext_decorate_string`, there is only one decoration that uses
OpDecorateString or OpMemberDecorateString, UserSemantic. However, that
decoration could have used OpDecorate or OpMemberDecorate because those
instructions accept string literals. I do not expect any new decorations
to use OpDecorateString or OpMemberDecorateString. I may eventually want
to deprecate `vk::ext_decorate_string`.

Fixes microsoft#4195
Comment thread tools/clang/lib/SPIRV/EmitVisitor.cpp Resolved
@bob80905

Joshua Batista (bob80905) commented Mar 3, 2025 •

Copy link
Copy Markdown
Collaborator

Steven Perron (@s-perron) Damyan Pepper (@damyanp)
I've encountered an error where tools\clang\test\SemaHLSL\attributes\spv.inline.decorate.member.hlsl only fails when the build env doesn't have spirv enabled. I believe we want all tests to pass whether the build has spirv enabled or not.
Is there a better spot to move this file, or maybe change some lit configs so this test doesn't fail / run without spirv enabled in the build environment?

@s-perron

Copy link
Copy Markdown
Collaborator Author

I'll let Damyan Pepper (@damyanp) decide how to handle this. I just don't want to remove test coverage.

@tex3d

Copy link
Copy Markdown
Contributor

Steven Perron (@s-perron) Damyan Pepper (@damyanp) I've encountered an error where tools\clang\test\SemaHLSL\attributes\spv.inline.decorate.member.hlsl only fails when the build env doesn't have spirv enabled. I believe we want all tests to pass whether the build has spirv enabled or not. Is there a better spot to move this file, or maybe change some lit configs so this test doesn't fail / run without spirv enabled in the build environment?

You should be able to add a line to the test:

// REQUIRES: spirv

@webez

webez commented Mar 26, 2025

Copy link
Copy Markdown

Shouldn't vk::ext_decorate_string support Fields if there exists OpMemberDecorateString? Our code is currently broken because of this change because vk::ext_decorate_string does not support Fields anymore and vk::ext_decorate does not support strings

@s-perron

Copy link
Copy Markdown
Collaborator Author

Shouldn't vk::ext_decorate_string support Fields if there exists OpMemberDecorateString? Our code is currently broken because of this change because vk::ext_decorate_string does not support Fields anymore and vk::ext_decorate does not support strings

Your code was probably not doing what you thought it did. Before this change, the decoration attributes on members were ignored. See https://godbolt.org/z/EMsKMMj1E. Note that there is no OpMemberDecorateString. Please open a new issue with details about what you are trying to do, and why you feel this is a regression.

@s-perron
Steven Perron (s-perron) deleted the member_offset branch May 28, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[SPIR-V] enable [[vk::ext_decorate/_id/_string]] for struct/class fields or function parameter

6 participants