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-com-example/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'examples/cpu-com-example') diff --git a/examples/cpu-com-example/main.cpp b/examples/cpu-com-example/main.cpp index dedbf69f5..d75822e72 100644 --- a/examples/cpu-com-example/main.cpp +++ b/examples/cpu-com-example/main.cpp @@ -9,11 +9,14 @@ // 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 using namespace Slang; +static const ExampleResources resourceBase("cpu-com-example"); + // For the moment we have to explicitly write the Slang COM interface in C++ code. It *MUST* match // the interface in the slang source // As it stands all interfaces need to derive from ISlangUnknown (or IUnknown). @@ -79,7 +82,8 @@ static SlangResult _innerMain(int argc, char** argv) const int translationUnitIndex = request->addTranslationUnit(SLANG_SOURCE_LANGUAGE_SLANG, nullptr); // Set the source file for the translation unit - request->addTranslationUnitSourceFile(translationUnitIndex, "shader.slang"); + Slang::String path = resourceBase.resolveResource("shader.slang"); + request->addTranslationUnitSourceFile(translationUnitIndex, path.getBuffer()); const SlangResult compileRes = request->compile(); -- cgit v1.2.3