Commit Graph

263 Commits (ad85a9fa2501a5913538e80b43e9ea8e9d551af4)

Author SHA1 Message Date
Colin Edwards ad85a9fa25 Apply clang-format to objective c code 2019-07-09 13:39:13 -05:00
jpark37 b8e5cf3a95 libobs-opengl: Empty VAO
Use an empty VAO for shaders that generate their own vertices.
2019-06-24 23:13:04 -05:00
jp9000 f53df7da64 clang-format: Apply formatting
Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed.  Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
2019-06-23 23:49:10 -07:00
James Park aa22b61e3e libobs: Full-screen triangle format conversions
The cache coherency of rasterization for full-screen passes is better
using an oversized triangle that is clipped rather than two triangles.
Traversal order of rasterization is GPU-specific, but will almost
certainly be better using an undivided primitive.

A smaller benefit is that quads along the diagonal are not evaluated
multiple times, but that's minor in comparison.

Redo format shaders to bypass vertex buffer, and input layout. Add
global shader bool "obs_glsl_compile" to make API-specific decisions,
i.e. handle upside-down UVs. gl_ortho is not needed for format
conversion because the vertex shader does not use ViewProj anymore.

This can be applied to more situations, but start small first.

Testbed full screen passes, Intel HD Graphics 530:
RGBA -> UYVX: 467 -> 439 us, ~6% savings
UYVX -> uv: 295 -> 239 us, ~19% savings
2019-06-18 22:29:07 -07:00
James Park 8bafa51d3b libobs: Fix GS_UNSIGNED_LONG definition
GS_UNSIGNED_LONG is defined as sizeof(long) in some places, making it 8
outside of Windows instead of 4 as it should be.

Fixes https://obsproject.com/mantis/view.php?id=1444
2019-04-21 21:25:35 -07:00
Jim 9480cc4fd2
Merge pull request #1675 from admshao/clear-linux-compiling-warnings
Clear linux compiling warnings
2019-04-14 04:21:21 -07:00
James Park 2996a6c06b libobs/graphics: Support debug markers
Add support for debug markers via D3DPERF API and KHR_debug. This makes
it easier to understand RenderDoc captures.

D3DPERF is preferred to ID3DUserDefinedAnnotation because it supports
colors. d3d9.lib is now linked in to support this.

This feature is disabled by default, and is controlled by
GS_USE_DEBUG_MARKERS.

From: obsproject/obs-studio#1799
2019-04-08 02:05:37 -07:00
Shaolin 64d0da1533 libobs-opengl: Clear some conversion and uncaught switch cases warnings 2019-03-29 06:22:14 -03:00
James Park 5fe128a047 libobs-opengl: Fix bad log string 2019-03-19 09:17:15 -07:00
Colin Edwards d7d5d6b87d libobs-opengl: Log shader compiler errors 2019-02-24 12:32:28 -06:00
Alex Anderson 4eac034814 libobs-opengl: Add int2-4 support
Closes obsproject/obs-studio#1506
2018-09-28 13:59:49 -07:00
Shaolin acd44b525e libobs-opengl: Store FBOs per texture instead of per device
The previous model stored a new FBO per texture width/height/format on
a array in the device struct. This allocated memory was only released
on gs_device_destroy (obs exit).

The new approach stores a FBO on gs_texture and the its info is
destroyed once the texture is deleted.
2018-08-31 19:00:20 -03:00
Shaolin 85c7669ad2 libobs-opengl: Fix segfault on access of invalid window
Once a window is invalid gl-x11::get_window_geometry will return 0
so just check if the returned geometry is a valid pointer before
trying to get its width/height.
2018-08-03 00:55:09 -03:00
Shaolin 4a266dc920 libobs-opengl: Improve X error handler message 2018-08-03 00:52:47 -03:00
Jim 8c0be08040
Merge pull request #1309 from nleseul/effect-arg-modifier
libobs: Handle 'in', 'out', and 'inout' keywords in shader parsers
2018-06-05 15:51:36 -07:00
nleseul 5a111cf073 libobs: Handle 'in', 'out', and 'inout' keywords in shader parsers 2018-05-28 12:07:20 -04:00
Shaolin d8a4c4cd52 libobs-opengl: Request at least 8 bits for alpha
10bpc support is under active development all over the linux stack
so while we wait for it to mature, request an alpha size of 8.
2018-03-12 22:36:50 -03:00
Shaolin d9f3482504 libobs-opengl: Log adapter and driver info
Closes jp9000/obs-studio#1197
2018-02-15 17:02:48 -08:00
jp9000 c111fa68b8 libobs: Add vertex/index buffer "direct" flush functions
(Note: This commit also modifies libobs-d3d11 and libobs-opengl)

Allows the ability to flush data directly without having to use the
buffer's internal data.

Allows the caller to manage his/her own vertex/index buffer data if
desired, working around the design flaw of having to rely on a
vertex/index buffer's internal data.
2017-11-27 03:00:20 -08:00
jp9000 4583dcbd4d libobs-opengl: Make update_buffer data param const 2017-11-27 02:30:49 -08:00
jp9000 4494e927f7 libobs-opengl: Disable v-sync on mac
Sets the swap interval to 0 to prevent v-sync from affecting any of the
preview panes on mac.
2017-10-06 06:35:56 -07:00
jp9000 5ba37f81ec libobs-opengl: Fix potential crash w/ viewports
'device->cur_swap' can be null in this function, and gl_getclientsize
expects it not to be null.
2017-05-13 01:21:15 -07:00
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