mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-24 23:31:36 +08:00
libobs/graphics, libobs-d3d11: Add P010 support
This commit is contained in:
@@ -190,6 +190,7 @@ bool load_graphics_imports(struct gs_exports *exports, void *module,
|
||||
GRAPHICS_IMPORT(gs_shader_set_next_sampler);
|
||||
|
||||
GRAPHICS_IMPORT_OPTIONAL(device_nv12_available);
|
||||
GRAPHICS_IMPORT_OPTIONAL(device_p010_available);
|
||||
|
||||
GRAPHICS_IMPORT(device_debug_marker_begin);
|
||||
GRAPHICS_IMPORT(device_debug_marker_end);
|
||||
@@ -222,7 +223,9 @@ bool load_graphics_imports(struct gs_exports *exports, void *module,
|
||||
GRAPHICS_IMPORT_OPTIONAL(device_texture_acquire_sync);
|
||||
GRAPHICS_IMPORT_OPTIONAL(device_texture_release_sync);
|
||||
GRAPHICS_IMPORT_OPTIONAL(device_texture_create_nv12);
|
||||
GRAPHICS_IMPORT_OPTIONAL(device_texture_create_p010);
|
||||
GRAPHICS_IMPORT_OPTIONAL(device_stagesurface_create_nv12);
|
||||
GRAPHICS_IMPORT_OPTIONAL(device_stagesurface_create_p010);
|
||||
GRAPHICS_IMPORT_OPTIONAL(device_register_loss_callbacks);
|
||||
GRAPHICS_IMPORT_OPTIONAL(device_unregister_loss_callbacks);
|
||||
#elif __linux__
|
||||
|
||||
@@ -266,6 +266,7 @@ struct gs_exports {
|
||||
gs_samplerstate_t *sampler);
|
||||
|
||||
bool (*device_nv12_available)(gs_device_t *device);
|
||||
bool (*device_p010_available)(gs_device_t *device);
|
||||
|
||||
void (*device_debug_marker_begin)(gs_device_t *device,
|
||||
const char *markername,
|
||||
@@ -323,10 +324,18 @@ struct gs_exports {
|
||||
gs_texture_t **tex_uv,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t flags);
|
||||
bool (*device_texture_create_p010)(gs_device_t *device,
|
||||
gs_texture_t **tex_y,
|
||||
gs_texture_t **tex_uv,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t flags);
|
||||
|
||||
gs_stagesurf_t *(*device_stagesurface_create_nv12)(gs_device_t *device,
|
||||
uint32_t width,
|
||||
uint32_t height);
|
||||
gs_stagesurf_t *(*device_stagesurface_create_p010)(gs_device_t *device,
|
||||
uint32_t width,
|
||||
uint32_t height);
|
||||
void (*device_register_loss_callbacks)(
|
||||
gs_device_t *device, const struct gs_device_loss *callbacks);
|
||||
void (*device_unregister_loss_callbacks)(gs_device_t *device,
|
||||
|
||||
@@ -2795,6 +2795,18 @@ bool gs_nv12_available(void)
|
||||
thread_graphics->device);
|
||||
}
|
||||
|
||||
bool gs_p010_available(void)
|
||||
{
|
||||
if (!gs_valid("gs_p010_available"))
|
||||
return false;
|
||||
|
||||
if (!thread_graphics->exports.device_p010_available)
|
||||
return false;
|
||||
|
||||
return thread_graphics->exports.device_p010_available(
|
||||
thread_graphics->device);
|
||||
}
|
||||
|
||||
void gs_debug_marker_begin(const float color[4], const char *markername)
|
||||
{
|
||||
if (!gs_valid("gs_debug_marker_begin"))
|
||||
@@ -3118,6 +3130,45 @@ bool gs_texture_create_nv12(gs_texture_t **tex_y, gs_texture_t **tex_uv,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool gs_texture_create_p010(gs_texture_t **tex_y, gs_texture_t **tex_uv,
|
||||
uint32_t width, uint32_t height, uint32_t flags)
|
||||
{
|
||||
graphics_t *graphics = thread_graphics;
|
||||
bool success = false;
|
||||
|
||||
if (!gs_valid("gs_texture_create_p010"))
|
||||
return false;
|
||||
|
||||
if ((width & 1) == 1 || (height & 1) == 1) {
|
||||
blog(LOG_ERROR, "P010 textures must have dimensions "
|
||||
"divisible by 2.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (graphics->exports.device_texture_create_p010) {
|
||||
success = graphics->exports.device_texture_create_p010(
|
||||
graphics->device, tex_y, tex_uv, width, height, flags);
|
||||
if (success)
|
||||
return true;
|
||||
}
|
||||
|
||||
*tex_y = gs_texture_create(width, height, GS_R16, 1, NULL, flags);
|
||||
*tex_uv = gs_texture_create(width / 2, height / 2, GS_RG16, 1, NULL,
|
||||
flags);
|
||||
|
||||
if (!*tex_y || !*tex_uv) {
|
||||
if (*tex_y)
|
||||
gs_texture_destroy(*tex_y);
|
||||
if (*tex_uv)
|
||||
gs_texture_destroy(*tex_uv);
|
||||
*tex_y = NULL;
|
||||
*tex_uv = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
gs_stagesurf_t *gs_stagesurface_create_nv12(uint32_t width, uint32_t height)
|
||||
{
|
||||
graphics_t *graphics = thread_graphics;
|
||||
@@ -3138,6 +3189,26 @@ gs_stagesurf_t *gs_stagesurface_create_nv12(uint32_t width, uint32_t height)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gs_stagesurf_t *gs_stagesurface_create_p010(uint32_t width, uint32_t height)
|
||||
{
|
||||
graphics_t *graphics = thread_graphics;
|
||||
|
||||
if (!gs_valid("gs_stagesurface_create_p010"))
|
||||
return NULL;
|
||||
|
||||
if ((width & 1) == 1 || (height & 1) == 1) {
|
||||
blog(LOG_ERROR, "P010 textures must have dimensions "
|
||||
"divisible by 2.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (graphics->exports.device_stagesurface_create_p010)
|
||||
return graphics->exports.device_stagesurface_create_p010(
|
||||
graphics->device, width, height);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void gs_register_loss_callbacks(const struct gs_device_loss *callbacks)
|
||||
{
|
||||
graphics_t *graphics = thread_graphics;
|
||||
|
||||
@@ -835,6 +835,7 @@ EXPORT bool gs_timer_range_get_data(gs_timer_range_t *range, bool *disjoint,
|
||||
uint64_t *frequency);
|
||||
|
||||
EXPORT bool gs_nv12_available(void);
|
||||
EXPORT bool gs_p010_available(void);
|
||||
|
||||
#define GS_USE_DEBUG_MARKERS 0
|
||||
#if GS_USE_DEBUG_MARKERS
|
||||
@@ -931,9 +932,14 @@ EXPORT int gs_texture_release_sync(gs_texture_t *tex, uint64_t key);
|
||||
EXPORT bool gs_texture_create_nv12(gs_texture_t **tex_y, gs_texture_t **tex_uv,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t flags);
|
||||
EXPORT bool gs_texture_create_p010(gs_texture_t **tex_y, gs_texture_t **tex_uv,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t flags);
|
||||
|
||||
EXPORT gs_stagesurf_t *gs_stagesurface_create_nv12(uint32_t width,
|
||||
uint32_t height);
|
||||
EXPORT gs_stagesurf_t *gs_stagesurface_create_p010(uint32_t width,
|
||||
uint32_t height);
|
||||
|
||||
EXPORT void gs_register_loss_callbacks(const struct gs_device_loss *callbacks);
|
||||
EXPORT void gs_unregister_loss_callbacks(void *data);
|
||||
|
||||
Reference in New Issue
Block a user