diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-11 08:17:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-11 08:17:27 +0000 |
commit | f215e02bf85f68d3a6106c2a1f4f7f063f819064 (patch) | |
tree | 6bb5b92c046312c4e95ac2620b10ddf482d3fa8b /src/VBox/Additions/3D | |
parent | Initial commit. (diff) | |
download | virtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.tar.xz virtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.zip |
Adding upstream version 7.0.14-dfsg.upstream/7.0.14-dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
45 files changed, 8620 insertions, 0 deletions
diff --git a/src/VBox/Additions/3D/Config.kmk b/src/VBox/Additions/3D/Config.kmk new file mode 100644 index 00000000..1f6fc5c3 --- /dev/null +++ b/src/VBox/Additions/3D/Config.kmk @@ -0,0 +1,141 @@ +# $Id: Config.kmk $ +## @file +# kBuild Configuration file for the Mesa3D. +# + +# +# Copyright (C) 2016-2023 Oracle and/or its affiliates. +# +# This file is part of VirtualBox base platform packages, as +# available from https://www.virtualbox.org. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, in version 3 of the +# License. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see <https://www.gnu.org/licenses>. +# +# SPDX-License-Identifier: GPL-3.0-only +# + +VBOX_MESA3D_CONFIG_KMK_INCLUDED := 1 + +# Include the top-level configure file. +ifndef VBOX_ROOT_CONFIG_KMK_INCLUDED + include $(PATH_ROOT)/Config.kmk +endif + +VBOX_MESA := mesa-21.3.8 +VBOX_PATH_3D := $(PATH_ROOT)/src/VBox/Additions/3D +VBOX_PATH_MESA := $(PATH_ROOT)/src/VBox/Additions/3D/mesa/$(VBOX_MESA) +VBOX_PATH_WDDM := $(PATH_ROOT)/src/VBox/Additions/WINNT/Graphics/Video +VBOX_PATH_VMSVGA_INC := $(VBOX_PATH_MESA)/src/gallium/drivers/svga/include + +# +# Base template for Mesa3D code and code which uses Mesa3D libraries. +# +TEMPLATE_VBoxMesa3DGuestR3Dll = VBox Mesa 3D Guest User Mode DLL +TEMPLATE_VBoxMesa3DGuestR3Dll_EXTENDS = NewerVccVBoxGuestR3Dll +TEMPLATE_VBoxMesa3DGuestR3Dll_INST = $(INST_ADDITIONS) +TEMPLATE_VBoxMesa3DGuestR3Dll_DEFS = $(TEMPLATE_NewerVccVBoxGuestR3Dll_DEFS) \ + VBOX_WITH_MESA3D +ifdef VBOX_WITH_VMSVGA + TEMPLATE_VBoxMesa3DGuestR3Dll_DEFS += \ + VBOX_WITH_VMSVGA + # treat as error: warning C4013: 'close' undefined; assuming extern returning int + TEMPLATE_VBoxMesa3DGuestR3Dll_CFLAGS = $(TEMPLATE_NewerVccVBoxGuestR3Dll_CFLAGS) -we4013 +endif +TEMPLATE_VBoxMesa3DGuestR3Dll_SDKS.win = $(TEMPLATE_NewerVccVBoxGuestR3Dll_SDKS) \ + $(VBOX_WINDDK_GST_W8) +# VirtualBox specific modifications of the Mesa3D code. +# All modified places can be found by searching for VBOX +# +# Each define represents a group of related modifications. +# The purpose of the separation is to document why each modification was necessary. +# +# Modifications which would be nice to have in upstream Mesa code are marked with '*' here. +# +# VBOX Modifications in headers shared with VBox WDDM driver code (see comments). +# VBOX_WITH_MESA3D_COMPILE Tweaks to compile Mesa as part of VBox WDDM. +# VBOX_WITH_MESA3D_D3D_FROM_SYSTEMMEM Create D3DPOOL_SYSTEMMEM textures from provided system memory pointer. +# VBOX_WITH_MESA3D_D3D_THREADPOOL (No) threadpool for VBox build. +# VBOX_WITH_MESA3D_DBG Tweaks for easier debugging and better logging. +# VBOX_WITH_MESA3D_HACKS Hacks to make it work (need a proper solutions). +# *VBOX_WITH_MESA3D_MSC Tweaks for Microsoft VCC. +# VBOX_WITH_MESA3D_NINE_SVGA Make the D3D state tracker to work together with VMSVGA. +# VBOX_WITH_MESA3D_SVGA_GPU_FINISHED PIPE_QUERY_GPU_FINISHED in VMSVGA driver. +# VBOX_WITH_MESA3D_SVGA_HALFZ D3D Z coord [0.0;1.0] in the Gallium SVGA driver (VGPU9 only). +# VBOX_WITH_MESA3D_SVGA_INSTANCING Instancing for DrawPrimitives in the Gallium SVGA driver +# (VGPU9 only, VGPU10 has it). +TEMPLATE_VBoxMesa3DGuestR3Dll_DEFS += \ + VBOX_WITH_MESA3D_COMPILE \ + VBOX_WITH_MESA3D_D3D_FROM_SYSTEMMEM \ + VBOX_WITH_MESA3D_D3D_THREADPOOL \ + VBOX_WITH_MESA3D_DBG \ + VBOX_WITH_MESA3D_HACKS \ + VBOX_WITH_MESA3D_MSC \ + VBOX_WITH_MESA3D_NINE_SVGA \ + VBOX_WITH_MESA3D_SVGA_GPU_FINISHED \ + VBOX_WITH_MESA3D_SVGA_HALFZ \ + VBOX_WITH_MESA3D_SVGA_INSTANCING +ifdef VBOX_WITH_NOCRT_STATIC + TEMPLATE_VBoxMesa3DGuestR3Dll_DEFS += \ + IPRT_NO_CRT_FOR_3RD_PARTY \ + RT_WITHOUT_NOCRT_WRAPPERS \ + RT_WITHOUT_NOCRT_WRAPPER_ALIASES +endif +TEMPLATE_VBoxMesa3DGuestR3Dll_DEFS.win = $(TEMPLATE_NewerVccVBoxGuestR3Dll_DEFS.win) \ + _USE_MATH_DEFINES \ + WINAPI=__stdcall \ + _WIN32 +TEMPLATE_VBoxMesa3DGuestR3Dll_INCS = $(TEMPLATE_NewerVccVBoxGuestR3Dll_INCS) \ + $(VBOX_PATH_MESA)/include \ + $(VBOX_PATH_MESA)/include/c99 \ + $(VBOX_PATH_MESA)/src \ + $(VBOX_PATH_MESA)/src/mesa \ + $(VBOX_PATH_MESA)/src/gallium/auxiliary \ + $(VBOX_PATH_MESA)/src/gallium/include \ + $(VBOX_PATH_3D)/win/VBoxWddmUmHlp +ifdef VBOX_WITH_NOCRT_STATIC # Only the softfloat libs are added here as mesa includes a softfloat.h and we wish for no conflicts. + TEMPLATE_VBoxMesa3DGuestR3Dll_LIBS.x86 += $(TEMPLATE_NewerVccVBoxGuestR3Dll_LIBS.x86) \ + $(VBOX_LIB_IPRT_GUEST_R3_SHARED_X86) \ + $(SDK_VBoxSoftFloatGuestR3Shared_LIBS.x86) + TEMPLATE_VBoxMesa3DGuestR3Dll_LIBS.$(KBUILD_TARGET_ARCH) += $(TEMPLATE_NewerVccVBoxGuestR3Dll_LIBS.$(KBUILD_TARGET)) \ + $(VBOX_LIB_IPRT_GUEST_R3_SHARED) \ + $(SDK_VBoxSoftFloatGuestR3Shared_LIBS.$(KBUILD_TARGET_ARCH)) + TEMPLATE_VBoxMesa3DGuestR3Dll_LDFLAGS.win += $(TEMPLATE_NewerVccVBoxGuestR3Dll_LDFLAGS.win) + # The -Oi- disable optimizations of math functions like sqrt(), that takes all + # parameters on the stack, into calls to __CIsqrt that takes parameters in FPU + # registers. While we could implement the __CIxxxx functions too, they would + # be difficult to test properly given that they're not directly callable from + # C. Also, there could be other aspects to these functions that we don't know + # about, given that they aren't documented all that well. See: + # https://docs.microsoft.com/en-us/cpp/preprocessor/intrinsic?view=msvc-160#intrinsic-floating-point-functions + # https://docs.microsoft.com/en-us/cpp/build/reference/oi-generate-intrinsic-functions?view=msvc-160 + # Unforutnately, this does mean that we will miss out on a little bit of + # performance in 32-bit binaries. + TEMPLATE_VBoxMesa3DGuestR3Dll_CFLAGS.win.x86 += $(TEMPLATE_NewerVccVBoxGuestR3Dll_CFLAGS.win.x86) -Oi- + TEMPLATE_VBoxMesa3DGuestR3Dll_CXXFLAGS.win.x86 += $(TEMPLATE_NewerVccVBoxGuestR3Dll_CXXFLAGS.win.x86) -Oi- +endif + +# +# Variant of VBoxMesa3DGuestR3Dll that requires Windows Vista or later. +# +TEMPLATE_VBoxMesa3DGuestR3DllMinVista = VBox Mesa 3D Guest User Mode DLL (Windows Vista or newer) +TEMPLATE_VBoxMesa3DGuestR3DllMinVista_EXTENDS = VBoxMesa3DGuestR3Dll +TEMPLATE_VBoxMesa3DGuestR3DllMinVista_VBOX_IMPORT_CHECKER.win.x86 := vista +TEMPLATE_VBoxMesa3DGuestR3DllMinVista_VBOX_IMPORT_CHECKER.win.amd64 := vista +ifeq ($(KBUILD_TARGET),win) + TEMPLATE_VBoxMesa3DGuestR3DllMinVista_LDFLAGS.win.x86 = $(filter-out -Section:.bss$(COMMA)RW!K,$(TEMPLATE_VBoxMesa3DGuestR3Dll_LDFLAGS.win.x86)) + TEMPLATE_VBoxMesa3DGuestR3DllMinVista_POST_CMDS.win.x86 = $(subst $(VBOX_PE_SET_VERSION), $(VBOX_PE_SET_VERSION) --vista,$(TEMPLATE_VBoxMesa3DGuestR3Dll_POST_CMDS.win.x86)) + TEMPLATE_VBoxMesa3DGuestR3DllMinVista_POST_CMDS.win.amd64 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION) --vista $(out)$$(NLTAB)$(TEMPLATE_VBoxMesa3DGuestR3Dll_POST_CMDS.win.amd64)) + TEMPLATE_VBoxMesa3DGuestR3DllMinVista_LNK_DEPS.win.amd64 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION)) $(TEMPLATE_VBoxMesa3DGuestR3Dll_LNK_DEPS.win.amd64) +endif + diff --git a/src/VBox/Additions/3D/Makefile.kmk b/src/VBox/Additions/3D/Makefile.kmk new file mode 100644 index 00000000..eca2615f --- /dev/null +++ b/src/VBox/Additions/3D/Makefile.kmk @@ -0,0 +1,46 @@ +# $Id: Makefile.kmk $ +## @file +# Sub-Makefile for the Mesa3D code. +# + +# +# Copyright (C) 2016-2023 Oracle and/or its affiliates. +# +# This file is part of VirtualBox base platform packages, as +# available from https://www.virtualbox.org. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, in version 3 of the +# License. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see <https://www.gnu.org/licenses>. +# +# SPDX-License-Identifier: GPL-3.0-only +# + +SUB_DEPTH = ../../../.. +include $(KBUILD_PATH)/subheader.kmk + +# +# Make sure our Config.kmk is included. +# +ifndef VBOX_MESA3D_CONFIG_KMK_INCLUDED + include $(PATH_SUB_CURRENT)/Config.kmk +endif + +# +# Include sub-makefile. +# +include $(PATH_SUB_CURRENT)/mesa/Makefile.kmk +if1of ($(KBUILD_TARGET), win) + include $(PATH_SUB_CURRENT)/win/Makefile.kmk +endif + +include $(FILE_KBUILD_SUB_FOOTER) diff --git a/src/VBox/Additions/3D/mesa/.scm-settings b/src/VBox/Additions/3D/mesa/.scm-settings new file mode 100644 index 00000000..6deb7778 --- /dev/null +++ b/src/VBox/Additions/3D/mesa/.scm-settings @@ -0,0 +1,30 @@ +# $Id: .scm-settings $ +## @file +# Source code massager settings for 3D additions stuff. +# + +# +# Copyright (C) 2010-2023 Oracle and/or its affiliates. +# +# This file is part of VirtualBox base platform packages, as +# available from https://www.virtualbox.org. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, in version 3 of the +# License. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see <https://www.gnu.org/licenses>. +# +# SPDX-License-Identifier: GPL-3.0-only +# + + +--filter-out-dirs "/mesa-*/." + diff --git a/src/VBox/Additions/3D/mesa/Makefile.kmk b/src/VBox/Additions/3D/mesa/Makefile.kmk new file mode 100644 index 00000000..8ce09bf0 --- /dev/null +++ b/src/VBox/Additions/3D/mesa/Makefile.kmk @@ -0,0 +1,1516 @@ +# $Id: Makefile.kmk $ +## @file +# Sub-Makefile for the VirtualBox Guest Mesa 3D components +# + +# +# Copyright (C) 2016-2023 Oracle and/or its affiliates. +# +# This file is part of VirtualBox base platform packages, as +# available from https://www.virtualbox.org. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, in version 3 of the +# License. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see <https://www.gnu.org/licenses>. +# +# SPDX-License-Identifier: GPL-3.0-only +# + +SUB_DEPTH = ../../../../.. +include $(KBUILD_PATH)/subheader.kmk + +# +# Make sure our Config.kmk is included. +# +ifndef VBOX_MESA3D_CONFIG_KMK_INCLUDED + include $(PATH_SUB_CURRENT)/../Config.kmk +endif + +PYTHON_CMD = $(VBOX_BLD_PYTHON) -B + +# +# Target lists. +# +LIBRARIES.win += \ + VBoxMesaUtilLib \ + VBoxMesaLib \ + VBoxMesaWglLib \ + VBoxMesaGalliumAuxLib \ + VBoxMesaNineLib \ + VBoxMesaSVGALib \ + VBoxMesaSVGAWinsysLib +LIBRARIES.win.amd64 += \ + VBoxMesaUtilLib-x86 \ + VBoxMesaLib-x86 \ + VBoxMesaWglLib-x86 \ + VBoxMesaGalliumAuxLib-x86 \ + VBoxMesaNineLib-x86 \ + VBoxMesaSVGALib-x86 \ + VBoxMesaSVGAWinsysLib-x86 + + +TEMPLATE_VBoxMesa3DGuestR3Lib = VBox Mesa 3D Guest User Mode Library +TEMPLATE_VBoxMesa3DGuestR3Lib_EXTENDS = VBoxMesa3DGuestR3Dll +TEMPLATE_VBoxMesa3DGuestR3Lib_INST = $(INST_ADDITIONS_LIB) +ifeq ($(KBUILD_TARGET),win) + # Do not treat warnings as errors, because Mesa code produces too many warnings with MSC. + TEMPLATE_VBoxMesa3DGuestR3Lib_CFLAGS = $(filter-out -WX,$(TEMPLATE_VBoxMesa3DGuestR3Dll_CFLAGS)) + TEMPLATE_VBoxMesa3DGuestR3Lib_CXXFLAGS = $(filter-out -WX,$(TEMPLATE_VBoxMesa3DGuestR3Dll_CXXFLAGS)) + # -wd4005: vcc120: '__useHeader' : macro redefinition + # -wd4018: signed/unsigned mismatch + # -wd4054: 'type cast' : from function pointer to data pointer 'void *' + # -wd4057: 'function' : 'int *' differs in indirection to slightly different base types from 'uint32_t *' + # -wd4090: 'function' : different 'const' qualifiers + # -wd4098: 'void' function returning a value + # -wd4099: 'st_src_reg' : type name first seen using 'class' now seen using 'struct' + # -wd4100: unreferenced formal parameter + # -wd4101: unreferenced local variable + # -wd4130: '==' : logical operation on address of string constant + # -wd4132: 'color' : const object should be initialized + # -wd4146: unary minus operator applied to unsigned type, result still unsigned + # -wd4152: nonstandard extension, function/data pointer conversion in expression + # -wd4189: 'signo' : local variable is initialized but not referenced + # -wd4200: nonstandard extension used : zero-sized array in struct/union + # -wd4204: nonstandard extension used : non-constant aggregate initializer + # -wd4206: nonstandard extension used : translation unit is empty + # -wd4211: nonstandard extension used : redefined extern to static + # -wd4221: nonstandard extension used : 'tokens' : cannot be initialized using address of automatic variable 'tokens' + # -wd4245: '=' : conversion from 'int' to 'unsigned int', signed/unsigned mismatch + # -wd4255: no function prototype given + # -wd4258: 'i' : definition from the for loop is ignored; the definition from the enclosing scope is used + # -wd4265: 'ir_variable_refcount_visitor' : class has virtual functions, but destructor is not virtual + # -wd4267: '=' : conversion from 'size_t' to 'unsigned int', possible loss of data + # -wd4266: 'void ir_visitor::visit(ir_rvalue *)' : no override available for virtual member function from base 'ir_visitor'; function is hidden + # -wd4287: unsigned/negative constant mismatch + # -wd4291: 'void *exec_node::operator new(size_t,void *)' : no matching operator delete found; memory will not be freed if initialization throws an exception + # -wd4305: truncation from 'double' to 'const float' + # -wd4306: 'type cast' : conversion from 'int' to 'void *' of greater size + # -wd4310: cast truncates constant value + # -wd4311: 'type cast' : pointer truncation from 'void *' to 'unsigned long' + # -wd4351: new behavior: elements of array '_mesa_glsl_parse_state::cs_input_local_size' will be default initialized + # -wd4355: 'this' : used in base member initializer list + # -wd4388: '==' : signed/unsigned mismatch + # -wd4389: '==' : signed/unsigned mismatch + # -wd4640: 'ts' : construction of local static object is not thread-safe + # -wd4668: '__STDC_VERSION__' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' + # -wd4700: uninitialized local variable 'tmp' used + # -wd4701: potentially uninitialized local variable 'query' used + # -wd4702: unreachable code + # -wd4703: vcc120: potentially uninitialized local pointer variable 'gen_func' used + # -wd4756: overflow in constant arithmetic + # -wd4800: 'int' : forcing value to bool 'true' or 'false' (performance warning) + # -wd4805: '|=' : unsafe mix of type 'GLboolean' and type 'bool' in operation + # -wd4918: 'y' : invalid character in pragma optimization list + VBOX_MESA3D_VCC_DISABLED_WARNINGS := \ + -wd4005 -wd4018 -wd4054 -wd4057 -wd4090 -wd4098 -wd4099 -wd4100 -wd4101 -wd4130 -wd4132 -wd4146 \ + -wd4152 -wd4189 -wd4200 -wd4204 -wd4206 -wd4211 -wd4221 -wd4245 -wd4255 -wd4258 -wd4265 -wd4267 -wd4266 \ + -wd4287 -wd4291 -wd4305 -wd4306 -wd4310 -wd4311 -wd4351 -wd4355 -wd4388 -wd4389 -wd4640 -wd4668 -wd4700 \ + -wd4701 -wd4702 -wd4703 -wd4756 -wd4800 -wd4805 -wd4918 + # -wd4458: declaration of 'array' hides class member + # -wd4477: 'fprintf' : format string '%u' requires an argument of type 'unsigned int', but variadic argument 1 has type 'LONGLONG' + # -wd4774: 'printf' : format string expected in argument 1 is not a string literal + # -wd4456: declaration of 'pos_dst' hides previous local declaration + # -wd4777: '_snprintf' : format string '%u' requires an argument of type 'unsigned int', but variadic argument 1 has type 'const DWORD' + # -wd4459: declaration of 'stw_dev' hides global declaration + # -wd4457: declaration of 'usage' hides function parameter + VBOX_MESA3D_VCC_DISABLED_WARNINGS += \ + -wd4458 -wd4477 -wd4774 -wd4456 -wd4777 -wd4459 -wd4457 + # -wd4254: '=': conversion from 'unsigned int':'3' to 'unsigned int':'2', possible loss of data + # -wd5039: pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception + # -wd5204: class has virtual functions, but its trivial destructor is not virtual; instances of objects derived from this class may not be destructed correctly + # -wd5219: implicit conversion from 'int' to 'float', possible loss of data + VBOX_MESA3D_VCC_DISABLED_WARNINGS += \ + -wd4254 -wd5039 -wd5204 -wd5219 + + TEMPLATE_VBoxMesa3DGuestR3Lib_CFLAGS.win += $(VBOX_MESA3D_VCC_DISABLED_WARNINGS) + TEMPLATE_VBoxMesa3DGuestR3Lib_CXXFLAGS.win += $(VBOX_MESA3D_VCC_DISABLED_WARNINGS) +endif +TEMPLATE_VBoxMesa3DGuestR3Lib_INCS = \ + include \ + $(VBOX_MESA)/include \ + $(VBOX_MESA)/include/GL \ + $(VBOX_MESA)/src \ + $(VBOX_MESA)/src/mapi \ + $(VBOX_MESA)/src/util \ + $(VBOX_MESA)/src/mesa \ + $(VBOX_MESA)/src/mesa/main \ + $(VBOX_MESA)/src/compiler \ + $(VBOX_MESA)/src/compiler/nir \ + $(VBOX_MESA)/src/gallium/include \ + $(VBOX_MESA)/src/gallium/auxiliary \ + $(VBOX_MESA)/src/gallium/state_trackers/wgl +ifdef VBOX_WITH_NOCRT_STATIC + TEMPLATE_VBoxMesa3DGuestR3Lib_INCS += \ + $(TEMPLATE_VBoxMesa3DGuestR3Dll_INCS) +endif +ifdef VBOX_WITH_AUTOMATIC_DEFS_QUOTING + TEMPLATE_VBoxMesa3DGuestR3Lib_DEFS = \ + $(TEMPLATE_VBoxMesa3DGuestR3Dll_DEFS) \ + PACKAGE_VERSION="$(VBOX_MESA)" \ + PACKAGE_BUGREPORT="$(VBOX_MESA)" +else + TEMPLATE_VBoxMesa3DGuestR3Lib_DEFS = \ + $(TEMPLATE_VBoxMesa3DGuestR3Dll_DEFS) \ + PACKAGE_VERSION=\"$(VBOX_MESA)\" \ + PACKAGE_BUGREPORT=\"$(VBOX_MESA)\" +endif +# For wgl, glapi and mesa +TEMPLATE_VBoxMesa3DGuestR3Lib_DEFS += \ + MAPI_MODE_UTIL _GDI32_ BUILD_GL32 KHRONOS_DLL_EXPORTS GL_API=GLAPI GL_APIENTRY=GLAPIENTRY _GLAPI_NO_EXPORTS +TEMPLATE_VBoxMesa3DGuestR3Lib_DEFS.release = \ + $(TEMPLATE_VBoxMesa3DGuestR3Dll_DEFS.release) \ + NDEBUG + + +# +# VBoxMesaUtilLib +# +VBoxMesaUtilLib_TEMPLATE = VBoxMesa3DGuestR3Lib +VBoxMesaUtilLib_INCS = \ + $(VBoxMesaUtilLib_0_OUTDIR)/$(VBOX_MESA)/src \ + $(VBoxMesaUtilLib_0_OUTDIR)/$(VBOX_MESA)/src/util/format \ + $(VBOX_MESA)/src/util/format + +VBoxMesaUtilLib_DEPS = \ + $(VBoxMesaUtilLib_0_OUTDIR)/$(VBOX_MESA)/src/util/format/u_format_pack.h + +VBoxMesaUtilLib_SOURCES = \ + $(VBoxMesaUtilLib_0_OUTDIR)/$(VBOX_MESA)/src/util/format/u_format_pack.c \ + $(VBoxMesaUtilLib_0_OUTDIR)/$(VBOX_MESA)/src/util/format_srgb.c + +$$(VBoxMesaUtilLib_0_OUTDIR)/$(VBOX_MESA)/src/util/format/u_format_pack.c: \ + $(VBOX_PATH_MESA)/src/util/format/u_format_table.py \ + $(VBOX_PATH_MESA)/src/util/format/u_format.csv | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< $(VBOX_PATH_MESA)/src/util/format/u_format.csv >$@ + +$$(VBoxMesaUtilLib_0_OUTDIR)/$(VBOX_MESA)/src/util/format/u_format_pack.h: \ + $(VBOX_PATH_MESA)/src/util/format/u_format_table.py \ + $(VBOX_PATH_MESA)/src/util/format/u_format.csv | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< --header $(VBOX_PATH_MESA)/src/util/format/u_format.csv >$@ + +$$(VBoxMesaUtilLib_0_OUTDIR)/$(VBOX_MESA)/src/util/format_srgb.c: \ + $(VBOX_PATH_MESA)/src/util/format_srgb.py | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< >$@ + +VBoxMesaUtilLib_SOURCES += \ + $(VBOX_MESA)/src/util/anon_file.c \ + $(VBOX_MESA)/src/util/bitscan.c \ + $(VBOX_MESA)/src/util/blob.c \ + $(VBOX_MESA)/src/util/build_id.c \ + $(VBOX_MESA)/src/util/compress.c \ + $(VBOX_MESA)/src/util/crc32.c \ + $(VBOX_MESA)/src/util/dag.c \ + $(VBOX_MESA)/src/util/debug.c \ + $(VBOX_MESA)/src/util/disk_cache.c \ + $(VBOX_MESA)/src/util/disk_cache_os.c \ + $(VBOX_MESA)/src/util/double.c \ + $(VBOX_MESA)/src/util/fast_idiv_by_const.c \ + $(VBOX_MESA)/src/util/fossilize_db.c \ + $(VBOX_MESA)/src/util/half_float.c \ + $(VBOX_MESA)/src/util/hash_table.c \ + $(VBOX_MESA)/src/util/log.c \ + $(VBOX_MESA)/src/util/memstream.c \ + $(VBOX_MESA)/src/util/mesa-sha1.c \ + $(VBOX_MESA)/src/util/os_file.c \ + $(VBOX_MESA)/src/util/os_memory_fd.c \ + $(VBOX_MESA)/src/util/os_misc.c \ + $(VBOX_MESA)/src/util/os_socket.c \ + $(VBOX_MESA)/src/util/os_time.c \ + $(VBOX_MESA)/src/util/ralloc.c \ + $(VBOX_MESA)/src/util/rand_xor.c \ + $(VBOX_MESA)/src/util/rb_tree.c \ + $(VBOX_MESA)/src/util/register_allocate.c \ + $(VBOX_MESA)/src/util/rgtc.c \ + $(VBOX_MESA)/src/util/set.c \ + $(VBOX_MESA)/src/util/slab.c \ + $(VBOX_MESA)/src/util/softfloat.c \ + $(VBOX_MESA)/src/util/sparse_array.c \ + $(VBOX_MESA)/src/util/string_buffer.c \ + $(VBOX_MESA)/src/util/strtod.c \ + $(VBOX_MESA)/src/util/u_atomic.c \ + $(VBOX_MESA)/src/util/u_cpu_detect.c \ + $(VBOX_MESA)/src/util/u_debug.c \ + $(VBOX_MESA)/src/util/u_debug_describe.c \ + $(VBOX_MESA)/src/util/u_debug_memory.c \ + $(VBOX_MESA)/src/util/u_debug_refcnt.c \ + $(VBOX_MESA)/src/util/u_debug_stack.c \ + $(VBOX_MESA)/src/util/u_debug_symbol.c \ + $(VBOX_MESA)/src/util/u_hash_table.c \ + $(VBOX_MESA)/src/util/u_idalloc.c \ + $(VBOX_MESA)/src/util/u_math.c \ + $(VBOX_MESA)/src/util/u_mm.c \ + $(VBOX_MESA)/src/util/u_process.c \ + $(VBOX_MESA)/src/util/u_queue.c \ + $(VBOX_MESA)/src/util/u_vector.c \ + $(VBOX_MESA)/src/util/vma.c \ + $(VBOX_MESA)/src/util/format/u_format.c \ + $(VBOX_MESA)/src/util/format/u_format_bptc.c \ + $(VBOX_MESA)/src/util/format/u_format_etc.c \ + $(VBOX_MESA)/src/util/format/u_format_fxt1.c \ + $(VBOX_MESA)/src/util/format/u_format_latc.c \ + $(VBOX_MESA)/src/util/format/u_format_other.c \ + $(VBOX_MESA)/src/util/format/u_format_rgtc.c \ + $(VBOX_MESA)/src/util/format/u_format_s3tc.c \ + $(VBOX_MESA)/src/util/format/u_format_tests.c \ + $(VBOX_MESA)/src/util/format/u_format_unpack_neon.c \ + $(VBOX_MESA)/src/util/format/u_format_yuv.c \ + $(VBOX_MESA)/src/util/format/u_format_zs.c \ + $(VBOX_MESA)/src/util/u_printf.cpp \ + $(VBOX_MESA)/src/util/u_qsort.cpp \ + $(VBOX_MESA)/src/util/sha1/sha1.c + +# Unused +# $(VBOX_MESA)/src/util/xmlconfig.c + +# 32 bit lib for 64 bit build +VBoxMesaUtilLib-x86_EXTENDS = VBoxMesaUtilLib +VBoxMesaUtilLib-x86_BLD_TRG_ARCH = x86 + + +# +# VBoxMesaLib +# +VBoxMesaLib_TEMPLATE = VBoxMesa3DGuestR3Lib +VBoxMesaLib_INCS = \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/spirv \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mapi/glapi \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/program \ + $(VBOX_MESA)/src/compiler/glsl \ + $(VBOX_MESA)/src/compiler/glsl/glcpp \ + $(VBOX_MESA)/src/compiler/spirv + +VBoxMesaLib_DEPS = \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/ir_expression_operation.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/ir_expression_operation_strings.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/ir_expression_operation_constant.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl/float64_glsl.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl/glsl_parser.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl/glcpp/glcpp-parse.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_builder_opcodes.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_intrinsics.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_intrinsics_indices.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_opcodes.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/spirv/vtn_generator_ids.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mapi/glapi/glapitable.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mapi/glapi/glapitemp.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mapi/glapi/glprocs.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/dispatch.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/format_info.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/get_hash.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/remap_helper.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/program/program_parse.tab.h + +VBoxMesaLib_SOURCES = \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl/glsl_lexer.cpp \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl/glsl_parser.cpp \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl/glcpp/glcpp-lex.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl/glcpp/glcpp-parse.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_constant_expressions.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_intrinsics.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_opcodes.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_opt_algebraic.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/spirv/spirv_info.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/spirv/vtn_gather_types.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mapi/glapi/enums.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/api_exec.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/format_fallback.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated0.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated1.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated2.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated3.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated4.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated5.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated6.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated7.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/program/program_parse.tab.c \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/program/lex.yy.c + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_builder_opcodes.h: \ + $(VBOX_PATH_MESA)/src/compiler/nir/nir_builder_opcodes_h.py | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_constant_expressions.c: \ + $(VBOX_PATH_MESA)/src/compiler/nir/nir_constant_expressions.py | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_opcodes.h: \ + $(VBOX_PATH_MESA)/src/compiler/nir/nir_opcodes_h.py | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_opcodes.c: \ + $(VBOX_PATH_MESA)/src/compiler/nir/nir_opcodes_c.py | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_opt_algebraic.c: \ + $(VBOX_PATH_MESA)/src/compiler/nir/nir_opt_algebraic.py | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_intrinsics.h: \ + $(VBOX_PATH_MESA)/src/compiler/nir/nir_intrinsics_h.py | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< --outdir $(dir $@) + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_intrinsics_indices.h: \ + $(VBOX_PATH_MESA)/src/compiler/nir/nir_intrinsics_indices_h.py | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< --outdir $(dir $@) + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_intrinsics.c: \ + $(VBOX_PATH_MESA)/src/compiler/nir/nir_intrinsics_c.py | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< --outdir $(dir $@) + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/ir_expression_operation.h: \ + $(VBOX_PATH_MESA)/src/compiler/glsl/ir_expression_operation.py | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< enum >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/ir_expression_operation_strings.h: \ + $(VBOX_PATH_MESA)/src/compiler/glsl/ir_expression_operation.py | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< strings >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/ir_expression_operation_constant.h: \ + $(VBOX_PATH_MESA)/src/compiler/glsl/ir_expression_operation.py | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< constant >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/dispatch.h: \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_table.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -f $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml -m remap_table >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated.h: \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_marshal_h.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -f $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated0.c: \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_marshal.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -f $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml -i 0 -n 8 >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated1.c: \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_marshal.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -f $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml -i 1 -n 8 >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated2.c: \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_marshal.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -f $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml -i 2 -n 8 >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated3.c: \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_marshal.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -f $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml -i 3 -n 8 >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated4.c: \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_marshal.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -f $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml -i 4 -n 8 >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated5.c: \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_marshal.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -f $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml -i 5 -n 8 >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated6.c: \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_marshal.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -f $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml -i 6 -n 8 >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/marshal_generated7.c: \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_marshal.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -f $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml -i 7 -n 8 >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/api_exec.c: \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_genexec.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -f $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/format_info.h: \ + $(VBOX_PATH_MESA)/src/mesa/main/format_info.py \ + $(VBOX_PATH_MESA)/src/mesa/main/formats.csv | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< $(VBOX_PATH_MESA)/src/mesa/main/formats.csv >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/format_fallback.c: \ + $(VBOX_PATH_MESA)/src/mesa/main/format_fallback.py \ + $(VBOX_PATH_MESA)/src/mesa/main/formats.csv | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< $(VBOX_PATH_MESA)/src/mesa/main/formats.csv $@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/get_hash.h: \ + $(VBOX_PATH_MESA)/src/mesa/main/get_hash_generator.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -f $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/main/remap_helper.h: \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/remap_helper.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -f $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl/glsl_parser.cpp \ +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl/glsl_parser.h: \ + $(VBOX_PATH_MESA)/src/compiler/glsl/glsl_parser.yy | $$(dir $$@) + $(call MSG_GENERATE,bison,$@,$$@) + $(QUIET)$(TOOL_BISON_YACC) -o $@ -p _mesa_glsl_ --defines=$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl/glsl_parser.h $< + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl/glsl_lexer.cpp: \ + $(VBOX_PATH_MESA)/src/compiler/glsl/glsl_lexer.ll | $$(dir $$@) + $(call MSG_GENERATE,flex,$@,$$@) + $(QUIET)$(TOOL_FLEX_LEX) -o $@ $< + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl/glcpp/glcpp-parse.c \ +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl/glcpp/glcpp-parse.h: \ + $(VBOX_PATH_MESA)/src/compiler/glsl/glcpp/glcpp-parse.y | $$(dir $$@) + $(call MSG_GENERATE,bison,$@,$$@) + $(QUIET)$(TOOL_BISON_YACC) -o $@ -p glcpp_parser_ --defines=$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl/glcpp/glcpp-parse.h $< + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl/glcpp/glcpp-lex.c: \ + $(VBOX_PATH_MESA)/src/compiler/glsl/glcpp/glcpp-lex.l | $$(dir $$@) + $(call MSG_GENERATE,flex,$@,$$@) + $(QUIET)$(TOOL_FLEX_LEX) -o $@ $< + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/glsl/float64_glsl.h: \ + $(VBOX_PATH_MESA)/src/util/xxd.py \ + $(VBOX_PATH_MESA)/src/compiler/glsl/float64.glsl | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< $(VBOX_PATH_MESA)/src/compiler/glsl/float64.glsl $@ -n float64_source + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mapi/glapi/glapitemp.h: \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_apitemp.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -f $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mapi/glapi/glapitable.h: \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_table.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -f $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mapi/glapi/glprocs.h: \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_procs.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -c -f $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_and_es_API.xml >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mapi/glapi/enums.c: \ + $(VBOX_PATH_MESA)/src/mapi/glapi/gen/gl_enums.py \ + $(VBOX_PATH_MESA)/src/mapi/glapi/registry/gl.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< -f $(VBOX_PATH_MESA)/src/mapi/glapi/registry/gl.xml >$@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/spirv/spirv_info.c: \ + $(VBOX_PATH_MESA)/src/compiler/spirv/spirv_info_c.py \ + $(VBOX_PATH_MESA)/src/compiler/spirv/spirv.core.grammar.json | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< $(VBOX_PATH_MESA)/src/compiler/spirv/spirv.core.grammar.json $@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/spirv/vtn_gather_types.c: \ + $(VBOX_PATH_MESA)/src/compiler/spirv/vtn_gather_types_c.py \ + $(VBOX_PATH_MESA)/src/compiler/spirv/spirv.core.grammar.json | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< $(VBOX_PATH_MESA)/src/compiler/spirv/spirv.core.grammar.json $@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/spirv/vtn_generator_ids.h: \ + $(VBOX_PATH_MESA)/src/compiler/spirv/vtn_generator_ids_h.py \ + $(VBOX_PATH_MESA)/src/compiler/spirv/spir-v.xml | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< $(VBOX_PATH_MESA)/src/compiler/spirv/spir-v.xml $@ + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/program/program_parse.tab.c \ +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/program/program_parse.tab.h: \ + $(VBOX_PATH_MESA)/src/mesa/program/program_parse.y | $$(dir $$@) + $(call MSG_GENERATE,bison,$@,$$@) + $(QUIET)$(TOOL_BISON_YACC) -o $@ --defines=$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/program/program_parse.tab.h $< + +$$(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/mesa/program/lex.yy.c: \ + $(VBOX_PATH_MESA)/src/mesa/program/program_lexer.l | $$(dir $$@) + $(call MSG_GENERATE,flex,$@,$$@) + $(QUIET)$(TOOL_FLEX_LEX) -o $@ $< + +VBoxMesaLib_SOURCES += \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atifs_to_nir.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_array.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_atomicbuf.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_blend.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_clip.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_constbuf.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_depth.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_framebuffer.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_image.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_msaa.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_pixeltransfer.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_rasterizer.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_sampler.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_scissor.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_shader.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_stipple.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_storagebuf.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_tess.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_texture.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_atom_viewport.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_bitmap.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_bitmap_shader.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_blit.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_bufferobjects.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_clear.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_compute.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_condrender.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_copyimage.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_drawpixels.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_drawpixels_shader.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_drawtex.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_eglimage.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_fbo.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_feedback.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_flush.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_memoryobjects.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_msaa.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_perfmon.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_perfquery.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_program.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_queryobj.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_rasterpos.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_readpixels.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_semaphoreobjects.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_strings.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_syncobj.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_texture.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_texturebarrier.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_viewport.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_cb_xformfb.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_context.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_copytex.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_debug.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_draw.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_draw_feedback.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_extensions.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_format.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_gen_mipmap.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_glsl_to_ir.cpp \ + $(VBOX_MESA)/src/mesa/state_tracker/st_glsl_to_nir.cpp \ + $(VBOX_MESA)/src/mesa/state_tracker/st_glsl_to_tgsi.cpp \ + $(VBOX_MESA)/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp \ + $(VBOX_MESA)/src/mesa/state_tracker/st_glsl_to_tgsi_private.cpp \ + $(VBOX_MESA)/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp \ + $(VBOX_MESA)/src/mesa/state_tracker/st_manager.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_nir_builtins.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_nir_lower_builtin.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_nir_lower_tex_src_plane.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_pbo.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_program.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_sampler_view.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_scissor.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_shader_cache.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_texture.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_tgsi_lower_depth_clamp.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_tgsi_lower_yuv.c \ + $(VBOX_MESA)/src/mesa/state_tracker/st_vdpau.c +VBoxMesaLib_SOURCES += \ + $(VBOX_MESA)/src/mesa/program/arbprogparse.c \ + $(VBOX_MESA)/src/mesa/program/ir_to_mesa.cpp \ + $(VBOX_MESA)/src/mesa/program/prog_cache.c \ + $(VBOX_MESA)/src/mesa/program/prog_execute.c \ + $(VBOX_MESA)/src/mesa/program/prog_instruction.c \ + $(VBOX_MESA)/src/mesa/program/prog_noise.c \ + $(VBOX_MESA)/src/mesa/program/prog_opt_constant_fold.c \ + $(VBOX_MESA)/src/mesa/program/prog_optimize.c \ + $(VBOX_MESA)/src/mesa/program/prog_parameter.c \ + $(VBOX_MESA)/src/mesa/program/prog_parameter_layout.c \ + $(VBOX_MESA)/src/mesa/program/prog_print.c \ + $(VBOX_MESA)/src/mesa/program/prog_statevars.c \ + $(VBOX_MESA)/src/mesa/program/prog_to_nir.c \ + $(VBOX_MESA)/src/mesa/program/program.c \ + $(VBOX_MESA)/src/mesa/program/program_parse_extra.c \ + $(VBOX_MESA)/src/mesa/program/programopt.c \ + $(VBOX_MESA)/src/mesa/program/symbol_table.c +VBoxMesaLib_SOURCES += \ + $(VBOX_MESA)/src/mesa/main/accum.c \ + $(VBOX_MESA)/src/mesa/main/api_arrayelt.c \ + $(VBOX_MESA)/src/mesa/main/arbprogram.c \ + $(VBOX_MESA)/src/mesa/main/arrayobj.c \ + $(VBOX_MESA)/src/mesa/main/atifragshader.c \ + $(VBOX_MESA)/src/mesa/main/attrib.c \ + $(VBOX_MESA)/src/mesa/main/barrier.c \ + $(VBOX_MESA)/src/mesa/main/bbox.c \ + $(VBOX_MESA)/src/mesa/main/blend.c \ + $(VBOX_MESA)/src/mesa/main/blit.c \ + $(VBOX_MESA)/src/mesa/main/bufferobj.c \ + $(VBOX_MESA)/src/mesa/main/buffers.c \ + $(VBOX_MESA)/src/mesa/main/clear.c \ + $(VBOX_MESA)/src/mesa/main/clip.c \ + $(VBOX_MESA)/src/mesa/main/colortab.c \ + $(VBOX_MESA)/src/mesa/main/compute.c \ + $(VBOX_MESA)/src/mesa/main/condrender.c \ + $(VBOX_MESA)/src/mesa/main/conservativeraster.c \ + $(VBOX_MESA)/src/mesa/main/context.c \ + $(VBOX_MESA)/src/mesa/main/convolve.c \ + $(VBOX_MESA)/src/mesa/main/copyimage.c \ + $(VBOX_MESA)/src/mesa/main/cpuinfo.c \ + $(VBOX_MESA)/src/mesa/main/debug.c \ + $(VBOX_MESA)/src/mesa/main/debug_output.c \ + $(VBOX_MESA)/src/mesa/main/depth.c \ + $(VBOX_MESA)/src/mesa/main/dlist.c \ + $(VBOX_MESA)/src/mesa/main/draw.c \ + $(VBOX_MESA)/src/mesa/main/draw_validate.c \ + $(VBOX_MESA)/src/mesa/main/drawpix.c \ + $(VBOX_MESA)/src/mesa/main/drawtex.c \ + $(VBOX_MESA)/src/mesa/main/enable.c \ + $(VBOX_MESA)/src/mesa/main/errors.c \ + $(VBOX_MESA)/src/mesa/main/es1_conversion.c \ + $(VBOX_MESA)/src/mesa/main/eval.c \ + $(VBOX_MESA)/src/mesa/main/execmem.c \ + $(VBOX_MESA)/src/mesa/main/extensions.c \ + $(VBOX_MESA)/src/mesa/main/extensions_table.c \ + $(VBOX_MESA)/src/mesa/main/externalobjects.c \ + $(VBOX_MESA)/src/mesa/main/fbobject.c \ + $(VBOX_MESA)/src/mesa/main/feedback.c \ + $(VBOX_MESA)/src/mesa/main/ff_fragment_shader.cpp \ + $(VBOX_MESA)/src/mesa/main/ffvertex_prog.c \ + $(VBOX_MESA)/src/mesa/main/fog.c \ + $(VBOX_MESA)/src/mesa/main/format_utils.c \ + $(VBOX_MESA)/src/mesa/main/formatquery.c \ + $(VBOX_MESA)/src/mesa/main/formats.c \ + $(VBOX_MESA)/src/mesa/main/framebuffer.c \ + $(VBOX_MESA)/src/mesa/main/genmipmap.c \ + $(VBOX_MESA)/src/mesa/main/get.c \ + $(VBOX_MESA)/src/mesa/main/getstring.c \ + $(VBOX_MESA)/src/mesa/main/glformats.c \ + $(VBOX_MESA)/src/mesa/main/glspirv.c \ + $(VBOX_MESA)/src/mesa/main/glthread.c \ + $(VBOX_MESA)/src/mesa/main/glthread_bufferobj.c \ + $(VBOX_MESA)/src/mesa/main/glthread_draw.c \ + $(VBOX_MESA)/src/mesa/main/glthread_get.c \ + $(VBOX_MESA)/src/mesa/main/glthread_list.c \ + $(VBOX_MESA)/src/mesa/main/glthread_shaderobj.c \ + $(VBOX_MESA)/src/mesa/main/glthread_varray.c \ + $(VBOX_MESA)/src/mesa/main/hash.c \ + $(VBOX_MESA)/src/mesa/main/hint.c \ + $(VBOX_MESA)/src/mesa/main/histogram.c \ + $(VBOX_MESA)/src/mesa/main/image.c \ + $(VBOX_MESA)/src/mesa/main/light.c \ + $(VBOX_MESA)/src/mesa/main/lines.c \ + $(VBOX_MESA)/src/mesa/main/matrix.c \ + $(VBOX_MESA)/src/mesa/main/mipmap.c \ + $(VBOX_MESA)/src/mesa/main/multisample.c \ + $(VBOX_MESA)/src/mesa/main/objectlabel.c \ + $(VBOX_MESA)/src/mesa/main/objectpurge.c \ + $(VBOX_MESA)/src/mesa/main/pack.c \ + $(VBOX_MESA)/src/mesa/main/pbo.c \ + $(VBOX_MESA)/src/mesa/main/performance_monitor.c \ + $(VBOX_MESA)/src/mesa/main/performance_query.c \ + $(VBOX_MESA)/src/mesa/main/pipelineobj.c \ + $(VBOX_MESA)/src/mesa/main/pixel.c \ + $(VBOX_MESA)/src/mesa/main/pixelstore.c \ + $(VBOX_MESA)/src/mesa/main/pixeltransfer.c \ + $(VBOX_MESA)/src/mesa/main/points.c \ + $(VBOX_MESA)/src/mesa/main/polygon.c \ + $(VBOX_MESA)/src/mesa/main/program_binary.c \ + $(VBOX_MESA)/src/mesa/main/program_resource.c \ + $(VBOX_MESA)/src/mesa/main/querymatrix.c \ + $(VBOX_MESA)/src/mesa/main/queryobj.c \ + $(VBOX_MESA)/src/mesa/main/rastpos.c \ + $(VBOX_MESA)/src/mesa/main/readpix.c \ + $(VBOX_MESA)/src/mesa/main/remap.c \ + $(VBOX_MESA)/src/mesa/main/renderbuffer.c \ + $(VBOX_MESA)/src/mesa/main/robustness.c \ + $(VBOX_MESA)/src/mesa/main/samplerobj.c \ + $(VBOX_MESA)/src/mesa/main/scissor.c \ + $(VBOX_MESA)/src/mesa/main/shader_query.cpp \ + $(VBOX_MESA)/src/mesa/main/shaderapi.c \ + $(VBOX_MESA)/src/mesa/main/shaderimage.c \ + $(VBOX_MESA)/src/mesa/main/shaderobj.c \ + $(VBOX_MESA)/src/mesa/main/shared.c \ + $(VBOX_MESA)/src/mesa/main/spirv_extensions.c \ + $(VBOX_MESA)/src/mesa/main/state.c \ + $(VBOX_MESA)/src/mesa/main/stencil.c \ + $(VBOX_MESA)/src/mesa/main/streaming-load-memcpy.c \ + $(VBOX_MESA)/src/mesa/main/syncobj.c \ + $(VBOX_MESA)/src/mesa/main/texcompress.c \ + $(VBOX_MESA)/src/mesa/main/texcompress_astc.cpp \ + $(VBOX_MESA)/src/mesa/main/texcompress_bptc.c \ + $(VBOX_MESA)/src/mesa/main/texcompress_cpal.c \ + $(VBOX_MESA)/src/mesa/main/texcompress_etc.c \ + $(VBOX_MESA)/src/mesa/main/texcompress_fxt1.c \ + $(VBOX_MESA)/src/mesa/main/texcompress_rgtc.c \ + $(VBOX_MESA)/src/mesa/main/texcompress_s3tc.c \ + $(VBOX_MESA)/src/mesa/main/texenv.c \ + $(VBOX_MESA)/src/mesa/main/texformat.c \ + $(VBOX_MESA)/src/mesa/main/texgen.c \ + $(VBOX_MESA)/src/mesa/main/texgetimage.c \ + $(VBOX_MESA)/src/mesa/main/teximage.c \ + $(VBOX_MESA)/src/mesa/main/texobj.c \ + $(VBOX_MESA)/src/mesa/main/texparam.c \ + $(VBOX_MESA)/src/mesa/main/texstate.c \ + $(VBOX_MESA)/src/mesa/main/texstorage.c \ + $(VBOX_MESA)/src/mesa/main/texstore.c \ + $(VBOX_MESA)/src/mesa/main/texturebindless.c \ + $(VBOX_MESA)/src/mesa/main/textureview.c \ + $(VBOX_MESA)/src/mesa/main/transformfeedback.c \ + $(VBOX_MESA)/src/mesa/main/uniform_query.cpp \ + $(VBOX_MESA)/src/mesa/main/uniforms.c \ + $(VBOX_MESA)/src/mesa/main/varray.c \ + $(VBOX_MESA)/src/mesa/main/vdpau.c \ + $(VBOX_MESA)/src/mesa/main/version.c \ + $(VBOX_MESA)/src/mesa/main/viewport.c \ + $(VBOX_MESA)/src/mesa/main/vtxfmt.c +#VBoxMesaLib_SOURCES += \ + $(VBOX_MESA)/src/mesa/main/marshal_generated0.c \ + $(VBOX_MESA)/src/mesa/main/marshal_generated1.c \ + $(VBOX_MESA)/src/mesa/main/marshal_generated2.c \ + $(VBOX_MESA)/src/mesa/main/marshal_generated3.c \ + $(VBOX_MESA)/src/mesa/main/marshal_generated4.c \ + $(VBOX_MESA)/src/mesa/main/marshal_generated5.c \ + $(VBOX_MESA)/src/mesa/main/marshal_generated6.c \ + $(VBOX_MESA)/src/mesa/main/marshal_generated7.c +VBoxMesaLib_SOURCES += \ + $(VBOX_MESA)/src/mesa/math/m_debug_clip.c \ + $(VBOX_MESA)/src/mesa/math/m_debug_norm.c \ + $(VBOX_MESA)/src/mesa/math/m_debug_xform.c \ + $(VBOX_MESA)/src/mesa/math/m_eval.c \ + $(VBOX_MESA)/src/mesa/math/m_matrix.c \ + $(VBOX_MESA)/src/mesa/math/m_translate.c \ + $(VBOX_MESA)/src/mesa/math/m_vector.c \ + $(VBOX_MESA)/src/mesa/math/m_xform.c +VBoxMesaLib_SOURCES += \ + $(VBOX_MESA)/src/mesa/vbo/vbo_context.c \ + $(VBOX_MESA)/src/mesa/vbo/vbo_exec.c \ + $(VBOX_MESA)/src/mesa/vbo/vbo_exec_api.c \ + $(VBOX_MESA)/src/mesa/vbo/vbo_exec_draw.c \ + $(VBOX_MESA)/src/mesa/vbo/vbo_exec_eval.c \ + $(VBOX_MESA)/src/mesa/vbo/vbo_minmax_index.c \ + $(VBOX_MESA)/src/mesa/vbo/vbo_noop.c \ + $(VBOX_MESA)/src/mesa/vbo/vbo_save.c \ + $(VBOX_MESA)/src/mesa/vbo/vbo_save_api.c \ + $(VBOX_MESA)/src/mesa/vbo/vbo_save_draw.c \ + $(VBOX_MESA)/src/mesa/vbo/vbo_save_loopback.c +VBoxMesaLib_SOURCES += \ + $(VBOX_MESA)/src/compiler/glsl_types.cpp \ + $(VBOX_MESA)/src/compiler/nir_types.cpp \ + $(VBOX_MESA)/src/compiler/shader_enums.c +VBoxMesaLib_SOURCES += \ + $(VBOX_MESA)/src/compiler/glsl/ast_array_index.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ast_expr.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ast_function.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ast_to_hir.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ast_type.cpp \ + $(VBOX_MESA)/src/compiler/glsl/builtin_functions.cpp \ + $(VBOX_MESA)/src/compiler/glsl/builtin_types.cpp \ + $(VBOX_MESA)/src/compiler/glsl/builtin_variables.cpp \ + $(VBOX_MESA)/src/compiler/glsl/generate_ir.cpp \ + $(VBOX_MESA)/src/compiler/glsl/gl_nir_link_atomics.c \ + $(VBOX_MESA)/src/compiler/glsl/gl_nir_link_uniform_blocks.c \ + $(VBOX_MESA)/src/compiler/glsl/gl_nir_link_uniform_initializers.c \ + $(VBOX_MESA)/src/compiler/glsl/gl_nir_link_uniforms.c \ + $(VBOX_MESA)/src/compiler/glsl/gl_nir_link_xfb.c \ + $(VBOX_MESA)/src/compiler/glsl/gl_nir_linker.c \ + $(VBOX_MESA)/src/compiler/glsl/gl_nir_lower_atomics.c \ + $(VBOX_MESA)/src/compiler/glsl/gl_nir_lower_buffers.c \ + $(VBOX_MESA)/src/compiler/glsl/gl_nir_lower_images.c \ + $(VBOX_MESA)/src/compiler/glsl/gl_nir_lower_samplers.c \ + $(VBOX_MESA)/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c \ + $(VBOX_MESA)/src/compiler/glsl/glsl_parser_extras.cpp \ + $(VBOX_MESA)/src/compiler/glsl/glsl_symbol_table.cpp \ + $(VBOX_MESA)/src/compiler/glsl/glsl_to_nir.cpp \ + $(VBOX_MESA)/src/compiler/glsl/hir_field_selection.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_array_refcount.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_basic_block.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_builder.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_builder_print_visitor.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_clone.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_constant_expression.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_equals.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_expression_flattening.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_function.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_function_can_inline.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_function_detect_recursion.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_hierarchical_visitor.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_hv_accept.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_print_visitor.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_reader.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_rvalue_visitor.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_set_program_inouts.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_validate.cpp \ + $(VBOX_MESA)/src/compiler/glsl/ir_variable_refcount.cpp \ + $(VBOX_MESA)/src/compiler/glsl/link_atomics.cpp \ + $(VBOX_MESA)/src/compiler/glsl/link_functions.cpp \ + $(VBOX_MESA)/src/compiler/glsl/link_interface_blocks.cpp \ + $(VBOX_MESA)/src/compiler/glsl/link_uniform_block_active_visitor.cpp \ + $(VBOX_MESA)/src/compiler/glsl/link_uniform_blocks.cpp \ + $(VBOX_MESA)/src/compiler/glsl/link_uniform_initializers.cpp \ + $(VBOX_MESA)/src/compiler/glsl/link_uniforms.cpp \ + $(VBOX_MESA)/src/compiler/glsl/link_varyings.cpp \ + $(VBOX_MESA)/src/compiler/glsl/linker.cpp \ + $(VBOX_MESA)/src/compiler/glsl/linker_util.cpp \ + $(VBOX_MESA)/src/compiler/glsl/loop_analysis.cpp \ + $(VBOX_MESA)/src/compiler/glsl/loop_unroll.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_blend_equation_advanced.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_buffer_access.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_builtins.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_const_arrays_to_uniforms.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_cs_derived.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_discard.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_discard_flow.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_distance.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_if_to_cond_assign.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_instructions.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_int64.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_jumps.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_mat_op_to_vec.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_named_interface_blocks.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_offset_array.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_output_reads.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_packed_varyings.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_packing_builtins.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_precision.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_shared_reference.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_subroutine.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_tess_level.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_ubo_reference.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_variable_index_to_cond_assign.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_vec_index_to_cond_assign.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_vec_index_to_swizzle.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_vector.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_vector_derefs.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_vector_insert.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_vertex_id.cpp \ + $(VBOX_MESA)/src/compiler/glsl/lower_xfb_varying.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_algebraic.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_array_splitting.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_conditional_discard.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_constant_folding.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_constant_propagation.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_constant_variable.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_copy_propagation_elements.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_dead_builtin_variables.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_dead_builtin_varyings.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_dead_code.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_dead_code_local.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_dead_functions.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_flatten_nested_if_blocks.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_flip_matrices.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_function_inlining.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_if_simplification.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_minmax.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_rebalance_tree.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_redundant_jumps.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_structure_splitting.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_swizzle.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_tree_grafting.cpp \ + $(VBOX_MESA)/src/compiler/glsl/opt_vectorize.cpp \ + $(VBOX_MESA)/src/compiler/glsl/propagate_invariance.cpp \ + $(VBOX_MESA)/src/compiler/glsl/s_expression.cpp \ + $(VBOX_MESA)/src/compiler/glsl/serialize.cpp \ + $(VBOX_MESA)/src/compiler/glsl/shader_cache.cpp \ + $(VBOX_MESA)/src/compiler/glsl/string_to_uint_map.cpp \ + $(VBOX_MESA)/src/compiler/glsl/glcpp/pp.c +VBoxMesaLib_SOURCES += \ + $(VBOX_MESA)/src/compiler/nir/nir.c \ + $(VBOX_MESA)/src/compiler/nir/nir_builtin_builder.c \ + $(VBOX_MESA)/src/compiler/nir/nir_clone.c \ + $(VBOX_MESA)/src/compiler/nir/nir_control_flow.c \ + $(VBOX_MESA)/src/compiler/nir/nir_convert_ycbcr.c \ + $(VBOX_MESA)/src/compiler/nir/nir_deref.c \ + $(VBOX_MESA)/src/compiler/nir/nir_divergence_analysis.c \ + $(VBOX_MESA)/src/compiler/nir/nir_dominance.c \ + $(VBOX_MESA)/src/compiler/nir/nir_from_ssa.c \ + $(VBOX_MESA)/src/compiler/nir/nir_gather_info.c \ + $(VBOX_MESA)/src/compiler/nir/nir_gather_ssa_types.c \ + $(VBOX_MESA)/src/compiler/nir/nir_gather_xfb_info.c \ + $(VBOX_MESA)/src/compiler/nir/nir_gs_count_vertices.c \ + $(VBOX_MESA)/src/compiler/nir/nir_inline_functions.c \ + $(VBOX_MESA)/src/compiler/nir/nir_inline_uniforms.c \ + $(VBOX_MESA)/src/compiler/nir/nir_instr_set.c \ + $(VBOX_MESA)/src/compiler/nir/nir_linking_helpers.c \ + $(VBOX_MESA)/src/compiler/nir/nir_liveness.c \ + $(VBOX_MESA)/src/compiler/nir/nir_loop_analyze.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_alpha_test.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_alu.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_alu_to_scalar.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_amul.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_array_deref_of_vec.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_atomics_to_ssbo.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_bit_size.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_bitmap.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_blend.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_bool_to_bitsize.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_bool_to_float.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_bool_to_int32.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_clamp_color_outputs.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_clip.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_clip_cull_distance_arrays.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_clip_disable.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_clip_halfz.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_convert_alu_types.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_discard_or_demote.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_double_ops.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_drawpixels.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_fb_read.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_flatshade.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_flrp.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_fp16_conv.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_fragcolor.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_fragcoord_wtrans.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_frexp.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_global_vars_to_local.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_goto_ifs.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_gs_intrinsics.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_idiv.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_image.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_indirect_derefs.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_input_attachments.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_int_to_float.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_int64.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_interpolation.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_io.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_io_arrays_to_elements.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_io_to_scalar.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_io_to_temporaries.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_io_to_vector.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_is_helper_invocation.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_load_const_to_scalar.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_locals_to_regs.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_mediump.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_memcpy.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_memory_model.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_multiview.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_non_uniform_access.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_packing.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_passthrough_edgeflags.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_patch_vertices.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_phis_to_scalar.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_pntc_ytransform.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_point_size.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_point_size_mov.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_printf.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_readonly_images_to_tex.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_regs_to_ssa.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_returns.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_samplers.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_scratch.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_shader_calls.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_ssbo.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_subgroups.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_system_values.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_sysvals_to_varyings.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_tex.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_texcoord_replace.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_to_source_mods.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_two_sided_color.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_ubo_vec4.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_undef_to_zero.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_uniforms_to_ubo.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_var_copies.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_variable_initializers.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_vars_to_ssa.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_vec_to_movs.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_vec3_to_vec4.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_viewport_transform.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_wpos_center.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_wpos_ytransform.c \ + $(VBOX_MESA)/src/compiler/nir/nir_lower_wrmasks.c \ + $(VBOX_MESA)/src/compiler/nir/nir_metadata.c \ + $(VBOX_MESA)/src/compiler/nir/nir_move_vec_src_uses_to_dest.c \ + $(VBOX_MESA)/src/compiler/nir/nir_normalize_cubemap_coords.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_access.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_barriers.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_combine_stores.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_comparison_pre.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_conditional_discard.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_constant_folding.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_copy_prop_vars.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_copy_propagate.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_cse.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_dce.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_dead_cf.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_dead_write_vars.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_find_array_copies.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_fragdepth.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_gcm.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_idiv_const.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_if.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_intrinsics.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_large_constants.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_load_store_vectorize.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_loop_unroll.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_memcpy.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_move.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_move_discards_to_top.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_offsets.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_peephole_select.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_phi_precision.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_rematerialize_compares.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_remove_phis.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_shrink_vectors.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_sink.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_trivial_continues.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_undef.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_uniform_atomics.c \ + $(VBOX_MESA)/src/compiler/nir/nir_opt_vectorize.c \ + $(VBOX_MESA)/src/compiler/nir/nir_phi_builder.c \ + $(VBOX_MESA)/src/compiler/nir/nir_print.c \ + $(VBOX_MESA)/src/compiler/nir/nir_propagate_invariant.c \ + $(VBOX_MESA)/src/compiler/nir/nir_range_analysis.c \ + $(VBOX_MESA)/src/compiler/nir/nir_remove_dead_variables.c \ + $(VBOX_MESA)/src/compiler/nir/nir_repair_ssa.c \ + $(VBOX_MESA)/src/compiler/nir/nir_schedule.c \ + $(VBOX_MESA)/src/compiler/nir/nir_search.c \ + $(VBOX_MESA)/src/compiler/nir/nir_serialize.c \ + $(VBOX_MESA)/src/compiler/nir/nir_split_per_member_structs.c \ + $(VBOX_MESA)/src/compiler/nir/nir_split_var_copies.c \ + $(VBOX_MESA)/src/compiler/nir/nir_split_vars.c \ + $(VBOX_MESA)/src/compiler/nir/nir_sweep.c \ + $(VBOX_MESA)/src/compiler/nir/nir_to_lcssa.c \ + $(VBOX_MESA)/src/compiler/nir/nir_validate.c \ + $(VBOX_MESA)/src/compiler/nir/nir_worklist.c +VBoxMesaLib_SOURCES += \ + $(VBOX_MESA)/src/compiler/spirv/gl_spirv.c \ + $(VBOX_MESA)/src/compiler/spirv/nir_load_libclc.c \ + $(VBOX_MESA)/src/compiler/spirv/nir_lower_libclc.c \ + $(VBOX_MESA)/src/compiler/spirv/spirv_to_nir.c \ + $(VBOX_MESA)/src/compiler/spirv/vtn_alu.c \ + $(VBOX_MESA)/src/compiler/spirv/vtn_amd.c \ + $(VBOX_MESA)/src/compiler/spirv/vtn_cfg.c \ + $(VBOX_MESA)/src/compiler/spirv/vtn_glsl450.c \ + $(VBOX_MESA)/src/compiler/spirv/vtn_opencl.c \ + $(VBOX_MESA)/src/compiler/spirv/vtn_subgroup.c \ + $(VBOX_MESA)/src/compiler/spirv/vtn_variables.c +VBoxMesaLib_SOURCES += \ + $(VBOX_MESA)/src/mapi/glapi/glapi.c \ + $(VBOX_MESA)/src/mapi/glapi/glapi_dispatch.c \ + $(VBOX_MESA)/src/mapi/glapi/glapi_entrypoint.c \ + $(VBOX_MESA)/src/mapi/glapi/glapi_getproc.c \ + $(VBOX_MESA)/src/mapi/glapi/glapi_nop.c \ + $(VBOX_MESA)/src/mapi/u_current.c \ + $(VBOX_MESA)/src/mapi/u_execmem.c + +# 32 bit lib for 64 bit build +VBoxMesaLib-x86_EXTENDS = VBoxMesaLib +VBoxMesaLib-x86_BLD_TRG_ARCH = x86 + + +# +# VBoxMesaWglLib +# +VBoxMesaWglLib_TEMPLATE = VBoxMesa3DGuestR3Lib +VBoxMesaWglLib_INCS = \ + $(VBOX_MESA)/src/gallium/frontends/wgl +VBoxMesaWglLib_SOURCES = \ + $(VBOX_MESA)/src/gallium/frontends/wgl/stw_context.c \ + $(VBOX_MESA)/src/gallium/frontends/wgl/stw_device.c \ + $(VBOX_MESA)/src/gallium/frontends/wgl/stw_ext_context.c \ + $(VBOX_MESA)/src/gallium/frontends/wgl/stw_ext_extensionsstring.c \ + $(VBOX_MESA)/src/gallium/frontends/wgl/stw_ext_pbuffer.c \ + $(VBOX_MESA)/src/gallium/frontends/wgl/stw_ext_pixelformat.c \ + $(VBOX_MESA)/src/gallium/frontends/wgl/stw_ext_rendertexture.c \ + $(VBOX_MESA)/src/gallium/frontends/wgl/stw_ext_swapinterval.c \ + $(VBOX_MESA)/src/gallium/frontends/wgl/stw_framebuffer.c \ + $(VBOX_MESA)/src/gallium/frontends/wgl/stw_getprocaddress.c \ + $(VBOX_MESA)/src/gallium/frontends/wgl/stw_nopfuncs.c \ + $(VBOX_MESA)/src/gallium/frontends/wgl/stw_pixelformat.c \ + $(VBOX_MESA)/src/gallium/frontends/wgl/stw_st.c \ + $(VBOX_MESA)/src/gallium/frontends/wgl/stw_tls.c +VBoxMesaWglLib_SOURCES += \ + $(VBOX_MESA)/src/gallium/targets/libgl-gdi/stw_wgl.c + +# 32 bit lib for 64 bit build +VBoxMesaWglLib-x86_EXTENDS = VBoxMesaWglLib +VBoxMesaWglLib-x86_BLD_TRG_ARCH = x86 + + +# +# VBoxMesaGalliumAuxLib +# +VBoxMesaGalliumAuxLib_TEMPLATE = VBoxMesa3DGuestR3Lib +VBoxMesaGalliumAuxLib_INCS = \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir +VBoxMesaGalliumAuxLib_DEPS = \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_builder_opcodes.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_intrinsics.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_intrinsics_indices.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_opcodes.h + +# Auto-generated +VBoxMesaGalliumAuxLib_SOURCES = \ + $(VBoxMesaGalliumAuxLib_0_OUTDIR)/$(VBOX_MESA)/src/gallium/auxiliary/indices/u_indices_gen.c \ + $(VBoxMesaGalliumAuxLib_0_OUTDIR)/$(VBOX_MESA)/src/gallium/auxiliary/indices/u_unfilled_gen.c + +$$(VBoxMesaGalliumAuxLib_0_OUTDIR)/$(VBOX_MESA)/src/gallium/auxiliary/indices/u_indices_gen.c: \ + $(VBOX_PATH_MESA)/src/gallium/auxiliary/indices/u_indices_gen.py | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< >$@ + +$$(VBoxMesaGalliumAuxLib_0_OUTDIR)/$(VBOX_MESA)/src/gallium/auxiliary/indices/u_unfilled_gen.c: \ + $(VBOX_PATH_MESA)/src/gallium/auxiliary/indices/u_unfilled_gen.py | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$$@) + $(QUIET)$(PYTHON_CMD) $< >$@ + +VBoxMesaGalliumAuxLib_SOURCES += \ + $(VBOX_MESA)/src/gallium/auxiliary/cso_cache/cso_cache.c \ + $(VBOX_MESA)/src/gallium/auxiliary/cso_cache/cso_context.c \ + $(VBOX_MESA)/src/gallium/auxiliary/cso_cache/cso_hash.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_context.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_fs.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_gs.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe_aaline.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe_aapoint.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe_clip.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe_cull.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe_flatshade.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe_offset.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe_pstipple.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe_stipple.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe_twoside.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe_unfilled.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe_user_cull.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe_util.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe_validate.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe_vbuf.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe_wide_line.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pipe_wide_point.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_prim_assembler.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pt.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pt_emit.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pt_fetch.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pt_post_vs.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pt_so_emit.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pt_util.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_pt_vsplit.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_tess.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_vertex.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_vs.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_vs_exec.c \ + $(VBOX_MESA)/src/gallium/auxiliary/draw/draw_vs_variant.c \ + $(VBOX_MESA)/src/gallium/auxiliary/driver_ddebug/dd_context.c \ + $(VBOX_MESA)/src/gallium/auxiliary/driver_ddebug/dd_draw.c \ + $(VBOX_MESA)/src/gallium/auxiliary/driver_ddebug/dd_screen.c \ + $(VBOX_MESA)/src/gallium/auxiliary/driver_noop/noop_pipe.c \ + $(VBOX_MESA)/src/gallium/auxiliary/driver_noop/noop_state.c \ + $(VBOX_MESA)/src/gallium/auxiliary/driver_rbug/rbug_context.c \ + $(VBOX_MESA)/src/gallium/auxiliary/driver_rbug/rbug_core.c \ + $(VBOX_MESA)/src/gallium/auxiliary/driver_rbug/rbug_objects.c \ + $(VBOX_MESA)/src/gallium/auxiliary/driver_rbug/rbug_screen.c \ + $(VBOX_MESA)/src/gallium/auxiliary/driver_trace/tr_context.c \ + $(VBOX_MESA)/src/gallium/auxiliary/driver_trace/tr_dump.c \ + $(VBOX_MESA)/src/gallium/auxiliary/driver_trace/tr_dump_state.c \ + $(VBOX_MESA)/src/gallium/auxiliary/driver_trace/tr_screen.c \ + $(VBOX_MESA)/src/gallium/auxiliary/driver_trace/tr_texture.c \ + $(VBOX_MESA)/src/gallium/auxiliary/hud/font.c \ + $(VBOX_MESA)/src/gallium/auxiliary/hud/hud_context.c \ + $(VBOX_MESA)/src/gallium/auxiliary/hud/hud_cpu.c \ + $(VBOX_MESA)/src/gallium/auxiliary/hud/hud_nic.c \ + $(VBOX_MESA)/src/gallium/auxiliary/hud/hud_cpufreq.c \ + $(VBOX_MESA)/src/gallium/auxiliary/hud/hud_diskstat.c \ + $(VBOX_MESA)/src/gallium/auxiliary/hud/hud_sensors_temp.c \ + $(VBOX_MESA)/src/gallium/auxiliary/hud/hud_driver_query.c \ + $(VBOX_MESA)/src/gallium/auxiliary/hud/hud_fps.c \ + $(VBOX_MESA)/src/gallium/auxiliary/indices/u_primconvert.c \ + $(VBOX_MESA)/src/gallium/auxiliary/os/os_process.c \ + $(VBOX_MESA)/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c \ + $(VBOX_MESA)/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c \ + $(VBOX_MESA)/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c \ + $(VBOX_MESA)/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c \ + $(VBOX_MESA)/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c \ + $(VBOX_MESA)/src/gallium/auxiliary/pipebuffer/pb_cache.c \ + $(VBOX_MESA)/src/gallium/auxiliary/pipebuffer/pb_slab.c \ + $(VBOX_MESA)/src/gallium/auxiliary/pipebuffer/pb_validate.c \ + $(VBOX_MESA)/src/gallium/auxiliary/postprocess/pp_celshade.c \ + $(VBOX_MESA)/src/gallium/auxiliary/postprocess/pp_colors.c \ + $(VBOX_MESA)/src/gallium/auxiliary/postprocess/pp_init.c \ + $(VBOX_MESA)/src/gallium/auxiliary/postprocess/pp_mlaa.c \ + $(VBOX_MESA)/src/gallium/auxiliary/postprocess/pp_program.c \ + $(VBOX_MESA)/src/gallium/auxiliary/postprocess/pp_run.c \ + $(VBOX_MESA)/src/gallium/auxiliary/rbug/rbug_connection.c \ + $(VBOX_MESA)/src/gallium/auxiliary/rbug/rbug_context.c \ + $(VBOX_MESA)/src/gallium/auxiliary/rbug/rbug_core.c \ + $(VBOX_MESA)/src/gallium/auxiliary/rbug/rbug_demarshal.c \ + $(VBOX_MESA)/src/gallium/auxiliary/rbug/rbug_shader.c \ + $(VBOX_MESA)/src/gallium/auxiliary/rbug/rbug_texture.c \ + $(VBOX_MESA)/src/gallium/auxiliary/rtasm/rtasm_cpu.c \ + $(VBOX_MESA)/src/gallium/auxiliary/rtasm/rtasm_execmem.c \ + $(VBOX_MESA)/src/gallium/auxiliary/rtasm/rtasm_x86sse.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_aa_point.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_build.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_dump.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_dynamic_indexing.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_exec.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_emulate.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_from_mesa.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_info.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_iterate.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_lowering.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_parse.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_point_sprite.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_sanity.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_scan.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_strings.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_text.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_transform.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_two_side.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_ureg.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_util.c \ + $(VBOX_MESA)/src/gallium/auxiliary/tgsi/tgsi_vpos.c \ + $(VBOX_MESA)/src/gallium/auxiliary/translate/translate.c \ + $(VBOX_MESA)/src/gallium/auxiliary/translate/translate_cache.c \ + $(VBOX_MESA)/src/gallium/auxiliary/translate/translate_generic.c \ + $(VBOX_MESA)/src/gallium/auxiliary/translate/translate_sse.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_async_debug.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_bitmask.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_blitter.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_cache.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_compute.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_debug_flush.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_debug_image.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_dl.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_draw.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_draw_quad.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_driconf.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_dump_defines.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_dump_state.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_framebuffer.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_gen_mipmap.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_handle_table.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_helpers.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_index_modify.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_linear.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_live_shader_cache.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_log.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_network.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_prim.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_prim_restart.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_pstipple.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_resource.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_sampler.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_screen.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_simple_shaders.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_split_draw.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_suballoc.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_surface.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_tests.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_texture.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_tile.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_transfer.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_transfer_helper.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_threaded_context.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_upload_mgr.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_vbuf.c \ + $(VBOX_MESA)/src/gallium/auxiliary/util/u_vertex_state_cache.c \ + $(VBOX_MESA)/src/gallium/auxiliary/nir/tgsi_to_nir.c \ + $(VBOX_MESA)/src/gallium/auxiliary/nir/nir_to_tgsi.c \ + $(VBOX_MESA)/src/gallium/auxiliary/nir/nir_draw_helpers.c + +# 32 bit lib for 64 bit build +VBoxMesaGalliumAuxLib-x86_EXTENDS = VBoxMesaGalliumAuxLib +VBoxMesaGalliumAuxLib-x86_BLD_TRG_ARCH = x86 + + +# +# VBoxMesaNineLib +# +VBoxMesaNineLib_TEMPLATE = VBoxMesa3DGuestR3Lib +VBoxMesaNineLib_INCS = \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir \ + $(VBOX_MESA)/include/D3D9 +VBoxMesaNineLib_DEPS = \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_builder_opcodes.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_intrinsics.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_intrinsics_indices.h \ + $(VBoxMesaLib_0_OUTDIR)/$(VBOX_MESA)/src/compiler/nir/nir_opcodes.h +VBoxMesaNineLib_DEFS.win = COBJMACROS INC_OLE2 +# -wd4028: formal parameter 4 different from declaration +# 'nine_context_set_vertex_shader_constant_f' parameter is declared 'const unsigned pConstantData_size' +# but autogenerated code produces 'unsigned pConstantData_size'. +VBoxMesaNineLib_CFLAGS.win = -wd4028 +VBoxMesaNineLib_SOURCES = \ + $(VBOX_MESA)/src/gallium/frontends/nine/adapter9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/authenticatedchannel9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/basetexture9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/buffer9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/cryptosession9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/cubetexture9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/device9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/device9ex.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/device9video.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/guid.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/indexbuffer9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/iunknown.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/nine_buffer_upload.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/nine_debug.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/nine_dump.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/nine_ff.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/nine_helpers.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/nine_lock.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/nine_pipe.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/nine_queue.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/nine_quirk.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/nine_shader.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/nine_state.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/nineexoverlayextension.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/pixelshader9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/query9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/resource9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/stateblock9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/surface9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/swapchain9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/swapchain9ex.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/texture9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/threadpool.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/vertexbuffer9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/vertexdeclaration9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/vertexshader9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/volume9.c \ + $(VBOX_MESA)/src/gallium/frontends/nine/volumetexture9.c + +# 32 bit lib for 64 bit build +VBoxMesaNineLib-x86_EXTENDS = VBoxMesaNineLib +VBoxMesaNineLib-x86_BLD_TRG_ARCH = x86 + + +# +# VBoxMesaSVGALib +# +VBoxMesaSVGALib_TEMPLATE = VBoxMesa3DGuestR3Lib +VBoxMesaSVGALib_INCS = \ + $(VBOX_MESA)/src/gallium/drivers/svga/include +VBoxMesaSVGALib_SOURCES = \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_cmd.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_cmd_vgpu10.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_context.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_draw.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_draw_arrays.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_draw_elements.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_format.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_link.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_blend.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_blit.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_clear.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_constants.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_depthstencil.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_draw.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_flush.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_fs.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_gs.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_misc.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_query.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_rasterizer.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_sampler.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_streamout.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_ts.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_vertex.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_pipe_vs.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_resource.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_resource_buffer.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_resource_buffer_upload.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_resource_texture.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_sampler_view.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_screen.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_screen_cache.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_shader.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_state.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_state_constants.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_state_framebuffer.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_state_fs.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_state_gs.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_state_need_swtnl.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_state_rss.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_state_sampler.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_state_tgsi_transform.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_state_ts.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_state_tss.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_state_vdecl.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_state_vs.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_surface.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_swtnl_backend.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_swtnl_draw.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_swtnl_state.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_tgsi.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_tgsi_insn.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svga_tgsi_vgpu10.c + +VBoxMesaSVGALib_SOURCES.debug += \ + $(VBOX_MESA)/src/gallium/drivers/svga/svgadump/svga_dump.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svgadump/svga_shader_dump.c \ + $(VBOX_MESA)/src/gallium/drivers/svga/svgadump/svga_shader_op.c + +# 32 bit lib for 64 bit build +VBoxMesaSVGALib-x86_EXTENDS = VBoxMesaSVGALib +VBoxMesaSVGALib-x86_BLD_TRG_ARCH = x86 + + +# +# VBoxMesaSVGAWinsysLib +# +VBoxMesaSVGAWinsysLib_TEMPLATE = VBoxMesa3DGuestR3Lib +VBoxMesaSVGAWinsysLib_INCS += \ + $(VBOX_MESA)/src/gallium/drivers/svga/include \ + $(VBOX_MESA)/src/gallium/drivers/svga +VBoxMesaSVGAWinsysLib_SOURCES = \ + $(VBOX_MESA)/src/gallium/winsys/svga/drm/pb_buffer_simple_fenced.c \ + $(VBOX_MESA)/src/gallium/winsys/svga/drm/vmw_buffer.c \ + $(VBOX_MESA)/src/gallium/winsys/svga/drm/vmw_context.c \ + $(VBOX_MESA)/src/gallium/winsys/svga/drm/vmw_fence.c \ + $(VBOX_MESA)/src/gallium/winsys/svga/drm/vmw_query.c \ + $(VBOX_MESA)/src/gallium/winsys/svga/drm/vmw_screen_pools.c \ + $(VBOX_MESA)/src/gallium/winsys/svga/drm/vmw_screen_svga.c \ + $(VBOX_MESA)/src/gallium/winsys/svga/drm/vmw_shader.c \ + $(VBOX_MESA)/src/gallium/winsys/svga/drm/vmw_surface.c + +# These will be reimplemented for WDDM +# $(VBOX_MESA)/src/gallium/winsys/svga/drm/vmw_screen.c +# $(VBOX_MESA)/src/gallium/winsys/svga/drm/vmw_screen_dri.c +# $(VBOX_MESA)/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c + +# 32 bit lib for 64 bit build +VBoxMesaSVGAWinsysLib-x86_EXTENDS = VBoxMesaSVGAWinsysLib +VBoxMesaSVGAWinsysLib-x86_BLD_TRG_ARCH = x86 + + +include $(FILE_KBUILD_SUB_FOOTER) + diff --git a/src/VBox/Additions/3D/mesa/include/assert.h b/src/VBox/Additions/3D/mesa/include/assert.h new file mode 100644 index 00000000..fc9b0c81 --- /dev/null +++ b/src/VBox/Additions/3D/mesa/include/assert.h @@ -0,0 +1,47 @@ +/* $Id: assert.h $ */ +/** @file + * Replaces C runtime assert with a simplified version which just hits breakpoint. + * + * Mesa code uses assert.h a lot, which is inconvenient because the C runtime + * implementation wants to open a message box and it does not work in the + * graphics driver. + */ + +/* + * Copyright (C) 2017-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#ifndef GA_INCLUDED_3D_MESA_assert_h +#define GA_INCLUDED_3D_MESA_assert_h +#ifndef RT_WITHOUT_PRAGMA_ONCE +# pragma once +#endif + +#include <iprt/asm.h> + +#undef assert +#ifdef DEBUG +#define assert(_e) (void)( (!!(_e)) || (ASMBreakpoint(), 0) ) +#else +#define assert(_e) (void)(0) +#endif + +#endif /* !GA_INCLUDED_3D_MESA_assert_h */ diff --git a/src/VBox/Additions/3D/mesa/include/git_sha1.h b/src/VBox/Additions/3D/mesa/include/git_sha1.h new file mode 100644 index 00000000..fdfb99b3 --- /dev/null +++ b/src/VBox/Additions/3D/mesa/include/git_sha1.h @@ -0,0 +1,38 @@ +/* $Id: git_sha1.h $ */ +/** @file + * Provides this include file for Mesa. + * + * Mesa code does not check MESA_GIT_SHA1 define before including the file. + */ + +/* + * Copyright (C) 2018-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#ifndef GA_INCLUDED_3D_MESA_git_sha1_h +#define GA_INCLUDED_3D_MESA_git_sha1_h +#ifndef RT_WITHOUT_PRAGMA_ONCE +# pragma once +#endif + +#define MESA_GIT_SHA1 "" + +#endif /* !GA_INCLUDED_3D_MESA_git_sha1_h */ diff --git a/src/VBox/Additions/3D/win/Makefile.kmk b/src/VBox/Additions/3D/win/Makefile.kmk new file mode 100644 index 00000000..23a82fc6 --- /dev/null +++ b/src/VBox/Additions/3D/win/Makefile.kmk @@ -0,0 +1,37 @@ +# $Id: Makefile.kmk $ +## @file +# Sub-Makefile for the Windows guest components using Mesa3D. +# + +# +# Copyright (C) 2016-2023 Oracle and/or its affiliates. +# +# This file is part of VirtualBox base platform packages, as +# available from https://www.virtualbox.org. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, in version 3 of the +# License. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see <https://www.gnu.org/licenses>. +# +# SPDX-License-Identifier: GPL-3.0-only +# + +SUB_DEPTH = ../../../../.. +include $(KBUILD_PATH)/subheader.kmk + +# Include sub-makefile. +include $(PATH_SUB_CURRENT)/VBoxGL/Makefile.kmk +include $(PATH_SUB_CURRENT)/VBoxNine/Makefile.kmk +include $(PATH_SUB_CURRENT)/VBoxSVGA/Makefile.kmk + +include $(FILE_KBUILD_SUB_FOOTER) + diff --git a/src/VBox/Additions/3D/win/VBoxGL/GaDrvEnvKMT.cpp b/src/VBox/Additions/3D/win/VBoxGL/GaDrvEnvKMT.cpp new file mode 100644 index 00000000..39da970c --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxGL/GaDrvEnvKMT.cpp @@ -0,0 +1,1396 @@ +/* $Id: GaDrvEnvKMT.cpp $ */ +/** @file + * VirtualBox Windows Guest Mesa3D - Gallium driver interface to the WDDM miniport driver using Kernel Mode Thunks. + */ + +/* + * Copyright (C) 2016-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#include "GaDrvEnvKMT.h" + +#include <UmHlpInternal.h> + +#include "svga3d_reg.h" + +#include <common/wddm/VBoxMPIf.h> + +#include <iprt/assertcompile.h> +#include <iprt/param.h> /* For PAGE_SIZE */ + +AssertCompile(sizeof(HANDLE) >= sizeof(D3DKMT_HANDLE)); + + +/* + * AVL configuration. + */ +#define KAVL_FN(a) RTAvlU32##a +#define KAVL_MAX_STACK 27 /* Up to 2^24 nodes. */ +#define KAVL_CHECK_FOR_EQUAL_INSERT 1 /* No duplicate keys! */ +#define KAVLNODECORE AVLU32NODECORE +#define PKAVLNODECORE PAVLU32NODECORE +#define PPKAVLNODECORE PPAVLU32NODECORE +#define KAVLKEY AVLU32KEY +#define PKAVLKEY PAVLU32KEY +#define KAVLENUMDATA AVLU32ENUMDATA +#define PKAVLENUMDATA PAVLU32ENUMDATA +#define PKAVLCALLBACK PAVLU32CALLBACK + + +/* + * AVL Compare macros + */ +#define KAVL_G(key1, key2) ( (key1) > (key2) ) +#define KAVL_E(key1, key2) ( (key1) == (key2) ) +#define KAVL_NE(key1, key2) ( (key1) != (key2) ) + + +#include <iprt/avl.h> + +/* + * Include the code. + */ +#define SSToDS(ptr) ptr +#define KMAX RT_MAX +#define kASSERT(_e) do { } while (0) +#include "avl_Base.cpp.h" +#include "avl_Get.cpp.h" +//#include "avl_GetBestFit.cpp.h" +//#include "avl_RemoveBestFit.cpp.h" +//#include "avl_DoWithAll.cpp.h" +#include "avl_Destroy.cpp.h" + + +typedef struct GaKmtCallbacks +{ + D3DKMT_HANDLE hAdapter; + D3DKMT_HANDLE hDevice; + D3DKMTFUNCTIONS const *d3dkmt; + LUID AdapterLuid; +} GaKmtCallbacks; + +class GaDrvEnvKmt +{ + public: + GaDrvEnvKmt(); + ~GaDrvEnvKmt(); + + HRESULT Init(void); + + const WDDMGalliumDriverEnv *Env(); + + /* + * KMT specific helpers. + */ + bool drvEnvKmtRenderCompose(uint32_t u32Cid, + void *pvCommands, + uint32_t cbCommands, + ULONGLONG PresentHistoryToken); + D3DKMT_HANDLE drvEnvKmtContextHandle(uint32_t u32Cid); + D3DKMT_HANDLE drvEnvKmtSurfaceHandle(uint32_t u32Sid); + + GaKmtCallbacks mKmtCallbacks; + + private: + + VBOXGAHWINFO mHWInfo; + + /* Map to convert context id (cid) to WDDM context information (GAWDDMCONTEXTINFO). + * Key is the 32 bit context id. + */ + AVLU32TREE mContextTree; + + /* Map to convert surface id (sid) to WDDM surface information (GAWDDMSURFACEINFO). + * Key is the 32 bit surface id. + */ + AVLU32TREE mSurfaceTree; + + WDDMGalliumDriverEnv mEnv; + + static DECLCALLBACK(uint32_t) gaEnvContextCreate(void *pvEnv, + boolean extended, + boolean vgpu10); + static DECLCALLBACK(void) gaEnvContextDestroy(void *pvEnv, + uint32_t u32Cid); + static DECLCALLBACK(int) gaEnvSurfaceDefine(void *pvEnv, + GASURFCREATE *pCreateParms, + GASURFSIZE *paSizes, + uint32_t cSizes, + uint32_t *pu32Sid); + static DECLCALLBACK(void) gaEnvSurfaceDestroy(void *pvEnv, + uint32_t u32Sid); + static DECLCALLBACK(int) gaEnvRender(void *pvEnv, + uint32_t u32Cid, + void *pvCommands, + uint32_t cbCommands, + GAFENCEQUERY *pFenceQuery); + static DECLCALLBACK(void) gaEnvFenceUnref(void *pvEnv, + uint32_t u32FenceHandle); + static DECLCALLBACK(int) gaEnvFenceQuery(void *pvEnv, + uint32_t u32FenceHandle, + GAFENCEQUERY *pFenceQuery); + static DECLCALLBACK(int) gaEnvFenceWait(void *pvEnv, + uint32_t u32FenceHandle, + uint32_t u32TimeoutUS); + static DECLCALLBACK(int) gaEnvRegionCreate(void *pvEnv, + uint32_t u32RegionSize, + uint32_t *pu32GmrId, + void **ppvMap); + static DECLCALLBACK(void) gaEnvRegionDestroy(void *pvEnv, + uint32_t u32GmrId, + void *pvMap); + + /* VGPU10 */ + static DECLCALLBACK(int) gaEnvGBSurfaceDefine(void *pvEnv, + SVGAGBSURFCREATE *pCreateParms); + + /* + * Internal. + */ + bool doRender(uint32_t u32Cid, void *pvCommands, uint32_t cbCommands, + GAFENCEQUERY *pFenceQuery, ULONGLONG PresentHistoryToken, bool fPresentRedirected); +}; + +typedef struct GAWDDMCONTEXTINFO +{ + AVLU32NODECORE Core; + D3DKMT_HANDLE hContext; + VOID *pCommandBuffer; + UINT CommandBufferSize; + D3DDDI_ALLOCATIONLIST *pAllocationList; + UINT AllocationListSize; + D3DDDI_PATCHLOCATIONLIST *pPatchLocationList; + UINT PatchLocationListSize; +} GAWDDMCONTEXTINFO; + +typedef struct GAWDDMSURFACEINFO +{ + AVLU32NODECORE Core; + D3DKMT_HANDLE hAllocation; +} GAWDDMSURFACEINFO; + + +/// @todo vboxDdi helpers must return a boof success indicator +static bool +vboxDdiQueryAdapterInfo(GaKmtCallbacks *pKmtCallbacks, + D3DKMT_HANDLE hAdapter, + VBOXWDDM_QAI *pAdapterInfo, + uint32_t cbAdapterInfo) +{ + D3DKMT_QUERYADAPTERINFO QAI; + memset(&QAI, 0, sizeof(QAI)); + QAI.hAdapter = hAdapter; + QAI.Type = KMTQAITYPE_UMDRIVERPRIVATE; + QAI.pPrivateDriverData = pAdapterInfo; + QAI.PrivateDriverDataSize = cbAdapterInfo; + + NTSTATUS Status = pKmtCallbacks->d3dkmt->pfnD3DKMTQueryAdapterInfo(&QAI); + return Status == STATUS_SUCCESS; +} + +static void +vboxDdiDeviceDestroy(GaKmtCallbacks *pKmtCallbacks, + D3DKMT_HANDLE hDevice) +{ + if (hDevice) + { + D3DKMT_DESTROYDEVICE DestroyDeviceData; + memset(&DestroyDeviceData, 0, sizeof(DestroyDeviceData)); + DestroyDeviceData.hDevice = hDevice; + pKmtCallbacks->d3dkmt->pfnD3DKMTDestroyDevice(&DestroyDeviceData); + } +} + +static bool +vboxDdiDeviceCreate(GaKmtCallbacks *pKmtCallbacks, + D3DKMT_HANDLE *phDevice) +{ + D3DKMT_CREATEDEVICE CreateDeviceData; + memset(&CreateDeviceData, 0, sizeof(CreateDeviceData)); + CreateDeviceData.hAdapter = pKmtCallbacks->hAdapter; + // CreateDeviceData.Flags = 0; + + NTSTATUS Status = pKmtCallbacks->d3dkmt->pfnD3DKMTCreateDevice(&CreateDeviceData); + if (Status == STATUS_SUCCESS) + { + *phDevice = CreateDeviceData.hDevice; + return true; + } + return false; +} + +static bool +vboxDdiContextGetId(GaKmtCallbacks *pKmtCallbacks, + D3DKMT_HANDLE hContext, + uint32_t *pu32Cid) +{ + VBOXDISPIFESCAPE_GAGETCID data; + memset(&data, 0, sizeof(data)); + data.EscapeHdr.escapeCode = VBOXESC_GAGETCID; + // data.EscapeHdr.cmdSpecific = 0; + // data.u32Cid = 0; + + /* If the user-mode display driver sets hContext to a non-NULL value, the driver must + * have also set hDevice to a non-NULL value... + */ + D3DKMT_ESCAPE EscapeData; + memset(&EscapeData, 0, sizeof(EscapeData)); + EscapeData.hAdapter = pKmtCallbacks->hAdapter; + EscapeData.hDevice = pKmtCallbacks->hDevice; + EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; + // EscapeData.Flags.HardwareAccess = 0; + EscapeData.pPrivateDriverData = &data; + EscapeData.PrivateDriverDataSize = sizeof(data); + EscapeData.hContext = hContext; + + NTSTATUS Status = pKmtCallbacks->d3dkmt->pfnD3DKMTEscape(&EscapeData); + if (Status == STATUS_SUCCESS) + { + *pu32Cid = data.u32Cid; + return true; + } + return false; +} + +static void +vboxDdiContextDestroy(GaKmtCallbacks *pKmtCallbacks, + GAWDDMCONTEXTINFO *pContextInfo) +{ + if (pContextInfo->hContext) + { + D3DKMT_DESTROYCONTEXT DestroyContextData; + memset(&DestroyContextData, 0, sizeof(DestroyContextData)); + DestroyContextData.hContext = pContextInfo->hContext; + pKmtCallbacks->d3dkmt->pfnD3DKMTDestroyContext(&DestroyContextData); + } +} + +static bool +vboxDdiContextCreate(GaKmtCallbacks *pKmtCallbacks, + void *pvPrivateData, uint32_t cbPrivateData, + GAWDDMCONTEXTINFO *pContextInfo) +{ + D3DKMT_CREATECONTEXT CreateContextData; + memset(&CreateContextData, 0, sizeof(CreateContextData)); + CreateContextData.hDevice = pKmtCallbacks->hDevice; + // CreateContextData.NodeOrdinal = 0; + // CreateContextData.EngineAffinity = 0; + // CreateContextData.Flags.Value = 0; + CreateContextData.pPrivateDriverData = pvPrivateData; + CreateContextData.PrivateDriverDataSize = cbPrivateData; + CreateContextData.ClientHint = D3DKMT_CLIENTHINT_OPENGL; + + NTSTATUS Status = pKmtCallbacks->d3dkmt->pfnD3DKMTCreateContext(&CreateContextData); + if (Status == STATUS_SUCCESS) + { + /* Query cid. */ + uint32_t u32Cid = 0; + bool fSuccess = vboxDdiContextGetId(pKmtCallbacks, CreateContextData.hContext, &u32Cid); + if (fSuccess) + { + pContextInfo->Core.Key = u32Cid; + pContextInfo->hContext = CreateContextData.hContext; + pContextInfo->pCommandBuffer = CreateContextData.pCommandBuffer; + pContextInfo->CommandBufferSize = CreateContextData.CommandBufferSize; + pContextInfo->pAllocationList = CreateContextData.pAllocationList; + pContextInfo->AllocationListSize = CreateContextData.AllocationListSize; + pContextInfo->pPatchLocationList = CreateContextData.pPatchLocationList; + pContextInfo->PatchLocationListSize = CreateContextData.PatchLocationListSize; + + return true; + } + + vboxDdiContextDestroy(pKmtCallbacks, pContextInfo); + } + + return false; +} + +/* static */ DECLCALLBACK(void) +GaDrvEnvKmt::gaEnvContextDestroy(void *pvEnv, + uint32_t u32Cid) +{ + GaDrvEnvKmt *pThis = (GaDrvEnvKmt *)pvEnv; + + GAWDDMCONTEXTINFO *pContextInfo = (GAWDDMCONTEXTINFO *)RTAvlU32Remove(&pThis->mContextTree, u32Cid); + if (pContextInfo) + { + vboxDdiContextDestroy(&pThis->mKmtCallbacks, pContextInfo); + memset(pContextInfo, 0, sizeof(*pContextInfo)); + free(pContextInfo); + } +} + +D3DKMT_HANDLE GaDrvEnvKmt::drvEnvKmtContextHandle(uint32_t u32Cid) +{ + GAWDDMCONTEXTINFO *pContextInfo = (GAWDDMCONTEXTINFO *)RTAvlU32Get(&mContextTree, u32Cid); + Assert(pContextInfo); + return pContextInfo ? pContextInfo->hContext : 0; +} + +/* static */ DECLCALLBACK(uint32_t) +GaDrvEnvKmt::gaEnvContextCreate(void *pvEnv, + boolean extended, + boolean vgpu10) +{ + GaDrvEnvKmt *pThis = (GaDrvEnvKmt *)pvEnv; + + GAWDDMCONTEXTINFO *pContextInfo; + pContextInfo = (GAWDDMCONTEXTINFO *)malloc(sizeof(GAWDDMCONTEXTINFO)); + if (!pContextInfo) + return (uint32_t)-1; + + VBOXWDDM_CREATECONTEXT_INFO privateData; + memset(&privateData, 0, sizeof(privateData)); + privateData.u32IfVersion = 9; + privateData.enmType = VBOXWDDM_CONTEXT_TYPE_GA_3D; + privateData.u.vmsvga.u32Flags = extended? VBOXWDDM_F_GA_CONTEXT_EXTENDED: 0; + privateData.u.vmsvga.u32Flags |= vgpu10? VBOXWDDM_F_GA_CONTEXT_VGPU10: 0; + + bool fSuccess = vboxDdiContextCreate(&pThis->mKmtCallbacks, + &privateData, sizeof(privateData), pContextInfo); + if (fSuccess) + { + if (RTAvlU32Insert(&pThis->mContextTree, &pContextInfo->Core)) + { + return pContextInfo->Core.Key; + } + + vboxDdiContextDestroy(&pThis->mKmtCallbacks, + pContextInfo); + } + + Assert(0); + free(pContextInfo); + return (uint32_t)-1; +} + +static D3DDDIFORMAT svgaToD3DDDIFormat(SVGA3dSurfaceFormat format) +{ + /* The returning D3DDDIFMT_ value is used only to compute bpp, pitch, etc, + * so there is not need for an exact match. + */ + switch (format) + { + case SVGA3D_X8R8G8B8: return D3DDDIFMT_X8R8G8B8; + case SVGA3D_A8R8G8B8: return D3DDDIFMT_A8R8G8B8; + case SVGA3D_ALPHA8: return D3DDDIFMT_A8; + case SVGA3D_A4R4G4B4: return D3DDDIFMT_A4R4G4B4; + case SVGA3D_LUMINANCE8: return D3DDDIFMT_L8; + case SVGA3D_A1R5G5B5: return D3DDDIFMT_A1R5G5B5; + case SVGA3D_LUMINANCE8_ALPHA8: return D3DDDIFMT_A8L8; + case SVGA3D_R5G6B5: return D3DDDIFMT_R5G6B5; + case SVGA3D_ARGB_S10E5: return D3DDDIFMT_A16B16G16R16F; + case SVGA3D_ARGB_S23E8: return D3DDDIFMT_A32B32G32R32F; + case SVGA3D_A8_UNORM: return D3DDDIFMT_A8; + case SVGA3D_B5G5R5A1_UNORM: return D3DDDIFMT_A1R5G5B5; + + case SVGA3D_B8G8R8X8_TYPELESS: + case SVGA3D_B8G8R8X8_UNORM: return D3DDDIFMT_X8R8G8B8; + case SVGA3D_R16_FLOAT: return D3DDDIFMT_R16F; + case SVGA3D_R16G16_FLOAT: return D3DDDIFMT_G16R16F; + case SVGA3D_R16G16B16A16_FLOAT: return D3DDDIFMT_A16B16G16R16F; + case SVGA3D_R32_FLOAT: return D3DDDIFMT_R32F; + case SVGA3D_R32G32_FLOAT: return D3DDDIFMT_G32R32F; + case SVGA3D_R32G32B32A32_FLOAT: return D3DDDIFMT_A32B32G32R32F; + case SVGA3D_R8_TYPELESS: + case SVGA3D_R8_SINT: + case SVGA3D_R8_UINT: + case SVGA3D_R8_SNORM: + case SVGA3D_R8_UNORM: return D3DDDIFMT_L8; + case SVGA3D_R8G8_TYPELESS: + case SVGA3D_R8G8_SINT: + case SVGA3D_R8G8_UINT: + case SVGA3D_R8G8_SNORM: + case SVGA3D_R8G8_UNORM: return D3DDDIFMT_A8L8; + case SVGA3D_R8G8B8A8_TYPELESS: + case SVGA3D_R8G8B8A8_SINT: + case SVGA3D_R8G8B8A8_UINT: + case SVGA3D_R8G8B8A8_SNORM: + case SVGA3D_R8G8B8A8_UNORM: return D3DDDIFMT_A8R8G8B8; + case SVGA3D_R16_TYPELESS: + case SVGA3D_R16_SINT: + case SVGA3D_R16_UINT: + case SVGA3D_R16_SNORM: + case SVGA3D_R16_UNORM: return D3DDDIFMT_L16; + case SVGA3D_R16G16_TYPELESS: + case SVGA3D_R16G16_SINT: + case SVGA3D_R16G16_UINT: + case SVGA3D_R16G16_SNORM: + case SVGA3D_R16G16_UNORM: return D3DDDIFMT_G16R16; + case SVGA3D_R16G16B16A16_TYPELESS: + case SVGA3D_R16G16B16A16_SINT: + case SVGA3D_R16G16B16A16_UINT: + case SVGA3D_R16G16B16A16_SNORM: + case SVGA3D_R16G16B16A16_UNORM: return D3DDDIFMT_A16B16G16R16; + case SVGA3D_R32_TYPELESS: + case SVGA3D_R32_SINT: + case SVGA3D_R32_UINT: return D3DDDIFMT_R32F; /* Same size in bytes. */ + case SVGA3D_R32G32_TYPELESS: + case SVGA3D_R32G32_SINT: + case SVGA3D_R32G32_UINT: return D3DDDIFMT_G32R32F; /* Same size in bytes. */ + case SVGA3D_R32G32B32A32_TYPELESS: + case SVGA3D_R32G32B32A32_SINT: + case SVGA3D_R32G32B32A32_UINT: return D3DDDIFMT_A32B32G32R32F; /* Same size in bytes. */ + case SVGA3D_R10G10B10A2_TYPELESS: + case SVGA3D_R10G10B10A2_UINT: + case SVGA3D_R10G10B10A2_UNORM: return D3DDDIFMT_A2B10G10R10; + case SVGA3D_B5G6R5_UNORM: return D3DDDIFMT_R5G6B5; + case SVGA3D_R11G11B10_FLOAT: return D3DDDIFMT_R32F; + case SVGA3D_B8G8R8A8_UNORM: return D3DDDIFMT_A8R8G8B8; + default: break; + } + + VBoxDispMpLoggerLogF("WDDM: EnvKMT: unsupported surface format %d\n", format); + Assert(0); + return D3DDDIFMT_UNKNOWN; +} + +/* static */ DECLCALLBACK(int) +GaDrvEnvKmt::gaEnvSurfaceDefine(void *pvEnv, + GASURFCREATE *pCreateParms, + GASURFSIZE *paSizes, + uint32_t cSizes, + uint32_t *pu32Sid) +{ + GaDrvEnvKmt *pThis = (GaDrvEnvKmt *)pvEnv; + + D3DKMT_ESCAPE EscapeData; + VBOXDISPIFESCAPE_GASURFACEDEFINE *pData; + uint32_t cbAlloc; + uint8_t *pu8Req; + uint32_t cbReq; + + /* Size of the SVGA request data */ + cbReq = sizeof(GASURFCREATE) + cSizes * sizeof(GASURFSIZE); + /* How much to allocate for WDDM escape data. */ + cbAlloc = sizeof(VBOXDISPIFESCAPE_GASURFACEDEFINE) + + cbReq; + + pData = (VBOXDISPIFESCAPE_GASURFACEDEFINE *)malloc(cbAlloc); + if (!pData) + return -1; + + pData->EscapeHdr.escapeCode = VBOXESC_GASURFACEDEFINE; + // pData->EscapeHdr.cmdSpecific = 0; + // pData->u32Sid = 0; + pData->cbReq = cbReq; + pData->cSizes = cSizes; + + pu8Req = (uint8_t *)&pData[1]; + memcpy(pu8Req, pCreateParms, sizeof(GASURFCREATE)); + memcpy(&pu8Req[sizeof(GASURFCREATE)], paSizes, cSizes * sizeof(GASURFSIZE)); + + memset(&EscapeData, 0, sizeof(EscapeData)); + EscapeData.hAdapter = pThis->mKmtCallbacks.hAdapter; + EscapeData.hDevice = pThis->mKmtCallbacks.hDevice; + EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; + EscapeData.Flags.HardwareAccess = 1; + EscapeData.pPrivateDriverData = pData; + EscapeData.PrivateDriverDataSize = cbAlloc; + // EscapeData.hContext = 0; + + NTSTATUS Status = pThis->mKmtCallbacks.d3dkmt->pfnD3DKMTEscape(&EscapeData); + if (Status == STATUS_SUCCESS) + { + /* Create a kernel mode allocation for render targets, + * because we will need kernel mode handles for Present. + */ + if (pCreateParms->flags & SVGA3D_SURFACE_HINT_RENDERTARGET) + { + /* First check if the format is supported. */ + D3DDDIFORMAT const ddiFormat = svgaToD3DDDIFormat((SVGA3dSurfaceFormat)pCreateParms->format); + if (ddiFormat != D3DDDIFMT_UNKNOWN) + { + GAWDDMSURFACEINFO *pSurfaceInfo = (GAWDDMSURFACEINFO *)malloc(sizeof(GAWDDMSURFACEINFO)); + if (pSurfaceInfo) + { + memset(pSurfaceInfo, 0, sizeof(GAWDDMSURFACEINFO)); + + VBOXWDDM_ALLOCINFO wddmAllocInfo; + memset(&wddmAllocInfo, 0, sizeof(wddmAllocInfo)); + + wddmAllocInfo.enmType = VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC; + wddmAllocInfo.fFlags.RenderTarget = 1; + wddmAllocInfo.hSharedHandle = 0; + wddmAllocInfo.hostID = pData->u32Sid; + wddmAllocInfo.SurfDesc.slicePitch = 0; + wddmAllocInfo.SurfDesc.depth = paSizes[0].cDepth; + wddmAllocInfo.SurfDesc.width = paSizes[0].cWidth; + wddmAllocInfo.SurfDesc.height = paSizes[0].cHeight; + wddmAllocInfo.SurfDesc.format = ddiFormat; + wddmAllocInfo.SurfDesc.VidPnSourceId = 0; + wddmAllocInfo.SurfDesc.bpp = vboxWddmCalcBitsPerPixel(wddmAllocInfo.SurfDesc.format); + wddmAllocInfo.SurfDesc.pitch = vboxWddmCalcPitch(wddmAllocInfo.SurfDesc.width, + wddmAllocInfo.SurfDesc.format); + wddmAllocInfo.SurfDesc.cbSize = vboxWddmCalcSize(wddmAllocInfo.SurfDesc.pitch, + wddmAllocInfo.SurfDesc.height, + wddmAllocInfo.SurfDesc.format); + wddmAllocInfo.SurfDesc.d3dWidth = vboxWddmCalcWidthForPitch(wddmAllocInfo.SurfDesc.pitch, + wddmAllocInfo.SurfDesc.format); + + D3DDDI_ALLOCATIONINFO AllocationInfo; + memset(&AllocationInfo, 0, sizeof(AllocationInfo)); + // AllocationInfo.hAllocation = NULL; + // AllocationInfo.pSystemMem = NULL; + AllocationInfo.pPrivateDriverData = &wddmAllocInfo; + AllocationInfo.PrivateDriverDataSize = sizeof(wddmAllocInfo); + + D3DKMT_CREATEALLOCATION CreateAllocation; + memset(&CreateAllocation, 0, sizeof(CreateAllocation)); + CreateAllocation.hDevice = pThis->mKmtCallbacks.hDevice; + CreateAllocation.NumAllocations = 1; + CreateAllocation.pAllocationInfo = &AllocationInfo; + + Status = pThis->mKmtCallbacks.d3dkmt->pfnD3DKMTCreateAllocation(&CreateAllocation); + if (Status == STATUS_SUCCESS) + { + pSurfaceInfo->Core.Key = pData->u32Sid; + pSurfaceInfo->hAllocation = AllocationInfo.hAllocation; + if (!RTAvlU32Insert(&pThis->mSurfaceTree, &pSurfaceInfo->Core)) + { + Status = STATUS_NOT_SUPPORTED; + } + } + + if (Status != STATUS_SUCCESS) + { + free(pSurfaceInfo); + } + } + else + { + Status = STATUS_NOT_SUPPORTED; + } + } + else + { + /* Unsupported render target format. */ + Status = STATUS_NOT_SUPPORTED; + } + } + + if (Status != STATUS_SUCCESS) + { + gaEnvSurfaceDestroy(pvEnv, pData->u32Sid); + } + } + + if (Status == STATUS_SUCCESS) + { + *pu32Sid = pData->u32Sid; + free(pData); + return 0; + } + + Assert(0); + free(pData); + return -1; +} + +/* static */ DECLCALLBACK(void) +GaDrvEnvKmt::gaEnvSurfaceDestroy(void *pvEnv, + uint32_t u32Sid) +{ + GaDrvEnvKmt *pThis = (GaDrvEnvKmt *)pvEnv; + + VBOXDISPIFESCAPE_GASURFACEDESTROY data; + memset(&data, 0, sizeof(data)); + data.EscapeHdr.escapeCode = VBOXESC_GASURFACEDESTROY; + // data.EscapeHdr.cmdSpecific = 0; + data.u32Sid = u32Sid; + + D3DKMT_ESCAPE EscapeData; + memset(&EscapeData, 0, sizeof(EscapeData)); + EscapeData.hAdapter = pThis->mKmtCallbacks.hAdapter; + EscapeData.hDevice = pThis->mKmtCallbacks.hDevice; + EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; + EscapeData.Flags.HardwareAccess = 1; + EscapeData.pPrivateDriverData = &data; + EscapeData.PrivateDriverDataSize = sizeof(data); + // EscapeData.hContext = 0; + + NTSTATUS Status = pThis->mKmtCallbacks.d3dkmt->pfnD3DKMTEscape(&EscapeData); + Assert(Status == STATUS_SUCCESS); + + /* Try to remove from sid -> hAllocation map. */ + GAWDDMSURFACEINFO *pSurfaceInfo = (GAWDDMSURFACEINFO *)RTAvlU32Remove(&pThis->mSurfaceTree, u32Sid); + if (pSurfaceInfo) + { + D3DKMT_DESTROYALLOCATION DestroyAllocation; + memset(&DestroyAllocation, 0, sizeof(DestroyAllocation)); + DestroyAllocation.hDevice = pThis->mKmtCallbacks.hDevice; + // DestroyAllocation.hResource = 0; + DestroyAllocation.phAllocationList = &pSurfaceInfo->hAllocation; + DestroyAllocation.AllocationCount = 1; + + Status = pThis->mKmtCallbacks.d3dkmt->pfnD3DKMTDestroyAllocation(&DestroyAllocation); + Assert(Status == STATUS_SUCCESS); + + free(pSurfaceInfo); + } +} + +D3DKMT_HANDLE GaDrvEnvKmt::drvEnvKmtSurfaceHandle(uint32_t u32Sid) +{ + GAWDDMSURFACEINFO *pSurfaceInfo = (GAWDDMSURFACEINFO *)RTAvlU32Get(&mSurfaceTree, u32Sid); + return pSurfaceInfo ? pSurfaceInfo->hAllocation : 0; +} + +static bool +vboxDdiFenceCreate(GaKmtCallbacks *pKmtCallbacks, + GAWDDMCONTEXTINFO *pContextInfo, + uint32_t *pu32FenceHandle) +{ + VBOXDISPIFESCAPE_GAFENCECREATE fenceCreate; + memset(&fenceCreate, 0, sizeof(fenceCreate)); + fenceCreate.EscapeHdr.escapeCode = VBOXESC_GAFENCECREATE; + // fenceCreate.EscapeHdr.cmdSpecific = 0; + + /* If the user-mode display driver sets hContext to a non-NULL value, the driver must + * have also set hDevice to a non-NULL value... + */ + D3DKMT_ESCAPE EscapeData; + memset(&EscapeData, 0, sizeof(EscapeData)); + EscapeData.hAdapter = pKmtCallbacks->hAdapter; + EscapeData.hDevice = pKmtCallbacks->hDevice; + EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; + // EscapeData.Flags.HardwareAccess = 0; + EscapeData.pPrivateDriverData = &fenceCreate; + EscapeData.PrivateDriverDataSize = sizeof(fenceCreate); + EscapeData.hContext = pContextInfo->hContext; + + NTSTATUS Status = pKmtCallbacks->d3dkmt->pfnD3DKMTEscape(&EscapeData); + if (Status == STATUS_SUCCESS) + { + *pu32FenceHandle = fenceCreate.u32FenceHandle; + return true; + } + + Assert(0); + return false; +} + +static bool +vboxDdiFenceQuery(GaKmtCallbacks *pKmtCallbacks, + uint32_t u32FenceHandle, + GAFENCEQUERY *pFenceQuery) +{ + VBOXDISPIFESCAPE_GAFENCEQUERY fenceQuery; + memset(&fenceQuery, 0, sizeof(fenceQuery)); + fenceQuery.EscapeHdr.escapeCode = VBOXESC_GAFENCEQUERY; + // fenceQuery.EscapeHdr.cmdSpecific = 0; + fenceQuery.u32FenceHandle = u32FenceHandle; + + D3DKMT_ESCAPE EscapeData; + memset(&EscapeData, 0, sizeof(EscapeData)); + EscapeData.hAdapter = pKmtCallbacks->hAdapter; + EscapeData.hDevice = pKmtCallbacks->hDevice; + EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; + // EscapeData.Flags.HardwareAccess = 0; + EscapeData.pPrivateDriverData = &fenceQuery; + EscapeData.PrivateDriverDataSize = sizeof(fenceQuery); + EscapeData.hContext = 0; + + NTSTATUS Status = pKmtCallbacks->d3dkmt->pfnD3DKMTEscape(&EscapeData); + if (Status == STATUS_SUCCESS) + { + pFenceQuery->u32FenceHandle = fenceQuery.u32FenceHandle; + pFenceQuery->u32SubmittedSeqNo = fenceQuery.u32SubmittedSeqNo; + pFenceQuery->u32ProcessedSeqNo = fenceQuery.u32ProcessedSeqNo; + pFenceQuery->u32FenceStatus = fenceQuery.u32FenceStatus; + return true; + } + + Assert(0); + return false; +} + +/* static */ DECLCALLBACK(int) +GaDrvEnvKmt::gaEnvFenceQuery(void *pvEnv, + uint32_t u32FenceHandle, + GAFENCEQUERY *pFenceQuery) +{ + GaDrvEnvKmt *pThis = (GaDrvEnvKmt *)pvEnv; + + if (!pThis->mKmtCallbacks.hDevice) + { + pFenceQuery->u32FenceStatus = GA_FENCE_STATUS_NULL; + return 0; + } + + bool fSuccess = vboxDdiFenceQuery(&pThis->mKmtCallbacks, u32FenceHandle, pFenceQuery); + return fSuccess ? 0: -1; +} + +static bool +vboxDdiFenceWait(GaKmtCallbacks *pKmtCallbacks, + uint32_t u32FenceHandle, + uint32_t u32TimeoutUS) +{ + VBOXDISPIFESCAPE_GAFENCEWAIT fenceWait; + memset(&fenceWait, 0, sizeof(fenceWait)); + fenceWait.EscapeHdr.escapeCode = VBOXESC_GAFENCEWAIT; + // pFenceWait->EscapeHdr.cmdSpecific = 0; + fenceWait.u32FenceHandle = u32FenceHandle; + fenceWait.u32TimeoutUS = u32TimeoutUS; + + D3DKMT_ESCAPE EscapeData; + memset(&EscapeData, 0, sizeof(EscapeData)); + EscapeData.hAdapter = pKmtCallbacks->hAdapter; + EscapeData.hDevice = pKmtCallbacks->hDevice; + EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; + // EscapeData.Flags.HardwareAccess = 0; + EscapeData.pPrivateDriverData = &fenceWait; + EscapeData.PrivateDriverDataSize = sizeof(fenceWait); + EscapeData.hContext = 0; + + NTSTATUS Status = pKmtCallbacks->d3dkmt->pfnD3DKMTEscape(&EscapeData); + Assert(Status == STATUS_SUCCESS); + return Status == STATUS_SUCCESS; +} + +/* static */ DECLCALLBACK(int) +GaDrvEnvKmt::gaEnvFenceWait(void *pvEnv, + uint32_t u32FenceHandle, + uint32_t u32TimeoutUS) +{ + GaDrvEnvKmt *pThis = (GaDrvEnvKmt *)pvEnv; + + if (!pThis->mKmtCallbacks.hDevice) + return 0; + + bool fSuccess = vboxDdiFenceWait(&pThis->mKmtCallbacks, u32FenceHandle, u32TimeoutUS); + return fSuccess ? 0 : -1; +} + +static bool +vboxDdiFenceUnref(GaKmtCallbacks *pKmtCallbacks, + uint32_t u32FenceHandle) +{ + VBOXDISPIFESCAPE_GAFENCEUNREF fenceUnref; + memset(&fenceUnref, 0, sizeof(fenceUnref)); + fenceUnref.EscapeHdr.escapeCode = VBOXESC_GAFENCEUNREF; + // pFenceUnref->EscapeHdr.cmdSpecific = 0; + fenceUnref.u32FenceHandle = u32FenceHandle; + + D3DKMT_ESCAPE EscapeData; + memset(&EscapeData, 0, sizeof(EscapeData)); + EscapeData.hAdapter = pKmtCallbacks->hAdapter; + EscapeData.hDevice = pKmtCallbacks->hDevice; + EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; + // EscapeData.Flags.HardwareAccess = 0; + EscapeData.pPrivateDriverData = &fenceUnref; + EscapeData.PrivateDriverDataSize = sizeof(fenceUnref); + EscapeData.hContext = 0; + + NTSTATUS Status = pKmtCallbacks->d3dkmt->pfnD3DKMTEscape(&EscapeData); + Assert(Status == STATUS_SUCCESS); + return Status == STATUS_SUCCESS; +} + +/* static */ DECLCALLBACK(void) +GaDrvEnvKmt::gaEnvFenceUnref(void *pvEnv, + uint32_t u32FenceHandle) +{ + GaDrvEnvKmt *pThis = (GaDrvEnvKmt *)pvEnv; + + if (!pThis->mKmtCallbacks.hDevice) + return; + + vboxDdiFenceUnref(&pThis->mKmtCallbacks, u32FenceHandle); +} + +/** Calculate how many commands will fit in the buffer. + * + * @param pu8Commands Command buffer. + * @param cbCommands Size of command buffer. + * @param cbAvail Available buffer size.. + * @param pu32Length Size of commands which will fit in cbAvail bytes. + */ +static bool +vboxCalcCommandLength(const uint8_t *pu8Commands, uint32_t cbCommands, uint32_t cbAvail, uint32_t *pu32Length) +{ + uint32_t u32Length = 0; + const uint8_t *pu8Src = pu8Commands; + const uint8_t *pu8SrcEnd = pu8Commands + cbCommands; + + while (pu8SrcEnd > pu8Src) + { + const uint32_t cbSrcLeft = pu8SrcEnd - pu8Src; + if (cbSrcLeft < sizeof(uint32_t)) + { + return false; + } + + /* Get the command id and command length. */ + const uint32_t u32CmdId = *(uint32_t *)pu8Src; + uint32_t cbCmd = 0; + + if (SVGA_3D_CMD_BASE <= u32CmdId && u32CmdId < SVGA_3D_CMD_MAX) + { + if (cbSrcLeft < sizeof(SVGA3dCmdHeader)) + { + return false; + } + + const SVGA3dCmdHeader *pHeader = (SVGA3dCmdHeader *)pu8Src; + cbCmd = sizeof(SVGA3dCmdHeader) + pHeader->size; + if (cbCmd % sizeof(uint32_t) != 0) + { + return false; + } + if (cbSrcLeft < cbCmd) + { + return false; + } + } + else + { + /* It is not expected that any of common SVGA commands will be in the command buffer + * because the SVGA gallium driver does not use them. + */ + return false; + } + + if (u32Length + cbCmd > cbAvail) + { + if (u32Length == 0) + { + /* No commands fit into the buffer. */ + return false; + } + break; + } + + pu8Src += cbCmd; + u32Length += cbCmd; + } + + *pu32Length = u32Length; + return true; +} + +static bool +vboxDdiRender(GaKmtCallbacks *pKmtCallbacks, + GAWDDMCONTEXTINFO *pContextInfo, uint32_t u32FenceHandle, void *pvCommands, uint32_t cbCommands, + ULONGLONG PresentHistoryToken, bool fPresentRedirected) +{ + uint32_t cbLeft; + const uint8_t *pu8Src; + + cbLeft = cbCommands; + pu8Src = (uint8_t *)pvCommands; + /* Even when cbCommands is 0, submit the fence. The following code deals with this. */ + do + { + /* Actually available space. */ + const uint32_t cbAvail = pContextInfo->CommandBufferSize; + if (cbAvail <= sizeof(u32FenceHandle)) + { + return false; + } + + /* How many bytes of command data still to copy. */ + uint32_t cbCommandChunk = cbLeft; + + /* How many bytes still to copy. */ + uint32_t cbToCopy = sizeof(u32FenceHandle) + cbCommandChunk; + + /* Copy the buffer identifier. */ + if (cbToCopy <= cbAvail) + { + /* Command buffer is big enough. */ + *(uint32_t *)pContextInfo->pCommandBuffer = u32FenceHandle; + } + else + { + /* Split. Write zero as buffer identifier. */ + *(uint32_t *)pContextInfo->pCommandBuffer = 0; + + /* Get how much commands data will fit in the buffer. */ + if (!vboxCalcCommandLength(pu8Src, cbCommandChunk, cbAvail - sizeof(u32FenceHandle), &cbCommandChunk)) + { + return false; + } + + cbToCopy = sizeof(u32FenceHandle) + cbCommandChunk; + } + + if (cbCommandChunk) + { + /* Copy the command data. */ + memcpy((uint8_t *)pContextInfo->pCommandBuffer + sizeof(u32FenceHandle), pu8Src, cbCommandChunk); + } + + /* Advance the command position. */ + pu8Src += cbCommandChunk; + cbLeft -= cbCommandChunk; + + D3DKMT_RENDER RenderData; + memset(&RenderData, 0, sizeof(RenderData)); + RenderData.hContext = pContextInfo->hContext; + // RenderData.CommandOffset = 0; + RenderData.CommandLength = cbToCopy; + // RenderData.AllocationCount = 0; + // RenderData.PatchLocationCount = 0; + RenderData.PresentHistoryToken = PresentHistoryToken; + RenderData.Flags.PresentRedirected = fPresentRedirected; + + NTSTATUS Status = pKmtCallbacks->d3dkmt->pfnD3DKMTRender(&RenderData); + Assert(Status == STATUS_SUCCESS); + if (Status != STATUS_SUCCESS) + { + return false; + } + + pContextInfo->pCommandBuffer = RenderData.pNewCommandBuffer; + pContextInfo->CommandBufferSize = RenderData.NewCommandBufferSize; + pContextInfo->pAllocationList = RenderData.pNewAllocationList; + pContextInfo->AllocationListSize = RenderData.NewAllocationListSize; + pContextInfo->pPatchLocationList = RenderData.pNewPatchLocationList; + pContextInfo->PatchLocationListSize = RenderData.NewPatchLocationListSize; + } while (cbLeft); + + return true; +} + +bool GaDrvEnvKmt::doRender(uint32_t u32Cid, void *pvCommands, uint32_t cbCommands, + GAFENCEQUERY *pFenceQuery, ULONGLONG PresentHistoryToken, bool fPresentRedirected) +{ + uint32_t u32FenceHandle; + GAWDDMCONTEXTINFO *pContextInfo = (GAWDDMCONTEXTINFO *)RTAvlU32Get(&mContextTree, u32Cid); + if (!pContextInfo) + return false; + + bool fSuccess = true; + u32FenceHandle = 0; + if (pFenceQuery) + { + fSuccess = vboxDdiFenceCreate(&mKmtCallbacks, pContextInfo, &u32FenceHandle); + } + + if (fSuccess) + { + fSuccess = vboxDdiRender(&mKmtCallbacks, pContextInfo, u32FenceHandle, + pvCommands, cbCommands, PresentHistoryToken, fPresentRedirected); + if (fSuccess) + { + if (pFenceQuery) + { + if (!vboxDdiFenceQuery(&mKmtCallbacks, u32FenceHandle, pFenceQuery)) + { + pFenceQuery->u32FenceStatus = GA_FENCE_STATUS_NULL; + } + } + } + } + return fSuccess; +} + +/* static */ DECLCALLBACK(int) +GaDrvEnvKmt::gaEnvRender(void *pvEnv, + uint32_t u32Cid, + void *pvCommands, + uint32_t cbCommands, + GAFENCEQUERY *pFenceQuery) +{ + GaDrvEnvKmt *pThis = (GaDrvEnvKmt *)pvEnv; + return pThis->doRender(u32Cid, pvCommands, cbCommands, pFenceQuery, 0, false) ? 1 : 0; +} + +bool GaDrvEnvKmt::drvEnvKmtRenderCompose(uint32_t u32Cid, + void *pvCommands, + uint32_t cbCommands, + ULONGLONG PresentHistoryToken) +{ + return doRender(u32Cid, pvCommands, cbCommands, NULL, PresentHistoryToken, true); +} + + +static bool +vboxDdiRegionCreate(GaKmtCallbacks *pKmtCallbacks, + uint32_t u32RegionSize, + uint32_t *pu32GmrId, + void **ppvMap) +{ + VBOXDISPIFESCAPE_GAREGION data; + memset(&data, 0, sizeof(data)); + data.EscapeHdr.escapeCode = VBOXESC_GAREGION; + // data.EscapeHdr.cmdSpecific = 0; + data.u32Command = GA_REGION_CMD_CREATE; + data.u32NumPages = (u32RegionSize + PAGE_SIZE - 1) / PAGE_SIZE; + // data.u32GmrId = 0; + // data.u64UserAddress = 0; + + D3DKMT_ESCAPE EscapeData; + memset(&EscapeData, 0, sizeof(EscapeData)); + EscapeData.hAdapter = pKmtCallbacks->hAdapter; + EscapeData.hDevice = pKmtCallbacks->hDevice; + EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; + // EscapeData.Flags.HardwareAccess = 0; + EscapeData.pPrivateDriverData = &data; + EscapeData.PrivateDriverDataSize = sizeof(data); + // EscapeData.hContext = 0; + + NTSTATUS Status = pKmtCallbacks->d3dkmt->pfnD3DKMTEscape(&EscapeData); + if (Status == STATUS_SUCCESS) + { + *pu32GmrId = data.u32GmrId; + *ppvMap = (void *)(uintptr_t)data.u64UserAddress; + return true; + } + + Assert(0); + return false; +} + +/* static */ DECLCALLBACK(int) +GaDrvEnvKmt::gaEnvRegionCreate(void *pvEnv, + uint32_t u32RegionSize, + uint32_t *pu32GmrId, + void **ppvMap) +{ + GaDrvEnvKmt *pThis = (GaDrvEnvKmt *)pvEnv; + + if (pThis->mKmtCallbacks.hDevice) + { + /* That is a real device */ + bool fSuccess = vboxDdiRegionCreate(&pThis->mKmtCallbacks, u32RegionSize, pu32GmrId, ppvMap); + return fSuccess ? 0: -1; + } + + /* That is a fake device, created when WDDM adapter is initialized. */ + *ppvMap = malloc(u32RegionSize); + if (*ppvMap) + { + *pu32GmrId = 0; + return 0; + } + + return -1; +} + +static bool +vboxDdiRegionDestroy(GaKmtCallbacks *pKmtCallbacks, + uint32_t u32GmrId) +{ + VBOXDISPIFESCAPE_GAREGION data; + memset(&data, 0, sizeof(data)); + data.EscapeHdr.escapeCode = VBOXESC_GAREGION; + // data.EscapeHdr.cmdSpecific = 0; + data.u32Command = GA_REGION_CMD_DESTROY; + // data.u32NumPages = 0; + data.u32GmrId = u32GmrId; + // data.u64UserAddress = 0; + + D3DKMT_ESCAPE EscapeData; + memset(&EscapeData, 0, sizeof(EscapeData)); + EscapeData.hAdapter = pKmtCallbacks->hAdapter; + EscapeData.hDevice = pKmtCallbacks->hDevice; + EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; + EscapeData.Flags.HardwareAccess = 1; /* Sync with submitted commands. */ + EscapeData.pPrivateDriverData = &data; + EscapeData.PrivateDriverDataSize = sizeof(data); + // EscapeData.hContext = 0; + + NTSTATUS Status = pKmtCallbacks->d3dkmt->pfnD3DKMTEscape(&EscapeData); + Assert(Status == STATUS_SUCCESS); + return Status == STATUS_SUCCESS; +} + +/* static */ DECLCALLBACK(void) +GaDrvEnvKmt::gaEnvRegionDestroy(void *pvEnv, + uint32_t u32GmrId, + void *pvMap) +{ + GaDrvEnvKmt *pThis = (GaDrvEnvKmt *)pvEnv; + + if (pThis->mKmtCallbacks.hDevice) + { + vboxDdiRegionDestroy(&pThis->mKmtCallbacks, u32GmrId); + } + else + { + free(pvMap); + } +} + +/* static */ DECLCALLBACK(int) +GaDrvEnvKmt::gaEnvGBSurfaceDefine(void *pvEnv, + SVGAGBSURFCREATE *pCreateParms) +{ + GaDrvEnvKmt *pThis = (GaDrvEnvKmt *)pvEnv; + + VBOXDISPIFESCAPE_SVGAGBSURFACEDEFINE data; + data.EscapeHdr.escapeCode = VBOXESC_SVGAGBSURFACEDEFINE; + data.EscapeHdr.u32CmdSpecific = 0; + data.CreateParms = *pCreateParms; + + D3DKMT_ESCAPE EscapeData; + memset(&EscapeData, 0, sizeof(EscapeData)); + EscapeData.hAdapter = pThis->mKmtCallbacks.hAdapter; + EscapeData.hDevice = pThis->mKmtCallbacks.hDevice; + EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; + EscapeData.Flags.HardwareAccess = 1; + EscapeData.pPrivateDriverData = &data; + EscapeData.PrivateDriverDataSize = sizeof(data); + // EscapeData.hContext = 0; + + NTSTATUS Status = pThis->mKmtCallbacks.d3dkmt->pfnD3DKMTEscape(&EscapeData); + if (Status == STATUS_SUCCESS) + { + pCreateParms->gmrid = data.CreateParms.gmrid; + pCreateParms->cbGB = data.CreateParms.cbGB; + pCreateParms->u64UserAddress = data.CreateParms.u64UserAddress; + pCreateParms->u32Sid = data.CreateParms.u32Sid; + + /* Create a kernel mode allocation for render targets, + * because we will need kernel mode handles for Present. + */ + if (pCreateParms->s.flags & SVGA3D_SURFACE_HINT_RENDERTARGET) + { + /* First check if the format is supported. */ + D3DDDIFORMAT const ddiFormat = svgaToD3DDDIFormat((SVGA3dSurfaceFormat)pCreateParms->s.format); + if (ddiFormat != D3DDDIFMT_UNKNOWN) + { + GAWDDMSURFACEINFO *pSurfaceInfo = (GAWDDMSURFACEINFO *)malloc(sizeof(GAWDDMSURFACEINFO)); + if (pSurfaceInfo) + { + memset(pSurfaceInfo, 0, sizeof(GAWDDMSURFACEINFO)); + + VBOXWDDM_ALLOCINFO wddmAllocInfo; + memset(&wddmAllocInfo, 0, sizeof(wddmAllocInfo)); + + wddmAllocInfo.enmType = VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC; + wddmAllocInfo.fFlags.RenderTarget = 1; + wddmAllocInfo.hSharedHandle = 0; + wddmAllocInfo.hostID = pCreateParms->u32Sid; + wddmAllocInfo.SurfDesc.slicePitch = 0; + wddmAllocInfo.SurfDesc.depth = pCreateParms->s.size.depth; + wddmAllocInfo.SurfDesc.width = pCreateParms->s.size.width; + wddmAllocInfo.SurfDesc.height = pCreateParms->s.size.height; + wddmAllocInfo.SurfDesc.format = ddiFormat; + wddmAllocInfo.SurfDesc.VidPnSourceId = 0; + wddmAllocInfo.SurfDesc.bpp = vboxWddmCalcBitsPerPixel(wddmAllocInfo.SurfDesc.format); + wddmAllocInfo.SurfDesc.pitch = vboxWddmCalcPitch(wddmAllocInfo.SurfDesc.width, + wddmAllocInfo.SurfDesc.format); + wddmAllocInfo.SurfDesc.cbSize = vboxWddmCalcSize(wddmAllocInfo.SurfDesc.pitch, + wddmAllocInfo.SurfDesc.height, + wddmAllocInfo.SurfDesc.format); + wddmAllocInfo.SurfDesc.d3dWidth = vboxWddmCalcWidthForPitch(wddmAllocInfo.SurfDesc.pitch, + wddmAllocInfo.SurfDesc.format); + + D3DDDI_ALLOCATIONINFO AllocationInfo; + memset(&AllocationInfo, 0, sizeof(AllocationInfo)); + // AllocationInfo.hAllocation = NULL; + // AllocationInfo.pSystemMem = NULL; + AllocationInfo.pPrivateDriverData = &wddmAllocInfo; + AllocationInfo.PrivateDriverDataSize = sizeof(wddmAllocInfo); + + D3DKMT_CREATEALLOCATION CreateAllocation; + memset(&CreateAllocation, 0, sizeof(CreateAllocation)); + CreateAllocation.hDevice = pThis->mKmtCallbacks.hDevice; + CreateAllocation.NumAllocations = 1; + CreateAllocation.pAllocationInfo = &AllocationInfo; + + Status = pThis->mKmtCallbacks.d3dkmt->pfnD3DKMTCreateAllocation(&CreateAllocation); + if (Status == STATUS_SUCCESS) + { + pSurfaceInfo->Core.Key = pCreateParms->u32Sid; + pSurfaceInfo->hAllocation = AllocationInfo.hAllocation; + if (!RTAvlU32Insert(&pThis->mSurfaceTree, &pSurfaceInfo->Core)) + { + Status = STATUS_NOT_SUPPORTED; + } + } + + if (Status != STATUS_SUCCESS) + { + free(pSurfaceInfo); + } + } + else + { + Status = STATUS_NOT_SUPPORTED; + } + } + else + { + /* Unsupported render target format. */ + Assert(0); + Status = STATUS_NOT_SUPPORTED; + } + } + + if (Status != STATUS_SUCCESS) + { + gaEnvSurfaceDestroy(pvEnv, pCreateParms->u32Sid); + } + } + + if (Status == STATUS_SUCCESS) + return 0; + + Assert(0); + return -1; +} + +GaDrvEnvKmt::GaDrvEnvKmt() + : + mContextTree(0), + mSurfaceTree(0) +{ + RT_ZERO(mKmtCallbacks); + RT_ZERO(mHWInfo); + RT_ZERO(mEnv); +} + +GaDrvEnvKmt::~GaDrvEnvKmt() +{ +} + +HRESULT GaDrvEnvKmt::Init(void) +{ + mKmtCallbacks.d3dkmt = D3DKMTFunctions(); + + /* Figure out which adapter to use. */ + NTSTATUS Status = vboxDispKmtOpenAdapter2(&mKmtCallbacks.hAdapter, &mKmtCallbacks.AdapterLuid); + Assert(Status == STATUS_SUCCESS); + if (Status == STATUS_SUCCESS) + { + VBOXWDDM_QAI adapterInfo; + bool fSuccess = vboxDdiQueryAdapterInfo(&mKmtCallbacks, mKmtCallbacks.hAdapter, &adapterInfo, sizeof(adapterInfo)); + Assert(fSuccess); + if (fSuccess) + { + fSuccess = vboxDdiDeviceCreate(&mKmtCallbacks, &mKmtCallbacks.hDevice); + Assert(fSuccess); + if (fSuccess) + { + mHWInfo = adapterInfo.u.vmsvga.HWInfo; + + /* + * Success. + */ + return S_OK; + } + + vboxDdiDeviceDestroy(&mKmtCallbacks, mKmtCallbacks.hDevice); + } + + vboxDispKmtCloseAdapter(mKmtCallbacks.hAdapter); + } + + return E_FAIL; +} + +const WDDMGalliumDriverEnv *GaDrvEnvKmt::Env() +{ + if (mEnv.cb == 0) + { + mEnv.cb = sizeof(WDDMGalliumDriverEnv); + mEnv.pHWInfo = &mHWInfo; + mEnv.pvEnv = this; + mEnv.pfnContextCreate = gaEnvContextCreate; + mEnv.pfnContextDestroy = gaEnvContextDestroy; + mEnv.pfnSurfaceDefine = gaEnvSurfaceDefine; + mEnv.pfnSurfaceDestroy = gaEnvSurfaceDestroy; + mEnv.pfnRender = gaEnvRender; + mEnv.pfnFenceUnref = gaEnvFenceUnref; + mEnv.pfnFenceQuery = gaEnvFenceQuery; + mEnv.pfnFenceWait = gaEnvFenceWait; + mEnv.pfnRegionCreate = gaEnvRegionCreate; + mEnv.pfnRegionDestroy = gaEnvRegionDestroy; + /* VGPU10 */ + mEnv.pfnGBSurfaceDefine = gaEnvGBSurfaceDefine; + } + + return &mEnv; +} + +RT_C_DECLS_BEGIN + +const WDDMGalliumDriverEnv *GaDrvEnvKmtCreate(void) +{ + GaDrvEnvKmt *p = new GaDrvEnvKmt(); + if (p) + { + HRESULT hr = p->Init(); + if (hr != S_OK) + { + delete p; + p = NULL; + } + } + return p ? p->Env() : NULL; +} + +void GaDrvEnvKmtDelete(const WDDMGalliumDriverEnv *pEnv) +{ + if (pEnv) + { + GaDrvEnvKmt *p = (GaDrvEnvKmt *)pEnv->pvEnv; + delete p; + } +} + +D3DKMT_HANDLE GaDrvEnvKmtContextHandle(const WDDMGalliumDriverEnv *pEnv, uint32_t u32Cid) +{ + GaDrvEnvKmt *p = (GaDrvEnvKmt *)pEnv->pvEnv; + return p->drvEnvKmtContextHandle(u32Cid); +} + +D3DKMT_HANDLE GaDrvEnvKmtSurfaceHandle(const WDDMGalliumDriverEnv *pEnv, uint32_t u32Sid) +{ + GaDrvEnvKmt *p = (GaDrvEnvKmt *)pEnv->pvEnv; + return p->drvEnvKmtSurfaceHandle(u32Sid); +} + +void GaDrvEnvKmtAdapterLUID(const WDDMGalliumDriverEnv *pEnv, LUID *pAdapterLuid) +{ + GaDrvEnvKmt *p = (GaDrvEnvKmt *)pEnv->pvEnv; + *pAdapterLuid = p->mKmtCallbacks.AdapterLuid; +} + +D3DKMT_HANDLE GaDrvEnvKmtAdapterHandle(const WDDMGalliumDriverEnv *pEnv) +{ + GaDrvEnvKmt *p = (GaDrvEnvKmt *)pEnv->pvEnv; + return p->mKmtCallbacks.hAdapter; +} + +D3DKMT_HANDLE GaDrvEnvKmtDeviceHandle(const WDDMGalliumDriverEnv *pEnv) +{ + GaDrvEnvKmt *p = (GaDrvEnvKmt *)pEnv->pvEnv; + return p->mKmtCallbacks.hDevice; +} + +void GaDrvEnvKmtRenderCompose(const WDDMGalliumDriverEnv *pEnv, + uint32_t u32Cid, + void *pvCommands, + uint32_t cbCommands, + ULONGLONG PresentHistoryToken) +{ + GaDrvEnvKmt *p = (GaDrvEnvKmt *)pEnv->pvEnv; + p->drvEnvKmtRenderCompose(u32Cid, pvCommands, cbCommands, PresentHistoryToken); +} + +RT_C_DECLS_END diff --git a/src/VBox/Additions/3D/win/VBoxGL/GaDrvEnvKMT.h b/src/VBox/Additions/3D/win/VBoxGL/GaDrvEnvKMT.h new file mode 100644 index 00000000..44cad791 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxGL/GaDrvEnvKMT.h @@ -0,0 +1,58 @@ +/* $Id: GaDrvEnvKMT.h $ */ +/** @file + * VirtualBox Windows Guest Mesa3D - Gallium driver interface to the WDDM miniport driver. + */ + +/* + * Copyright (C) 2016-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#ifndef GA_INCLUDED_SRC_3D_win_VBoxGL_GaDrvEnvKMT_h +#define GA_INCLUDED_SRC_3D_win_VBoxGL_GaDrvEnvKMT_h +#ifndef RT_WITHOUT_PRAGMA_ONCE +# pragma once +#endif + +#include <VBoxGaDriver.h> +#include <VBoxWddmUmHlp.h> + +RT_C_DECLS_BEGIN + +const WDDMGalliumDriverEnv *GaDrvEnvKmtCreate(void); +void GaDrvEnvKmtDelete(const WDDMGalliumDriverEnv *pEnv); + +D3DKMT_HANDLE GaDrvEnvKmtContextHandle(const WDDMGalliumDriverEnv *pEnv, + uint32_t u32Cid); +D3DKMT_HANDLE GaDrvEnvKmtSurfaceHandle(const WDDMGalliumDriverEnv *pEnv, + uint32_t u32Sid); +void GaDrvEnvKmtAdapterLUID(const WDDMGalliumDriverEnv *pEnv, + LUID *pAdapterLuid); +D3DKMT_HANDLE GaDrvEnvKmtAdapterHandle(const WDDMGalliumDriverEnv *pEnv); +D3DKMT_HANDLE GaDrvEnvKmtDeviceHandle(const WDDMGalliumDriverEnv *pEnv); +void GaDrvEnvKmtRenderCompose(const WDDMGalliumDriverEnv *pEnv, + uint32_t u32Cid, + void *pvCommands, + uint32_t cbCommands, + ULONGLONG PresentHistoryToken); + +RT_C_DECLS_END + +#endif /* !GA_INCLUDED_SRC_3D_win_VBoxGL_GaDrvEnvKMT_h */ diff --git a/src/VBox/Additions/3D/win/VBoxGL/Makefile.kmk b/src/VBox/Additions/3D/win/VBoxGL/Makefile.kmk new file mode 100644 index 00000000..0a330258 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxGL/Makefile.kmk @@ -0,0 +1,87 @@ +# $Id: Makefile.kmk $ +## @file +# Sub-Makefile for VBoxGL OpenGL state tracker. +# + +# +# Copyright (C) 2018-2023 Oracle and/or its affiliates. +# +# This file is part of VirtualBox base platform packages, as +# available from https://www.virtualbox.org. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, in version 3 of the +# License. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see <https://www.gnu.org/licenses>. +# +# SPDX-License-Identifier: GPL-3.0-only +# + +SUB_DEPTH = ../../../../../.. +include $(KBUILD_PATH)/subheader.kmk + +DLLS += VBoxGL +DLLS.amd64 += VBoxGL-x86 + +VBoxGL_TEMPLATE = VBoxMesa3DGuestR3DllMinVista +VBoxGL_DEFS = VBOXGL +# -wd4005: '__useHeader' : redefinition +VBOXGL_DISABLED_WARNINGS := -wd4005 +# -wd4204: nonstandard extension used: non-constant aggregate initializer +# -wd4267: 'initializing': conversion from 'size_t' to 'unsigned int', possible loss of data +# -wd4459: stw_device.h(102): warning C4459: declaration of 'stw_dev' hides global declaration +# -wd4668: c99_compat.h(99): warning C4668: '__STDC_VERSION__' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' +VBOXGL_DISABLED_WARNINGS += -wd4204 -wd4267 -wd4459 -wd4668 +VBoxGL_CFLAGS = $(VBOXGL_DISABLED_WARNINGS) +VBoxGL_CXXFLAGS = $(VBOXGL_DISABLED_WARNINGS) +VBoxGL_INCS = \ + $(VBOX_PATH_3D)/win/include \ + $(VBOX_PATH_MESA)/include/GL \ + $(VBOX_PATH_MESA)/src/gallium/frontends/wgl \ + $(VBOX_PATH_MESA)/src/gallium/winsys/sw \ + $(VBOX_PATH_MESA)/src/gallium/drivers \ + $(PATH_ROOT)/src/VBox/Additions/WINNT/Graphics/Video \ + $(PATH_ROOT)/src/VBox/Runtime/common/table \ + $(VBOX_PATH_VMSVGA_INC) \ + $(VBOX_GRAPHICS_INCS) +VBoxGL_SOURCES = \ + $(VBOX_PATH_MESA)/src/gallium/targets/libgl-gdi/opengl32.def \ + VBoxGL.rc +VBoxGL_SOURCES += \ + GaDrvEnvKMT.cpp \ + VBoxGL.c +VBoxGL_LIBS = \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxWddmUmHlp$(VBOX_SUFF_LIB) \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaGalliumAuxLib$(VBOX_SUFF_LIB) \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaWglLib$(VBOX_SUFF_LIB) \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaUtilLib$(VBOX_SUFF_LIB) \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaLib$(VBOX_SUFF_LIB) + +if defined(VBOX_SIGNING_MODE) && defined(VBOX_SIGN_ADDITIONS) + VBoxGL_INSTTYPE = none + VBoxGL_DEBUG_INSTTYPE = both +endif + +# +# VBoxGL-x86 - x86 version of VBoxGL built for amd64 build +# +VBoxGL-x86_EXTENDS = VBoxGL +VBoxGL-x86_BLD_TRG_ARCH = x86 +VBoxGL-x86_LIBS = \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxWddmUmHlp-x86$(VBOX_SUFF_LIB) \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaGalliumAuxLib-x86$(VBOX_SUFF_LIB) \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaWglLib-x86$(VBOX_SUFF_LIB) \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaUtilLib-x86$(VBOX_SUFF_LIB) \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaLib-x86$(VBOX_SUFF_LIB) +VBoxGL-x86_DEFS = $(VBoxGL_DEFS) VBOX_WOW64 + +include $(FILE_KBUILD_SUB_FOOTER) + diff --git a/src/VBox/Additions/3D/win/VBoxGL/VBoxGL.c b/src/VBox/Additions/3D/win/VBoxGL/VBoxGL.c new file mode 100644 index 00000000..01b6cf89 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxGL/VBoxGL.c @@ -0,0 +1,580 @@ +/* $Id: VBoxGL.c $ */ +/** @file + * VirtualBox Windows Guest Mesa3D - OpenGL driver. + */ + +/* + * Copyright (C) 2018-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#include "GaDrvEnvKMT.h" + +#include "stw_winsys.h" +#include "stw_device.h" +#include "stw_context.h" + +#include "pipe/p_state.h" +#include "svga3d_reg.h" + +#include <iprt/asm.h> + +#include <common/wddm/VBoxMPIf.h> + +#include <Psapi.h> + +static const char *g_pszSvgaDll = +#ifdef VBOX_WOW64 + "VBoxSVGA-x86.dll" +#else + "VBoxSVGA.dll" +#endif +; + +static struct GaDrvFunctions +{ + PFNGaDrvScreenCreate pfnGaDrvScreenCreate; + PFNGaDrvScreenDestroy pfnGaDrvScreenDestroy; + PFNGaDrvGetWDDMEnv pfnGaDrvGetWDDMEnv; + PFNGaDrvGetContextId pfnGaDrvGetContextId; + PFNGaDrvGetSurfaceId pfnGaDrvGetSurfaceId; + PFNGaDrvContextFlush pfnGaDrvContextFlush; +} g_drvfuncs; + + +static HMODULE gaDrvLoadSVGA(struct GaDrvFunctions *pDrvFuncs) +{ + struct VBOXWDDMDLLPROC aDrvProcs[] = + { + { "GaDrvScreenCreate", (FARPROC *)&pDrvFuncs->pfnGaDrvScreenCreate }, + { "GaDrvScreenDestroy", (FARPROC *)&pDrvFuncs->pfnGaDrvScreenDestroy }, + { "GaDrvGetWDDMEnv", (FARPROC *)&pDrvFuncs->pfnGaDrvGetWDDMEnv }, + { "GaDrvGetContextId", (FARPROC *)&pDrvFuncs->pfnGaDrvGetContextId }, + { "GaDrvGetSurfaceId", (FARPROC *)&pDrvFuncs->pfnGaDrvGetSurfaceId }, + { "GaDrvContextFlush", (FARPROC *)&pDrvFuncs->pfnGaDrvContextFlush }, + { NULL, NULL } + }; + + HMODULE hmod = VBoxWddmLoadSystemDll(g_pszSvgaDll); + if (hmod) + { + VBoxWddmLoadAdresses(hmod, aDrvProcs); + } + return hmod; +} + +struct stw_shared_surface +{ + D3DKMT_HANDLE hResource; + D3DKMT_HANDLE hSurface; + uint32_t u32Sid; +}; + +static NTSTATUS vboxKmtPresent(D3DKMT_HANDLE hContext, HWND hwnd, D3DKMT_HANDLE hSource, LONG lWidth, LONG lHeight) +{ + RECT r; + r.left = 0; + r.top = 0; + r.right = lWidth; + r.bottom = lHeight; + + D3DKMT_PRESENT PresentData; + memset(&PresentData, 0, sizeof(PresentData)); + PresentData.hContext = hContext; + PresentData.hWindow = hwnd; + PresentData.hSource = hSource; + PresentData.hDestination = 0; + PresentData.Flags.Blt = 1; + PresentData.Flags.SrcRectValid = 1; + PresentData.Flags.DstRectValid = 1; + PresentData.SrcRect = r; + PresentData.SubRectCnt = 1; + PresentData.pSrcSubRects = &r; + PresentData.DstRect = r; + + D3DKMTFUNCTIONS const *d3dkmt = D3DKMTFunctions(); + NTSTATUS Status = d3dkmt->pfnD3DKMTPresent(&PresentData); + return Status; +} + +NTSTATUS vboxKmtOpenSharedSurface(D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, D3DKMT_HANDLE hSharedSurface, struct stw_shared_surface *pSurf) +{ + D3DKMTFUNCTIONS const *d3dkmt = D3DKMTFunctions(); + + D3DKMT_QUERYRESOURCEINFO QueryResourceInfoData; + memset(&QueryResourceInfoData, 0, sizeof(QueryResourceInfoData)); + QueryResourceInfoData.hDevice = hDevice; + QueryResourceInfoData.hGlobalShare = hSharedSurface; + + NTSTATUS Status = d3dkmt->pfnD3DKMTQueryResourceInfo(&QueryResourceInfoData); + if (Status == STATUS_SUCCESS) + { + D3DDDI_OPENALLOCATIONINFO OpenAllocationInfoData; + memset(&OpenAllocationInfoData, 0, sizeof(OpenAllocationInfoData)); + + D3DKMT_OPENRESOURCE OpenResourceData; + memset(&OpenResourceData, 0, sizeof(OpenResourceData)); + OpenResourceData.hDevice = hDevice; + OpenResourceData.hGlobalShare = hSharedSurface; + OpenResourceData.NumAllocations = 1; + OpenResourceData.pOpenAllocationInfo = &OpenAllocationInfoData; + if (QueryResourceInfoData.PrivateRuntimeDataSize) + { + OpenResourceData.pPrivateRuntimeData = malloc(QueryResourceInfoData.PrivateRuntimeDataSize); + if (OpenResourceData.pPrivateRuntimeData == NULL) + { + Status = STATUS_NOT_SUPPORTED; + } + OpenResourceData.PrivateRuntimeDataSize = QueryResourceInfoData.PrivateRuntimeDataSize; + } + if (QueryResourceInfoData.ResourcePrivateDriverDataSize) + { + OpenResourceData.pResourcePrivateDriverData = malloc(QueryResourceInfoData.ResourcePrivateDriverDataSize); + if (OpenResourceData.pResourcePrivateDriverData == NULL) + { + Status = STATUS_NOT_SUPPORTED; + } + OpenResourceData.ResourcePrivateDriverDataSize = QueryResourceInfoData.ResourcePrivateDriverDataSize; + } + if (QueryResourceInfoData.TotalPrivateDriverDataSize) + { + OpenResourceData.pTotalPrivateDriverDataBuffer = malloc(QueryResourceInfoData.TotalPrivateDriverDataSize); + if (OpenResourceData.pTotalPrivateDriverDataBuffer == NULL) + { + Status = STATUS_NOT_SUPPORTED; + } + OpenResourceData.TotalPrivateDriverDataBufferSize = QueryResourceInfoData.TotalPrivateDriverDataSize; + } + + if (Status == STATUS_SUCCESS) + { + Status = d3dkmt->pfnD3DKMTOpenResource(&OpenResourceData); + if (Status == STATUS_SUCCESS) + { + if (OpenAllocationInfoData.PrivateDriverDataSize == sizeof(VBOXWDDM_ALLOCINFO)) + { + VBOXWDDM_ALLOCINFO *pVBoxAllocInfo = (VBOXWDDM_ALLOCINFO *)OpenAllocationInfoData.pPrivateDriverData; + pSurf->hResource = OpenResourceData.hResource; + pSurf->hSurface = OpenAllocationInfoData.hAllocation; + pSurf->u32Sid = pVBoxAllocInfo->hostID; + } + else if (OpenAllocationInfoData.PrivateDriverDataSize == sizeof(VBOXDXALLOCATIONDESC)) + { + //VBOXDXALLOCATIONDESC *pAllocDesc = (VBOXDXALLOCATIONDESC *)OpenAllocationInfoData.PrivateDriverDataSize; + pSurf->hResource = OpenResourceData.hResource; + pSurf->hSurface = OpenAllocationInfoData.hAllocation; + + VBOXDISPIFESCAPE_SVGAGETSID data; + memset(&data, 0, sizeof(data)); + data.EscapeHdr.escapeCode = VBOXESC_SVGAGETSID; + data.hAllocation = OpenAllocationInfoData.hAllocation; + // data.u32Sid = 0; + + D3DKMT_ESCAPE EscapeData; + memset(&EscapeData, 0, sizeof(EscapeData)); + EscapeData.hAdapter = hAdapter; + EscapeData.hDevice = hDevice; + EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; + // EscapeData.Flags.HardwareAccess = 0; + EscapeData.pPrivateDriverData = &data; + EscapeData.PrivateDriverDataSize = sizeof(data); + // EscapeData.hContext = 0; + Status = d3dkmt->pfnD3DKMTEscape(&EscapeData); + if (Status == STATUS_SUCCESS) + pSurf->u32Sid = data.u32Sid; + else + Assert(0); + } + else + Assert(0); + } + } + + if (OpenResourceData.pPrivateRuntimeData != NULL) + { + free(OpenResourceData.pPrivateRuntimeData); + } + if (OpenResourceData.pResourcePrivateDriverData != NULL) + { + free(OpenResourceData.pResourcePrivateDriverData); + } + if (OpenResourceData.pTotalPrivateDriverDataBuffer != NULL) + { + free(OpenResourceData.pTotalPrivateDriverDataBuffer); + } + } + + return Status; +} + +NTSTATUS vboxKmtCloseSharedSurface(D3DKMT_HANDLE hDevice, struct stw_shared_surface *pSurf) +{ + D3DKMTFUNCTIONS const *d3dkmt = D3DKMTFunctions(); + + D3DKMT_DESTROYALLOCATION DestroyAllocationData; + memset(&DestroyAllocationData, 0, sizeof(DestroyAllocationData)); + DestroyAllocationData.hDevice = hDevice; + DestroyAllocationData.hResource = pSurf->hResource; + /* "If the OpenGL ICD sets the handle in the hResource member to a non-NULL value, + * the ICD must set phAllocationList to NULL." and + * "the AllocationCount member is ignored by the OpenGL runtime." + */ + // DestroyAllocationData.phAllocationList = NULL; + // DestroyAllocationData.AllocationCount = 0; + + NTSTATUS Status = d3dkmt->pfnD3DKMTDestroyAllocation(&DestroyAllocationData); + Assert(Status == STATUS_SUCCESS); + return Status; +} + + +static struct pipe_screen * +wddm_screen_create(HDC hDC) +{ + RT_NOREF(hDC); /** @todo Use it? */ + struct pipe_screen *screen = NULL; + + if (gaDrvLoadSVGA(&g_drvfuncs)) + { + WDDMGalliumDriverEnv const *pEnv = GaDrvEnvKmtCreate(); + if (pEnv) + { + /// @todo pEnv to include destructor callback, to be called from winsys screen destructor? + screen = g_drvfuncs.pfnGaDrvScreenCreate(pEnv); + } + } + + return screen; +} + +static void +wddm_present(struct pipe_screen *screen, + struct pipe_context *context, + struct pipe_resource *res, + HDC hDC) +{ + RT_NOREF(context); + struct stw_context *ctx = stw_current_context(); + struct pipe_context *pipe = ctx->st->pipe; + + const WDDMGalliumDriverEnv *pEnv = g_drvfuncs.pfnGaDrvGetWDDMEnv(screen); + if (pEnv) + { + /* Get context and kernel-mode handle of the resource. */ + uint32_t u32Cid = g_drvfuncs.pfnGaDrvGetContextId(pipe); + D3DKMT_HANDLE hContext = GaDrvEnvKmtContextHandle(pEnv, u32Cid); + + uint32_t u32SourceSid = g_drvfuncs.pfnGaDrvGetSurfaceId(screen, res); + D3DKMT_HANDLE hSource = GaDrvEnvKmtSurfaceHandle(pEnv, u32SourceSid); + + HWND hwnd = WindowFromDC(hDC); + + vboxKmtPresent(hContext, hwnd, hSource, res->width0, res->height0); + } +} + +static boolean +wddm_get_adapter_luid(struct pipe_screen *screen, + HDC hDC, + LUID *pAdapterLuid) +{ + RT_NOREF(hDC); /** @todo Use it? */ + const WDDMGalliumDriverEnv *pEnv = g_drvfuncs.pfnGaDrvGetWDDMEnv(screen); + if (pEnv) + { + GaDrvEnvKmtAdapterLUID(pEnv, pAdapterLuid); + return true; + } + + return false; +} + +static struct stw_shared_surface * +wddm_shared_surface_open(struct pipe_screen *screen, + HANDLE hSharedSurface) +{ + struct stw_shared_surface *surface = NULL; + + const WDDMGalliumDriverEnv *pEnv = g_drvfuncs.pfnGaDrvGetWDDMEnv(screen); + if (pEnv) + { + surface = (struct stw_shared_surface *)malloc(sizeof(struct stw_shared_surface)); + if (surface) + { + D3DKMT_HANDLE hAdapter = GaDrvEnvKmtAdapterHandle(pEnv); + D3DKMT_HANDLE hDevice = GaDrvEnvKmtDeviceHandle(pEnv); + NTSTATUS Status = vboxKmtOpenSharedSurface(hAdapter, hDevice, (D3DKMT_HANDLE)(uintptr_t)hSharedSurface, surface); + if (Status != STATUS_SUCCESS) + { + free(surface); + surface = NULL; + } + } + } + return surface; +} + +static void +wddm_shared_surface_close(struct pipe_screen *screen, + struct stw_shared_surface *surface) +{ + const WDDMGalliumDriverEnv *pEnv = g_drvfuncs.pfnGaDrvGetWDDMEnv(screen); + if (pEnv) + { + D3DKMT_HANDLE hDevice = GaDrvEnvKmtDeviceHandle(pEnv); + vboxKmtCloseSharedSurface(hDevice, surface); + } + free(surface); +} + +static void +wddm_compose(struct pipe_screen *screen, + struct pipe_resource *res, + struct stw_shared_surface *dest, + LPCRECT pRect, + ULONGLONG PresentHistoryToken) +{ + struct stw_context *ctx = stw_current_context(); + struct pipe_context *pipe = ctx->st->pipe; + + /* The ICD asked to present something, make sure that any outstanding commends are submitted. */ + g_drvfuncs.pfnGaDrvContextFlush(pipe); + + uint32_t u32SourceSid = g_drvfuncs.pfnGaDrvGetSurfaceId(screen, res); + + /* Generate SVGA_3D_CMD_SURFACE_COPY command for these resources. */ + struct + { + SVGA3dCmdHeader header; + SVGA3dCmdSurfaceCopy surfaceCopy; + SVGA3dCopyBox box; + } command; + + command.header.id = SVGA_3D_CMD_SURFACE_COPY; + command.header.size = sizeof(command) - sizeof(SVGA3dCmdHeader); + + command.surfaceCopy.src.sid = u32SourceSid; + command.surfaceCopy.src.face = 0; + command.surfaceCopy.src.mipmap = 0; + command.surfaceCopy.dest.sid = dest->u32Sid; + command.surfaceCopy.dest.face = 0; + command.surfaceCopy.dest.mipmap = 0; + + command.box.x = pRect->left; + command.box.y = pRect->top; + command.box.z = 0; + command.box.w = pRect->right - pRect->left; + command.box.h = pRect->bottom - pRect->top; + command.box.d = 1; + command.box.srcx = 0; + command.box.srcy = 0; + command.box.srcz = 0; + + const WDDMGalliumDriverEnv *pEnv = g_drvfuncs.pfnGaDrvGetWDDMEnv(screen); + if (pEnv) + { + uint32_t u32Cid = g_drvfuncs.pfnGaDrvGetContextId(pipe); + GaDrvEnvKmtRenderCompose(pEnv, u32Cid, &command, sizeof(command), PresentHistoryToken); + } +} + +static unsigned +wddm_get_pfd_flags(struct pipe_screen *screen) +{ + (void)screen; + return stw_pfd_gdi_support | stw_pfd_double_buffer; +} + +static const char * +wddm_get_name(void) +{ + return "VBoxGL"; +} + +static const struct stw_winsys stw_winsys = { + wddm_screen_create, + wddm_present, + wddm_get_adapter_luid, + wddm_shared_surface_open, + wddm_shared_surface_close, + wddm_compose, + wddm_get_pfd_flags, + NULL, /* create_framebuffer */ + wddm_get_name, +}; + +#ifdef DEBUG +typedef BOOL WINAPI FNGetModuleInformation(HANDLE hProcess, HMODULE hModule, LPMODULEINFO lpmodinfo, DWORD cb); +typedef FNGetModuleInformation *PFNGetModuleInformation; + +static PFNGetModuleInformation g_pfnGetModuleInformation = NULL; +static HMODULE g_hModPsapi = NULL; +static PVOID g_VBoxWDbgVEHandler = NULL; + +static bool vboxVDbgIsAddressInModule(PVOID pv, const char *pszModuleName) +{ + HMODULE hMod = GetModuleHandleA(pszModuleName); + if (!hMod) + return false; + + if (!g_pfnGetModuleInformation) + return false; + + HANDLE hProcess = GetCurrentProcess(); + MODULEINFO ModuleInfo = {0}; + if (!g_pfnGetModuleInformation(hProcess, hMod, &ModuleInfo, sizeof(ModuleInfo))) + return false; + + return (uintptr_t)ModuleInfo.lpBaseOfDll <= (uintptr_t)pv + && (uintptr_t)pv < (uintptr_t)ModuleInfo.lpBaseOfDll + ModuleInfo.SizeOfImage; +} + +static bool vboxVDbgIsExceptionIgnored(PEXCEPTION_RECORD pExceptionRecord) +{ + /* Module (dll) names for GetModuleHandle. + * Exceptions originated from these modules will be ignored. + */ + static const char *apszIgnoredModuleNames[] = + { + NULL + }; + + int i = 0; + while (apszIgnoredModuleNames[i]) + { + if (vboxVDbgIsAddressInModule(pExceptionRecord->ExceptionAddress, apszIgnoredModuleNames[i])) + return true; + + ++i; + } + + return false; +} + +static LONG WINAPI vboxVDbgVectoredHandler(struct _EXCEPTION_POINTERS *pExceptionInfo) RT_NOTHROW_DEF +{ + static volatile bool g_fAllowIgnore = true; /* Might be changed in kernel debugger. */ + + PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord; + /* PCONTEXT pContextRecord = pExceptionInfo->ContextRecord; */ + + switch (pExceptionRecord->ExceptionCode) + { + default: + break; + case EXCEPTION_BREAKPOINT: + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_STACK_OVERFLOW: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_FLT_DIVIDE_BY_ZERO: + case EXCEPTION_FLT_INVALID_OPERATION: + case EXCEPTION_INT_DIVIDE_BY_ZERO: + case EXCEPTION_ILLEGAL_INSTRUCTION: + if (g_fAllowIgnore && vboxVDbgIsExceptionIgnored(pExceptionRecord)) + break; + ASMBreakpoint(); + break; + case 0x40010006: /* OutputDebugStringA? */ + case 0x4001000a: /* OutputDebugStringW? */ + break; + } + return EXCEPTION_CONTINUE_SEARCH; +} + +static void vboxVDbgVEHandlerRegister(void) +{ + Assert(!g_VBoxWDbgVEHandler); + g_VBoxWDbgVEHandler = AddVectoredExceptionHandler(1, vboxVDbgVectoredHandler); + Assert(g_VBoxWDbgVEHandler); + + g_hModPsapi = GetModuleHandleA("Psapi.dll"); /* Usually already loaded. */ + if (g_hModPsapi) + g_pfnGetModuleInformation = (PFNGetModuleInformation)GetProcAddress(g_hModPsapi, "GetModuleInformation"); +} + +static void vboxVDbgVEHandlerUnregister(void) +{ + Assert(g_VBoxWDbgVEHandler); + ULONG uResult = RemoveVectoredExceptionHandler(g_VBoxWDbgVEHandler); + Assert(uResult); RT_NOREF(uResult); + g_VBoxWDbgVEHandler = NULL; + + g_hModPsapi = NULL; + g_pfnGetModuleInformation = NULL; +} +#endif /* DEBUG */ + +BOOL WINAPI DllMain(HINSTANCE hDLLInst, + DWORD fdwReason, + LPVOID lpvReserved) +{ + RT_NOREF2(hDLLInst, lpvReserved); + + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: +#ifdef DEBUG + vboxVDbgVEHandlerRegister(); +#endif + D3DKMTLoad(); + stw_init(&stw_winsys); + stw_init_thread(); + break; + + case DLL_PROCESS_DETACH: +#ifdef DEBUG + vboxVDbgVEHandlerUnregister(); +#endif + break; + + case DLL_THREAD_ATTACH: + stw_init_thread(); + break; + + case DLL_THREAD_DETACH: + stw_cleanup_thread(); + break; + + default: + if (lpvReserved == NULL) + { + // We're being unloaded from the process. + stw_cleanup_thread(); + stw_cleanup(); + } + else + { + // Process itself is terminating, and all threads and modules are + // being detached. + // + // The order threads (including llvmpipe rasterizer threads) are + // destroyed can not be relied up, so it's not safe to cleanup. + // + // However global destructors (e.g., LLVM's) will still be called, and + // if Microsoft OPENGL32.DLL's DllMain is called after us, it will + // still try to invoke DrvDeleteContext to destroys all outstanding, + // so set stw_dev to NULL to return immediately if that happens. + stw_dev = NULL; + } + break; + } + + return TRUE; +} diff --git a/src/VBox/Additions/3D/win/VBoxGL/VBoxGL.rc b/src/VBox/Additions/3D/win/VBoxGL/VBoxGL.rc new file mode 100644 index 00000000..6c96f47e --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxGL/VBoxGL.rc @@ -0,0 +1,66 @@ +/* $Id: VBoxGL.rc $ */ +/** @file + * VBoxGL - Resource file containing version info and icon. + */ + +/* + * Copyright (C) 2018-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#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 OpenGL Mesa State Tracker\0" + VALUE "InternalName", "VBoxGL\0" +#ifdef VBOX_WOW64 + VALUE "OriginalFilename", "VBoxGL-x86.DLL\0" +#else + VALUE "OriginalFilename", "VBoxGL.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 diff --git a/src/VBox/Additions/3D/win/VBoxICD/.scm-settings b/src/VBox/Additions/3D/win/VBoxICD/.scm-settings new file mode 100644 index 00000000..f4fffd8f --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxICD/.scm-settings @@ -0,0 +1,29 @@ +# $Id: .scm-settings $ +## @file +# Source code massager settings for VBoxGL. +# + +# +# Copyright (C) 2010-2023 Oracle and/or its affiliates. +# +# This file is part of VirtualBox base platform packages, as +# available from https://www.virtualbox.org. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, in version 3 of the +# License. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see <https://www.gnu.org/licenses>. +# +# SPDX-License-Identifier: GPL-3.0-only +# + + +--filter-out-files "opengl32*def" diff --git a/src/VBox/Additions/3D/win/VBoxICD/Makefile.kmk b/src/VBox/Additions/3D/win/VBoxICD/Makefile.kmk new file mode 100644 index 00000000..93434205 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxICD/Makefile.kmk @@ -0,0 +1,85 @@ +# $Id: Makefile.kmk $ +## @file +# Sub-Makefile for OpenGL ICD loader. +# + +# +# Copyright (C) 2018-2023 Oracle and/or its affiliates. +# +# This file is part of VirtualBox base platform packages, as +# available from https://www.virtualbox.org. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, in version 3 of the +# License. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see <https://www.gnu.org/licenses>. +# +# SPDX-License-Identifier: GPL-3.0-only +# + +SUB_DEPTH = ../../../../../.. +include $(KBUILD_PATH)/subheader.kmk + +VBOX_GL_ICD_DEF_FILE = $(PATH_ROOT)/src/VBox/Additions/3D/win/VBoxICD/opengl32.mingw.def + +DLLS += VBoxICD +DLLS.amd64 += VBoxICD-x86 + +VBoxICD_TEMPLATE = VBoxMesa3DGuestR3DllMinVista +# -wd4005: '__useHeader' : redefinition +VBoxICD_CFLAGS := -wd4005 +if "$(VBOX_NEWER_VCC_TOOL_STEM)" >= "VCC141" + # -wd4255: 'PFND3DKMT_CHECKEXCLUSIVEOWNERSHIP': no function prototype given: converting '()' to '(void)' + VBoxICD_CFLAGS += -wd4255 +endif + +VBoxICD_INCS = \ + $(VBOX_PATH_3D)/win/include \ + $(PATH_ROOT)/src/VBox/Additions/WINNT/Graphics/Video \ + $(PATH_ROOT)/src/VBox/Devices/Graphics/vmsvga_include \ + $(VBOX_GRAPHICS_INCS) +VBoxICD_SOURCES = \ + opengl32.def \ + $(VBoxICD_0_OUTDIR)/forwarders.asm \ + $(VBoxICD_0_OUTDIR)/pfns.c \ + VBoxICD.c \ + VBoxICD.rc +VBoxICD_CLEAN = \ + $(VBoxICD_0_OUTDIR)/forwarders.asm \ + $(VBoxICD_0_OUTDIR)/pfns.c +VBoxICD_LIBS = \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxWddmUmHlp$(VBOX_SUFF_LIB) + +$$(VBoxICD_0_OUTDIR)/forwarders.asm: \ + $(PATH_SUB_CURRENT)/icd_forwarders.py $(VBOX_GL_ICD_DEF_FILE) | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$(VBOX_GL_ICD_DEF_FILE)) + $(QUIET)$(VBOX_BLD_PYTHON) $< $(VBOX_GL_ICD_DEF_FILE) $@ +$$(VBoxICD_0_OUTDIR)/pfns.c: \ + $(PATH_SUB_CURRENT)/icd_pfns.py $(VBOX_GL_ICD_DEF_FILE) | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$(VBOX_GL_ICD_DEF_FILE)) + $(QUIET)$(VBOX_BLD_PYTHON) $< $(VBOX_GL_ICD_DEF_FILE) $@ + +if defined(VBOX_SIGNING_MODE) && defined(VBOX_SIGN_ADDITIONS) + VBoxICD_INSTTYPE = none + VBoxICD_DEBUG_INSTTYPE = both +endif + +# +# x86 version built for amd64 build +# +VBoxICD-x86_EXTENDS = VBoxICD +VBoxICD-x86_BLD_TRG_ARCH = x86 +VBoxICD-x86_LIBS = \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxWddmUmHlp-x86$(VBOX_SUFF_LIB) +VBoxICD-x86_DEFS = $(VBoxICD_DEFS) VBOX_WOW64 + +include $(FILE_KBUILD_SUB_FOOTER) + diff --git a/src/VBox/Additions/3D/win/VBoxICD/VBoxICD.c b/src/VBox/Additions/3D/win/VBoxICD/VBoxICD.c new file mode 100644 index 00000000..cc5aa9ad --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxICD/VBoxICD.c @@ -0,0 +1,165 @@ +/* $Id: VBoxICD.c $ */ +/** @file + * VirtualBox Windows Guest Mesa3D - OpenGL driver loader. + */ + +/* + * Copyright (C) 2018-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#include <VBoxWddmUmHlp.h> + +#include <common/wddm/VBoxMPIf.h> + +static const char *g_pszGalliumDll = +#ifdef VBOX_WOW64 + "VBoxGL-x86.dll" +#else + "VBoxGL.dll" +#endif +; + +static const char *g_pszChromiumDll = +#ifdef VBOX_WOW64 + "VBoxOGL-x86.dll" +#else + "VBoxOGL.dll" +#endif +; + +extern struct VBOXWDDMDLLPROC aIcdProcs[]; + +HMODULE volatile g_hmodICD = NULL; + +static NTSTATUS +vboxDdiQueryAdapterInfo(D3DKMT_HANDLE hAdapter, + VBOXWDDM_QAI *pAdapterInfo, + uint32_t cbAdapterInfo) +{ + NTSTATUS Status; + D3DKMTFUNCTIONS const *d3dkmt = D3DKMTFunctions(); + + if (d3dkmt->pfnD3DKMTQueryAdapterInfo) + { + D3DKMT_QUERYADAPTERINFO QAI; + memset(&QAI, 0, sizeof(QAI)); + QAI.hAdapter = hAdapter; + QAI.Type = KMTQAITYPE_UMDRIVERPRIVATE; + QAI.pPrivateDriverData = pAdapterInfo; + QAI.PrivateDriverDataSize = cbAdapterInfo; + + Status = d3dkmt->pfnD3DKMTQueryAdapterInfo(&QAI); + } + else + { + Status = STATUS_NOT_SUPPORTED; + } + + return Status; +} + +void VBoxLoadICD(void) +{ + NTSTATUS Status; + D3DKMT_HANDLE hAdapter = 0; + + D3DKMTLoad(); + + Status = vboxDispKmtOpenAdapter(&hAdapter); + if (Status == STATUS_SUCCESS) + { + VBOXWDDM_QAI adapterInfo; + Status = vboxDdiQueryAdapterInfo(hAdapter, &adapterInfo, sizeof(adapterInfo)); + if (Status == STATUS_SUCCESS) + { + const char *pszDll = NULL; + switch (adapterInfo.enmHwType) + { + case VBOXVIDEO_HWTYPE_VBOX: pszDll = g_pszChromiumDll; break; + default: + case VBOXVIDEO_HWTYPE_VMSVGA: pszDll = g_pszGalliumDll; break; + } + + if (pszDll) + { + g_hmodICD = VBoxWddmLoadSystemDll(pszDll); + if (g_hmodICD) + { + VBoxWddmLoadAdresses(g_hmodICD, aIcdProcs); + } + } + } + + vboxDispKmtCloseAdapter(hAdapter); + } +} + +/* + * MSDN says: + * "You should never perform the following tasks from within DllMain: + * Call LoadLibrary or LoadLibraryEx (either directly or indirectly)." + * + * However it turned out that loading the real ICD from DLL_PROCESS_ATTACH works, + * and loading it in a lazy way fails for unknown reason on 64 bit Windows. + * + * So just call VBoxLoadICD from DLL_PROCESS_ATTACH. + */ +BOOL WINAPI DllMain(HINSTANCE hDLLInst, + DWORD fdwReason, + LPVOID lpvReserved) +{ + RT_NOREF(hDLLInst); + + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + VBoxLoadICD(); + break; + + case DLL_PROCESS_DETACH: + if (lpvReserved == NULL) + { + /* "The DLL is being unloaded because of a call to FreeLibrary." */ + if (g_hmodICD) + { + FreeLibrary(g_hmodICD); + g_hmodICD = NULL; + } + } + else + { + /* "The DLL is being unloaded due to process termination." */ + /* Do not bother. */ + } + break; + + case DLL_THREAD_ATTACH: + break; + + case DLL_THREAD_DETACH: + break; + + default: + break; + } + + return TRUE; +} diff --git a/src/VBox/Additions/3D/win/VBoxICD/VBoxICD.rc b/src/VBox/Additions/3D/win/VBoxICD/VBoxICD.rc new file mode 100644 index 00000000..80ef8df7 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxICD/VBoxICD.rc @@ -0,0 +1,66 @@ +/* $Id: VBoxICD.rc $ */ +/** @file + * VBoxGL - Resource file containing version info and icon. + */ + +/* + * Copyright (C) 2018-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#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 OpenGL ICD Loader\0" + VALUE "InternalName", "VBoxICD\0" +#ifdef VBOX_WOW64 + VALUE "OriginalFilename", "VBoxICD-x86.dll\0" +#else + VALUE "OriginalFilename", "VBoxICD.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 diff --git a/src/VBox/Additions/3D/win/VBoxICD/icd_forwarders.py b/src/VBox/Additions/3D/win/VBoxICD/icd_forwarders.py new file mode 100755 index 00000000..c9ffe2f5 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxICD/icd_forwarders.py @@ -0,0 +1,105 @@ +""" +Copyright (C) 2018-2023 Oracle and/or its affiliates. + +This file is part of VirtualBox base platform packages, as +available from https://www.virtualbox.org. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation, in version 3 of the +License. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, see <https://www.gnu.org/licenses>. + +SPDX-License-Identifier: GPL-3.0-only +""" + +import sys + +def GenerateForwarders(): + + # Get list of functions. + exports_file = open(sys.argv[1], "r") + if not exports_file: + print("Error: couldn't open %s file!" % filename) + sys.exit() + + names = [] + cbArgs = [] + for line in exports_file.readlines(): + line = line.strip() + if len(line) > 0 and line[0] != ';' and line != 'EXPORTS': + # Parse 'glAccum = glAccum@8' + words = line.split('=', 1) + + # Function name + names.append(words[0].strip()) + + # Size of arguments in bytes + words = words[1].split('@') + cbArgs.append(words[1].strip()) + + exports_file.close() + + + # + # Assembler forwarders + # + asm_file = open(sys.argv[2], "w") + if not asm_file: + print("Error: couldn't open %s file!" % filename) + sys.exit() + + asm_file.write('%include "iprt/asmdefs.mac"\n') + asm_file.write('\n') + asm_file.write(';;;; Enable ICD_LAZY_LOAD to lazy load the ICD DLL (does not work on Win64)\n') + asm_file.write('; %define ICD_LAZY_LOAD 1\n') + asm_file.write('\n') + asm_file.write('%ifdef RT_ARCH_AMD64\n') + asm_file.write('%define PTR_SIZE_PREFIX qword\n') + asm_file.write('%else ; X86\n') + asm_file.write('%define PTR_SIZE_PREFIX dword\n') + asm_file.write('%endif\n') + asm_file.write('\n') + asm_file.write('%ifdef ICD_LAZY_LOAD\n') + asm_file.write('extern NAME(VBoxLoadICD)\n') + asm_file.write('%endif\n') + asm_file.write('extern NAME(g_hmodICD)\n') + + for index in range(len(names)): + fn = names[index] + cbRet = cbArgs[index] + asm_file.write('\n') + asm_file.write('BEGINPROC_EXPORTED %s\n' % fn) + asm_file.write(' extern NAME(pfn_%s)\n' % fn) + asm_file.write('; int3\n') + asm_file.write('%ifdef ICD_LAZY_LOAD\n') + asm_file.write(' mov xAX, PTR_SIZE_PREFIX NAME(g_hmodICD)\n') + asm_file.write(' mov xAX, [xAX]\n') + asm_file.write(' or xAX, xAX\n') + asm_file.write(' jnz l_icd_loaded_%s\n' % fn) + asm_file.write(' call NAME(VBoxLoadICD)\n') + asm_file.write('l_icd_loaded_%s:\n' % fn) + asm_file.write('%endif\n') + asm_file.write(' mov xAX, PTR_SIZE_PREFIX NAME(pfn_%s)\n' % fn) + asm_file.write(' mov xAX, [xAX]\n') + asm_file.write(' or xAX, xAX\n') + asm_file.write(' jnz l_jmp_to_%s\n' % fn) + asm_file.write('%ifdef RT_ARCH_AMD64\n') + asm_file.write(' ret\n') + asm_file.write('%else ; X86\n') + asm_file.write(' ret %s\n' % cbRet) + asm_file.write('%endif\n') + asm_file.write('l_jmp_to_%s:\n' % fn) + asm_file.write(' jmp xAX\n') + asm_file.write('ENDPROC %s\n' % fn) + + asm_file.close() + +GenerateForwarders() diff --git a/src/VBox/Additions/3D/win/VBoxICD/icd_pfns.py b/src/VBox/Additions/3D/win/VBoxICD/icd_pfns.py new file mode 100755 index 00000000..7099a714 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxICD/icd_pfns.py @@ -0,0 +1,73 @@ +""" +Copyright (C) 2018-2023 Oracle and/or its affiliates. + +This file is part of VirtualBox base platform packages, as +available from https://www.virtualbox.org. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation, in version 3 of the +License. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, see <https://www.gnu.org/licenses>. + +SPDX-License-Identifier: GPL-3.0-only +""" + +import sys + +def GeneratePfns(): + + # Get list of functions. + exports_file = open(sys.argv[1], "r") + if not exports_file: + print("Error: couldn't open %s file!" % filename) + sys.exit() + + names = [] + for line in exports_file.readlines(): + line = line.strip() + if len(line) > 0 and line[0] != ';' and line != 'EXPORTS': + # Parse 'glAccum = glAccum@8' + words = line.split('=') + + # Function name + names.append(words[0].strip()) + + exports_file.close() + + + # + # C loader data + # + c_file = open(sys.argv[2], "w") + if not c_file: + print("Error: couldn't open %s file!" % filename) + sys.exit() + + c_file.write('#include <iprt/win/windows.h>\n') + c_file.write('#include <VBoxWddmUmHlp.h>\n') + c_file.write('\n') + + for index in range(len(names)): + fn = names[index] + c_file.write('FARPROC pfn_%s;\n' % fn) + c_file.write('\n') + + c_file.write("struct VBOXWDDMDLLPROC aIcdProcs[] =\n") + c_file.write('{\n') + for index in range(len(names)): + fn = names[index] + c_file.write(' { "%s", &pfn_%s },\n' % (fn, fn) ) + c_file.write(' { NULL, NULL }\n') + c_file.write('};\n') + + c_file.close() + +GeneratePfns() diff --git a/src/VBox/Additions/3D/win/VBoxICD/opengl32.def b/src/VBox/Additions/3D/win/VBoxICD/opengl32.def new file mode 100644 index 00000000..c35c23b5 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxICD/opengl32.def @@ -0,0 +1,388 @@ +EXPORTS +; GlmfBeginGlsBlock +; GlmfCloseMetaFile +; GlmfEndGlsBlock +; GlmfEndPlayback +; GlmfInitPlayback +; GlmfPlayGlsRecord + glAccum + glAlphaFunc + glAreTexturesResident + glArrayElement + glBegin + glBindTexture + glBitmap + glBlendFunc + glCallList + glCallLists + glClear + glClearAccum + glClearColor + glClearDepth + glClearIndex + glClearStencil + glClipPlane + glColor3b + glColor3bv + glColor3d + glColor3dv + glColor3f + glColor3fv + glColor3i + glColor3iv + glColor3s + glColor3sv + glColor3ub + glColor3ubv + glColor3ui + glColor3uiv + glColor3us + glColor3usv + glColor4b + glColor4bv + glColor4d + glColor4dv + glColor4f + glColor4fv + glColor4i + glColor4iv + glColor4s + glColor4sv + glColor4ub + glColor4ubv + glColor4ui + glColor4uiv + glColor4us + glColor4usv + glColorMask + glColorMaterial + glColorPointer + glCopyPixels + glCopyTexImage1D + glCopyTexImage2D + glCopyTexSubImage1D + glCopyTexSubImage2D + glCullFace +; glDebugEntry + glDeleteLists + glDeleteTextures + glDepthFunc + glDepthMask + glDepthRange + glDisable + glDisableClientState + glDrawArrays + glDrawBuffer + glDrawElements + glDrawPixels + glEdgeFlag + glEdgeFlagPointer + glEdgeFlagv + glEnable + glEnableClientState + glEnd + glEndList + glEvalCoord1d + glEvalCoord1dv + glEvalCoord1f + glEvalCoord1fv + glEvalCoord2d + glEvalCoord2dv + glEvalCoord2f + glEvalCoord2fv + glEvalMesh1 + glEvalMesh2 + glEvalPoint1 + glEvalPoint2 + glFeedbackBuffer + glFinish + glFlush + glFogf + glFogfv + glFogi + glFogiv + glFrontFace + glFrustum + glGenLists + glGenTextures + glGetBooleanv + glGetClipPlane + glGetDoublev + glGetError + glGetFloatv + glGetIntegerv + glGetLightfv + glGetLightiv + glGetMapdv + glGetMapfv + glGetMapiv + glGetMaterialfv + glGetMaterialiv + glGetPixelMapfv + glGetPixelMapuiv + glGetPixelMapusv + glGetPointerv + glGetPolygonStipple + glGetString + glGetTexEnvfv + glGetTexEnviv + glGetTexGendv + glGetTexGenfv + glGetTexGeniv + glGetTexImage + glGetTexLevelParameterfv + glGetTexLevelParameteriv + glGetTexParameterfv + glGetTexParameteriv + glHint + glIndexMask + glIndexPointer + glIndexd + glIndexdv + glIndexf + glIndexfv + glIndexi + glIndexiv + glIndexs + glIndexsv + glIndexub + glIndexubv + glInitNames + glInterleavedArrays + glIsEnabled + glIsList + glIsTexture + glLightModelf + glLightModelfv + glLightModeli + glLightModeliv + glLightf + glLightfv + glLighti + glLightiv + glLineStipple + glLineWidth + glListBase + glLoadIdentity + glLoadMatrixd + glLoadMatrixf + glLoadName + glLogicOp + glMap1d + glMap1f + glMap2d + glMap2f + glMapGrid1d + glMapGrid1f + glMapGrid2d + glMapGrid2f + glMaterialf + glMaterialfv + glMateriali + glMaterialiv + glMatrixMode + glMultMatrixd + glMultMatrixf + glNewList + glNormal3b + glNormal3bv + glNormal3d + glNormal3dv + glNormal3f + glNormal3fv + glNormal3i + glNormal3iv + glNormal3s + glNormal3sv + glNormalPointer + glOrtho + glPassThrough + glPixelMapfv + glPixelMapuiv + glPixelMapusv + glPixelStoref + glPixelStorei + glPixelTransferf + glPixelTransferi + glPixelZoom + glPointSize + glPolygonMode + glPolygonOffset + glPolygonStipple + glPopAttrib + glPopClientAttrib + glPopMatrix + glPopName + glPrioritizeTextures + glPushAttrib + glPushClientAttrib + glPushMatrix + glPushName + glRasterPos2d + glRasterPos2dv + glRasterPos2f + glRasterPos2fv + glRasterPos2i + glRasterPos2iv + glRasterPos2s + glRasterPos2sv + glRasterPos3d + glRasterPos3dv + glRasterPos3f + glRasterPos3fv + glRasterPos3i + glRasterPos3iv + glRasterPos3s + glRasterPos3sv + glRasterPos4d + glRasterPos4dv + glRasterPos4f + glRasterPos4fv + glRasterPos4i + glRasterPos4iv + glRasterPos4s + glRasterPos4sv + glReadBuffer + glReadPixels + glRectd + glRectdv + glRectf + glRectfv + glRecti + glRectiv + glRects + glRectsv + glRenderMode + glRotated + glRotatef + glScaled + glScalef + glScissor + glSelectBuffer + glShadeModel + glStencilFunc + glStencilMask + glStencilOp + glTexCoord1d + glTexCoord1dv + glTexCoord1f + glTexCoord1fv + glTexCoord1i + glTexCoord1iv + glTexCoord1s + glTexCoord1sv + glTexCoord2d + glTexCoord2dv + glTexCoord2f + glTexCoord2fv + glTexCoord2i + glTexCoord2iv + glTexCoord2s + glTexCoord2sv + glTexCoord3d + glTexCoord3dv + glTexCoord3f + glTexCoord3fv + glTexCoord3i + glTexCoord3iv + glTexCoord3s + glTexCoord3sv + glTexCoord4d + glTexCoord4dv + glTexCoord4f + glTexCoord4fv + glTexCoord4i + glTexCoord4iv + glTexCoord4s + glTexCoord4sv + glTexCoordPointer + glTexEnvf + glTexEnvfv + glTexEnvi + glTexEnviv + glTexGend + glTexGendv + glTexGenf + glTexGenfv + glTexGeni + glTexGeniv + glTexImage1D + glTexImage2D + glTexParameterf + glTexParameterfv + glTexParameteri + glTexParameteriv + glTexSubImage1D + glTexSubImage2D + glTranslated + glTranslatef + glVertex2d + glVertex2dv + glVertex2f + glVertex2fv + glVertex2i + glVertex2iv + glVertex2s + glVertex2sv + glVertex3d + glVertex3dv + glVertex3f + glVertex3fv + glVertex3i + glVertex3iv + glVertex3s + glVertex3sv + glVertex4d + glVertex4dv + glVertex4f + glVertex4fv + glVertex4i + glVertex4iv + glVertex4s + glVertex4sv + glVertexPointer + glViewport + wglChoosePixelFormat + wglCopyContext + wglCreateContext + wglCreateLayerContext + wglDeleteContext + wglDescribeLayerPlane + wglDescribePixelFormat + wglGetCurrentContext + wglGetCurrentDC +; wglGetDefaultProcAddress + wglGetLayerPaletteEntries + wglGetPixelFormat + wglGetProcAddress + wglMakeCurrent + wglRealizeLayerPalette + wglSetLayerPaletteEntries + wglSetPixelFormat + wglShareLists + wglSwapBuffers + wglSwapLayerBuffers + wglSwapMultipleBuffers + wglUseFontBitmapsA + wglUseFontBitmapsW + wglUseFontOutlinesA + wglUseFontOutlinesW + DrvCopyContext + DrvCreateContext + DrvCreateLayerContext + DrvDeleteContext + DrvDescribeLayerPlane + DrvDescribePixelFormat + DrvGetLayerPaletteEntries + DrvGetProcAddress + DrvPresentBuffers + DrvRealizeLayerPalette + DrvReleaseContext + DrvSetCallbackProcs + DrvSetContext + DrvSetLayerPaletteEntries + DrvSetPixelFormat + DrvShareLists + DrvSwapBuffers + DrvSwapLayerBuffers + DrvValidateVersion diff --git a/src/VBox/Additions/3D/win/VBoxICD/opengl32.mingw.def b/src/VBox/Additions/3D/win/VBoxICD/opengl32.mingw.def new file mode 100644 index 00000000..0bceee06 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxICD/opengl32.mingw.def @@ -0,0 +1,388 @@ +EXPORTS +; GlmfBeginGlsBlock = GlmfBeginGlsBlock@4 +; GlmfCloseMetaFile = GlmfCloseMetaFile@4 +; GlmfEndGlsBlock = GlmfEndGlsBlock@4 +; GlmfEndPlayback = GlmfEndPlayback@4 +; GlmfInitPlayback = GlmfInitPlayback@12 +; GlmfPlayGlsRecord = GlmfPlayGlsRecord@16 + glAccum = glAccum@8 + glAlphaFunc = glAlphaFunc@8 + glAreTexturesResident = glAreTexturesResident@12 + glArrayElement = glArrayElement@4 + glBegin = glBegin@4 + glBindTexture = glBindTexture@8 + glBitmap = glBitmap@28 + glBlendFunc = glBlendFunc@8 + glCallList = glCallList@4 + glCallLists = glCallLists@12 + glClear = glClear@4 + glClearAccum = glClearAccum@16 + glClearColor = glClearColor@16 + glClearDepth = glClearDepth@8 + glClearIndex = glClearIndex@4 + glClearStencil = glClearStencil@4 + glClipPlane = glClipPlane@8 + glColor3b = glColor3b@12 + glColor3bv = glColor3bv@4 + glColor3d = glColor3d@24 + glColor3dv = glColor3dv@4 + glColor3f = glColor3f@12 + glColor3fv = glColor3fv@4 + glColor3i = glColor3i@12 + glColor3iv = glColor3iv@4 + glColor3s = glColor3s@12 + glColor3sv = glColor3sv@4 + glColor3ub = glColor3ub@12 + glColor3ubv = glColor3ubv@4 + glColor3ui = glColor3ui@12 + glColor3uiv = glColor3uiv@4 + glColor3us = glColor3us@12 + glColor3usv = glColor3usv@4 + glColor4b = glColor4b@16 + glColor4bv = glColor4bv@4 + glColor4d = glColor4d@32 + glColor4dv = glColor4dv@4 + glColor4f = glColor4f@16 + glColor4fv = glColor4fv@4 + glColor4i = glColor4i@16 + glColor4iv = glColor4iv@4 + glColor4s = glColor4s@16 + glColor4sv = glColor4sv@4 + glColor4ub = glColor4ub@16 + glColor4ubv = glColor4ubv@4 + glColor4ui = glColor4ui@16 + glColor4uiv = glColor4uiv@4 + glColor4us = glColor4us@16 + glColor4usv = glColor4usv@4 + glColorMask = glColorMask@16 + glColorMaterial = glColorMaterial@8 + glColorPointer = glColorPointer@16 + glCopyPixels = glCopyPixels@20 + glCopyTexImage1D = glCopyTexImage1D@28 + glCopyTexImage2D = glCopyTexImage2D@32 + glCopyTexSubImage1D = glCopyTexSubImage1D@24 + glCopyTexSubImage2D = glCopyTexSubImage2D@32 + glCullFace = glCullFace@4 +; glDebugEntry = glDebugEntry@8 + glDeleteLists = glDeleteLists@8 + glDeleteTextures = glDeleteTextures@8 + glDepthFunc = glDepthFunc@4 + glDepthMask = glDepthMask@4 + glDepthRange = glDepthRange@16 + glDisable = glDisable@4 + glDisableClientState = glDisableClientState@4 + glDrawArrays = glDrawArrays@12 + glDrawBuffer = glDrawBuffer@4 + glDrawElements = glDrawElements@16 + glDrawPixels = glDrawPixels@20 + glEdgeFlag = glEdgeFlag@4 + glEdgeFlagPointer = glEdgeFlagPointer@8 + glEdgeFlagv = glEdgeFlagv@4 + glEnable = glEnable@4 + glEnableClientState = glEnableClientState@4 + glEnd = glEnd@0 + glEndList = glEndList@0 + glEvalCoord1d = glEvalCoord1d@8 + glEvalCoord1dv = glEvalCoord1dv@4 + glEvalCoord1f = glEvalCoord1f@4 + glEvalCoord1fv = glEvalCoord1fv@4 + glEvalCoord2d = glEvalCoord2d@16 + glEvalCoord2dv = glEvalCoord2dv@4 + glEvalCoord2f = glEvalCoord2f@8 + glEvalCoord2fv = glEvalCoord2fv@4 + glEvalMesh1 = glEvalMesh1@12 + glEvalMesh2 = glEvalMesh2@20 + glEvalPoint1 = glEvalPoint1@4 + glEvalPoint2 = glEvalPoint2@8 + glFeedbackBuffer = glFeedbackBuffer@12 + glFinish = glFinish@0 + glFlush = glFlush@0 + glFogf = glFogf@8 + glFogfv = glFogfv@8 + glFogi = glFogi@8 + glFogiv = glFogiv@8 + glFrontFace = glFrontFace@4 + glFrustum = glFrustum@48 + glGenLists = glGenLists@4 + glGenTextures = glGenTextures@8 + glGetBooleanv = glGetBooleanv@8 + glGetClipPlane = glGetClipPlane@8 + glGetDoublev = glGetDoublev@8 + glGetError = glGetError@0 + glGetFloatv = glGetFloatv@8 + glGetIntegerv = glGetIntegerv@8 + glGetLightfv = glGetLightfv@12 + glGetLightiv = glGetLightiv@12 + glGetMapdv = glGetMapdv@12 + glGetMapfv = glGetMapfv@12 + glGetMapiv = glGetMapiv@12 + glGetMaterialfv = glGetMaterialfv@12 + glGetMaterialiv = glGetMaterialiv@12 + glGetPixelMapfv = glGetPixelMapfv@8 + glGetPixelMapuiv = glGetPixelMapuiv@8 + glGetPixelMapusv = glGetPixelMapusv@8 + glGetPointerv = glGetPointerv@8 + glGetPolygonStipple = glGetPolygonStipple@4 + glGetString = glGetString@4 + glGetTexEnvfv = glGetTexEnvfv@12 + glGetTexEnviv = glGetTexEnviv@12 + glGetTexGendv = glGetTexGendv@12 + glGetTexGenfv = glGetTexGenfv@12 + glGetTexGeniv = glGetTexGeniv@12 + glGetTexImage = glGetTexImage@20 + glGetTexLevelParameterfv = glGetTexLevelParameterfv@16 + glGetTexLevelParameteriv = glGetTexLevelParameteriv@16 + glGetTexParameterfv = glGetTexParameterfv@12 + glGetTexParameteriv = glGetTexParameteriv@12 + glHint = glHint@8 + glIndexMask = glIndexMask@4 + glIndexPointer = glIndexPointer@12 + glIndexd = glIndexd@8 + glIndexdv = glIndexdv@4 + glIndexf = glIndexf@4 + glIndexfv = glIndexfv@4 + glIndexi = glIndexi@4 + glIndexiv = glIndexiv@4 + glIndexs = glIndexs@4 + glIndexsv = glIndexsv@4 + glIndexub = glIndexub@4 + glIndexubv = glIndexubv@4 + glInitNames = glInitNames@0 + glInterleavedArrays = glInterleavedArrays@12 + glIsEnabled = glIsEnabled@4 + glIsList = glIsList@4 + glIsTexture = glIsTexture@4 + glLightModelf = glLightModelf@8 + glLightModelfv = glLightModelfv@8 + glLightModeli = glLightModeli@8 + glLightModeliv = glLightModeliv@8 + glLightf = glLightf@12 + glLightfv = glLightfv@12 + glLighti = glLighti@12 + glLightiv = glLightiv@12 + glLineStipple = glLineStipple@8 + glLineWidth = glLineWidth@4 + glListBase = glListBase@4 + glLoadIdentity = glLoadIdentity@0 + glLoadMatrixd = glLoadMatrixd@4 + glLoadMatrixf = glLoadMatrixf@4 + glLoadName = glLoadName@4 + glLogicOp = glLogicOp@4 + glMap1d = glMap1d@32 + glMap1f = glMap1f@24 + glMap2d = glMap2d@56 + glMap2f = glMap2f@40 + glMapGrid1d = glMapGrid1d@20 + glMapGrid1f = glMapGrid1f@12 + glMapGrid2d = glMapGrid2d@40 + glMapGrid2f = glMapGrid2f@24 + glMaterialf = glMaterialf@12 + glMaterialfv = glMaterialfv@12 + glMateriali = glMateriali@12 + glMaterialiv = glMaterialiv@12 + glMatrixMode = glMatrixMode@4 + glMultMatrixd = glMultMatrixd@4 + glMultMatrixf = glMultMatrixf@4 + glNewList = glNewList@8 + glNormal3b = glNormal3b@12 + glNormal3bv = glNormal3bv@4 + glNormal3d = glNormal3d@24 + glNormal3dv = glNormal3dv@4 + glNormal3f = glNormal3f@12 + glNormal3fv = glNormal3fv@4 + glNormal3i = glNormal3i@12 + glNormal3iv = glNormal3iv@4 + glNormal3s = glNormal3s@12 + glNormal3sv = glNormal3sv@4 + glNormalPointer = glNormalPointer@12 + glOrtho = glOrtho@48 + glPassThrough = glPassThrough@4 + glPixelMapfv = glPixelMapfv@12 + glPixelMapuiv = glPixelMapuiv@12 + glPixelMapusv = glPixelMapusv@12 + glPixelStoref = glPixelStoref@8 + glPixelStorei = glPixelStorei@8 + glPixelTransferf = glPixelTransferf@8 + glPixelTransferi = glPixelTransferi@8 + glPixelZoom = glPixelZoom@8 + glPointSize = glPointSize@4 + glPolygonMode = glPolygonMode@8 + glPolygonOffset = glPolygonOffset@8 + glPolygonStipple = glPolygonStipple@4 + glPopAttrib = glPopAttrib@0 + glPopClientAttrib = glPopClientAttrib@0 + glPopMatrix = glPopMatrix@0 + glPopName = glPopName@0 + glPrioritizeTextures = glPrioritizeTextures@12 + glPushAttrib = glPushAttrib@4 + glPushClientAttrib = glPushClientAttrib@4 + glPushMatrix = glPushMatrix@0 + glPushName = glPushName@4 + glRasterPos2d = glRasterPos2d@16 + glRasterPos2dv = glRasterPos2dv@4 + glRasterPos2f = glRasterPos2f@8 + glRasterPos2fv = glRasterPos2fv@4 + glRasterPos2i = glRasterPos2i@8 + glRasterPos2iv = glRasterPos2iv@4 + glRasterPos2s = glRasterPos2s@8 + glRasterPos2sv = glRasterPos2sv@4 + glRasterPos3d = glRasterPos3d@24 + glRasterPos3dv = glRasterPos3dv@4 + glRasterPos3f = glRasterPos3f@12 + glRasterPos3fv = glRasterPos3fv@4 + glRasterPos3i = glRasterPos3i@12 + glRasterPos3iv = glRasterPos3iv@4 + glRasterPos3s = glRasterPos3s@12 + glRasterPos3sv = glRasterPos3sv@4 + glRasterPos4d = glRasterPos4d@32 + glRasterPos4dv = glRasterPos4dv@4 + glRasterPos4f = glRasterPos4f@16 + glRasterPos4fv = glRasterPos4fv@4 + glRasterPos4i = glRasterPos4i@16 + glRasterPos4iv = glRasterPos4iv@4 + glRasterPos4s = glRasterPos4s@16 + glRasterPos4sv = glRasterPos4sv@4 + glReadBuffer = glReadBuffer@4 + glReadPixels = glReadPixels@28 + glRectd = glRectd@32 + glRectdv = glRectdv@8 + glRectf = glRectf@16 + glRectfv = glRectfv@8 + glRecti = glRecti@16 + glRectiv = glRectiv@8 + glRects = glRects@16 + glRectsv = glRectsv@8 + glRenderMode = glRenderMode@4 + glRotated = glRotated@32 + glRotatef = glRotatef@16 + glScaled = glScaled@24 + glScalef = glScalef@12 + glScissor = glScissor@16 + glSelectBuffer = glSelectBuffer@8 + glShadeModel = glShadeModel@4 + glStencilFunc = glStencilFunc@12 + glStencilMask = glStencilMask@4 + glStencilOp = glStencilOp@12 + glTexCoord1d = glTexCoord1d@8 + glTexCoord1dv = glTexCoord1dv@4 + glTexCoord1f = glTexCoord1f@4 + glTexCoord1fv = glTexCoord1fv@4 + glTexCoord1i = glTexCoord1i@4 + glTexCoord1iv = glTexCoord1iv@4 + glTexCoord1s = glTexCoord1s@4 + glTexCoord1sv = glTexCoord1sv@4 + glTexCoord2d = glTexCoord2d@16 + glTexCoord2dv = glTexCoord2dv@4 + glTexCoord2f = glTexCoord2f@8 + glTexCoord2fv = glTexCoord2fv@4 + glTexCoord2i = glTexCoord2i@8 + glTexCoord2iv = glTexCoord2iv@4 + glTexCoord2s = glTexCoord2s@8 + glTexCoord2sv = glTexCoord2sv@4 + glTexCoord3d = glTexCoord3d@24 + glTexCoord3dv = glTexCoord3dv@4 + glTexCoord3f = glTexCoord3f@12 + glTexCoord3fv = glTexCoord3fv@4 + glTexCoord3i = glTexCoord3i@12 + glTexCoord3iv = glTexCoord3iv@4 + glTexCoord3s = glTexCoord3s@12 + glTexCoord3sv = glTexCoord3sv@4 + glTexCoord4d = glTexCoord4d@32 + glTexCoord4dv = glTexCoord4dv@4 + glTexCoord4f = glTexCoord4f@16 + glTexCoord4fv = glTexCoord4fv@4 + glTexCoord4i = glTexCoord4i@16 + glTexCoord4iv = glTexCoord4iv@4 + glTexCoord4s = glTexCoord4s@16 + glTexCoord4sv = glTexCoord4sv@4 + glTexCoordPointer = glTexCoordPointer@16 + glTexEnvf = glTexEnvf@12 + glTexEnvfv = glTexEnvfv@12 + glTexEnvi = glTexEnvi@12 + glTexEnviv = glTexEnviv@12 + glTexGend = glTexGend@16 + glTexGendv = glTexGendv@12 + glTexGenf = glTexGenf@12 + glTexGenfv = glTexGenfv@12 + glTexGeni = glTexGeni@12 + glTexGeniv = glTexGeniv@12 + glTexImage1D = glTexImage1D@32 + glTexImage2D = glTexImage2D@36 + glTexParameterf = glTexParameterf@12 + glTexParameterfv = glTexParameterfv@12 + glTexParameteri = glTexParameteri@12 + glTexParameteriv = glTexParameteriv@12 + glTexSubImage1D = glTexSubImage1D@28 + glTexSubImage2D = glTexSubImage2D@36 + glTranslated = glTranslated@24 + glTranslatef = glTranslatef@12 + glVertex2d = glVertex2d@16 + glVertex2dv = glVertex2dv@4 + glVertex2f = glVertex2f@8 + glVertex2fv = glVertex2fv@4 + glVertex2i = glVertex2i@8 + glVertex2iv = glVertex2iv@4 + glVertex2s = glVertex2s@8 + glVertex2sv = glVertex2sv@4 + glVertex3d = glVertex3d@24 + glVertex3dv = glVertex3dv@4 + glVertex3f = glVertex3f@12 + glVertex3fv = glVertex3fv@4 + glVertex3i = glVertex3i@12 + glVertex3iv = glVertex3iv@4 + glVertex3s = glVertex3s@12 + glVertex3sv = glVertex3sv@4 + glVertex4d = glVertex4d@32 + glVertex4dv = glVertex4dv@4 + glVertex4f = glVertex4f@16 + glVertex4fv = glVertex4fv@4 + glVertex4i = glVertex4i@16 + glVertex4iv = glVertex4iv@4 + glVertex4s = glVertex4s@16 + glVertex4sv = glVertex4sv@4 + glVertexPointer = glVertexPointer@16 + glViewport = glViewport@16 + wglChoosePixelFormat = wglChoosePixelFormat@8 + wglCopyContext = wglCopyContext@12 + wglCreateContext = wglCreateContext@4 + wglCreateLayerContext = wglCreateLayerContext@8 + wglDeleteContext = wglDeleteContext@4 + wglDescribeLayerPlane = wglDescribeLayerPlane@20 + wglDescribePixelFormat = wglDescribePixelFormat@16 + wglGetCurrentContext = wglGetCurrentContext@0 + wglGetCurrentDC = wglGetCurrentDC@0 +; wglGetDefaultProcAddress = wglGetDefaultProcAddress@4 + wglGetLayerPaletteEntries = wglGetLayerPaletteEntries@20 + wglGetPixelFormat = wglGetPixelFormat@4 + wglGetProcAddress = wglGetProcAddress@4 + wglMakeCurrent = wglMakeCurrent@8 + wglRealizeLayerPalette = wglRealizeLayerPalette@12 + wglSetLayerPaletteEntries = wglSetLayerPaletteEntries@20 + wglSetPixelFormat = wglSetPixelFormat@12 + wglShareLists = wglShareLists@8 + wglSwapBuffers = wglSwapBuffers@4 + wglSwapLayerBuffers = wglSwapLayerBuffers@8 + wglSwapMultipleBuffers = wglSwapMultipleBuffers@8 + wglUseFontBitmapsA = wglUseFontBitmapsA@16 + wglUseFontBitmapsW = wglUseFontBitmapsW@16 + wglUseFontOutlinesA = wglUseFontOutlinesA@32 + wglUseFontOutlinesW = wglUseFontOutlinesW@32 + DrvCopyContext = DrvCopyContext@12 + DrvCreateContext = DrvCreateContext@4 + DrvCreateLayerContext = DrvCreateLayerContext@8 + DrvDeleteContext = DrvDeleteContext@4 + DrvDescribeLayerPlane = DrvDescribeLayerPlane@20 + DrvDescribePixelFormat = DrvDescribePixelFormat@16 + DrvGetLayerPaletteEntries = DrvGetLayerPaletteEntries@20 + DrvGetProcAddress = DrvGetProcAddress@4 + DrvPresentBuffers = DrvPresentBuffers@8 + DrvRealizeLayerPalette = DrvRealizeLayerPalette@12 + DrvReleaseContext = DrvReleaseContext@4 + DrvSetCallbackProcs = DrvSetCallbackProcs@8 + DrvSetContext = DrvSetContext@12 + DrvSetLayerPaletteEntries = DrvSetLayerPaletteEntries@20 + DrvSetPixelFormat = DrvSetPixelFormat@8 + DrvShareLists = DrvShareLists@8 + DrvSwapBuffers = DrvSwapBuffers@4 + DrvSwapLayerBuffers = DrvSwapLayerBuffers@8 + DrvValidateVersion = DrvValidateVersion@4 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..43f4906b --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxNine/Makefile.kmk @@ -0,0 +1,74 @@ +# $Id: Makefile.kmk $ +## @file +# Sub-Makefile for VBoxNine D3D9 state tracker. +# + +# +# Copyright (C) 2016-2023 Oracle and/or its affiliates. +# +# This file is part of VirtualBox base platform packages, as +# available from https://www.virtualbox.org. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, in version 3 of the +# License. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see <https://www.gnu.org/licenses>. +# +# SPDX-License-Identifier: GPL-3.0-only +# + +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/frontends/nine +VBoxNine_SOURCES = \ + nine/nine_memory_helper.c \ + 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)/VBoxMesaLib$(VBOX_SUFF_LIB) \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaUtilLib$(VBOX_SUFF_LIB) \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaNineLib$(VBOX_SUFF_LIB) + +if defined(VBOX_SIGNING_MODE) && defined(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)/VBoxMesaLib-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..59b73db6 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxNine/VBoxNine.c @@ -0,0 +1,181 @@ +/* $Id: VBoxNine.c $ */ +/** @file + * VirtualBox Windows Guest Mesa3D - Direct3D9 state tracker. + */ + +/* + * Copyright (C) 2016-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#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.hal = s; + /** @todo Need software device here. Currently assigned to hw device to prevent NineDevice9_ctor crash. */ + ctx->base.ref = ctx->base.hal; + // D3DADAPTER_IDENTIFIER9 identifier; + ctx->base.linear_framebuffer = TRUE; + ctx->base.throttling = FALSE; + ctx->base.throttling_value = 0; + ctx->base.vblank_mode = 1; + ctx->base.thread_submit = FALSE; + ctx->base.discard_delayed_release = FALSE; + ctx->base.tearfree_discard = FALSE; + ctx->base.csmt_force = FALSE; + ctx->base.dynamic_texture_workaround = FALSE; + ctx->base.shader_inline_constants = FALSE; + ctx->base.memfd_virtualsizelimit = -1; + ctx->base.override_vram_size = -1; + ctx->base.destroy = wddm_destroy; + + + /* 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..5197ba7b --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxNine/VBoxNine.def @@ -0,0 +1,34 @@ +; $Id: VBoxNine.def $; +;; @file +; Export definition file for the VBoxNine D3D9 state tracker. +; + +; +; Copyright (C) 2016-2023 Oracle and/or its affiliates. +; +; This file is part of VirtualBox base platform packages, as +; available from https://www.virtualbox.org. +; +; This program is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation, in version 3 of the +; License. +; +; This program is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program; if not, see <https://www.gnu.org/licenses>. +; +; SPDX-License-Identifier: GPL-3.0-only +; + +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..4ad22662 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxNine/VBoxNine.rc @@ -0,0 +1,66 @@ +/* $Id: VBoxNine.rc $ */ +/** @file + * VBoxNine - Resource file containing version info and icon. + */ + +/* + * Copyright (C) 2016-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#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 diff --git a/src/VBox/Additions/3D/win/VBoxNine/nine/nine_memory_helper.c b/src/VBox/Additions/3D/win/VBoxNine/nine/nine_memory_helper.c new file mode 100644 index 00000000..9fe5c652 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxNine/nine/nine_memory_helper.c @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2016-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +/* + * Copyright 2020 Axel Davy <davyaxel0@gmail.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#include "util/list.h" +#include "util/u_memory.h" +#include "util/slab.h" + +#include "nine_debug.h" +#include "nine_memory_helper.h" +#include "nine_state.h" + +#include <iprt/win/windows.h> + +#define DIVUP(a,b) (((a)+(b)-1)/(b)) + +/* Required alignment for allocations */ +#define NINE_ALLOCATION_ALIGNMENT 32 + +#define DBG_CHANNEL (DBG_BASETEXTURE|DBG_SURFACE|DBG_VOLUME|DBG_TEXTURE|DBG_CUBETEXTURE) + +struct nine_allocation { + unsigned is_external; + void *external; +}; + +struct nine_allocator { + struct slab_mempool external_allocation_pool; + CRITICAL_SECTION mutex_slab; +}; + +struct nine_allocation * +nine_allocate(struct nine_allocator *allocator, unsigned size) +{ + struct nine_allocation *allocation; + (void)allocator; + assert(sizeof(struct nine_allocation) <= NINE_ALLOCATION_ALIGNMENT); + allocation = align_calloc(size + NINE_ALLOCATION_ALIGNMENT, NINE_ALLOCATION_ALIGNMENT); + allocation->is_external = false; + return allocation; +} + + +void nine_free(struct nine_allocator *allocator, struct nine_allocation *allocation) +{ + if (allocation->is_external) { + EnterCriticalSection(&allocator->mutex_slab); + slab_free_st(&allocator->external_allocation_pool, allocation); + LeaveCriticalSection(&allocator->mutex_slab); + } else + align_free(allocation); +} + +void nine_free_worker(struct nine_allocator *allocator, struct nine_allocation *allocation) +{ + nine_free(allocator, allocation); +} + +void *nine_get_pointer(struct nine_allocator *allocator, struct nine_allocation *allocation) +{ + (void)allocator; + if (allocation->is_external) + return allocation->external; + return (uint8_t *)allocation + NINE_ALLOCATION_ALIGNMENT; +} + +void nine_pointer_weakrelease(struct nine_allocator *allocator, struct nine_allocation *allocation) +{ + (void)allocator; + (void)allocation; +} + +void nine_pointer_strongrelease(struct nine_allocator *allocator, struct nine_allocation *allocation) +{ + (void)allocator; + (void)allocation; +} + +void nine_pointer_delayedstrongrelease(struct nine_allocator *allocator, + struct nine_allocation *allocation, + unsigned *counter) +{ + (void)allocator; + (void)allocation; + (void)counter; +} + +struct nine_allocation * +nine_suballocate(struct nine_allocator* allocator, struct nine_allocation *allocation, int offset) +{ + struct nine_allocation *new_allocation; + EnterCriticalSection(&allocator->mutex_slab); + new_allocation = slab_alloc_st(&allocator->external_allocation_pool); + LeaveCriticalSection(&allocator->mutex_slab); + new_allocation->is_external = true; + if (allocation->is_external) + new_allocation->external = (uint8_t *)allocation->external + offset; + else + new_allocation->external = (uint8_t *)allocation + NINE_ALLOCATION_ALIGNMENT + offset; + return new_allocation; +} + +struct nine_allocation * +nine_wrap_external_pointer(struct nine_allocator* allocator, void* data) +{ + struct nine_allocation *new_allocation; + EnterCriticalSection(&allocator->mutex_slab); + new_allocation = slab_alloc_st(&allocator->external_allocation_pool); + LeaveCriticalSection(&allocator->mutex_slab); + new_allocation->is_external = true; + new_allocation->external = data; + return new_allocation; +} + +struct nine_allocator * +nine_allocator_create(struct NineDevice9 *device, int memfd_virtualsizelimit) +{ + struct nine_allocator* allocator = MALLOC(sizeof(struct nine_allocator)); + (void)device; + (void)memfd_virtualsizelimit; + + if (!allocator) + return NULL; + + slab_create(&allocator->external_allocation_pool, sizeof(struct nine_allocation), 4096); + InitializeCriticalSection(&allocator->mutex_slab); + + return allocator; +} + +void +nine_allocator_destroy(struct nine_allocator *allocator) +{ + slab_destroy(&allocator->external_allocation_pool); + DeleteCriticalSection(&allocator->mutex_slab); +} diff --git a/src/VBox/Additions/3D/win/VBoxSVGA/.scm-settings b/src/VBox/Additions/3D/win/VBoxSVGA/.scm-settings new file mode 100644 index 00000000..5e0d6e61 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxSVGA/.scm-settings @@ -0,0 +1,28 @@ +# $Id: .scm-settings $ +## @file +# Source code massager settings for VBoxSVGA. +# + +# +# Copyright (C) 2010-2023 Oracle and/or its affiliates. +# +# This file is part of VirtualBox base platform packages, as +# available from https://www.virtualbox.org. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, in version 3 of the +# License. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see <https://www.gnu.org/licenses>. +# +# SPDX-License-Identifier: GPL-3.0-only +# + +/winsys/*.c: --no-convert-tabs --no-strip-trailing-blanks diff --git a/src/VBox/Additions/3D/win/VBoxSVGA/Makefile.kmk b/src/VBox/Additions/3D/win/VBoxSVGA/Makefile.kmk new file mode 100644 index 00000000..1c7c710d --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxSVGA/Makefile.kmk @@ -0,0 +1,85 @@ +# $Id: Makefile.kmk $ +## @file +# Sub-Makefile for VBoxSVGA hardware driver. +# + +# +# Copyright (C) 2016-2023 Oracle and/or its affiliates. +# +# This file is part of VirtualBox base platform packages, as +# available from https://www.virtualbox.org. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, in version 3 of the +# License. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see <https://www.gnu.org/licenses>. +# +# SPDX-License-Identifier: GPL-3.0-only +# + +SUB_DEPTH = ../../../../../.. +include $(KBUILD_PATH)/subheader.kmk + +DLLS += VBoxSVGA +DLLS.amd64 += VBoxSVGA-x86 + +VBoxSVGA_TEMPLATE = VBoxMesa3DGuestR3DllMinVista +# -wd4005: vcc120: '__useHeader' : macro redefinition +# -wd4100: unreferenced formal parameter +# -wd4200: nonstandard extension used : zero-sized array in struct/union +# -wd4204: vmw_screen_ioctl.c(392): warning C4204: nonstandard extension used: non-constant aggregate initializer +# -wd4211: nonstandard extension used : redefined extern to static +# -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' +VBoxSVGA_CFLAGS = -wd4005 -wd4100 -wd4200 -wd4204 -wd4211 -wd4245 -wd4255 -wd4668 +VBoxSVGA_INCS = \ + $(VBoxSVGA_0_OUTDIR)/../VBoxMesaUtilLib/$(VBOX_MESA)/src \ + $(VBOX_PATH_3D)/win/include \ + $(VBOX_PATH_MESA)/src/gallium/drivers/svga \ + $(VBOX_PATH_MESA)/src/gallium/drivers/svga/include \ + $(VBOX_PATH_MESA)/src/gallium/winsys/svga/drm +VBoxSVGA_SOURCES = \ + winsys/vmw_screen.c \ + winsys/vmw_screen_wddm.c \ + winsys/vmw_screen_ioctl.c \ + VBoxSVGA.c \ + VBoxSVGA.rc \ + VBoxSVGA.def +VBoxSVGA_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)/VBoxMesaLib$(VBOX_SUFF_LIB) \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaSVGAWinsysLib$(VBOX_SUFF_LIB) \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaSVGALib$(VBOX_SUFF_LIB) + +if defined(VBOX_SIGNING_MODE) && defined(VBOX_SIGN_ADDITIONS) + VBoxSVGA_INSTTYPE = none + VBoxSVGA_DEBUG_INSTTYPE = both +endif + +# +# VBoxSVGA-x86 - x86 version of VBoxSVGA built for amd64 build +# +VBoxSVGA-x86_EXTENDS = VBoxSVGA +VBoxSVGA-x86_BLD_TRG_ARCH = x86 +VBoxSVGA-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)/VBoxMesaLib-x86$(VBOX_SUFF_LIB) \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaSVGAWinsysLib-x86$(VBOX_SUFF_LIB) \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxMesaSVGALib-x86$(VBOX_SUFF_LIB) +VBoxSVGA-x86_DEFS = $(VBoxSVGA_DEFS) VBOX_WOW64 + +include $(FILE_KBUILD_SUB_FOOTER) + diff --git a/src/VBox/Additions/3D/win/VBoxSVGA/VBoxSVGA.c b/src/VBox/Additions/3D/win/VBoxSVGA/VBoxSVGA.c new file mode 100644 index 00000000..f140d7bb --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxSVGA/VBoxSVGA.c @@ -0,0 +1,146 @@ +/* $Id: VBoxSVGA.c $ */ +/** @file + * VirtualBox Windows Guest Mesa3D - VMSVGA hardware driver. + */ + +/* + * Copyright (C) 2016-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#include <VBoxWddmUmHlp.h> + +#include "svga_public.h" +#include "svga_screen.h" +#include "pipe/p_screen.h" +#include "pipe/p_context.h" +#include "frontend/drm_driver.h" + +#include "wddm_screen.h" + +struct svga_winsys_screen * +svga_wddm_winsys_screen_create(const WDDMGalliumDriverEnv *pEnv); + +struct pipe_screen * WINAPI +GaDrvScreenCreate(const WDDMGalliumDriverEnv *pEnv) +{ + struct svga_winsys_screen *sws = svga_wddm_winsys_screen_create(pEnv); + if (sws) + return svga_screen_create(sws); + return NULL; +} + +void WINAPI +GaDrvScreenDestroy(struct pipe_screen *s) +{ + if (s) + s->destroy(s); +} + +uint32_t WINAPI +GaDrvGetSurfaceId(struct pipe_screen *pScreen, struct pipe_resource *pResource) +{ + uint32_t u32Sid = 0; + + if ( pScreen + && pResource) + { + /* Get the sid (surface id). */ + struct winsys_handle whandle; + memset(&whandle, 0, sizeof(whandle)); + whandle.type = WINSYS_HANDLE_TYPE_SHARED; + + if (pScreen->resource_get_handle(pScreen, NULL, pResource, &whandle, 0)) + { + u32Sid = (uint32_t)whandle.handle; + } + } + + return u32Sid; +} + +const WDDMGalliumDriverEnv *WINAPI +GaDrvGetWDDMEnv(struct pipe_screen *pScreen) +{ + HANDLE hAdapter = NULL; + + if (pScreen) + { + struct svga_screen *pSvgaScreen = svga_screen(pScreen); + struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)pSvgaScreen->sws; + + return vws_wddm->pEnv; + } + + return hAdapter; +} + +uint32_t WINAPI +GaDrvGetContextId(struct pipe_context *pPipeContext) +{ + uint32 u32Cid = ~0; + + if (pPipeContext) + { + struct svga_winsys_context *pSWC = svga_winsys_context(pPipeContext); + u32Cid = pSWC->cid; + } + + return u32Cid; +} + +void WINAPI +GaDrvContextFlush(struct pipe_context *pPipeContext) +{ + if (pPipeContext) + pPipeContext->flush(pPipeContext, NULL, PIPE_FLUSH_END_OF_FRAME); +} + +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/VBoxSVGA/VBoxSVGA.def b/src/VBox/Additions/3D/win/VBoxSVGA/VBoxSVGA.def new file mode 100644 index 00000000..4f161b98 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxSVGA/VBoxSVGA.def @@ -0,0 +1,36 @@ +; $Id: VBoxSVGA.def $ +;; @file +; Linker defintion file for the VBoxSVGA hardware driver. +; + +; +; Copyright (C) 2016-2023 Oracle and/or its affiliates. +; +; This file is part of VirtualBox base platform packages, as +; available from https://www.virtualbox.org. +; +; This program is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation, in version 3 of the +; License. +; +; This program is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program; if not, see <https://www.gnu.org/licenses>. +; +; SPDX-License-Identifier: GPL-3.0-only +; + +LIBRARY VBOXSVGA + +EXPORTS + GaDrvScreenCreate @1 + GaDrvScreenDestroy @2 + GaDrvGetWDDMEnv @3 + GaDrvGetContextId @4 + GaDrvGetSurfaceId @5 + GaDrvContextFlush @6 diff --git a/src/VBox/Additions/3D/win/VBoxSVGA/VBoxSVGA.rc b/src/VBox/Additions/3D/win/VBoxSVGA/VBoxSVGA.rc new file mode 100644 index 00000000..236c5dcd --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxSVGA/VBoxSVGA.rc @@ -0,0 +1,66 @@ +/* $Id: VBoxSVGA.rc $ */ +/** @file + * VBoxSVGA - Resource file containing version info and icon. + */ + +/* + * Copyright (C) 2016-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#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 VMSVGA Hardware Driver\0" + VALUE "InternalName", "VBoxSVGA\0" +#ifdef VBOX_WOW64 + VALUE "OriginalFilename", "VBoxSVGA-x86.DLL\0" +#else + VALUE "OriginalFilename", "VBoxSVGA.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 diff --git a/src/VBox/Additions/3D/win/VBoxSVGA/wddm_screen.h b/src/VBox/Additions/3D/win/VBoxSVGA/wddm_screen.h new file mode 100644 index 00000000..cad1eaae --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxSVGA/wddm_screen.h @@ -0,0 +1,47 @@ +/* $Id: wddm_screen.h $ */ +/** @file + * VirtualBox Windows Guest Mesa3D - VMSVGA hardware driver. + */ + +/* + * Copyright (C) 2016-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#ifndef GA_INCLUDED_SRC_3D_win_VBoxSVGA_wddm_screen_h +#define GA_INCLUDED_SRC_3D_win_VBoxSVGA_wddm_screen_h +#ifndef RT_WITHOUT_PRAGMA_ONCE +# pragma once +#endif + +#include <VBoxGaDriver.h> + +#include "vmw_screen.h" + +struct vmw_winsys_screen_wddm +{ + struct vmw_winsys_screen base; + + const WDDMGalliumDriverEnv *pEnv; + VBOXGAHWINFOSVGA HwInfo; +}; + +#endif /* !GA_INCLUDED_SRC_3D_win_VBoxSVGA_wddm_screen_h */ + diff --git a/src/VBox/Additions/3D/win/VBoxSVGA/winsys/Makefile.kup b/src/VBox/Additions/3D/win/VBoxSVGA/winsys/Makefile.kup new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxSVGA/winsys/Makefile.kup diff --git a/src/VBox/Additions/3D/win/VBoxSVGA/winsys/vmw_screen.c b/src/VBox/Additions/3D/win/VBoxSVGA/winsys/vmw_screen.c new file mode 100644 index 00000000..b96a37ce --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxSVGA/winsys/vmw_screen.c @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2016-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +/********************************************************** + * Copyright 2009-2015 VMware, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + **********************************************************/ + + +#include "../wddm_screen.h" +#include "vmw_fence.h" +#include "vmw_context.h" +#include "vmwgfx_drm.h" + +#include "util/os_file.h" +#include "util/u_memory.h" +#include "pipe/p_compiler.h" +#include "util/u_hash_table.h" + +/* Called from vmw_drm_create_screen(), creates and initializes the + * vmw_winsys_screen structure, which is the main entity in this + * module. + * First, check whether a vmw_winsys_screen object already exists for + * this device, and in that case return that one, making sure that we + * have our own file descriptor open to DRM. + */ + +struct vmw_winsys_screen_wddm * +vmw_winsys_create_wddm(const WDDMGalliumDriverEnv *pEnv) +{ + struct vmw_winsys_screen_wddm *vws_wddm; + struct vmw_winsys_screen *vws; + + if ( pEnv->pHWInfo == NULL + || pEnv->pHWInfo->u32HwType != VBOX_GA_HW_TYPE_VMSVGA) + return NULL; + + vws_wddm = CALLOC_STRUCT(vmw_winsys_screen_wddm); + vws = &vws_wddm->base; + if (!vws) + goto out_no_vws; + + vws_wddm->pEnv = pEnv; + vws_wddm->HwInfo = pEnv->pHWInfo->u.svga; + + vws->device = 0; /* not used */ + vws->open_count = 1; + vws->ioctl.drm_fd = -1; /* not used */ + vws->force_coherent = FALSE; + if (!vmw_ioctl_init(vws)) + goto out_no_ioctl; + + vws->base.have_gb_dma = !vws->force_coherent; + vws->base.need_to_rebind_resources = FALSE; + vws->base.have_transfer_from_buffer_cmd = vws->base.have_vgpu10; + vws->base.have_constant_buffer_offset_cmd = FALSE; + vws->cache_maps = FALSE; + vws->fence_ops = vmw_fence_ops_create(vws); + if (!vws->fence_ops) + goto out_no_fence_ops; + + if(!vmw_pools_init(vws)) + goto out_no_pools; + + if (!vmw_winsys_screen_init_svga(vws)) + goto out_no_svga; + + cnd_init(&vws->cs_cond); + mtx_init(&vws->cs_mutex, mtx_plain); + + return vws_wddm; +out_no_svga: + vmw_pools_cleanup(vws); +out_no_pools: + vws->fence_ops->destroy(vws->fence_ops); +out_no_fence_ops: + vmw_ioctl_cleanup(vws); +out_no_ioctl: + FREE(vws); +out_no_vws: + return NULL; +} + +void +vmw_winsys_destroy(struct vmw_winsys_screen *vws) +{ + if (--vws->open_count == 0) { + vmw_pools_cleanup(vws); + vws->fence_ops->destroy(vws->fence_ops); + vmw_ioctl_cleanup(vws); + mtx_destroy(&vws->cs_mutex); + cnd_destroy(&vws->cs_cond); + FREE(vws); + } +} diff --git a/src/VBox/Additions/3D/win/VBoxSVGA/winsys/vmw_screen_ioctl.c b/src/VBox/Additions/3D/win/VBoxSVGA/winsys/vmw_screen_ioctl.c new file mode 100644 index 00000000..106ff74a --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxSVGA/winsys/vmw_screen_ioctl.c @@ -0,0 +1,979 @@ +/* + * Copyright (C) 2016-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +/********************************************************** + * Copyright 2009-2015 VMware, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + **********************************************************/ + +/** + * @file + * + * Wrappers for DRM ioctl functionlaity used by the rest of the vmw + * drm winsys. + * + * Based on svgaicd_escape.c + */ + + +#include "svga_cmd.h" +#include "util/u_memory.h" +#include "util/u_math.h" +#include "svgadump/svga_dump.h" +#include "frontend/drm_driver.h" +#include "vmw_screen.h" +#include "vmw_context.h" +#include "vmw_fence.h" +#include "vmwgfx_drm.h" +#include "svga3d_caps.h" +#include "svga3d_reg.h" +#include "svga3d_surfacedefs.h" + +#include "../wddm_screen.h" +#include <iprt/asm.h> + +#define VMW_MAX_DEFAULT_TEXTURE_SIZE (128 * 1024 * 1024) +#define VMW_FENCE_TIMEOUT_SECONDS 3600UL + +#define SVGA3D_FLAGS_64(upper32, lower32) (((uint64_t)upper32 << 32) | lower32) +#define SVGA3D_FLAGS_UPPER_32(svga3d_flags) (svga3d_flags >> 32) +#define SVGA3D_FLAGS_LOWER_32(svga3d_flags) \ + (svga3d_flags & ((uint64_t)UINT32_MAX)) + +struct vmw_region +{ + uint32_t handle; + uint64_t map_handle; + void *data; + uint32_t map_count; + struct vmw_winsys_screen_wddm *vws_wddm; + uint32_t size; +}; + +uint32_t +vmw_region_size(struct vmw_region *region) +{ + return region->size; +} + +#if defined(__DragonFly__) || defined(__FreeBSD__) || \ + defined(__NetBSD__) || defined(__OpenBSD__) +#define ERESTART EINTR +#endif + +uint32 +vmw_ioctl_context_create(struct vmw_winsys_screen *vws) +{ + struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)vws; + return vws_wddm->pEnv->pfnContextCreate(vws_wddm->pEnv->pvEnv, false, false); +} + +uint32 +vmw_ioctl_extended_context_create(struct vmw_winsys_screen *vws, + boolean vgpu10) +{ + struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)vws; + return vws_wddm->pEnv->pfnContextCreate(vws_wddm->pEnv->pvEnv, true, vgpu10); +} + +void +vmw_ioctl_context_destroy(struct vmw_winsys_screen *vws, uint32 cid) +{ + struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)vws; + vws_wddm->pEnv->pfnContextDestroy(vws_wddm->pEnv->pvEnv, cid); +} + +uint32 +vmw_ioctl_surface_create(struct vmw_winsys_screen *vws, + SVGA3dSurface1Flags flags, + SVGA3dSurfaceFormat format, + unsigned usage, + SVGA3dSize size, + uint32_t numFaces, uint32_t numMipLevels, + unsigned sampleCount) +{ + struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)vws; + + GASURFCREATE createParms; + GASURFSIZE sizes[DRM_VMW_MAX_SURFACE_FACES* + DRM_VMW_MAX_MIP_LEVELS]; + GASURFSIZE *cur_size; + uint32_t iFace; + uint32_t iMipLevel; + uint32_t u32Sid; + int ret; + + RT_NOREF(sampleCount); + + memset(&createParms, 0, sizeof(createParms)); + createParms.flags = (uint32_t) flags; + createParms.format = (uint32_t) format; + createParms.usage = (uint32_t) usage; + + if (numFaces * numMipLevels >= GA_MAX_SURFACE_FACES*GA_MAX_MIP_LEVELS) { + return (uint32_t)-1; + } + cur_size = sizes; + for (iFace = 0; iFace < numFaces; ++iFace) { + SVGA3dSize mipSize = size; + + createParms.mip_levels[iFace] = numMipLevels; + for (iMipLevel = 0; iMipLevel < numMipLevels; ++iMipLevel) { + cur_size->cWidth = mipSize.width; + cur_size->cHeight = mipSize.height; + cur_size->cDepth = mipSize.depth; + cur_size->u32Reserved = 0; + mipSize.width = MAX2(mipSize.width >> 1, 1); + mipSize.height = MAX2(mipSize.height >> 1, 1); + mipSize.depth = MAX2(mipSize.depth >> 1, 1); + cur_size++; + } + } + for (iFace = numFaces; iFace < SVGA3D_MAX_SURFACE_FACES; ++iFace) { + createParms.mip_levels[iFace] = 0; + } + + ret = vws_wddm->pEnv->pfnSurfaceDefine(vws_wddm->pEnv->pvEnv, &createParms, &sizes[0], numFaces * numMipLevels, &u32Sid); + if (ret) { + return (uint32_t)-1; + } + + return u32Sid; +} + + +uint32 +vmw_ioctl_gb_surface_create(struct vmw_winsys_screen *vws, + SVGA3dSurfaceAllFlags flags, + SVGA3dSurfaceFormat format, + unsigned usage, + SVGA3dSize size, + uint32_t numFaces, + uint32_t numMipLevels, + unsigned sampleCount, + uint32_t buffer_handle, + SVGA3dMSPattern multisamplePattern, + SVGA3dMSQualityLevel qualityLevel, + struct vmw_region **p_region) +{ + struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)vws; + + struct vmw_region *region = NULL; + if (p_region) + { + region = CALLOC_STRUCT(vmw_region); + if (!region) + return SVGA3D_INVALID_ID; + } + + SVGAGBSURFCREATE createParms; + createParms.s.flags = flags; + createParms.s.format = format; + createParms.s.usage = usage; + createParms.s.size = size; + createParms.s.numFaces = numFaces; + createParms.s.numMipLevels = numMipLevels; + createParms.s.sampleCount = sampleCount; + createParms.s.multisamplePattern = multisamplePattern; + createParms.s.qualityLevel = qualityLevel; + if (buffer_handle) + createParms.gmrid = buffer_handle; + else + createParms.gmrid = SVGA3D_INVALID_ID; + createParms.u64UserAddress = 0; /* out */ + createParms.u32Sid = 0; /* out */ + + createParms.cbGB = svga3dsurface_get_serialized_size(format, + size, + numMipLevels, + numFaces); + + int ret = vws_wddm->pEnv->pfnGBSurfaceDefine(vws_wddm->pEnv->pvEnv, &createParms); + if (ret) + { + FREE(region); + return SVGA3D_INVALID_ID; + } + + if (p_region) + { + region->handle = createParms.gmrid; + region->map_handle = 0; + region->data = (void *)(uintptr_t)createParms.u64UserAddress; + region->map_count = 0; + region->size = createParms.cbGB; + region->vws_wddm = vws_wddm; + *p_region = region; + } + return createParms.u32Sid; +} + +/** + * vmw_ioctl_surface_req - Fill in a struct surface_req + * + * @vws: Winsys screen + * @whandle: Surface handle + * @req: The struct surface req to fill in + * @needs_unref: This call takes a kernel surface reference that needs to + * be unreferenced. + * + * Returns 0 on success, negative error type otherwise. + * Fills in the surface_req structure according to handle type and kernel + * capabilities. + */ +static int +vmw_ioctl_surface_req(const struct vmw_winsys_screen *vws, + const struct winsys_handle *whandle, + struct drm_vmw_surface_arg *req, + boolean *needs_unref) +{ + ASMBreakpoint(); + RT_NOREF4(vws, whandle, req, needs_unref); + return -1; +} + +/** + * vmw_ioctl_gb_surface_ref - Put a reference on a guest-backed surface and + * get surface information + * + * @vws: Screen to register the reference on + * @handle: Kernel handle of the guest-backed surface + * @flags: flags used when the surface was created + * @format: Format used when the surface was created + * @numMipLevels: Number of mipmap levels of the surface + * @p_region: On successful return points to a newly allocated + * struct vmw_region holding a reference to the surface backup buffer. + * + * Returns 0 on success, a system error on failure. + */ +int +vmw_ioctl_gb_surface_ref(struct vmw_winsys_screen *vws, + const struct winsys_handle *whandle, + SVGA3dSurfaceAllFlags *flags, + SVGA3dSurfaceFormat *format, + uint32_t *numMipLevels, + uint32_t *handle, + struct vmw_region **p_region) +{ + ASMBreakpoint(); + RT_NOREF7(vws, whandle, flags, format, numMipLevels, handle, p_region); + return -1; +} + +void +vmw_ioctl_surface_destroy(struct vmw_winsys_screen *vws, uint32 sid) +{ + struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)vws; + vws_wddm->pEnv->pfnSurfaceDestroy(vws_wddm->pEnv->pvEnv, sid); +} + +void +vmw_ioctl_command(struct vmw_winsys_screen *vws, int32_t cid, + uint32_t throttle_us, void *commands, uint32_t size, + struct pipe_fence_handle **pfence, int32_t imported_fence_fd, + uint32_t flags) +{ + struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)vws; + GAFENCEQUERY FenceQuery; + RT_NOREF3(throttle_us, imported_fence_fd, flags); +#ifdef DEBUG + // svga_dump_commands(commands, size); +#endif + memset(&FenceQuery, 0, sizeof(FenceQuery)); + FenceQuery.u32FenceStatus = GA_FENCE_STATUS_NULL; + + vws_wddm->pEnv->pfnRender(vws_wddm->pEnv->pvEnv, cid, commands, size, pfence? &FenceQuery: NULL); + if (FenceQuery.u32FenceStatus == GA_FENCE_STATUS_NULL) + { + /* + * Kernel has already synced, or caller requested no fence. + */ + if (pfence) + *pfence = NULL; + } + else + { + if (pfence) + { + vmw_fences_signal(vws->fence_ops, FenceQuery.u32ProcessedSeqNo, FenceQuery.u32SubmittedSeqNo, TRUE); + + *pfence = vmw_fence_create(vws->fence_ops, FenceQuery.u32FenceHandle, + FenceQuery.u32SubmittedSeqNo, /* mask */ 0, -1); + if (*pfence == NULL) + { + /* + * Fence creation failed. Need to sync. + */ + (void) vmw_ioctl_fence_finish(vws, FenceQuery.u32FenceHandle, /* mask */ 0); + vmw_ioctl_fence_unref(vws, FenceQuery.u32FenceHandle); + } + } + } +} + + +struct vmw_region * +vmw_ioctl_region_create(struct vmw_winsys_screen *vws, uint32_t size) +{ + /* 'region' is a buffer visible both for host and guest */ + struct vmw_region *region; + struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)vws; + uint32_t u32GmrId = 0; + void *pvMap = NULL; + int ret; + + region = CALLOC_STRUCT(vmw_region); + if (!region) + goto out_err1; + + ret = vws_wddm->pEnv->pfnRegionCreate(vws_wddm->pEnv->pvEnv, size, &u32GmrId, &pvMap); + + if (ret) { + vmw_error("IOCTL failed %d: %s\n", ret, strerror(-ret)); + goto out_err1; + } + + region->handle = u32GmrId; + region->map_handle = 0; + region->data = pvMap; + region->map_count = 0; + region->size = size; + region->vws_wddm = vws_wddm; + + return region; + +out_err1: + FREE(region); + return NULL; +} + +void +vmw_ioctl_region_destroy(struct vmw_region *region) +{ + struct vmw_winsys_screen_wddm *vws_wddm = region->vws_wddm; + + vws_wddm->pEnv->pfnRegionDestroy(vws_wddm->pEnv->pvEnv, region->handle, region->data); + + FREE(region); +} + +SVGAGuestPtr +vmw_ioctl_region_ptr(struct vmw_region *region) +{ + SVGAGuestPtr ptr = {region->handle, 0}; + return ptr; +} + +void * +vmw_ioctl_region_map(struct vmw_region *region) +{ + debug_printf("%s: gmrId = %u\n", __FUNCTION__, + region->handle); + + if (region->data == NULL) + { + /* Should not get here. */ + return NULL; + } + + ++region->map_count; + + return region->data; +} + +void +vmw_ioctl_region_unmap(struct vmw_region *region) +{ + --region->map_count; +} + +/** + * vmw_ioctl_syncforcpu - Synchronize a buffer object for CPU usage + * + * @region: Pointer to a struct vmw_region representing the buffer object. + * @dont_block: Dont wait for GPU idle, but rather return -EBUSY if the + * GPU is busy with the buffer object. + * @readonly: Hint that the CPU access is read-only. + * @allow_cs: Allow concurrent command submission while the buffer is + * synchronized for CPU. If FALSE command submissions referencing the + * buffer will block until a corresponding call to vmw_ioctl_releasefromcpu. + * + * This function idles any GPU activities touching the buffer and blocks + * command submission of commands referencing the buffer, even from + * other processes. + */ +int +vmw_ioctl_syncforcpu(struct vmw_region *region, + boolean dont_block, + boolean readonly, + boolean allow_cs) +{ + ASMBreakpoint(); + RT_NOREF4(region, dont_block, readonly, allow_cs); + return -1; +} + +/** + * vmw_ioctl_releasefromcpu - Undo a previous syncforcpu. + * + * @region: Pointer to a struct vmw_region representing the buffer object. + * @readonly: Should hold the same value as the matching syncforcpu call. + * @allow_cs: Should hold the same value as the matching syncforcpu call. + */ +void +vmw_ioctl_releasefromcpu(struct vmw_region *region, + boolean readonly, + boolean allow_cs) +{ + ASMBreakpoint(); + RT_NOREF3(region, readonly, allow_cs); + return; +} + +void +vmw_ioctl_fence_unref(struct vmw_winsys_screen *vws, + uint32_t handle) +{ + struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)vws; + vws_wddm->pEnv->pfnFenceUnref(vws_wddm->pEnv->pvEnv, handle); +} + +static inline uint32_t +vmw_drm_fence_flags(uint32_t flags) +{ + uint32_t dflags = 0; + + if (flags & SVGA_FENCE_FLAG_EXEC) + dflags |= DRM_VMW_FENCE_FLAG_EXEC; + if (flags & SVGA_FENCE_FLAG_QUERY) + dflags |= DRM_VMW_FENCE_FLAG_QUERY; + + return dflags; +} + + +int +vmw_ioctl_fence_signalled(struct vmw_winsys_screen *vws, + uint32_t handle, + uint32_t flags) +{ + RT_NOREF(flags); + struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)vws; + GAFENCEQUERY FenceQuery; + int ret; + + memset(&FenceQuery, 0, sizeof(FenceQuery)); + FenceQuery.u32FenceStatus = GA_FENCE_STATUS_NULL; + + ret = vws_wddm->pEnv->pfnFenceQuery(vws_wddm->pEnv->pvEnv, handle, &FenceQuery); + + if (ret != 0) + return ret; + + if (FenceQuery.u32FenceStatus == GA_FENCE_STATUS_NULL) + return 0; /* Treat as signalled. */ + + vmw_fences_signal(vws->fence_ops, FenceQuery.u32ProcessedSeqNo, FenceQuery.u32SubmittedSeqNo, TRUE); + + return FenceQuery.u32FenceStatus == GA_FENCE_STATUS_SIGNALED ? 0 : -1; +} + + + +int +vmw_ioctl_fence_finish(struct vmw_winsys_screen *vws, + uint32_t handle, + uint32_t flags) +{ + RT_NOREF(flags); + struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)vws; + + vws_wddm->pEnv->pfnFenceWait(vws_wddm->pEnv->pvEnv, handle, VMW_FENCE_TIMEOUT_SECONDS*1000000); + + return 0; /* Regardless. */ +} + +uint32 +vmw_ioctl_shader_create(struct vmw_winsys_screen *vws, + SVGA3dShaderType type, + uint32 code_len) +{ + ASMBreakpoint(); + RT_NOREF3(vws, type, code_len); + return 0; +} + +void +vmw_ioctl_shader_destroy(struct vmw_winsys_screen *vws, uint32 shid) +{ + ASMBreakpoint(); + RT_NOREF2(vws, shid); + return; +} + +static int +vmw_ioctl_parse_caps(struct vmw_winsys_screen *vws, + const uint32_t *cap_buffer) +{ + unsigned i; + + if (vws->base.have_gb_objects) { + for (i = 0; i < vws->ioctl.num_cap_3d; ++i) { + vws->ioctl.cap_3d[i].has_cap = TRUE; + vws->ioctl.cap_3d[i].result.u = cap_buffer[i]; + } + return 0; + } else { + const uint32 *capsBlock; + const SVGA3dCapsRecord *capsRecord = NULL; + uint32 offset; + const SVGA3dCapPair *capArray; + unsigned numCaps, index; + + /* + * Search linearly through the caps block records for the specified type. + */ + capsBlock = cap_buffer; + for (offset = 0; capsBlock[offset] != 0; offset += capsBlock[offset]) { + const SVGA3dCapsRecord *record; + if (offset >= SVGA_FIFO_3D_CAPS_SIZE) + break; + record = (const SVGA3dCapsRecord *) (capsBlock + offset); + if ((record->header.type >= SVGA3DCAPS_RECORD_DEVCAPS_MIN) && + (record->header.type <= SVGA3DCAPS_RECORD_DEVCAPS_MAX) && + (!capsRecord || (record->header.type > capsRecord->header.type))) { + capsRecord = record; + } + } + + if(!capsRecord) + return -1; + + /* + * Calculate the number of caps from the size of the record. + */ + capArray = (const SVGA3dCapPair *) capsRecord->data; + numCaps = (int) ((capsRecord->header.length * sizeof(uint32) - + sizeof capsRecord->header) / (2 * sizeof(uint32))); + + for (i = 0; i < numCaps; i++) { + index = capArray[i][0]; + if (index < vws->ioctl.num_cap_3d) { + vws->ioctl.cap_3d[index].has_cap = TRUE; + vws->ioctl.cap_3d[index].result.u = capArray[i][1]; + } else { + debug_printf("Unknown devcaps seen: %d\n", index); + } + } + } + return 0; +} + +#define SVGA_CAP2_DX2 0x00000004 +#define SVGA_CAP2_DX3 0x00000400 + +enum SVGASHADERMODEL +{ + SVGA_SM_LEGACY = 0, + SVGA_SM_4, + SVGA_SM_4_1, + SVGA_SM_5, + SVGA_SM_MAX +}; + +static enum SVGASHADERMODEL vboxGetShaderModel(struct vmw_winsys_screen_wddm *vws_wddm) +{ +#if 0 + (void)vws_wddm; + return SVGA_SM_5; +#else + enum SVGASHADERMODEL enmResult = SVGA_SM_LEGACY; + + if ( (vws_wddm->HwInfo.au32Regs[SVGA_REG_CAPABILITIES] & SVGA_CAP_GBOBJECTS) + && (vws_wddm->HwInfo.au32Regs[SVGA_REG_CAPABILITIES] & SVGA_CAP_CMD_BUFFERS_3 /*=SVGA_CAP_DX*/) + && vws_wddm->HwInfo.au32Caps[SVGA3D_DEVCAP_DXCONTEXT]) + { + enmResult = SVGA_SM_4; + + if (vws_wddm->HwInfo.au32Regs[SVGA_REG_CAPABILITIES] & SVGA_CAP_CAP2_REGISTER) + { + if ( (vws_wddm->HwInfo.au32Regs[SVGA_REG_CAP2] & SVGA_CAP2_DX2) + && vws_wddm->HwInfo.au32Caps[SVGA3D_DEVCAP_SM41]) + { + enmResult = SVGA_SM_4_1; + + if ( (vws_wddm->HwInfo.au32Regs[SVGA_REG_CAP2] & SVGA_CAP2_DX3) + && vws_wddm->HwInfo.au32Caps[SVGA3D_DEVCAP_SM5]) + { + enmResult = SVGA_SM_5; + } + } + } + } + + return enmResult; +#endif +} + +static int +vboxGetParam(struct vmw_winsys_screen_wddm *vws_wddm, struct drm_vmw_getparam_arg *gp_arg) +{ + /* DRM_VMW_GET_PARAM */ + switch (gp_arg->param) + { + case DRM_VMW_PARAM_NUM_STREAMS: + gp_arg->value = 1; /* not used */ + break; + case DRM_VMW_PARAM_NUM_FREE_STREAMS: + gp_arg->value = 1; /* not used */ + break; + case DRM_VMW_PARAM_3D: + gp_arg->value = (vws_wddm->HwInfo.au32Regs[SVGA_REG_CAPABILITIES] & SVGA_CAP_3D) != 0; + break; + case DRM_VMW_PARAM_HW_CAPS: + gp_arg->value = vws_wddm->HwInfo.au32Regs[SVGA_REG_CAPABILITIES]; + break; + case DRM_VMW_PARAM_FIFO_CAPS: + gp_arg->value = vws_wddm->HwInfo.au32Fifo[SVGA_FIFO_CAPABILITIES]; + break; + case DRM_VMW_PARAM_MAX_FB_SIZE: + gp_arg->value = vws_wddm->HwInfo.au32Regs[SVGA_REG_MAX_PRIMARY_BOUNDING_BOX_MEM]; + break; + case DRM_VMW_PARAM_FIFO_HW_VERSION: + if (vws_wddm->HwInfo.au32Fifo[SVGA_FIFO_CAPABILITIES] & SVGA_FIFO_CAP_3D_HWVERSION_REVISED) + { + gp_arg->value = + vws_wddm->HwInfo.au32Fifo[SVGA_FIFO_3D_HWVERSION_REVISED]; + } + else + { + gp_arg->value = + vws_wddm->HwInfo.au32Fifo[SVGA_FIFO_3D_HWVERSION]; + } + break; + case DRM_VMW_PARAM_MAX_SURF_MEMORY: + if (vws_wddm->HwInfo.au32Regs[SVGA_REG_CAPABILITIES] & SVGA_CAP_GBOBJECTS) + gp_arg->value = vws_wddm->HwInfo.au32Regs[SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB] * 1024 / 2; + else + gp_arg->value = vws_wddm->HwInfo.au32Regs[SVGA_REG_MEMORY_SIZE]; + break; + case DRM_VMW_PARAM_3D_CAPS_SIZE: + if (vws_wddm->HwInfo.au32Regs[SVGA_REG_CAPABILITIES] & SVGA_CAP_GBOBJECTS) + gp_arg->value = SVGA3D_DEVCAP_MAX * sizeof(uint32_t); + else + gp_arg->value = (SVGA_FIFO_3D_CAPS_LAST - SVGA_FIFO_3D_CAPS + 1) * sizeof(uint32_t); + break; + case DRM_VMW_PARAM_MAX_MOB_MEMORY: + gp_arg->value = vws_wddm->HwInfo.au32Regs[SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB] * 1024; + break; + case DRM_VMW_PARAM_MAX_MOB_SIZE: + gp_arg->value = vws_wddm->HwInfo.au32Regs[SVGA_REG_MOB_MAX_SIZE]; + break; + case DRM_VMW_PARAM_SCREEN_TARGET: + gp_arg->value = 1; /* not used */ + break; + case DRM_VMW_PARAM_DX: + gp_arg->value = (vboxGetShaderModel(vws_wddm) >= SVGA_SM_4); + break; + case DRM_VMW_PARAM_HW_CAPS2: + if (vws_wddm->HwInfo.au32Regs[SVGA_REG_CAPABILITIES] & SVGA_CAP_CAP2_REGISTER) + gp_arg->value = vws_wddm->HwInfo.au32Regs[SVGA_REG_CAP2]; + else + gp_arg->value = 0; + break; + case DRM_VMW_PARAM_SM4_1: + gp_arg->value = (vboxGetShaderModel(vws_wddm) >= SVGA_SM_4_1); + break; + case DRM_VMW_PARAM_SM5: + gp_arg->value = (vboxGetShaderModel(vws_wddm) >= SVGA_SM_5); + break; + default: return -1; + } + return 0; +} + +static int +vboxGet3DCap(struct vmw_winsys_screen_wddm *vws_wddm, void *pvCap, size_t cbCap) +{ + /* DRM_VMW_GET_3D_CAP */ + if (vws_wddm->HwInfo.au32Regs[SVGA_REG_CAPABILITIES] & SVGA_CAP_GBOBJECTS) + memcpy(pvCap, vws_wddm->HwInfo.au32Caps, cbCap); + else + memcpy(pvCap, &vws_wddm->HwInfo.au32Fifo[SVGA_FIFO_3D_CAPS], cbCap); + return 0; +} + +boolean +vmw_ioctl_init(struct vmw_winsys_screen *vws) +{ + struct vmw_winsys_screen_wddm *vws_wddm = (struct vmw_winsys_screen_wddm *)vws; + + struct drm_vmw_getparam_arg gp_arg; + unsigned int size; + int ret; + uint32_t *cap_buffer; + boolean drm_gb_capable; + boolean have_drm_2_5; + + VMW_FUNC; + + have_drm_2_5 = 1; + vws->ioctl.have_drm_2_6 = 1; + vws->ioctl.have_drm_2_9 = 1; + vws->ioctl.have_drm_2_15 = 1; + vws->ioctl.have_drm_2_16 = 1; + vws->ioctl.have_drm_2_17 = 1; + vws->ioctl.have_drm_2_18 = 1; + vws->ioctl.have_drm_2_19 = 1; + + vws->ioctl.drm_execbuf_version = vws->ioctl.have_drm_2_9 ? 2 : 1; + + drm_gb_capable = have_drm_2_5; + + memset(&gp_arg, 0, sizeof(gp_arg)); + gp_arg.param = DRM_VMW_PARAM_3D; + ret = vboxGetParam(vws_wddm, &gp_arg); + if (ret || gp_arg.value == 0) { + vmw_error("No 3D enabled (%i, %s).\n", ret, strerror(-ret)); + goto out_no_3d; + } + + memset(&gp_arg, 0, sizeof(gp_arg)); + gp_arg.param = DRM_VMW_PARAM_FIFO_HW_VERSION; + ret = vboxGetParam(vws_wddm, &gp_arg); + if (ret) { + vmw_error("Failed to get fifo hw version (%i, %s).\n", + ret, strerror(-ret)); + goto out_no_3d; + } + vws->ioctl.hwversion = gp_arg.value; + + memset(&gp_arg, 0, sizeof(gp_arg)); + gp_arg.param = DRM_VMW_PARAM_HW_CAPS; + ret = vboxGetParam(vws_wddm, &gp_arg); + if (ret) + vws->base.have_gb_objects = FALSE; + else + vws->base.have_gb_objects = + !!(gp_arg.value & (uint64_t) SVGA_CAP_GBOBJECTS); + + if (vws->base.have_gb_objects && !drm_gb_capable) + goto out_no_3d; + + vws->base.have_vgpu10 = FALSE; + vws->base.have_sm4_1 = FALSE; + vws->base.have_intra_surface_copy = FALSE; + + if (vws->base.have_gb_objects) { + memset(&gp_arg, 0, sizeof(gp_arg)); + gp_arg.param = DRM_VMW_PARAM_MAX_MOB_MEMORY; + ret = vboxGetParam(vws_wddm, &gp_arg); + if (ret) { + /* Just guess a large enough value. */ + vws->ioctl.max_mob_memory = 256*1024*1024; + } else { + vws->ioctl.max_mob_memory = gp_arg.value; + } + + memset(&gp_arg, 0, sizeof(gp_arg)); + gp_arg.param = DRM_VMW_PARAM_MAX_MOB_SIZE; + ret = vboxGetParam(vws_wddm, &gp_arg); + + if (ret || gp_arg.value == 0) { + vws->ioctl.max_texture_size = VMW_MAX_DEFAULT_TEXTURE_SIZE; + } else { + vws->ioctl.max_texture_size = gp_arg.value; + } + + /* Never early flush surfaces, mobs do accounting. */ + vws->ioctl.max_surface_memory = -1; + + if (vws->ioctl.have_drm_2_9) { + memset(&gp_arg, 0, sizeof(gp_arg)); + gp_arg.param = DRM_VMW_PARAM_DX; + ret = vboxGetParam(vws_wddm, &gp_arg); + if (ret == 0 && gp_arg.value != 0) { + const char *vgpu10_val; + + debug_printf("Have VGPU10 interface and hardware.\n"); + vws->base.have_vgpu10 = TRUE; + vgpu10_val = getenv("SVGA_VGPU10"); + if (vgpu10_val && strcmp(vgpu10_val, "0") == 0) { + debug_printf("Disabling VGPU10 interface.\n"); + vws->base.have_vgpu10 = FALSE; + } else { + debug_printf("Enabling VGPU10 interface.\n"); + } + } + } + + if (vws->ioctl.have_drm_2_15 && vws->base.have_vgpu10) { + memset(&gp_arg, 0, sizeof(gp_arg)); + gp_arg.param = DRM_VMW_PARAM_HW_CAPS2; + ret = vboxGetParam(vws_wddm, &gp_arg); + if (ret == 0 && gp_arg.value != 0) { + vws->base.have_intra_surface_copy = TRUE; + } + + memset(&gp_arg, 0, sizeof(gp_arg)); + gp_arg.param = DRM_VMW_PARAM_SM4_1; + ret = vboxGetParam(vws_wddm, &gp_arg); + if (ret == 0 && gp_arg.value != 0) { + vws->base.have_sm4_1 = TRUE; + } + } + + if (vws->ioctl.have_drm_2_18 && vws->base.have_sm4_1) { + memset(&gp_arg, 0, sizeof(gp_arg)); + gp_arg.param = DRM_VMW_PARAM_SM5; + ret = vboxGetParam(vws_wddm, &gp_arg); + if (ret == 0 && gp_arg.value != 0) { + vws->base.have_sm5 = TRUE; + } + } + + memset(&gp_arg, 0, sizeof(gp_arg)); + gp_arg.param = DRM_VMW_PARAM_3D_CAPS_SIZE; + ret = vboxGetParam(vws_wddm, &gp_arg); + if (ret) + size = SVGA_FIFO_3D_CAPS_SIZE * sizeof(uint32_t); + else + size = gp_arg.value; + + if (vws->base.have_gb_objects) + vws->ioctl.num_cap_3d = size / sizeof(uint32_t); + else + vws->ioctl.num_cap_3d = SVGA3D_DEVCAP_MAX; + + if (vws->ioctl.have_drm_2_16) { + vws->base.have_coherent = TRUE; + } + } else { + vws->ioctl.num_cap_3d = SVGA3D_DEVCAP_MAX; + + memset(&gp_arg, 0, sizeof(gp_arg)); + gp_arg.param = DRM_VMW_PARAM_MAX_SURF_MEMORY; + if (have_drm_2_5) + ret = vboxGetParam(vws_wddm, &gp_arg); + if (!have_drm_2_5 || ret) { + /* Just guess a large enough value, around 800mb. */ + vws->ioctl.max_surface_memory = 0x30000000; + } else { + vws->ioctl.max_surface_memory = gp_arg.value; + } + + vws->ioctl.max_texture_size = VMW_MAX_DEFAULT_TEXTURE_SIZE; + + size = SVGA_FIFO_3D_CAPS_SIZE * sizeof(uint32_t); + } + + debug_printf("VGPU10 interface is %s.\n", + vws->base.have_vgpu10 ? "on" : "off"); + + cap_buffer = calloc(1, size); + if (!cap_buffer) { + debug_printf("Failed alloc fifo 3D caps buffer.\n"); + goto out_no_3d; + } + + vws->ioctl.cap_3d = calloc(vws->ioctl.num_cap_3d, + sizeof(*vws->ioctl.cap_3d)); + if (!vws->ioctl.cap_3d) { + debug_printf("Failed alloc fifo 3D caps buffer.\n"); + goto out_no_caparray; + } + + /* + * This call must always be after DRM_VMW_PARAM_MAX_MOB_MEMORY and + * DRM_VMW_PARAM_SM4_1. This is because, based on these calls, kernel + * driver sends the supported cap. + */ + ret = vboxGet3DCap(vws_wddm, cap_buffer, size); + + if (ret) { + debug_printf("Failed to get 3D capabilities" + " (%i, %s).\n", ret, strerror(-ret)); + goto out_no_caps; + } + + ret = vmw_ioctl_parse_caps(vws, cap_buffer); + if (ret) { + debug_printf("Failed to parse 3D capabilities" + " (%i, %s).\n", ret, strerror(-ret)); + goto out_no_caps; + } + + if (vws->ioctl.have_drm_2_15 && vws->base.have_vgpu10) { + + /* support for these commands didn't make it into vmwgfx kernel + * modules before 2.10. + */ + vws->base.have_generate_mipmap_cmd = TRUE; + vws->base.have_set_predication_cmd = TRUE; + } + + if (vws->ioctl.have_drm_2_15) { + vws->base.have_fence_fd = TRUE; + } + + free(cap_buffer); + vmw_printf("%s OK\n", __FUNCTION__); + return TRUE; + out_no_caps: + free(vws->ioctl.cap_3d); + out_no_caparray: + free(cap_buffer); + out_no_3d: + vws->ioctl.num_cap_3d = 0; + debug_printf("%s Failed\n", __FUNCTION__); + return FALSE; +} + + + +void +vmw_ioctl_cleanup(struct vmw_winsys_screen *vws) +{ + VMW_FUNC; + + free(vws->ioctl.cap_3d); +} diff --git a/src/VBox/Additions/3D/win/VBoxSVGA/winsys/vmw_screen_wddm.c b/src/VBox/Additions/3D/win/VBoxSVGA/winsys/vmw_screen_wddm.c new file mode 100644 index 00000000..16b0ac21 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxSVGA/winsys/vmw_screen_wddm.c @@ -0,0 +1,177 @@ +/* + * Copyright (C) 2016-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +/********************************************************** + * Copyright 2009-2015 VMware, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + **********************************************************/ + + +#include "pipe/p_compiler.h" +#include "util/u_inlines.h" +#include "util/u_memory.h" + +#include "vmw_context.h" +#include "vmw_screen.h" +#include "vmw_surface.h" +#include "vmw_buffer.h" +#include "svga_drm_public.h" +#include "svga3d_surfacedefs.h" + +#include "frontend/drm_driver.h" + +#include "vmwgfx_drm.h" + +#include "../wddm_screen.h" + +#include <iprt/asm.h> + +static struct svga_winsys_surface * +vmw_drm_surface_from_handle(struct svga_winsys_screen *sws, + struct winsys_handle *whandle, + SVGA3dSurfaceFormat *format); + +static struct svga_winsys_surface * +vmw_drm_gb_surface_from_handle(struct svga_winsys_screen *sws, + struct winsys_handle *whandle, + SVGA3dSurfaceFormat *format); +static boolean +vmw_drm_surface_get_handle(struct svga_winsys_screen *sws, + struct svga_winsys_surface *surface, + unsigned stride, + struct winsys_handle *whandle); + +struct vmw_winsys_screen_wddm * +vmw_winsys_create_wddm(const WDDMGalliumDriverEnv *pEnv); + +/* This is actually the entrypoint to the entire driver, + * called by the target bootstrap code. + */ +struct svga_winsys_screen * +svga_wddm_winsys_screen_create(const WDDMGalliumDriverEnv *pEnv) +{ + struct vmw_winsys_screen_wddm *vws; + + if (pEnv->cb < sizeof(WDDMGalliumDriverEnv)) + goto out_no_vws; + + vws = vmw_winsys_create_wddm(pEnv); + if (!vws) + goto out_no_vws; + + /* XXX do this properly */ + vws->base.base.surface_from_handle = vws->base.base.have_gb_objects ? + vmw_drm_gb_surface_from_handle : vmw_drm_surface_from_handle; + vws->base.base.surface_get_handle = vmw_drm_surface_get_handle; + + return &vws->base.base; + +out_no_vws: + return NULL; +} + +static struct svga_winsys_surface * +vmw_drm_gb_surface_from_handle(struct svga_winsys_screen *sws, + struct winsys_handle *whandle, + SVGA3dSurfaceFormat *format) +{ + RT_NOREF3(sws, whandle, format); + return 0; +} + +static struct svga_winsys_surface * +vmw_drm_surface_from_handle(struct svga_winsys_screen *sws, + struct winsys_handle *whandle, + SVGA3dSurfaceFormat *format) +{ + RT_NOREF3(sws, whandle, format); + return 0; +} + +/* + * The user mode driver asks the kernel driver to create a resource + * (vmw_ioctl_surface_create) and gets a sid (surface id). + * This function is supposed to convert the sid to a handle (file descriptor) + * which can be used to access the surface. + */ +static boolean +vmw_drm_surface_get_handle(struct svga_winsys_screen *sws, + struct svga_winsys_surface *surface, + unsigned stride, + struct winsys_handle *whandle) +{ + struct vmw_winsys_screen *vws = vmw_winsys_screen(sws); + struct vmw_svga_winsys_surface *vsrf; + + RT_NOREF(vws); + + if (!surface) + return FALSE; + + vsrf = vmw_svga_winsys_surface(surface); + whandle->handle = vsrf->sid; + whandle->stride = stride; + whandle->offset = 0; + + switch (whandle->type) { + case WINSYS_HANDLE_TYPE_SHARED: + case WINSYS_HANDLE_TYPE_KMS: + whandle->handle = vsrf->sid; + break; + case WINSYS_HANDLE_TYPE_FD: + whandle->handle = vsrf->sid; /// @todo will this be enough for WDDM? + break; + default: + vmw_error("Attempt to export unsupported handle type %d.\n", + whandle->type); + return FALSE; + } + + return TRUE; +} + +void +vmw_svga_winsys_host_log(struct svga_winsys_screen *sws, const char *log) +{ + (void)sws; + _debug_printf("%s\n", log); +} diff --git a/src/VBox/Additions/3D/win/VBoxWddmUmHlp/D3DKMT.cpp b/src/VBox/Additions/3D/win/VBoxWddmUmHlp/D3DKMT.cpp new file mode 100644 index 00000000..b30698a5 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxWddmUmHlp/D3DKMT.cpp @@ -0,0 +1,260 @@ +/* $Id: D3DKMT.cpp $ */ +/** @file + * WDDM Kernel Mode Thunks helpers. + */ + +/* + * Copyright (C) 2018-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +/* We're unable to use standard r3 vbgl-based backdoor logging API because win8 Metro apps + * can not do CreateFile/Read/Write by default. + * This is why we use miniport escape functionality to issue backdoor log string to the miniport + * and submit it to host via standard r0 backdoor logging api accordingly + */ + +#include "UmHlpInternal.h" + + +/** Loads a system DLL. + * + * @returns Module handle or NULL + * @param pszName The DLL name. + */ +DECLCALLBACK(HMODULE) VBoxWddmLoadSystemDll(const char *pszName) +{ + char szPath[MAX_PATH]; + UINT cchPath = GetSystemDirectoryA(szPath, sizeof(szPath)); + size_t cbName = strlen(pszName) + 1; + if (cchPath + 1 + cbName > sizeof(szPath)) + { + SetLastError(ERROR_FILENAME_EXCED_RANGE); + return NULL; + } + szPath[cchPath] = '\\'; + memcpy(&szPath[cchPath + 1], pszName, cbName); + return LoadLibraryA(szPath); +} + +DECLCALLBACK(void) VBoxWddmLoadAdresses(HMODULE hmod, VBOXWDDMDLLPROC *paProcs) +{ + struct VBOXWDDMDLLPROC *pIter = paProcs; + while (pIter->pszName) + { + FARPROC pfn = GetProcAddress(hmod, pIter->pszName); + *pIter->ppfn = pfn; + ++pIter; + } +} + +/* + * Kernel Mode Thunks (KMT) initialization. + */ + +#define D3DKMT_LOAD_ENTRY(a) { #a, (FARPROC *)&g_D3DKMT.pfn##a } + +static D3DKMTFUNCTIONS g_D3DKMT = { 0 }; +static VBOXWDDMDLLPROC g_D3DKMTLoadTable[] = +{ + D3DKMT_LOAD_ENTRY(D3DKMTOpenAdapterFromHdc), + D3DKMT_LOAD_ENTRY(D3DKMTOpenAdapterFromDeviceName), + D3DKMT_LOAD_ENTRY(D3DKMTCloseAdapter), + D3DKMT_LOAD_ENTRY(D3DKMTQueryAdapterInfo), + D3DKMT_LOAD_ENTRY(D3DKMTEscape), + D3DKMT_LOAD_ENTRY(D3DKMTCreateDevice), + D3DKMT_LOAD_ENTRY(D3DKMTDestroyDevice), + D3DKMT_LOAD_ENTRY(D3DKMTCreateContext), + D3DKMT_LOAD_ENTRY(D3DKMTDestroyContext), + D3DKMT_LOAD_ENTRY(D3DKMTCreateAllocation), + D3DKMT_LOAD_ENTRY(D3DKMTDestroyAllocation), + D3DKMT_LOAD_ENTRY(D3DKMTRender), + D3DKMT_LOAD_ENTRY(D3DKMTPresent), + D3DKMT_LOAD_ENTRY(D3DKMTGetSharedPrimaryHandle), + D3DKMT_LOAD_ENTRY(D3DKMTQueryResourceInfo), + D3DKMT_LOAD_ENTRY(D3DKMTOpenResource), + D3DKMT_LOAD_ENTRY(D3DKMTEnumAdapters), + D3DKMT_LOAD_ENTRY(D3DKMTOpenAdapterFromLuid), + {NULL, NULL}, +}; + +#undef D3DKMT_LOAD_ENTRY + +/** Initialize Kernel Mode Thunks (KMT) pointers in the g_D3DKMT structure. + * + * @returns True if successful. + */ +DECLCALLBACK(int) D3DKMTLoad(void) +{ + /* Modules which use D3DKMT must link with gdi32. */ + HMODULE hmod = GetModuleHandleA("gdi32.dll"); + Assert(hmod); + if (hmod) + { + VBoxWddmLoadAdresses(hmod, g_D3DKMTLoadTable); + } + return hmod != NULL; +} + +DECLCALLBACK(D3DKMTFUNCTIONS const *) D3DKMTFunctions(void) +{ + return &g_D3DKMT; +} + + +/* + * Getting VirtualBox Graphics Adapter handle. + */ + +static NTSTATUS vboxDispKmtOpenAdapterFromHdc(D3DKMT_HANDLE *phAdapter, LUID *pLuid) +{ + *phAdapter = 0; + + D3DKMTFUNCTIONS const *d3dkmt = D3DKMTFunctions(); + if (d3dkmt->pfnD3DKMTOpenAdapterFromHdc == NULL) + return STATUS_NOT_SUPPORTED; + + D3DKMT_OPENADAPTERFROMHDC OpenAdapterData; + memset(&OpenAdapterData, 0, sizeof(OpenAdapterData)); + + for (int i = 0; ; ++i) + { + DISPLAY_DEVICEA dd; + memset(&dd, 0, sizeof(dd)); + dd.cb = sizeof(dd); + + if (!EnumDisplayDevicesA(NULL, i, &dd, 0)) + break; + + if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) + { + OpenAdapterData.hDc = CreateDCA(NULL, dd.DeviceName, NULL, NULL); + break; + } + } + + Assert(OpenAdapterData.hDc); + + NTSTATUS Status; + if (OpenAdapterData.hDc) + { + Status = d3dkmt->pfnD3DKMTOpenAdapterFromHdc(&OpenAdapterData); + Assert(Status == STATUS_SUCCESS); + if (Status == STATUS_SUCCESS) + { + *phAdapter = OpenAdapterData.hAdapter; + if (pLuid) + { + *pLuid = OpenAdapterData.AdapterLuid; + } + } + + DeleteDC(OpenAdapterData.hDc); + } + else + { + Status = STATUS_NOT_SUPPORTED; + } + + return Status; +} + +static NTSTATUS vboxDispKmtOpenAdapterFromLuid(D3DKMT_HANDLE *phAdapter, LUID *pLuid) +{ + *phAdapter = 0; + + D3DKMTFUNCTIONS const *d3dkmt = D3DKMTFunctions(); + if ( d3dkmt->pfnD3DKMTOpenAdapterFromLuid == NULL + || d3dkmt->pfnD3DKMTEnumAdapters == NULL) + return STATUS_NOT_SUPPORTED; + + D3DKMT_ENUMADAPTERS EnumAdaptersData; + memset(&EnumAdaptersData, 0, sizeof(EnumAdaptersData)); + EnumAdaptersData.NumAdapters = RT_ELEMENTS(EnumAdaptersData.Adapters); + + NTSTATUS Status = d3dkmt->pfnD3DKMTEnumAdapters(&EnumAdaptersData); + Assert(Status == STATUS_SUCCESS); + if (Status == STATUS_SUCCESS) + { + Assert(EnumAdaptersData.NumAdapters); + + /* Try the same twice: if we fail to open the adapter containing present sources, + * then try to open any adapter. + */ + for (int iPass = 0; iPass < 2 && *phAdapter == 0; ++iPass) + { + for (ULONG i = 0; i < EnumAdaptersData.NumAdapters; ++i) + { + if (iPass > 0 || EnumAdaptersData.Adapters[i].NumOfSources) + { + D3DKMT_OPENADAPTERFROMLUID OpenAdapterData; + memset(&OpenAdapterData, 0, sizeof(OpenAdapterData)); + OpenAdapterData.AdapterLuid = EnumAdaptersData.Adapters[i].AdapterLuid; + + Status = d3dkmt->pfnD3DKMTOpenAdapterFromLuid(&OpenAdapterData); + Assert(Status == STATUS_SUCCESS); + if (Status == STATUS_SUCCESS) + { + *phAdapter = OpenAdapterData.hAdapter; + if (pLuid) + { + *pLuid = EnumAdaptersData.Adapters[i].AdapterLuid; + } + break; + } + } + } + } + } + + return Status; +} + +NTSTATUS vboxDispKmtOpenAdapter2(D3DKMT_HANDLE *phAdapter, LUID *pLuid) +{ + NTSTATUS Status = vboxDispKmtOpenAdapterFromLuid(phAdapter, pLuid); + if (Status != STATUS_SUCCESS) + { + /* Fallback for pre-Windows8 */ + Status = vboxDispKmtOpenAdapterFromHdc(phAdapter, pLuid); + } + + return Status; +} + +NTSTATUS vboxDispKmtOpenAdapter(D3DKMT_HANDLE *phAdapter) +{ + return vboxDispKmtOpenAdapter2(phAdapter, NULL); +} + +NTSTATUS vboxDispKmtCloseAdapter(D3DKMT_HANDLE hAdapter) +{ + D3DKMTFUNCTIONS const *d3dkmt = D3DKMTFunctions(); + if (d3dkmt->pfnD3DKMTCloseAdapter == NULL) + return STATUS_NOT_SUPPORTED; + + D3DKMT_CLOSEADAPTER CloseAdapterData; + CloseAdapterData.hAdapter = hAdapter; + + NTSTATUS Status = d3dkmt->pfnD3DKMTCloseAdapter(&CloseAdapterData); + Assert(Status == STATUS_SUCCESS); + + return Status; +} diff --git a/src/VBox/Additions/3D/win/VBoxWddmUmHlp/Makefile.kmk b/src/VBox/Additions/3D/win/VBoxWddmUmHlp/Makefile.kmk new file mode 100644 index 00000000..80f6a078 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxWddmUmHlp/Makefile.kmk @@ -0,0 +1,54 @@ +# $Id: Makefile.kmk $ +## @file +# Sub-Makefile for the VirtualBox WDDM user mode driver +# + +# +# Copyright (C) 2018-2023 Oracle and/or its affiliates. +# +# This file is part of VirtualBox base platform packages, as +# available from https://www.virtualbox.org. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, in version 3 of the +# License. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see <https://www.gnu.org/licenses>. +# +# SPDX-License-Identifier: GPL-3.0-only +# + +SUB_DEPTH = ../../../../../.. +include $(KBUILD_PATH)/subheader.kmk + +LIBRARIES += VBoxWddmUmHlp +LIBRARIES.amd64 += VBoxWddmUmHlp-x86 + +# +# VBoxWddmUmHlp - logger and other helpers for user mode driver +# +VBoxWddmUmHlp_TEMPLATE = NewerVccVBoxGuestR3Dll +VBoxWddmUmHlp_INST = $(INST_ADDITIONS_LIB) +VBoxWddmUmHlp_DEFS = VBOX_WITH_WDDM +VBoxWddmUmHlp_INCS = \ + $(PATH_ROOT)/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/shared \ + $(VBOX_GRAPHICS_INCS) +VBoxWddmUmHlp_SOURCES = \ + D3DKMT.cpp \ + VBoxMpLogger.cpp + +# +# 64-bit version for 32-bit build. +# +VBoxWddmUmHlp-x86_EXTENDS = VBoxWddmUmHlp +VBoxWddmUmHlp-x86_BLD_TRG_ARCH = x86 + +include $(FILE_KBUILD_SUB_FOOTER) + diff --git a/src/VBox/Additions/3D/win/VBoxWddmUmHlp/UmHlpInternal.h b/src/VBox/Additions/3D/win/VBoxWddmUmHlp/UmHlpInternal.h new file mode 100644 index 00000000..5a7bafdb --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxWddmUmHlp/UmHlpInternal.h @@ -0,0 +1,36 @@ +/* $Id: UmHlpInternal.h $ */ +/** @file + * VBox WDDM User Mode Driver Helpers + */ + +/* + * Copyright (C) 2018-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#ifndef GA_INCLUDED_SRC_3D_win_VBoxWddmUmHlp_UmHlpInternal_h +#define GA_INCLUDED_SRC_3D_win_VBoxWddmUmHlp_UmHlpInternal_h +#ifndef RT_WITHOUT_PRAGMA_ONCE +# pragma once +#endif + +#include "VBoxWddmUmHlp.h" + +#endif /* !GA_INCLUDED_SRC_3D_win_VBoxWddmUmHlp_UmHlpInternal_h */ diff --git a/src/VBox/Additions/3D/win/VBoxWddmUmHlp/VBoxMpLogger.cpp b/src/VBox/Additions/3D/win/VBoxWddmUmHlp/VBoxMpLogger.cpp new file mode 100644 index 00000000..702e1558 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxWddmUmHlp/VBoxMpLogger.cpp @@ -0,0 +1,167 @@ +/* $Id: VBoxMpLogger.cpp $ */ +/** @file + * VBox WDDM Display logger implementation + * + * We're unable to use standard r3 vbgl-based backdoor logging API because + * win8 Metro apps can not do CreateFile/Read/Write by default. This is why + * we use miniport escape functionality to issue backdoor log string to the + * miniport and submit it to host via standard r0 backdoor logging api + * accordingly + */ + +/* + * Copyright (C) 2018-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#define IPRT_NO_CRT_FOR_3RD_PARTY /* To get malloc and free wrappers in IPRT_NO_CRT mode. Doesn't link with IPRT in non-no-CRT mode. */ +#include "UmHlpInternal.h" + +#include <../../../common/wddm/VBoxMPIf.h> +#include <stdlib.h> +#ifdef IPRT_NO_CRT +# include <iprt/process.h> +# include <iprt/string.h> +#else +# include <stdio.h> +#endif +#include <VBox/VBoxGuestLib.h> + + +static void VBoxDispMpLoggerLogN(const char *pchString, size_t cchString) +{ + D3DKMTFUNCTIONS const *d3dkmt = D3DKMTFunctions(); + if (d3dkmt->pfnD3DKMTEscape == NULL) + return; + + D3DKMT_HANDLE hAdapter; + NTSTATUS Status = vboxDispKmtOpenAdapter(&hAdapter); + Assert(Status == STATUS_SUCCESS); + if (Status == 0) + { + uint32_t cchString2 = (uint32_t)RT_MIN(cchString, _64K - 1U); + uint32_t cbCmd = RT_UOFFSETOF_DYN(VBOXDISPIFESCAPE_DBGPRINT, aStringBuf[cchString2 + 1]); + PVBOXDISPIFESCAPE_DBGPRINT pCmd = (PVBOXDISPIFESCAPE_DBGPRINT)malloc(cbCmd); + Assert(pCmd); + if (pCmd) + { + pCmd->EscapeHdr.escapeCode = VBOXESC_DBGPRINT; + pCmd->EscapeHdr.u32CmdSpecific = 0; + memcpy(pCmd->aStringBuf, pchString, cchString2); + pCmd->aStringBuf[cchString2] = '\0'; + + D3DKMT_ESCAPE EscapeData; + memset(&EscapeData, 0, sizeof(EscapeData)); + EscapeData.hAdapter = hAdapter; + // EscapeData.hDevice = NULL; + EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; + // EscapeData.Flags.HardwareAccess = 0; + EscapeData.pPrivateDriverData = pCmd; + EscapeData.PrivateDriverDataSize = cbCmd; + // EscapeData.hContext = NULL; + + Status = d3dkmt->pfnD3DKMTEscape(&EscapeData); + Assert(Status == STATUS_SUCCESS); + + free(pCmd); + } + + Status = vboxDispKmtCloseAdapter(hAdapter); + Assert(Status == STATUS_SUCCESS); + } +} + + +DECLCALLBACK(void) VBoxDispMpLoggerLog(const char *pszString) +{ + VBoxDispMpLoggerLogN(pszString, strlen(pszString)); +} + + +DECLCALLBACK(void) VBoxDispMpLoggerLogF(const char *pszFormat, ...) +{ + /** @todo would make a whole lot more sense to just allocate + * VBOXDISPIFESCAPE_DBGPRINT here and printf into it's buffer than + * double buffering it like this */ + char szBuffer[4096]; + va_list va; + va_start(va, pszFormat); +#ifdef IPRT_NO_CRT + RTStrPrintfV(szBuffer, sizeof(szBuffer), pszFormat, va); +#else + _vsnprintf(szBuffer, sizeof(szBuffer), pszFormat, va); + szBuffer[sizeof(szBuffer) - 1] = '\0'; /* Don't trust the _vsnprintf function terminate the string! */ +#endif + va_end(va); + + VBoxDispMpLoggerLog(szBuffer); +} + + +/* Interface used for backdoor logging. In no-CRT mode we will drag in IPRT + logging and it will be used on assertion in the no-CRT and IPRT code. */ +VBGLR3DECL(int) VbglR3WriteLog(const char *pch, size_t cch) +{ + VBoxDispMpLoggerLogN(pch, cch); + return VINF_SUCCESS; +} + + +/** + * Prefix the output string with exe name and pid/tid. + */ +#ifndef IPRT_NO_CRT +static const char *vboxUmLogGetExeName(void) +{ + static int s_fModuleNameInited = 0; + static char s_szModuleName[MAX_PATH]; + + if (!s_fModuleNameInited) + { + const DWORD cchName = GetModuleFileNameA(NULL, s_szModuleName, RT_ELEMENTS(s_szModuleName)); + if (cchName == 0) + return "<no module>"; + s_fModuleNameInited = 1; + } + return &s_szModuleName[0]; +} +#endif + +DECLCALLBACK(void) VBoxWddmUmLog(const char *pszString) +{ + /** @todo Allocate VBOXDISPIFESCAPE_DBGPRINT here and format right into it + * instead? That would be a lot more flexible and a little faster. */ + char szBuffer[4096]; +#ifdef IPRT_NO_CRT + /** @todo use RTProcShortName instead of RTProcExecutablePath? Will avoid + * chopping off log text if the executable path is too long. */ + RTStrPrintf(szBuffer, sizeof(szBuffer), "['%s' 0x%lx.0x%lx]: %s", + RTProcExecutablePath() /* should've been initialized by nocrt-startup-dll-win.cpp already */, + GetCurrentProcessId(), GetCurrentThreadId(), pszString); +#else + int cch = _snprintf(szBuffer, sizeof(szBuffer), "['%s' 0x%lx.0x%lx]: %s", + vboxUmLogGetExeName(), GetCurrentProcessId(), GetCurrentThreadId(), pszString); + AssertReturnVoid(cch > 0); /* unlikely that we'll have string encoding problems, but just in case. */ + szBuffer[sizeof(szBuffer) - 1] = '\0'; /* the function doesn't necessarily terminate the buffer on overflow. */ +#endif + + VBoxDispMpLoggerLog(szBuffer); +} + diff --git a/src/VBox/Additions/3D/win/VBoxWddmUmHlp/VBoxWddmUmHlp.h b/src/VBox/Additions/3D/win/VBoxWddmUmHlp/VBoxWddmUmHlp.h new file mode 100644 index 00000000..ffc10c79 --- /dev/null +++ b/src/VBox/Additions/3D/win/VBoxWddmUmHlp/VBoxWddmUmHlp.h @@ -0,0 +1,116 @@ +/* $Id: VBoxWddmUmHlp.h $ */ +/** @file + * VBox WDDM User Mode Driver Helpers + */ + +/* + * Copyright (C) 2018-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#ifndef GA_INCLUDED_SRC_3D_win_VBoxWddmUmHlp_VBoxWddmUmHlp_h +#define GA_INCLUDED_SRC_3D_win_VBoxWddmUmHlp_VBoxWddmUmHlp_h +#ifndef RT_WITHOUT_PRAGMA_ONCE +# pragma once +#endif + +#include <iprt/win/d3d9.h> +#include <d3dumddi.h> +#include <iprt/win/d3dkmthk.h> + +#include <iprt/asm.h> +#include <iprt/cdefs.h> + +/* Do not require IPRT library. */ +/** @todo r=bird: It is *NOT* okay to redefine Assert* (or Log*) macros! It + * causes confusing as the code no longer behaves in the way one expect. Thus, + * it is strictly forbidden. */ +#ifndef IPRT_NO_CRT +# undef Assert +# undef AssertReturnVoid +# ifdef RT_STRICT +# define Assert(_e) (void)( (!!(_e)) || (ASMBreakpoint(), 0) ) +# define AssertReturnVoid(a_Expr) do { if (RT_LIKELY(a_Expr)) {} else { ASMBreakpoint(); return; } } while (0) +# else +# define Assert(_e) (void)( 0 ) +# define AssertReturnVoid(a_Expr) do { if (RT_LIKELY(a_Expr)) {} else return; } while (0) +# endif +#endif + +/* Do not require ntstatus.h. + * D3DKMT functions return NTSTATUS, but the driver code uses it only as a success/failure indicator. + * Therefore define the success and a failure status here. + */ +#ifndef STATUS_SUCCESS +#define STATUS_SUCCESS 0 +#endif +#ifndef STATUS_NOT_SUPPORTED +#define STATUS_NOT_SUPPORTED ((NTSTATUS)0xC00000BBL) +#endif + +RT_C_DECLS_BEGIN + +typedef struct VBOXWDDMDLLPROC +{ + char const *pszName; + FARPROC *ppfn; +} VBOXWDDMDLLPROC; + +typedef struct D3DKMTFUNCTIONS +{ + PFND3DKMT_OPENADAPTERFROMHDC pfnD3DKMTOpenAdapterFromHdc; + PFND3DKMT_OPENADAPTERFROMDEVICENAME pfnD3DKMTOpenAdapterFromDeviceName; + PFND3DKMT_CLOSEADAPTER pfnD3DKMTCloseAdapter; + PFND3DKMT_QUERYADAPTERINFO pfnD3DKMTQueryAdapterInfo; + PFND3DKMT_ESCAPE pfnD3DKMTEscape; + PFND3DKMT_CREATEDEVICE pfnD3DKMTCreateDevice; + PFND3DKMT_DESTROYDEVICE pfnD3DKMTDestroyDevice; + PFND3DKMT_CREATECONTEXT pfnD3DKMTCreateContext; + PFND3DKMT_DESTROYCONTEXT pfnD3DKMTDestroyContext; + PFND3DKMT_CREATEALLOCATION pfnD3DKMTCreateAllocation; + PFND3DKMT_DESTROYALLOCATION pfnD3DKMTDestroyAllocation; + PFND3DKMT_RENDER pfnD3DKMTRender; + PFND3DKMT_PRESENT pfnD3DKMTPresent; + PFND3DKMT_GETSHAREDPRIMARYHANDLE pfnD3DKMTGetSharedPrimaryHandle; + PFND3DKMT_QUERYRESOURCEINFO pfnD3DKMTQueryResourceInfo; + PFND3DKMT_OPENRESOURCE pfnD3DKMTOpenResource; + + /* Win 8+ */ + PFND3DKMT_ENUMADAPTERS pfnD3DKMTEnumAdapters; + PFND3DKMT_OPENADAPTERFROMLUID pfnD3DKMTOpenAdapterFromLuid; +} D3DKMTFUNCTIONS; + +DECLCALLBACK(HMODULE) VBoxWddmLoadSystemDll(const char *pszName); +DECLCALLBACK(void) VBoxWddmLoadAdresses(HMODULE hmod, VBOXWDDMDLLPROC *paProcs); + +DECLCALLBACK(int) D3DKMTLoad(void); +DECLCALLBACK(D3DKMTFUNCTIONS const *) D3DKMTFunctions(void); + +DECLCALLBACK(void) VBoxDispMpLoggerLogF(const char *pszFormat, ...); +DECLCALLBACK(void) VBoxWddmUmLog(const char *pszString); + +/** @todo Rename to VBoxWddm* */ +NTSTATUS vboxDispKmtOpenAdapter2(D3DKMT_HANDLE *phAdapter, LUID *pLuid); +NTSTATUS vboxDispKmtOpenAdapter(D3DKMT_HANDLE *phAdapter); +NTSTATUS vboxDispKmtCloseAdapter(D3DKMT_HANDLE hAdapter); + +RT_C_DECLS_END + +#endif /* !GA_INCLUDED_SRC_3D_win_VBoxWddmUmHlp_VBoxWddmUmHlp_h */ diff --git a/src/VBox/Additions/3D/win/include/VBoxGaDriver.h b/src/VBox/Additions/3D/win/include/VBoxGaDriver.h new file mode 100644 index 00000000..0f964999 --- /dev/null +++ b/src/VBox/Additions/3D/win/include/VBoxGaDriver.h @@ -0,0 +1,115 @@ +/* $Id: VBoxGaDriver.h $ */ +/** @file + * VirtualBox Windows Guest Mesa3D - Gallium driver interface. + */ + +/* + * Copyright (C) 2016-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#ifndef GA_INCLUDED_3D_WIN_VBoxGaDriver_h +#define GA_INCLUDED_3D_WIN_VBoxGaDriver_h +#ifndef RT_WITHOUT_PRAGMA_ONCE +# pragma once +#endif + +#include <VBoxGaHWInfo.h> +#include <VBoxGaTypes.h> + +#include <iprt/win/windows.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct WDDMGalliumDriverEnv +{ + /* Size of the structure. */ + DWORD cb; + const VBOXGAHWINFO *pHWInfo; + /* The environment context pointer to use in the following callbacks. */ + void *pvEnv; + /* The callbacks to use by the driver. */ + DECLCALLBACKMEMBER(uint32_t, pfnContextCreate,(void *pvEnv, + boolean extended, + boolean vgpu10)); + DECLCALLBACKMEMBER(void, pfnContextDestroy,(void *pvEnv, + uint32_t u32Cid)); + DECLCALLBACKMEMBER(int, pfnSurfaceDefine,(void *pvEnv, + GASURFCREATE *pCreateParms, + GASURFSIZE *paSizes, + uint32_t cSizes, + uint32_t *pu32Sid)); + DECLCALLBACKMEMBER(void, pfnSurfaceDestroy,(void *pvEnv, + uint32_t u32Sid)); + DECLCALLBACKMEMBER(int, pfnRender,(void *pvEnv, + uint32_t u32Cid, + void *pvCommands, + uint32_t cbCommands, + GAFENCEQUERY *pFenceQuery)); + DECLCALLBACKMEMBER(void, pfnFenceUnref,(void *pvEnv, + uint32_t u32FenceHandle)); + DECLCALLBACKMEMBER(int, pfnFenceQuery,(void *pvEnv, + uint32_t u32FenceHandle, + GAFENCEQUERY *pFenceQuery)); + DECLCALLBACKMEMBER(int, pfnFenceWait,(void *pvEnv, + uint32_t u32FenceHandle, + uint32_t u32TimeoutUS)); + DECLCALLBACKMEMBER(int, pfnRegionCreate,(void *pvEnv, + uint32_t u32RegionSize, + uint32_t *pu32GmrId, + void **ppvMap)); + DECLCALLBACKMEMBER(void, pfnRegionDestroy,(void *pvEnv, + uint32_t u32GmrId, + void *pvMap)); + /* VGPU10 */ + DECLCALLBACKMEMBER(int, pfnGBSurfaceDefine,(void *pvEnv, + SVGAGBSURFCREATE *pCreateParms)); +} WDDMGalliumDriverEnv; + +struct pipe_context; +struct pipe_screen; +struct pipe_resource; + +typedef struct pipe_screen * WINAPI FNGaDrvScreenCreate(const WDDMGalliumDriverEnv *pEnv); +typedef FNGaDrvScreenCreate *PFNGaDrvScreenCreate; + +typedef void WINAPI FNGaDrvScreenDestroy(struct pipe_screen *s); +typedef FNGaDrvScreenDestroy *PFNGaDrvScreenDestroy; + +typedef const WDDMGalliumDriverEnv * WINAPI FNGaDrvGetWDDMEnv(struct pipe_screen *pScreen); +typedef FNGaDrvGetWDDMEnv *PFNGaDrvGetWDDMEnv; + +typedef uint32_t WINAPI FNGaDrvGetContextId(struct pipe_context *pPipeContext); +typedef FNGaDrvGetContextId *PFNGaDrvGetContextId; + +typedef uint32_t WINAPI FNGaDrvGetSurfaceId(struct pipe_screen *pScreen, struct pipe_resource *pResource); +typedef FNGaDrvGetSurfaceId *PFNGaDrvGetSurfaceId; + +typedef void WINAPI FNGaDrvContextFlush(struct pipe_context *pPipeContext); +typedef FNGaDrvContextFlush *PFNGaDrvContextFlush; + +#ifdef __cplusplus +} +#endif + +#endif /* !GA_INCLUDED_3D_WIN_VBoxGaDriver_h */ + diff --git a/src/VBox/Additions/3D/win/include/VBoxGaHWInfo.h b/src/VBox/Additions/3D/win/include/VBoxGaHWInfo.h new file mode 100644 index 00000000..54a38eda --- /dev/null +++ b/src/VBox/Additions/3D/win/include/VBoxGaHWInfo.h @@ -0,0 +1,64 @@ +/* $Id: VBoxGaHWInfo.h $ */ +/** @file + * VirtualBox Windows Guest Mesa3D - Gallium driver interface. + */ + +/* + * Copyright (C) 2016-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#ifndef GA_INCLUDED_3D_WIN_VBoxGaHWInfo_h +#define GA_INCLUDED_3D_WIN_VBoxGaHWInfo_h +#ifndef RT_WITHOUT_PRAGMA_ONCE +# pragma once +#endif + +#include <iprt/assert.h> + +#include <VBoxGaHwSVGA.h> + +/* Gallium virtual hardware supported by the miniport. */ +#define VBOX_GA_HW_TYPE_UNKNOWN 0 +#define VBOX_GA_HW_TYPE_VMSVGA 1 + +/* + * VBOXGAHWINFO contains information about the virtual hardware, which is passed + * to the user mode Gallium driver. The driver can not query the info at the initialization time, + * therefore we send the complete info to the driver. + * + * VBOXGAHWINFO struct goes both to 32 and 64 bit user mode binaries, take care of alignment. + */ +#pragma pack(1) +typedef struct VBOXGAHWINFO +{ + uint32_t u32HwType; /* VBOX_GA_HW_TYPE_* */ + uint32_t u32Reserved; + union + { + VBOXGAHWINFOSVGA svga; + uint8_t au8Raw[65536]; + } u; +} VBOXGAHWINFO; +#pragma pack() + +AssertCompile(RT_SIZEOFMEMB(VBOXGAHWINFO, u) <= RT_SIZEOFMEMB(VBOXGAHWINFO, u.au8Raw)); + +#endif /* !GA_INCLUDED_3D_WIN_VBoxGaHWInfo_h */ diff --git a/src/VBox/Additions/3D/win/include/VBoxGaHwSVGA.h b/src/VBox/Additions/3D/win/include/VBoxGaHwSVGA.h new file mode 100644 index 00000000..6c145eb0 --- /dev/null +++ b/src/VBox/Additions/3D/win/include/VBoxGaHwSVGA.h @@ -0,0 +1,66 @@ +/* $Id: VBoxGaHwSVGA.h $ */ +/** @file + * VirtualBox Windows Guest Mesa3D - Gallium driver interface. + */ + +/* + * Copyright (C) 2016-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#ifndef GA_INCLUDED_3D_WIN_VBoxGaHwSVGA_h +#define GA_INCLUDED_3D_WIN_VBoxGaHwSVGA_h +#ifndef RT_WITHOUT_PRAGMA_ONCE +# pragma once +#endif + +#include <iprt/types.h> + +/* + * VBOXGAHWINFOSVGA contains information about the virtual hardware, which is neede dy the user mode + * Gallium driver. The driver can not query the info at the initialization time, therefore + * we send the complete info to the driver. + * + * Since both FIFO and SVGA_REG_ are expanded over time, we reserve some space. + * The Gallium user mode driver can figure out which part of au32Regs and au32Fifo + * is valid from the raw data. + * + * VBOXGAHWINFOSVGA struct goes both to 32 and 64 bit user mode binaries, take care of alignment. + */ +#pragma pack(1) +typedef struct VBOXGAHWINFOSVGA +{ + uint32_t cbInfoSVGA; + + /* Copy of SVGA_REG_*, up to 256, currently 58 are used. */ + uint32_t au32Regs[256]; + + /* Copy of FIFO registers, up to 1024, currently 290 are used. */ + uint32_t au32Fifo[1024]; + + /* Currently SVGA has 260 caps, 512 should be ok for near future. + * This is a copy of SVGA3D_DEVCAP_* values returned by the host. + * Only valid if SVGA_CAP_GBOBJECTS is set in SVGA_REG_CAPABILITIES. + */ + uint32_t au32Caps[512]; +} VBOXGAHWINFOSVGA; +#pragma pack() + +#endif /* !GA_INCLUDED_3D_WIN_VBoxGaHwSVGA_h */ diff --git a/src/VBox/Additions/3D/win/include/VBoxGaNine.h b/src/VBox/Additions/3D/win/include/VBoxGaNine.h new file mode 100644 index 00000000..cb896c5e --- /dev/null +++ b/src/VBox/Additions/3D/win/include/VBoxGaNine.h @@ -0,0 +1,58 @@ +/* $Id: VBoxGaNine.h $ */ +/** @file + * VirtualBox Windows Guest Mesa3D - Gallium driver interface for WDDM user mode driver. + */ + +/* + * Copyright (C) 2016-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#ifndef GA_INCLUDED_3D_WIN_VBoxGaNine_h +#define GA_INCLUDED_3D_WIN_VBoxGaNine_h +#ifndef RT_WITHOUT_PRAGMA_ONCE +# pragma once +#endif + +#include <iprt/win/d3d9.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct pipe_screen; +struct pipe_resource; +struct pipe_context; +typedef struct ID3DAdapter9 ID3DAdapter9; + +typedef HRESULT WINAPI FNGaNineD3DAdapter9Create(struct pipe_screen *s, ID3DAdapter9 **ppOut); +typedef FNGaNineD3DAdapter9Create *PFNGaNineD3DAdapter9Create; + +typedef struct pipe_resource * WINAPI FNGaNinePipeResourceFromSurface(IUnknown *pSurface); +typedef FNGaNinePipeResourceFromSurface *PFNGaNinePipeResourceFromSurface; + +typedef struct pipe_context * WINAPI FNGaNinePipeContextFromDevice(IDirect3DDevice9 *pDevice); +typedef FNGaNinePipeContextFromDevice *PFNGaNinePipeContextFromDevice; + +#ifdef __cplusplus +} +#endif + +#endif /* !GA_INCLUDED_3D_WIN_VBoxGaNine_h */ diff --git a/src/VBox/Additions/3D/win/include/VBoxGaTypes.h b/src/VBox/Additions/3D/win/include/VBoxGaTypes.h new file mode 100644 index 00000000..cfd379a1 --- /dev/null +++ b/src/VBox/Additions/3D/win/include/VBoxGaTypes.h @@ -0,0 +1,114 @@ +/* $Id: VBoxGaTypes.h $ */ +/** @file + * VirtualBox Windows Guest Mesa3D - Gallium driver interface. + */ + +/* + * Copyright (C) 2016-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#ifndef GA_INCLUDED_3D_WIN_VBoxGaTypes_h +#define GA_INCLUDED_3D_WIN_VBoxGaTypes_h +#ifndef RT_WITHOUT_PRAGMA_ONCE +# pragma once +#endif + +#include <iprt/types.h> + +#pragma pack(1) /* VMSVGA structures are '__packed'. */ +#include <svga3d_caps.h> +#include <svga3d_reg.h> +#pragma pack() + +#ifdef __cplusplus +extern "C" { +#endif + +#define GA_MAX_SURFACE_FACES 6 +#define GA_MAX_MIP_LEVELS 24 + +typedef struct GASURFCREATE +{ + uint32_t flags; /* SVGA3dSurfaceFlags */ + uint32_t format; /* SVGA3dSurfaceFormat */ + uint32_t usage; /* SVGA_SURFACE_USAGE_* */ + uint32_t mip_levels[GA_MAX_SURFACE_FACES]; +} GASURFCREATE; + +typedef struct GASURFSIZE +{ + uint32_t cWidth; + uint32_t cHeight; + uint32_t cDepth; + uint32_t u32Reserved; +} GASURFSIZE; + +#define GA_FENCE_STATUS_NULL 0 /* Fence not found */ +#define GA_FENCE_STATUS_IDLE 1 +#define GA_FENCE_STATUS_SUBMITTED 2 +#define GA_FENCE_STATUS_SIGNALED 3 + +typedef struct GAFENCEQUERY +{ + /* IN: The miniport's handle of the fence. + * Assigned by the miniport. Not DXGK fence id! + */ + uint32_t u32FenceHandle; + + /* OUT: The miniport's sequence number associated with the command buffer. + */ + uint32_t u32SubmittedSeqNo; + + /* OUT: The miniport's sequence number associated with the last command buffer completed on host. + */ + uint32_t u32ProcessedSeqNo; + + /* OUT: GA_FENCE_STATUS_*. */ + uint32_t u32FenceStatus; +} GAFENCEQUERY; + +typedef struct SVGAGBSURFCREATE +{ + /* Surface data. */ + struct + { + SVGA3dSurfaceAllFlags flags; + SVGA3dSurfaceFormat format; + unsigned usage; + SVGA3dSize size; + uint32_t numFaces; + uint32_t numMipLevels; + unsigned sampleCount; + SVGA3dMSPattern multisamplePattern; + SVGA3dMSQualityLevel qualityLevel; + } s; + uint32_t gmrid; /* In/Out: Backing GMR. */ + uint32_t cbGB; /* Out: Size of backing memory. */ + uint64_t u64UserAddress; /* Out: R3 mapping of the backing memory. */ + uint32_t u32Sid; /* Out: Surface id. */ +} SVGAGBSURFCREATE, *PSVGAGBSURFCREATE; + +#ifdef __cplusplus +} +#endif + +#endif /* !GA_INCLUDED_3D_WIN_VBoxGaTypes_h */ + |