Skip to content

Commit ac0f77b

Browse files
authored
Allow SDL GPU to opt into additional Vulkan features (#14204)
1 parent 6905714 commit ac0f77b

File tree

3 files changed

+654
-42
lines changed

3 files changed

+654
-42
lines changed

include/SDL3/SDL_gpu.h

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2315,7 +2315,13 @@ extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDevice(
23152315
* This can be useful if your application _requires_ SDL_GPU, but if you can
23162316
* provide your own fallback renderer (for example, an OpenGL renderer) this
23172317
* property can be set to true. Defaults to false.
2318-
*
2318+
* - `SDL_PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTER`: pointer to an
2319+
* SDL_GPUVulkanOptions structure to be processed during device creation.
2320+
* This allows configuring a variety of Vulkan-specific options such as
2321+
* increasing the API version and opting into extensions aside from the
2322+
* minimal set SDL requires. The structure is NOT deep-copied. Make sure
2323+
* that the pointer valid memory during window creation.
2324+
*
23192325
* \param props the properties to use.
23202326
* \returns a GPU context on success or NULL on failure; call SDL_GetError()
23212327
* for more information.
@@ -2347,6 +2353,38 @@ extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDeviceWithProperties(
23472353
#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN "SDL.gpu.device.create.d3d12.allowtier1resourcebinding"
23482354
#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING "SDL.gpu.device.create.d3d12.semantic"
23492355
#define SDL_PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION_BOOLEAN "SDL.gpu.device.create.vulkan.requirehardwareacceleration"
2356+
#define SDL_PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTER "SDL.gpu.device.create.vulkan.options"
2357+
2358+
2359+
/**
2360+
* A structure specifying additional options when using Vulkan.
2361+
*
2362+
* When no such structure is provided, SDL will use Vulkan API version 1.0 and
2363+
* a minimal set of features.
2364+
* The requested API version influences how the feature_list is processed by
2365+
* SDL. When requesting API version 1.0, the feature_list is ignored. Only the
2366+
* vulkan_10_phyisical_device_features and the extension lists are used. When
2367+
* requesting API version 1.1, the feature_list is scanned for feature
2368+
* structures introduced in Vulkan 1.1. When requesting Vulkan 1.2 or higher,
2369+
* the feature_list is additionally scanned for compound feature structs such
2370+
* as VkPhysicalDeviceVulkan11Features. The device and instance extension
2371+
* lists, as well as vulkan_10_physical_device_features, are always processed.
2372+
* The pointers inside this structure are NOT deep-copied. Make sure they are
2373+
* valid during window creation.
2374+
*
2375+
* \since This struct is available since SDL 3.4.0.
2376+
*
2377+
*/
2378+
typedef struct SDL_GPUVulkanOptions
2379+
{
2380+
Uint32 vulkan_api_version; /**< The Vulkan API version to request for the instance. Use Vulkan's VK_MAKE_VERSION or VK_MAKE_API_VERSION. */
2381+
void *feature_list; /**< Pointer to the first element of a chain of Vulkan feature structs. (Requires API version 1.1 or higher.)*/
2382+
void *vulkan_10_physical_device_features; /**< Pointer to a VkPhysicalDeviceFeatures struct to enable additional Vulkan 1.0 features. */
2383+
Uint32 device_extension_count; /**< Number of additional device extensions to require. */
2384+
const char **device_extension_names; /**< Pointer to a list of additional device extensions to require. */
2385+
Uint32 instance_extension_count; /**< Number of additional instance extensions to require. */
2386+
const char **instance_extension_names; /**< Pointer to a list of additional instance extensions to require. */
2387+
} SDL_GPUVulkanOptions;
23502388

23512389
/**
23522390
* Destroys a GPU context previously returned by SDL_CreateGPUDevice.

0 commit comments

Comments
 (0)