-
Notifications
You must be signed in to change notification settings - Fork 852
[SM6.10][LinAlg][HLK] Small test cleanups #8295
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ceb3e1a
[SM6.10][LinAlg][HLK] Small test cleanups
V-FEXrt da34591
more cleanup
V-FEXrt 71fc55a
format
V-FEXrt c2b19dd
Update tools/clang/unittests/HLSLExec/HlslExecTestUtils.h
V-FEXrt 51ea744
Update tools/clang/unittests/HLSLExec/HlslExecTestUtils.h
V-FEXrt ba0489e
Revert "Update tools/clang/unittests/HLSLExec/HlslExecTestUtils.h"
V-FEXrt 0cbabc4
Add verbose logging to compileShader
V-FEXrt e89391b
format
V-FEXrt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
|
|
||
| #include "HlslExecTestUtils.h" | ||
|
|
||
| #include <climits> | ||
| #include <optional> | ||
| #include <sstream> | ||
| #include <string> | ||
|
|
@@ -52,134 +53,6 @@ static int elemSize(ComponentType CT) { | |
| } | ||
| } | ||
|
|
||
| /// Create a ShaderOp for a compute shader dispatch. | ||
| static std::unique_ptr<st::ShaderOp> | ||
| createComputeOp(const char *Source, const char *Target, const char *RootSig, | ||
| const char *Args = nullptr, UINT DispatchX = 1, | ||
| UINT DispatchY = 1, UINT DispatchZ = 1) { | ||
| auto Op = std::make_unique<st::ShaderOp>(); | ||
| LPCSTR CSName = Op->Strings.insert("CS"); | ||
| Op->Name = CSName; | ||
| Op->CS = CSName; | ||
| Op->RootSignature = Op->Strings.insert(RootSig); | ||
| Op->DispatchX = DispatchX; | ||
| Op->DispatchY = DispatchY; | ||
| Op->DispatchZ = DispatchZ; | ||
| Op->UseWarpDevice = true; | ||
|
|
||
| st::ShaderOpShader Shader = {}; | ||
| Shader.Name = CSName; | ||
| Shader.Target = Op->Strings.insert(Target); | ||
| Shader.EntryPoint = Op->Strings.insert("main"); | ||
| Shader.Text = Op->Strings.insert(Source); | ||
| Shader.Arguments = Args ? Op->Strings.insert(Args) : nullptr; | ||
| Shader.Compiled = FALSE; | ||
| Shader.Callback = FALSE; | ||
| Op->Shaders.push_back(Shader); | ||
|
|
||
| return Op; | ||
| } | ||
|
|
||
| /// Add a UAV buffer resource to a ShaderOp. | ||
| static void addUAVBuffer(st::ShaderOp *Op, const char *Name, UINT64 Width, | ||
| bool ReadBack, const char *Init = "zero") { | ||
| st::ShaderOpResource Res = {}; | ||
| Res.Name = Op->Strings.insert(Name); | ||
| Res.Init = Op->Strings.insert(Init); | ||
| Res.ReadBack = ReadBack ? TRUE : FALSE; | ||
|
|
||
| Res.HeapProperties.Type = D3D12_HEAP_TYPE_DEFAULT; | ||
| Res.HeapFlags = D3D12_HEAP_FLAG_NONE; | ||
| Res.Desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; | ||
| Res.Desc.Width = Width; | ||
| Res.Desc.Height = 1; | ||
| Res.Desc.DepthOrArraySize = 1; | ||
| Res.Desc.MipLevels = 1; | ||
| Res.Desc.SampleDesc.Count = 1; | ||
| Res.Desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; | ||
| Res.Desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; | ||
| Res.InitialResourceState = D3D12_RESOURCE_STATE_COPY_DEST; | ||
| Res.TransitionTo = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; | ||
|
|
||
| Op->Resources.push_back(Res); | ||
| } | ||
|
|
||
| /// Bind a resource to a root UAV parameter by index. | ||
| static void addRootUAV(st::ShaderOp *Op, UINT Index, const char *ResName) { | ||
| st::ShaderOpRootValue RV = {}; | ||
| RV.ResName = Op->Strings.insert(ResName); | ||
| RV.HeapName = nullptr; | ||
| RV.Index = Index; | ||
| Op->RootValues.push_back(RV); | ||
| } | ||
|
|
||
| /// Run a programmatically-built ShaderOp and return the result. | ||
| static std::shared_ptr<st::ShaderOpTestResult> | ||
| runShaderOp(ID3D12Device *Device, dxc::SpecificDllLoader &DxcSupport, | ||
| std::unique_ptr<st::ShaderOp> Op, | ||
| st::ShaderOpTest::TInitCallbackFn InitCallback = nullptr) { | ||
| auto OpSet = std::make_shared<st::ShaderOpSet>(); | ||
| OpSet->ShaderOps.push_back(std::move(Op)); | ||
|
|
||
| return st::RunShaderOpTestAfterParse( | ||
| Device, DxcSupport, nullptr, std::move(InitCallback), std::move(OpSet)); | ||
| } | ||
|
|
||
| /// Compiles an HLSL shader using the DXC API to verify it is well-formed. | ||
| /// Fails the test on compile error. | ||
| static void compileShader(dxc::SpecificDllLoader &DxcSupport, | ||
| const char *Source, const char *Target, | ||
| const std::string &Args) { | ||
| CComPtr<IDxcCompiler3> Compiler; | ||
| VERIFY_SUCCEEDED(DxcSupport.CreateInstance(CLSID_DxcCompiler, &Compiler)); | ||
|
|
||
| CComPtr<IDxcUtils> Utils; | ||
| VERIFY_SUCCEEDED(DxcSupport.CreateInstance(CLSID_DxcUtils, &Utils)); | ||
|
|
||
| CComPtr<IDxcBlobEncoding> SourceBlob; | ||
| VERIFY_SUCCEEDED(Utils->CreateBlobFromPinned( | ||
| Source, static_cast<UINT32>(strlen(Source)), DXC_CP_UTF8, &SourceBlob)); | ||
|
|
||
| // Build wide-string argument list: -T <target> -E main <extra args>. | ||
| std::vector<std::wstring> WArgStorage; | ||
| WArgStorage.push_back(L"-T"); | ||
| WArgStorage.push_back(std::wstring(Target, Target + strlen(Target))); | ||
| WArgStorage.push_back(L"-E"); | ||
| WArgStorage.push_back(L"main"); | ||
|
|
||
| // Tokenize the additional arguments string. | ||
| std::istringstream SS(Args); | ||
| std::string Tok; | ||
| while (SS >> Tok) | ||
| WArgStorage.push_back(std::wstring(Tok.begin(), Tok.end())); | ||
|
|
||
| std::vector<LPCWSTR> WArgPtrs; | ||
| for (const auto &A : WArgStorage) | ||
| WArgPtrs.push_back(A.c_str()); | ||
|
|
||
| DxcBuffer Buf = {}; | ||
| Buf.Ptr = SourceBlob->GetBufferPointer(); | ||
| Buf.Size = SourceBlob->GetBufferSize(); | ||
| Buf.Encoding = DXC_CP_UTF8; | ||
|
|
||
| CComPtr<IDxcResult> Result; | ||
| VERIFY_SUCCEEDED(Compiler->Compile(&Buf, WArgPtrs.data(), | ||
| static_cast<UINT32>(WArgPtrs.size()), | ||
| nullptr, IID_PPV_ARGS(&Result))); | ||
|
|
||
| HRESULT HR; | ||
| VERIFY_SUCCEEDED(Result->GetStatus(&HR)); | ||
|
|
||
| if (FAILED(HR)) { | ||
| CComPtr<IDxcBlobUtf8> Errors; | ||
| Result->GetOutput(DXC_OUT_ERRORS, IID_PPV_ARGS(&Errors), nullptr); | ||
| if (Errors && Errors->GetStringLength() > 0) | ||
| hlsl_test::LogErrorFmt(L"Shader compilation failed:\n%S", | ||
| Errors->GetStringPointer()); | ||
| VERIFY_SUCCEEDED(HR); | ||
| } | ||
| } | ||
|
|
||
| struct MatrixParams { | ||
| ComponentType CompType; | ||
| int M; | ||
|
|
@@ -292,6 +165,9 @@ class DxilConf_SM610_LinAlg { | |
| bool VerboseLogging = false; | ||
| bool Initialized = false; | ||
| std::optional<D3D12SDKSelector> D3D12SDK; | ||
|
|
||
| WEX::TestExecution::SetVerifyOutput VerifyOutput{ | ||
| WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures}; | ||
| }; | ||
|
|
||
| /// Creates the device and setups the test scenario with the following variants | ||
|
|
@@ -322,9 +198,6 @@ bool DxilConf_SM610_LinAlg::createDevice() { | |
| } | ||
|
|
||
| bool DxilConf_SM610_LinAlg::setupClass() { | ||
| WEX::TestExecution::SetVerifyOutput VerifySettings( | ||
| WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures); | ||
|
|
||
|
Comment on lines
-325
to
-327
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we added this to the class above so it shouldn't be needed here |
||
| if (!Initialized) { | ||
| Initialized = true; | ||
| VERIFY_SUCCEEDED( | ||
|
|
@@ -381,7 +254,7 @@ static void runLoadStoreRoundtrip(ID3D12Device *Device, | |
| std::string Args = buildCompilerArgs(Params, ExtraDefs.str().c_str()); | ||
|
|
||
| // Always verify the shader compiles. | ||
| compileShader(DxcSupport, LoadStoreShader, "cs_6_10", Args); | ||
| compileShader(DxcSupport, LoadStoreShader, "cs_6_10", Args, Verbose); | ||
|
|
||
| #ifndef _HLK_CONF | ||
| // Skip GPU execution if no device. | ||
|
|
@@ -504,7 +377,7 @@ static void runSplatStore(ID3D12Device *Device, | |
| std::string Args = buildCompilerArgs(Params, ExtraDefs.str().c_str()); | ||
|
|
||
| // Always verify the shader compiles. | ||
| compileShader(DxcSupport, SplatStoreShader, "cs_6_10", Args); | ||
| compileShader(DxcSupport, SplatStoreShader, "cs_6_10", Args, Verbose); | ||
|
|
||
| #ifndef _HLK_CONF | ||
| // Skip GPU execution if no device. | ||
|
|
@@ -523,6 +396,8 @@ static void runSplatStore(ID3D12Device *Device, | |
| ExpectedFloats.assign(NumElements, FillValue); | ||
| break; | ||
| case ComponentType::I32: | ||
| VERIFY_IS_TRUE(FillValue < static_cast<float>(INT_MAX), | ||
| "FillValue too large to cast to int32_t"); | ||
| ExpectedInts.assign(NumElements, static_cast<int32_t>(FillValue)); | ||
| break; | ||
| default: | ||
|
|
||
Oops, something went wrong.
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.
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.
Note that this bit of code was also edited, not just moved