vrend: manual clear_color srgb encoding for eglimage-backed bgr* textures

Since eglimage-backed textures don't support glTextureView(), colorspace
conversion must be applied manually on the clear_color vector. Also, if
the view intended to swizzle, we need to do that manually as well.

Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/725>
macos/master
Ryan Neph 3 years ago committed by Marge Bot
parent cd33353097
commit bea282334d
  1. 18
      src/vrend_renderer.c

@ -3987,22 +3987,28 @@ void vrend_clear(struct vrend_context *ctx,
float colorf[4]; float colorf[4];
memcpy(colorf, color->f, sizeof(colorf)); memcpy(colorf, color->f, sizeof(colorf));
if (sub_ctx->nr_cbufs && sub_ctx->surf[0] && {
vrend_resource_has_24bpp_internal_format(sub_ctx->surf[0]->texture) && struct vrend_surface *surf = sub_ctx->surf[0];
util_format_is_srgb(sub_ctx->surf[0]->format)) { if (sub_ctx->nr_cbufs && surf &&
util_format_is_srgb(surf->format) &&
!vrend_resource_supports_view(surf->texture, surf->format)) {
VREND_DEBUG(dbg_tex, ctx, VREND_DEBUG(dbg_tex, ctx,
"manually converting glClearColor from linear->srgb colorspace for EGL-backed framebuffer color attachment" "manually converting glClearColor from linear->srgb colorspace for EGL-backed framebuffer color attachment"
" (surface format is %s; resource format is %s)\n", " (surface format is %s; resource format is %s)\n",
util_format_name(sub_ctx->surf[0]->format), util_format_name(surf->format),
util_format_name(sub_ctx->surf[0]->texture->base.format)); util_format_name(surf->texture->base.format));
for (int i = 0; i < 3; ++i) // i < 3: don't convert alpha channel for (int i = 0; i < 3; ++i) // i < 3: don't convert alpha channel
colorf[i] = vrend_color_convert_linear_to_srgb(colorf[i]); colorf[i] = vrend_color_convert_linear_to_srgb(colorf[i]);
} }
}
if (buffers & PIPE_CLEAR_COLOR) { if (buffers & PIPE_CLEAR_COLOR) {
if (sub_ctx->nr_cbufs && sub_ctx->surf[0] && vrend_format_is_emulated_alpha(sub_ctx->surf[0]->format)) { if (sub_ctx->nr_cbufs && sub_ctx->surf[0] && vrend_format_is_emulated_alpha(sub_ctx->surf[0]->format)) {
glClearColor(colorf[3], 0.0, 0.0, 0.0); glClearColor(colorf[3], 0.0, 0.0, 0.0);
} else if (sub_ctx->nr_cbufs && sub_ctx->surf[0] && vrend_resource_is_emulated_bgra(sub_ctx->surf[0]->texture)) { } else if (sub_ctx->nr_cbufs && sub_ctx->surf[0] &&
!vrend_resource_supports_view(sub_ctx->surf[0]->texture,
sub_ctx->surf[0]->format) &&
!vrend_format_is_bgra(sub_ctx->surf[0]->format)) {
VREND_DEBUG(dbg_bgra, ctx, "swizzling glClearColor() since rendering surface is an externally-stored BGR* resource\n"); VREND_DEBUG(dbg_bgra, ctx, "swizzling glClearColor() since rendering surface is an externally-stored BGR* resource\n");
glClearColor(colorf[2], colorf[1], colorf[0], colorf[3]); glClearColor(colorf[2], colorf[1], colorf[0], colorf[3]);
} else { } else {

Loading…
Cancel
Save