Skip to content

[SPIR-V] Follow-up to #8616: exclude entry functions from function-target decoration - #8719

Open
Matthew Moulton (mmoult) wants to merge 13 commits into
microsoft:mainfrom
mmoult:inline2
Open

Matthew Moulton (mmoult) wants to merge 13 commits into
microsoft:mainfrom
mmoult:inline2

Conversation

@mmoult

@mmoult Matthew Moulton (mmoult) commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Patch #8616 made [[vk::ext_decorate]] apply to the OpFunction of any
function, including entry points. This PR applies it only to non-entry
functions. For entry points, [[vk::ext_decorate]] keeps decorating the
interface variables, as before. The attribute handling moves from
getOrRegisterFn to SpirvEmitter::doFunctionDecl, where entry status is known.
[[vk::ext_capability]] and [[vk::ext_extension]] are still registered for
every function, including ray-tracing entries.

After #8616, an entry point with [[vk::ext_decorate]] got an extra
OpDecorate on its source OpFunction. Decorations such as Location are not
valid on an OpFunction, so the output was invalid SPIR-V. The existing
entry-point test did not check for this.

Example:
[[vk::ext_decorate(/* Location */ 30, 23)]]
float4 main() : SV_Target { return 1.0; }
Expected: only OpDecorate %out_var_SV_Target Location 23.
Unwanted: OpDecorate %src_main Location 23.

Tests:

  • spv.intrinsicDecorate.hlsl and the new spv.intrinsicDecorate.entry.hlsl
    use --implicit-check-not "OpDecorate %src_main".
  • The new spv.intrinsicDecorate.entry.raytracing.hlsl covers
    capability/extension on a ray-generation entry.
  • The function error test now puts both unsupported attributes on one
    function.

…nction-target decoration

Resolve some issues raised on the last pull request. Most notably, fix
the interaction between decorations on entry points and decorations on
regular functions. The pre-existing test for entry points was not
specific enough to catch introduced bug. This has been amended.
Copilot AI balanced review requested due to automatic review settings July 30, 2026 19:35
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions

github-actions Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

✅ With the latest revision this PR passed the C/C++ code formatter.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Prevents entry-point inline SPIR-V decorations from incorrectly targeting source OpFunctions.

Changes:

  • Moves ordinary-function attribute handling into SpirvEmitter.
  • Excludes entry functions from function-target decorations.
  • Strengthens entry-point and diagnostic tests; updates release notes.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/clang/lib/SPIRV/SpirvEmitter.cpp Applies attributes based on entry-point status.
tools/clang/lib/SPIRV/DeclResultIdMapper.cpp Removes unconditional function decoration.
tools/clang/test/CodeGenSPIRV/inline-spirv/spv.intrinsicDecorate.hlsl Rejects accidental source-function decoration.
tools/clang/test/CodeGenSPIRV/inline-spirv/spv.intrinsicDecorate.function.error.hlsl Checks both unsupported function attributes.
tools/clang/test/CodeGenSPIRV/inline-spirv/spv.intrinsicDecorate.entry.hlsl Adds focused entry-point coverage.
docs/ReleaseNotes.md Documents function decoration support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/clang/lib/SPIRV/SpirvEmitter.cpp Resolved
Update code comments for accuracy and brevity.
Copilot AI review requested due to automatic review settings July 30, 2026 19:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 30, 2026 20:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

tools/clang/lib/SPIRV/SpirvEmitter.cpp:1651

  • Ray-tracing entries are not covered by processInlineSpirvAttributes: emitEntryFunctionWrapper returns through emitEntryFunctionWrapperForRayTracing at line 15141 before the call at line 15226. Consequently, this new entry-point guard removes the only registration of [[vk::ext_capability]] and [[vk::ext_extension]] for ray-tracing entry functions, so those attributes are silently dropped. Keep decoration excluded, but register capabilities/extensions for ray entries as well.
  if (!isEntry) {
    declIdMapper.decorateWithIntrinsicAttrs(decl, func);
    declIdMapper.registerCapabilitiesAndExtensionsForDecl(decl);
  }

Comment thread docs/ReleaseNotes.md Outdated
Comment on lines +71 to +74
- Functions can now be decorated with inline SPIR-V, and
`[[vk::ext_capability]]`/`[[vk::ext_extension]]` are honored on ordinary
functions
[#8616](https://github.com/microsoft/DirectXShaderCompiler/pull/8616).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This needs to go in the upcoming release section, not the just-release 1.9.2607 one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Apologies for my delay. I believe this is fixed now.

Moved from Version 1.9.2607 to the upcoming preview release.
Copilot AI review requested due to automatic review settings August 4, 2026 22:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (2)

docs/ReleaseNotes.md:49

  • This SPIR-V change is not limited to experimental preview shader models—the implementation and tests cover ordinary ps_6_0/cs_6_0 functions. Placing the note under “Upcoming Preview Release” makes the preceding text incorrectly state that it will not be part of the next non-preview release. Move this SPIR-V section under “Upcoming Release.”
#### SPIR-V

- Functions can now be decorated with inline SPIR-V. `[[vk::ext_capability]]`
  and `[[vk::ext_extension]]` are now honored on ordinary functions
  [#8616](https://github.com/microsoft/DirectXShaderCompiler/pull/8616)
  [#8719](https://github.com/microsoft/DirectXShaderCompiler/pull/8719).

tools/clang/lib/SPIRV/DeclResultIdMapper.cpp:1834

  • The comment groups capabilities and extensions with decorations as attributes “consumed by the stage-variable path,” but that path only consumes vk::ext_decorate; capabilities and extensions are module-level and handled separately. Please distinguish these paths so this guidance does not misdescribe why each attribute is excluded here.
  // applied in SpirvEmitter::doFunctionDecl, which excludes entry points. For
  // an entry point, those attributes are consumed by the stage-variable path
  // (they decorate the entry's interface variables, not its OpFunction), so
  // they must not be applied to the source function here.

Should be under "Upcoming Release" instead of "Upcoming Preview
Release". This is the first bullet under the next release.
Copilot AI review requested due to automatic review settings August 5, 2026 19:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (1)

tools/clang/lib/SPIRV/DeclResultIdMapper.cpp:1834

  • This comment still groups capabilities and extensions with decorations as being consumed by the stage-variable path, but only vk::ext_decorate is handled there; entry-point capabilities/extensions are handled by processInlineSpirvAttributes (as documented in SpirvEmitter.cpp:1642-1645). Please distinguish the two paths to avoid misleading future changes.
  // an entry point, those attributes are consumed by the stage-variable path
  // (they decorate the entry's interface variables, not its OpFunction), so
  // they must not be applied to the source function here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (1)

docs/ReleaseNotes.md:34

  • The release note currently implies that entry functions can be decorated as functions, but this change intentionally excludes entry points and applies their inline decorations to interface variables instead. Scope the feature to ordinary/non-entry functions so users are not promised unsupported entry-function decoration.
- Functions can now be decorated with inline SPIR-V. `[[vk::ext_capability]]`
  and `[[vk::ext_extension]]` are now honored on ordinary functions

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread docs/ReleaseNotes.md Resolved
Copilot AI review requested due to automatic review settings August 22, 2026 03:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Resolve issue for ray-tacing capability/extension.

Update comments to be more precise and succinct.

Apply formatting changes via clang-format.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

docs/ReleaseNotes.md:35

  • CONTRIBUTING.md:139 explicitly says release-note entries should not link to specific pull requests. This still links to the current PR; remove that link (or link a relevant bug instead, if one exists).
  [#8719](https://github.com/microsoft/DirectXShaderCompiler/pull/8719).

Comment thread tools/clang/lib/SPIRV/SpirvEmitter.cpp Resolved
Copilot AI review requested due to automatic review settings August 27, 2026 03:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@dnovillo Diego Novillo (dnovillo) added the spirv Work related to SPIR-V label Sep 11, 2026

@dnovillo Diego Novillo (dnovillo) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The SPIR-V changes LGTM. I agree that the release note changes move too much stuff around.

@github-project-automation github-project-automation Bot moved this from New to In progress in HLSL Roadmap Sep 15, 2026
Copilot AI review requested due to automatic review settings September 15, 2026 23:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The corrected attribute routing is focused and adequately covered by regression tests.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI review requested due to automatic review settings September 15, 2026 23:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation correctly distinguishes entry functions and includes focused regression coverage for affected paths.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@llvm-beanz Chris B (llvm-beanz) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The functional change looks fine, but the comments are way overly verbose and not useful.

Please also update the PR description to ensure it has an accurate explanation of the change, why it is necessary and what issue it fixes.

Apply brevity and update stale.
Copilot AI balanced review requested due to automatic review settings November 7, 2026 16:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the SPIR-V attribute-handling change.

No open issues 🎉

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spirv Work related to SPIR-V

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

5 participants