diff --git a/repos/ports/lib/mk/spec/x86_64/virtualbox6-devices.mk b/repos/ports/lib/mk/spec/x86_64/virtualbox6-devices.mk index a636f7ba3f..a9404d175b 100644 --- a/repos/ports/lib/mk/spec/x86_64/virtualbox6-devices.mk +++ b/repos/ports/lib/mk/spec/x86_64/virtualbox6-devices.mk @@ -1,6 +1,6 @@ include $(REP_DIR)/lib/mk/virtualbox6-common.inc -LIBS += stdcxx mesa +LIBS += stdcxx mesa egl virtualbox6-shaderlib SRC_CC += Devices/Audio/AudioHlp.cpp SRC_CC += Devices/Audio/AudioMixBuffer.cpp @@ -34,15 +34,6 @@ SRC_CC += Devices/Graphics/DevVGA_VBVA.cpp SRC_CC += Devices/Graphics/DevVGA_VDMA.cpp SRC_CC += Devices/Graphics/HGSMI/HGSMIHost.cpp SRC_CC += Devices/Graphics/HGSMI/SHGSMIHost.cpp -SRC_C += Devices/Graphics/shaderlib/directx.c -SRC_C += Devices/Graphics/shaderlib/glsl_shader.c -SRC_C += Devices/Graphics/shaderlib/libWineStub/debug.c -SRC_C += Devices/Graphics/shaderlib/shader.c -SRC_C += Devices/Graphics/shaderlib/shader_sm1.c -SRC_C += Devices/Graphics/shaderlib/shader_sm4.c -SRC_C += Devices/Graphics/shaderlib/shaderapi.c -SRC_C += Devices/Graphics/shaderlib/stateblock.c -SRC_C += Devices/Graphics/shaderlib/utils.c SRC_CC += Devices/Input/DevPS2.cpp SRC_CC += Devices/Input/DevPS2K.cpp SRC_CC += Devices/Input/DevPS2M.cpp @@ -129,23 +120,6 @@ INC_DIR += $(VIRTUALBOX_DIR)/include/VBox/Graphics # found in src/VBox/Devices/Makefile.kmk CC_OPT += -DVBOX_HGCM_HOST_CODE -# SVGA3D/wine specific config -WINE_CC_OPT := -D__WINESRC__ -DWINE_NOWINSOCK -D_USE_MATH_DEFINES \ - -DVBOX_USING_WINDDK_W7_OR_LATER \ - -DVBOX_WINE_WITH_SINGLE_SWAPCHAIN_CONTEXT \ - -DVBOX_WINE_WITH_IPRT \ - -UVBOX_WITH_WDDM - -CC_OPT_Devices/Graphics/shaderlib/directx = $(WINE_CC_OPT) -CC_OPT_Devices/Graphics/shaderlib/glsl_shader = $(WINE_CC_OPT) -CC_OPT_Devices/Graphics/shaderlib/libWineStub/debug = $(WINE_CC_OPT) -CC_OPT_Devices/Graphics/shaderlib/shader = $(WINE_CC_OPT) -CC_OPT_Devices/Graphics/shaderlib/shader_sm1 = $(WINE_CC_OPT) -CC_OPT_Devices/Graphics/shaderlib/shader_sm4 = $(WINE_CC_OPT) -CC_OPT_Devices/Graphics/shaderlib/shaderapi = $(WINE_CC_OPT) -CC_OPT_Devices/Graphics/shaderlib/stateblock = $(WINE_CC_OPT) -CC_OPT_Devices/Graphics/shaderlib/utils = $(WINE_CC_OPT) - Devices/Graphics/DevVGA.o: vbetables.h vbetables.h: vbetables-gen diff --git a/repos/ports/lib/mk/spec/x86_64/virtualbox6-shaderlib.mk b/repos/ports/lib/mk/spec/x86_64/virtualbox6-shaderlib.mk new file mode 100644 index 0000000000..80934eafd0 --- /dev/null +++ b/repos/ports/lib/mk/spec/x86_64/virtualbox6-shaderlib.mk @@ -0,0 +1,34 @@ +include $(REP_DIR)/lib/mk/virtualbox6-common.inc + +SHARED_LIB = yes +LIBS = stdcxx mesa + +SRC_C += Devices/Graphics/shaderlib/directx.c +SRC_C += Devices/Graphics/shaderlib/glsl_shader.c +SRC_C += Devices/Graphics/shaderlib/libWineStub/debug.c +SRC_C += Devices/Graphics/shaderlib/shader.c +SRC_C += Devices/Graphics/shaderlib/shader_sm1.c +SRC_C += Devices/Graphics/shaderlib/shader_sm4.c +SRC_C += Devices/Graphics/shaderlib/shaderapi.c +SRC_C += Devices/Graphics/shaderlib/stateblock.c +SRC_C += Devices/Graphics/shaderlib/utils.c + +INC_DIR += $(VBOX_DIR)/Devices/Graphics/shaderlib/wine/include +INC_DIR += $(VIRTUALBOX_DIR)/include/VBox/Graphics + +# SVGA3D/wine specific config +WINE_CC_OPT := -D__WINESRC__ -DWINE_NOWINSOCK -D_USE_MATH_DEFINES \ + -DVBOX_USING_WINDDK_W7_OR_LATER \ + -DVBOX_WINE_WITH_SINGLE_SWAPCHAIN_CONTEXT \ + -DVBOX_WINE_WITH_IPRT \ + -UVBOX_WITH_WDDM + +CC_OPT_Devices/Graphics/shaderlib/directx = $(WINE_CC_OPT) +CC_OPT_Devices/Graphics/shaderlib/glsl_shader = $(WINE_CC_OPT) +CC_OPT_Devices/Graphics/shaderlib/libWineStub/debug = $(WINE_CC_OPT) +CC_OPT_Devices/Graphics/shaderlib/shader = $(WINE_CC_OPT) +CC_OPT_Devices/Graphics/shaderlib/shader_sm1 = $(WINE_CC_OPT) +CC_OPT_Devices/Graphics/shaderlib/shader_sm4 = $(WINE_CC_OPT) +CC_OPT_Devices/Graphics/shaderlib/shaderapi = $(WINE_CC_OPT) +CC_OPT_Devices/Graphics/shaderlib/stateblock = $(WINE_CC_OPT) +CC_OPT_Devices/Graphics/shaderlib/utils = $(WINE_CC_OPT) diff --git a/repos/ports/ports/virtualbox6.hash b/repos/ports/ports/virtualbox6.hash index d4c61036b9..6617a3a3e5 100644 --- a/repos/ports/ports/virtualbox6.hash +++ b/repos/ports/ports/virtualbox6.hash @@ -1 +1 @@ -7991a9853bb0a96cad9a54ebaf3290dfda9ae2d2 +ee399455b46b3f366f0423567e06608b0bf1a853 diff --git a/repos/ports/recipes/pkg/vbox6/archives b/repos/ports/recipes/pkg/vbox6/archives index 55569f514a..fd5314ece3 100755 --- a/repos/ports/recipes/pkg/vbox6/archives +++ b/repos/ports/recipes/pkg/vbox6/archives @@ -1,13 +1,17 @@ _/raw/vbox6 +_/src/expat _/src/init _/src/jpeg _/src/libc +_/src/libdrm _/src/libiconv _/src/libyuv +_/src/mesa _/src/posix _/src/stdcxx _/src/vbox6 _/src/vfs +_/src/vfs_gpu _/src/vfs_oss _/src/vfs_pipe _/src/zlib diff --git a/repos/ports/recipes/pkg/vbox6/runtime b/repos/ports/recipes/pkg/vbox6/runtime index 3ccd3855a2..fbe5101464 100755 --- a/repos/ports/recipes/pkg/vbox6/runtime +++ b/repos/ports/recipes/pkg/vbox6/runtime @@ -1,10 +1,11 @@ - + + @@ -12,6 +13,7 @@ + @@ -30,6 +32,7 @@ + @@ -44,14 +47,14 @@ - + - + @@ -82,6 +85,8 @@ + + @@ -93,21 +98,29 @@ + + + + + + + + diff --git a/repos/ports/recipes/raw/vbox6/machine.vbox6 b/repos/ports/recipes/raw/vbox6/machine.vbox6 index e8df5bebcd..bfe40f93a0 100644 --- a/repos/ports/recipes/raw/vbox6/machine.vbox6 +++ b/repos/ports/recipes/raw/vbox6/machine.vbox6 @@ -17,7 +17,14 @@ + + + diff --git a/repos/ports/recipes/src/vbox6/used_apis b/repos/ports/recipes/src/vbox6/used_apis index 695710127b..e0ce69ef4b 100644 --- a/repos/ports/recipes/src/vbox6/used_apis +++ b/repos/ports/recipes/src/vbox6/used_apis @@ -6,6 +6,7 @@ gui_session input_session libc libiconv +mesa nic_session nitpicker_gfx os diff --git a/repos/ports/src/virtualbox6/glx_x11.cc b/repos/ports/src/virtualbox6/glx_x11.cc index a2f1bc9b04..4ee33cc417 100644 --- a/repos/ports/src/virtualbox6/glx_x11.cc +++ b/repos/ports/src/virtualbox6/glx_x11.cc @@ -1,6 +1,7 @@ /* * \brief GLX/X11 emulation for SVGA3D * \author Christian Helmuth + * \author Sebastian Sumpf * \date 2021-10-01 */ @@ -27,7 +28,7 @@ /* local includes */ #include -static bool const debug = true; +static bool const debug = false; using namespace Genode; @@ -40,42 +41,187 @@ extern "C" int ExplicitlyLoadVBoxSVGA3D(bool fResolveAllImports, PRTERRINFO pErr * GLX */ -//static void impl_glXGetProcAddress(GLubyte const *procname) -//{ -//} - -void (*glXGetProcAddress(const GLubyte *procname))(void) -{ - log(__func__, ": procname='", (char const *)procname, "'"); - - return (void(*)())nullptr; -} - extern "C" GLXFBConfig * glXChooseFBConfig(Display *dpy, int screen, const int *attribList, int *nitems) STOP -extern "C" XVisualInfo * glXChooseVisual(Display *dpy, int screen, int *attribList) STOP -extern "C" GLXContext glXCreateContext(Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct) STOP -extern "C" void glXDestroyContext(Display *dpy, GLXContext ctx) STOP extern "C" int glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, int attribute, int *value) STOP extern "C" XVisualInfo * glXGetVisualFromFBConfig(Display *dpy, GLXFBConfig config) STOP -extern "C" Bool glXMakeCurrent(Display *dpy, GLXDrawable drawable, GLXContext ctx) STOP -extern "C" Bool glXQueryVersion(Display *dpy, int *maj, int *min) STOP + + +typedef void (*__GLXextFuncPtr)(void); + +__GLXextFuncPtr glXGetProcAddress(GLubyte const *procname) +{ + return (__GLXextFuncPtr)eglGetProcAddress((char const *)procname); +} + + +extern "C" +Bool glXQueryVersion(Display *display, int *major, int *minor) +{ + EGLBoolean initialized = eglInitialize(display->dpy, major, minor); + + if (initialized) + Genode::log("EGL_VERSION = ", eglQueryString(display->dpy, EGL_VERSION)); + + return initialized; +} + + +extern "C" +XVisualInfo * glXChooseVisual(Display *display, int screen, int *attribList) +{ + EGLConfig config; + EGLint config_attribs[32]; + EGLint num_configs, i; + + i = 0; + config_attribs[i++] = EGL_RED_SIZE; + config_attribs[i++] = 1; + config_attribs[i++] = EGL_GREEN_SIZE; + config_attribs[i++] = 1; + config_attribs[i++] = EGL_BLUE_SIZE; + config_attribs[i++] = 1; + config_attribs[i++] = EGL_DEPTH_SIZE; + config_attribs[i++] = 1; + config_attribs[i++] = EGL_SURFACE_TYPE; + config_attribs[i++] = EGL_WINDOW_BIT; + config_attribs[i++] = EGL_RENDERABLE_TYPE; + config_attribs[i++] = EGL_OPENGL_BIT; + config_attribs[i] = EGL_NONE; + + if (!eglChooseConfig(display->dpy, config_attribs, &config, 1, &num_configs) + || !num_configs) { + Genode::error("failed to choose a config"); + return nullptr; + } + + static XVisualInfo info { }; + static Visual visual { }; + visual.config = config; + info.visual = &visual; + + return &info; +} + + +extern "C" +GLXContext glXCreateContext(Display *display, XVisualInfo *vis, + GLXContext shareList, Bool direct) +{ + eglBindAPI(EGL_OPENGL_API); + EGLint context_attribs[1] { EGL_NONE }; + + GLXContext ctx = new _GLXContext(); + ctx->context = eglCreateContext(display->dpy, vis->visual->config, + shareList ? shareList->context : EGL_NO_CONTEXT, + context_attribs); + if (!ctx->context) { + Genode::error("failed to create context"); + return nullptr; + } + + return ctx; +} + + +extern "C" +Bool glXMakeCurrent(Display *display, GLXDrawable drawable, GLXContext ctx) +{ + if (!eglMakeCurrent(display->dpy, + drawable ? drawable->surface : EGL_NO_SURFACE, + drawable ? drawable->surface : EGL_NO_SURFACE, + ctx ? ctx->context : EGL_NO_CONTEXT)) { + Genode::error("failed to make current drawable"); + return False; + } + + //Genode::warning("glXMakeCurrent: succeeded"); + return True; +} + + +extern "C" +void glXDestroyContext(Display *display, GLXContext ctx) +{ + eglDestroyContext(display->dpy, ctx->context); +} /* * Xlib */ +extern "C" Window XDefaultRootWindow(Display *) TRACE(Window()); +extern "C" Colormap XCreateColormap(Display *, Window, Visual *, int) TRACE(Colormap(1)); +extern "C" XErrorHandler XSetErrorHandler(XErrorHandler) TRACE(XErrorHandler(nullptr)); -extern "C" int XCloseDisplay(Display *) STOP -extern "C" Colormap XCreateColormap(Display *, Window, Visual *, int) STOP -extern "C" Window XCreateWindow( Display *, Window, int, int, unsigned int, unsigned int, unsigned int, int, unsigned int, Visual *, unsigned long, XSetWindowAttributes *) STOP -extern "C" Window XDefaultRootWindow(Display *) STOP -extern "C" int XDestroyWindow(Display *, Window) STOP -extern "C" XErrorHandler XSetErrorHandler(XErrorHandler) STOP -extern "C" int XFree(void *) STOP -extern "C" Status XGetWindowAttributes(Display *, Window, XWindowAttributes *) STOP -extern "C" int XMapWindow(Display *, Window) STOP -extern "C" int XNextEvent(Display *, XEvent *) STOP -extern "C" Display * XOpenDisplay(char *name) STOP -extern "C" int XPending(Display *) STOP -extern "C" int XScreenNumberOfScreen(Screen *) STOP -extern "C" int XSync(Display *, Bool) STOP +extern "C" int XFree(void *) STOP +extern "C" Status XGetWindowAttributes(Display *, Window, XWindowAttributes *) STOP +extern "C" int XMapWindow(Display *, Window) STOP +extern "C" int XNextEvent(Display *, XEvent *) STOP +extern "C" int XScreenNumberOfScreen(Screen *) STOP +extern "C" int XSync(Display *, Bool) STOP + + +extern "C" +Display * XOpenDisplay(char *) +{ + Display *display = new Display(); + display->dpy = eglGetDisplay(EGLNativeDisplayType()); + return display; +} + + +extern "C" +int XCloseDisplay(Display *display) +{ + delete display; + return 0; +} + + +extern "C" +int XPending(Display *) +{ + static bool once = true; + + if (once) { + Genode::error(__func__, " called by 'vmsvga3dXEventThread' implement!"); + once = false; + } + + return 0; +} + + +extern "C" +Window XCreateWindow(Display *display, Window, + int, int, + unsigned width, unsigned height, + unsigned int, int, unsigned int, + Visual *visual, unsigned long, XSetWindowAttributes *) +{ + Genode_egl_window *egl_window = new Genode_egl_window(); + egl_window->width = width; + egl_window->height = height; + egl_window->type = Surface_type::WINDOW; + egl_window->addr = (unsigned char*)0xcafebabe; + + Window window = new _Window(); + window->window = egl_window; + + window->surface = eglCreateWindowSurface(display->dpy, visual->config, egl_window, NULL); + if (window->surface == EGL_NO_SURFACE) { + Genode::error("could not create surface"); + return nullptr; + } + + return window; +} + + +extern "C" int XDestroyWindow(Display *display, Window window) +{ + eglDestroySurface(display->dpy, window->surface); + delete window->window; + delete window; + return 0; +} diff --git a/repos/ports/src/virtualbox6/include/GL/glx.h b/repos/ports/src/virtualbox6/include/GL/glx.h index 0a1e79cf86..1d49e514d3 100644 --- a/repos/ports/src/virtualbox6/include/GL/glx.h +++ b/repos/ports/src/virtualbox6/include/GL/glx.h @@ -4,7 +4,7 @@ #include #include #include - +#include #ifdef __cplusplus extern "C" { @@ -23,10 +23,13 @@ extern "C" { #define GLX_WINDOW_BIT 0x00000001 #define GLX_DRAWABLE_TYPE 0x8010 -typedef struct _GLXContext { void *dummy; } * GLXContext; +typedef struct _GLXContext +{ + EGLContext context; +} * GLXContext; typedef struct _GLXFBConfig { void *dummy; } * GLXFBConfig; -typedef XID GLXDrawable; +typedef Window GLXDrawable; extern void (*glXGetProcAddress(const GLubyte *procname))(void); diff --git a/repos/ports/src/virtualbox6/include/X11/X.h b/repos/ports/src/virtualbox6/include/X11/X.h index 9466545b29..7aea97fe7f 100644 --- a/repos/ports/src/virtualbox6/include/X11/X.h +++ b/repos/ports/src/virtualbox6/include/X11/X.h @@ -1,6 +1,8 @@ #ifndef _X11__X_H_ #define _X11__X_H_ +#include + #ifdef __cplusplus extern "C" { #endif @@ -8,9 +10,11 @@ extern "C" { /* originally in X11/Xmd.h */ typedef unsigned int CARD32; +struct _Window; + typedef CARD32 XID; typedef CARD32 VisualID; -typedef XID Window; +typedef struct _Window* Window; typedef XID Colormap; #define None 0L diff --git a/repos/ports/src/virtualbox6/include/X11/Xlib.h b/repos/ports/src/virtualbox6/include/X11/Xlib.h index 620c68a5d0..bbc0e8286a 100644 --- a/repos/ports/src/virtualbox6/include/X11/Xlib.h +++ b/repos/ports/src/virtualbox6/include/X11/Xlib.h @@ -2,7 +2,7 @@ #define _X11__XLIB_H_ #include - +#include #ifdef __cplusplus extern "C" { #endif @@ -12,9 +12,18 @@ extern "C" { #define True 1 #define False 0 -typedef struct { void *dummy; } Display; +typedef struct { EGLDisplay dpy; } Display; typedef struct { void *dummy; } Screen; -typedef struct { void *dummy; } Visual; +typedef struct +{ + EGLConfig config; +} Visual; + +struct _Window +{ + EGLSurface surface; + EGLNativeWindowType window; +}; typedef struct { unsigned char error_code; } XErrorEvent; diff --git a/repos/ports/src/virtualbox6/patches/series b/repos/ports/src/virtualbox6/patches/series index 4b939e26a6..4c2ced6d33 100644 --- a/repos/ports/src/virtualbox6/patches/series +++ b/repos/ports/src/virtualbox6/patches/series @@ -9,3 +9,5 @@ tm_poke.patch exec_state.patch rttimer.patch devsvga.patch +shaderlib.patch +svga.patch diff --git a/repos/ports/src/virtualbox6/patches/shaderlib.patch b/repos/ports/src/virtualbox6/patches/shaderlib.patch new file mode 100644 index 0000000000..e92533c32f --- /dev/null +++ b/repos/ports/src/virtualbox6/patches/shaderlib.patch @@ -0,0 +1,43 @@ +diff --git a/src/virtualbox6/src/VBox/Devices/Graphics/shaderlib/shader.c b/src/virtualbox6/src/VBox/Devices/Graphics/shaderlib/shader.c +index 19da2bc..1510e67 100644 +--- a/src/virtualbox6/src/VBox/Devices/Graphics/shaderlib/shader.c ++++ b/src/virtualbox6/src/VBox/Devices/Graphics/shaderlib/shader.c +@@ -745,7 +745,8 @@ static HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct + + /* Fake sampler usage, only set reserved bit and type. */ + sampler_idx = dst_param.reg.idx; +- AssertReturn(sampler_idx < RT_ELEMENTS(reg_maps->sampler_type), E_INVALIDARG); ++ /* triggers in native VirtualBox6 as well */ ++ //AssertReturn(sampler_idx < RT_ELEMENTS(reg_maps->sampler_type), E_INVALIDARG); + + TRACE("Setting fake 2D sampler for 1.x pixelshader.\n"); + reg_maps->sampler_type[sampler_idx] = WINED3DSTT_2D; +diff --git a/src/virtualbox6/src/VBox/Devices/Graphics/shaderlib/wined3d_gl.h b/src/virtualbox6/src/VBox/Devices/Graphics/shaderlib/wined3d_gl.h +index 2fa9b12..99bd0d9 100644 +--- a/src/virtualbox6/src/VBox/Devices/Graphics/shaderlib/wined3d_gl.h ++++ b/src/virtualbox6/src/VBox/Devices/Graphics/shaderlib/wined3d_gl.h +@@ -64,6 +64,11 @@ + #define WINE_GLAPI + #endif + ++#ifdef DECLSPEC_HIDDEN ++#undef DECLSPEC_HIDDEN ++#endif ++#define DECLSPEC_HIDDEN __attribute__((visibility("hidden"))) ++ + /**************************************************** + * OpenGL 1.0/1.1/1.2/1.3 + * types, #defines and function pointers +diff --git a/src/virtualbox6/src/VBox/Devices/Graphics/shaderlib/wined3d_private.h b/src/virtualbox6/src/VBox/Devices/Graphics/shaderlib/wined3d_private.h +index 3c7e750..bc23da2 100644 +--- a/src/virtualbox6/src/VBox/Devices/Graphics/shaderlib/wined3d_private.h ++++ b/src/virtualbox6/src/VBox/Devices/Graphics/shaderlib/wined3d_private.h +@@ -1323,7 +1323,7 @@ struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3 + , struct VBOXUHGSMI *pHgsmi + #endif + ) DECLSPEC_HIDDEN; +-struct IWineD3DDeviceImpl *context_get_device(const struct wined3d_context *context); DECLSPEC_HIDDEN; ++struct IWineD3DDeviceImpl *context_get_device(const struct wined3d_context *context) DECLSPEC_HIDDEN; + #ifdef VBOX_WITH_WDDM + struct wined3d_context *context_find_create(IWineD3DDeviceImpl *device, IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target, + const struct wined3d_format_desc *ds_format_desc) DECLSPEC_HIDDEN; diff --git a/repos/ports/src/virtualbox6/patches/svga.patch b/repos/ports/src/virtualbox6/patches/svga.patch new file mode 100644 index 0000000000..80bf179b05 --- /dev/null +++ b/repos/ports/src/virtualbox6/patches/svga.patch @@ -0,0 +1,10 @@ +--- virtualbox6-0cabc6a3f8e2884326dabeb1768916704dfdd115/src/virtualbox6/src/VBox/Devices/Graphics/DevVGA-SVGA3d-internal.h 2021-01-07 16:39:17.000000000 +0100 ++++ virtualbox6-devel-gpu/src/virtualbox6/src/VBox/Devices/Graphics/DevVGA-SVGA3d-internal.h 2021-10-12 12:06:58.895163551 +0200 +@@ -88,6 +88,7 @@ + + #include "vmsvga/svga3d_shaderdefs.h" + #ifdef VMSVGA3D_OPENGL ++#undef GL_GLEXT_VERSION + # include "vmsvga_glext/glext.h" + # include "shaderlib/shaderlib.h" + #endif