mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 22:41:43 +00:00
96b800fa0c
If glBufferStorage() is available, we can replace our usage of glBufferSubData() with persistently mapped storage via glMappedBufferRange(). This has 1 disadvantage: 1. It's not supported everywhere, it requires GL 4.4 or GL_EXT_buffer_storage. But every GPU of the last 10 years should implement it. So we check for it and keep the old code. The old code can also be forced via GDK_GL_DISABLE=buffer-storage. But it has 2 advantages: 1. It is what Vulkan does, so it unifies the two renderers' buffer handling. 2. It is a significant performance boost in use cases with large vertex buffers. Those are pretty rare, but do happen with lots of text at a small font size. An example would be a small font in a maximized VTE terminal or the overview in gnome-text-editor. A custom benchmark tailored for this problem can be created with: tests/rendernode-create-tests 1000000 text.node This creates a node file called "text.node" that draws 1 million text nodes. (Creating that test takes a minute or so. A smaller number may be useful on less powerful hardware than my Intel Tigerlake laptop.) The difference can then be compared via: tools/gtk4-rendernode-tool benchmark --runs=20 text.node and GDK_GL_DISABLE=buffer-storage tools/gtk4-rendernode-tool benchmark --runs=20 text.node For my laptop, the difference is: before: 1.1s after: 0.8s Related: !7021
28 lines
1.3 KiB
C
28 lines
1.3 KiB
C
#pragma once
|
|
|
|
#include "gskgpubufferprivate.h"
|
|
|
|
#include "gskgldeviceprivate.h"
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
#define GSK_TYPE_GL_BUFFER (gsk_gl_buffer_get_type ())
|
|
#define GSK_TYPE_GL_MAPPED_BUFFER (gsk_gl_mapped_buffer_get_type ())
|
|
#define GSK_TYPE_GL_COPIED_BUFFER (gsk_gl_copied_buffer_get_type ())
|
|
|
|
G_DECLARE_FINAL_TYPE (GskGLBuffer, gsk_gl_buffer, GSK, GL_BUFFER, GskGpuBuffer)
|
|
G_DECLARE_FINAL_TYPE (GskGLMappedBuffer, gsk_gl_mapped_buffer, GSK, GL_MAPPED_BUFFER, GskGLBuffer)
|
|
G_DECLARE_FINAL_TYPE (GskGLCopiedBuffer, gsk_gl_copied_buffer, GSK, GL_COPIED_BUFFER, GskGLBuffer)
|
|
|
|
GskGpuBuffer * gsk_gl_mapped_buffer_new (GLenum target,
|
|
gsize size);
|
|
GskGpuBuffer * gsk_gl_copied_buffer_new (GLenum target,
|
|
gsize size);
|
|
|
|
void gsk_gl_buffer_bind (GskGLBuffer *self);
|
|
void gsk_gl_buffer_bind_base (GskGLBuffer *self,
|
|
GLuint index);
|
|
|
|
G_END_DECLS
|
|
|