summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/gfx/d3d12/d3d12-device.cpp59
-rw-r--r--tools/gfx/d3d12/d3d12-device.h2
2 files changed, 51 insertions, 10 deletions
diff --git a/tools/gfx/d3d12/d3d12-device.cpp b/tools/gfx/d3d12/d3d12-device.cpp
index fc9ab43cb..37b26e78c 100644
--- a/tools/gfx/d3d12/d3d12-device.cpp
+++ b/tools/gfx/d3d12/d3d12-device.cpp
@@ -376,14 +376,29 @@ Result DeviceImpl::initialize(const Desc& desc)
{
SLANG_RETURN_ON_FAIL(RendererBase::initialize(desc));
+ // Rather than statically link against D3D, we load it dynamically.
+
+ HMODULE d3dModule = LoadLibraryA("d3d12.dll");
+ if (!d3dModule)
+ {
+ getDebugCallback()->handleMessage(
+ DebugMessageType::Error, DebugMessageSource::Layer, "error: failed load 'd3d12.dll'\n");
+ return SLANG_FAIL;
+ }
+
// Find extended desc.
for (GfxIndex i = 0; i < desc.extendedDescCount; i++)
{
StructType stype;
memcpy(&stype, desc.extendedDescs[i], sizeof(stype));
- if (stype == StructType::D3D12ExtendedDesc)
+ switch (stype )
{
+ case StructType::D3D12DeviceExtendedDesc:
memcpy(&m_extendedDesc, desc.extendedDescs[i], sizeof(m_extendedDesc));
+ break;
+ case StructType::D3D12ExperimentalFeaturesDesc:
+ processExperimentalFeaturesDesc(d3dModule, desc.extendedDescs[i]);
+ break;
}
}
@@ -401,15 +416,6 @@ Result DeviceImpl::initialize(const Desc& desc)
::memcpy(m_info.identityProjectionMatrix, kIdentity, sizeof(kIdentity));
}
- // Rather than statically link against D3D, we load it dynamically.
-
- HMODULE d3dModule = LoadLibraryA("d3d12.dll");
- if (!d3dModule)
- {
- fprintf(stderr, "error: failed load 'd3d12.dll'\n");
- return SLANG_FAIL;
- }
-
// Get all the dll entry points
m_D3D12SerializeRootSignature =
(PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)loadProc(d3dModule, "D3D12SerializeRootSignature");
@@ -1917,6 +1923,39 @@ void DeviceImpl::submitResourceCommandsAndWait(const DeviceImpl::ResourceCommand
m_resourceCommandTransientHeap->synchronizeAndReset();
}
+void DeviceImpl::processExperimentalFeaturesDesc(void* d3dModule, void* inDesc)
+{
+ typedef HRESULT(WINAPI* PFN_D3D12_ENABLE_EXPERIMENTAL_FEATURES)(
+ UINT NumFeatures,
+ const IID* pIIDs,
+ void* pConfigurationStructs,
+ UINT* pConfigurationStructSizes
+ );
+
+ D3D12ExperimentalFeaturesDesc desc = {};
+ memcpy(&desc, inDesc, sizeof(desc));
+ auto enableExperimentalFeaturesFunc =
+ (PFN_D3D12_ENABLE_EXPERIMENTAL_FEATURES)loadProc((HMODULE)d3dModule, "D3D12EnableExperimentalFeatures");
+ if (!enableExperimentalFeaturesFunc)
+ {
+ getDebugCallback()->handleMessage(
+ gfx::DebugMessageType::Warning,
+ gfx::DebugMessageSource::Layer,
+ "cannot enable D3D12 experimental features, 'D3D12EnableExperimentalFeatures' function "
+ "not found.");
+ return;
+ }
+ if (!SLANG_SUCCEEDED(enableExperimentalFeaturesFunc(desc.numFeatures, (IID*)desc.featureIIDs, desc.configurationStructs, desc.configurationStructSizes)))
+ {
+ getDebugCallback()->handleMessage(
+ gfx::DebugMessageType::Warning,
+ gfx::DebugMessageSource::Layer,
+ "cannot enable D3D12 experimental features, 'D3D12EnableExperimentalFeatures' call "
+ "failed.");
+ return;
+ }
+}
+
Result DeviceImpl::createQueryPool(const IQueryPool::Desc& desc, IQueryPool** outState)
{
switch (desc.type)
diff --git a/tools/gfx/d3d12/d3d12-device.h b/tools/gfx/d3d12/d3d12-device.h
index e02005ffd..38b3251fd 100644
--- a/tools/gfx/d3d12/d3d12-device.h
+++ b/tools/gfx/d3d12/d3d12-device.h
@@ -247,6 +247,8 @@ public:
};
ResourceCommandRecordInfo encodeResourceCommands();
void submitResourceCommandsAndWait(const ResourceCommandRecordInfo& info);
+private:
+ void processExperimentalFeaturesDesc(void* d3dModule, void* desc);
};
} // namespace d3d12