summaryrefslogtreecommitdiffstats
path: root/tools/gfx-unit-test/precompiled-module-2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/gfx-unit-test/precompiled-module-2.cpp')
-rw-r--r--tools/gfx-unit-test/precompiled-module-2.cpp36
1 files changed, 33 insertions, 3 deletions
diff --git a/tools/gfx-unit-test/precompiled-module-2.cpp b/tools/gfx-unit-test/precompiled-module-2.cpp
index 3da77e05c..93b9d1b89 100644
--- a/tools/gfx-unit-test/precompiled-module-2.cpp
+++ b/tools/gfx-unit-test/precompiled-module-2.cpp
@@ -17,7 +17,8 @@ namespace gfx_test
static Slang::Result precompileProgram(
gfx::IDevice* device,
ISlangMutableFileSystem* fileSys,
- const char* shaderModuleName)
+ const char* shaderModuleName,
+ bool precompileToTarget)
{
Slang::ComPtr<slang::ISession> slangSession;
SLANG_RETURN_ON_FAIL(device->getSlangSession(slangSession.writeRef()));
@@ -34,6 +35,20 @@ namespace gfx_test
if (!module)
return SLANG_FAIL;
+ if (precompileToTarget)
+ {
+ SlangCompileTarget target;
+ switch (device->getDeviceInfo().deviceType)
+ {
+ case gfx::DeviceType::DirectX12:
+ target = SLANG_DXIL;
+ break;
+ default:
+ return SLANG_FAIL;
+ }
+ module->precompileForTarget(target, diagnosticsBlob.writeRef());
+ }
+
// Write loaded modules to memory file system.
for (SlangInt i = 0; i < slangSession->getLoadedModuleCount(); i++)
{
@@ -50,7 +65,7 @@ namespace gfx_test
return SLANG_OK;
}
- void precompiledModule2TestImpl(IDevice* device, UnitTestContext* context)
+ void precompiledModule2TestImplCommon(IDevice* device, UnitTestContext* context, bool precompileToTarget)
{
Slang::ComPtr<ITransientResourceHeap> transientHeap;
ITransientResourceHeap::Desc transientHeapDesc = {};
@@ -63,7 +78,7 @@ namespace gfx_test
ComPtr<IShaderProgram> shaderProgram;
slang::ProgramLayout* slangReflection;
- GFX_CHECK_CALL_ABORT(precompileProgram(device, memoryFileSystem.get(), "precompiled-module-imported"));
+ GFX_CHECK_CALL_ABORT(precompileProgram(device, memoryFileSystem.get(), "precompiled-module-imported", precompileToTarget));
// Next, load the precompiled slang program.
Slang::ComPtr<slang::ISession> slangSession;
@@ -168,11 +183,26 @@ namespace gfx_test
Slang::makeArray<float>(3.0f, 3.0f, 3.0f, 3.0f));
}
+ void precompiledModule2TestImpl(IDevice* device, UnitTestContext* context)
+ {
+ precompiledModule2TestImplCommon(device, context, false);
+ }
+
+ void precompiledTargetModule2TestImpl(IDevice* device, UnitTestContext* context)
+ {
+ precompiledModule2TestImplCommon(device, context, true);
+ }
+
SLANG_UNIT_TEST(precompiledModule2D3D12)
{
runTestImpl(precompiledModule2TestImpl, unitTestContext, Slang::RenderApiFlag::D3D12);
}
+ SLANG_UNIT_TEST(precompiledTargetModule2D3D12)
+ {
+ runTestImpl(precompiledTargetModule2TestImpl, unitTestContext, Slang::RenderApiFlag::D3D12);
+ }
+
SLANG_UNIT_TEST(precompiledModule2Vulkan)
{
runTestImpl(precompiledModule2TestImpl, unitTestContext, Slang::RenderApiFlag::Vulkan);