Skip to main content

SDL_CreateGPUDeviceWithProperties

Function SDL_CreateGPUDeviceWithProperties 

Source
pub unsafe extern "C" fn SDL_CreateGPUDeviceWithProperties(
    props: SDL_PropertiesID,
) -> *mut SDL_GPUDevice
Expand description

Creates a GPU context.

These are the supported properties:

These are the current shader format properties:

With the D3D12 backend:

With the Vulkan backend:

  • SDL_PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION_BOOLEAN: By default, Vulkan device enumeration includes drivers of all types, including software renderers (for example, the Lavapipe Mesa driver). This can be useful if your application requires SDL_GPU, but if you can provide your own fallback renderer (for example, an OpenGL renderer) this property can be set to true. Defaults to false.
  • SDL_PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTER: a pointer to an SDL_GPUVulkanOptions structure to be processed during device creation. This allows configuring a variety of Vulkan-specific options such as increasing the API version and opting into extensions aside from the minimal set SDL requires.

With the Metal backend: - SDL_PROP_GPU_DEVICE_CREATE_METAL_ALLOW_MACFAMILY1_BOOLEAN: By default, macOS support requires what Apple calls “MTLGPUFamilyMac2” hardware or newer. However, an application can set this property to true to enable support for “MTLGPUFamilyMac1” hardware, if (and only if) the application does not write to sRGB textures. (For history’s sake: MacFamily1 also does not support indirect command buffers, MSAA depth resolve, and stencil resolve/feedback, but these are not exposed features in SDL_GPU.)

§Parameters

  • props: the properties to use.

§Return value

Returns a GPU context on success or NULL on failure; call SDL_GetError() for more information.

§Availability

This function is available since SDL 3.2.0.

§See also