VirtualBox

source: vbox/trunk/src/VBox/Additions/3D/win/VBoxNine/VBoxNine.c@ 76553

Last change on this file since 76553 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1/* $Id: VBoxNine.c 76553 2019-01-01 01:45:53Z vboxsync $ */
2/** @file
3 * VirtualBox Windows Guest Mesa3D - Direct3D9 state tracker.
4 */
5
6/*
7 * Copyright (C) 2016-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#include <iprt/win/windows.h>
19#include <iprt/win/d3d9.h>
20//#include <d3dumddi.h>
21
22#include <VBoxWddmUmHlp.h>
23
24//#include <windef.h>
25//#include <winbase.h>
26//#include <winsvc.h>
27//#include <winnetwk.h>
28//#include <npapi.h>
29//#include <devioctl.h>
30//#include <stdio.h>
31
32//#include <iprt/alloc.h>
33//#include <iprt/initterm.h>
34//#include <iprt/string.h>
35//#include <iprt/log.h>
36//#include <VBox/version.h>
37//#include <VBox/VMMDev.h>
38//#include <VBox/Log.h>
39
40#include "adapter9.h"
41#include "surface9.h"
42#include "pipe/p_screen.h"
43
44#include <iprt/types.h>
45// #include <iprt/asm.h>
46
47// #include "VBoxNine.h"
48
49struct d3dadapter9_context_wddm
50{
51 struct d3dadapter9_context base;
52 void *reserved;
53};
54
55static void
56wddm_destroy(struct d3dadapter9_context *ctx)
57{
58 /* struct d3dadapter9_context_wddm *ctx_wddm = (struct d3dadapter9_context_wddm *)ctx; */
59
60/// @todo screen (hal) is deleted by the upper level. Do not delete here.
61// if (ctx->ref)
62// ctx->ref->destroy(ctx->ref);
63// /* because ref is a wrapper around hal, freeing ref frees hal too. */
64// else if (ctx->hal)
65// ctx->hal->destroy(ctx->hal);
66
67 FREE(ctx);
68}
69
70static HRESULT
71d3dadapter9_context_wddm_create(struct d3dadapter9_context_wddm **ppCtx, struct pipe_screen *s)
72{
73 struct d3dadapter9_context_wddm *ctx = CALLOC_STRUCT(d3dadapter9_context_wddm);
74
75 if (!ctx) { return E_OUTOFMEMORY; }
76
77 ctx->base.destroy = wddm_destroy;
78
79 ctx->base.linear_framebuffer = 1;
80
81 ctx->base.hal = s;
82
83 ctx->base.throttling = FALSE;
84 ctx->base.throttling_value = 0;
85
86 ctx->base.vblank_mode = 1;
87
88 ctx->base.thread_submit = 0;
89
90 /** @todo Need software device here. Currently assigned to hw device to prevent NineDevice9_ctor crash. */
91 ctx->base.ref = ctx->base.hal;
92
93 /* read out PCI info */
94 /// @todo read_descriptor(&ctx->base, fd);
95
96 *ppCtx = ctx;
97 return D3D_OK;
98}
99
100HRESULT WINAPI
101GaNineD3DAdapter9Create(struct pipe_screen *s, ID3DAdapter9 **ppOut)
102{
103 HRESULT hr;
104 struct d3dadapter9_context_wddm *pCtx = NULL;
105 hr = d3dadapter9_context_wddm_create(&pCtx, s);
106 if (SUCCEEDED(hr))
107 {
108 hr = NineAdapter9_new(&pCtx->base, (struct NineAdapter9 **)ppOut);
109 if (FAILED(hr))
110 {
111 /// @todo NineAdapter9_new calls this as ctx->base.destroy,
112 // and will not call if memory allocation fails.
113 // wddm_destroy(&pCtx->base);
114 }
115 }
116 return hr;
117}
118
119struct pipe_resource * WINAPI
120GaNinePipeResourceFromSurface(IUnknown *pSurface)
121{
122 /// @todo QueryInterface?
123 struct NineResource9 *pResource = (struct NineResource9 *)pSurface;
124 return pResource->resource;
125}
126
127extern struct pipe_context *
128NineDevice9_GetPipe( struct NineDevice9 *This );
129
130struct pipe_context * WINAPI
131GaNinePipeContextFromDevice(IDirect3DDevice9 *pDevice)
132{
133 /// @todo Verify that this is a NineDevice?
134 struct pipe_context *pPipeContext = NineDevice9_GetPipe((struct NineDevice9 *)pDevice);
135 return pPipeContext;
136}
137
138BOOL WINAPI DllMain(HINSTANCE hDLLInst,
139 DWORD fdwReason,
140 LPVOID lpvReserved)
141{
142 BOOL fReturn = TRUE;
143
144 RT_NOREF2(hDLLInst, lpvReserved);
145
146 switch (fdwReason)
147 {
148 case DLL_PROCESS_ATTACH:
149 //RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
150 D3DKMTLoad();
151 break;
152
153 case DLL_PROCESS_DETACH:
154 /// @todo RTR3Term();
155 break;
156
157 case DLL_THREAD_ATTACH:
158 break;
159
160 case DLL_THREAD_DETACH:
161 break;
162
163 default:
164 break;
165 }
166
167 return fReturn;
168}
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