VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_config.cpp@ 78408

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

Additions,GuestHost/OpenGL,HostServices/SharedOpenGL: Get rid of the individual SPU shared libraries and merge them into the VBoxSharedCrOpenGL shared libraries on the host and VBoxOGL{,-x86} shared libraries for the guest additions, bugref:9435

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 5.7 KB
Line 
1 /* Copyright (c) 2001, Stanford University
2 * All rights reserved
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#include <string.h>
8#include "cr_mem.h"
9#include "cr_string.h"
10#include "cr_error.h"
11#include "cr_glstate.h"
12#include "server.h"
13
14#include <iprt/env.h>
15
16#ifdef WINDOWS
17#pragma warning( disable: 4706 )
18#endif
19
20static void
21setDefaults(void)
22{
23 cr_server.run_queue = NULL;
24 cr_server.optimizeBucket = 1;
25 cr_server.useL2 = 0;
26 cr_server.maxBarrierCount = 0;
27 cr_server.ignore_papi = 0;
28 cr_server.only_swap_once = 0;
29 cr_server.overlapBlending = 0;
30 cr_server.debug_barriers = 0;
31 cr_server.sharedDisplayLists = 0;
32 cr_server.sharedTextureObjects = 0;
33 cr_server.sharedPrograms = 0;
34 cr_server.sharedWindows = 0;
35 cr_server.useDMX = 0;
36 cr_server.vpProjectionMatrixParameter = -1;
37 cr_server.vpProjectionMatrixVariable = NULL;
38 cr_server.currentProgram = 0;
39
40 cr_server.num_overlap_intens = 0;
41 cr_server.overlap_intens = 0;
42 crMemset(&cr_server.MainContextInfo, 0, sizeof (cr_server.MainContextInfo));
43
44 crMatrixInit(&cr_server.viewMatrix[0]);
45 crMatrixInit(&cr_server.viewMatrix[1]);
46 crMatrixInit(&cr_server.projectionMatrix[0]);
47 crMatrixInit(&cr_server.projectionMatrix[1]);
48 cr_server.currentEye = -1;
49
50 cr_server.uniqueWindows = 0;
51
52 cr_server.screenCount = 0;
53 cr_server.bUsePBOForReadback = GL_FALSE;
54 cr_server.bWindowsInitiallyHidden = GL_FALSE;
55
56 cr_server.pfnNotifyEventCB = NULL;
57}
58
59/* Check if host reports minimal OpenGL capabilities.
60 *
61 * Require OpenGL 2.1 or later.
62 *
63 * For example, on Windows host this may happen if host has no graphics
64 * card drivers installed or drivers were not properly signed or VBox
65 * is running via remote desktop session etc. Currently, we take care
66 * about Windows host only when specific RENDERER and VERSION strings
67 * returned in this case. Later this check should be expanded to the
68 * rest of hosts. */
69static bool crServerHasInsufficientCaps()
70{
71 const char *pszRealVersion;
72 int rc;
73 uint32_t u32VerMajor = 0;
74 uint32_t u32VerMinor = 0;
75 char *pszNext = NULL;
76
77 if (!cr_server.head_spu)
78 return true;
79
80 pszRealVersion = (const char *)cr_server.head_spu->dispatch_table.GetString(GL_REAL_VERSION);
81 if (!pszRealVersion)
82 return true; /* No version == insufficient. */
83
84 rc = RTStrToUInt32Ex(pszRealVersion, &pszNext, 10, &u32VerMajor);
85 if ( RT_SUCCESS(rc)
86 && *pszNext == '.')
87 RTStrToUInt32Ex(pszNext + 1, NULL, 10, &u32VerMinor);
88
89 crInfo("Host supports version %d.%d [%s]", u32VerMajor, u32VerMinor, pszRealVersion);
90
91 if ( u32VerMajor > 2
92 || (u32VerMajor == 2 && u32VerMinor >= 1))
93 return false; /* >= 2.1, i.e. good enough. */
94
95 return true; /* Insufficient. */
96}
97
98void crServerSetVBoxConfigurationHGCM()
99{
100 CRMuralInfo *defaultMural;
101 int i;
102 GLint dims[4];
103 const char * env;
104
105 defaultMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, 0);
106 CRASSERT(defaultMural);
107
108 /// @todo should be moved to addclient so we have a chain for each client
109
110 setDefaults();
111
112 /* Load the SPUs */
113 PCSPUREG aSpuRegs[] = { &g_RenderSpuReg, &g_ErrorSpuReg, NULL};
114 cr_server.head_spu = crSPUInitFromReg(NULL, 0, "render", &cr_server, &aSpuRegs[0]);
115 if (!cr_server.head_spu)
116 return;
117
118
119 env = RTEnvGet( "CR_SERVER_DEFAULT_VISUAL_BITS" );
120 if (env != NULL && env[0] != '\0')
121 {
122 unsigned int bits = (unsigned int)crStrParseI32(env, 0);
123 if (bits <= CR_ALL_BITS)
124 cr_server.fVisualBitsDefault = bits;
125 else
126 crWarning("invalid bits option %c", bits);
127 }
128 else
129 cr_server.fVisualBitsDefault = CR_RGB_BIT | CR_ALPHA_BIT | CR_DOUBLE_BIT;
130
131
132 env = RTEnvGet("CR_SERVER_CAPS");
133 if (env && env[0] != '\0')
134 {
135 cr_server.u32Caps = crStrParseI32(env, 0);
136 cr_server.u32Caps &= CR_VBOX_CAPS_ALL;
137 }
138 else
139 {
140 cr_server.u32Caps = CR_VBOX_CAP_TEX_PRESENT
141 | CR_VBOX_CAP_CMDVBVA
142 | CR_VBOX_CAP_CMDBLOCKS
143 | CR_VBOX_CAP_GETATTRIBSLOCATIONS
144 | CR_VBOX_CAP_CMDBLOCKS_FLUSH
145 ;
146 }
147
148 if (crServerHasInsufficientCaps())
149 {
150 crDebug("Cfg: report minimal OpenGL capabilities");
151 cr_server.u32Caps |= CR_VBOX_CAP_HOST_CAPS_NOT_SUFFICIENT;
152 }
153
154 crInfo("Cfg: u32Caps(%#x), fVisualBitsDefault(%#x)",
155 cr_server.u32Caps,
156 cr_server.fVisualBitsDefault);
157
158 cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_POSITION_CR, 0, GL_INT, 2, &dims[0]);
159 cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, 0, GL_INT, 2, &dims[2]);
160
161 defaultMural->gX = dims[0];
162 defaultMural->gY = dims[1];
163 defaultMural->width = dims[2];
164 defaultMural->height = dims[3];
165
166 cr_server.mtu = 1024 * 250;
167
168 cr_server.numClients = 0;
169 strcpy(cr_server.protocol, "vboxhgcm");
170
171 for (i = 0; i < cr_server.numClients; i++)
172 {
173 CRClient *newClient = (CRClient *) crCalloc(sizeof(CRClient));
174 newClient->spu_id = 0;
175 newClient->conn = crNetAcceptClient(cr_server.protocol, NULL,
176 cr_server.tcpip_port,
177 cr_server.mtu, 0);
178 newClient->currentCtxInfo = &cr_server.MainContextInfo;
179 crServerAddToRunQueue(newClient);
180
181 cr_server.clients[i] = newClient;
182 }
183
184 /* set default client and mural */
185 if (cr_server.numClients > 0) {
186 cr_server.curClient = cr_server.clients[0];
187 cr_server.curClient->currentMural = defaultMural;
188 cr_server.client_spu_id =cr_server.clients[0]->spu_id;
189 }
190}
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