summaryrefslogtreecommitdiff
path: root/gdk/gdkglcontextprivate.h
Commit message (Collapse)AuthorAgeFilesLines
* glcontext: Add a way to check for GLsyncMatthias Clasen2023-04-271-0/+2
|
* glcontext: Compute matching version the simple wayBenjamin Otte2023-04-271-4/+2
| | | | Do it all in one function instead of requiring two different ones.
* egl: Make sure highest possible GL version is createdBenjamin Otte2023-04-271-5/+7
| | | | | | | | | | | | | | | | | The EGL spec states: The context returned must be the specified version, or a later version which is backwards compatible with that version. Even if a later version is returned, the specified version must correspond to a defined version of the client API. GTK has so far been relying on EGL implementations returning a later version, because that is what Mesa does. But ANGLE does not do that and only provides the minimum version, which means Windows EGL has been forced to use a lower EGL version for no reason. So fix this and try versions in order from highest to lowest.
* glcontext: Use GdkGLVersion elsewhereBenjamin Otte2023-04-271-5/+13
| | | | | ... and add a convenience API to generate GL versions from strings to make the gdk_gl_context_check() API nicer.
* gdk: Introduce GdkGLVersionBenjamin Otte2023-04-271-34/+12
| | | | | | ... and use it. Makes the code simpler.
* gdk: drop libangle GLES minimum versionMarc-André Lureau2023-04-171-5/+1
| | | | | | | GLES 2.0 version is fine now with current gtk according to B. Otte. Let's use the same minimum requirement for all implementations. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* gdk: drop unused vertex_array_objectMarc-André Lureau2023-04-171-1/+0
| | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* Make fractional scaling for GL opt-inMatthias Clasen2023-04-021-0/+2
| | | | | | | | Fractional scaling with the GL renderer is experimental for now, so we disable it unless GDK_DEBUG=gl-fractional is set. This will give us time to work out the kinks.
* Convert headers to #pragma onceMatthias Clasen2023-03-311-3/+1
| | | | The conversion was done by guard2one.
* gdk: Add private GLContext::is_current() checkBenjamin Otte2023-02-021-0/+1
| | | | | | | | | | | | | | | | ... and use this check in gdk_gl_context_make_current() and gdk_gl_context_get_current() to make sure the context really is still current. The context no longer being current can happen when external GL implementations make their own contexts current in the same threads GDK contexts are used in. And that can happen for example by WebKit. Theoretically, this should also allow external EGL code to run in X11 applications when GDK chooses to use GLX, but I didn't try it. Fixes #5392
* Merge branch 'gl-api-es-fix' into 'main'Benjamin Otte2022-06-041-0/+26
|\ | | | | | | | | | | | | glcontext: Respect ES API when getting gl version from shared context Closes #4763 See merge request GNOME/gtk!4687
| * glcontext: Refactor realize function, fix interaction with shared contextPablo Correa Gómez2022-06-041-0/+21
| |
| * glcontext: Add internal get_clipped_version functionPablo Correa Gómez2022-06-041-0/+5
| | | | | | | | | | | | It is useful for backends to get user set preferences while ensuring the correctness of the result, which will be always greater or equal than the minimum version provided
* | gdk: Check OES_vertex_half_float GLES extensionMatthias Clasen2022-05-051-0/+2
|/ | | | This will be checked in the GL renderer.
* gsk/gl: support non-standard default framebufferChristian Hergert2022-02-221-0/+2
| | | | | | | | | | | | | There are situations where our "default framebuffer" is not actually zero, yet we still want to apply a scissor rect. Generally, 0 is the default framebuffer. But on platforms where we need to bind a platform-specific feature to a GL_FRAMEBUFFER, we might have a default that is not 0. For example, on macOS we bind an IOSurfaceRef to a GL_TEXTURE_RECTANGLE which then is assigned as the backing store for a framebuffer. This is different than using gsk_gl_renderer_render_texture() in that we don't want to incur an extra copy to the destination surface nor do we even have a way to pass a texture_id into render_texture().
* gl: Change gdk_gl_context_check_version()Benjamin Otte2021-12-251-2/+4
| | | | | | | | | | | | Instead of just passing major/minor, pass them twice, once for GL and once for GLES. This way, we don't need to check for GL and GLES separately. If something is supported unconditionally, passing 0/0 works fine. That said, I'd like to group the arguments somehow, because otherwise it's just a confusing list of numbers - but I have no idea how to do that.
* gl: Clear current when destroying current's surfaceBenjamin Otte2021-12-221-0/+2
| | | | | | | | | When destroying the EGLSurface or GLXDrawable of a GdkSurface, make sure the current context is not still bound to it. If it is, clear the current context. Fixes #4554
* API: Add gdk_display_create_gl_context()Benjamin Otte2021-10-201-1/+2
| | | | | | | | | | | | This is an alternative to gdk_surface_create_gl_context() when the context is meant to only draw to textures. This is useful in the testsuite or in GStreamer or with GLArea, basically whenever we want to do GL stuff but don't need to actually draw anything on screen. A bunch of code will need to be updated to deal with context->surface being NULL.
* gdk: Move GdkMemoryFormat enum to gdktypes.hBenjamin Otte2021-10-161-1/+0
| | | | It's used in too many places now.
* gl: Move texture uploading to the rendererBenjamin Otte2021-10-131-7/+4
| | | | | | | | It does not belong in GdkGLContext, it's a renderer thing. It's also the only user of that API. Introduce gdk_gl_context_check_version() private API to make version checks simpler.
* gl: Check allowed APIs in realize()Benjamin Otte2021-10-081-1/+4
| | | | | | | | | | | Add gdk_gl_context_is_api_allowed() for backends and make them use it. Finally, have them return the final API as the return value (or 0 on error). And then use that api instead of a use_es boolean flag. Fixes #4221
* egl: Unify contextsBenjamin Otte2021-10-061-1/+0
| | | | | | | | | | | | | Unify the X11 and Wayland EGL contexts. This is a bit ugly to implement, because I don't want to create an interface and I can't make them inherit from the same object, because one needs to inherit from X11GLContext and the other from WaylandGLContext. So we have to put the code in GdkGLContext and make sure non-EGL contexts can't accidentally run it. This is rather easy because we can just check for priv->egl_context != NULL.
* glcontext: Remove unused functionalityBenjamin Otte2021-10-061-2/+0
| | | | | The recent changes made and unused function removals make these features unused.
* gdk: Remove unused gdk_gl_texture_quads() functionBenjamin Otte2021-10-061-11/+0
| | | | That function carried a lot of baggage.
* gdk: Make sure only one GL backend is usedwip/otte/shittymorphBenjamin Otte2021-09-241-0/+14
| | | | | | | | | | | | Creative people managed to create an X11 display and a Wayland display at once, thereby getting EGL and GLX involved in a fight to the death over the ownership of the glFoo() symbolspace. A way to force such a fight with available tools here is (on Wayland) running something like: GTK_INSPECTOR_DISPLAY=:1 GTK_DEBUG=interactive gtk4-demo Related: xdg-desktop-portal-gnome#5
* gdk: Move GL context construction to GdkGLContextBenjamin Otte2021-07-221-0/+2
| | | | | | | | | | | | Now that we have the display's context to hook into, we can use it to construct other GL contexts and don't need a GdkSurface vfunc anymore. This has the added benefit that backends can have different GdkGLContext classes on the display and get new GLContexts generated from them, so we get multiple GL backend support per GDK backend for free. I originally wanted to make this a vfunc on GdkGLContextClass, but it turns out all the abckends would just call g_object_new() anyway.
* gl: Move vfuncBenjamin Otte2021-07-221-0/+3
| | | | | | | | | | | | | | | | Instead of Display::make_gl_context_current() we now have GLContext::clear_current() GLContext::make_current() This fits better with the backends (we can actually implement clearCurrent on macOS now) and makes it easier to implement different GL backends for backends (like EGL/GLX on X11). We also pass a surfaceless boolean to make_current() so the calling code can decide if a surface needs to be bound or not, because the backends were all doing whatever, which was very counterproductive.
* gdk: Add gdk_gl_context_is_shared()Benjamin Otte2021-07-221-3/+6
| | | | ... and use it in the GL renderers.
* gdk: Require EGL version 1.4 across the boardBenjamin Otte2021-07-221-0/+7
| | | | Mesa currently ships 1.5.
* gl: remove unused texture_from_surface APIwip/chergert/gdk-remove-texture_from_surfaceChristian Hergert2020-10-291-4/+0
| | | | | This is not used anywhere and only exists within the X11 backend. It can be removed now.
* Correctly upload textures for GLESAlexander Larsson2020-09-251-0/+2
| | | | | | | | | | | | | | | | | GLES doesn't support the GL_BGRA + GL_UNSIGNED_INT_24_8 hack that we use on desktop OpenGL to upload textures directly in the cairo pixel format. This adds the required conversions to all the places that currently need it. We also add a data_format to the internal gdk_gl_context_upload_texture() function to make it clearer what the format are. Currently it is always the cairo image surface format, but eventually we want to support other formats so that we can avoid some of the unnecessary conversions we do. Also, the current gdk_gl_context_upload_texture() code always converts to a cairo format and uploads that like we did before. Later commits will allow this to use other upload formats that gl supports to avoid conversions.
* gdk: Slim down gdkinternals.h moreMatthias Clasen2020-08-141-0/+12
| | | | Move things to the private headers they belong in.
* GdkGLContext: Drop gdk_gl_context_has_[framebuffer_blit|frame_terminator]()Chun-wei Fan2020-08-051-2/+0
| | | | | | gdk_gl_context_has_framebuffer_blit() and gdk_gl_context_has_frame_terminator() were only used by by GDK/Win32, and they do not provide performance advantages in GTK master, so clean up the code a bit by dropping them.
* OpenGL/ES: Fix 'R' and 'B' bits inverted on WindowsChun-wei Fan2020-07-301-0/+3
| | | | | | | | | We need to use GL_BGRA instead of GL_RGBA when doing glReadPixels() on EGL on Windows (ANGLE) so that the red and blue bits won't be displayed inverted. Also fix the logic where we determine whether to bit blit or redraw everything.
* gl: Add a gdk_gl_context_has_debug accessorTimm Bäder2020-07-281-1/+3
| | | | | Check if the label_object_ etc. functions are gonna do anything at all. The g_type_name_from_instance calls keep poppoing up in profiles.
* Replace "gchar" with "char"Benjamin Otte2020-07-251-1/+1
|
* GdkGLContext: Add internal functions for KHR_DEBUG callsAlexander Larsson2019-04-251-1/+15
| | | | | This includes pushing and poping debug group messages and labeling objects.
* glcontext: Store the buffer age regions in the GL contextBenjamin Otte2018-04-091-0/+3
| | | | | | | | That way, we can store the right region there: The actual painted area instead of the exposed area (which is way too small). Also, the GL context is the only user of this data, so storing it there seems way smarter.
* gdkgl: Add gdk_gl_context_get_damage()Benjamin Otte2016-12-051-0/+2
| | | | | | | | | | | | | | | | This is a way to query the damaged area of the backbuffer. The GL renderer uses this to compute the extents of that damage region (computed via buffer age) and use them to minimize the area to redraw. This changes the semantics of GL rendering to "When calling gdk_window_begin_frame() with a GL context, the area by gdk_gl_context_get_damage() needs to be redrawn and every other pixel of the backbuffer is guaranteed to be correct. After gdk_window_end_frame() on a GL-drawn window, the whole backbuffer must be correct. We can always glXBufferSwap() now because of this.
* gdk: Make gdk_window_begin_draw_frame() take a draw contextBenjamin Otte2016-12-051-11/+0
| | | | | | | | | | ... instead of a gl context. This requires some refactoring in the way we mark the shared context as drawing: We now call begin_frame/end_frame() on it and ignore the call on the main context. Unfortunately we need to do this check in all vfuncs, which sucks. But I haven't found a better way.
* gdk: Turn GdkGLContext into a GdkDrawContextBenjamin Otte2016-12-051-2/+3
|
* glcontext: Make begin/end_draw() pairedBenjamin Otte2016-12-051-0/+3
| | | | | | | | | | This way, we can query the GL context's state via gdk_gl_context_is_drawing(). Use this function to make GL contexts as attached and grant them access to the front/backbuffer for rendering. All of this is still unused because GL drawing is still disabled.
* gdk: Large GL refactoringBenjamin Otte2016-12-051-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No visible changes as GL rendering is disabled at the moment. What was done: 1. Move window->invalidate_for_new_frame to glcontext->begin_frame This moves the code to where it is used (the GLContext) and prepares it for being called where it is used when actually beginning to draw the frame. 2. Get rid of buffer-age usage We want to let the application render directly to the backbuffer. Because of that, we cannot make any assumptions about the contents the application renders outside the clip area. In particular GskGLRenderer renders random stuff there but not actual contents. 3. Pass the actual GL context Previously, we passed the shared context to end_frame, now we pass the actual GL context that the application uses for rendering. This is so that the vfuncs could prepare the actual contexts for rendering (they don't currently). 4. Simplify the code The previous code set up the final drawing method in begin_frame. Instead, we now just ensure the clip area is something we can render and decide on the actual method in end_frame. This is both more robust (we can change the clip area in between if we want to) and less code.
* gdkgl: Change prototype of functionBenjamin Otte2016-11-011-1/+2
| | | | | | The function does not upload a cairo surface, it uploads pixel data. So don't take a cairo surface as an argument, take pixel data.
* gl: Use a uniform to flip R and B colors on GLESEmmanuele Bassi2016-04-251-0/+1
| | | | | | | | | | | | This allows us to decide when the R and B color channels should be flipped with a much better granularity. For instance, when using GLX_EXT_texture_from_pixmap to create a GL texture from a surface we don't need to swap the R and B channels, as the internal representation of the texture data will already have the appropriate colors. We also don't need to flip color channels when blitting from a texture.
* gl: Add more OpenGL ES checksEmmanuele Bassi2016-04-251-0/+1
| | | | | Check for the appropriate extensions depending on which type of API we're using.
* gl: Add 'use-es' flagEmmanuele Bassi2016-04-251-0/+1
| | | | | | | | | | | | | On some platforms we can ask the GL context machinery to create a GLES context, instead of a GL one. In order to ask for a GLES context at GdkGLContext realization time, we use a bit field like we do for forward compatible, or debug contexts. The 'use-es' bit also changes the way we select a default version, because OpenGL and OpenGLES versions differ. https://bugzilla.gnome.org/show_bug.cgi?id=743746
* gl: Store the legacy bit in the GL program dataEmmanuele Bassi2015-10-071-0/+2
| | | | | | We need to know if we're using a legacy GL context in various places. https://bugzilla.gnome.org/show_bug.cgi?id=756142
* gdk: Allow querying if a GL context is in legacy modeEmmanuele Bassi2015-10-071-0/+3
| | | | | | | | | | | | | | | | | | | | We want to have the ability to fall back to legacy GL contexts when creating them. In order to do so, we need to store the legacy bit on the GdkGLContext, as well as being able to query it. Setting the legacy bit from outside GDK is not possible; we cannot create GL contexts in 3.2 core profile *and* compatibility modes at the same time, and if we allowed users to select the legacy mode themselves, it would break the creation of the GdkWindow's paint GL context. What we do allow is falling back to legacy GL context if the platform does not support 3.2 core profiles — for instance, on older GPUs or inside virtualized environments. We are also going to use the legacy bit internally, to choose which GL API we can use when drawing GL content. https://bugzilla.gnome.org/show_bug.cgi?id=756142
* gl: Drop GdkGLContextClass.upload_texture()Emmanuele Bassi2015-02-091-12/+12
| | | | It's unnecessary to allow per-backend overrides.