-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dxcopt: Support full container and restore extra data to module #4845
Conversation
This modifies IDxcOptimizer::RunOptimizier to accept full DxilContainer input. When full container input is used, this also restores subobjects from RDAT or root signature data from RST0 to the DxilModule state. Serialization of these to metadata in module bitcode output still requires hlsl-dxilemit step.
❌ Build DirectXShaderCompiler 1.0.2349 failed (commit 38a54aad92 by @tex3d) |
❌ Build DirectXShaderCompiler 1.0.2351 failed (commit 820b4beff2 by @tex3d) |
❌ Build DirectXShaderCompiler 1.0.2352 failed (commit c1695ea9f7 by @tex3d) |
❌ Build DirectXShaderCompiler 1.0.2353 failed (commit 1a3253b270 by @tex3d) |
❌ Build DirectXShaderCompiler 1.0.2355 failed (commit c66f216376 by @jeffnn) |
❌ Build DirectXShaderCompiler 1.0.2356 failed (commit acf132ae91 by @jeffnn) |
✅ Build DirectXShaderCompiler 1.0.2366 completed (commit facc8071f2 by @jeffnn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed that this fixes the PIX scenario.
✅ Build DirectXShaderCompiler 1.0.2384 completed (commit ac8d443bef by @jeffnn) |
VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcContainerReflection, &pReflection)); | ||
VERIFY_SUCCEEDED(pReflection->Load(pOptimizedContainer)); | ||
UINT32 dxilIndex; | ||
VERIFY_SUCCEEDED(pReflection->FindFirstPartKind(hlsl::DFCC_DXIL, &dxilIndex)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this uses container reflection here, then the lower-level DxilContainer code below? Either one works, but it doesn't seem necessary to use a different method when getting a different part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just because I had lifted the lower-level code from elsewhere prior to deleting the code in the optimizer that serialized the dxil to container.
reinterpret_cast<const char *>(pOptimizedContainer->GetBufferPointer()); | ||
unsigned blobSize = pOptimizedContainer->GetBufferSize(); | ||
const hlsl::DxilContainerHeader *pContainerHeader = | ||
hlsl::IsDxilContainerLike(pBlobContent, blobSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: After IsDxilContainerLike
, you can also use IsValidDxilContainer
to make sure the container is well-formed (though it's unlikely to be badly formed on output from AssembleToContainer
).
Small refactor to separate code that translates between ViewID data format serialized in DxilModule and the PSV0 data format. Added the equivalent functions to go back to DxilModule serialized version from PSV0 used in IDxcOptimizer.
hlsl::DXIL::SubobjectKind subobjectKind = subObject.getKind(); | ||
switch (subobjectKind) { | ||
case hlsl::DXIL::SubobjectKind::StateObjectConfig: | ||
VERIFY_IS_TRUE(0 == strcmp(subObject.getName(), "so_StateObjectConfig")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to use VERIFY_ARE_EQUAL_STR, since that will be more informative if it fails.
✅ Build DirectXShaderCompiler 1.0.2387 completed (commit f6e6a4cd00 by @tex3d) |
Also, make sources const.
// ComputeViewIdState. It could be moved into some common location if this | ||
// ViewID serialization/deserialization code were moved out of here. | ||
static unsigned RoundUpToUINT(unsigned x) { return (x + 31) / 32; } | ||
static unsigned ComputeSeriaizedViewIDStateSizeInUInts( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we going to make ComputeViewIdState call this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, this could live in a common location, but I haven't yet figured out where that should be. Hence the comment on the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do plan to clean this up along with the format inconsistency between module and PSV0 in the near future, so I'd rather clean this up at that point.
VERIFY_ARE_EQUAL(originalRes->GetResDimName(), optimizedRes->GetResDimName()); | ||
VERIFY_ARE_EQUAL(originalRes->GetResIDPrefix(), optimizedRes->GetResIDPrefix()); | ||
VERIFY_ARE_EQUAL_STR(originalRes->GetResBindPrefix(), optimizedRes->GetResBindPrefix()); | ||
VERIFY_ARE_EQUAL_STR(originalRes->GetResIDPrefix(), optimizedRes->GetResIDPrefix()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are just the prefix character decoded from the Class, so comparing GetResBindPrefix
and GetResIDPrefix
are also unnecessary. Basically, if Class was wrong, there would be something very fundamentally wrong with which list the resource is in for the DxilModule. By which I mean we would have much bigger problems, and expect a whole lot of things to break.
❌ Build DirectXShaderCompiler 1.0.2418 failed (commit cf55aba051 by @tex3d) |
✅ Build DirectXShaderCompiler 1.0.2419 completed (commit d03b146981 by @tex3d) |
✅ Build DirectXShaderCompiler 1.0.2421 completed (commit 1d3323d150 by @jeffnn) |
✅ Build DirectXShaderCompiler 1.0.2422 completed (commit 2abb9421de by @jeffnn) |
✅ Build DirectXShaderCompiler 1.0.2425 completed (commit 6c865ae7c6 by @jeffnn) |
✅ Build DirectXShaderCompiler 1.0.2426 completed (commit ccab925f1a by @jeffnn) |
✅ Build DirectXShaderCompiler 1.0.2427 completed (commit 07e18ea352 by @jeffnn) |
✅ Build DirectXShaderCompiler 1.0.2431 completed (commit 2258c9284f by @jeffnn) |
✅ Build DirectXShaderCompiler 1.0.2433 completed (commit e5b460438d by @jeffnn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
PIX is unique in that it needs to deserialize, modify and then reserialize root sigs. The focus of this checkin is adding such modifications to PixPassHelpers.cpp. (This closes a gap in PIX support: PIX can now support shaders that use dxil-defined and attribute-style root signatures.) But this required some work outside of the purely PIX-focused areas. Deserialized root sigs are described by a C-like structure with embedded arrays that are new/delete-ed by routines in DxilRootSignature.cpp. Since modifying these structs requires more new/delete calls, I chose to add a new entry point in DxilRootSignature.cpp to do the bare minimum that PIX needs: extend root params by one descriptor. This approach keeps all those raw new/deletes in one file. I found a leak in DxilRootSignatureSerialzier.cpp, which I fixed. There appear to be no unit tests that exercise this path. I welcome feedback on adding one. There were other leaks in class CVersionedRootSignatureDeserializer, but this class is unused so I deleted it. Oh, and there are bazillions of commits because I was cherry-picking from a recent change (#4845) as it eveolved, since I needed that change and this to test PIX.
…soft#4876) PIX is unique in that it needs to deserialize, modify and then reserialize root sigs. The focus of this checkin is adding such modifications to PixPassHelpers.cpp. (This closes a gap in PIX support: PIX can now support shaders that use dxil-defined and attribute-style root signatures.) But this required some work outside of the purely PIX-focused areas. Deserialized root sigs are described by a C-like structure with embedded arrays that are new/delete-ed by routines in DxilRootSignature.cpp. Since modifying these structs requires more new/delete calls, I chose to add a new entry point in DxilRootSignature.cpp to do the bare minimum that PIX needs: extend root params by one descriptor. This approach keeps all those raw new/deletes in one file. I found a leak in DxilRootSignatureSerialzier.cpp, which I fixed. There appear to be no unit tests that exercise this path. I welcome feedback on adding one. There were other leaks in class CVersionedRootSignatureDeserializer, but this class is unused so I deleted it. Oh, and there are bazillions of commits because I was cherry-picking from a recent change (microsoft#4845) as it eveolved, since I needed that change and this to test PIX. (cherry picked from commit 20bb3d0)
…osoft#4845) This modifies IDxcOptimizer::RunOptimizier to accept full DxilContainer input. When full container input is used, this restores some data that is stripped from the module and placed in various other container parts. Data restored: - Subobjects from RDAT - RootSignature from RTS0 - ViewID and I/O dependency data from PSV0 - Resource names and types/annotations from STAT Serialization of these to metadata in module bitcode output still requires hlsl-dxilemit step. (cherry picked from commit 2c3d965)
Cherry-pick of PIX and HLK changes for the 2212 release Changes for PIX: 20bb3d0 PIX: Modify root sigs in place (plus fix root sig memory leak) (PIX: Modify root sigs in place (plus fix root sig memory leak) #4876) 2c3d965 dxcopt: Support full container and restore extra data to module (dxcopt: Support full container and restore extra data to module #4845) 21cf36a Fix hitgroup metadata argument order HLK Test Updates: ee0994e add barycentrics ordering check onto existing barycentrics test (add barycentrics ordering check onto existing barycentrics test #4635) 6acd11b ConvertFloat32ToFloat16: Use DirectXMath conversion functions (ConvertFloat32ToFloat16: Use DirectXMath conversion functions #4855) e7aac8e Include TestConfig.h only if DEFAULT_TEST_DIR is not defined (Include TestConfig.h only if DEFAULT_TEST_DIR is not already defined #4884) 5decc4a Do not include TestConfig.h for all HLK build (Do not include TestConfig.h for all HLK build #4887)
This modifies IDxcOptimizer::RunOptimizier to accept full DxilContainer input. When full container input is used, this restores some data that is stripped from the module and placed in various other container parts.
Data restored:
Serialization of these to metadata in module bitcode output still requires hlsl-dxilemit step.
Fixes #4874