Skip to content

Commit 7cdea44

Browse files
committed
Set GPU properties for maximum hardware compatibility
Resolves #13928
1 parent 00812d1 commit 7cdea44

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

include/SDL3/SDL_gpu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,12 +2261,12 @@ extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDevice(
22612261
* use for all vertex semantics, default is "TEXCOORD".
22622262
* - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN`: By
22632263
* default, Resourcing Binding Tier 2 is required for D3D12 support.
2264-
* However, an application can enable this property to enable Tier 1
2264+
* However, an application can set this property to true to enable Tier 1
22652265
* support, if (and only if) the application uses 8 or fewer storage
22662266
* resources across all shader stages. As of writing, this property is
22672267
* useful for targeting Intel Haswell and Broadwell GPUs; other hardware
22682268
* either supports Tier 2 Resource Binding or does not support D3D12 in any
2269-
* capacity.
2269+
* capacity. Defaults to false.
22702270
*
22712271
* With the Vulkan renderer:
22722272
*

src/render/gpu/SDL_render_gpu.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,25 @@ static bool GPU_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_P
11991199
SDL_SetBooleanProperty(create_props, SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN, debug);
12001200
SDL_SetBooleanProperty(create_props, SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN, lowpower);
12011201

1202+
// Set hints for the greatest hardware compatibility
1203+
// This property allows using the renderer on Intel Haswell and Broadwell GPUs.
1204+
if (!SDL_HasProperty(create_props, SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN)) {
1205+
SDL_SetBooleanProperty(create_props, SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN, true);
1206+
}
1207+
// These properties allow using the renderer on more Android devices.
1208+
if (!SDL_HasProperty(create_props, SDL_PROP_GPU_DEVICE_CREATE_VULKAN_SHADERCLIPDISTANCE_BOOLEAN)) {
1209+
SDL_SetBooleanProperty(create_props, SDL_PROP_GPU_DEVICE_CREATE_VULKAN_SHADERCLIPDISTANCE_BOOLEAN, false);
1210+
}
1211+
if (!SDL_HasProperty(create_props, SDL_PROP_GPU_DEVICE_CREATE_VULKAN_DEPTHCLAMP_BOOLEAN)) {
1212+
SDL_SetBooleanProperty(create_props, SDL_PROP_GPU_DEVICE_CREATE_VULKAN_DEPTHCLAMP_BOOLEAN, false);
1213+
}
1214+
if (!SDL_HasProperty(create_props, SDL_PROP_GPU_DEVICE_CREATE_VULKAN_DRAWINDIRECTFIRST_BOOLEAN)) {
1215+
SDL_SetBooleanProperty(create_props, SDL_PROP_GPU_DEVICE_CREATE_VULKAN_DRAWINDIRECTFIRST_BOOLEAN, false);
1216+
}
1217+
if (!SDL_HasProperty(create_props, SDL_PROP_GPU_DEVICE_CREATE_VULKAN_SAMPLERANISOTROPY_BOOLEAN)) {
1218+
SDL_SetBooleanProperty(create_props, SDL_PROP_GPU_DEVICE_CREATE_VULKAN_SHADERCLIPDISTANCE_BOOLEAN, false);
1219+
}
1220+
12021221
GPU_FillSupportedShaderFormats(create_props);
12031222
data->device = SDL_CreateGPUDeviceWithProperties(create_props);
12041223

0 commit comments

Comments
 (0)