|
|
5525bd |
From 6c6c6ad5412f5bb13592630d7cb3b7aed25d159b Mon Sep 17 00:00:00 2001
|
|
|
5525bd |
From: Pekka Paalanen <pekka.paalanen@collabora.com>
|
|
|
5525bd |
Date: Mon, 6 May 2019 14:09:16 +0300
|
|
|
5525bd |
Subject: [PATCH 04/12] cogl: Relax formats on glBlitFramebuffer
|
|
|
5525bd |
|
|
|
5525bd |
Depends on: "cogl: Replace ANGLE with GLES3 and NV framebuffer_blit"
|
|
|
5525bd |
|
|
|
5525bd |
As a possible ANGLE implementation is not longer limiting the pixel format
|
|
|
5525bd |
matching, lift the requirement of having the same pixel format.
|
|
|
5525bd |
|
|
|
5525bd |
We still cannot do a premult <-> non-premult conversion during a blit, so guard
|
|
|
5525bd |
against that.
|
|
|
5525bd |
|
|
|
5525bd |
This will be useful in follow-up work to copy from onscreen primary GPU
|
|
|
5525bd |
framebuffer to an offscreen secondary GPU framebuffer if the formats do not
|
|
|
5525bd |
match exactly.
|
|
|
5525bd |
|
|
|
5525bd |
https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
|
|
|
5525bd |
|
|
|
5525bd |
(cherry picked from commit 6df34eb4b7c65210f4066f7eb9bd462278b7279b)
|
|
|
5525bd |
---
|
|
|
5525bd |
cogl/cogl/cogl-blit.c | 10 ++++++----
|
|
|
5525bd |
cogl/cogl/cogl-framebuffer-private.h | 8 ++++++--
|
|
|
5525bd |
cogl/cogl/cogl-framebuffer.c | 6 ++++--
|
|
|
5525bd |
3 files changed, 16 insertions(+), 8 deletions(-)
|
|
|
5525bd |
|
|
|
5525bd |
diff --git a/cogl/cogl/cogl-blit.c b/cogl/cogl/cogl-blit.c
|
|
|
5525bd |
index 74f404f3d..a61eb66d2 100644
|
|
|
5525bd |
--- a/cogl/cogl/cogl-blit.c
|
|
|
5525bd |
+++ b/cogl/cogl/cogl-blit.c
|
|
|
5525bd |
@@ -4,6 +4,7 @@
|
|
|
5525bd |
* A Low Level GPU Graphics and Utilities API
|
|
|
5525bd |
*
|
|
|
5525bd |
* Copyright (C) 2011 Intel Corporation.
|
|
|
5525bd |
+ * Copyright (C) 2019 DisplayLink (UK) Ltd.
|
|
|
5525bd |
*
|
|
|
5525bd |
* Permission is hereby granted, free of charge, to any person
|
|
|
5525bd |
* obtaining a copy of this software and associated documentation
|
|
|
5525bd |
@@ -152,10 +153,11 @@ _cogl_blit_framebuffer_begin (CoglBlitData *data)
|
|
|
5525bd |
CoglFramebuffer *dst_fb, *src_fb;
|
|
|
5525bd |
CoglError *ignore_error = NULL;
|
|
|
5525bd |
|
|
|
5525bd |
- /* We can only blit between FBOs if both textures are the same
|
|
|
5525bd |
- format and the blit framebuffer extension is supported */
|
|
|
5525bd |
- if ((_cogl_texture_get_format (data->src_tex) & ~COGL_A_BIT) !=
|
|
|
5525bd |
- (_cogl_texture_get_format (data->dst_tex) & ~COGL_A_BIT) ||
|
|
|
5525bd |
+ /* We can only blit between FBOs if both textures have the same
|
|
|
5525bd |
+ premult convention and the blit framebuffer extension is
|
|
|
5525bd |
+ supported. */
|
|
|
5525bd |
+ if ((_cogl_texture_get_format (data->src_tex) & COGL_PREMULT_BIT) !=
|
|
|
5525bd |
+ (_cogl_texture_get_format (data->dst_tex) & COGL_PREMULT_BIT) ||
|
|
|
5525bd |
!_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_OFFSCREEN_BLIT))
|
|
|
5525bd |
return FALSE;
|
|
|
5525bd |
|
|
|
5525bd |
diff --git a/cogl/cogl/cogl-framebuffer-private.h b/cogl/cogl/cogl-framebuffer-private.h
|
|
|
5525bd |
index 3aab852c4..b06fbaee1 100644
|
|
|
5525bd |
--- a/cogl/cogl/cogl-framebuffer-private.h
|
|
|
5525bd |
+++ b/cogl/cogl/cogl-framebuffer-private.h
|
|
|
5525bd |
@@ -381,8 +381,12 @@ _cogl_push_framebuffers (CoglFramebuffer *draw_buffer,
|
|
|
5525bd |
* This blits a region of the color buffer of the source buffer
|
|
|
5525bd |
* to the destination buffer. This function should only be
|
|
|
5525bd |
* called if the COGL_PRIVATE_FEATURE_OFFSCREEN_BLIT feature is
|
|
|
5525bd |
- * advertised. The two buffers must both be offscreen and have the
|
|
|
5525bd |
- * same format.
|
|
|
5525bd |
+ * advertised. The two buffers must both be offscreen.
|
|
|
5525bd |
+ *
|
|
|
5525bd |
+ * The two buffers must have the same value types (e.g. floating-point,
|
|
|
5525bd |
+ * unsigned int, signed int, or fixed-point), but color formats do not
|
|
|
5525bd |
+ * need to match. This limitation comes from OpenGL ES 3.0 definition
|
|
|
5525bd |
+ * of glBlitFramebuffer.
|
|
|
5525bd |
*
|
|
|
5525bd |
* Note that this function differs a lot from the glBlitFramebuffer
|
|
|
5525bd |
* function provided by the GL_EXT_framebuffer_blit extension. Notably
|
|
|
5525bd |
diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c
|
|
|
5525bd |
index bd8a7fa42..0bc225945 100644
|
|
|
5525bd |
--- a/cogl/cogl/cogl-framebuffer.c
|
|
|
5525bd |
+++ b/cogl/cogl/cogl-framebuffer.c
|
|
|
5525bd |
@@ -4,6 +4,7 @@
|
|
|
5525bd |
* A Low Level GPU Graphics and Utilities API
|
|
|
5525bd |
*
|
|
|
5525bd |
* Copyright (C) 2007,2008,2009,2012 Intel Corporation.
|
|
|
5525bd |
+ * Copyright (C) 2019 DisplayLink (UK) Ltd.
|
|
|
5525bd |
*
|
|
|
5525bd |
* Permission is hereby granted, free of charge, to any person
|
|
|
5525bd |
* obtaining a copy of this software and associated documentation
|
|
|
5525bd |
@@ -1468,8 +1469,9 @@ _cogl_blit_framebuffer (CoglFramebuffer *src,
|
|
|
5525bd |
support this */
|
|
|
5525bd |
_COGL_RETURN_IF_FAIL (cogl_is_offscreen (src));
|
|
|
5525bd |
_COGL_RETURN_IF_FAIL (cogl_is_offscreen (dest));
|
|
|
5525bd |
- /* The buffers must be the same format */
|
|
|
5525bd |
- _COGL_RETURN_IF_FAIL (src->internal_format == dest->internal_format);
|
|
|
5525bd |
+ /* The buffers must use the same premult convention */
|
|
|
5525bd |
+ _COGL_RETURN_IF_FAIL ((src->internal_format & COGL_PREMULT_BIT) ==
|
|
|
5525bd |
+ (dest->internal_format & COGL_PREMULT_BIT));
|
|
|
5525bd |
|
|
|
5525bd |
/* Make sure the current framebuffers are bound. We explicitly avoid
|
|
|
5525bd |
flushing the clip state so we can bind our own empty state */
|
|
|
5525bd |
--
|
|
|
5525bd |
2.21.0
|
|
|
5525bd |
|