Skip to content
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

Feature/capture unit test #4898

Merged
merged 5 commits into from
Aug 22, 2024

Conversation

kaizhangNV
Copy link
Contributor

Convert existing examples into tests for capture/replay layer.

  • Add a simply TestBase class to the example base class, which handle the command line input parameter "--test-mode", so we can turn the examples into test mode.
  • In the test mode, we first disable the swapchain and enable offline rendering, because we will run those tests on headless environment. Then we enable printing the hashcode of all the entry point functions to stdout.
  • Since getting hash code is a slang API, it will recored by our recorder. Therefore, it can be replayed by the replayer, and we will also print the hash code the the stdout.
  • The test script will parse the hash code from the stdout, and compare the hash code generated by tests with one generated by replayer.

Fix some bugs in record/replay:

  • remove release() call for those com ptr.
  • don't store the hash code because it's just a blob data not a handle.

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.
We need to check whether the output Diagnostics is a nullptr,
because it's allowed.
@kaizhangNV kaizhangNV marked this pull request as draft August 21, 2024 17:38
@kaizhangNV kaizhangNV requested a review from csyonghe August 21, 2024 17:38
@kaizhangNV kaizhangNV added the pr: non-breaking PRs without breaking changes label Aug 21, 2024
@kaizhangNV kaizhangNV force-pushed the feature/capture-unit-test branch 2 times, most recently from cebe29d to 1f03f3e Compare August 21, 2024 21:30
@kaizhangNV
Copy link
Contributor Author

kaizhangNV commented Aug 21, 2024

The changes in source/slang-record-replay/ directory are just minor bug fix, so feel free to skip it if you are not interested.

@kaizhangNV kaizhangNV marked this pull request as ready for review August 21, 2024 21:34
@kaizhangNV kaizhangNV marked this pull request as draft August 21, 2024 21:34
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.
@kaizhangNV kaizhangNV force-pushed the feature/capture-unit-test branch from 1f03f3e to 9a6afa8 Compare August 21, 2024 21:36
@kaizhangNV kaizhangNV marked this pull request as ready for review August 21, 2024 22:26
examples/example-base/example-base.cpp Outdated Show resolved Hide resolved
examples/example-base/test-base.cpp Outdated Show resolved Hide resolved
test-record-replay.sh Show resolved Hide resolved
@kaizhangNV kaizhangNV merged commit b5bb824 into shader-slang:master Aug 22, 2024
12 checks passed
@kaizhangNV
Copy link
Contributor Author

Finish part of issue #4570.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: non-breaking PRs without breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants