libobs: Add checks to some graphics API functions

A few recently introduced graphics API functions needed for Enhanced
Broadcasting were marked as `GRAPHICS_IMPORT_OPTIONAL`. Add the
proper checks in the wrapper to ensure they are safe on platforms
that do not implement the underlying function.
This commit is contained in:
Alex Luccisano
2025-05-09 13:08:10 -04:00
committed by Ryan Foster
parent e474a3723b
commit ef3e7b2563
+36 -4
View File
@@ -325,22 +325,54 @@ const char *gs_get_device_name(void)
const char *gs_get_driver_version(void)
{
return gs_valid("gs_get_driver_version") ? thread_graphics->exports.gpu_get_driver_version() : NULL;
graphics_t *graphics = thread_graphics;
if (!gs_valid("gs_get_driver_version"))
return NULL;
if (graphics->exports.gpu_get_driver_version)
return (graphics->exports.gpu_get_driver_version());
else
return NULL;
}
const char *gs_get_renderer(void)
{
return gs_valid("gs_get_renderer") ? thread_graphics->exports.gpu_get_renderer() : NULL;
graphics_t *graphics = thread_graphics;
if (!gs_valid("gs_get_renderer"))
return NULL;
if (graphics->exports.gpu_get_renderer)
return (graphics->exports.gpu_get_renderer());
else
return NULL;
}
uint64_t gs_get_gpu_dmem(void)
{
return gs_valid("gs_get_gpu_dmem") ? thread_graphics->exports.gpu_get_dmem() : 0;
graphics_t *graphics = thread_graphics;
if (!gs_valid("gs_get_gpu_dmem"))
return 0;
if (graphics->exports.gpu_get_dmem)
return (graphics->exports.gpu_get_dmem());
else
return 0;
}
uint64_t gs_get_gpu_smem(void)
{
return gs_valid("gs_get_gpu_smem") ? thread_graphics->exports.gpu_get_smem() : 0;
graphics_t *graphics = thread_graphics;
if (!gs_valid("gs_get_gpu_smem"))
return 0;
if (graphics->exports.gpu_get_smem)
return (graphics->exports.gpu_get_smem());
else
return 0;
}
int gs_get_device_type(void)