Commit graph

183 commits

Author SHA1 Message Date
Vlad Zahorodnii
46e452127e opengl: Add GLTexture::update() overload that takes a region
This ensures a couple of things:

- avoid pointlessly binding and unbinding the texture
- if the image format needs to be changed, it will be done only once
2024-08-16 19:03:40 +03:00
Xaver Hugl
ad27858df3 platformsupport/scene/opengl: do test imports for external_only formats properly
The scene renderer doesn't use external_only formats as a single EGLImage, but only does
YUV conversion for some specific formats, so the test import should match that.
2024-08-15 01:09:36 +02:00
Vlad Zahorodnii
2cc3f9cdee Avoid issuing many glTexSubImage2D() calls when uploading shm contents
Applications that use QtWidgets can have a lot of rectangles in the
damage region. For example, when you navigate between directories in
Dolphin, each individual file or folder item will be added to the
damage region rather than the container view where they are.

On the other hand, issuing multiple glTexSubImage2D() function calls
is not great because it means stalling the cpu until the texture upload
completes.

This change attempts to improve that by simplifying the input damage.
If the input damage isn't complex, use it as is; otherwise use its
bounding rect.

The gains are not impressive. On my machine, I see fewer 5ms texture
upload time spikes when navigating in Dolphin, now I can observe 4ms
spikes instead. Still, I believe the change is reasonable enough.
2024-08-14 13:18:33 +00:00
Vlad Zahorodnii
bc2c5bf43e Fix checking whether GraphicsBufferView is null
If the graphics buffer view is null, GraphicsBufferView::image() will
point to a valid memory location but the QImage at that address is going
to be null.
2024-07-30 14:02:16 +00:00
Aleix Pol Gonzalez
68d1e2f42a wayland: Log an entry when an unsupported buffer was submitted
It's fine to be conservative about what kind of buffers we support, but
failing silently only makes it hard on such cases.

Signed-off-by: Victoria Fischer <victoria.fischer@mbition.io>
2024-06-10 17:23:43 +02:00
Xaver Hugl
0f41239515 waylandserver: set render backend for linuxdrmsyncobj directly
The code would previously never set the render backend, causing the use of explicit sync
to fail

BUG: 486391
2024-05-22 00:26:14 +02:00
Xaver Hugl
219f110093 backends: move render time queries into OutputFrame
This way, multiple OutputFrames can be pending at the same time, without
interfering in each other's render time queries
2024-05-02 13:03:27 +00:00
Vlad Zahorodnii
5c93c4251b Fix scanout device information when running nested kwin
Without it, there are issues with running Xwayland.
2024-04-28 15:15:20 +00:00
Xaver Hugl
32addf4d59 wayland: implement linux-drm-syncobj-v1
linux-drm-syncobj-v1 allows drivers and apps to synchronize KWin's buffer access
to their rendering, and synchronize their rendering to KWin's buffer release. This
fixes severe glitches with the proprietary NVidia driver and allows for some
performance improvements with Mesa too.
2024-04-10 19:06:00 +02:00
Vlad Zahorodnii
883acb1f58 scene: Update surface texture in preprocess()
If two items display image data, the item renderer needs to special case
each item. It's not an extensible design, and my long term goal is to
introduce a separate tree specifically to solve this problem and also
help with computing the repaint damage automatically, instead of issuing
scheduleRepaint()s manually.

The first step is to refactor the item renderer so it merely takes the
input data and renders it. At the moment, it's not exactly the case
because surface textures are updated while painting the items, which
inherently requires special casing. This change moves surface texture
update code to the surface item so it's easier to refactor rendering code
in the item renderer.
2024-04-03 11:45:28 +00:00
Xaver Hugl
686ea6374b backends/x11/standalone: port the egl backend away from AbstractEglBackend
This reduces the requirement on AbstractEglBackend to accomodate for X11
2024-03-25 12:52:31 +00:00
Xaver Hugl
6a4a68dea4 backends: expose the DrmDevice instead of an allocator 2024-03-22 12:07:29 +01:00
Xaver Hugl
af3bf939c5 platformsupport/scenes/opengl: don't access std::nullopt 2024-03-17 18:08:36 +01:00
Xaver Hugl
2a13a33040 platformsupport/scenes/opengl: advertise formats unnknown to KWin too
While KWin may not have information about the formats, that doesn't mean KWin
should filter them out - EGL can still import them, so allow clients to use them
2024-03-17 03:01:09 +00:00
Xaver Hugl
493797ff31 opengl: move extension function resolving and debug output into OpenGlContext 2024-03-08 17:26:54 +00:00
Xaver Hugl
7618be3697 opengl/glplatform: remove dependency on OpenGlContext 2024-03-08 17:26:54 +00:00
Xaver Hugl
a8b9e8d262 opengl: remove most of glutils 2024-03-08 17:26:54 +00:00
Xaver Hugl
f98477e05b opengl/glframebuffer: move static variables to OpenGlContext 2024-03-08 17:26:54 +00:00
Xaver Hugl
9e70c2a21c backends/drm: always prefer 10bpc buffers when supported
The environment variable is primarily meant as a workaround for displays
and drivers that misbehave when more than 8 bits per color is used. To simplify
the code, this commit makes the environment variable only control the bpc
used for displays, instead of also controlling which buffer formats get
used.
2024-02-27 21:01:28 +01:00
Vlad Zahorodnii
13c092d671 Fix a crash in eglDestroyImageKHR()
Apparently, libepoxy requires a current EGL display in order to resolve
EGL functions. This is unexpected as most of the EGL functions require no
current opengl context.

This change makes kwin bypass libepoxy for problematic cases.

BUG: 470980
2024-02-26 15:31:30 +02:00
Xaver Hugl
0ed66ed5d2 move more opengl related files to the opengl folder 2024-01-09 19:45:59 +01:00
Vlad Zahorodnii
f8df72497f opengl: Replace TextureTransform with OutputTransform
It reduces duplication of same math code.
2024-01-09 17:42:09 +00:00
Xaver Hugl
673cb16f15 utils: move drm format list to a cpp file
Makes compilation a little bit faster and removes warnings about the unused
function in some files
2023-11-24 16:14:07 +01:00
Xaver Hugl
9e03a219cb platformsupport/scenes/opengl: don't crash when creating the texture fails 2023-11-23 18:46:03 +00:00
Xaver Hugl
985f0edf88 platformsupport/scenes/openglbackend: increase GPU reset timeout again
Apparently it can take a while in some cases, so this commit increases the
timeout to 10s
2023-11-23 17:36:41 +01:00
Aleix Pol
4540925f3f Remove unnecessary variable 2023-11-21 18:52:40 +00:00
Aleix Pol
97e75c858a nv12: Remove unnecessary debug
Forgot to remove it before merging the patch
2023-11-21 18:52:40 +00:00
Aleix Pol Gonzalez
b860439be5 Allow support dmabuf formats that we have conversions for.
If there's a supported mechanism to handle the format, announce them as
supported.
If there are modifiers supported by the graphics card (even though as
external only), offer them as well.
2023-11-15 21:42:05 +01:00
Aleix Pol Gonzalez
3568829216 opengl: Add support for NV12 on Wayland dmabufs
Offers wayland clients the possibility to send us their contents using
an NV12 texture.
It implements it by rendering into scene using a shader.
2023-11-15 21:32:25 +01:00
Xaver Hugl
ee146d33b9 libkwineffects: move files out to more fitting places 2023-11-14 17:03:40 +01:00
Xaver Hugl
d0a9e90716 platformsupport/scenes/opengl: fix format filtering
We support formats that are neither 10 nor 8 bits per color, so the filtering needs
to reflect that
2023-11-06 12:42:00 +01:00
Vlad Zahorodnii
d7b1661e08 Merge libkwineffects into libkwin
libkwineffects was introduced when kwin used to be an executable. It
provided an api to implement effects and shielded from the technical
quirks in kwin.

Over the time, kwin internals had been split and abstractions were
refactored so they can be consumed in scripts or plugins. Besides that,
new ways to implement extensions have been introduced, which use
kwin's internal abstractions.

On the other hand, effects continue using libkwineffects specific apis.
This has a few issues: qtquick effects use both apis and it bites us,
duplicating same apis.

The best solution so far is to merge libkwineffects with libkwin, and
replace libkwineffects abstractions with libkwin abstractions, e.g.
EffectScreen -> Output, etc. This change takes care of adjusting libs.

Obviously, the main disadvantage of doing so is that binary effects
have to be recompiled every time new libkwin is released. But it's
already the case with libkwineffects too.
2023-10-25 12:46:12 +00:00
Laurent Montel
bc6116c5a7 There's no QVector anymore, QList is the QVector in Qt6 2023-10-19 13:43:53 +00:00
Xaver Hugl
ae09600481 platformsupport/scenes/opengl: add a factory function for EglSwapchainSlot
This makes it more obvious that creating slots can fail, and makes it simpler to add
checks for that
2023-09-28 23:27:37 +00:00
Xaver Hugl
d6bc5d9b14 platformsupport/scenes/opengl: don't crash when importing a texture fails
CCBUG: 474933
2023-09-27 17:31:12 +00:00
Xaver Hugl
a4dedb64f6 backends/drm: handle multiple OpenGl contexts more correctly
In order to destroy resources from a context on the secondary GPU, that
context needs to be current. We also want to destroy the context once it's
no longer used, if the GPU is unplugged etc, so this commit uses shared
and weak pointers to manage the lifetime of the contexts
2023-09-27 14:42:13 +00:00
Vlad Zahorodnii
4d2c9f5d88 Refactor compositing config loading
Config loading is split in two groups: loading compositing config and
loading the rest. They are loaded separately at different times. Some
options are loaded in the Options constructor, some are loaded when compositing
starts, some are loaded when the Workspace is created. It's not easy to
keep track of what loads what and when.

This change simplifies option handling by loading all options in bulk
and decouples Options from OutputBackend and GLPlatform to ensure that
it can safely load options before kwin is fully operational.
2023-09-18 13:40:33 +00:00
Vlad Zahorodnii
de36fe82e8 wayland: Integrate KWaylandServer classes into KWin namespace 2023-09-15 16:31:15 +03:00
Vlad Zahorodnii
14ab38b596 composite.h -> compositor.h 2023-09-08 09:48:59 +03:00
Xaver Hugl
6d35a27f90 libkwineffects: drop checks for GLSL and NPOT
Instead, creating contexts that miss these features should fail directly,
making KWin fall back to software rendering.
While this commit also drops workarounds for broken drivers that do software
emulation for features we need, such workarounds belong into these drivers and
the user can still manually turn off compositing if needed.
2023-09-07 21:13:16 +02:00
Xaver Hugl
451947b282 backends/x11/standalone: extract glx context into a separate class
This commit also drops most of the code around checks for direct rendering. If
direct rendering isn't supported, creating the OpenGL context will now simply fail,
achieving the same effect
2023-09-07 16:41:22 +02:00
Xaver Hugl
27f90476b4 libkwineffects: rename kwingl* files to gl* 2023-09-07 16:41:22 +02:00
Xaver Hugl
02b996cf9c platformsupport/scenes/opengl: add opengl render query class 2023-08-23 10:51:19 +00:00
Xaver Hugl
74f10d0cdf port most uses of the reset(new ...) pattern to std::make_unique 2023-08-11 15:58:15 +02:00
Vlad Zahorodnii
1687183d4d qpa: Port OpenGL code path to GraphicsBuffer
This allows us to unify graphics buffer handling for normal wayland
windows and internal windows.
2023-08-07 13:17:18 +00:00
Xaver Hugl
53c2b8c68b port most remaining uses of EGLDisplay and EGLContext to their wrappers 2023-07-29 22:07:46 +00:00
Vlad Zahorodnii
762254c354 qpa: Port BackingStore to shared memory graphics buffer allocator
At the moment, graphics buffers coming from wayland and internal windows
use different code paths to update textures. However, they don't have
to.

If the internal windows are ported to GraphicsBuffer, it will be
possible to unify SurfacePixmapInternal and SurfacePixmapWayland to make
pixmap logic a bit simpler.
2023-07-26 07:29:27 +00:00
Xaver Hugl
d3fed712f0 platformsupport/opengl: support implicit modifiers even with explicit modifiers
This is needed to make the combination of explicit modifier OpenGL + implicit modifier drm
backend work
2023-07-25 16:08:38 +00:00
Xaver Hugl
4cb665dd08 platformsupport/scenes/opengl: fix simpledrm
With simpledrm, only linear modifiers are supported, but with llvmpipe, only
implicit modifiers are supported. As it's still possible to allocate linear
buffers without modififer support by using GBM_BO_USE_LINEAR, this commit fixes
that problem by adding linear modififers to the supported list.
2023-07-17 09:34:04 +02:00
Laurent Montel
b823747c3b Add explicit moc includes to sources for moc-covered headers
* speeds up incremental builds as changes to a header will not always
  need the full mocs_compilation.cpp for all the target's headers rebuild,
  while having a moc file sourced into a source file only adds minor
  extra costs, due to small own code and the used headers usually
  already covered by the source file, being for the same class/struct
* seems to not slow down clean builds, due to empty mocs_compilation.cpp
  resulting in those quickly processed, while the minor extra cost of the
  sourced moc files does not outweigh that in summary.
  Measured times actually improved by some percent points.
  (ideally CMake would just skip empty mocs_compilation.cpp & its object
  file one day)
* enables compiler to see all methods of a class in same compilation unit
  to do some sanity checks
* potentially more inlining in general, due to more in the compilation unit
* allows to keep using more forward declarations in the header, as with the
  moc code being sourced into the cpp file there definitions can be ensured
  and often are already for the needs of the normal class methods
2023-07-15 08:40:49 +00:00