Commit 874e9aee authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/kraxel/tags/pull-sdl-20150505-1' into staging



sdl2: add opengl support

# gpg: Signature made Tue May  5 10:36:25 2015 BST using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/kraxel/tags/pull-sdl-20150505-1:
  sdl2: Fix RGB555
  sdl2: add support for display rendering using opengl.
  sdl2: move SDL_* includes to sdl2.h
  console-gl: add opengl rendering helper functions
  opengl: add shader helper functions.
  opengl: add shader build infrastructure

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents b4c5df7a e444ea34
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -296,6 +296,7 @@ clean:
	rm -f fsdev/*.pod
	rm -rf .libs */.libs
	rm -f qemu-img-cmds.h
	rm -f ui/shader/*-vert.h ui/shader/*-frag.h
	@# May not be present in GENERATED_HEADERS
	rm -f trace/generated-tracers-dtrace.dtrace*
	rm -f trace/generated-tracers-dtrace.h*
@@ -441,6 +442,22 @@ cscope:
	find "$(SRC_PATH)" -name "*.[chsS]" -print | sed 's,^\./,,' > ./cscope.files
	cscope -b

# opengl shader programs
ui/shader/%-vert.h: $(SRC_PATH)/ui/shader/%.vert $(SRC_PATH)/scripts/shaderinclude.pl
	@mkdir -p $(dir $@)
	$(call quiet-command,\
		perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
		"  VERT  $@")

ui/shader/%-frag.h: $(SRC_PATH)/ui/shader/%.frag $(SRC_PATH)/scripts/shaderinclude.pl
	@mkdir -p $(dir $@)
	$(call quiet-command,\
		perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
		"  FRAG  $@")

ui/console-gl.o: $(SRC_PATH)/ui/console-gl.c \
	ui/shader/texture-blit-vert.h ui/shader/texture-blit-frag.h

# documentation
MAKEINFO=makeinfo
MAKEINFOFLAGS=--no-headers --no-split --number-sections
+1 −1
Original line number Diff line number Diff line
@@ -3142,7 +3142,7 @@ else
fi

if test "$opengl" != "no" ; then
  opengl_pkgs="gl"
  opengl_pkgs="gl glesv2"
  if $pkg_config $opengl_pkgs x11 && test "$have_glx" = "yes"; then
    opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
    opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
+37 −0
Original line number Diff line number Diff line
@@ -9,6 +9,11 @@
#include "qapi-types.h"
#include "qapi/error.h"

#ifdef CONFIG_OPENGL
# include <GLES2/gl2.h>
# include <GLES2/gl2ext.h>
#endif

/* keyboard/mouse support */

#define MOUSE_EVENT_LBUTTON 0x01
@@ -117,6 +122,11 @@ struct DisplaySurface {
    pixman_format_code_t format;
    pixman_image_t *image;
    uint8_t flags;
#ifdef CONFIG_OPENGL
    GLenum glformat;
    GLenum gltype;
    GLuint texture;
#endif
};

typedef struct QemuUIInfo {
@@ -270,6 +280,11 @@ static inline int surface_bytes_per_pixel(DisplaySurface *s)
    return (bits + 7) / 8;
}

static inline pixman_format_code_t surface_format(DisplaySurface *s)
{
    return s->format;
}

#ifdef CONFIG_CURSES
#include <curses.h>
typedef chtype console_ch_t;
@@ -322,7 +337,29 @@ void qemu_console_copy(QemuConsole *con, int src_x, int src_y,
                       int dst_x, int dst_y, int w, int h);
DisplaySurface *qemu_console_surface(QemuConsole *con);

/* console-gl.c */
typedef struct ConsoleGLState ConsoleGLState;
#ifdef CONFIG_OPENGL
ConsoleGLState *console_gl_init_context(void);
void console_gl_fini_context(ConsoleGLState *gls);
bool console_gl_check_format(DisplayChangeListener *dcl,
                             pixman_format_code_t format);
void surface_gl_create_texture(ConsoleGLState *gls,
                               DisplaySurface *surface);
void surface_gl_update_texture(ConsoleGLState *gls,
                               DisplaySurface *surface,
                               int x, int y, int w, int h);
void surface_gl_render_texture(ConsoleGLState *gls,
                               DisplaySurface *surface);
void surface_gl_destroy_texture(ConsoleGLState *gls,
                               DisplaySurface *surface);
void surface_gl_setup_viewport(ConsoleGLState *gls,
                               DisplaySurface *surface,
                               int ww, int wh);
#endif

/* sdl.c */
void sdl_display_early_init(int opengl);
void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);

/* cocoa.m */
+17 −0
Original line number Diff line number Diff line
#ifndef SDL2_H
#define SDL2_H

/* Avoid compiler warning because macro is redefined in SDL_syswm.h. */
#undef WIN32_LEAN_AND_MEAN

#include <SDL.h>
#include <SDL_syswm.h>

struct sdl2_console {
    DisplayChangeListener dcl;
    DisplaySurface *surface;
@@ -11,6 +17,10 @@ struct sdl2_console {
    int last_vm_running; /* per console for caption reasons */
    int x, y;
    int hidden;
    int opengl;
    int updates;
    SDL_GLContext winctx;
    ConsoleGLState *gls;
};

void sdl2_window_create(struct sdl2_console *scon);
@@ -31,4 +41,11 @@ void sdl2_2d_redraw(struct sdl2_console *scon);
bool sdl2_2d_check_format(DisplayChangeListener *dcl,
                          pixman_format_code_t format);

void sdl2_gl_update(DisplayChangeListener *dcl,
                    int x, int y, int w, int h);
void sdl2_gl_switch(DisplayChangeListener *dcl,
                    DisplaySurface *new_surface);
void sdl2_gl_refresh(DisplayChangeListener *dcl);
void sdl2_gl_redraw(struct sdl2_console *scon);

#endif /* SDL2_H */

include/ui/shader.h

0 → 100644
+11 −0
Original line number Diff line number Diff line
#ifdef CONFIG_OPENGL
# include <GLES2/gl2.h>
# include <GLES2/gl2ext.h>
#endif

void qemu_gl_run_texture_blit(GLint texture_blit_prog);

GLuint qemu_gl_create_compile_shader(GLenum type, const GLchar *src);
GLuint qemu_gl_create_link_program(GLuint vert, GLuint frag);
GLuint qemu_gl_create_compile_link_program(const GLchar *vert_src,
                                           const GLchar *frag_src);
Loading