From 0f640b8dd951f2336b252d57a3cf49342ebc77f6 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 2 Jan 2024 23:42:20 -0600 Subject: [PATCH] Fix clear color when rendering to VA surfaces --- src/platform/linux/graphics.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/platform/linux/graphics.cpp b/src/platform/linux/graphics.cpp index ab6702c2..b25032b3 100644 --- a/src/platform/linux/graphics.cpp +++ b/src/platform/linux/graphics.cpp @@ -605,6 +605,22 @@ namespace egl { nv12->buf.bind(std::begin(nv12->tex), std::end(nv12->tex)); + GLenum attachments[] { + GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT1 + }; + + for (int x = 0; x < sizeof(attachments) / sizeof(decltype(attachments[0])); ++x) { + gl::ctx.BindFramebuffer(GL_FRAMEBUFFER, nv12->buf[x]); + gl::ctx.DrawBuffers(1, &attachments[x]); + + const float y_black[] = { 0.0f, 0.0f, 0.0f, 0.0f }; + const float uv_black[] = { 0.5f, 0.5f, 0.5f, 0.5f }; + gl::ctx.ClearBufferfv(GL_COLOR, 0, x == 0 ? y_black : uv_black); + } + + gl::ctx.BindFramebuffer(GL_FRAMEBUFFER, 0); + gl_drain_errors; return nv12;