Commit graph

377 commits

Author SHA1 Message Date
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
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
jp9000 778cc2b318 (API Change) obs_reset_video: Use return codes
Changed API functions:
libobs: obs_reset_video

Before, video initialization returned a boolean, but "failed" is too
little information, if it fails due to lack of device capabilities or
bad video device parameters, the front-end needs to know that.

The OBS Basic UI has also been updated to reflect this API change.
2014-07-20 18:25:57 -07:00
jp9000 89a5bdbcf1 Add gs_device_type function
This allows a programatic way of determining the type of graphics module
currently active.
2014-07-20 16:23:03 -07:00
jp9000 a446dd74af Add gs_device_name function
This returns the name of the device, "Direct3D 11" or "OpenGL"
respectively.
2014-07-20 15:31:45 -07:00
jp9000 a27f2fbb3a Fix potentially uninitialized variable warnings 2014-07-12 11:59:46 -07:00
jp9000 f675c8029f Fix 'unused parameter' warnings on windows 2014-07-12 11:59:07 -07:00
Zachary Lund 543acf8477 Modified debug proc to possibly be more appropriate 2014-07-11 01:36:42 -05:00
BtbN a79ff06420 Fix gl_debug_proc function for unexpected parameters 2014-07-10 14:36:16 +02:00
jp9000 7b12133af3 Use uint8_t* instead of void* for texture data
NOTE: In texture_setimage, I had to move variables to the top of the
scope because microsoft's C compiler will give the legacy C90 error of:
'illegal use of this type as an expression'.

To sum it up, microsoft's C compiler is still utter garbage.
2014-06-28 10:12:57 -07:00
jp9000 f025cd6f87 GL: Mark unused 'device' parameter for flush 2014-06-25 22:24:26 -07:00
jp9000 caf8ca9ba8 Remove 'shader' param from shader param functions 2014-06-25 19:50:08 -07:00
jp9000 27010a2f56 Add a 'flush' command to graphics subsystem
...I'm actually concerned that I went a bit overkill trying to prevent
backwards compatibility issues with this abstraction design, because
this is a large number of files that have to be modified just to add a
single graphics subsystem export.  Someone's going to strangle me, and
when you know that someone might strangle you, that means that you did
something wrong.  We'll have to look in to simplifying this in the
future without killing backward compatibility safety.
2014-06-25 19:32:34 -07:00
jp9000 8aa49cc9ad Remove unused graphics subsystem functions
These functions were mostly related to being able to set true fullscreen
mode -- however, this has no place for our purposes, and these functions
were just sitting empty and unused, so they should be removed.

Besides, fullscreen mode only applies to the windows operating system.
2014-06-25 01:54:32 -07:00
jp9000 f4e7a893c5 Remove 'rebuild' variable from vertexbuffer_flush
This variable is currently somewhat pointless, I was originally going to
use it to tell the graphics subsystem to completely rebuild the internal
vertex buffers, but it would be bad/inefficient to allow that
functionality.
2014-06-25 01:54:32 -07:00
jp9000 1c2a0524b7 Change graphics subsystem to 4x4 matrices
4x4 matrices aren't as optimal, but are much more sensible to handle
when you want to do more advanced stuff like scaling, skewing, or
inversion.
2014-06-14 23:17:04 -07:00
jp9000 cec11d624a OpenGL: Don't call glGetAttribLocation on outputs
Previously we were using glGetAttribLocation on all inputs/outputs and
then just discarding if it was returned -1.  However, we have a boolean
value of 'input' in gl_parser_attrib, so there's no need to be doing
this and discarding potentially useful error handling information.
2014-06-07 19:33:41 -07:00
jp9000 3ce70778f9 OpenGL: Don't name VS inputs as 'geom' inputs.
Geometry shaders come after vertex shaders, not before.
2014-06-07 19:31:57 -07:00
jp9000 efaafd7cb4 OpenGL: Fix erroneous handling of BGRX
BGRX was being treated as "BGR input" with "RGBA storage", where it
should have been "BGRA input" with "RGB storage".  So the input for the
texture was expecting 24 bits of packed BGR rather than 32bit BGRX
pixels, and was internally storing it with alpha available.
2014-06-07 15:30:05 -07:00
jp9000 b64900e630 Graphics: Comment out parsed shader logging 2014-05-18 17:37:30 -07:00
fryshorts 944c2dc9f7 Destroy swapchain before removing the window info
This fixes an issue reported by valgrind where cleaning up the
swapchain fails because the window info is destroyed before.
2014-05-16 20:32:30 +02:00
Thomas McGrew 59328d86ce Added a version to the X11 GL context request
This enables the application to start on Intel graphics under Mesa 10.2
2014-05-12 02:31:15 -04:00
Palana cfc3f2590e Update OSX dependencies for cmake generators other than ninja/make 2014-05-08 14:31:43 +02:00
Palana 824ff961d0 Enable GL vertex attribute normalization
Fixes GL vertex color attributes
2014-05-02 00:37:32 +02:00
jp9000 5e2d283b9c GL/D3D11: Add scissor support 2014-05-01 11:26:17 -07:00
jp9000 d9d0d87431 libobs-opengl: Fix some code formatting issues 2014-04-24 21:10:07 -07:00
Lioncash 96031f2392 Fix a possible null pointer dereference 2014-04-21 21:28:40 -04:00
Palana 12f0877ebc Remove destroyed sampler states from the current samplers list 2014-04-19 05:25:21 +02:00
Palana b0237fd581 Use high resolution GL surface when available 2014-04-16 22:39:20 +02:00
Jim 2fc810fd09 Merge pull request #65 from BtbN/glad
Move from glLoadGen to GLAD
2014-04-16 12:51:32 -07:00
BtbN e50201cad1 Move from glLoadGen to GLAD 2014-04-15 22:19:40 +02:00
jp9000 0bec267e40 OpenGL: Fix swizzle code again for alpha textures
My prior code was incorrect;  I mixed up the two parameters, the
GL_TEXTURE_SWIZZLE_* parameter specifies the target channel, and the
value itself specifies the source channel.,  If that makes sense.
2014-04-15 12:19:20 -07:00
jp9000 51d338430f Only do the alpha swizzle on alpha textures
Avoids problems if swizzles are used elsewhere (like in the newer X11
plugins)
2014-04-15 04:23:55 -07:00
jp9000 bc33b09ba9 Revert OpenGL swizzle change
Was wrong to use the swizzle -- it was an incorrect assumption on my
part that this could work in the first place (despite working on
windows)
2014-04-12 23:57:40 -07:00
jp9000 0e9b13fcf9 Fix style errors (please don't make me do this) 2014-04-12 11:21:47 -07:00
BtbN 0f9c6e5503 Create sub window for rendering, to avoid visual mismatch issues 2014-04-12 16:24:38 +02:00
BtbN 97c94b183a Add copy_texture_region function 2014-04-12 12:45:18 +02:00
Timo R b9f0da026e Move opengl loader into a seperate static library, so plugins can use it 2014-04-12 12:45:18 +02:00
jp9000 362e008b87 OpenGL: Use texture swizzle for BGRA/BGR/A8
On some operating systems, with specific drivers it seems that BGR/BGRA
isn't properly treated as such in certain cases.  This fix will
hopefully force the formats to be treated as BGR/BGRA when actually
rendering, which should get around the implementation-specific issue.
2014-04-11 13:14:20 -07:00
Zachary Lund 92f253d65f More extensions, less bugs 2014-04-06 16:21:19 -05:00
Zachary Lund 1dd3917745 Added GLX_NV_copy_image extension, updated tools 2014-04-05 13:49:19 -05:00
Zachary Lund baa57d4c39 Merge branch 'master' of https://github.com/jp9000/obs-studio 2014-04-03 20:12:26 -05:00
Zachary Lund e5b90accb9 Removed no longer valid comment 2014-04-03 19:24:03 -05:00
Zachary Lund b4d2146861 This commit contains more than I intended. Read below for more info.
1) Fixed the preview window. It now correctly displays the source.
2) The GLX backend now correctly uses the devices current swap.
3) We now set device->cur_swap to a default so we don't have to check it in every function.
4) Minor syntactical cleanups and perhaps some messiness added.
2014-04-03 19:21:24 -05:00
Palana c2abb80c9a Use bzalloc instead of bmalloc+memset 2014-04-04 02:00:10 +02:00
Palana 61cf2faad3 Delete per window GL context for Cocoa and just swap the view instead
This unfortunately re-introduces undesirable rendering behaviour for
slow renderers (e.g. first gen Intel HD graphics/Apple software
renderer) when the property window is open, but fixes property window
preview rendering for sufficiently fast renderers
2014-04-04 02:00:08 +02:00
Zachary Lund ee9ff9cfb9 Use Qt provided display with GLX functions for consistency.
Remove unneeded assignment from previous code.
2014-04-03 17:36:01 -05:00
BtbN a31e938c2b Fix getting the X11 display with the Qt ui 2014-04-03 23:41:22 +02:00
BtbN acab80cbef Fixup libobs-opengl CMakeLists 2014-04-01 21:30:52 +02:00
jp9000 263f940806 Fix CMakeLists.txt for each project (my fault) 2014-03-29 17:29:02 -07:00
jp9000 b2885480fa Minor fix to GL texture cleanup
Don't clear any data if it's a dummy texture.
2014-03-29 17:23:31 -07:00
jp9000 0a86e8fb3f Add dummy GL texture flag & direct object access
- Add dummy GL texture support to allow libobs texture references to be
   created for GL without

 - Add a texture_getobj function to allow the retrieval of the
   context-specific object, such as the D3D texture pointer, or the
   OpenGL texture object handle.

 - Also cleaned up the export stuff.  I realized it was all totally
   superfluous.  Kind of a dumb moment, but nice to clean it up
   regardless.
2014-03-29 17:19:31 -07:00
Palana f8b90a5c8f Add per window GL context for Cocoa libobs-opengl implementation
This fixes some problems with multiple swap chains (e.g. flickering
between the render views)
2014-03-24 17:42:45 +01:00
jp9000 2b4e381c3b Change a reference variable to be volatile long
Removed some warnings associated with it, was the wrong variable type.
2014-03-16 20:08:12 -07:00
jp9000 154e0c59e1 Use atomic functions where appropriate
Also, rename atomic functions to be consistent with the rest of the
platform/threading functions, and move atomic functions to threading*
files rather than platform* files
2014-03-16 18:26:46 -07:00
jp9000 fd37d9e9a8 Implement encoder interface (still preliminary)
- Implement OBS encoder interface.  It was previously incomplete, but
   now is reaching some level of completion, though probably should
   still be considered preliminary.

   I had originally implemented it so that encoders only have a 'reset'
   function to reset their parameters, but I felt that having both a
   'start' and 'stop' function would be useful.

   Encoders are now assigned to a specific video/audio media output each
   rather than implicitely assigned to the main obs video/audio
   contexts.  This allows separate encoder contexts that aren't
   necessarily assigned to the main video/audio context (which is useful
   for things such as recording specific sources).  Will probably have
   to do this for regular obs outputs as well.

   When creating an encoder, you must now explicitely state whether that
   encoder is an audio or video encoder.

   Audio and video can optionally be automatically converted depending
   on what the encoder specifies.

   When something 'attaches' to an encoder, the first attachment starts
   the encoder, and the encoder automatically attaches to the media
   output context associated with it.  Subsequent attachments won't have
   the same effect, they will just start receiving the same encoder data
   when the next keyframe plays (along with SEI if any).  When detaching
   from the encoder, the last detachment will fully stop the encoder and
   detach the encoder from the media output context associated with the
   encoder.

   SEI must actually be exported separately; because new encoder
   attachments may not always be at the beginning of the stream, the
   first keyframe they get must have that SEI data in it.  If the
   encoder has SEI data, it needs only add one small function to simply
   query that SEI data, and then that data will be handled automatically
   by libobs for all subsequent encoder attachments.

 - Implement x264 encoder plugin, move x264 files to separate plugin to
   separate necessary dependencies.

 - Change video/audio frame output structures to not use const
   qualifiers to prevent issues with non-const function usage elsewhere.
   This was an issue when writing the x264 encoder, as the x264 encoder
   expects non-const frame data.

   Change stagesurf_map to return a non-const data type to prevent this
   as well.

 - Change full range parameter of video scaler to be an enum rather than
   boolean
2014-03-16 16:21:34 -07:00
jp9000 4f7ab552df Reimplement monitor capture
- Implement windows monitor capture (code is so much cleaner than in
   OBS1).  Will implement duplication capture later

 - Add GDI texture support to d3d11 graphics library

 - Fix precision issue with sleep timing, you have to call
   timeBeginPeriod otherwise windows sleep will be totally erratic.
2014-03-05 10:43:14 -07:00
jp9000 e560a426c5 Give cf_parser functions better naming 2014-03-01 01:25:41 -07:00
jp9000 429195aa6f Fix a warning and an error
Happened because I compiled on windows and it only compiled
windows-specific code.
2014-02-28 20:11:10 -07:00
jp9000 2dbbffe4a2 Make a number of key optimizations
- Changed glMapBuffer to glMapBufferRange to allow invalidation.  Using
   just glMapBuffer alone was causing some unacceptable stalls.

 - Changed dynamic buffers from GL_DYNAMIC_WRITE to GL_STREAM_WRITE
   because I had misunderstood the OpenGL specification

 - Added _OPENGL and _D3D11 builtin preprocessor macros to effects to
   allow special processing if needed

 - Added fmod support to shaders (NOTE: D3D and GL do not function
   identically with negative numbers when using this.  Positive numbers
   however function identically)

 - Created a planar conversion shader that converts from packed YUV to
   planar 420 right on the GPU without any CPU processing.  Reduces
   required GPU download size to approximately 37.5% of its normal rate
   as well.  GPU usage down by 10 entire percentage points despite the
   extra required pass.
2014-02-16 19:28:21 -07:00
jp9000 1570fa75b9 Fix variable placement, not safe with goto usage 2014-02-14 18:23:21 -07:00
jp9000 30af7dc211 Optimize GL staging surface and fix mac issue
Staging surfaces with GL originally copied to a texture and then
downloaded that copied texture, but I realized that there was really no
real need to do that.  Now instead they'll copy directly from the
texture that's given to them rather than copying to a buffer first.

Secondly, hopefully fix the mac issue where the only way to perform an
asynchronous texture download is via FBOs and glReadPixels.  It's a
really dumb issue with macs and the amount of "gotchas" and non-standard
internal GL functionaly on mac is really annoying.
2014-02-14 18:13:25 -07:00
jp9000 8b8217f68e Fix a some more linux/GCC specific warnings 2014-02-14 15:56:01 -07:00
jp9000 966b943d5b Remove majority of warnings
There were a *lot* of warnings, managed to remove most of them.

Also, put warning flags before C_FLAGS and CXX_FLAGS, rather than after,
as -Wall -Wextra was overwriting flags that came before it.
2014-02-14 15:13:36 -07:00
jp9000 b067440f73 Use bzalloc instead of bmalloc then memset
Reduces needless code repetition and still allows for proper memory
alignment.  Cleans up the code a bit.
2014-02-09 12:34:07 -07:00
jp9000 6ffcd5e74e Implement FBO blit texture copy
This trick uses FBOs to allow for copying textures without the need for
special texture copy functions.
2014-02-09 11:37:22 -07:00