This is an archive of the discontinued LLVM Phabricator instance.

[DX] Begin adding support for pipeline state
ClosedPublic

Authored by beanz on Jan 12 2023, 7:04 PM.

Details

Summary

DirectX shader pipeline state validation information is a fairly
complicated to serialize data structure. This patch adds the first bit
of support for reading and writing the runtime info structure which
comes first in the encoded data.

Subsequent patches will flesh out the remaining fields of the data
structure.

There is no official documentation for the format, but the format is
roughly documented in the code comment here:
https://github.com/microsoft/DirectXShaderCompiler/blob/main/include/dxc
/DxilContainer/DxilPipelineStateValidation.h#L731

Diff Detail

Event Timeline

beanz created this revision.Jan 12 2023, 7:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2023, 7:04 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
beanz requested review of this revision.Jan 12 2023, 7:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2023, 7:04 PM

So no resource support in this PR?

beanz added a comment.Jan 12 2023, 9:26 PM

So no resource support in this PR?

This is a fairly large change which adds support for the first bits of the PSV info. I have more changes locally, but to put it all in one change is against the developer policy (see: https://llvm.org/docs/DeveloperPolicy.html#incremental-development).

As I said in the description, subsequent patches will continue to fill out the data structure.

python3kgae added inline comments.Jan 17 2023, 8:56 AM
llvm/include/llvm/BinaryFormat/DXContainer.h
203

Why we need Unused here?
If we need 32bit align, VertexPSVInfo need Unused too.

287

Both swapBytes() and swapBytes(Stage) changed data.
Do we call both of them?

llvm/test/ObjectYAML/DXContainer/PSVv0-amplification.yaml
28

amplification shader needs shader model 6.5

llvm/test/ObjectYAML/DXContainer/PSVv0-mesh.yaml
32

mesh shader needs shader model 6.5

llvm/test/ObjectYAML/DXContainer/PSVv2-domain.yaml
29

Only mesh/compute/amplification shader set NumThreadX/Y/Z.

llvm/test/ObjectYAML/DXContainer/PSVv2-hull.yaml
29

We cannot have NumThreadsX and Signature at the same time.

beanz added inline comments.Jan 17 2023, 9:53 AM
llvm/include/llvm/BinaryFormat/DXContainer.h
287

Yes, proper byte swapping of the union requires knowing the shader stage. The default swapBytes method gets called generically when reading the structures, but the version that needs to know the shader stage has to be called explicitly.

llvm/test/ObjectYAML/DXContainer/PSVv0-mesh.yaml
32

The point of these tests is to verify the testing infrastructure's ability to deconstruct and re-construct the data structures. They do not (and should not) validate the data itself. The testing infrastructure needs to be able to generate invalid data so that we can test for error cases in the tools that do validate.

beanz updated this revision to Diff 489866.Jan 17 2023, 9:53 AM

Adding Unused to VertexPSVInfo

beanz updated this revision to Diff 490902.Jan 20 2023, 9:59 AM

A little bit of code cleanup. While working on the next patch in the series I refactored some of this code and thought I should just bring the refactoring back.

I also discovered a bug encoding data on big endian systems because I missed a stage-specific byte swap call. I've fixed that here too.

python3kgae accepted this revision.Feb 1 2023, 4:35 PM

LGTM.
Will next PR add resource support?

This revision is now accepted and ready to land.Feb 1 2023, 4:35 PM
This revision was landed with ongoing or failed builds.Feb 1 2023, 5:00 PM
This revision was automatically updated to reflect the committed changes.