From 2f344b7eb5527b2449f1ad0dc2a9e42ac2542b76 Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 2 Oct 2020 21:14:03 -0700 Subject: Added device features to indicate support of 16-bit types --- .../src/RenderDeviceD3D12Impl.cpp | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp index 127abdfc..d5fc2bda 100644 --- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp @@ -251,8 +251,29 @@ RenderDeviceD3D12Impl::RenderDeviceD3D12Impl(IReferenceCounters* pRefCo m_DeviceCaps.Features.MeshShaders = MeshShadersSupported ? DEVICE_FEATURE_STATE_ENABLED : DEVICE_FEATURE_STATE_DISABLED; + D3D12_FEATURE_DATA_D3D12_OPTIONS4 d3d12Options4 = {}; + m_pd3d12Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS4, &d3d12Options4, sizeof(d3d12Options4)); + + if (d3d12Options4.Native16BitShaderOpsSupported) + { + m_DeviceCaps.Features.ShaderFloat16 = DEVICE_FEATURE_STATE_ENABLED; + m_DeviceCaps.Features.ResourceBuffer16BitAccess = DEVICE_FEATURE_STATE_ENABLED; + m_DeviceCaps.Features.UniformBuffer16BitAccess = DEVICE_FEATURE_STATE_ENABLED; + m_DeviceCaps.Features.ShaderInputOutput16 = DEVICE_FEATURE_STATE_ENABLED; + } + else + { + if (EngineCI.Features.ShaderFloat16 == DEVICE_FEATURE_STATE_ENABLED || + EngineCI.Features.ResourceBuffer16BitAccess == DEVICE_FEATURE_STATE_ENABLED || + EngineCI.Features.UniformBuffer16BitAccess == DEVICE_FEATURE_STATE_ENABLED || + EngineCI.Features.ShaderInputOutput16 == DEVICE_FEATURE_STATE_ENABLED) + { + LOG_ERROR_AND_THROW("This device/driver does not natively support 16-bit floats and ints."); + } + } + #if defined(_MSC_VER) && defined(_WIN64) - static_assert(sizeof(DeviceFeatures) == 23, "Did you add a new feature to DeviceFeatures? Please handle its satus here."); + static_assert(sizeof(DeviceFeatures) == 27, "Did you add a new feature to DeviceFeatures? Please handle its satus here."); #endif auto& TexCaps = m_DeviceCaps.TexCaps; -- cgit v1.2.3