From nobody Tue Feb 10 12:57:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150764398060457.051752638500716; Tue, 10 Oct 2017 06:59:40 -0700 (PDT) Received: from localhost ([::1]:35201 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1v4K-0007Lv-UG for importer@patchew.org; Tue, 10 Oct 2017 09:59:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1uzu-00045R-Re for qemu-devel@nongnu.org; Tue, 10 Oct 2017 09:55:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1uzr-0007VU-Nh for qemu-devel@nongnu.org; Tue, 10 Oct 2017 09:55:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38558) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1uzr-0007UI-D2 for qemu-devel@nongnu.org; Tue, 10 Oct 2017 09:54:59 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DDF65C04AC7E; Tue, 10 Oct 2017 13:54:57 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3B8962478; Tue, 10 Oct 2017 13:54:54 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1A12A16A89E; Tue, 10 Oct 2017 15:54:54 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DDF65C04AC7E Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 10 Oct 2017 15:54:50 +0200 Message-Id: <20171010135453.6704-4-kraxel@redhat.com> In-Reply-To: <20171010135453.6704-1-kraxel@redhat.com> References: <20171010135453.6704-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 10 Oct 2017 13:54:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/6] opengl: add flipping vertex shader X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gvt-dev@lists.freedesktop.org, Gerd Hoffmann , Tina Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add vertex shader which flips the texture upside down while blitting it. Add argument to qemu_gl_run_texture_blit() to enable flipping. Signed-off-by: Gerd Hoffmann --- Makefile | 4 +++- include/ui/shader.h | 2 +- ui/console-gl.c | 2 +- ui/shader.c | 12 +++++++++--- ui/shader/texture-blit-flip.vert | 10 ++++++++++ 5 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 ui/shader/texture-blit-flip.vert diff --git a/Makefile b/Makefile index e4275691fb..cb6a974a6f 100644 --- a/Makefile +++ b/Makefile @@ -672,7 +672,9 @@ ui/shader/%-frag.h: $(SRC_PATH)/ui/shader/%.frag $(SRC_= PATH)/scripts/shaderinclu "FRAG","$@") =20 ui/shader.o: $(SRC_PATH)/ui/shader.c \ - ui/shader/texture-blit-vert.h ui/shader/texture-blit-frag.h + ui/shader/texture-blit-vert.h \ + ui/shader/texture-blit-flip-vert.h \ + ui/shader/texture-blit-frag.h =20 # documentation MAKEINFO=3Dmakeinfo diff --git a/include/ui/shader.h b/include/ui/shader.h index 369e49865f..4c5acb2ce8 100644 --- a/include/ui/shader.h +++ b/include/ui/shader.h @@ -5,7 +5,7 @@ =20 typedef struct QemuGLShader QemuGLShader; =20 -void qemu_gl_run_texture_blit(QemuGLShader *gls); +void qemu_gl_run_texture_blit(QemuGLShader *gls, bool flip); =20 QemuGLShader *qemu_gl_init_shader(void); void qemu_gl_fini_shader(QemuGLShader *gls); diff --git a/ui/console-gl.c b/ui/console-gl.c index 9b50daedbd..5b77e7aa88 100644 --- a/ui/console-gl.c +++ b/ui/console-gl.c @@ -109,7 +109,7 @@ void surface_gl_render_texture(QemuGLShader *gls, glClearColor(0.1f, 0.1f, 0.1f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); =20 - qemu_gl_run_texture_blit(gls); + qemu_gl_run_texture_blit(gls, false); } =20 void surface_gl_destroy_texture(QemuGLShader *gls, diff --git a/ui/shader.c b/ui/shader.c index d36e7af232..008458bf94 100644 --- a/ui/shader.c +++ b/ui/shader.c @@ -29,10 +29,12 @@ #include "ui/shader.h" =20 #include "shader/texture-blit-vert.h" +#include "shader/texture-blit-flip-vert.h" #include "shader/texture-blit-frag.h" =20 struct QemuGLShader { GLint texture_blit_prog; + GLint texture_blit_flip_prog; GLint texture_blit_vao; }; =20 @@ -68,9 +70,11 @@ static GLuint qemu_gl_init_texture_blit(GLint texture_bl= it_prog) return vao; } =20 -void qemu_gl_run_texture_blit(QemuGLShader *gls) +void qemu_gl_run_texture_blit(QemuGLShader *gls, bool flip) { - glUseProgram(gls->texture_blit_prog); + glUseProgram(flip + ? gls->texture_blit_flip_prog + : gls->texture_blit_prog); glBindVertexArray(gls->texture_blit_vao); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } @@ -150,7 +154,9 @@ QemuGLShader *qemu_gl_init_shader(void) =20 gls->texture_blit_prog =3D qemu_gl_create_compile_link_program (texture_blit_vert_src, texture_blit_frag_src); - if (!gls->texture_blit_prog) { + gls->texture_blit_flip_prog =3D qemu_gl_create_compile_link_program + (texture_blit_flip_vert_src, texture_blit_frag_src); + if (!gls->texture_blit_prog || !gls->texture_blit_flip_prog) { exit(1); } =20 diff --git a/ui/shader/texture-blit-flip.vert b/ui/shader/texture-blit-flip= .vert new file mode 100644 index 0000000000..ba081fa5a6 --- /dev/null +++ b/ui/shader/texture-blit-flip.vert @@ -0,0 +1,10 @@ + +#version 300 es + +in vec2 in_position; +out vec2 ex_tex_coord; + +void main(void) { + gl_Position =3D vec4(in_position, 0.0, 1.0); + ex_tex_coord =3D vec2(1.0 + in_position.x, 1.0 + in_position.y) * 0.5; +} --=20 2.9.3