summaryrefslogtreecommitdiffstats
path: root/tools/render-test/slang-support.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-08-19 14:08:57 -0400
committerGitHub <noreply@github.com>2019-08-19 14:08:57 -0400
commitdc6d0417b137c8ecdcb3b99b7624358bba7fefa8 (patch)
tree326fe7f93b08431685c6b01052c2eee18168776b /tools/render-test/slang-support.cpp
parentc4541e83b4a57d8317932bc4277ee6a2d45bb2f6 (diff)
WIP: Compute test running on CPU (#1023)
* * Simplify some of test code around CPPCompiler * Test using 'callable' with pass-through * Small cpu doc improvements * Improvements to Clang output parsing. * Remove temporary file (base filename) . * Improve handling of external errors - handle severity. * On error dumping out to 'actual' file for runCPPCompilerCompile. * Small fixes. Set the source language type correctly for pass thru. * Remove warning for test for clang backend c * Preliminary work around making render-test compute potentiall work with CPU. Made ShaderCompiler -> a stateless ShaderCompilerUtil. Means we don't require a Renderer interface to do shader compilation. * Refactor such that CPU test can take place in without Window or Renderer. * Hack to look for prelude in source file directory. Fix bug returning the SharedLibrary for HostCallable. * Compute test running on CPU. * Need the prelude currently in same directly as test. * Hack to remove warning - that then produces an error on appveyor build. Disable running render CPU test on non-windows. * Improve handling of disabling CPU tests on linux. * Added bit-cast.slang working on CPU.
Diffstat (limited to 'tools/render-test/slang-support.cpp')
-rw-r--r--tools/render-test/slang-support.cpp49
1 files changed, 18 insertions, 31 deletions
diff --git a/tools/render-test/slang-support.cpp b/tools/render-test/slang-support.cpp
index 77f1436b1..230f78453 100644
--- a/tools/render-test/slang-support.cpp
+++ b/tools/render-test/slang-support.cpp
@@ -11,19 +11,21 @@
namespace renderer_test {
-RefPtr<ShaderProgram> ShaderCompiler::compileProgram(
- ShaderCompileRequest const& request)
+/* static */ SlangResult ShaderCompilerUtil::compileProgram(SlangSession* session, const Input& input, const ShaderCompileRequest& request, Output& out)
{
- SlangCompileRequest* slangRequest = spCreateCompileRequest(slangSession);
+ out.reset();
- spSetCodeGenTarget(slangRequest, target);
- spSetTargetProfile(slangRequest, 0,
- spFindProfile(slangSession, profile));
+ SlangCompileRequest* slangRequest = spCreateCompileRequest(session);
+ out.request = slangRequest;
+ out.session = session;
+
+ spSetCodeGenTarget(slangRequest, input.target);
+ spSetTargetProfile(slangRequest, 0, spFindProfile(session, input.profile));
// Define a macro so that shader code in a test can detect what language we
// are nominally working with.
char const* langDefine = nullptr;
- switch (sourceLanguage)
+ switch (input.sourceLanguage)
{
case SLANG_SOURCE_LANGUAGE_GLSL:
spAddPreprocessorDefine(slangRequest, "__GLSL__", "1");
@@ -41,14 +43,14 @@ RefPtr<ShaderProgram> ShaderCompiler::compileProgram(
break;
}
- if (passThrough != SLANG_PASS_THROUGH_NONE)
+ if (input.passThrough != SLANG_PASS_THROUGH_NONE)
{
- spSetPassThrough(slangRequest, passThrough);
+ spSetPassThrough(slangRequest, input.passThrough);
}
// Process any additional command-line options specified for Slang using
// the `-xslang <arg>` option to `render-test`.
- SLANG_RETURN_NULL_ON_FAIL(spProcessCommandLineArguments(slangRequest, &gOptions.slangArgs[0], gOptions.slangArgCount));
+ SLANG_RETURN_ON_FAIL(spProcessCommandLineArguments(slangRequest, input.args, input.argCount));
int computeTranslationUnit = 0;
int vertexTranslationUnit = 0;
@@ -57,6 +59,8 @@ RefPtr<ShaderProgram> ShaderCompiler::compileProgram(
char const* fragmentEntryPointName = request.fragmentShader.name;
char const* computeEntryPointName = request.computeShader.name;
+ const auto sourceLanguage = input.sourceLanguage;
+
if (sourceLanguage == SLANG_SOURCE_LANGUAGE_GLSL)
{
// GLSL presents unique challenges because, frankly, it got the whole
@@ -91,8 +95,6 @@ RefPtr<ShaderProgram> ShaderCompiler::compileProgram(
}
- RefPtr<ShaderProgram> shaderProgram;
-
Slang::List<const char*> rawGlobalTypeNames;
for (auto typeName : request.globalGenericTypeArguments)
rawGlobalTypeNames.add(typeName.getBuffer());
@@ -146,12 +148,7 @@ RefPtr<ShaderProgram> ShaderCompiler::compileProgram(
kernelDesc.codeBegin = code;
kernelDesc.codeEnd = code + codeSize;
- ShaderProgram::Desc desc;
- desc.pipelineType = PipelineType::Compute;
- desc.kernels = &kernelDesc;
- desc.kernelCount = 1;
-
- shaderProgram = renderer->createProgram(desc);
+ out.set(PipelineType::Compute, &kernelDesc, 1);
}
}
else
@@ -189,21 +186,11 @@ RefPtr<ShaderProgram> ShaderCompiler::compileProgram(
kernelDescs[1].codeBegin = fragmentCode;
kernelDescs[1].codeEnd = fragmentCode + fragmentCodeSize;
- ShaderProgram::Desc desc;
- desc.pipelineType = PipelineType::Graphics;
- desc.kernels = &kernelDescs[0];
- desc.kernelCount = kDescCount;
-
- shaderProgram = renderer->createProgram(desc);
+ out.set(PipelineType::Graphics, kernelDescs, kDescCount);
}
}
- // We clean up the Slang compilation context and result *after*
- // we have run the downstream compiler, because Slang
- // owns the memory allocation for the generated text, and will
- // free it when we destroy the compilation result.
- spDestroyCompileRequest(slangRequest);
-
- return shaderProgram;
+
+ return SLANG_OK;
}
} // renderer_test