Commit Graph

242 Commits (a196fc7824a7b7e4bbf3f4f725a41a2a7787a6e6)

Author SHA1 Message Date
jp9000 ccd801b03e libobs-d3d11: Blacklist certain adapters from NV12
Some older adapters apparently can't handle NV12 properly.  Wonderful.
2019-02-26 08:37:55 -08:00
jp9000 28860411dd libobs-d3d11: Improve check for NV12 texture support
Checks to make sure that DXGI_FORMAT_NV12 is actually supported by the
GPU.
2019-02-25 23:02:54 -08:00
jp9000 925f72c8c3 libobs-d3d11: Fix rebuild of NV12 textures
When NV12 textures were added, driver crashes and their rebuild process
was not taken in to consideration.  This fixes that by adding explicit
NV12 rebuild functions.
2019-02-17 17:42:48 -08:00
jp9000 86f82c952a libobs-d3d11: Actually use paired NV12 member variable 2019-02-17 17:42:48 -08:00
jp9000 e09c63914e libobs-d3d11: Don't inline rebuild funcs
Inlining these functions is pretty pointless.
2019-02-17 17:42:48 -08:00
jp9000 93fc61fa82 libobs/graphics: Add NV12 texture support 2019-02-07 17:00:46 -08:00
jp9000 b64d7d71d0 libobs/graphics: Add texture sharing functions 2019-02-07 17:00:46 -08:00
jp9000 35dc89f5ca libobs-d3d11: Use mip levels are used in resource view 2018-09-28 16:37:48 -07:00
Alex Anderson af67086912 libobs: Add HLSL annotation parsing
Gives the ability to retrieve param annotations. Blocks wrapped in <>
following a parameter.

For example:
float slider < float max_value = 10.0; float min_value = 0.0; >;

These blocks are not for shading purposes but to help describe the
shader's gui as in the example above.

Adds graphics api functions for retrieving annotations:
size_t gs_param_get_num_annotations(const gs_eparam_t *param);

gs_eparam_t *gs_param_get_annotation_by_idx(const gs_eparam_t *param,
		size_t annotation);

gs_eparam_t *gs_param_get_annotation_by_name(const gs_eparam_t *param,
		const char *name);
2018-09-08 05:22:12 -07:00
SuslikV dbfcbac3e4 libobs-d3d11: Do not allow Alt+Enter interception
Prevents Alt-Enter from attempting to automatically fullscreen an OBS
graphics display.

Closes obsproject/obs-studio#1248
2018-04-20 22:34:22 -07:00
Wouter 65f81105f5 libobs-d3d11: Allow multiple display captures of same monitor
This commit fixes a bug that occurs on Windows 8+ when two or more
"Display Capture" sources are active that are configured to capture the
same monitor.  Only one display capture would show, while all subsequent
display captures would display nothing.

Closes jp9000/obs-studio#1142
2018-01-09 19:49:54 -08:00
jp9000 0d6204c8af Fix a number of MSVC warnings
Fixes a number of warnings with all modules
2017-12-05 13:53:44 -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
Micah Elizabeth Scott b55bb44845 libobs-d3d11: Fix gs_enable_color
It looks like the link between the gs layer rgba enable flags and the
underlying D3D states never got fully implemented.

This change adds the missing piece, fixing an issue I had in a plugin
wherein I couldn't write a blended value to a RGBA render target without
also changing the alpha of the dest pixel.  Debugging that led to the
missing gs_enable_color functionality.

Closes jp9000/obs-studio#1064
2017-11-25 18:12:52 -08:00
jp9000 e74a007718 libobs-d3d11: Allow rebuild even if output duplicator fails
Prevents an issue where the output duplicator would cause the program to
crash if the graphics driver crashes and the graphics subsystem needs to
be rebuilt.
2017-11-16 20:49:56 -08:00
Richard Stanway 58e2e69f81
libobs-d3d11: Better error message for missing D3DCompiler 2017-06-25 22:27:59 +02:00
jp9000 aafe08db5c libobs-d3d11: Fix potential issue rebuilding shared texture
Sometimes when rebuilding a texture, it often has to fall back and
create a temporary texture, but it'll fail when trying to create a
shader resource for it.  The suspicion is because it's due to not having
the proper shader binding flag when creating that temporary texture, so
this fixes that possible loophole.
2017-06-24 05:44:32 -07:00
jp9000 b775e579cb libobs-d3d11: Fix shader const array size miscalculation
When a shader constant was an array, the size of the array wouldn't be
factored in to the actual constant size and constant buffer size.
2017-06-20 18:20:15 -07:00
jp9000 e6f9a73235 libobs-d3d11: Fix bug where vertex buffers would be reset
There's no need to reset vertex buffers like this anymore.  This would
unintentionally cause certain things (such as the freetype text source
on windows) to stop rendering properly.
2017-05-20 19:37:28 -07:00
jp9000 ea6efc9514 libobs-d3d11: Only load vertex buffer before drawing
Fixes a bug where loading vertex shaders could cause error messages
about mismatching vertex buffer data to appear because the vertex shader
would try to reload the previously used vertex buffer.
2017-05-15 23:57:53 -07:00
Ryan Foster be98cee2a0 Fix various typos across multiple modules 2017-04-25 22:39:42 -04:00
jp9000 8cc5f8de55 libobs-d3d11: Don't crash if unable to rebuild shared texture
When rebuilding the graphics subsystem, it's possible a shared texture
may no longer be available.  In this case, just soft fail and allow the
texture to be rebuilt rather than crash the entire program over it.
2016-12-21 16:09:12 -08:00
jp9000 d2bb7157c2 libobs-d3d11: Add optional macro to log shader disassembly 2016-11-25 12:01:31 -08:00
jp9000 f6fae9b7e9 libobs-d3d11: Remove possible null pointer dereference 2016-11-06 16:49:02 -08:00
jp9000 bd5de5d938 libobs-d3d11: Include GDI surface in rebuild
The GDI surface was not included in the rebuild process, therefore when
window capture is used, it would cause a crash after a rebuild.
2016-11-06 16:46:38 -08:00
jp9000 8e8834f109 libobs-d3d11: Rebuild device and assets if device removed/reset
Due to an NVIDIA driver bug with the Windows 10 Anniversary Update,
there are an increasingly large number of reports of "Device Removed"
errors and TDRs.  When this happens, OBS stops outputting all data
because all graphics functions are failing, and it appears to just
"freeze up" for users.

To temporarily alleviate this issue while waiting for it to be fixed,
the D3D subsystem can be rebuilt when that happens, all assets can be
reloaded to ensure that it can continue functioning (with a minor hiccup
in playback).

To allow rebuilding the entire D3D subsystem, all objects that contain
D3D references must be part of a linked list (with a few exceptions) so
we can quickly traverse them all whenever needed, and all data for those
resources (static resources primarily, such as shaders, textures, index
buffers, vertex buffers) must be stored in RAM so they can be recreated
whenever needed.

Then if D3D reports a "device removed" or "device reset" error, all D3D
references must first be fully released with no stray references; the
linked list must be fully traversed until all references are released.
Then, the linked list must once again be traversed again, and all those
D3D objects must be recreated with the same data and descriptors (which
are now saved in each object).  Finally, all states need to be reset.

After that's complete, the device is able to continue functioning almost
as it was before, although the output to recording/stream may get a few
green frames due to texture data being reset.

This will temporarily alleviate the "Device Removed" issue while waiting
for a fix from NVIDIA.
2016-11-03 09:23:24 -07:00
jp9000 5eb0c4ec83 libobs-d3d11: Add Release funtions to all GS objects
Releases references for each graphics object.
2016-11-03 09:23:23 -07:00
jp9000 54737c9c68 libobs-d3d11: Remove unused function 2016-11-03 09:23:22 -07:00
jp9000 951c6892b0 libobs-d3d11: Use linked list for all objects (for rebuilding) 2016-11-03 09:23:21 -07:00
jp9000 5c71f79d5f libobs-d3d11: Make shared texture error message less vague 2016-11-03 09:23:20 -07:00
jp9000 ecd5b4ee81 libobs-d3d11: Save all D3D11 object descriptors (for rebuilding) 2016-11-03 09:23:19 -07:00
jp9000 bab77c2afd libobs-d3d11: Store static vertex buffer data (for rebuilding)
Instead of letting vertex buffer data be freed immediately, store it so
it can be used for rebuilding later.  Also, separate the buffer building
to a function.
2016-11-03 09:23:18 -07:00
jp9000 61042e2bc4 libobs-d3d11: Store static textures in RAM (for rebuilding) 2016-11-03 09:23:17 -07:00
jp9000 e4900751c3 libobs-d3d11: Store device adapter index (for rebuilding) 2016-11-03 09:23:16 -07:00
jp9000 6d18ae39c5 libobs-d3d11: Store swap initialization data (for rebuilding) 2016-11-03 09:23:15 -07:00
jp9000 bc0faf9a3c libobs-d3d11: Clear device state before unloading
Unloads all device data and clears all device references.  Probably not
necessary, but it's unknown how D3D11 handles this internally so
probably best to be safe.
2016-11-03 09:23:14 -07:00
jp9000 a5ed61e02e libobs-d3d11: Store index and add "Start" function
This allows restarting the duplicator at a later point in time.
2016-11-03 09:23:13 -07:00
jp9000 75cd6b4ab4 libobs-d3d11: Correct error message creating blend states 2016-11-03 09:23:12 -07:00
jp9000 66bdf43e44 libobs-d3d11: Correct error message for staging surfaces 2016-11-03 09:23:11 -07:00
jp9000 7321cc38e8 libobs-d3d11: Store shader samplers as pointers
This allows having them be a part of a linked list later.
2016-11-03 09:23:10 -07:00
jp9000 d4d0cd479d libobs-d3d11: Correct error message for pixel shaders 2016-11-03 09:23:09 -07:00
jp9000 1ecb1550af libobs-d3d11: Store compiled shader data (for rebuilding) 2016-11-03 09:23:08 -07:00
jp9000 29eea269fc libobs-d3d11: Store dxgi adapter used for device
Keeping a reference is useful, and additionally allows pruning a bit of
duplicated code in the dupicator object.
2016-11-03 09:23:07 -07:00
Ryan Foster 487ef58ee7 libobs-d3d11: Log GetDeviceRemovedReason
When DirectX throws error 0x887A0005 (DXGI_ERROR_DEVICE_REMOVED),
Microsoft recommends calling ID3D11Device::GetDeviceRemovedReason to
retrieve a more precise error code.

Closes jp9000/obs-studio#652
2016-10-07 01:07:00 -07: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 876cc94d51 libobs: Fix bug where bool constant size would be 1
(This commit also modifies libobs-d3d11)

Boolean constant size should be 4
2016-02-21 12:05:04 -08:00
jp9000 2a99e6ff18 libobs-d3d11: Log monitors/VRAM 2015-12-21 14:19:20 -08:00
jp9000 fd591fbd45 libobs-d3d11: Use debug log if duplicator fails to create
The duplicator is supposed to be able to safely fail to create, so using
a debug log message is more appropriate.
2015-11-16 11:11:16 -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
jp9000 eb459e2adc libobs-d3d11: Remove windowless context #error 2015-08-05 01:07:16 -07:00
jp9000 2b62c33c16 libobs-d3d11: Use windowless context
(Non-compiling commit: windowless-context branch)
2015-08-05 01:07:15 -07:00
jp9000 844123164f libobs-d3d11: Add windowless context #error 2015-08-05 01:07:06 -07:00
jp9000 278fd03a66 libobs-d3d11: Use get_win_ver (not GetVersionEx) 2015-08-01 14:51:23 -07:00
jp9000 cedd894fe7 libobs-d3d11: Make sure current swap is valid 2015-07-30 17:16:24 -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 3812393472 libobs-d3d11: Fix uint -> HWND casting
HWND is considered a pointer, so when casting you must cast to a
pointer-sized integer before attempting to cast to a pointer.
2015-02-09 03:56:12 -08:00
jp9000 86563ea1cd libobs-d3d11: Fix vertical alignment
Someone's going to yell at me about this, but fix vertical alignment for
certain member variables in the main header.

For future reference, if you must use vertical alignment, always give it
plenty of space for the type names to grow in case you need to
add/change variables in the future; don't just align to the 'longest'
value, give it an extra 8-16 spaces for potential future variables.
This is done to prevent having to make commits like this in the future
that sort of pollute the history.
2015-02-09 03:56:12 -08:00
jp9000 3af33b26ac libobs-d3d11: Use integer type with switch
DXGI_FORMAT has too many values we don't need/use, so the value for this
switch should be an integer instead of an enum to prevent warnings.
2015-02-09 03:56:11 -08:00
jp9000 e7cca4edd1 libobs-d3d11: Fix incorrect format specifier 2015-02-09 03:56:10 -08:00
jp9000 73c6dca1b5 libobs-d3d11: Fix potentially uninitialized vars 2015-02-09 03:56:10 -08:00
jp9000 7650df5525 libobs-d3d11: Fill out switch enum values
When using an enumeration value with a switch, it needs to be filled out
with all possible values to prevent compiler warnings.  This warning is
used to prevent the developer from unintentionally forgetting to add new
enum values to any switches the enum is used on later on.  Sadly, only
good compilers actually have this warning (mingw).
2015-02-09 03:56:09 -08:00
jp9000 1b2c3a6176 libobs-d3d11: Fix initializer list ordering
Microsoft's compiler doesn't seem to care about warning about things
like initializer list ordering.  Mingw actually reports on this to
prevent potential confusion about ordering.
2015-02-09 03:56:09 -08:00
jp9000 f4406e71f4 libobs-d3d11: Use member initialization
Instead of using initializer lists, use member initialization to clean
up the default values for member variables
2015-02-09 03:56:08 -08:00
martell 5d184dc8e5 obs-d3d11: use sprintf for mingw-w64
We have a sprintf_s function in mingw-w64, but it's the it won't compile
with visual studio because it's the C11 specification (aka the correct
specification that's not made by morons).  Microsoft's version differs
to the specification (and is made by morons), so fall back to sprintf

(note if you can't tell, this commit message was edited by Jim)
2015-02-09 03:46:11 -08:00
martell d1a1a84722 obs-d3d11: Use cinttypes header (mingw)
There appears to be a bug with mingw where including the regular C
inttypes.h won't work; instead you have to use the 'cinttypes' C++
version.
2015-02-09 03:43:56 -08:00
martell e96bd8c6bb obs-d3d11: include float.h for FLT_MAX
gcc expects this header to be included
2015-02-09 03:41:59 -08:00
martell 27c4336eed libobs-d3d11: Remove Microsoft's dxgi.h
I have added LGPL idl's for d3d11 and dxgi to mingw-w64, so we can
remove the existing mingw helper files from libobs-d3d11
2015-02-09 03:41:50 -08:00
jp9000 111b516043 libobs-d3d11: Log available adapters 2015-01-14 21:28:08 -08:00
jp9000 389c0b95d6 libobs-d3d11: Log adapter ID 2015-01-14 21:28:08 -08:00
jp9000 1cb02d5879 libobs: Add function to enumerate video adapters
The gs_enum_adapters function is an optional implementation to allow
enumeration of available graphics adapters that can be used with the
program.  The ID associated with the adapter can be an index or a hash
depending on the implementation.
2015-01-14 21:28:01 -08:00
jp9000 44b8c24f34 libobs: Add output duplicator support
This adds support for the windows 8+ output duplicator feature which
allows the efficient capturing of a specific monitor connected to the
currently used device.
2015-01-03 02:37:13 -08:00
jp9000 a5447b5fd8 libobs-d3d11: Move DXGI -> GS format conversion
Move the DXGI -> GS format conversion function to d3d11-subsystem.hpp
instead of being exclusively in the d3d11-texture2d.cpp function.
2015-01-03 02:37:12 -08:00
jp9000 caa32cb6d1 Add support for shared textures to graphics API 2014-10-13 21:56:42 -07:00
jp9000 a1b46c0fa5 libobs-d3d11: Don't depend on specific D3DCompiler
I do not want the D3D11 library to depend on a specific compiler
version.  This way, I do not have to distribute D3D Compiler libraries
with the program (proprietary binary blobs).  Any particular version
works because the API for the D3DCompiler function appears to be the
same; the only things that change are other features and additions
mostly (at least as far as I can tell).  Using any version available on
the system should be more than sufficient rather than depending on some
specific D3D compiler version.

If the user doesn't have it, a download of the latest D3D distributables
should be fine, though it should work with the ones that come with
windows 7+ as well.
2014-10-03 14:33:56 -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
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 a8d4774eef Fix D3D11 render target blending issues
The alpha source and destination blend values were always being set to
one and zero, when they should have been set to the same as the color
values.  This caused the alpha of the source texture to always overwrite
the alpha of the destination texture, rather than apply the blend
function upon it.  Needless to say that it seriously screwed up the
render target if you rendered something with alpha on it.

Thanks to paibox for pointing this issue out and yelling at me to fix
it.  I apologize for not getting to this sooner.
2014-08-11 17:40:35 -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 5c597102f2 Improve additional_install_files for debug/release
This improves dependency copying and adds separated debug/release
install files.
2014-07-18 22:41:11 -07:00
jp9000 fbf4d18399 Remove obsolete FindDirectX.cmake script
There's no need to find DirectX because with VS2013 and mingw it's
already available by default.  Older visual studio versions that didn't
come with DirectX by default are no longer supported anyway.

(Also mingw doesn't currently work at all due to lack of proper headers,
but once they do it'll be available in the same way.  I think.)
2014-07-19 01:38:43 +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 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 e42667d8f4 d3d11: Fix a number of warnings 2014-06-25 01:54:33 -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 f37c510f10 d3d11: Fix bug creating static vertex buffers
The vertex data wasn't getting properly freed, it was actually setting
the parameter itself to null for some reason.
2014-06-14 23:37: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
paibox 8334c48677 D3D11 scissorrect fix
Make sure the D3D11 scissorrect settings actually get applied.
2014-05-03 18:08:49 +02:00
jp9000 2838a95066 D3D11: Fix constant position code for good
I had forgotten how constants worked when compiled; constants are
uploaded as constant registers.  When constants are used with shaders,
multiple constants are often packed in to a single register when
possible to reduce constant register count.

For example, one 'float' constant and one 'float3' constant will be
packed in to a single register (c0.x for constant 1, c0.yzw for constant
2), but two 'float' constants and one 'float3' constant must inhabit two
registers (c0.xy for constant 1, c1.xyz for constant 2), so it must
start on a new register boundry (every 16 bytes).

I had first instinctively thought it was just a simple case of
alignment like it is on the CPU, but then I realized that it didn't
sound right, so I went back and did some more tests and then ultimately
remembered how constants actually are uploaded.
2014-05-02 21:38:05 -07:00
jp9000 4a370acf22 d3d11: Fix float3 constant alignment (128bit) 2014-05-02 13:04:26 -07:00
jp9000 5e2d283b9c GL/D3D11: Add scissor support 2014-05-01 11:26:17 -07:00
jp9000 53fe31e1ac libobs-d3d11: Fix vertex buffer bug
It was using the point buffer for points, normals, colors, tangents,
instead of using their specific buffers
2014-04-25 23:36:49 -07:00
Palana d19ba7f624 Update current samplers list on shader load
Ideally this should populate the list with matching OBS samplerstate_ts
like the GL code, but unfortunately there is no mapping for that yet
2014-04-19 05:25:30 +02:00
Palana 12f0877ebc Remove destroyed sampler states from the current samplers list 2014-04-19 05:25:21 +02:00
jp9000 0e9b13fcf9 Fix style errors (please don't make me do this) 2014-04-12 11:21:47 -07:00
BtbN 97c94b183a Add copy_texture_region function 2014-04-12 12:45:18 +02:00
jp9000 263f940806 Fix CMakeLists.txt for each project (my fault) 2014-03-29 17:29:02 -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
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 348588254c Add WASAPI audio capture
- Add WASAPI audio capture for windows, input and output

 - Check for null pointer in os_dlopen

 - Add exception-safe 'WinHandle' and 'CoTaskMemPtr' helper classes that
   will automatically call CloseHandle on handles and call CoTaskMemFree
   on certain types of memory returned from windows functions

 - Changed the wide <-> MBS/UTF8 conversion functions so that you use
   buffers (like these functions are *supposed* to behave), and changed
   the ones that allocate to a different naming scheme to be safe
2014-03-04 07:07:13 -07:00
jp9000 771eac6015 Be more consistent about log levels
LOG_ERROR should be used in places where though recoverable (or at least
something that can be handled safely), was unexpected, and may affect
the user/application.

LOG_WARNING should be used in places where it's not entirely unexpected,
is recoverable, and doesn't really affect the user/application.
2014-02-28 20:02:29 -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 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 6c92cf5841 Implement output, improve video/audio subsystems
- Fill in the rest of the FFmpeg test output code for testing so it
   actually properly outputs data.

 - Improve the main video subsystem to be a bit more optimal and
   automatically output I420 or NV12 if needed.

 - Fix audio subsystem insertation and byte calculation.  Now it will
   seamlessly insert new audio data in to the audio stream based upon
   its timestamp value.  (Be extremely cautious when using floating
   point calculations for important things like this, and always round
   your values and check your values)

 - Use 32 byte alignment in case of future optimizations and export a
   function to get the current alignment.

 - Make os_sleepto_ns return true if slept, false if the time has
   already been passed before the call.

 - Fix sinewave output so that it actually properly calculates a middle
   C sinewave.

 - Change the use of row_bytes to linesize (also makes it a bit more
   consistent with FFmpeg's naming as well)
2014-02-09 05:51:06 -07:00
BtbN 45ec80fb7d Full rewrite of all CMakeLists
CMake now works on all platforms
2014-01-24 18:56:32 +01:00
jp9000 f41bb4b7e9 add support for texture_rect texture type in shaders, add new form, clear up a few things in the API 2013-12-20 11:58:09 -07:00
jp9000 aead95f5e3 converted project to vs2013, removed 2010 support (ugh) 2013-12-14 16:01:30 -07:00
jp9000 8298fa4dc7 With the permission of my fellow contributors, I'm switching obs-studio back to GPL v2+ to prevent issues between this project and the original OBS project, and for personal reasons to avoid legal ambiguity (not political reasons, I admittedly would prefer GPL v3+) 2013-12-02 22:24:38 -07:00
jp9000 e5c99175c5 fixed some build issues on non-windows systems 2013-11-26 23:07:27 -07:00
jp9000 409b011a8e cleaned up main internal data structure design, changed to reference counting for sources to ensure safe destruction of source objects from all parts of the system, added some service-related stuff for testing 2013-11-20 15:00:16 -07:00
jp9000 db5aca1ab5 fixed some D3D macros 2013-11-10 06:31:55 -07:00
jp9000 f5e41f441e added initial main program and directshow files, finally have a UI functioning 2013-11-07 16:45:03 -07:00
jp9000 ab08c2c3f2 fixed a minor bug in the gl shader parser 2013-10-29 06:01:19 -07:00
jp9000 a43e291577 fill in the texture_setimage function, fill in a few other functions, and change certain names to be a little more consistent 2013-10-25 10:25:28 -07:00
jp9000 bb329b9278 avoid using 'default' for enum switches 2013-10-24 01:29:06 -07:00
jp9000 18834c6a45 some static analysis cleanup 2013-10-17 17:21:42 -07:00
jp9000 dfa2dc6eab fix up the rest of the GL code, add glew to project, add makefiles for opengl, fix makefiles so that it can be built with gcc, update project files to automatically output to the build directory 2013-10-16 23:31:18 -07:00
jp9000 9570f0b8d7 change names, fix some bugs, minor GL/D3D fixes, update tests, fix effect files, output a little more debug information 2013-10-14 12:37:52 -07:00
Peter SZTANOJEV 0301b24ace modernize header guards to #pragma once 2013-10-14 13:21:15 +02:00
jp9000 9577ddcf9b fill in the rest of the GL functions. finally 2013-10-12 20:18:05 -07:00
jp9000 83ddb920a1 finish up shader/sampler/texture/buffer loading/unloading/association 2013-10-12 12:35:38 -07:00
jp9000 aeea0eadc9 added shader attributes and added vertex buffer loading 2013-10-11 20:14:26 -07:00
jp9000 c1939de49b added z-stencil buffers to GL and made a GS_MAX_TEXTURES macro 2013-10-10 12:37:03 -07:00
jp9000 904725390a changed all references of the old d3d11 filenames to the new filenames 2013-10-10 08:01:09 -07:00
jp9000 47e0700f3f renamed some files to be a bit more consistent 2013-10-10 07:57:09 -07:00
jp9000 806bf557e5 removed a fairly pointless constant for the time being 2013-10-10 07:46:27 -07:00
jp9000 e159fc4f06 fill in shader parameter functions 2013-10-09 20:34:23 -07:00
jp9000 f9d1a4b9ed added first GLSL code, moved some graphics functions around, and adjusted some existing shader parser code 2013-10-06 18:29:29 -07:00
jp9000 f9c2aadf53 remove some more code duplication, fix a string, and remove a potential bug 2013-10-05 09:40:43 -07:00
jp9000 5c92f22f0d moved some stuff around to avoid code duplication and finish up gl 2D texture code 2013-10-05 00:34:43 -07:00
jp9000 9f0b7f25f6 one minor fix to texture pixel assignment code 2013-10-04 12:47:44 -07:00
jp9000 543d2481f1 move around some graphics stuff and put in copyright comments 2013-10-04 12:13:59 -07:00
jp9000 75262e6e0b update graphics subsystem code to add mipmap support and also add initial GL texture stuff and helper functions 2013-10-04 08:55:33 -07:00
jp9000 92aa7a6fae just some minor coding style adjustments 2013-10-04 05:28:36 -07:00
jp9000 4e6affdfc3 add an optional aligned new operator and use it with the d3d11 subsystem to prevent SIMD crashes 2013-10-01 00:27:14 -07:00
jp9000 f255ae1922 first commit 2013-09-30 19:37:13 -07:00