From f215e02bf85f68d3a6106c2a1f4f7f063f819064 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 11 Apr 2024 10:17:27 +0200 Subject: Adding upstream version 7.0.14-dfsg. Signed-off-by: Daniel Baumann --- .../Additions/3D/win/VBoxSVGA/winsys/vmw_screen.c | 134 +++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 src/VBox/Additions/3D/win/VBoxSVGA/winsys/vmw_screen.c (limited to 'src/VBox/Additions/3D/win/VBoxSVGA/winsys/vmw_screen.c') 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 . + * + * 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); + } +} -- cgit v1.2.3