SDL_CreateGP...ithProperties(3)
β¨ SDL_CreateGPUDeviceWithProperties β¨
okay bestie, welcome to the SDL3 FUNCTIONS manual, and buckle up because this one is a chonky girl. we're talking about SDL_CreateGPUDeviceWithProperties today, and she is giving main character energy, no cap π
πΈ NAME πΈ
SDL_CreateGPUDeviceWithProperties β Creates a GPU context. periodt.
π¦ SYNOPSIS π¦
#include <SDL3/SDL_gpu.h>
SDL_GPUDevice * SDL_CreateGPUDeviceWithProperties(
SDL_PropertiesID props);
π DESCRIPTION π
so like, you hand her a bag of properties and she builds you a whole GPU context out of it. these are the supported properties, and yes, we're listing all of them, because we don't skip. skipping is not the vibe. π«Ά
SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEANβ turns on debug mode properties and validations. defaults totrue, because she's careful like that.SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEANβ enable this if you want energy efficiency over maximum GPU performance. defaults tofalse, so by default she's going full throttle π₯SDL_PROP_GPU_DEVICE_CREATE_VERBOSE_BOOLEANβ enable to automatically log useful debug information when the device gets created. defaults totrue.SDL_PROP_GPU_DEVICE_CREATE_NAME_STRINGβ the name of the GPU driver to use, if you want a specific one. picky picky, we love that for you πSDL_PROP_GPU_DEVICE_CREATE_FEATURE_CLIP_DISTANCE_BOOLEANβ enables the Vulkan device featureshaderClipDistance. if you disable it, clip distances are literally not supported in shader code: that's thegl_ClipDistance[]built-ins of GLSL, theSV_ClipDistance0/1semantics of HLSL, and the[[clip_distance]]attribute of Metal. turning off optional features lets your app run on some older Android devices. defaults totrue.SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEANβ enables the Vulkan device featuredepthClamp. if disabled, there is no depth clamp support andenable_depth_clipinSDL_GPURasterizerStatemust always be set totrue. turning off optional features lets your app run on some older Android devices. defaults totrue.SDL_PROP_GPU_DEVICE_CREATE_FEATURE_INDIRECT_DRAW_FIRST_INSTANCE_BOOLEANβ enables the Vulkan device featuredrawIndirectFirstInstance. if disabled, the argumentfirst_instanceofSDL_GPUIndirectDrawCommandmust be set to zero. turning off optional features lets your app run on some older Android devices. defaults totrue.SDL_PROP_GPU_DEVICE_CREATE_FEATURE_ANISOTROPY_BOOLEANβ enables the Vulkan device featuresamplerAnisotropy. if disabled,enable_anisotropyofSDL_GPUSamplerCreateInfomust be set tofalse. turning off optional features lets your app run on some older Android devices. defaults totrue.
and now, the current shader format properties π (these are giving "what shaders can you actually feed me"):
SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOLEANβ the app is able to provide shaders for an NDA platform.SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEANβ the app is able to provide SPIR-V shaders if applicable.SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEANβ the app is able to provide DXBC shaders if applicableSDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEANβ the app is able to provide DXIL shaders if applicable.SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEANβ the app is able to provide MSL shaders if applicable.SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEANβ the app is able to provide Metal shader libraries if applicable.
π With the D3D12 backend π
SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRINGβ the prefix to use for all vertex semantics, default is"TEXCOORD".SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEANβ by default, Resourcing Binding Tier 2 is required for D3D12 support. however, an application can set this property totrueto enable Tier 1 support, if (and only if) the application uses 8 or fewer storage resources across all shader stages. as of writing, this property is useful for targeting Intel Haswell and Broadwell GPUs; other hardware either supports Tier 2 Resource Binding or does not support D3D12 in any capacity. defaults tofalse.SDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_VERSION_NUMBERβ certain feature checks are only possible on Windows 11 by default. by setting this alongsideSDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_PATH_STRINGand vendoringD3D12Core.dllfrom the D3D12 Agility SDK, you can make those feature checks possible on older platforms. the version you provide must match the one given in the DLL. πSDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_PATH_STRINGβ certain feature checks are only possible on Windows 11 by default. by setting this alongsideSDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_VERSION_NUMBERand vendoringD3D12Core.dllfrom the D3D12 Agility SDK, you can make those feature checks possible on older platforms. the path you provide must be relative to the executable path of your app.
π¨ bestie LISTEN. be sure not to put the DLL in the same directory as the exe; Microsoft strongly advises against this! do not do it. I'm not kidding. π
π§ 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 totrue. defaults tofalse.SDL_PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTERβ a pointer to anSDL_GPUVulkanOptionsstructure 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. fancy β¨
β 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 totrueto 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.)
π FUNCTION PARAMETERS π
propsβ the properties to use.
π RETURN VALUE π
returns a GPU context on success or NULL on failure; call SDL_GetError() for more information. if it's NULL, go read your error, she left you a note π
π AVAILABILITY π
this function is available since SDL 3.2.0.
πΈ SEE ALSO πΈ
SDL_GetGPUShaderFormats(3)SDL_GetGPUDeviceDriver(3)SDL_DestroyGPUDevice(3)SDL_GPUSupportsProperties(3)
and that's the whole page, bestie π«Ά go forth and create your GPU context. this was brought to you by Simple Directmedia Layer, version SDL 3.4.18, and honestly? iconic. slay. bye π β¨
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms