This is an archive of the discontinued LLVM Phabricator instance.

[DirectX] Add DXIL metadata `dx.shaderModel`
ClosedPublic

Authored by beanz on Sep 22 2022, 12:40 PM.

Details

Summary

This captures the target shader model and pipeline stage into the DXIL
metadata for consumption by the DirectX runtime.

Diff Detail

Event Timeline

beanz created this revision.Sep 22 2022, 12:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 22 2022, 12:40 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
beanz requested review of this revision.Sep 22 2022, 12:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 22 2022, 12:40 PM
python3kgae added inline comments.Sep 22 2022, 3:34 PM
llvm/test/CodeGen/DirectX/Metadata/shaderModel-vs.ll
6

Should we report an error for vs_0_0?

beanz added inline comments.Sep 23 2022, 7:27 AM
llvm/test/CodeGen/DirectX/Metadata/shaderModel-vs.ll
6

Not in the backend. I think we should catch this error in the driver before we start compilation, and in the validator later. The test cases here cover some odd edge cases to ensure the compiler doesn’t crash, but we shouldn’t rely on the backend for producing errors to users unless there are no other alternatives.

python3kgae added inline comments.Sep 26 2022, 11:05 AM
llvm/lib/Target/DirectX/DXILMetadata.cpp
68

Shall we add "dx.version" in the function too since it is just shader model with offset on major.

beanz added inline comments.Sep 27 2022, 11:34 AM
llvm/lib/Target/DirectX/DXILMetadata.cpp
68

Yea, that’s probably fair. There is a possibility the two versions may not always be in sync, but we can cross that when we get there.

beanz added inline comments.Sep 27 2022, 12:02 PM
llvm/lib/Target/DirectX/DXILMetadata.cpp
68

I'd like to have that come in through a separate metadata utility function just for code organization.

python3kgae added inline comments.Sep 27 2022, 12:07 PM
llvm/lib/Target/DirectX/DXILMetadata.cpp
64

assert for invalid shader profile?

beanz updated this revision to Diff 463328.Sep 27 2022, 1:41 PM

Making unset environment unreachable, and removing cooresponding test case.

python3kgae accepted this revision.Sep 28 2022, 5:31 PM
This revision is now accepted and ready to land.Sep 28 2022, 5:31 PM
This revision was landed with ongoing or failed builds.Oct 3 2022, 11:00 AM
This revision was automatically updated to reflect the committed changes.