microsoft / microsoft/DirectXShaderCompiler

[Feature Request] Warn on use of eval intrinsics (`EvaluateAttribute*`, `GetAttributeAtVertex`) outside entry function

Open
#6,478 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Is your feature request related to a problem? Please describe.
Using an attribute evaluation intrinsic (EvaluateAttribute* and GetAttributeAtVertex) outside an entry point is not well-defined in the HLSL language. Sometimes it works for DXIL because of the way we optimize code before lowering to a DXIL operation, and many times it doesn't work. However, it can't be reliably defined or implemented in the current language due to our current calling convention that uses copy-in semantics.

See issue #6220.

Describe the solution you'd like
I suggest we introduce a warning when using these intrinsics outside of the entry function, since that's where the language does not have a well-defined way to support this.

The wording of the warning should indicate that calls to these intrinsics are unsupported outside the entry function, even though they may work in some cases on certain targets.

Defaulting this warning to error would be useful, but might be too disruptive in the short term, so we may need to limit the scope for that, perhaps to SPIR-V and HLSL 202x.

The warning should have a unique group to allow user override.

For the longer term, we will work on a clean language solution, see: https://github.com/microsoft/hlsl-specs/issues/181.

Describe alternatives you've considered
A change to require nointerpolation on intermediate function arguments used for GetAttributeAtVertex has been submitted in PR #6453. However, while this may be used to catch some invalid use cases, it will also block legal use cases, won't help catch a variety of other problematic cases, and won't help with the EvaluateAttribute* intrinsics at all, which have the same problem. It will only be enabled on SPIR-V, so it may be acceptable as a helpful mitigation in SPIR-V for now, but I do not believe it points towards a solution to the general problem.

Additional context
Related issues: #6220, #6382, #6383, #6384, #6225, #3649

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading issue #6220 and the related issues listed in the report to understand the unsupported call patterns for EvaluateAttribute* and GetAttributeAtVertex. Identify the compiler entry points that determine whether a call is inside the entry function; done means emitting a uniquely overridable warning for unsupported uses, with coverage for the stated target and language-version considerations.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.