diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-11-29 14:53:59 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-12-07 16:32:05 +0100 |
commit | d9cdfeebd9eb6a067b97316daa149c7f58e1c7ec (patch) | |
tree | 9ad8ae07190f6e491397272114f0e7c4539e5c1d /src/qtmultimediaquicktools/shaders | |
parent | 466a4f29c20b6d797af9d67029a7329b2124b276 (diff) |
Use AVPlayerItemVideoOutput to generate video frames
This fixes rendering problems on M1 based Macs.
It also unifies the rendering pipeline between macOS and iOS as
much as possible, and avoids an intermediate copy to an FBO,
Since AVPlayerItemVideoOutput produces GL_TEXTURE_RECTANGLE
textures on macOS a new QAbstractVideoBuffer handle has been
added that explicitly maps to GL_TEXTURE_RECTANGLE.
We use this handle type internally in QSGVideoMaterial_Texture
where we know how to blit GL_TEXTURE_RECTANGLE textures.
To maintain compatibility for QAbstractVideoSurface consumers who
expect GL_TEXTURE_2D textures we blit the rectangle texture to
an FBO returned as QAbstractVideoBuffer::GLTextureHandle.
Fixes: QTBUG-89803
Done-with: Lars Knoll <lars.knoll@qt.io>
Change-Id: I36d22eafb63902ecc1097e138705812ef6a8cb71
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Doris Verria <doris.verria@qt.io>
Diffstat (limited to 'src/qtmultimediaquicktools/shaders')
4 files changed, 39 insertions, 0 deletions
diff --git a/src/qtmultimediaquicktools/shaders/rectsampler.vert b/src/qtmultimediaquicktools/shaders/rectsampler.vert new file mode 100644 index 000000000..762ec7e7e --- /dev/null +++ b/src/qtmultimediaquicktools/shaders/rectsampler.vert @@ -0,0 +1,10 @@ +uniform highp mat4 qt_Matrix; +uniform highp vec2 qt_videoSize; +attribute highp vec4 qt_VertexPosition; +attribute highp vec2 qt_VertexTexCoord; +varying highp vec2 qt_TexCoord; + +void main() { + qt_TexCoord = vec2(qt_VertexTexCoord.x * qt_videoSize.x, qt_VertexTexCoord.y * qt_videoSize.y); + gl_Position = qt_Matrix * qt_VertexPosition; +} diff --git a/src/qtmultimediaquicktools/shaders/rectsampler_core.vert b/src/qtmultimediaquicktools/shaders/rectsampler_core.vert new file mode 100644 index 000000000..f0fe02349 --- /dev/null +++ b/src/qtmultimediaquicktools/shaders/rectsampler_core.vert @@ -0,0 +1,11 @@ +#version 150 core +uniform highp mat4 qt_Matrix; +uniform highp vec2 qt_videoSize; +in highp vec4 qt_VertexPosition; +in highp vec2 qt_VertexTexCoord; +out highp vec2 qt_TexCoord; + +void main() { + qt_TexCoord = vec2(qt_VertexTexCoord.x * qt_videoSize.x, qt_VertexTexCoord.y * qt_videoSize.y); + gl_Position = qt_Matrix * qt_VertexPosition; +} diff --git a/src/qtmultimediaquicktools/shaders/rectsampler_rgb.frag b/src/qtmultimediaquicktools/shaders/rectsampler_rgb.frag new file mode 100644 index 000000000..2a30f7c3d --- /dev/null +++ b/src/qtmultimediaquicktools/shaders/rectsampler_rgb.frag @@ -0,0 +1,8 @@ +uniform sampler2DRect rgbTexture; +uniform lowp float opacity; +varying highp vec2 qt_TexCoord; + +void main() +{ + gl_FragColor = texture2DRect(rgbTexture, qt_TexCoord) * opacity; +} diff --git a/src/qtmultimediaquicktools/shaders/rectsampler_rgb_core.frag b/src/qtmultimediaquicktools/shaders/rectsampler_rgb_core.frag new file mode 100644 index 000000000..17f306456 --- /dev/null +++ b/src/qtmultimediaquicktools/shaders/rectsampler_rgb_core.frag @@ -0,0 +1,10 @@ +#version 150 core +uniform sampler2DRect rgbTexture; +uniform lowp float opacity; +in highp vec2 qt_TexCoord; +out vec4 fragColor; + +void main() +{ + fragColor = texture(rgbTexture, qt_TexCoord) * opacity; +} |