0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00
Commit Graph

241 Commits

Author SHA1 Message Date
Ryan Foster
be98cee2a0 Fix various typos across multiple modules 2017-04-25 22:39:42 -04:00
Ryan Foster
bfed33aa77 libobs-opengl: Log OpenGL version on all systems
This commit logs the OpenGL version on all operating systems and brings
the OpenGL subsystem's initialization logging more in line with the
D3D11 logging to make logs more uniform.
2017-04-23 19:42:24 -04:00
Richard Stanway
8b640fae24
Fix various null pointer issues detected by Coverity 2017-02-25 16:45:45 +01:00
Lasse Dalegaard
ebd837d605 libobs-opengl: Add xcb message poll to empty out the queue
The xcb message queue is not currently emptied.  If errors are generated
by any void requests the message queue will simply fill up and messages
will never be deleted.

Due to a (currently unknown) other problem this happens for me, and
results in OBS using up all memory with a queue that will never be
emptied.

Here we add a poll loop that will empty the xcb message queue and
discard the messages.  While this means that errors are still not
handled, OBS wont end up crashing either.

Closes jp9000/obs-studio#675
2016-11-24 12:55:51 -08:00
jp9000
234fddcf56 libobs-opengl: Add warning when used on windows 2016-11-20 01:48:16 -08:00
jp9000
4dc0024198 libobs/graphics: Add ability to set shader texture sampler
(Note: This also modifies libobs-d3d11 and libobs-opengl)

Allows overriding the sampler for a specific shader parameter.
2016-06-29 04:15:38 -07:00
jp9000
92af243a27 libobs-opengl: Fix bug with texelFetch shader intrinsic
This is supposed to assign -1 to the sampler_id to indicate that no
sampler need be assigned for the texture, but instead it was leaving the
variable with uninitialized data, resulting in a crash when used.
2016-04-19 19:42:27 -07:00
jp9000
ad0ee4d2d8 libobs-opengl: Bind index buffers to VAO
To be able to use index buffers, they must also be bound to a vertex
array object along with the vertex buffers.

Ideally, if there are multiple index buffers for a vertex buffer,
separate VAOs should be created for each combination.
2016-04-19 15:35:05 -07:00
jp9000
8e4fdbbc20 libobs-opengl: Fix type when binding index buffers
GL_ARRAY_BUFFER is for vertex buffers, GL_ELEMENT_ARRAY_BUFFER is for
index buffers.
2016-04-19 15:29:32 -07:00
jp9000
9a22ebdc71 libobs-opengl: Fix sampler not being assigned to texture 2016-03-22 12:01:35 -07:00
John R. Bradley
2278051985 libobs-opengl: Make sampler optional when binding textures 2016-03-21 21:22:29 -07:00
John R. Bradley
3dede60384 libobs-opengl: Add handling of Load(float3) w/ texelFetch 2016-03-21 21:22:29 -07:00
John R. Bradley
acf640b40c libobs-opengl: Allow omission of sampler in texture calls 2016-03-21 21:22:28 -07:00
John Bradley
431a02459d libobs/graphics: Add int vector support to shaders 2016-03-21 21:22:28 -07:00
jp9000
ddc8e6fde2 libobs-opengl: Fix GS_A8 texture format
The non-internal format should be set to R8, and then swizzle is used to
set the red channel to the alpha channel.
2016-03-10 00:38:19 -08:00
jp9000
9cded466dc libobs-opengl: Disable v-sync when drawing on linux
Prevents glXSwapBuffers from stalling.  It would have to stall and wait
for the next frame for each and every single additional swap chain.
2016-01-25 17:29:09 -08:00
jp9000
ccfd57d100 libobs/graphics: Rename inconsistent function names
Renames functions:
gs_shader_setmatrix3 -> gs_shader_set_matrix3
gs_voltexture_getdepth -> gs_voltexture_get_depth
2015-10-21 07:46:43 -07:00
repeat
f7e4a79517 libobs-opengl: Terminate visual attribs with None
(Jim) The documentation for glXChooseFBConfig states that the last value
of the visual attributes array must be 'None'.  Fixes potential
initialization issues with certain drivers.

Closes jp9000/obs-studio#486
2015-10-18 01:04:12 -07:00
michael bishop
cd7a648ba4 libobs-opengl: Use bfree instead of free
The variable is allocated with a bmalloc -- not a malloc.

Closes jp9000/obs-studio#473
2015-09-11 16:07:00 -07:00
jp9000
04e4ca1d53 libobs-opengl: Remove windowless context #error 2015-08-05 01:07:21 -07:00
jp9000
09a18b6f6d libobs-opengl: Use windowless context (X11)
(Non-compiling commit: windowless-context branch)

In the land of X11, life is suffering.

Suffering aside, X11 is capable of a hardware-accelerated windowless
context by using a GLXPbuffer in conjunction with glXMakeContextCurrent.
2015-08-05 01:07:20 -07:00
jp9000
e5e168e930 libobs-opengl: Use windowless context (windows)
(Non-compiling commit: windowless-context branch)

On windows, you can just create a hidden window as the "main" opengl
window to get the equivalent of a windowless context.  You might be able
to do it without a window, but honestly it's more trouble than it's
worth.
2015-08-05 01:07:19 -07:00
jp9000
ce1014c417 libobs-opengl: Use windowless context (cocoa)
(Non-compiling commit: windowless-context branch)

On cocoa, windowless contexts appear to be no problem.  You just don't
set a view or just clear the view.
2015-08-05 01:07:18 -07:00
jp9000
a496f64de4 libobs-opengl: Implement windowless context
(Non-compiling commit: windowless-context branch)
2015-08-05 01:07:17 -07:00
jp9000
58b49f68a5 libobs-opengl: Add windowless context #error 2015-08-05 01:07:05 -07:00
jp9000
ec69bcb15e libobs-opengl: Add X11 error handler (for logging) 2015-07-30 18:41:46 -07:00
jp9000
05a191618f libobs-opengl: Only flush if no active swap on OSX
glFlush is somewhat implementation-specific; on OSX for example, it is
additionally used to draw to a view.  However, we're already using the
Objective-C function flushBuffer, which apparently calls glFlush
internally anyway to draw to views.  That means that we're superfluously
calling glFlush most of the time if there's an active swap chain.  So
instead, only call glFlush when there are no active swap chains on OSX.
2015-07-30 17:59:34 -07:00
jp9000
de65407ac4 libobs-opengl: Make sure current swap is valid 2015-07-30 17:28:40 -07:00
jp9000
be52fa26f9 Add gs_blend_function_separate
This allows the ability to separate the blend states of color and alpha.

The default blend state has also changed so that alpha is always added
together to ensure that the destination image always gets an alpha value
that is actually usable after the operation (for render targets).

Old default state:
  color source: GS_BLEND_SRCALPHA, color dest: GS_BLEND_INVSRCALPHA
  alpha source: GS_BLEND_SRCALPHA, alpha dest: GS_BLEND_INVSRCALPHA

New default state:
  color source: GS_BLEND_SRCALPHA, color dest: GS_BLEND_INVSRCALPHA
  alpha source: GS_BLEND_ONE,      alpha dest: GS_BLEND_ONE
2015-03-27 11:18:02 -07:00
jp9000
2abf7b057a libobs-opengl: Fix bug switching render targets
If a render target was switched from one to another and then back
consecutively, the texture would not get reattached at the last point
due to the fact that the cur_render_target variable of the FBO storage
structure would already be set to that texture, and then it would never
get reattached because it thought it was already using that render
target.

So to fix this, any time a render target legitimately changes from one
to another, it sets the cur_render_target and cur_zstencil_buffer
variables of the FBO structure to null.
2015-03-22 18:38:47 -07:00
jp9000
86e56a5c4e libobs-opengl: Do not fail if shader param unused
I encountered a scenario where effects might reference shader parameters
that may not potentially exist, this isn't particularly a bad thing that
needs to return failure.  It just needs to gracefully ignore it.
2015-03-22 18:38:46 -07:00
jp9000
2fa37a1f2e libobs-opengl: Fix render targets being flipped
When render targets are used, they output to the render target inverted
due to the way that opengl works.  This fixes that issue by inverting
the projection matrix so that it renders the image upside down and
inverting the front face from counterclockwise to clockwise.
2015-03-22 18:38:45 -07:00
jp9000
84d16fed8e libobs-opengl: Assign texture units to shader vars
Texture units were not being properly associated with the shader uniform
variables.
2015-03-22 18:38:45 -07:00
Kevin Tardif
c293c17620 Generate proper DL_OPENGL value for linux
Since we rely on the dynamic linker to find the library for us via
dlopen(), we need to have DL_OPENGL be .so.N, not the full library
filename, as ldconfig doesn't cache the full filename

Use of TARGET_SONAME_FILE requires the library to be marked as SHARED,
not MODULE

This closes pull request #370
2015-02-16 15:28:42 -05:00
jp9000
5dfecab15c Fix windows printf format warnings (from mingw) 2015-02-09 03:49:14 -08:00
jp9000
0e81b0a2ac libobs-opengl: Use original lib naming for mac/win
On mac and windows, the libraries are always meant to be portable,
therefore the naming convention does not need to change for each
revision.  For linux this makes sense; windows and mac not so much.
2015-01-13 21:38:47 -08:00
Carl Fürstenberg
6095e7ef51 Add SOVERSION to libobs-opengl
Because libobs-opengl is a public library, it's customary to have SONAME
embedded in the library file.  Also remove the prefix override and
remove the prefixing "lib" from the output name.  This also requires us
to pass the library file name to dlopen invocations.
2015-01-13 17:51:38 -08:00
jp9000
8ba279fa45 libobs-opengl: Change a log message to debug
The anisotropy message isn't particularly useful for users.
2015-01-05 02:45:38 -08:00
Zachary Lund
de6e997264 Move from libX11/GLX to XCB/libX11/GLX. 2014-12-19 19:23:08 -08:00
jp9000
e88632ed73 libobs-opengl: Don't display unimportant messages
The glDebugMessageCallback function will set a callback that will relay
all messages coming from the driver (on supported drivers at least).
For nvidia, sometimes there are a lot of irrelevant messages, which is
nice depending on the type of application you're writing.

I actually at first thought these messages were important, but it turns
out that they're almost always irrelevant and not actually warnings.
Most of the messages at a certain type/severity are mostly for debugging
purposes or minor hints about how to maximize performance, so
unfortunately there ends up being a lot of pointless spam in the debug
output.

The particular performance messages are related to optimizations you can
get via multithreading, and are optimizations you would expect for games
more than for this type of application.  They don't really apply for our
use cases most of the time.

High severity messages however are not omitted regardless of message
type.

These messages can be enabled again by simply defining the
SHOW_ALL_GL_MESSAGES macro.
2014-12-09 14:21:02 -08:00
jp9000
caa32cb6d1 Add support for shared textures to graphics API 2014-10-13 21:56:42 -07:00
jp9000
41fad2d1a4 (API Change) Use const params where applicable
This Fixes a minor flaw with the API where data had to always be mutable
to be usable by the API.

Functions that do not modify the fundamental underlying data of a
structure should be marked as constant, both for safety and to signify
that the parameter is input only and will not be modified by the
function using it.
2014-09-26 17:23:07 -07:00
GoaLitiuM
10f5d7f3aa Fixed NULL pointer dereferencing in linked lists 2014-09-27 01:35:36 +03:00
jp9000
0ef7a3f3d0 libobs-opengl: Fix styling (80 column limit) 2014-09-25 21:48:16 -07:00
jp9000
c9df41c1e2 (API Change) Remove pointers from all typedefs
Typedef pointers are unsafe.  If you do:
typedef struct bla *bla_t;
then you cannot use it as a constant, such as: const bla_t, because
that constant will be to the pointer itself rather than to the
underlying data.  I admit this was a fundamental mistake that must
be corrected.

All typedefs that were pointer types will now have their pointers
removed from the type itself, and the pointers will be used when they
are actually used as variables/parameters/returns instead.

This does not break ABI though, which is pretty nice.
2014-09-25 21:48:11 -07:00
jp9000
732d24caa1 Remove unused variables 2014-09-19 18:46:25 -07:00
jp9000
3967c6354a Replace ARB_separate_shader_objects extension
This replaces the ARB_separate_shader_objects extension with traditional
linked shaders.  I was able to get the existing system to use linked
shaders without having to change any libobs graphics API.

This essentially creates a linked list of shader programs with
references to the shaders they link.  Before draw, it searches that
linked list for a particular pixel/vertex shader pair, and the linked
program associated with it.  If no matching program exists, it creates
the program.
2014-09-19 18:23:51 -07:00
jp9000
4654eca6b8 Remove GL shader debug text 2014-08-21 03:04:20 -07:00
jp9000
5780f3f177 (API Change) Improve graphics API consistency
Summary:
- Prefix all graphics subsystem names with gs_ or GS_
- Unsquish funciton names (for example _setfloat to _set_float)
- Changed create functions to be more consistent with the rest of the
  API elsewhere.  For exmaple, instead of
  gs_create_texture/gs_texture_destroy, it's now
  gs_texture_create/gs_texture_destroy
- Renamed gs_stencil_op enum to gs_stencil_op_type

From:                            To:
-----------------------------------------------------------
tvertarray                       gs_tvertarray
vb_data                          gs_vb_data
vbdata_create                    gs_vbdata_create
vbdata_destroy                   gs_vbdata_destroy
shader_param                     gs_shader_param
gs_effect                        gs_effect
effect_technique                 gs_effect_technique
effect_pass                      gs_effect_pass
effect_param                     gs_effect_param
texture_t                        gs_texture_t
stagesurf_t                      gs_stagesurf_t
zstencil_t                       gs_zstencil_t
vertbuffer_t                     gs_vertbuffer_t
indexbuffer_t                    gs_indexbuffer_t
samplerstate_t                   gs_samplerstate_t
swapchain_t                      gs_swapchain_t
texrender_t                      gs_texrender_t
shader_t                         gs_shader_t
sparam_t                         gs_sparam_t
effect_t                         gs_effect_t
technique_t                      gs_technique_t
eparam_t                         gs_eparam_t
device_t                         gs_device_t
graphics_t                       graphics_t
shader_param_type                gs_shader_param_type
SHADER_PARAM_UNKNOWN             GS_SHADER_PARAM_UNKNOWN
SHADER_PARAM_BOOL                GS_SHADER_PARAM_BOOL
SHADER_PARAM_FLOAT               GS_SHADER_PARAM_FLOAT
SHADER_PARAM_INT                 GS_SHADER_PARAM_INT
SHADER_PARAM_STRING              GS_SHADER_PARAM_STRING
SHADER_PARAM_VEC2                GS_SHADER_PARAM_VEC2
SHADER_PARAM_VEC3                GS_SHADER_PARAM_VEC3
SHADER_PARAM_VEC4                GS_SHADER_PARAM_VEC4
SHADER_PARAM_MATRIX4X4           GS_SHADER_PARAM_MATRIX4X4
SHADER_PARAM_TEXTURE             GS_SHADER_PARAM_TEXTURE
shader_param_info                gs_shader_param_info
shader_type                      gs_shader_type
SHADER_VERTEX                    GS_SHADER_VERTEX
SHADER_PIXEL                     GS_SHADER_PIXEL
shader_destroy                   gs_shader_destroy
shader_numparams                 gs_shader_get_num_params
shader_getparambyidx             gs_shader_get_param_by_idx
shader_getparambyname            gs_shader_get_param_by_name
shader_getviewprojmatrix         gs_shader_get_viewproj_matrix
shader_getworldmatrix            gs_shader_get_world_matrix
shader_getparaminfo              gs_shader_get_param_info
shader_setbool                   gs_shader_set_bool
shader_setfloat                  gs_shader_set_float
shader_setint                    gs_shader_set_int
shader_setmatrix3                gs_shader_setmatrix3
shader_setmatrix4                gs_shader_set_matrix4
shader_setvec2                   gs_shader_set_vec2
shader_setvec3                   gs_shader_set_vec3
shader_setvec4                   gs_shader_set_vec4
shader_settexture                gs_shader_set_texture
shader_setval                    gs_shader_set_val
shader_setdefault                gs_shader_set_default
effect_property_type             gs_effect_property_type
EFFECT_NONE                      GS_EFFECT_NONE
EFFECT_BOOL                      GS_EFFECT_BOOL
EFFECT_FLOAT                     GS_EFFECT_FLOAT
EFFECT_COLOR                     GS_EFFECT_COLOR
EFFECT_TEXTURE                   GS_EFFECT_TEXTURE
effect_param_info                gs_effect_param_info
effect_destroy                   gs_effect_destroy
effect_gettechnique              gs_effect_get_technique
technique_begin                  gs_technique_begin
technique_end                    gs_technique_end
technique_beginpass              gs_technique_begin_pass
technique_beginpassbyname        gs_technique_begin_pass_by_name
technique_endpass                gs_technique_end_pass
effect_numparams                 gs_effect_get_num_params
effect_getparambyidx             gs_effect_get_param_by_idx
effect_getparambyname            gs_effect_get_param_by_name
effect_updateparams              gs_effect_update_params
effect_getviewprojmatrix         gs_effect_get_viewproj_matrix
effect_getworldmatrix            gs_effect_get_world_matrix
effect_getparaminfo              gs_effect_get_param_info
effect_setbool                   gs_effect_set_bool
effect_setfloat                  gs_effect_set_float
effect_setint                    gs_effect_set_int
effect_setmatrix4                gs_effect_set_matrix4
effect_setvec2                   gs_effect_set_vec2
effect_setvec3                   gs_effect_set_vec3
effect_setvec4                   gs_effect_set_vec4
effect_settexture                gs_effect_set_texture
effect_setval                    gs_effect_set_val
effect_setdefault                gs_effect_set_default
texrender_create                 gs_texrender_create
texrender_destroy                gs_texrender_destroy
texrender_begin                  gs_texrender_begin
texrender_end                    gs_texrender_end
texrender_reset                  gs_texrender_reset
texrender_gettexture             gs_texrender_get_texture
GS_BUILDMIPMAPS                  GS_BUILD_MIPMAPS
GS_RENDERTARGET                  GS_RENDER_TARGET
gs_device_name                   gs_get_device_name
gs_device_type                   gs_get_device_type
gs_entercontext                  gs_enter_context
gs_leavecontext                  gs_leave_context
gs_getcontext                    gs_get_context
gs_renderstart                   gs_render_start
gs_renderstop                    gs_render_stop
gs_rendersave                    gs_render_save
gs_getinput                      gs_get_input
gs_geteffect                     gs_get_effect
gs_create_effect_from_file       gs_effect_create_from_file
gs_create_effect                 gs_effect_create
gs_create_vertexshader_from_file gs_vertexshader_create_from_file
gs_create_pixelshader_from_file  gs_pixelshader_create_from_file
gs_create_texture_from_file      gs_texture_create_from_file
gs_resetviewport                 gs_reset_viewport
gs_set2dmode                     gs_set_2d_mode
gs_set3dmode                     gs_set_3d_mode
gs_create_swapchain              gs_swapchain_create
gs_getsize                       gs_get_size
gs_getwidth                      gs_get_width
gs_getheight                     gs_get_height
gs_create_texture                gs_texture_create
gs_create_cubetexture            gs_cubetexture_create
gs_create_volumetexture          gs_voltexture_create
gs_create_zstencil               gs_zstencil_create
gs_create_stagesurface           gs_stagesurface_create
gs_create_samplerstate           gs_samplerstate_create
gs_create_vertexshader           gs_vertexshader_create
gs_create_pixelshader            gs_pixelshader_create
gs_create_vertexbuffer           gs_vertexbuffer_create
gs_create_indexbuffer            gs_indexbuffer_create
gs_gettexturetype                gs_get_texture_type
gs_load_defaultsamplerstate      gs_load_default_samplerstate
gs_getvertexshader               gs_get_vertex_shader
gs_getpixelshader                gs_get_pixel_shader
gs_getrendertarget               gs_get_render_target
gs_getzstenciltarget             gs_get_zstencil_target
gs_setrendertarget               gs_set_render_target
gs_setcuberendertarget           gs_set_cube_render_target
gs_beginscene                    gs_begin_scene
gs_draw                          gs_draw
gs_endscene                      gs_end_scene
gs_setcullmode                   gs_set_cull_mode
gs_getcullmode                   gs_get_cull_mode
gs_enable_depthtest              gs_enable_depth_test
gs_enable_stenciltest            gs_enable_stencil_test
gs_enable_stencilwrite           gs_enable_stencil_write
gs_blendfunction                 gs_blend_function
gs_depthfunction                 gs_depth_function
gs_stencilfunction               gs_stencil_function
gs_stencilop                     gs_stencil_op
gs_setviewport                   gs_set_viewport
gs_getviewport                   gs_get_viewport
gs_setscissorrect                gs_set_scissor_rect
gs_create_texture_from_iosurface gs_texture_create_from_iosurface
gs_create_gdi_texture            gs_texture_create_gdi
gs_is_compressed_format          gs_is_compressed_format
gs_num_total_levels              gs_get_total_levels
texture_setimage                 gs_texture_set_image
cubetexture_setimage             gs_cubetexture_set_image
swapchain_destroy                gs_swapchain_destroy
texture_destroy                  gs_texture_destroy
texture_getwidth                 gs_texture_get_width
texture_getheight                gs_texture_get_height
texture_getcolorformat           gs_texture_get_color_format
texture_map                      gs_texture_map
texture_unmap                    gs_texture_unmap
texture_isrect                   gs_texture_is_rect
texture_getobj                   gs_texture_get_obj
cubetexture_destroy              gs_cubetexture_destroy
cubetexture_getsize              gs_cubetexture_get_size
cubetexture_getcolorformat       gs_cubetexture_get_color_format
volumetexture_destroy            gs_voltexture_destroy
volumetexture_getwidth           gs_voltexture_get_width
volumetexture_getheight          gs_voltexture_get_height
volumetexture_getdepth           gs_voltexture_getdepth
volumetexture_getcolorformat     gs_voltexture_get_color_format
stagesurface_destroy             gs_stagesurface_destroy
stagesurface_getwidth            gs_stagesurface_get_width
stagesurface_getheight           gs_stagesurface_get_height
stagesurface_getcolorformat      gs_stagesurface_get_color_format
stagesurface_map                 gs_stagesurface_map
stagesurface_unmap               gs_stagesurface_unmap
zstencil_destroy                 gs_zstencil_destroy
samplerstate_destroy             gs_samplerstate_destroy
vertexbuffer_destroy             gs_vertexbuffer_destroy
vertexbuffer_flush               gs_vertexbuffer_flush
vertexbuffer_getdata             gs_vertexbuffer_get_data
indexbuffer_destroy              gs_indexbuffer_destroy
indexbuffer_flush                gs_indexbuffer_flush
indexbuffer_getdata              gs_indexbuffer_get_data
indexbuffer_numindices           gs_indexbuffer_get_num_indices
indexbuffer_gettype              gs_indexbuffer_get_type
texture_rebind_iosurface         gs_texture_rebind_iosurface
texture_get_dc                   gs_texture_get_dc
texture_release_dc               gs_texture_release_dc
2014-08-09 11:57:38 -07:00
jp9000
9d300685ca (API Change) Unsquish libobs/util
Changed:                      To:
-----------------------------------------------------------
dstr_isempty                  dstr_is_empty
cf_lexer_gettokens            cf_lexer_get_tokens
cf_preprocessor_gettokens     cf_preprocessor_get_tokens
2014-08-09 11:57:37 -07:00