summaryrefslogtreecommitdiffstats
path: root/examples/example-base
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/example-base
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/example-base')
-rw-r--r--examples/example-base/example-base.cpp22
-rw-r--r--examples/example-base/test-base.cpp3
-rw-r--r--examples/example-base/test-base.h3
3 files changed, 15 insertions, 13 deletions
diff --git a/examples/example-base/example-base.cpp b/examples/example-base/example-base.cpp
index fb11105f5..344611bed 100644
--- a/examples/example-base/example-base.cpp
+++ b/examples/example-base/example-base.cpp
@@ -34,6 +34,16 @@ Slang::Result WindowedAppBase::initializeBase(
windowWidth = width;
windowHeight = height;
+
+ IFramebufferLayout::TargetLayout renderTargetLayout = {gfx::Format::R8G8B8A8_UNORM, 1};
+ IFramebufferLayout::TargetLayout depthLayout = {gfx::Format::D32_FLOAT, 1};
+ IFramebufferLayout::Desc framebufferLayoutDesc;
+ framebufferLayoutDesc.renderTargetCount = 1;
+ framebufferLayoutDesc.renderTargets = &renderTargetLayout;
+ framebufferLayoutDesc.depthStencil = &depthLayout;
+ SLANG_RETURN_ON_FAIL(
+ gDevice->createFramebufferLayout(framebufferLayoutDesc, gFramebufferLayout.writeRef()));
+
// Do not create swapchain and windows in test mode, because there won't be any display.
if (!isTestMode())
{
@@ -64,17 +74,7 @@ Slang::Result WindowedAppBase::initializeBase(
gSwapchain = gDevice->createSwapchain(swapchainDesc, windowHandle);
createSwapchainFramebuffers();
}
-
- IFramebufferLayout::TargetLayout renderTargetLayout = {gfx::Format::R8G8B8A8_UNORM, 1};
- IFramebufferLayout::TargetLayout depthLayout = {gfx::Format::D32_FLOAT, 1};
- IFramebufferLayout::Desc framebufferLayoutDesc;
- framebufferLayoutDesc.renderTargetCount = 1;
- framebufferLayoutDesc.renderTargets = &renderTargetLayout;
- framebufferLayoutDesc.depthStencil = &depthLayout;
- SLANG_RETURN_ON_FAIL(
- gDevice->createFramebufferLayout(framebufferLayoutDesc, gFramebufferLayout.writeRef()));
-
- if (isTestMode())
+ else
{
createOfflineFramebuffers();
}
diff --git a/examples/example-base/test-base.cpp b/examples/example-base/test-base.cpp
index 5c727aabe..0e0f8a69c 100644
--- a/examples/example-base/test-base.cpp
+++ b/examples/example-base/test-base.cpp
@@ -37,7 +37,8 @@ void TestBase::printEntrypointHashes(int entryPointCount, int targetCount, ComPt
composedProgram->getEntryPointHash(entryPointIndex, targetIndex, entryPointHashBlob.writeRef());
Slang::StringBuilder strBuilder;
- strBuilder << "entrypoint: "<< entryPointIndex << ", target: " << targetIndex << ", hash: ";
+ strBuilder << "callIdx: " << m_globalCounter << ", entrypoint: "<< entryPointIndex << ", target: " << targetIndex << ", hash: ";
+ m_globalCounter++;
uint8_t* buffer = (uint8_t*)entryPointHashBlob->getBufferPointer();
for (size_t i = 0; i < entryPointHashBlob->getBufferSize(); i++)
diff --git a/examples/example-base/test-base.h b/examples/example-base/test-base.h
index 22cd70d09..cdd72c580 100644
--- a/examples/example-base/test-base.h
+++ b/examples/example-base/test-base.h
@@ -17,5 +17,6 @@ public:
bool isTestMode() const { return m_isTestMode; }
private:
- bool m_isTestMode = false;
+ bool m_isTestMode = false;
+ uint64_t m_globalCounter = 0;
};