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

349 Commits

Author SHA1 Message Date
Colin Edwards
d795905138
Merge pull request #2749 from jpark37/gl-viewport-flip
libobs-opengl: Fix viewport flip
2020-04-19 15:56:17 -05:00
jpark37
44ebde553d libobs-opengl: Fix viewport flip
Flip viewport in coordination with update_viewproj_matrix.
2020-04-18 22:13:03 -07:00
Colin Edwards
55e2985026
Merge pull request #1944 from WizardCM/windows-rc-definition
CMake: Build Windows modules with file descriptors
2020-04-18 18:27:22 -05:00
jp9000
2a318d915f libobs-opengl: Fix atan2 HLSL->GLSL transpile 2020-04-07 23:59:14 -07:00
jp9000
6ca52db8ce libobs-opengl: Add sincos to HLSL->GLSL transpile 2020-04-07 23:59:14 -07:00
jpark37
ff2b07c032 libobs-opengl: Support 3D texelFetch 2020-03-23 20:38:43 -07:00
jpark37
1733705070 libobs-opengl: Fix Mac VAO created without context 2020-02-24 22:08:28 -08:00
Jim
d75245f017
Merge pull request #2264 from jpark37/mac-context-share
Fix OpenGL thread-safety on Mac to use latest Xcode
2020-02-05 14:33:27 -08:00
jpark37
50c53e3c39 libobs-opengl: Fix missing GL_HALF_FLOAT usages 2020-01-12 20:02:24 -08:00
jpark37
882687934c libobs-opengl: Fix volume texture leak 2020-01-04 01:28:16 -08:00
jpark37
846be2063c libobs-opengl: Don't allow volume render targets
Unlikely to be necessary. Disable for simplicity.
2020-01-01 12:39:53 -08:00
jpark37
9f330050ef libobs-opengl: OpenGL thread-safety on Mac
Attempt to fix threading issues that cause OBS to force-crash when
compiled with latest Xcode. There are two places where the new SDK
introduces a force-crash because operations are not happening on the
main thread: when we modify the context view to switch swap chains, and
when we resize a swap chain.

Instead of using just one context for all rendering, we create an
additional context for each swap chain, set each view once on
initialization, and switch contexts only in present to blit the final
framebuffer. This is an extra copy, but it's pretty hairy to optimize
away, and it's not worth potential regressions just to speed up Mac.

For resizing, we schedule the update code to run on the main thread from
the render thread. Ideally, we wouldn't have to round trip the logic
from main thread to graphics thread and back, but I don't think we want
to hack up the interface for this, especially since OpenGL will give way
to Metal soon enough.
2019-12-26 01:45:48 -08:00
jpark37
8f6984e345 libobs: Add support for volume textures
Also fix some mip calculations along the way.
2019-12-15 14:38:26 -08:00
Jim
3e01fdf3e5
Merge pull request #2116 from jpark37/begin-frame
libobs: Add gs_begin_frame for duplicators
2019-10-15 22:23:34 -07:00
Matt Gajownik
51be039cf8 CMake: Build Windows modules with file descriptors 2019-10-15 21:34:12 +11:00
Jim
09c7ec487b
Merge pull request #2064 from jpark37/bgra-swap-chain
D3D swap chain enhancements
2019-10-12 20:54:33 -07:00
jpark37
ade65df2aa libobs: Add gs_begin_frame for duplicators
We really shouldn't be resetting duplicator state as part of gs_flush.
gs_begin_scene is not ideal because it is called twice per frame, and
only after duplicators have been ticked. Even though it makes no
user-facing difference, it makes more logical sense to reset at the top
of the frame than the bottom.
2019-10-10 21:06:01 -07:00
jpark37
6eca70a529 libobs-opengl: Require OpenGL 3.3 instead of 3.2
There don't appear to be any GPUs that support 3.2, but not 3.3. GLSL
330 maps to HLSL Shader Model 4, so this will theoretically make shaders
programs less likely to diverge, particularly for behavior around NaNs.
2019-09-12 21:28:26 -07:00
jpark37
2ae9d6f683 libobs-opengl: Support BGRA swap chains on Windows 2019-09-05 23:34:23 -07:00
jp9000
bf41fd5a6b libobs: Add graphics API to get graphics object pointer 2019-08-29 12:43:10 -07:00
Jim
021defd962
Merge pull request #2036 from jpark37/gl-warnings
libobs-opengl: Fix Clang warnings
2019-08-17 12:11:46 -07:00
jpark37
2af98bf483 libobs-opengl: Fix Clang warnings 2019-08-17 11:02:03 -07:00
jpark37
a6af549155 libobs-opengl: Redundant cast 2019-08-17 08:48:28 -07:00
jpark37
4aaef353d4 libobs-opengl: Fix gl_error_to_str
Tweaked function to address some issues: compiler warnings, skipped
entries, and type safety.
2019-08-12 08:05:38 -07:00
Kurt Kartaltepe
9bc39c7617 libobs-opengl: Fix DUMMY textures left bound 2019-08-11 19:40:24 -07:00
Kurt Kartaltepe
491b6ec035 Revert "libobs-opengl: Add GS_RGBX format"
This reverts commit d940b9e580.
2019-08-11 18:30:28 -07:00
Jim
0546d18855
Merge pull request #1934 from kkartaltepe/alpha-linux
linux-capture: Correct XCompCap glxFBConfigs alpha check
2019-08-11 05:00:35 -07:00
jpark37
0e12d8189c libobs: Add GPU timestamp query support
This change only wraps the functionality. I have rough code to exercise
the the query functionality, but that part is not really clean enough to
submit.
2019-07-27 13:31:07 -07:00
jpark37
2f286b81d9 libobs: Default sampler sometimes unset for GL
When mixing sampling with raw loads in a shader, ending a shader with a
load would case the default sampler to become unset for OpenGL. Instead,
initialize with no sampler, and only set if there is a sampler.
2019-07-25 21:54:23 -07:00
jpark37
a7ac33488c libobs-opengl: Remove unused VERTEXID code
I think this was leftover from an abandoned approach.
2019-07-23 08:33:49 -07:00
jpark37
df59046050 libobs-opengl: Support gl_FragCoord and cull unused interpolants 2019-07-23 08:31:57 -07:00
jpark37
ce9e4dd4d2 libobs-opengl: Fix GS_R8G8 values 2019-07-23 08:29:54 -07:00
jpark37
b90ce6944f libobs-opengl: Fix glGetError() infinite loop
glGetError() returns GL_INVALID_OPERATION during OBS shutdown when GL is
used on Windows. This change gives up after eight errors.

This could be avoided by stopping the graphics thread before window
destruction, but the shutdown code looks like it could be tricky to
reorder.
2019-07-15 09:13:14 -07:00
Colin Edwards
ad85a9fa25 Apply clang-format to objective c code 2019-07-09 13:39:13 -05:00
Kurt Kartaltepe
499e648fff libobs-opengl: Fix GS_GL_DUMMY textures creation
Previously these textures were left in an incomplete state rendering
them usuable for most texturing operations.
2019-07-08 20:27:18 -07:00
Kurt Kartaltepe
d940b9e580 libobs-opengl: Add GS_RGBX format 2019-07-08 20:27:13 -07:00
Kurt Kartaltepe
16752c4bb4 libobs-opengl: Add error enum to string function 2019-07-08 20:27:08 -07: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
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