GPU: device & frameSDL 3.2

SDL_GetGPUShaderFormats

Tells which shader formats the chosen backend accepts, so you load the right file.

Signature

SDL_GPUShaderFormat SDL_GetGPUShaderFormats(SDL_GPUDevice *device);

How it works

You offered several formats when creating the device; now load the one that matches. Test the returned bits with &.

Parameters

deviceSDL_GPUDevice *

The device.

Return value

A mask of SDL_GPU_SHADERFORMAT_… bits.

Example

example.cpp
1SDL_GPUShaderFormat fmts = SDL_GetGPUShaderFormats(device);
2const char* ext = (fmts & SDL_GPU_SHADERFORMAT_SPIRV) ? ".spv"
3                : (fmts & SDL_GPU_SHADERFORMAT_DXIL)  ? ".dxil"
4                :                                        ".msl";
Official SDL wiki