Commit Graph

7343 Commits

Author SHA1 Message Date
Pekka Paalanen
83e4315e41 gl-renderer: pass 'gr' from draw_view()
Avoid looking up 'gr' from view->compositor by passing it explicitly
into the functions needing it.

Also fixes the whitespace in repaint_region() signature.

Clarifies code by removing local variables, but also future changes will
need 'gr' more.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-04-07 11:45:10 +00:00
Pekka Paalanen
6e45fcc999 gl-renderer: move gl_renderer_send_shader_error() upwards
A future change will call this function from draw_view(), so move it
upwards to avoid adding a function declaration.

No functional or even cosmetic change.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-04-07 11:45:10 +00:00
Pekka Paalanen
9f428a633c gl-renderer: move functions into gl-shaders.c
These functions are related to shaders, so they are more at home in
gl-shaders.c. gl-renderer.c is too long already.

This allows making a couple functions static while the moved functions
become non-static. Future changes turn some of these functions into
static again, with the ultimate goal of making struct gl_shader opaque.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-04-07 11:45:10 +00:00
Marius Vlad
73aaf14ebe kiosk-shell: Read background-color from ini file
desktop-shell's client is able to read-up from the config file, [shell]
section the background, but for kiosk-shell we don't actually have
client that does that, so instead allow the shell do that directly.
Seems to be a useful thing to have, as a default background color.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-04-04 19:00:31 +03:00
Marius Vlad
bf3e200169 kiosk-shell: Add transform_handler to correctly position xwayland surfaces
When using xwayland surfaces and multiple outputs we need to notify
xwayland surface that the surface position has changed, otherwise we're
going to end up with pop-ups being displayed on other outputs rather
than the one were the main surface resides.

Stolen from desktop-shell.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2021-04-04 18:45:33 +03:00
Marius Vlad
15363291c1 kiosk-shell: Enable screenshooter in kiosk-shell
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-04-04 18:45:33 +03:00
Marius Vlad
d171c7b3ba libweston/backend-drm: Re-order gbm destruction at DRM-backend tear down
Tearing down the drm-backend when there are no input devices, would call
for the gbm device destruction before compositor shutdown. The latter
would call into the renderer detroy function and assume that the
EGLDisplay, which was created using the before-mentioned gbm device, is
still available. This patch re-orders the gbm destruction after the
compositor shutdown when no one would make use of it.

Fixes: #314

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2021-04-01 11:28:44 +03:00
Simon Ser
8df8532ee5 clients/simple-dmabuf-egl: add format option
This allows to specify a custom DRM format. For instance, to test
XBGR2101010:

    weston-simple-dmabuf-egl -f 0x30334258

Signed-off-by: Simon Ser <contact@emersion.fr>
2021-03-22 16:02:47 +00:00
Pekka Paalanen
0b61620c22 doc: fix udev rule in calibration-helper.bash
This used a cargo-culted form of the ACTION check. Kernel is allowed to
invent new ACTIONs and IIRC there are already actions like bind and
unbind.

Udev events before rule processing always start with a clean property
list. This means that if you only match ACTION==add to add some value to
the event, then that value will not be present for ACTION==bind. Udev
event consumers do not accumulate values, so inconsistent value setting
may confuse them.

Therefore one needs to match ACTION!=remove, not ACTION==add|change, to
keep the device properties consistent for every event. It doesn't hurt
to set them on remove either, but it's a habit to try to avoid
processing when not strictly needed.

This issue came up in
https://gitlab.freedesktop.org/wayland/weston/-/issues/476#note_841430

For more information, see
https://lists.freedesktop.org/archives/systemd-devel/2020-November/045570.html
the part "KERNEL API INCOMPATIBILITY" near the beginning.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-18 11:06:08 +02:00
Leandro Ribeiro
91f398bc30 libweston: do not forget to check if test_data is NULL
Since commit "libweston: add required_capabilities test suite quirk"
a new function that depends on test_data is being called in wet_main().

We should check if test_data is NULL before calling it, otherwise
we have a segfault when running outside the test suite.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-03-16 15:03:49 -03:00
Pekka Paalanen
1c73ff8d57 CI: test skips are failures
In CI we should never get a skip, so turn them into failures to make
sure we notice.

This is enabled only for the configuration where we build everything. If
anything is disabled, skips are expected.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-12 16:14:28 +02:00
Pekka Paalanen
ee38ed80d8 tests: add build option to force skips as failures
This will be useful in CI, where we do not want to see any skips. If
something starts to skip, that's a mistake somewhere, and want to catch
it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-12 16:14:28 +02:00
Pekka Paalanen
cde58fd20a build: add -Wundef
There is no case in pre-processor directives where would like to have
undefined identifiers be silently replaced with a zero. This warning can
discover typos and forgotten includes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-12 16:14:28 +02:00
Pekka Paalanen
a4ecf96316 libweston: fix #ifdef ENABLE_EGL
Everywhere else uses #ifdef, this used just #if. When the next commit
adds -Wundef to the compiler options, this #if here will start failing
as ENABLE_EGL is undefined.

It would be much better to use Meson's set10() for ENABLE_EGL and change
all #ifdef into #if, but I opted for the smaller change for now.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-12 16:14:28 +02:00
Pekka Paalanen
e88de3ef37 tests: define ENABLE_JUNIT_XML to 1 or 0
Code is using the form
  #if ENABLE_JUNIT_XML
which is fine until we start using -Wundef. I think the existing code
would fail or at least warn if you disabled test-junit-xml with -Wundef.

Make sure ENABLE_JUNIT_XML is always defined so that -Wundef can be
added to build flags.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-12 16:14:28 +02:00
Pekka Paalanen
f1fb48ed28 tests: let output damage skip without color ops
If the compositor does not have the shadow buffer capability (implied by
the color ops capability bit), then trying to run the shadow buffer test
is useless, it would just fail. Let it skip instead.

Fixes: b1e56143c5

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-12 16:14:28 +02:00
Pekka Paalanen
19d31dd4c3 libweston: add required_capabilities test suite quirk
This allows tests to skip when required capabilities are not present.
The output damage test for the shadow buffer case needs this.

required_capabilities is added to struct weston_testsuite_quirks which
is libweston public API just because there is no better place currently.
This is a little weird because the code to check it is in compositor,
not libweston.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-12 16:14:28 +02:00
Pekka Paalanen
ed2182f356 compositor: print all existing capability bits
Gives a string for all existing capability bits. This is useful for the
next commit.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-09 12:13:08 +02:00
Pekka Paalanen
eb2aa7d8f3 compositor: move colon in capability printing
The capability strings will be printed also in another occasion, where
the colon does not fit with the capability description.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-09 12:13:08 +02:00
Pekka Paalanen
f6ff85b1b7 CI: work around Gitlab Cobertura parsing quirk
This should not be necessary, but my testing with fd.o Gitlab 13.9.1
shows this is needed. Otherwise the coverage markings will not appear in
a MR diff view.

Apparently Gitlab has some problem with 'filename' attribute containing
"../" in Cobertura XML files, even when that does result in a correct
path. Or maybe the problem is is with the <source> path referring to the
build dir which from Gitlab perspective does not exist in the project,
even though builddir/../ is a good path.

This sed hack removes the "../" part and the last element in the
<source> path correspondingly.

See https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/567
for my testing.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-08 15:57:34 +02:00
Pekka Paalanen
e72119f1ee CI: add test coverage results
This runs the coverage tools to produce HTML pages listing the code lines /
functions / branches hit/totalled by the test suite.

Nowadays Gitlab has some Cobertura support itself:
https://docs.gitlab.com/ee/user/project/merge_requests/test_coverage_visualization.html

lcov is needed for the HTML report, gcovr is needed for the Cobertura
report. 'ninja clean' must be removed, otherwise it deletes the coverage
files before they are analysed.

Seeing the test suite code coverage is really interesting. It can guide
designing tests. If Gitlab MRs show the coverage in diff view, it shows
if new code actually gets executed in CI.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-03-08 15:55:14 +02:00
Vlad Zahorodnii
022ea43f9b xwayland: Pass -listenfd instead of -listen <fd>
The -listen <fd> option has been deprecated. Its replacement is -listenfd.

Signed-off-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2021-03-04 09:35:55 +00:00
Marius Vlad
e62ccf179a kiosk-shell: Give keyboard focus when mapping the surface
Doing it when the surface is being added would cause clients that
wait for frame callbacks to wait indefinitely as the surface being
activated is not yet, committed.

Fixes: #473

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-02-28 19:37:41 +02:00
Pekka Paalanen
f65ba18853 gl-renderer: print use time with gl-shader-generator debug
This should help correlate which shaders were used in repainting outputs
recently.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
1ed2cad87e gl-renderer: garbage-collect old shaders
This adds a heuristic for freeing shader programs that have not been
needed for a while. The intention is to stop Weston accumulating shader
programs indefinitely, especially in the future when color management
will explode the number of possible different shader programs.

Shader programs that have not been used in the past minute are freed,
except always keep the ten most recently used shader programs anyway.
The former rule is to ensure we keep shader programs that are actively
used regardless of how many.  The latter rule is to prevent freeing too
many shader programs after Weston has been idle for a long time and then
repaints just a small area. Many of the shader programs could still be
relevant even though not needed in the first repaint after idle.

The numbers ten and one minute in the above are arbitrary and not based
on anything.

These heuristics are simpler to implement than e.g. views taking
references on shader programs. Expiry by time allows shader programs to
survive a while even after their last user is gone, with the hope of
being re-used soon. Tracking actual use instead of references also
adapts to what is actually visible rather than what merely exists.

Keeping the shader list in most recently used order might also make
gl_renderer_get_program() more efficient on average.

last_repaint_start time is used for shader timestamp to avoid calling
clock_gettime() more often. Adding that variable is an ABI break, but
libweston major has already been bumped to 10 since last release.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
a8c4dfead5 gl-renderer: log shader deletions too
This is useful for seeing that the shader program garbage collection
works in a future patch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
40c26a0b7c gl-renderer: add compositor shorthand pointer
One more thing is coming to need this, so add the compositor pointer and
migrate existing places to use it where it simplifies things.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
768f07cb38 gl-renderer: whitespace style clean-up
Fix some deviations from the coding style.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
9a59303a4f gl-renderer: doc YCbCr-RGB conversion
I have verified that the conversion here follows ITU-R BT.601 except for
the offsets 16/256 and 128/256 which should be 16/255 and 128/255
respectively.

I used to following octave script to verify this:

rf = 0.299;
gf = 0.587;
bf = 0.114;

crdiv = 1.402;
cbdiv = 1.772;

M = [ rf, gf, bf ;
      -rf / cbdiv, -gf / cbdiv, (1 - bf) / cbdiv;
      (1 - rf) / crdiv, -gf / crdiv, -bf / crdiv ];

YCbCr = [ 'Y'; 'Cb'; 'Cr' ];
RGB = [ 'R'; 'G'; 'B' ];
eq = [ ' '; '='; ' ' ];
l = [ ' [ '; ' [ '; ' [ ' ];
r = [ ' ] '; ' ] '; ' ] ' ];

mat = [
	sprintf('%9f %9f %9f', M(1,:));
	sprintf('%9f %9f %9f', M(2,:));
	sprintf('%9f %9f %9f', M(3,:));
];

[ l YCbCr r eq l mat r l RGB r ]

R = inv(M);

mat = [
	sprintf('%9f %9f %9f', R(1,:));
	sprintf('%9f %9f %9f', R(2,:));
	sprintf('%9f %9f %9f', R(3,:));
];

[ l RGB r eq l mat r l YCbCr r ]

[ R(:,1), R(:,2:3) .* (255/224) ]

The final matrix printed is what the shader uses down to +/- one digit,
so at least 7 correct decimals.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
2b5a863974 gl-renderer: move view alpha out of sample_input_texture()
Sampling input texture has nothing to do with view alpha. This clarifies
the code structure.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
3f6be39f94 gl-renderer: factor out sample_input_texture()
Reading the input texture is just one part of the future color pipeline,
so separate it into a function of its own. This makes it easier to add
more steps to the pipeline, and shows the green tint is separate as
well.

Making use of early returns, reducing the if-else ladder should help
with readability. Sharing the call to yuva2rgba() likewise.

Setting yuva.w = alpha is not shared though, in case support for AYUV
format might be added in the future.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
d278015d00 gl-renderer: drop redundant texture lookups
Do not call texture2D() in the shader when we already have the result.
Simpler code, maybe even a little bit faster?

Suggested-by: Harish Krupo <harishkrupo@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
a88144f9e1 gl-renderer: move magic constants into yuva2rgba()
These same magic constants were used in all cases, so move them into a
common place.

While we are touching all these lines, also change from the four floats
into a vec4. This allows further clean-up in the next patch.

This makes the code easier to read.

Behavior and results are unchanged.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
054ba37084 gl-renderer: move alpha pre-mult from YUV to RGB
Mathematically the result is the same, while multiplying RGB with alpha
is easier to understand as correct than the earlier form.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
a8d5ef4a04 gl-renderer: rename color uniform to unicolor
A more unique name is easier to grep for. Using 'color' as a local
variable might be useful in the future.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
f6a8aa15f5 tests: add XYUV8888 to yuv-test
This will hit the XYUV shader variant in GL-renderer that was not
covered in the test suite before.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen
30104bd89a gl-renderer: support XYUV8888 wl_shm format
This support is added so that the XYUV shader variant can be tested with
wl_shm from the test suite.

Libwayland version requirement is bumped to get WL_SHM_FORMAT_XYUV8888.
Libwayland is bumped to 1.18 too in the CI image. libwayland-dev package
is dropped, because we build wayland anyway.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:24 +02:00
Pekka Paalanen
4b301fe7f2 Add weston-drm-fourcc.h
This header is for sharing fallback definitions for drm_fourcc.h. A new
test in tests/yuv-buffer-test.c is going to be needing XYUV8888 format,
and more new formats will be expected with HDR supports.

Share these fallback definitions in one place instead of copying them
all over.

All users of drm_fourcc.h are converted to include weston-drm-fourcc.h
instead for consistency: have the same definitions available everywhere.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:35:03 +02:00
Pekka Paalanen
b9ca801324 drop MOD_INVALID, MOD_LINEAR definitions
MOD_INVALID came with libdrm 2.4.83 and MOD_LINEAR came with libdrm
2.4.82. libweston unconditionally depends on libdrm >= 2.4.95, so the
fallback is not necessary.

Since linux-dmabuf.h itself has no use for these and also forgets to
include drm_fourcc.h, .c files including drm_fourcc.h after this header
would trigger compiler warnings.

linux-dmabuf.c does need these, so add the proper include.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:35:03 +02:00
Pekka Paalanen
e51a75c7b3 gl-renderer: drop R8 and GR88 definitions
These were introduced in libdrm 2.4.68, commit
268ae7cae5afd76462c3ef14ed9021a2d40c2e57. Weston unconditionally
requires libdrm >= 2.4.95, so these fallback definitions are
unnecessary now.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:35:03 +02:00
Pekka Paalanen
b1e56143c5 tests: extend output-damage to GL shadow framebuffer
Extend the existing output-damage test to test
blit_shadow_to_output() specifically. This function had problems
originally, so make sure they can't reappear.

The added quirk is explained in the test.

An additional check of the quirk in gl_renderer_output_create() ensures
that the shadow framebuffer is really used. The test could false-pass if
the shadow is not used.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:27:33 +02:00
Pekka Paalanen
a3b68c29f9 CI: bump Mesa to 20.3.1
The version we used does not advertise GL_EXT_color_buffer_half_float
with llvmpipe even though the functionality seems to work.

If the extension is not advertised, the future commit
"tests: extend output-damage to GL shadow framebuffer"
will result in a test failure.

Upgrade Mesa, this gets the extension advertised and the test is happy.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:20:15 +02:00
Pekka Paalanen
81ef6d0ab3 compositor: add weston.ini option use-renderer-shadow
This adds an output section option use-renderer-shadow in weston.ini.
This option is only recognized with headless and DRM backends, because
it requires GL-renderer and does not support resizing outputs.

The option is called use-renderer-shadow because this is what it does
right now. In the future the same setting will be used to turn on more
complex image processing when operational pieces required for color
management land. Once color management is implemented, this option is
expected to be removed. This option allows developer testing of features
to be used to implement color management.

This is a rewrite of "weston.ini: introduce use-shadow-fbo in output
config" by Harish Krupo. The main.c code is structured differently, the
weston.ini option is renamed, and the man page paragraph is moved to
weston.ini.man with different content.

Cc: Harish Krupo <harishkrupo@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Harish Krupo
7ef26886f5 gl-renderer: implement intermediate framebuffer (shadow)
Proper color management will need blending done with linear light pixel
values, that is, EOTF applied before blending, and then inverse-EOTF
applied for scanout after blending. The simplest way to set that up is
to use an intemediate framebuffer a.k.a shadow buffer containing the
composited image in linear light values, then blit from that to the
actual framebuffer.

This patch implements the shadow buffer, but the linear light
blending is left for another patch. This allows GL-renderer to turn
WESTON_CAP_COLOR_OPS on.

Half-float is chosen as the buffer format because linear light values
require more bits to encode with sufficient precision than the usual
non-linear pixel values.

v2: Use /* */ instead of // (Pekka)
    Rename fbo and tex to shadow_{fbo,tex} (Pekka)
    Check for OpenGLES capabilities before creating
    shadow_{tex,fbo} (Pekka)

Signed-off-by: Harish Krupo <harishkrupo@gmail.com>

v3: Rebased.
    Simplified GL version checks (Sebastian)
    Apply changes from "libweston: add color ops cap and bool renderer
    shadow buffer"
    Renamed supports_half_float_texture to has_gl_half_float to
    follow the existing naming pattern.
    Introduce gl_renderer_create_shadow_16f().
    Undo moving of glViewport() call.
    Replace half_float_texture_enabled with shadow_exists().
    Introduce struct gl_output_state_shadow.
    Assert no resizing with shadow.
    Fix triangle fan debug.
    Rename repaint_from_texture() to blit_shadow_to_output().
    Rewrite commit message because linear light blending is not
    implemented in this patch.
    Fix blit_shadow_to_output() for scaled/transformed outputs and
    remove redundant code.
    Fix has_gl_half_float determination.

v4: Disable blending in blit_shadow. (Daniel)
    Port to gl_renderer_get_program().
    Make a generic fbo-texture struct with parameterized format. (Daniel)
    Change has_gl_half_float into gl_half_float_type.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
0692079aae pixman-renderer: share region_global_to_output()
Converting a region from global coordinates to output pixel coordinates
will become useful in GL-renderer soon, so move this function to be
shared. It is tricky to reinvent.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
b5265af620 libweston: add color ops cap and bool renderer shadow buffer
This adds the libweston capability bit for "color operations" which
refers to a renderer's support for operations needed for color
management. GL-renderer will grow the support while Pixman-renderer will
not, which is why the cap is needed.

To make an example use of the cap, this also adds new API:
weston_output_set_renderer_shadow_buffer(). This is a temporary API to
enable future experimental features. The first such feature will be the
renderer internal shadow buffer, the boolean variable for it taken from
Harish Krupo's "weston.ini: introduce use-shadow-fbo in output config".

Obviously this patch does not implement the renderer shadow buffer. No
renderer sets WESTON_CAP_COLOR_OPS yet so trying to enable it will fail.

The documentation here is deliberately vague, because the bits needed
for color management will come in trickling for a long time until we can
call it color management in any sense. Until then, the temporary API
shall remain, perhaps poorly named.

Cc: Harish Krupo <harishkrupo@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Harish Krupo
71078b4044 gl-renderer: Add debug scope for shader generator
This helps accounting how many shaders live in the cache, what the
shader source code is, and when shaders are compiled.

Signed-off-by: Harish Krupo <harishkrupo@gmail.com>

v2: Resolved rebase conflicts.
    Put shader_scope in struct gl_renderer, remove struct
    gl_shader_generator.
    Wrote commit message.
    Rebased for "gl-renderer: rewrite fragment shaders" which completely
    changed how shader sources are generated.
    Added cache statistics to debug output on subscribe.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
7714c6172d gl-renderer: add missing glActiveTexture calls
Various functions leave the current active texture as whatever. The
functions touched in this commit forgot to reset the active texture to
slot 0 before binding their textures. If not explicitly unbound, this
could leave textures lingering in unused slots, perhaps. Not sure if
that could cause any harm, but for consistency's sake, always use slot 0
when not multitexturing.

Found by code inspection.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
c12963f98d gl-renderer: add fallback shader
If shader compiling on demand fails, then rather than using whatever
random shader happens to be current, use an explicit fallback shader
painting stuff brown.

The color is chosen dim enough to hopefully not cause problems even in
a HDR setting as it will be written verbatim into the fb/shadow.

This also prevents NULL dereference on shader->key.variant in
draw_view().

One way to test this shader is to hack fragment.glsl:
 #if DEF_VARIANT == SHADER_VARIANT_EXTERNAL
 #extension GL_OES_EGL_image_external : require
+#error haa haa
 #endif

and then run e.g. weston-simple-dmabuf-v4l -f YUYV
with vivid kernel module loaded. This worked on Intel.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen
06c9d0f054 gl-renderer: send protocol error on shader failure
If we are trying to use a NULL shader, it is likely that the shader
compilation failed for some reason. Since we are trying this for a view,
the failure was probably triggered by a client. If there is a client,
get rid of it by sending it a protocol error. Hopefully the compositor
can then continue operation after a glitch on screen.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00