NV12 GPU copies to staging textures for CPU read take a ridiculously
long time on my integrated Intel GPU. Using R8/R8G8 instead seems to be
a huge speed-up.
Intel HD Graphics 530, D3D11 query timings, SetStablePowerState
NV12: ~3268 us (minimum of wild timings)
R8/R8G8: ~781 us (most frequently occurring timing)
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.
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.
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
There are cases where alpha is multiplied unnecessarily. This change
attempts to use premultiplied alpha blending for composition.
To keep this change simple, The filter chain will continue to use
straight alpha. Otherwise, every source would need to modified to output
premultiplied, and every filter modified for premultiplied input.
"DrawAlphaDivide" shader techniques have been added to convert from
premultiplied alpha to straight alpha for final output. "DrawMatrix"
techniques ignore alpha, so they do not appear to need changing.
One remaining issue is that scale effects are set up here to use the
same shader logic for both scale filters (straight alpha - incorrectly),
and output composition (premultiplied alpha - correctly). A fix could be
made to add additional shaders for straight alpha, but the "real" fix
may be to eliminate the straight alpha path at some point.
For graphics, SrcBlendAlpha and DestBlendAlpha were both ONE, and could
combine together to form alpha values greater than one. This is not as
noticeable of a problem for UNORM targets because the channels are
clamped, but it will likely become a problem in more situations if FLOAT
targets are used.
This change switches DestBlendAlpha to INVSRCALPHA. The blending
behavior of stacked transparents is preserved without overflowing the
alpha channel.
obs-transitions: Use premultiplied alpha blend, and simplify shaders
because both inputs and outputs use premultiplied alpha now.
Fixes https://obsproject.com/mantis/view.php?id=1108
This reverts commit d91bd327d7a8bb4597562fc26da4edb7b56874ff, which
broke alpha with sources, scenes, and filter, causing them all to become
opaque unintentionally.
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
Currently SrcBlendAlpha and DestBlendAlpha are both ONE, and can
combine together to form two. This is not a noticeable problem for
UNORM targets because the channels are clamped, but it will likely
become a problem if FLOAT targets are more widely used.
This change switches DestBlendAlpha to INVSRCALPHA, and starts
backgrounds as opaque black instead of transparent black. The blending
behavior of stacked transparents is preserved without overflowing the
alpha channel.
On some AMD systems, the test for bad NV12 output would come up negative
(output was good), but when recording/streaming, it would have bad
output. While the test worked correctly with NVIDIA systems, it did not
work in these cases. This was because we did not correctly reproduce
the exact conditions of green output because the textures used for the
test were not also keyed mutex shared textures. This fixes that issue
and ensures the test works correctly in those other niche cases.
Performs a test on a texture to determine if NV12 textures are
functioning correctly. Older NVIDIA drivers appear to have a bug where
they will output their UV channel data on to the Y channel when copying
from the GPU. This test on startup determines whether that bug is
occurring, and if so, disables NV12 texture support.
If a texture has to be rebuilt due to a driver reset and is a keyed
mutex shared texture, make sure to reacquire the shared handle and
acquire the lock.
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.
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);
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.
Closesjp9000/obs-studio#1142
(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.
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.
Closesjp9000/obs-studio#1064
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.
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.