From 05af41d21d74d24871507e6f8f50574ea08c48a2 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 23 Sep 2019 15:38:25 -0400 Subject: Simple test profiling (#1062) * First pass support for performance profiling * Test across all elements * Fix bug - sourceContents is not used, should use rawSource. * * Add ability to get prelude from API. * Allow specifying source language for render-test * Made it possible to compile a test input file as C++ * Special handling for reflection * Added C++ impl to performance-profile.slang * Remove some clang warnings. * Output profile timings on appveyor and other TC. * Remove passing around of StdWriters (can use global). Small comment improvements. --- tools/render-test/slang-support.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tools/render-test/slang-support.cpp') diff --git a/tools/render-test/slang-support.cpp b/tools/render-test/slang-support.cpp index 515481d4f..9afddc09b 100644 --- a/tools/render-test/slang-support.cpp +++ b/tools/render-test/slang-support.cpp @@ -9,6 +9,8 @@ #include #include +#include "../../source/core/slang-string-util.h" + namespace renderer_test { using namespace Slang; @@ -54,6 +56,12 @@ static const char computeEntryPointName[] = "computeMain"; case SLANG_SOURCE_LANGUAGE_HLSL: spAddPreprocessorDefine(slangRequest, "__HLSL__", "1"); break; + case SLANG_SOURCE_LANGUAGE_C: + spAddPreprocessorDefine(slangRequest, "__C__", "1"); + break; + case SLANG_SOURCE_LANGUAGE_CPP: + spAddPreprocessorDefine(slangRequest, "__CPP__", "1"); + break; default: assert(!"unexpected"); @@ -240,6 +248,23 @@ static const char computeEntryPointName[] = "computeMain"; List sourceText; SLANG_RETURN_ON_FAIL(readSource(sourcePath, sourceText)); + if (input.sourceLanguage == SLANG_SOURCE_LANGUAGE_CPP || input.sourceLanguage == SLANG_SOURCE_LANGUAGE_C) + { + // Add an include of the prelude + ComPtr prelude; + session->getDownstreamCompilerPrelude(SLANG_PASS_THROUGH_GENERIC_C_CPP, prelude.writeRef()); + + String preludeString = StringUtil::getString(prelude); + + // Add the prelude + StringBuilder builder; + builder << preludeString << "\n"; + builder << UnownedStringSlice(sourceText.getBuffer(), sourceText.getCount()); + + sourceText.setCount(builder.getLength()); + memcpy(sourceText.getBuffer(), builder.getBuffer(), builder.getLength()); + } + output.sourcePath = sourcePath; auto& layout = output.layout; -- cgit v1.2.3