VirtualBox

source: vbox/trunk/src/VBox/Additions/3D/win/VBoxSVGA/winsys/vmw_screen.c@ 103999

Last change on this file since 103999 was 103999, checked in by vboxsync, 8 months ago

Addition/3D,Additions/WINNT/Graphics: Updates for mesa-24.0.2 (not enabled yet). bugref:10606

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1/*
2 * Copyright (C) 2016-2023 Oracle and/or its affiliates.
3 *
4 * This file is part of VirtualBox base platform packages, as
5 * available from https://www.virtualbox.org.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, in version 3 of the
10 * License.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <https://www.gnu.org/licenses>.
19 *
20 * SPDX-License-Identifier: GPL-3.0-only
21 */
22
23/**********************************************************
24 * Copyright 2009-2015 VMware, Inc. All rights reserved.
25 *
26 * Permission is hereby granted, free of charge, to any person
27 * obtaining a copy of this software and associated documentation
28 * files (the "Software"), to deal in the Software without
29 * restriction, including without limitation the rights to use, copy,
30 * modify, merge, publish, distribute, sublicense, and/or sell copies
31 * of the Software, and to permit persons to whom the Software is
32 * furnished to do so, subject to the following conditions:
33 *
34 * The above copyright notice and this permission notice shall be
35 * included in all copies or substantial portions of the Software.
36 *
37 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
38 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
39 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
40 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
41 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
42 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
43 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
44 * SOFTWARE.
45 *
46 **********************************************************/
47
48
49#include "../wddm_screen.h"
50#include "vmw_fence.h"
51#include "vmw_context.h"
52#include "vmwgfx_drm.h"
53
54#include "util/os_file.h"
55#include "util/u_memory.h"
56#if VBOX_MESA_V_MAJOR < 24
57#include "pipe/p_compiler.h"
58#else
59#include "util/compiler.h"
60#endif
61#include "util/u_hash_table.h"
62
63/* Called from vmw_drm_create_screen(), creates and initializes the
64 * vmw_winsys_screen structure, which is the main entity in this
65 * module.
66 * First, check whether a vmw_winsys_screen object already exists for
67 * this device, and in that case return that one, making sure that we
68 * have our own file descriptor open to DRM.
69 */
70
71struct vmw_winsys_screen_wddm *
72vmw_winsys_create_wddm(const WDDMGalliumDriverEnv *pEnv)
73{
74 struct vmw_winsys_screen_wddm *vws_wddm;
75 struct vmw_winsys_screen *vws;
76
77 if ( pEnv->pHWInfo == NULL
78 || pEnv->pHWInfo->u32HwType != VBOX_GA_HW_TYPE_VMSVGA)
79 return NULL;
80
81 vws_wddm = CALLOC_STRUCT(vmw_winsys_screen_wddm);
82 vws = &vws_wddm->base;
83 if (!vws)
84 goto out_no_vws;
85
86 vws_wddm->pEnv = pEnv;
87 vws_wddm->HwInfo = pEnv->pHWInfo->u.svga;
88
89 vws->device = 0; /* not used */
90 vws->open_count = 1;
91 vws->ioctl.drm_fd = -1; /* not used */
92 vws->force_coherent = false;
93 if (!vmw_ioctl_init(vws))
94 goto out_no_ioctl;
95
96 vws->base.have_gb_dma = !vws->force_coherent;
97 vws->base.need_to_rebind_resources = false;
98 vws->base.have_transfer_from_buffer_cmd = vws->base.have_vgpu10;
99#if VBOX_MESA_V_MAJOR < 24
100 vws->base.have_constant_buffer_offset_cmd = false;
101#else
102 vws->base.have_constant_buffer_offset_cmd =
103 vws->ioctl.have_drm_2_20 && vws->base.have_sm5;
104 vws->base.have_index_vertex_buffer_offset_cmd = false;
105 vws->base.have_rasterizer_state_v2_cmd =
106 vws->ioctl.have_drm_2_20 && vws->base.have_sm5;
107#endif
108
109 vws->cache_maps = false;
110 vws->fence_ops = vmw_fence_ops_create(vws);
111 if (!vws->fence_ops)
112 goto out_no_fence_ops;
113
114 if(!vmw_pools_init(vws))
115 goto out_no_pools;
116
117 if (!vmw_winsys_screen_init_svga(vws))
118 goto out_no_svga;
119
120 cnd_init(&vws->cs_cond);
121 mtx_init(&vws->cs_mutex, mtx_plain);
122
123 return vws_wddm;
124out_no_svga:
125 vmw_pools_cleanup(vws);
126out_no_pools:
127 vws->fence_ops->destroy(vws->fence_ops);
128out_no_fence_ops:
129 vmw_ioctl_cleanup(vws);
130out_no_ioctl:
131 FREE(vws);
132out_no_vws:
133 return NULL;
134}
135
136void
137vmw_winsys_destroy(struct vmw_winsys_screen *vws)
138{
139 if (--vws->open_count == 0) {
140 vmw_pools_cleanup(vws);
141 vws->fence_ops->destroy(vws->fence_ops);
142 vmw_ioctl_cleanup(vws);
143 mtx_destroy(&vws->cs_mutex);
144 cnd_destroy(&vws->cs_cond);
145 FREE(vws);
146 }
147}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette