Commit Graph

1339 Commits

Author SHA1 Message Date
Timm Bäder
82ca65956f gl renderer: Make debugging code shorter 2020-11-02 14:55:14 -05:00
Timm Bäder
c8c2106f3e gl renderer: Refactor vertex data loading code 2020-11-02 14:55:14 -05:00
Timm Bäder
8178dfb85a gl renderer: Use the load_vertex_data* functions more often 2020-11-02 14:55:14 -05:00
Timm Bäder
50e78198a8 gl renderer: More load_vertex_data* usage 2020-11-02 14:55:14 -05:00
Timm Bäder
ee04cbcfa8 gl renderer: Reword a comment 2020-11-02 14:55:14 -05:00
Timm Bäder
fc312f7ffe gl renderer: Remove an outdated comment 2020-11-02 14:55:14 -05:00
Timm Bäder
e6e964c3f3 gl renderer: Refactor rendering shadow nodes
Also use load_vertex_data_with_region here.
2020-11-02 14:55:14 -05:00
Timm Bäder
df5e796d99 gl renderer: Refactor blurred shadow drawing code
We already have various load_vertex_data* code, so try to reuse that
here.
2020-11-02 14:55:14 -05:00
Timm Bäder
d3239c953d gl renderer: Nine-slice unblurred outset shadows
See #3284
2020-11-02 14:55:13 -05:00
Matthias Clasen
7db58d5f8d gsk: Don't compile unused code
The NodeSample and GskGLImage code is not used,
so don't compile it.
2020-10-30 23:36:39 -04:00
Matthias Clasen
03fec389f4 docs: Add details for gsk_renderer_new_for_surface
Mention the GSK_RENDERER variable here.
2020-10-29 18:21:44 -04:00
Christian Hergert
a3fd46c516 glsl: tweak pre-processor to support Apple GLSL compiler
The Apple GLSL compiler cannot deal with empty pre-processor blocks such as

  #if GSK_GLES
  #elif GSK_LEGACY
2020-10-29 10:57:02 -07:00
Timm Bäder
9109dee072 gl renderer: Don't use blur node bounds
The blur node bounds are different/larger than the ones we use. This
made the textures get stretched to the blur node bounds.

Fixes #3282
2020-10-22 17:46:34 +02:00
Timm Bäder
b6a843a05b gl renderer: Fix two scale_x/y mixups 2020-10-22 17:46:34 +02:00
Sophie Herold
cd0bef9390 Add some missing nullable return annotations 2020-10-17 15:32:36 +02:00
Timm Bäder
07fb33c033 gl renderer: Fix private function name
It's a GskGLRenderer, not a GskGLRender
2020-10-14 15:06:12 -04:00
Timm Bäder
1fe7043be4 gl renderer: Add more scale_x/scale_y code
We really need all of this to be aware of both dimensions of course...
2020-10-14 15:06:12 -04:00
Timm Bäder
0e6014f2f6 gl renderer: Remove two unused uniforms 2020-10-14 15:06:12 -04:00
Timm Bäder
0a4d442849 gl renderer: return empty texture for too small blurred nodes 2020-10-14 15:06:12 -04:00
Timm Bäder
5f9fa13c65 gl renderer: Use op builder to render flipped texture
Otherwise, we don't know about the uniform state
2020-10-14 15:06:12 -04:00
Timm Bäder
161b171004 gl renderer: Remove unused parameter 2020-10-14 15:06:12 -04:00
Timm Bäder
eb345cd033 gl renderer: Use nearest filtering for textures in render_texture()
Makes the output in the node editor a bit more bearable.
2020-10-14 15:06:12 -04:00
Timm Bäder
f456438051 vulkan: Remove double initialization
Clang said:

../gsk/vulkan/gskvulkanrenderpass.c:250:5: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
    .render.node = node
    ^~~~~~~~~~~~~~~~~~~
../gsk/vulkan/gskvulkanrenderpass.c:249:13: note: previous initialization is here
    .type = GSK_VULKAN_OP_FALLBACK,
            ^~~~~~~~~~~~~~~~~~~~~~
2020-10-14 15:06:12 -04:00
Timm Bäder
4735c27e69 gl renderer: Avoid some code duplication 2020-10-14 15:06:12 -04:00
Timm Bäder
44f10c5861 gl renderer: Flip texture in render_texture() 2020-10-14 15:06:12 -04:00
Timm Bäder
44d1e81ae9 glsl: Add a comment 2020-10-14 15:06:12 -04:00
Timm Bäder
ddcff9eb0f gl renderer: simplify ->render() implementation a bit
We already use self->scale_factor when initialized whole_surface,
so set self->scale_factor first.
2020-10-14 15:06:12 -04:00
Timm Bäder
9fe21b7181 shaderbuilder: Print error message after source code
My terminal scrolls down, so showing the error message last makes sense.
2020-10-14 15:06:12 -04:00
Timm Bäder
7bf858b9d0 gl renderer: Add a helper to setup projection matrix 2020-10-14 15:06:12 -04:00
Timm Bäder
bc034d1190 gl renderer: Ignore rendering if accumulated opacity is too small 2020-10-14 15:06:12 -04:00
Timm Bäder
7222a0901d unblurred outset shadow shader: Use premultiply() 2020-10-14 15:06:12 -04:00
Timm Bäder
a0bb248bb3 gl renderer: Use premultiply() in inset shadow shader` 2020-10-14 15:06:12 -04:00
Timm Bäder
982ebf1b69 gradient shaders: Reduce out values as well
We only do 6 color stops here now. Also works around a driver bug.

Fixes #3196
2020-10-05 20:35:34 -04:00
Alexander Larsson
24a27ba44f gl renderer: Fix up texture cache key
The commit e14d2be1 forgot to actually set the parent_rect in the texture
key in the case it is necessary.
2020-10-05 15:43:04 +02:00
Matthias Clasen
cef1cd19ff gsk: Avoid long lines in serialized nodes
When encoding big blobs of data in base64, insert newlines.
Base64 allows it, CSS allows it, so not need to make GtkTextView
struggle with multi-megabyte lines.

Update nodeparser tests to reflect this change.
2020-10-03 13:10:55 -04:00
Matthias Clasen
a9809b0f67 Allow inserting newlines in css strings
Rename _gtk_css_print_string to strip the _ and add
an insert_newlines argument to it. Update all callers,
and make the render node serializer insert newlines.
2020-10-02 23:40:16 -04:00
Matthias Clasen
9033336a23 css: Move _gtk_css_print_string around
Move this to a separate header, since it is not
parser functionality, and kill the duplicate
gtkcssparserprivate.h header.
2020-10-02 23:40:16 -04:00
Matthias Clasen
dc3b140fd7 Cosmetics 2020-10-01 13:48:24 -04:00
Matthias Clasen
b0da095944 gsk: Fix compiler warnings
We forgot to teach the broadway renderer about new enum
values, and our ci didn't catch it because werror didn't
actually work there until now.
2020-09-30 15:39:30 -04:00
Alexander Larsson
e14d2be1e8 gl renderer: Fix render node texture cache
We're caching two things, either a node itself being rendered, or a
parent storing a cached version of a child as rendered to an offscreen
the size and location of the parent.

If both the parent and child uses the cache this will cause a conflict in
the cache as it is currently use keying of a node pointer which will have
the same value for the node-as-itself and the child-node-of-the-parent.

We fix this by adding another part to the key "pointer_is_child" which means
we can have the same node pointer twice in the cache.

Additionally, in the child-is-rendered-offscreen case the offscreen
result actually depends on the position and size of the parent viewport,
so we need to store the parent bounds in that case.
2020-09-30 14:53:13 +02:00
Matthias Clasen
00c6340777 gsk: Add some more shader docs
Do a pass over the docs and address minor inconsistencies,
cosmetics and formatting differences.

Mention GSK_DEBUG=shaders.
2020-09-29 14:44:31 -04:00
Matthias Clasen
4cfa9ee19f Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2639
2020-09-29 12:57:36 +00:00
Matthias Clasen
07c338b487 gsk: Document radial gradient api 2020-09-29 07:04:07 -04:00
Alexander Larsson
51ab56d33a gl: Track the current uniform state for custom programs
This allows us to avoid updating uniforms if that is not necessary. This
in turn allows us to sometimes reuse the same draw op by just extending the
vertex array size we draw rather than doing a separate glDraw call.

For example, in the fishbowl demo, all the icons added at the same
time will have the same time and size, so we emit single draw calls
with 100s of triangles instead of 100s of draw calls with 2 triangles.
2020-09-29 11:52:39 +02:00
Alexander Larsson
4d697283ae Support GLShaderNode in backends
For vulkan/broadway this just means to ignore it, but for the gl
backend we support (with up to 4 texture inputs, which is similar to
what shadertoy does, so should be widely supported).
2020-09-29 09:51:16 +02:00
Alexander Larsson
7ea755e206 Add GskGLShaderNode and GskGLShader
A GskGLShader is an abstraction of a GLSL fragment shader that
can produce pixel values given inputs:
 * N (currently max 4) textures
 * Current arguments for the shader uniform
Uniform types are: float,(u)int,bool,vec234)
There is also a builder for the uniform arguments which are
passed around as immutable GBytes in the built form.

A GskGLShaderNode is a render node that renders a GskGLShader inside a
specified rectangular bounds. It renders its child nodes as textures
and passes those as texture arguments to the shader. You also pass it
a uniform arguments object.
2020-09-29 09:51:16 +02:00
Matthias Clasen
6e9b58b6f0 gsk: Add more shader debug spew
Print out the full assembled shader sources when
GSK_DEBUG=shaders is given. This is very verbose,
but may be useful to see what we actually pass
to the compiler.
2020-09-29 09:51:16 +02:00
Alexander Larsson
bacb3affb3 gl: Add some namespacing to the preamble symbols
This adds a gsk prefix to the stuff in the preamble, as we want to
avoid it conflicting with things in the main shader. Especially once
we start allow some customization of shaders.
2020-09-29 09:51:16 +02:00
Alexander Larsson
9460d0131f gl backend: Add line numbers to source in glsl compilation errors
Almost always the source is created by combining various sources, which
means the line numbers in the error messages are hard to use. Adding
the line numbers to the source in the error message helps with this.
2020-09-29 09:51:16 +02:00
Alexander Larsson
7edcd1748c gl: Properly report error if shader linking fails
In gsk_gl_shader_builder_create_program(), if linking fails we
need to return -1 to indicate error, rather than the old deleted
program id.
2020-09-29 09:51:16 +02:00