summaryrefslogtreecommitdiffstats
path: root/src/VBox/Additions/3D/win/VBoxNine
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 03:01:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 03:01:46 +0000
commitf8fe689a81f906d1b91bb3220acde2a4ecb14c5b (patch)
tree26484e9d7e2c67806c2d1760196ff01aaa858e8c /src/VBox/Additions/3D/win/VBoxNine
parentInitial commit. (diff)
downloadvirtualbox-upstream.tar.xz
virtualbox-upstream.zip
Adding upstream version 6.0.4-dfsg.upstream/6.0.4-dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Additions/3D/win/VBoxNine')
-rw-r--r--src/VBox/Additions/3D/win/VBoxNine/Makefile.kmk61
-rw-r--r--src/VBox/Additions/3D/win/VBoxNine/VBoxNine.c168
-rw-r--r--src/VBox/Additions/3D/win/VBoxNine/VBoxNine.def24
-rw-r--r--src/VBox/Additions/3D/win/VBoxNine/VBoxNine.rc56
4 files changed, 309 insertions, 0 deletions
diff --git a/src/VBox/Additions/3D/win/VBoxNine/Makefile.kmk b/src/VBox/Additions/3D/win/VBoxNine/Makefile.kmk
new file mode 100644
index 00000000..ea254c01
--- /dev/null
+++ b/src/VBox/Additions/3D/win/VBoxNine/Makefile.kmk
@@ -0,0 +1,61 @@
+# $Id: Makefile.kmk $
+## @file
+# Sub-Makefile for VBoxNine D3D9 state tracker.
+#
+
+#
+# Copyright (C) 2016-2019 Oracle Corporation
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+
+SUB_DEPTH = ../../../../../..
+include $(KBUILD_PATH)/subheader.kmk
+
+DLLS += VBoxNine
+DLLS.amd64 += VBoxNine-x86
+
+VBoxNine_TEMPLATE = VBoxMesa3DGuestR3DllMinVista
+# -wd4100: unreferenced formal parameter
+# -wd4200: nonstandard extension used : zero-sized array in struct/union
+# -wd4245: 'return' : conversion from 'int' to 'unsigned int', signed/unsigned mismatch
+# -wd4255: no function prototype given
+# -wd4668: 'something' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
+VBoxNine_CFLAGS = -wd4100 -wd4200 -wd4245 -wd4255 -wd4668
+VBoxNine_INCS = \
+ $(VBOX_PATH_MESA)/src/gallium/state_trackers/nine
+VBoxNine_SOURCES = \
+ VBoxNine.c \
+ VBoxNine.rc \
+ VBoxNine.def
+VBoxNine_LIBS = \
+ $(VBOX_PATH_ADDITIONS_LIB)/VBoxWddmUmHlp$(VBOX_SUFF_LIB) \
+ $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaGalliumAuxLib$(VBOX_SUFF_LIB) \
+ $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaUtilLib$(VBOX_SUFF_LIB) \
+ $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaNineLib$(VBOX_SUFF_LIB)
+
+ifdef VBOX_SIGN_ADDITIONS
+ VBoxNine_INSTTYPE = none
+ VBoxNine_DEBUG_INSTTYPE = both
+endif
+
+#
+# VBoxNine-x86 - x86 version of VBoxNine built for amd64 build
+#
+VBoxNine-x86_EXTENDS = VBoxNine
+VBoxNine-x86_BLD_TRG_ARCH = x86
+VBoxNine-x86_LIBS = \
+ $(VBOX_PATH_ADDITIONS_LIB)/VBoxWddmUmHlp-x86$(VBOX_SUFF_LIB) \
+ $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaGalliumAuxLib-x86$(VBOX_SUFF_LIB) \
+ $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaUtilLib-x86$(VBOX_SUFF_LIB) \
+ $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaNineLib-x86$(VBOX_SUFF_LIB)
+VBoxNine-x86_DEFS = $(VBoxNine_DEFS) VBOX_WOW64
+
+include $(FILE_KBUILD_SUB_FOOTER)
+
diff --git a/src/VBox/Additions/3D/win/VBoxNine/VBoxNine.c b/src/VBox/Additions/3D/win/VBoxNine/VBoxNine.c
new file mode 100644
index 00000000..ad01f804
--- /dev/null
+++ b/src/VBox/Additions/3D/win/VBoxNine/VBoxNine.c
@@ -0,0 +1,168 @@
+/* $Id: VBoxNine.c $ */
+/** @file
+ * VirtualBox Windows Guest Mesa3D - Direct3D9 state tracker.
+ */
+
+/*
+ * Copyright (C) 2016-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#include <iprt/win/windows.h>
+#include <iprt/win/d3d9.h>
+//#include <d3dumddi.h>
+
+#include <VBoxWddmUmHlp.h>
+
+//#include <windef.h>
+//#include <winbase.h>
+//#include <winsvc.h>
+//#include <winnetwk.h>
+//#include <npapi.h>
+//#include <devioctl.h>
+//#include <stdio.h>
+
+//#include <iprt/alloc.h>
+//#include <iprt/initterm.h>
+//#include <iprt/string.h>
+//#include <iprt/log.h>
+//#include <VBox/version.h>
+//#include <VBox/VMMDev.h>
+//#include <VBox/Log.h>
+
+#include "adapter9.h"
+#include "surface9.h"
+#include "pipe/p_screen.h"
+
+#include <iprt/types.h>
+// #include <iprt/asm.h>
+
+// #include "VBoxNine.h"
+
+struct d3dadapter9_context_wddm
+{
+ struct d3dadapter9_context base;
+ void *reserved;
+};
+
+static void
+wddm_destroy(struct d3dadapter9_context *ctx)
+{
+ /* struct d3dadapter9_context_wddm *ctx_wddm = (struct d3dadapter9_context_wddm *)ctx; */
+
+/// @todo screen (hal) is deleted by the upper level. Do not delete here.
+// if (ctx->ref)
+// ctx->ref->destroy(ctx->ref);
+// /* because ref is a wrapper around hal, freeing ref frees hal too. */
+// else if (ctx->hal)
+// ctx->hal->destroy(ctx->hal);
+
+ FREE(ctx);
+}
+
+static HRESULT
+d3dadapter9_context_wddm_create(struct d3dadapter9_context_wddm **ppCtx, struct pipe_screen *s)
+{
+ struct d3dadapter9_context_wddm *ctx = CALLOC_STRUCT(d3dadapter9_context_wddm);
+
+ if (!ctx) { return E_OUTOFMEMORY; }
+
+ ctx->base.destroy = wddm_destroy;
+
+ ctx->base.linear_framebuffer = 1;
+
+ ctx->base.hal = s;
+
+ ctx->base.throttling = FALSE;
+ ctx->base.throttling_value = 0;
+
+ ctx->base.vblank_mode = 1;
+
+ ctx->base.thread_submit = 0;
+
+ /** @todo Need software device here. Currently assigned to hw device to prevent NineDevice9_ctor crash. */
+ ctx->base.ref = ctx->base.hal;
+
+ /* read out PCI info */
+ /// @todo read_descriptor(&ctx->base, fd);
+
+ *ppCtx = ctx;
+ return D3D_OK;
+}
+
+HRESULT WINAPI
+GaNineD3DAdapter9Create(struct pipe_screen *s, ID3DAdapter9 **ppOut)
+{
+ HRESULT hr;
+ struct d3dadapter9_context_wddm *pCtx = NULL;
+ hr = d3dadapter9_context_wddm_create(&pCtx, s);
+ if (SUCCEEDED(hr))
+ {
+ hr = NineAdapter9_new(&pCtx->base, (struct NineAdapter9 **)ppOut);
+ if (FAILED(hr))
+ {
+ /// @todo NineAdapter9_new calls this as ctx->base.destroy,
+ // and will not call if memory allocation fails.
+ // wddm_destroy(&pCtx->base);
+ }
+ }
+ return hr;
+}
+
+struct pipe_resource * WINAPI
+GaNinePipeResourceFromSurface(IUnknown *pSurface)
+{
+ /// @todo QueryInterface?
+ struct NineResource9 *pResource = (struct NineResource9 *)pSurface;
+ return pResource->resource;
+}
+
+extern struct pipe_context *
+NineDevice9_GetPipe( struct NineDevice9 *This );
+
+struct pipe_context * WINAPI
+GaNinePipeContextFromDevice(IDirect3DDevice9 *pDevice)
+{
+ /// @todo Verify that this is a NineDevice?
+ struct pipe_context *pPipeContext = NineDevice9_GetPipe((struct NineDevice9 *)pDevice);
+ return pPipeContext;
+}
+
+BOOL WINAPI DllMain(HINSTANCE hDLLInst,
+ DWORD fdwReason,
+ LPVOID lpvReserved)
+{
+ BOOL fReturn = TRUE;
+
+ RT_NOREF2(hDLLInst, lpvReserved);
+
+ switch (fdwReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ //RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
+ D3DKMTLoad();
+ break;
+
+ case DLL_PROCESS_DETACH:
+ /// @todo RTR3Term();
+ break;
+
+ case DLL_THREAD_ATTACH:
+ break;
+
+ case DLL_THREAD_DETACH:
+ break;
+
+ default:
+ break;
+ }
+
+ return fReturn;
+}
diff --git a/src/VBox/Additions/3D/win/VBoxNine/VBoxNine.def b/src/VBox/Additions/3D/win/VBoxNine/VBoxNine.def
new file mode 100644
index 00000000..e467f073
--- /dev/null
+++ b/src/VBox/Additions/3D/win/VBoxNine/VBoxNine.def
@@ -0,0 +1,24 @@
+; $Id: VBoxNine.def $;
+;; @file
+; Export definition file for the VBoxNine D3D9 state tracker.
+;
+
+;
+; Copyright (C) 2016-2019 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+
+LIBRARY VBOXNINE
+
+EXPORTS
+ GaNineD3DAdapter9Create @1
+ GaNinePipeResourceFromSurface @2
+ GaNinePipeContextFromDevice @3
+
diff --git a/src/VBox/Additions/3D/win/VBoxNine/VBoxNine.rc b/src/VBox/Additions/3D/win/VBoxNine/VBoxNine.rc
new file mode 100644
index 00000000..4a5a15a6
--- /dev/null
+++ b/src/VBox/Additions/3D/win/VBoxNine/VBoxNine.rc
@@ -0,0 +1,56 @@
+/* $Id: VBoxNine.rc $ */
+/** @file
+ * VBoxNine - Resource file containing version info and icon.
+ */
+
+/*
+ * Copyright (C) 2016-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#include <windows.h>
+#include <VBox/version.h>
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION VBOX_RC_FILE_VERSION
+ PRODUCTVERSION VBOX_RC_FILE_VERSION
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+ FILEFLAGS VBOX_RC_FILE_FLAGS
+ FILEOS VBOX_RC_FILE_OS
+ FILETYPE VBOX_RC_TYPE_DLL
+ FILESUBTYPE VFT2_UNKNOWN
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "VirtualBox D3D9 Mesa State Tracker\0"
+ VALUE "InternalName", "VBoxNine\0"
+#ifdef VBOX_WOW64
+ VALUE "OriginalFilename", "VBoxNine-x86.DLL\0"
+#else
+ VALUE "OriginalFilename", "VBoxNine.DLL\0"
+#endif
+ VALUE "CompanyName", VBOX_RC_COMPANY_NAME
+ VALUE "FileVersion", VBOX_RC_FILE_VERSION_STR
+ VALUE "LegalCopyright", VBOX_RC_LEGAL_COPYRIGHT
+ VALUE "ProductName", VBOX_RC_PRODUCT_NAME_GA_STR
+ VALUE "ProductVersion", VBOX_RC_PRODUCT_VERSION_STR
+ VBOX_RC_MORE_STRINGS
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END