mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-27 23:19:11 +00:00
gpu: Implement support for SDL_GPU_DISABLED
This commit is contained in:
parent
d3932b1ba2
commit
371cfaf8fe
2 changed files with 15 additions and 0 deletions
|
@ -263,6 +263,7 @@
|
||||||
#cmakedefine SDL_VIDEO_DISABLED @SDL_VIDEO_DISABLED@
|
#cmakedefine SDL_VIDEO_DISABLED @SDL_VIDEO_DISABLED@
|
||||||
#cmakedefine SDL_POWER_DISABLED @SDL_POWER_DISABLED@
|
#cmakedefine SDL_POWER_DISABLED @SDL_POWER_DISABLED@
|
||||||
#cmakedefine SDL_CAMERA_DISABLED @SDL_CAMERA_DISABLED@
|
#cmakedefine SDL_CAMERA_DISABLED @SDL_CAMERA_DISABLED@
|
||||||
|
#cmakedefine SDL_GPU_DISABLED @SDL_GPU_DISABLED@
|
||||||
|
|
||||||
/* Enable various audio drivers */
|
/* Enable various audio drivers */
|
||||||
#cmakedefine SDL_AUDIO_DRIVER_ALSA @SDL_AUDIO_DRIVER_ALSA@
|
#cmakedefine SDL_AUDIO_DRIVER_ALSA @SDL_AUDIO_DRIVER_ALSA@
|
||||||
|
|
|
@ -150,6 +150,7 @@
|
||||||
|
|
||||||
// Drivers
|
// Drivers
|
||||||
|
|
||||||
|
#ifndef SDL_GPU_DISABLED
|
||||||
static const SDL_GPUBootstrap *backends[] = {
|
static const SDL_GPUBootstrap *backends[] = {
|
||||||
#ifdef SDL_GPU_METAL
|
#ifdef SDL_GPU_METAL
|
||||||
&MetalDriver,
|
&MetalDriver,
|
||||||
|
@ -165,6 +166,7 @@ static const SDL_GPUBootstrap *backends[] = {
|
||||||
#endif
|
#endif
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
#endif // SDL_GPU_DISABLED
|
||||||
|
|
||||||
// Internal Utility Functions
|
// Internal Utility Functions
|
||||||
|
|
||||||
|
@ -368,6 +370,7 @@ void SDL_GPU_BlitCommon(
|
||||||
|
|
||||||
// Driver Functions
|
// Driver Functions
|
||||||
|
|
||||||
|
#ifndef SDL_GPU_DISABLED
|
||||||
static SDL_GPUDriver SDL_GPUSelectBackend(
|
static SDL_GPUDriver SDL_GPUSelectBackend(
|
||||||
SDL_VideoDevice *_this,
|
SDL_VideoDevice *_this,
|
||||||
const char *gpudriver,
|
const char *gpudriver,
|
||||||
|
@ -406,12 +409,14 @@ static SDL_GPUDriver SDL_GPUSelectBackend(
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_GPU, "No supported SDL_GPU backend found!");
|
SDL_LogError(SDL_LOG_CATEGORY_GPU, "No supported SDL_GPU backend found!");
|
||||||
return SDL_GPU_DRIVER_INVALID;
|
return SDL_GPU_DRIVER_INVALID;
|
||||||
}
|
}
|
||||||
|
#endif // SDL_GPU_DISABLED
|
||||||
|
|
||||||
SDL_GPUDevice *SDL_CreateGPUDevice(
|
SDL_GPUDevice *SDL_CreateGPUDevice(
|
||||||
SDL_GPUShaderFormat format_flags,
|
SDL_GPUShaderFormat format_flags,
|
||||||
SDL_bool debug_mode,
|
SDL_bool debug_mode,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
|
#ifndef SDL_GPU_DISABLED
|
||||||
SDL_GPUDevice *result;
|
SDL_GPUDevice *result;
|
||||||
SDL_PropertiesID props = SDL_CreateProperties();
|
SDL_PropertiesID props = SDL_CreateProperties();
|
||||||
if (format_flags & SDL_GPU_SHADERFORMAT_PRIVATE) {
|
if (format_flags & SDL_GPU_SHADERFORMAT_PRIVATE) {
|
||||||
|
@ -437,10 +442,15 @@ SDL_GPUDevice *SDL_CreateGPUDevice(
|
||||||
result = SDL_CreateGPUDeviceWithProperties(props);
|
result = SDL_CreateGPUDeviceWithProperties(props);
|
||||||
SDL_DestroyProperties(props);
|
SDL_DestroyProperties(props);
|
||||||
return result;
|
return result;
|
||||||
|
#else
|
||||||
|
SDL_SetError("SDL not built with GPU support");
|
||||||
|
return NULL;
|
||||||
|
#endif // SDL_GPU_DISABLED
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GPUDevice *SDL_CreateGPUDeviceWithProperties(SDL_PropertiesID props)
|
SDL_GPUDevice *SDL_CreateGPUDeviceWithProperties(SDL_PropertiesID props)
|
||||||
{
|
{
|
||||||
|
#ifndef SDL_GPU_DISABLED
|
||||||
SDL_GPUShaderFormat format_flags = 0;
|
SDL_GPUShaderFormat format_flags = 0;
|
||||||
bool debug_mode;
|
bool debug_mode;
|
||||||
bool preferLowPower;
|
bool preferLowPower;
|
||||||
|
@ -498,6 +508,10 @@ SDL_GPUDevice *SDL_CreateGPUDeviceWithProperties(SDL_PropertiesID props)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
#else
|
||||||
|
SDL_SetError("SDL not built with GPU support");
|
||||||
|
return NULL;
|
||||||
|
#endif // SDL_GPU_DISABLED
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_DestroyGPUDevice(SDL_GPUDevice *device)
|
void SDL_DestroyGPUDevice(SDL_GPUDevice *device)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue