summaryrefslogtreecommitdiffstats
path: root/tools/render-test/slang-support.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-06-02 16:58:25 -0700
committerGitHub <noreply@github.com>2021-06-02 16:58:25 -0700
commite67af5b1a3993529c702ff2924dea11fd1017d2e (patch)
treec4359fb6df6110d81a658278aef9ab7244af5496 /tools/render-test/slang-support.cpp
parent8e571669b3c8d4ac8236d0aed7a960bf88ad2bd1 (diff)
Various Fixes to gfx, reflection and emit. (#1867)
* Various Fixes to gfx, reflection and emit. - Fix GLSL emit to properly output `*bitsTo*` functions for `IRBitCast` insts. - Add line directive mode setting for `ISession`. - Extend `TypeLayout::getElementStride` to handle `VectorType` case. - Fix `IDevice::readBufferResource` 's D3D12 implementation to copy only the requested bytes out. - Fix `render-test` to use the `ISession` from `gfx` instead of creating its own `ISession` to make sure `gfx` and `render-test` agree on WitnessTable and RTTI IDs. - Extend `render-test` to support filling vector and matrix values in the new `set x = ...` TEST_INPUT syntax. - Add a `dynamic-dispatch-15` test case to make sure packing / unpacking works correctly across all targets, and to make sure render-test's RTTI/WitnessTable ID filling logic is correct for non-trivial cases. * Remove default-major test * Fix cyclic reference in `ExtendedTypeLayout`. * Move `lineDirectiveMode` setting to `TargetDesc`. Add `structureSize` to `TargetDesc` and `SessionDesc` for future binary compatibility. * Cleanup. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tools/render-test/slang-support.cpp')
-rw-r--r--tools/render-test/slang-support.cpp25
1 files changed, 8 insertions, 17 deletions
diff --git a/tools/render-test/slang-support.cpp b/tools/render-test/slang-support.cpp
index adfea337c..a533a6378 100644
--- a/tools/render-test/slang-support.cpp
+++ b/tools/render-test/slang-support.cpp
@@ -66,26 +66,19 @@ void ShaderCompilerUtil::Output::reset()
desc.slangProgram = nullptr;
}
- if (m_requestForKernels && session)
- {
- spDestroyCompileRequest(m_requestForKernels);
- }
- if (m_extraRequestForReflection && session)
- {
- spDestroyCompileRequest(m_extraRequestForReflection);
- }
session = nullptr;
m_requestForKernels = nullptr;
m_extraRequestForReflection = nullptr;
}
-/* static */ SlangResult ShaderCompilerUtil::_compileProgramImpl(SlangSession* session, const Options& options, const Input& input, const ShaderCompileRequest& request, Output& out)
+/* static */ SlangResult ShaderCompilerUtil::_compileProgramImpl(slang::ISession* session, const Options& options, const Input& input, const ShaderCompileRequest& request, Output& out)
{
out.reset();
- SlangCompileRequest* slangRequest = spCreateCompileRequest(session);
+ ComPtr<SlangCompileRequest> slangRequest = nullptr;
+ session->createCompileRequest(slangRequest.writeRef());
out.m_requestForKernels = slangRequest;
- out.session = session;
+ out.session = session->getGlobalSession();
// Parse all the extra args
{
@@ -102,7 +95,7 @@ void ShaderCompilerUtil::Output::reset()
}
spSetCodeGenTarget(slangRequest, input.target);
- spSetTargetProfile(slangRequest, 0, spFindProfile(session, input.profile.getBuffer()));
+ spSetTargetProfile(slangRequest, 0, spFindProfile(out.session, input.profile.getBuffer()));
// Define a macro so that shader code in a test can detect what language we
// are nominally working with.
@@ -241,11 +234,10 @@ void ShaderCompilerUtil::Output::reset()
}
out.set(input.pipelineType, linkedSlangProgram);
-
return SLANG_OK;
}
-/* static */ SlangResult ShaderCompilerUtil::compileProgram(SlangSession* session, const Options& options, const Input& input, const ShaderCompileRequest& request, Output& out)
+/* static */ SlangResult ShaderCompilerUtil::compileProgram(slang::ISession* session, const Options& options, const Input& input, const ShaderCompileRequest& request, Output& out)
{
if( input.passThrough == SLANG_PASS_THROUGH_NONE )
{
@@ -319,7 +311,7 @@ void ShaderCompilerUtil::Output::reset()
return SLANG_OK;
}
-/* static */SlangResult ShaderCompilerUtil::compileWithLayout(SlangSession* session, const Options& options, const ShaderCompilerUtil::Input& input, OutputAndLayout& output)
+/* static */SlangResult ShaderCompilerUtil::compileWithLayout(slang::ISession* session, const Options& options, const ShaderCompilerUtil::Input& input, OutputAndLayout& output)
{
String sourcePath = options.sourcePath;
auto shaderType = options.shaderType;
@@ -331,7 +323,7 @@ void ShaderCompilerUtil::Output::reset()
{
// Add an include of the prelude
ComPtr<ISlangBlob> prelude;
- session->getLanguagePrelude(input.sourceLanguage, prelude.writeRef());
+ session->getGlobalSession()->getLanguagePrelude(input.sourceLanguage, prelude.writeRef());
String preludeString = StringUtil::getString(prelude);
@@ -421,7 +413,6 @@ void ShaderCompilerUtil::Output::reset()
}
compileRequest.globalSpecializationArgs = layout.globalSpecializationArgs;
compileRequest.entryPointSpecializationArgs = layout.entryPointSpecializationArgs;
-
return ShaderCompilerUtil::compileProgram(session, options, input, compileRequest, output.output);
}