-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* record/replay: Add tests Modify the hello-world example to generate the hash code for the entry point spirv code, so that we can compare it with replaying the example. Add the test script to run the example and compare the hash code with replaying it. * Check nullptr for out Diagnostics We need to check whether the output Diagnostics is a nullptr, because it's allowed. * Fix the double free pointers * Add triangle example as the new test for record-replay Change the example base to add the offline rendering path because we don't want to display anything when we're in the test mode. This change involves introducing a TestBase that will parse the command line option. It will decide whether we are in the test mode. Disable all the swapchain and windows related creation, instead we will only create one single framebuffer for the render target. * Address comments TODO: In the follow up patches, I will add more tests and integrate the test flow into slang-unit-test.
- Loading branch information
1 parent
a3fbd8f
commit b5bb824
Showing
24 changed files
with
384 additions
and
135 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "test-base.h" | ||
|
||
#ifdef _WIN32 | ||
#include <windows.h> | ||
#include <shellapi.h> | ||
#endif | ||
|
||
int TestBase::parseOption(int argc, char** argv) | ||
{ | ||
// We only make the parse in a very loose way for only extracting the test option. | ||
#ifdef _WIN32 | ||
wchar_t** szArglist; | ||
szArglist = CommandLineToArgvW(GetCommandLineW(), &argc); | ||
#endif | ||
|
||
for (int i = 0; i < argc; i++) | ||
{ | ||
#ifdef _WIN32 | ||
if (wcscmp(szArglist[i], L"--test-mode") == 0) | ||
#else | ||
if (strcmp(argv[i], "--test-mode") == 0) | ||
#endif | ||
{ | ||
m_isTestMode = true; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
void TestBase::printEntrypointHashes(int entryPointCount, int targetCount, ComPtr<slang::IComponentType>& composedProgram) | ||
{ | ||
for (int targetIndex = 0; targetIndex < targetCount; targetIndex++) | ||
{ | ||
for (int entryPointIndex = 0; entryPointIndex < entryPointCount; entryPointIndex++) | ||
{ | ||
ComPtr<slang::IBlob> entryPointHashBlob; | ||
composedProgram->getEntryPointHash(entryPointIndex, targetIndex, entryPointHashBlob.writeRef()); | ||
|
||
Slang::StringBuilder strBuilder; | ||
strBuilder << "entrypoint: "<< entryPointIndex << ", target: " << targetIndex << ", hash: "; | ||
|
||
uint8_t* buffer = (uint8_t*)entryPointHashBlob->getBufferPointer(); | ||
for (size_t i = 0; i < entryPointHashBlob->getBufferSize(); i++) | ||
{ | ||
strBuilder<<Slang::StringUtil::makeStringWithFormat("%.2X", buffer[i]); | ||
} | ||
fprintf(stdout, "%s\n", strBuilder.begin()); | ||
} | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include "slang.h" | ||
#include "slang-com-ptr.h" | ||
#include "source/core/slang-string-util.h" | ||
|
||
using Slang::ComPtr; | ||
|
||
class TestBase { | ||
|
||
public: | ||
// Parses command line options. This example only has one option for testing purpose. | ||
int parseOption(int argc, char** argv); | ||
|
||
void printEntrypointHashes(int entryPointCount, int targetCount, ComPtr<slang::IComponentType>& composedProgram); | ||
|
||
bool isTestMode() const { return m_isTestMode; } | ||
|
||
private: | ||
bool m_isTestMode = false; | ||
}; |
This file contains 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 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
Oops, something went wrong.