2013-09-30 19:37:13 -07:00
|
|
|
/******************************************************************************
|
|
|
|
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2013-12-02 21:24:38 -08:00
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
2013-09-30 19:37:13 -07:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#include "../util/base.h"
|
|
|
|
#include "../util/dstr.h"
|
|
|
|
#include "../util/platform.h"
|
|
|
|
#include "graphics-internal.h"
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
#define GRAPHICS_IMPORT(func) \
|
|
|
|
do { \
|
|
|
|
exports->func = os_dlsym(module, #func); \
|
|
|
|
if (!exports->func) { \
|
|
|
|
success = false; \
|
|
|
|
blog(LOG_ERROR, \
|
|
|
|
"Could not load function '%s' from " \
|
|
|
|
"module '%s'", \
|
|
|
|
#func, module_name); \
|
|
|
|
} \
|
2013-09-30 19:37:13 -07:00
|
|
|
} while (false)
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
#define GRAPHICS_IMPORT_OPTIONAL(func) \
|
|
|
|
do { \
|
2013-12-20 11:36:38 -08:00
|
|
|
exports->func = os_dlsym(module, #func); \
|
|
|
|
} while (false)
|
|
|
|
|
2013-09-30 19:37:13 -07:00
|
|
|
bool load_graphics_imports(struct gs_exports *exports, void *module,
|
2019-06-22 22:13:45 -07:00
|
|
|
const char *module_name)
|
2013-09-30 19:37:13 -07:00
|
|
|
{
|
|
|
|
bool success = true;
|
|
|
|
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(device_get_name);
|
|
|
|
GRAPHICS_IMPORT(device_get_type);
|
2015-01-14 21:08:33 -08:00
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_enum_adapters);
|
2014-02-16 18:28:21 -08:00
|
|
|
GRAPHICS_IMPORT(device_preprocessor_name);
|
2013-09-30 19:37:13 -07:00
|
|
|
GRAPHICS_IMPORT(device_create);
|
|
|
|
GRAPHICS_IMPORT(device_destroy);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(device_enter_context);
|
|
|
|
GRAPHICS_IMPORT(device_leave_context);
|
2019-08-29 12:43:10 -07:00
|
|
|
GRAPHICS_IMPORT(device_get_device_obj);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(device_swapchain_create);
|
2013-09-30 19:37:13 -07:00
|
|
|
GRAPHICS_IMPORT(device_resize);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(device_get_size);
|
|
|
|
GRAPHICS_IMPORT(device_get_width);
|
|
|
|
GRAPHICS_IMPORT(device_get_height);
|
|
|
|
GRAPHICS_IMPORT(device_texture_create);
|
|
|
|
GRAPHICS_IMPORT(device_cubetexture_create);
|
|
|
|
GRAPHICS_IMPORT(device_voltexture_create);
|
|
|
|
GRAPHICS_IMPORT(device_zstencil_create);
|
|
|
|
GRAPHICS_IMPORT(device_stagesurface_create);
|
|
|
|
GRAPHICS_IMPORT(device_samplerstate_create);
|
|
|
|
GRAPHICS_IMPORT(device_vertexshader_create);
|
|
|
|
GRAPHICS_IMPORT(device_pixelshader_create);
|
|
|
|
GRAPHICS_IMPORT(device_vertexbuffer_create);
|
|
|
|
GRAPHICS_IMPORT(device_indexbuffer_create);
|
2019-07-27 13:31:07 -07:00
|
|
|
GRAPHICS_IMPORT(device_timer_create);
|
|
|
|
GRAPHICS_IMPORT(device_timer_range_create);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(device_get_texture_type);
|
2013-09-30 19:37:13 -07:00
|
|
|
GRAPHICS_IMPORT(device_load_vertexbuffer);
|
|
|
|
GRAPHICS_IMPORT(device_load_indexbuffer);
|
|
|
|
GRAPHICS_IMPORT(device_load_texture);
|
|
|
|
GRAPHICS_IMPORT(device_load_samplerstate);
|
|
|
|
GRAPHICS_IMPORT(device_load_vertexshader);
|
|
|
|
GRAPHICS_IMPORT(device_load_pixelshader);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(device_load_default_samplerstate);
|
|
|
|
GRAPHICS_IMPORT(device_get_vertex_shader);
|
|
|
|
GRAPHICS_IMPORT(device_get_pixel_shader);
|
|
|
|
GRAPHICS_IMPORT(device_get_render_target);
|
|
|
|
GRAPHICS_IMPORT(device_get_zstencil_target);
|
|
|
|
GRAPHICS_IMPORT(device_set_render_target);
|
|
|
|
GRAPHICS_IMPORT(device_set_cube_render_target);
|
libobs: Add dormant SRGB format support
GS_RGBA, GS_BGRX, and GS_BGRA now use TYPELESS DXGI formats, so we can
alias them between UNORM and UNORM_SRGB as necessary. GS_RGBA_UNORM,
GS_BGRX_UNORM, and GS_BGRA_UNORM have been added to support straight
UNORM types, which Windows requires for sharing textures from D3D9 and
OpenGL. The D3D path aliases via views, and GL aliases via
GL_EXT_texture_sRGB_decode/GL_FRAMEBUFFER_SRGB.
A significant amount of code has changed in the D3D/GL backends, but the
concepts are simple. On the D3D side, we need separate SRVs and RTVs to
support nonlinear/linear reads and writes. On the GL side, we need to
set the proper GL parameters to emulate the same.
Add gs_enable_framebuffer_srgb/gs_framebuffer_srgb_enabled to set/get
the framebuffer as SRGB or not.
Add gs_linear_srgb_active/gs_set_linear_srgb to instruct sources that
they should render as SRGB. Legacy sources can ignore this setting
without regression.
Update obs_source_draw to use linear SRGB as needed.
Update render_filter_tex to use linear SRGB as needed.
Add gs_effect_set_texture_srgb next to gs_effect_set_texture to set
texture with SRGB view instead.
Add SRGB helpers for vec4 struct.
Create GDI-compatible textures without SRGB support. Doesn't seem to
work with SRGB formats.
2021-01-19 15:00:51 -08:00
|
|
|
GRAPHICS_IMPORT(device_enable_framebuffer_srgb);
|
|
|
|
GRAPHICS_IMPORT(device_framebuffer_srgb_enabled);
|
2014-04-09 11:04:58 -07:00
|
|
|
GRAPHICS_IMPORT(device_copy_texture_region);
|
2013-09-30 19:37:13 -07:00
|
|
|
GRAPHICS_IMPORT(device_copy_texture);
|
|
|
|
GRAPHICS_IMPORT(device_stage_texture);
|
2019-10-10 21:06:01 -07:00
|
|
|
GRAPHICS_IMPORT(device_begin_frame);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(device_begin_scene);
|
2013-09-30 19:37:13 -07:00
|
|
|
GRAPHICS_IMPORT(device_draw);
|
|
|
|
GRAPHICS_IMPORT(device_load_swapchain);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(device_end_scene);
|
2013-09-30 19:37:13 -07:00
|
|
|
GRAPHICS_IMPORT(device_clear);
|
|
|
|
GRAPHICS_IMPORT(device_present);
|
2014-06-25 19:32:34 -07:00
|
|
|
GRAPHICS_IMPORT(device_flush);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(device_set_cull_mode);
|
|
|
|
GRAPHICS_IMPORT(device_get_cull_mode);
|
2013-09-30 19:37:13 -07:00
|
|
|
GRAPHICS_IMPORT(device_enable_blending);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(device_enable_depth_test);
|
|
|
|
GRAPHICS_IMPORT(device_enable_stencil_test);
|
|
|
|
GRAPHICS_IMPORT(device_enable_stencil_write);
|
2013-09-30 19:37:13 -07:00
|
|
|
GRAPHICS_IMPORT(device_enable_color);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(device_blend_function);
|
2015-03-27 11:18:02 -07:00
|
|
|
GRAPHICS_IMPORT(device_blend_function_separate);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(device_depth_function);
|
|
|
|
GRAPHICS_IMPORT(device_stencil_function);
|
|
|
|
GRAPHICS_IMPORT(device_stencil_op);
|
|
|
|
GRAPHICS_IMPORT(device_set_viewport);
|
|
|
|
GRAPHICS_IMPORT(device_get_viewport);
|
|
|
|
GRAPHICS_IMPORT(device_set_scissor_rect);
|
2013-09-30 19:37:13 -07:00
|
|
|
GRAPHICS_IMPORT(device_ortho);
|
|
|
|
GRAPHICS_IMPORT(device_frustum);
|
|
|
|
GRAPHICS_IMPORT(device_projection_push);
|
|
|
|
GRAPHICS_IMPORT(device_projection_pop);
|
|
|
|
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(gs_swapchain_destroy);
|
|
|
|
|
|
|
|
GRAPHICS_IMPORT(gs_texture_destroy);
|
|
|
|
GRAPHICS_IMPORT(gs_texture_get_width);
|
|
|
|
GRAPHICS_IMPORT(gs_texture_get_height);
|
|
|
|
GRAPHICS_IMPORT(gs_texture_get_color_format);
|
|
|
|
GRAPHICS_IMPORT(gs_texture_map);
|
|
|
|
GRAPHICS_IMPORT(gs_texture_unmap);
|
|
|
|
GRAPHICS_IMPORT_OPTIONAL(gs_texture_is_rect);
|
|
|
|
GRAPHICS_IMPORT(gs_texture_get_obj);
|
|
|
|
|
|
|
|
GRAPHICS_IMPORT(gs_cubetexture_destroy);
|
|
|
|
GRAPHICS_IMPORT(gs_cubetexture_get_size);
|
|
|
|
GRAPHICS_IMPORT(gs_cubetexture_get_color_format);
|
|
|
|
|
|
|
|
GRAPHICS_IMPORT(gs_voltexture_destroy);
|
|
|
|
GRAPHICS_IMPORT(gs_voltexture_get_width);
|
|
|
|
GRAPHICS_IMPORT(gs_voltexture_get_height);
|
2015-10-21 07:43:02 -07:00
|
|
|
GRAPHICS_IMPORT(gs_voltexture_get_depth);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(gs_voltexture_get_color_format);
|
|
|
|
|
|
|
|
GRAPHICS_IMPORT(gs_stagesurface_destroy);
|
|
|
|
GRAPHICS_IMPORT(gs_stagesurface_get_width);
|
|
|
|
GRAPHICS_IMPORT(gs_stagesurface_get_height);
|
|
|
|
GRAPHICS_IMPORT(gs_stagesurface_get_color_format);
|
|
|
|
GRAPHICS_IMPORT(gs_stagesurface_map);
|
|
|
|
GRAPHICS_IMPORT(gs_stagesurface_unmap);
|
|
|
|
|
|
|
|
GRAPHICS_IMPORT(gs_zstencil_destroy);
|
|
|
|
|
|
|
|
GRAPHICS_IMPORT(gs_samplerstate_destroy);
|
|
|
|
|
|
|
|
GRAPHICS_IMPORT(gs_vertexbuffer_destroy);
|
|
|
|
GRAPHICS_IMPORT(gs_vertexbuffer_flush);
|
2017-11-27 02:19:48 -08:00
|
|
|
GRAPHICS_IMPORT(gs_vertexbuffer_flush_direct);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(gs_vertexbuffer_get_data);
|
|
|
|
|
|
|
|
GRAPHICS_IMPORT(gs_indexbuffer_destroy);
|
|
|
|
GRAPHICS_IMPORT(gs_indexbuffer_flush);
|
2017-11-27 02:19:48 -08:00
|
|
|
GRAPHICS_IMPORT(gs_indexbuffer_flush_direct);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(gs_indexbuffer_get_data);
|
|
|
|
GRAPHICS_IMPORT(gs_indexbuffer_get_num_indices);
|
|
|
|
GRAPHICS_IMPORT(gs_indexbuffer_get_type);
|
|
|
|
|
2019-07-27 13:31:07 -07:00
|
|
|
GRAPHICS_IMPORT(gs_timer_destroy);
|
|
|
|
GRAPHICS_IMPORT(gs_timer_begin);
|
|
|
|
GRAPHICS_IMPORT(gs_timer_end);
|
|
|
|
GRAPHICS_IMPORT(gs_timer_get_data);
|
|
|
|
GRAPHICS_IMPORT(gs_timer_range_destroy);
|
|
|
|
GRAPHICS_IMPORT(gs_timer_range_begin);
|
|
|
|
GRAPHICS_IMPORT(gs_timer_range_end);
|
|
|
|
GRAPHICS_IMPORT(gs_timer_range_get_data);
|
|
|
|
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(gs_shader_destroy);
|
|
|
|
GRAPHICS_IMPORT(gs_shader_get_num_params);
|
|
|
|
GRAPHICS_IMPORT(gs_shader_get_param_by_idx);
|
|
|
|
GRAPHICS_IMPORT(gs_shader_get_param_by_name);
|
|
|
|
GRAPHICS_IMPORT(gs_shader_get_viewproj_matrix);
|
|
|
|
GRAPHICS_IMPORT(gs_shader_get_world_matrix);
|
|
|
|
GRAPHICS_IMPORT(gs_shader_get_param_info);
|
|
|
|
GRAPHICS_IMPORT(gs_shader_set_bool);
|
|
|
|
GRAPHICS_IMPORT(gs_shader_set_float);
|
|
|
|
GRAPHICS_IMPORT(gs_shader_set_int);
|
2015-10-21 07:43:02 -07:00
|
|
|
GRAPHICS_IMPORT(gs_shader_set_matrix3);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(gs_shader_set_matrix4);
|
|
|
|
GRAPHICS_IMPORT(gs_shader_set_vec2);
|
|
|
|
GRAPHICS_IMPORT(gs_shader_set_vec3);
|
|
|
|
GRAPHICS_IMPORT(gs_shader_set_vec4);
|
|
|
|
GRAPHICS_IMPORT(gs_shader_set_texture);
|
|
|
|
GRAPHICS_IMPORT(gs_shader_set_val);
|
|
|
|
GRAPHICS_IMPORT(gs_shader_set_default);
|
2016-06-29 04:15:38 -07:00
|
|
|
GRAPHICS_IMPORT(gs_shader_set_next_sampler);
|
2013-09-30 19:37:13 -07:00
|
|
|
|
2018-10-05 03:15:13 -07:00
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_nv12_available);
|
|
|
|
|
2019-04-02 23:22:19 -07:00
|
|
|
GRAPHICS_IMPORT(device_debug_marker_begin);
|
|
|
|
GRAPHICS_IMPORT(device_debug_marker_end);
|
|
|
|
|
2013-12-23 07:34:56 -08:00
|
|
|
/* OSX/Cocoa specific functions */
|
2014-03-05 09:43:14 -08:00
|
|
|
#ifdef __APPLE__
|
2020-11-30 12:59:01 -08:00
|
|
|
GRAPHICS_IMPORT(device_shared_texture_available);
|
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_texture_open_shared);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_texture_create_from_iosurface);
|
|
|
|
GRAPHICS_IMPORT_OPTIONAL(gs_texture_rebind_iosurface);
|
2013-12-23 07:34:56 -08:00
|
|
|
|
2014-03-05 09:43:14 -08:00
|
|
|
/* win32 specific functions */
|
|
|
|
#elif _WIN32
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT(device_gdi_texture_available);
|
2014-10-13 21:41:09 -07:00
|
|
|
GRAPHICS_IMPORT(device_shared_texture_available);
|
2014-12-29 00:29:55 -08:00
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_get_duplicator_monitor_info);
|
2021-01-26 16:22:21 -08:00
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_duplicator_get_monitor_index);
|
2014-12-29 00:29:55 -08:00
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_duplicator_create);
|
|
|
|
GRAPHICS_IMPORT_OPTIONAL(gs_duplicator_destroy);
|
|
|
|
GRAPHICS_IMPORT_OPTIONAL(gs_duplicator_update_frame);
|
|
|
|
GRAPHICS_IMPORT_OPTIONAL(gs_duplicator_get_texture);
|
2014-08-07 23:42:07 -07:00
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_texture_create_gdi);
|
|
|
|
GRAPHICS_IMPORT_OPTIONAL(gs_texture_get_dc);
|
|
|
|
GRAPHICS_IMPORT_OPTIONAL(gs_texture_release_dc);
|
2014-10-13 21:41:09 -07:00
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_texture_open_shared);
|
2018-10-05 02:38:11 -07:00
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_texture_get_shared_handle);
|
2020-11-22 23:39:59 -08:00
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_texture_wrap_obj);
|
2018-10-05 02:38:11 -07:00
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_texture_acquire_sync);
|
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_texture_release_sync);
|
2018-10-05 03:15:13 -07:00
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_texture_create_nv12);
|
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_stagesurface_create_nv12);
|
2019-11-27 16:35:27 -08:00
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_register_loss_callbacks);
|
|
|
|
GRAPHICS_IMPORT_OPTIONAL(device_unregister_loss_callbacks);
|
2014-03-05 09:43:14 -08:00
|
|
|
#endif
|
|
|
|
|
2013-09-30 19:37:13 -07:00
|
|
|
return success;
|
|
|
|
}
|