Skip to content

[SM6.10] Linalg Builtin Diag on Bad Stage#8233

Open
V-FEXrt wants to merge 2 commits intomicrosoft:mainfrom
V-FEXrt:linalg-stage-tests-8229
Open

[SM6.10] Linalg Builtin Diag on Bad Stage#8233
V-FEXrt wants to merge 2 commits intomicrosoft:mainfrom
V-FEXrt:linalg-stage-tests-8229

Conversation

@V-FEXrt
Copy link
Collaborator

@V-FEXrt V-FEXrt commented Mar 6, 2026

Some builtins are only allowed in a limited set of shader stages. Raise a Sema Diag when they are improperly used.

Fixes #8229

Some builtins are only allowed in a limited set of shader stages. Raise
a Sema Diag when they are improperly used.
// REQUIRES: dxil-1-10
// RUN: %dxc -T lib_6_10 %s -verify

// expected-no-diagnostics
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No clue how this was ever passing. The DXIL op is appropiately marked as a restricted one.

Maybe some kind of DCE? Not sure, I need to follow up on what happened here

// REQUIRES: dxil-1-10
// RUN: %dxc -T lib_6_10 %s -verify

// expected-no-diagnostics
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same here.

// expected-error@+3{{builtin unavailable in shader stage 'hull' (requires 'compute', 'mesh' or 'amplification')}}
// expected-error@+2{{builtin unavailable in shader stage 'domain' (requires 'compute', 'mesh' or 'amplification')}}
// expected-error@+1{{builtin unavailable in shader stage 'geometry' (requires 'compute', 'mesh' or 'amplification')}}
DO_FUNC
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DO_FUNC macro is a weird choice here.

I tried to both expected-error@* and expected-error@? where internal chat history implies the second should have worked but both failed.

Unless I can get wildcard working the only other option beyond the macro is to repeat the expected-error code a bunch

}

// Some LinAlg builtins are not available in all shader stages
// Detect those use cases and raise a Diagnositc
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Diagnostic

: Error<"argument must be linear algebra matrix type">;

def err_hlsl_linalg_unsupported_stage : Error<
"builtin unavailable in shader stage '%0' (requires 'compute', 'mesh' or 'amplification')">;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: perhaps change to "linalg builtin unavailable...", or make the diagnostic ID more abstract than hlsl_linalg_unsuppported_stage.

#endif

// The builtins below are allowed in all stages, if they raise an error
// then the test will fall with "saw unexpected diagnostic"
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: fail

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

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Restrict LinAlg builtins by legal stages

3 participants