Commit Graph

169 Commits

Author SHA1 Message Date
Michael Fabian 'Xaymar' Dirks ec19f44f96 project: Don't prefix includes with "libobs/" 2018-04-23 17:53:27 +02:00
Michael Fabian 'Xaymar' Dirks 0b5a848c32 cmake: Improve automatic versioning 2018-04-23 17:52:40 +02:00
Michael Fabian 'Xaymar' Dirks fc78bd83a6 filter-custom-shader: Initial version based on gfx::effect_source 2018-04-09 13:28:13 +02:00
Michael Fabian 'Xaymar' Dirks 9f91039ca0 util-memory: Don't use _dbg versions for aligned_alloc/free 2018-04-09 13:27:51 +02:00
Michael Fabian 'Xaymar' Dirks 5e9f113553 gfx-effect-source: Base class for Custom Shaders
gfx::effect_source is the base class for all Custom Shader Sources and Transitions, which reduces the overall workload to a single file, but unfortunately also reducing the effective customization per source a bit.
2018-04-09 13:27:22 +02:00
Michael Fabian 'Xaymar' Dirks 9ae8ecc3e1 source-mirror: Fix crashes caused by uncaught exception 2018-04-09 13:23:57 +02:00
Michael Fabian 'Xaymar' Dirks fe05dca51e gfx, gs: Fix commits 9f518764b6 & 2adfa5765c 2018-03-20 12:50:17 +01:00
Michael Fabian 'Xaymar' Dirks 22eb53a856 gfx: Initial code for an Effect Source (Custom Shader)
This class will be used by any Custom Shader type (Filter, Source, Transition) and as such is pretty much used as the basis for all of it.
2018-03-20 12:45:41 +01:00
Michael Fabian 'Xaymar' Dirks 2adfa5765c gs: Rename to snake_case instead of PascalCase
This should prevent mishaps with upper/lowercase typos and fits in better with the C++ standard code, which is also in snake_case.
2018-03-20 12:44:02 +01:00
Michael Fabian 'Xaymar' Dirks 9f518764b6 gfx: Move util::SourceTexture to gfx::SourceTexture
'gfx' is the new preview for Graphics utilities that do not act as a wrapper around the Graphics Subsystem directly.
2018-03-08 11:28:23 +01:00
Michael Fabian 'Xaymar' Dirks 53073660c0 Merge branch 'filter-custom-shader' 2018-03-05 16:50:57 +01:00
Michael Fabian 'Xaymar' Dirks 65a7ac696b source-mirror: Use util:SourceTexture instead of custom code 2018-03-05 16:50:19 +01:00
Michael Fabian 'Xaymar' Dirks 304db23335 util-math: Add SizeFromString method
Converts a String to an std::pair of int64_t (long long), which contain the size or 0 if none could be parsed. Any delimiter except digits(0-9), a minus sign(-) or a plus sign(+) between width and height are allowed. If a plus or minus sign is used as a delimiter, it must immediately be followed by the second size number. This allows for formats such as: 100x100, 100:100, 100p100, 100@100, 100+100 and so on, but not formats such as 100+:100, 100ThisIsSomeReall+yLongText100, etc.

The parameter 'allowSquare' also determines what to do when the height parameter is not found. A value of true will have the function return <width,width> instead of <width,0>.
2018-03-05 16:36:20 +01:00
Michael Fabian 'Xaymar' Dirks 1f60e3d56f util-source-texture: Fix commit 75aeb561bd
Including obs.h directly is not compatible with CPack installations of libobs.
2018-03-05 16:21:30 +01:00
Michael Fabian 'Xaymar' Dirks 224544efff util-source-texture: Add method to retrieve obs_source_t* obejct 2018-03-05 16:19:42 +01:00
Michael Fabian 'Xaymar' Dirks 75aeb561bd util: Add SourceTexture utility
This utility class is used to quickly render and retrieve a Texture from a source. It should be used in place of manual rendering since it can be updated quickly, fixing outstanding issue in all places of the plugin instead of just one.
2018-03-05 15:17:34 +01:00
Michael Fabian 'Xaymar' Dirks cc68e2864f gs-rendertarget: Add and implement GetTexture(...) methods 2018-03-05 15:10:51 +01:00
Michael Fabian 'Xaymar' Dirks 7d065c131d gs-texture: Allow creation from existing gs_texture_t* 2018-03-05 15:10:19 +01:00
Michael Fabian 'Xaymar' Dirks 01bf510a28 util-memory: Use standard alloc/free and fix incorrect aligned length
The custom allocator occasionally returned memory that was aligned, but did not have enough space to store the actual size due to a calculation error in the size. This resulted in situations where allocating 1022 bytes would give you a writable buffer of only 1020 bytes or less, or also known as writing into unknown memory, possibly even the heap. This is now fixed by doubling the padding used.

Additionally it will now default to using standard allocators, which should work better and rely on the Compiler.
2018-02-24 04:35:49 +01:00
Michael Fabian 'Xaymar' Dirks eccd95c68c filter-custom-shader: First working version with several fixes
- Shaders now have all promised special variables available to them.
- 'Pass' (int) is no longer a special variable.
- Files should now properly update every half second.
- Fixed a ton of compiler warnings.
- Forced loading shaders from text instead of files to avoid caching.
- Fixed file modification tests always failing.
- Actually renders shaders now.

Known issues:
- Parameters aren't updated with file modifications unless the file is actually changed in the UI.
2018-01-25 10:26:09 +01:00
Michael Fabian 'Xaymar' Dirks 107103001b gs-effect: Add HasParameter and fix Set*Array
HasParameter can be used to safely check if a parameter exists and such should be preferred over try-catch blocks. Additionally, SetFloat2, SetFloat3, SetFloat4, SetFloatArray, SetInteger2, SetInteger3, SetInteger4 and SetIntegerArray should no longer cause rendering issues due to invalid buffer sizes.
2018-01-25 09:12:47 +01:00
Michael Fabian 'Xaymar' Dirks b4eadc2995 filter-blur: Don't override blend mode of original source
This causes a black square to appear, since the blend mode should ideally match what the original source thought it would be.
2018-01-25 05:11:15 +01:00
Michael Fabian 'Xaymar' Dirks 080048a471 filter-custom-shader: UI improvements and initial rendering code 2018-01-19 20:46:54 +01:00
Michael Fabian 'Xaymar' Dirks 26b447901c filter-custom-shader: Implement new Filter 'Custom Shader'
Custom Shader allows you to write your own effect files and just have them applied to your source(s). It will dynamically update the properties to match the parameters in the source as well as offer some special parameters to the shader.

# Conflicts:
#	CMakeLists.txt
#	data/locale/en-US.ini

# Conflicts:
#	data/locale/en-US.ini
2018-01-19 20:46:54 +01:00
Michael Fabian 'Xaymar' Dirks adafbf40ca util-memory: Expose aligned_offset to code 2018-01-19 20:46:22 +01:00
Michael Fabian 'Xaymar' Dirks 67099c2b23 gs-effect: Fix assigning of Integer and Float arrays 2018-01-19 20:46:21 +01:00
Michael Fabian 'Xaymar' Dirks 734ea577b8 source-mirror: Release source and fix compiler warnings 2018-01-19 20:46:21 +01:00
Michael Fabian 'Xaymar' Dirks a307283349 gs-effect: Allow directly assigning OBS GS objects 2018-01-19 20:46:21 +01:00
Michael Fabian 'Xaymar' Dirks 0565065c2b source-mirror: 'Point' rescale should use point sampling 2018-01-19 05:10:42 +01:00
Michael Fabian 'Xaymar' Dirks 102e4e5eeb gs-effect: Implement method to override the next sampler 2018-01-19 05:10:10 +01:00
Michael Fabian 'Xaymar' Dirks 36cd5bbf21 gs-sampler: Add wrapper for gs_samplerstate_t
Simple manager with automatic updating whenever the object is requested.
2018-01-19 05:06:42 +01:00
Michael Fabian 'Xaymar' Dirks 662199fb4a source-mirror: Fix scaling issues and allow keeping original size
Scaling was previously incorrectly rendering the source with another effect forced onto it, resulting in slower rendering and some sources that would no longer render properly.

Additionally the new option allows the user to have the source render at the original resolution in order to allow previously applied transform to stay identical. The rescaling however will no longer apply to filters after this source then, thus the speed bonus is lost.

Also categorized the localization file and adds descriptions for existing and new properties for Source Mirror.
2018-01-19 04:15:40 +01:00
Michael Fabian 'Xaymar' Dirks 5e0b387dc1 gs-vertexbuffer: Functions to directly access internal buffers
Skips the previously necessary step to call At(0) and use the pointers stored in GS::Vertex to directly write to the buffers.
2018-01-19 03:15:12 +01:00
Michael Fabian 'Xaymar' Dirks fe3186220c gs-vertexbuffer: Slight Refactor to unify code style 2018-01-19 03:13:02 +01:00
Michael Fabian 'Xaymar' Dirks 3a05c08daf gs-vertexbuffer: Implement copy and move constructor/assignment 2018-01-19 03:05:24 +01:00
Michael Fabian 'Xaymar' Dirks b4d63e919e gs-vertex: Allocate memory if none is assigned
Allows code to directly use GS::Vertex for their own purposes without having to rely on GS::VertexBuffer, which comes with the added overhead of allocating GPU memory.
2018-01-19 03:01:54 +01:00
Michael Fabian 'Xaymar' Dirks 82ec6b93ec gs-vertexbuffer: Also free layer data
Fixes a tiny memory leak caused by a missing free.

Related: #9
2018-01-18 05:22:57 +01:00
Michael Fabian 'Xaymar' Dirks 1ebb0beac4 gs-vertexbuffer: Avoid relying on std for aligned types
Changes the GS::VertexBuffer storage to be one continuous buffer that is properly aligned and is also now used for GS::Vertex. This halves the necessary memory, removes reallocation cost and removes the copy necessary to get things onto the GPU.

Related: #9
2018-01-18 05:02:10 +01:00
Michael Fabian 'Xaymar' Dirks 4983e0ca06 gs: Define shared limits and exclude mipmapper
This unifies the logic in GS::IndexBuffer and GS::VertexBuffer so that both can take the same amount of vertices. Additionally the limit for vertices was increased to 16777216 from 65536 to allow for proper models to be stored.
2018-01-18 05:02:10 +01:00
Michael Fabian 'Xaymar' Dirks 53568d445b gs-vertex: Hint VS2013/2015 at proper alignment
The previous fix unfortunately didn't actually fix it and instead made the crash invisible at first and then corrupt the heap at a later point. With this, VS2013 and VS2015 create code identical to what VS2017 creates, and no longer seem to crash.

Related: #9
2018-01-18 03:12:52 +01:00
Michael Fabian 'Xaymar' Dirks e9fc9e89f2 plugin: Use self-registration code everywhere 2018-01-16 11:47:24 +01:00
Michael Fabian 'Xaymar' Dirks cb1ae28b07 gs-vertexbuffer: Use aligned memory and fix null pointer
This fixes the crash on creation issues, but a crash on exit still happens with the plugin installed. Unsure what exactly is causing it but it looks like something is writing into heap memory.

Related: #9
2018-01-08 19:08:49 +01:00
Michael Fabian 'Xaymar' Dirks 1e2cff48c9 util-memory: Implement aligned std::allocator 2018-01-08 19:01:26 +01:00
Michael Fabian 'Xaymar' Dirks 8a595501b3 gs-vertex, util-math: Use _aligned_malloc instead of util::malloc_aligned 2018-01-08 17:41:26 +01:00
Michael Fabian 'Xaymar' Dirks 1993c42ea6 filter-transform: Use 16-byte aligned vec3 & vec4 2018-01-08 17:31:50 +01:00
Michael Fabian 'Xaymar' Dirks 3e97906b32 gs-vertex: Always align to 16-byte 2018-01-08 17:30:33 +01:00
Michael Fabian 'Xaymar' Dirks f721ad0f19 util-math: Fix standalone compilation issues
All libobs files must be loaded with libobs/... instead of directly.
2018-01-08 16:47:39 +01:00
Michael Fabian 'Xaymar' Dirks 08c088ce5a util-math, util-memory: Formatting 2018-01-08 16:14:54 +01:00
Michael Fabian 'Xaymar' Dirks a3d859fb4f util-math: Implement aligned vec3 and vec4 versions
A bug in Visual C++ 2013 32-bit & 2015 32-bit causes the C++ compiler to incorrectly align the vec3 and vec4 structs to 8-byte instead of 16-byte, resulting in a crash if the target PC supports SSE. Visual Studio 2017 and 64-bit builds are not affected.

Related: #9
2018-01-08 15:29:42 +01:00
Michael Fabian 'Xaymar' Dirks cf17cdab19 util-memory: Rename aligned_malloc 2018-01-08 11:35:05 +01:00
Michael Fabian 'Xaymar' Dirks 32ed7b645a util-memory: Memory utility functions 2018-01-08 10:52:53 +01:00
Michael Fabian 'Xaymar' Dirks add8012549 source-mirror: Add a Source Mirror source
The source allows you to apply effects to the same source without requiring a new instance of the source. Any changes done to the original source also apply to the mirror, so there is less total work that needs to be done.

It can also rescale the source, allowing you to use the same source as a cheap instant backdrop with Blur for example. What you do in the end is completely unwritten and up to you to decide.
2017-12-14 08:46:36 +01:00
Michael Fabian 'Xaymar' Dirks 78ccd94639 filter-blur: Ensure that the initializer is unique 2017-12-14 08:05:06 +01:00
Michael Fabian 'Xaymar' Dirks f5fca108d7 gs-rendertarget: Fix missing initialization 2017-12-14 08:04:54 +01:00
Michael Fabian 'Xaymar' Dirks e7bbb213a4 filter-blur: Fix Blur filter occasionally not rendering
An earlier commit changed how Blur filter rendered and thus m_technique was no longer being initialized, resulting in the check randomly failing if the memory was just right.

This also adds some more extra logging to the instance creation in case things fail and fixed one MSVC warning.

Fixes #1
2017-12-14 03:52:29 +01:00
Michael Fabian 'Xaymar' Dirks 9ab06e7368 gs-mipmapper: Fix type conversion warnings 2017-12-14 03:12:24 +01:00
Michael Fabian 'Xaymar' Dirks 762c961ed3 gs-vertexbuffer: Fix incorrect vertex buffer size on GPU crash 2017-12-14 03:09:02 +01:00
Michael Fabian 'Xaymar' Dirks 0d794254be util-math: Fix MSVC 2013 errors 2017-12-14 03:00:31 +01:00
Michael Fabian 'Xaymar' Dirks 6c4b8bbf12 filter-blur: Fix up some MSVC warnings 2017-12-14 03:00:08 +01:00
Michael Fabian 'Xaymar' Dirks 09d5ac4635 gs-vertexbuffer: Fix support for 20.x graphics API
Reverts an earlier change that made the plugin rely on 21.x features.
2017-12-14 02:59:50 +01:00
Michael Fabian 'Xaymar' Dirks 911f7696bb filter-blur: Reduce log spam on error 2017-12-14 02:35:47 +01:00
Michael Fabian 'Xaymar' Dirks 9d4314141a gs-texture: Remove unused function 2017-12-14 01:39:43 +01:00
Michael Fabian 'Xaymar' Dirks 578c963a02 filter-blur: Code cleanup, fixes and more
- Fixed Gaussian Blur having color issues with radii that aren't a power of 2.
- Improved error reporting to better debug problems where Blur doesn't render.
- Switched from manual object management to managed classes.
- Lots of code cleanup for maintainability.
2017-12-14 01:39:33 +01:00
Michael Fabian 'Xaymar' Dirks 408481c22d util-math: Functions to calculate nearest power of two values 2017-12-14 01:36:07 +01:00
Michael Fabian 'Xaymar' Dirks d78d3024cc util-math: Add commonly used mathematical functions 2017-12-14 00:28:35 +01:00
Michael Fabian 'Xaymar' Dirks 61f20a83ad filter-blur: Use self-registration feature 2017-12-14 00:24:37 +01:00
Michael Fabian 'Xaymar' Dirks 9e813d98f1 gs-vertexbuffer: Update to new API adding flush_direct functionality
This fixes the crashes on deleting a filter without requiring painful memory editing.
2017-12-14 00:22:27 +01:00
Michael Fabian 'Xaymar' Dirks 71900e6752 gs-effect: Allow retrieving effect parameter name 2017-11-05 21:50:38 +01:00
Michael Fabian 'Xaymar' Dirks 4b364865a1 gs-effect: Allow empty effect and check errorMessage validity 2017-11-05 21:31:05 +01:00
Michael Fabian 'Xaymar' Dirks fc02f3fdad plugin: Allow new filters and transitions to self-register 2017-11-05 20:05:48 +01:00
Michael Fabian 'Xaymar' Dirks a9b13787be gs-effect: Provide parameter count and index access 2017-11-05 16:47:36 +01:00
Michael Fabian 'Xaymar' Dirks c7cfbff7dd gs-vertexbuffer: Workaround for a foreign deallocation bug in libobs
The graphics subsystem in OBS is freeing memory it didn't allocate, resulting in stack/heap corruption and other kinds of messy situations. The official "fix" for this is to use bmalloc, but then you lose any kind of ability to re-use the same buffer for multiple vertex buffers or update on the fly without adjusting code that is possibly outside of your control (such as in libraries).

This works around the issues by "patching" the gs_vertexbuffer object to no longer hold a reference to the gs_vb_data object. Currently only D3D11 is supported for this kind of hack and it might break in a future obs-studio release.

PR fixing this Issue: https://github.com/jp9000/obs-studio/pull/993
2017-11-03 00:13:07 +01:00
Michael Fabian 'Xaymar' Dirks 3450c149aa filter-displacement: Fix loading displacement filter 2017-11-02 17:57:52 +01:00
Xaymar c0aa79abbe filter-blur: Faster initialization for Gaussian Blur 2017-10-22 19:04:41 +02:00
Xaymar b266af1044 gs: Fix some type conversion warnings 2017-10-22 18:58:38 +02:00
Xaymar 6a208ed215 gs: Leave GS context and then return texture
This fixes a hang when calling GetTextureObject() on a GS::RenderTarget.
2017-10-22 18:57:28 +02:00
Michael Fabian Dirks 3899476a7f filter-transform: Actually include new C++ class header 2017-09-18 00:16:46 +02:00
Michael Fabian Dirks 27744f8b2a gs: Fix commit eb1612c6ee 2017-09-18 00:15:57 +02:00
Michael Fabian Dirks 90563e6b31 filter-transform: Add shearing support 2017-09-18 00:05:55 +02:00
Michael Fabian Dirks b07b5b1a0a filter-transform: Update code and fix camera and scaling 2017-09-18 00:05:54 +02:00
Michael Fabian Dirks 4de0a0ca16 filter-transform: Move translation strings to code 2017-09-18 00:05:54 +02:00
Michael Fabian Dirks 88cc142afb gs, effects: Anisotropic Mipmapper Class
End goal of this is to be an anisotropic filtering purely on the GPU without any actual mipmaps in the graphics subsystem. The basic idea behind it is that we can create all possible mipmaps in a twice as big texture as the original and then can efficiently render it no matter the GPU features as it will only consume one sampler.

The texture that it outputs will have both horizontal, vertical and full mipmaps in it. Horizontal mipmaps reduce Width, Vertical mipmaps reduce Height and full mipmaps reduce both. This means that LoD levels are both possible in the X and Y direction, allowing for much greater precision mipmapping on all GPUs.

This is a temporary solution until we can directly copy updated textures to a mipmap level.
2017-09-18 00:05:54 +02:00
Michael Fabian Dirks fce3fb8977 filter-shape: Use new GS classes 2017-09-18 00:05:53 +02:00
Michael Fabian Dirks e619f03217 filter-blur: Remove unused and duplicate functions 2017-09-18 00:05:40 +02:00
Michael Fabian Dirks eb1612c6ee gs: Wrap OBS Graphics Subsystem in proper C++ classes 2017-09-18 00:05:28 +02:00
Michael Fabian Dirks 607c8bf170 filter-transform: Formatting, Camera improvements and general fixes 2017-08-20 00:31:19 +02:00
Michael Fabian Dirks 4dbf414214 effects, filter-blur: Precalculated Kernel, Formatting, Rendering and more
Filter:
* Massively improved Rendering loop to reduce overhead and provide cleaner code.

Gaussian Blur:
* Added precalculated Kernels using Textures. Slightly reduced GPU load.
* Added basic attempt at a Nvidia o(n/2+1) gaussian blur implementation.
* Fix up LOD for texture sampling.

Box Blur:
* Halved loop count.
2017-08-20 00:25:05 +02:00
Michael Fabian Dirks 374d1183ea filter-shape: Formatting improvements 2017-08-19 23:56:53 +02:00
Michael Fabian Dirks 9c8778b6f6 filter-displacement: Formatting improvements 2017-08-19 23:56:05 +02:00
Michael Fabian Dirks 1b58632a3f plugin: Formatting 2017-08-19 23:47:54 +02:00
Michael Fabian Dirks 90138ef636 project: Update Copyright Notice 2017-08-19 23:41:53 +02:00
Michael Fabian Dirks 52c3a0171e filter-blur: Initial work on optimization 2017-07-18 16:50:30 +02:00
Michael Fabian Dirks 9c56898842 plugin: Formatting 2017-07-18 16:45:30 +02:00
Michael Fabian Dirks 58deaa9408 filter-displacement: Move effects to 'data/effects' 2017-07-06 06:23:06 +02:00
Michael Fabian Dirks 9967a6ebf0 filter-blur: Add Color Format option
This option allows applying the blur to other color formats such as YUV. Bilateral Blur benefits the most from this, resulting in smoother images at lower kernel sizes.
2017-07-06 06:02:41 +02:00
Michael Fabian Dirks 9c97d90cc2 filter-blur: Split off blur rendering into method 2017-07-06 05:57:57 +02:00
Michael Fabian Dirks 191b1ea23f filter-blur: Move effects to 'data/effects'
This should help reusing the same effect instead of having an effect per filter.
2017-07-06 05:52:46 +02:00
Michael Fabian Dirks d4778a56f4 gs-helper: Fix formatting of License header 2017-07-06 05:03:32 +02:00
Michael Fabian Dirks 2621d4961f filter-blur: Multiple changes, see description
* Added a 'Bilateral' de-noising blur, currently very resource hungry. It also has two extra sliders called 'Smoothing' and 'Sharpness', the former controls how smooth the output is
* Updated effect loading to be global instead of per instance.
* Changed default blur size to 5px.
* Simplified render loop (see previous effect commit).
2017-07-03 07:20:15 +02:00
Michael Fabian Dirks 5cdbb127c7 filter-blur: Add Box and Gaussian Blur Filter
This is not very optimized at the moment and will take quite a bit of GPU time. Will have to spend some time later to optimize it and perhaps add directional blur ("Motion Blur" to it).
2017-07-03 02:46:45 +02:00