From b5bb82411cc6101b66283f7d0abca7ceb58aa2f6 Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Thu, 22 Aug 2024 12:18:44 -0500 Subject: Feature/capture unit test (#4898) * 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. --- examples/triangle/main.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'examples/triangle') diff --git a/examples/triangle/main.cpp b/examples/triangle/main.cpp index 93ae1bd2e..88c55c416 100644 --- a/examples/triangle/main.cpp +++ b/examples/triangle/main.cpp @@ -187,6 +187,11 @@ gfx::Result loadShaderProgram( programDesc.slangGlobalScope = linkedProgram; SLANG_RETURN_ON_FAIL(device->createProgram(programDesc, outProgram)); + if (isTestMode()) + { + printEntrypointHashes(entryPointCount, 1, linkedProgram); + } + return SLANG_OK; } @@ -387,9 +392,12 @@ virtual void renderFrame(int frameBufferIndex) override commandBuffer->close(); gQueue->executeCommandBuffer(commandBuffer); - // With that, we are done drawing for one frame, and ready for the next. - // - gSwapchain->present(); + if (!isTestMode()) + { + // With that, we are done drawing for one frame, and ready for the next. + // + gSwapchain->present(); + } } }; -- cgit v1.2.3