From 59c23b96b3649e77f5428c32e47b4401a802c604 Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Tue, 27 Aug 2024 11:53:16 -0500 Subject: Migrate examples (#4920) * Migrate cpu-hello-world to new slang API Migrate cpu-hello-world to new slang API, and also convert this example as one of the unit test. * Add 'shader-object' to slang-unit-test * Convert ray-tracing example into unit-test Convert ray-tracing example into unit-test * Fix some replay bugs: - Wrong decode type in 'getEntryPointHostCallable'. - Mistakes in computing the output buffer size. - Wrong decode type in array size in specialize() call. - When capture entrypoint, we should increase the reference count for the allocated entrypoint recorder object, because that is allocated by record layer, it should be owned by the layer, user should not be able to free it. - Improve json consumer on the prelude text. * Test verify change: In our test, we add a "callIdx" string at beginning of the hash-code string, as there could be more than one modules in the example, so they could call 'getEntryPointHash' multiple times, in order for the test can identify them, add "callIdx: " as the key word. --- tools/slang-unit-test/unit-test-record-replay.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/slang-unit-test/unit-test-record-replay.cpp b/tools/slang-unit-test/unit-test-record-replay.cpp index 2d5619f71..654fb6823 100644 --- a/tools/slang-unit-test/unit-test-record-replay.cpp +++ b/tools/slang-unit-test/unit-test-record-replay.cpp @@ -37,6 +37,7 @@ static SlangResult createProcess(UnitTestContext* context, const char* processNa struct entryHashInfo { + int64_t callIdx = -1; int64_t targetIndex = -1; int64_t entryPointIndex = -1; String hash; @@ -60,7 +61,7 @@ static SlangResult parseHashes(List const& lines, List& o } StringUtil::split(UnownedStringSlice(line.getBuffer() + skipCharacters), ',', tokens); - if (tokens.getCount() != 3) + if (tokens.getCount() != 4) { return SLANG_FAIL; } @@ -83,7 +84,7 @@ static SlangResult parseHashes(List const& lines, List& o SLANG_RETURN_ON_FAIL(extractToken(tokens[0], ':', subToken)); int64_t outNumer = 0; StringUtil::parseInt64(subToken, outNumer); - hashInfo.entryPointIndex = outNumer; + hashInfo.callIdx = outNumer; } { @@ -91,12 +92,21 @@ static SlangResult parseHashes(List const& lines, List& o SLANG_RETURN_ON_FAIL(extractToken(tokens[1], ':', subToken)); int64_t outNumer = 0; StringUtil::parseInt64(subToken, outNumer); - hashInfo.targetIndex = outNumer; + hashInfo.entryPointIndex = outNumer; } { UnownedStringSlice subToken; SLANG_RETURN_ON_FAIL(extractToken(tokens[2], ':', subToken)); + int64_t outNumer = 0; + StringUtil::parseInt64(subToken, outNumer); + hashInfo.targetIndex = outNumer; + } + + { + UnownedStringSlice subToken; + SLANG_RETURN_ON_FAIL(extractToken(tokens[3], ':', subToken)); + // remove the white space after ":" hashInfo.hash = subToken.begin() + 1; } @@ -406,7 +416,10 @@ error: static SlangResult runTests(UnitTestContext* context) { const char* testBinaryNames[] = { + "cpu-hello-world", "triangle", + "shader-object", + "ray-tracing" }; SlangResult finalRes = SLANG_OK; -- cgit v1.2.3