From 8a2ed7ab8cfd010a19f86410bd56ee1983c5b9ef Mon Sep 17 00:00:00 2001 From: jihye kim Date: Mon, 16 Jul 2012 16:03:18 +0900 Subject: [PATCH] [Title] add open gl for windows [Type] enhancement [Module] emulator [Priority] major [Jira#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- hw/virtio-pci.c | 8 ++++---- package/pkginfo.manifest | 4 ++-- tizen/src/Makefile.tizen | 10 +++++----- tizen/src/hw/gloffscreen_test.c | 4 ++-- tizen/src/hw/gloffscreen_wgl.c | 10 ++++++++-- tizen/src/hw/helper_opengl.c | 21 ++++++++++++++++++--- tizen/src/hw/opengl_exec.c | 17 ++++++++++------- vl.c | 16 ++++++++-------- 8 files changed, 57 insertions(+), 33 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 8fb8b9f1d2..ce14a0d352 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -779,7 +779,7 @@ static int virtio_balloon_exit_pci(PCIDevice *pci_dev) return virtio_exit_pci(pci_dev); } -#ifndef _WIN32 +//#ifndef _WIN32 extern VirtIODevice *virtio_gl_init(DeviceState *dev); static int virtio_gl_init_pci(PCIDevice *pci_dev) { @@ -793,7 +793,7 @@ static int virtio_gl_init_pci(PCIDevice *pci_dev) virtio_init_pci(proxy, vdev); return 0; } -#endif +//#endif static PCIDeviceInfo virtio_info[] = { { @@ -880,7 +880,7 @@ static PCIDeviceInfo virtio_info[] = { }, .qdev.reset = virtio_pci_reset, },{ -#ifndef _WIN32 +//#ifndef _WIN32 .qdev.name = "virtio-gl-pci", .qdev.alias = "virtio-gl", .qdev.size = sizeof(VirtIOPCIProxy), @@ -895,7 +895,7 @@ static PCIDeviceInfo virtio_info[] = { }, .qdev.reset = virtio_pci_reset, },{ -#endif +//#endif /* end of list */ } }; diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index 41869745b2..50ff5fff2b 100644 --- a/package/pkginfo.manifest +++ b/package/pkginfo.manifest @@ -1,5 +1,5 @@ Package: emulator -Version:1.2.107 +Version:1.2.108 OS: linux Build-host-os: linux Maintainer: Yeong-Kyoon Lee @@ -8,7 +8,7 @@ Source: emulator Description: Tizen Emulator Package: emulator -Version:1.2.107 +Version:1.2.108 OS: windows Build-host-os: windows Maintainer: Yeong-Kyoon Lee diff --git a/tizen/src/Makefile.tizen b/tizen/src/Makefile.tizen index 4626a19421..7a3eb5fac8 100755 --- a/tizen/src/Makefile.tizen +++ b/tizen/src/Makefile.tizen @@ -12,7 +12,7 @@ QEMU_CFLAGS += $(GLIB_CFLAGS) CFLAGS += -g -O2 ifdef CONFIG_WIN32 -LIBS += -lavformat -lavcodec -lavutil -lm +LIBS += -lavformat -lavcodec -lavutil -lm -lopengl32 -lglu32 -lgdi32 else LIBS += -lavformat -lavcodec -lavutil -lm -lGL endif @@ -23,7 +23,7 @@ else GL_CFLAGS := -Wall -g -O2 -fno-strict-aliasing endif -ifndef CONFIG_WIN32 +#ifndef CONFIG_WIN32 ########################################################### ## Build openGL # i386 @@ -51,7 +51,7 @@ opengl_exec.o : opengl_exec.c server_stub.c opengl_func.h gl_beginend.h opengl_p endif #($(TARGET_ARCH), i386) ########################################################### -endif #CONFIG_WIN32 +#endif #CONFIG_WIN32 # maru loader obj-y += emulator.o emul_state.o option.o maru_err_table.o @@ -94,9 +94,9 @@ obj-i386-y += maruskin_client.o maruskin_server.o maruskin_operation.o maruskin_ # guest server obj-i386-y += guest_server.o -ifndef CONFIG_WIN32 +#ifndef CONFIG_WIN32 ########################################################### ## opengl library for i386 obj-i386-y += virtio-gl.o helper_opengl.o opengl_exec.o mesa_mipmap.o gloffscreen_common.o gloffscreen_xcomposite.o gloffscreen_wgl.o gloffscreen_test.o ########################################################### -endif +#endif diff --git a/tizen/src/hw/gloffscreen_test.c b/tizen/src/hw/gloffscreen_test.c index a685125d25..1e9e9bc9a0 100755 --- a/tizen/src/hw/gloffscreen_test.c +++ b/tizen/src/hw/gloffscreen_test.c @@ -87,12 +87,12 @@ int gl_acceleration_capability_check (void) { int bufferFlags = glo_flags_get_from_glx(bufferAttributes, 0); int bpp = glo_flags_get_bytes_per_pixel(bufferFlags); int glFormat, glType; - +/* if (glo_sanity_test () != 0) { // test failed. return 1; } - +*/ memset(datain_flip, 0, TX*TY*4); memset(datain, 0, TX*TY*4); p = datain; diff --git a/tizen/src/hw/gloffscreen_wgl.c b/tizen/src/hw/gloffscreen_wgl.c index ec86cebec7..491af01c6a 100755 --- a/tizen/src/hw/gloffscreen_wgl.c +++ b/tizen/src/hw/gloffscreen_wgl.c @@ -213,7 +213,7 @@ int glo_init(void) { glo_inited = 1; - return 0 + return 0; } /* Uninitialise gloffscreen */ @@ -639,7 +639,13 @@ void *glo_getprocaddress(const char *procName) { opengl_exec), so all we need to do is return a nunzero value... But we also have to check for 'standard' GL function names - too as wgl doesn't return those either! */ + too as wgl doesn't return those either! */ + /* Caller in opengl_exec.c may query some base GL API, then call them + * directly. On windows, wglGetProcAddress usually return NULL in such + * case, then we return 1, which casue segfault when accessing (void*)1. We + * should call base GL API directly instead of GET_EXT_PTR + ptr_func_*. + * TODO: add LoadLibrary + GetProcAddress as call back. + */ if (procAddr==0) { const char *p = STANDARD_GL_FUNCTIONS; while (*p) { diff --git a/tizen/src/hw/helper_opengl.c b/tizen/src/hw/helper_opengl.c index c5cd4fa313..a13ca40df0 100755 --- a/tizen/src/hw/helper_opengl.c +++ b/tizen/src/hw/helper_opengl.c @@ -190,9 +190,24 @@ static inline int do_decode_call_int(ProcessStruct *process, void *args_in, int r_buffer[0] = 0; // In case high bits are set. ret = do_function_call(process, func_number, args, r_buffer); - + switch(signature->ret_type) { + case TYPE_INT: + case TYPE_UNSIGNED_INT: + memcpy(r_buffer, &ret, sizeof(int)); + break; + case TYPE_CHAR: + case TYPE_UNSIGNED_CHAR: + *r_buffer = ret & 0xff; + break; + case TYPE_CONST_CHAR: + case TYPE_NONE: + break; + default: + DEBUGF("Unsupported GL API return type %i!\n", signature->ret_type); + exit (-1); + } } // endwhile - +/* switch(signature->ret_type) { case TYPE_INT: case TYPE_UNSIGNED_INT: @@ -209,7 +224,7 @@ static inline int do_decode_call_int(ProcessStruct *process, void *args_in, int DEBUGF("Unsupported GL API return type %i!\n", signature->ret_type); exit (-1); } - +*/ return 1; } #define GL_PASSINGTHROUGH_ABI 1 diff --git a/tizen/src/hw/opengl_exec.c b/tizen/src/hw/opengl_exec.c index 118380d972..001a202908 100755 --- a/tizen/src/hw/opengl_exec.c +++ b/tizen/src/hw/opengl_exec.c @@ -1741,7 +1741,7 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args case glGenTextures_fake_func: { - GET_EXT_PTR(void, glGenTextures, (GLsizei n, GLuint *textures)); + //GET_EXT_PTR(void, glGenTextures, (GLsizei n, GLuint *textures)); int i; int n = args[0]; unsigned int *clientTabTextures = g_malloc(n * sizeof(int)); @@ -1750,7 +1750,8 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args alloc_range(process->current_state->textureAllocator, n, clientTabTextures); - ptr_func_glGenTextures(n, serverTabTextures); + //ptr_func_glGenTextures(n, serverTabTextures); + glGenTextures(n, serverTabTextures); for (i = 0; i < n; i++) { process->current_state->tabTextures[clientTabTextures[i]] = serverTabTextures[i]; @@ -1764,8 +1765,8 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args case glDeleteTextures_func: { - GET_EXT_PTR(void, glDeleteTextures, - (GLsizei n, const GLuint *textures)); + //GET_EXT_PTR(void, glDeleteTextures, + // (GLsizei n, const GLuint *textures)); int i; int n = args[0]; unsigned int *clientTabTextures = (unsigned int *) args[1]; @@ -1779,7 +1780,8 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args serverTabTextures[i] = get_server_texture(process, clientTabTextures[i]); } - ptr_func_glDeleteTextures(n, serverTabTextures); + //ptr_func_glDeleteTextures(n, serverTabTextures); + glDeleteTextures(n, serverTabTextures); for (i = 0; i < n; i++) { process->current_state->tabTextures[clientTabTextures[i]] = 0; } @@ -1825,12 +1827,13 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args case glIsTexture_func: case glIsTextureEXT_func: { - GET_EXT_PTR(GLboolean, glIsTexture, (GLuint texture)); + //GET_EXT_PTR(GLboolean, glIsTexture, (GLuint texture)); unsigned int client_texture = args[0]; unsigned int server_texture = get_server_texture(process, client_texture); if (server_texture) - ret.c = ptr_func_glIsTexture(server_texture); + // ret.c = ptr_func_glIsTexture(server_texture); + ret.c = glIsTexture(server_texture); else ret.c = 0; break; diff --git a/vl.c b/vl.c index 9ec81c6cdb..e713bb7e51 100644 --- a/vl.c +++ b/vl.c @@ -263,10 +263,10 @@ int boot_splash_filedata_size; uint8_t qemu_extra_params_fw[2]; //virtio-gl -#ifndef _WIN32 +//#ifndef _WIN32 extern int gl_acceleration_capability_check (void); int enable_gl = 0; -#endif +//#endif typedef struct FWBootEntry FWBootEntry; @@ -1791,7 +1791,7 @@ static int device_init_func(QemuOpts *opts, void *opaque) { DeviceState *dev; -#ifndef _WIN32 +//#ifndef _WIN32 // virtio-gl pci device if (!enable_gl) { // ignore virtio-gl-pci device, even if users set it in option. @@ -1800,7 +1800,7 @@ static int device_init_func(QemuOpts *opts, void *opaque) return 0; } } -#endif +//#endif dev = qdev_device_add(opts); if (!dev) @@ -2960,9 +2960,9 @@ int main(int argc, char **argv, char **envp) qemu_opts_parse(olist, "accel=kvm", 0); break; case QEMU_OPTION_enable_gl: -#ifndef _WIN32 +//#ifndef _WIN32 enable_gl = 1; -#endif +//#endif break; case QEMU_OPTION_machine: olist = qemu_find_opts("machine"); @@ -3216,7 +3216,7 @@ int main(int argc, char **argv, char **envp) } loc_set_none(); -#ifndef _WIN32 +//#ifndef _WIN32 if (enable_gl && (gl_acceleration_capability_check () != 0)) { enable_gl = 0; fprintf (stderr, "Warn: GL acceleration was disabled due to the fail of GL check!\n"); @@ -3237,7 +3237,7 @@ int main(int argc, char **argv, char **envp) } } } -#endif +//#endif /* Open the logfile at this point, if necessary. We can't open the logfile -- 2.34.1