mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
gpu: D3D12 only requires feature level 11_0 with Resource Binding Tier 2.
We previously thought this wasn't possible because constant buffer offsets and partial updates were unavailable, but we were reading the wrong table - this is only the case for D3D11... https://learn.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-devices-downlevel-intro ... while 12 doesn't list this feature at all: https://learn.microsoft.com/en-us/windows/win32/direct3d12/hardware-feature-levels We double checked and Jesse Natalie confirmed that this feature is required for D3D12 even for 11_0 drivers. (Thanks Jesse!) Additionally, D3D12 requires that UAVs are accessible from all shader stages, meaning Tier 2 is enough to support the number of UAVs we need. Tier 1 could be a property to lower the requirements, but that can be done later.
This commit is contained in:
@@ -235,7 +235,8 @@
|
||||
* SDL driver name: "direct3d12"
|
||||
*
|
||||
* Supported on Windows 10 or newer, Xbox One (GDK), and Xbox Series X|S
|
||||
* (GDK). Requires a GPU that supports DirectX 12 Feature Level 11_1.
|
||||
* (GDK). Requires a GPU that supports DirectX 12 Feature Level 11_0 and
|
||||
* Resource Binding Tier 2 or above.
|
||||
*
|
||||
* ### Metal
|
||||
*
|
||||
|
@@ -109,8 +109,8 @@
|
||||
#define DXGI_GET_DEBUG_INTERFACE_FUNC "DXGIGetDebugInterface"
|
||||
#define D3D12_GET_DEBUG_INTERFACE_FUNC "D3D12GetDebugInterface"
|
||||
#define WINDOW_PROPERTY_DATA "SDL_GPUD3D12WindowPropertyData"
|
||||
#define D3D_FEATURE_LEVEL_CHOICE D3D_FEATURE_LEVEL_11_1
|
||||
#define D3D_FEATURE_LEVEL_CHOICE_STR "11_1"
|
||||
#define D3D_FEATURE_LEVEL_CHOICE D3D_FEATURE_LEVEL_11_0
|
||||
#define D3D_FEATURE_LEVEL_CHOICE_STR "11_0"
|
||||
#define MAX_ROOT_SIGNATURE_PARAMETERS 64
|
||||
#define D3D12_FENCE_UNSIGNALED_VALUE 0
|
||||
#define D3D12_FENCE_SIGNAL_VALUE 1
|
||||
@@ -8347,6 +8347,7 @@ static bool D3D12_PrepareDriver(SDL_VideoDevice *_this, SDL_PropertiesID props)
|
||||
IDXGIFactory4 *factory4;
|
||||
IDXGIFactory6 *factory6;
|
||||
IDXGIAdapter1 *adapter;
|
||||
bool supports_64UAVs = false;
|
||||
|
||||
// Early check to see if the app has _any_ D3D12 formats, if not we don't
|
||||
// have to fuss with loading D3D in the first place.
|
||||
@@ -8446,12 +8447,39 @@ static bool D3D12_PrepareDriver(SDL_VideoDevice *_this, SDL_PropertiesID props)
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(featurelevel, D3D_FEATURE_LEVEL_CHOICE < D3D_FEATURE_LEVEL_11_1);
|
||||
|
||||
// Check feature level 11_1 first, guarantees 64+ UAVs unlike 11_0 Tier1
|
||||
res = D3D12CreateDeviceFunc(
|
||||
(IUnknown *)adapter,
|
||||
D3D_FEATURE_LEVEL_CHOICE,
|
||||
D3D_FEATURE_LEVEL_11_1,
|
||||
D3D_GUID(D3D_IID_ID3D12Device),
|
||||
(void **)&device);
|
||||
|
||||
if (SUCCEEDED(res)) {
|
||||
supports_64UAVs = true;
|
||||
} else {
|
||||
res = D3D12CreateDeviceFunc(
|
||||
(IUnknown *)adapter,
|
||||
D3D_FEATURE_LEVEL_CHOICE,
|
||||
D3D_GUID(D3D_IID_ID3D12Device),
|
||||
(void **)&device);
|
||||
|
||||
if (SUCCEEDED(res)) {
|
||||
D3D12_FEATURE_DATA_D3D12_OPTIONS featureOptions;
|
||||
SDL_zero(featureOptions);
|
||||
|
||||
res = ID3D12Device_CheckFeatureSupport(
|
||||
device,
|
||||
D3D12_FEATURE_D3D12_OPTIONS,
|
||||
&featureOptions,
|
||||
sizeof(featureOptions));
|
||||
if (SUCCEEDED(res) && featureOptions.ResourceBindingTier >= D3D12_RESOURCE_BINDING_TIER_2) {
|
||||
supports_64UAVs = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SUCCEEDED(res)) {
|
||||
D3D12_FEATURE_DATA_SHADER_MODEL shaderModel;
|
||||
shaderModel.HighestShaderModel = D3D_SHADER_MODEL_6_0;
|
||||
@@ -8473,6 +8501,11 @@ static bool D3D12_PrepareDriver(SDL_VideoDevice *_this, SDL_PropertiesID props)
|
||||
SDL_UnloadObject(d3d12Dll);
|
||||
SDL_UnloadObject(dxgiDll);
|
||||
|
||||
if (!supports_64UAVs) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_GPU, "D3D12: Tier 2 Resource binding is not supported");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!supports_dxil && !has_dxbc) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_GPU, "D3D12: DXIL is not supported and DXBC is not being provided");
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user