summaryrefslogtreecommitdiffstats
path: root/examples/ray-tracing/main.cpp
diff options
context:
space:
mode:
authorkaizhangNV <149626564+kaizhangNV@users.noreply.github.com>2024-08-27 11:53:16 -0500
committerGitHub <noreply@github.com>2024-08-27 09:53:16 -0700
commit59c23b96b3649e77f5428c32e47b4401a802c604 (patch)
tree54fe251ddbdbbfd03967f5a12eeed56480184e5c /examples/ray-tracing/main.cpp
parentf0ba756c2f982aac8095ff0928d048fc97548315 (diff)
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: <number>" as the key word.
Diffstat (limited to 'examples/ray-tracing/main.cpp')
-rw-r--r--examples/ray-tracing/main.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/examples/ray-tracing/main.cpp b/examples/ray-tracing/main.cpp
index 2eb0a8481..4ec5070d8 100644
--- a/examples/ray-tracing/main.cpp
+++ b/examples/ray-tracing/main.cpp
@@ -195,6 +195,11 @@ gfx::Result loadShaderProgram(
diagnoseIfNeeded(diagnosticsBlob);
SLANG_RETURN_ON_FAIL(result);
+ if (isTestMode())
+ {
+ printEntrypointHashes(componentTypes.getCount() - 1, 1, linkedProgram);
+ }
+
gfx::IShaderProgram::Desc programDesc = {};
programDesc.slangGlobalScope = linkedProgram;
SLANG_RETURN_ON_FAIL(device->createProgram(programDesc, outProgram));
@@ -288,11 +293,15 @@ void onMouseUp(platform::MouseEventArgs args) { isMouseDown = false; }
Slang::Result initialize()
{
initializeBase("Ray Tracing", 1024, 768);
- gWindow->events.mouseMove = [this](const platform::MouseEventArgs& e) { onMouseMove(e); };
- gWindow->events.mouseUp = [this](const platform::MouseEventArgs& e) { onMouseUp(e); };
- gWindow->events.mouseDown = [this](const platform::MouseEventArgs& e) { onMouseDown(e); };
- gWindow->events.keyDown = [this](const platform::KeyEventArgs& e) { onKeyDown(e); };
- gWindow->events.keyUp = [this](const platform::KeyEventArgs& e) { onKeyUp(e); };
+
+ if (!isTestMode())
+ {
+ gWindow->events.mouseMove = [this](const platform::MouseEventArgs& e) { onMouseMove(e); };
+ gWindow->events.mouseUp = [this](const platform::MouseEventArgs& e) { onMouseUp(e); };
+ gWindow->events.mouseDown = [this](const platform::MouseEventArgs& e) { onMouseDown(e); };
+ gWindow->events.keyDown = [this](const platform::KeyEventArgs& e) { onKeyDown(e); };
+ gWindow->events.keyUp = [this](const platform::KeyEventArgs& e) { onKeyUp(e); };
+ }
IBufferResource::Desc vertexBufferDesc;
vertexBufferDesc.type = IResource::Type::Buffer;
@@ -635,9 +644,13 @@ virtual void renderFrame(int frameBufferIndex) override
presentCommandBuffer->close();
gQueue->executeCommandBuffer(presentCommandBuffer);
}
- // 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();
+ }
}
};