diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-09-23 15:38:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-23 15:38:25 -0400 |
| commit | 05af41d21d74d24871507e6f8f50574ea08c48a2 (patch) | |
| tree | 3197b021ed71c40f6035fdfa7d450b4b3b945422 /tools/render-test/slang-support.cpp | |
| parent | ede0792fd9b4c7bc5c2653092ba1d492e67ca190 (diff) | |
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.
Diffstat (limited to 'tools/render-test/slang-support.cpp')
| -rw-r--r-- | tools/render-test/slang-support.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
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 <assert.h> #include <stdio.h> +#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<char> 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<ISlangBlob> 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; |
