Fix concurrent dxilconv pass initialization - #8820
Draft
Damyan Pepper (damyanp) wants to merge 1 commit into
Draft
Fix concurrent dxilconv pass initialization#8820Damyan Pepper (damyanp) wants to merge 1 commit into
Damyan Pepper (damyanp) wants to merge 1 commit into
Conversation
Register all passes used by the DXBC converter during DLL startup. Add fresh-process tests for the pass closure and concurrent conversion. Fixes microsoft#8819 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1147c945-f9cc-4aa3-8f58-e7238e0270ec
Contributor
You can test this locally with the following command:git-clang-format --diff 9a3e225dab9683212c648d2cc2b7f09bbf57cbe8 9aaaa225d99409f9b572ef8a427cda147b09052b -- projects/dxilconv/include/DxilConvPasses/InitializePasses.h projects/dxilconv/unittests/DxilConvPassRegistryTestHelper.cpp projects/dxilconv/lib/DxilConvPasses/DxilCleanup.cpp projects/dxilconv/lib/DxilConvPasses/InitializePasses.cpp projects/dxilconv/tools/dxilconv/dxilconv.cpp projects/dxilconv/unittests/DxilConvTests.cpp tools/opt/opt.cppView the diff from clang-format here.diff --git a/projects/dxilconv/unittests/DxilConvPassRegistryTestHelper.cpp b/projects/dxilconv/unittests/DxilConvPassRegistryTestHelper.cpp
index 482d3a3f..bddd5c99 100644
--- a/projects/dxilconv/unittests/DxilConvPassRegistryTestHelper.cpp
+++ b/projects/dxilconv/unittests/DxilConvPassRegistryTestHelper.cpp
@@ -29,15 +29,9 @@ static int VerifyPassRegistration() {
llvm::PassRegistry *Registry = llvm::PassRegistry::getPassRegistry();
const char *RequiredPasses[] = {
- "dce",
- "mem2reg",
- "assumption-cache-tracker",
- "red",
- "loops",
- "domtree",
- "dxil-cleanup",
- "normalizedxil",
- "scopenested",
+ "dce", "mem2reg", "assumption-cache-tracker",
+ "red", "loops", "domtree",
+ "dxil-cleanup", "normalizedxil", "scopenested",
"scopenestinfo",
};
for (const char *PassName : RequiredPasses) {
@@ -72,9 +66,9 @@ static bool CompileShaders(std::vector<CComPtr<ID3DBlob>> &Shaders) {
std::to_string(Index) + ".0f, position.y, 0.0f, 1.0f); }";
CComPtr<ID3DBlob> Errors;
HRESULT Result =
- D3DCompile(Source.data(), Source.size(), "concurrent-init.hlsl", nullptr,
- nullptr, "main", "ps_5_0", D3DCOMPILE_OPTIMIZATION_LEVEL3, 0,
- &Shaders[Index], &Errors);
+ D3DCompile(Source.data(), Source.size(), "concurrent-init.hlsl",
+ nullptr, nullptr, "main", "ps_5_0",
+ D3DCOMPILE_OPTIMIZATION_LEVEL3, 0, &Shaders[Index], &Errors);
if (FAILED(Result)) {
if (Errors)
std::fwrite(Errors->GetBufferPointer(), 1, Errors->GetBufferSize(),
@@ -125,9 +119,9 @@ static int RunConcurrentConversions() {
for (unsigned Index = 0; Index < WorkerCount; ++Index) {
Workers.emplace_back([&, Index]() {
IDxbcConverter *RawConverter = nullptr;
- HRESULT Result = CreateInstance(
- CLSID_DxbcConverter, __uuidof(IDxbcConverter),
- reinterpret_cast<void **>(&RawConverter));
+ HRESULT Result =
+ CreateInstance(CLSID_DxbcConverter, __uuidof(IDxbcConverter),
+ reinterpret_cast<void **>(&RawConverter));
CComPtr<IDxbcConverter> Converter;
Converter.Attach(RawConverter);
@@ -141,8 +135,8 @@ static int RunConcurrentConversions() {
LPWSTR Diagnostics = nullptr;
Result = Converter->Convert(
Shaders[Index]->GetBufferPointer(),
- static_cast<UINT32>(Shaders[Index]->GetBufferSize()), nullptr, &Dxil,
- &DxilSize, &Diagnostics);
+ static_cast<UINT32>(Shaders[Index]->GetBufferSize()), nullptr,
+ &Dxil, &DxilSize, &Diagnostics);
CoTaskMemFree(Dxil);
CoTaskMemFree(Diagnostics);
}
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Register all passes that dxilconv uses when the DLL starts. This prevents concurrent first conversions from modifying the global pass registry.
Add fresh-process tests that verify pass registration and convert 256 different DXBC shaders at the same time.
Fixes #8819