From 0e71a6d40d2ccdc9e6bb861e7bbdb9479dbec636 Mon Sep 17 00:00:00 2001 From: venkataram-nv Date: Mon, 1 Jul 2024 10:08:04 -0700 Subject: Resource searching for examples (#4518) --- examples/cpu-hello-world/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'examples/cpu-hello-world/main.cpp') diff --git a/examples/cpu-hello-world/main.cpp b/examples/cpu-hello-world/main.cpp index 460b4698b..fedbf7ebe 100644 --- a/examples/cpu-hello-world/main.cpp +++ b/examples/cpu-hello-world/main.cpp @@ -25,6 +25,7 @@ // This includes a useful small function for setting up the prelude (described more further below). #include "../../source/core/slang-test-tool-util.h" +#include "examples/example-base/example-base.h" // Slang namespace is used for elements support code (like core) which we use here // for ComPtr<> and TestToolUtil @@ -40,6 +41,8 @@ using namespace Slang; #define SLANG_PRELUDE_NAMESPACE CPPPrelude #include "../../prelude/slang-cpp-types.h" +static const ExampleResources resourceBase("cpu-hello-world"); + struct UniformState; static SlangResult _innerMain(int argc, char** argv) @@ -102,7 +105,8 @@ static SlangResult _innerMain(int argc, char** argv) // We will load source code for our translation unit from the file `shader.slang`. // There are also variations of this API for adding source code from application-provided buffers. // - spAddTranslationUnitSourceFile(slangRequest, translationUnitIndex, "shader.slang"); + Slang::String path = resourceBase.resolveResource("shader.slang"); + spAddTranslationUnitSourceFile(slangRequest, translationUnitIndex, path.getBuffer()); // Once all of the input options for the compiler have been specified, // we can invoke `spCompile` to run the compiler and see if any errors -- cgit v1.2.3