Changeset 55763 in vbox
- Timestamp:
- May 8, 2015 6:41:02 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c
r55762 r55763 1220 1220 } 1221 1221 1222 static int crVBoxAddFBDataElement(CRFBData *pData, GLint idFBO, GLenum enmBuffer, GLint width, GLint height, GLenum enmFormat, GLenum enmType) 1223 { 1224 CRFBDataElement *pEl; 1225 1226 AssertCompile(sizeof (GLfloat) == 4); 1227 AssertCompile(sizeof (GLuint) == 4); 1228 1229 pEl = &pData->aElements[pData->cElements]; 1230 pEl->idFBO = idFBO; 1231 pEl->enmBuffer = enmBuffer; 1232 pEl->posX = 0; 1233 pEl->posY = 0; 1234 pEl->width = width; 1235 pEl->height = height; 1236 pEl->enmFormat = enmFormat; 1237 pEl->enmType = enmType; 1238 pEl->cbData = width * height * 4; 1239 1240 pEl->pvData = crCalloc(pEl->cbData); 1241 if (!pEl->pvData) 1242 { 1243 crVBoxServerFBImageDataTerm(pData); 1244 crWarning(": crCalloc failed"); 1245 return VERR_NO_MEMORY; 1246 } 1247 1248 ++pData->cElements; 1249 1250 return VINF_SUCCESS; 1251 } 1252 1222 1253 static int crVBoxServerFBImageDataInitEx(CRFBData *pData, CRContextInfo *pCtxInfo, CRMuralInfo *pMural, GLboolean fWrite, uint32_t version, GLuint overrideWidth, GLuint overrideHeight) 1223 1254 { … … 1228 1259 GLuint width; 1229 1260 GLuint height; 1261 int rc; 1230 1262 1231 1263 crMemset(pData, 0, sizeof (*pData)); … … 1258 1290 pData->cElements = 0; 1259 1291 1260 pEl = &pData->aElements[pData->cElements]; 1261 pEl->idFBO = pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0; 1262 pEl->enmBuffer = pData->aElements[1].idFBO ? GL_COLOR_ATTACHMENT0 : GL_FRONT; 1263 pEl->posX = 0; 1264 pEl->posY = 0; 1265 pEl->width = width; 1266 pEl->height = height; 1267 pEl->enmFormat = GL_RGBA; 1268 pEl->enmType = GL_UNSIGNED_BYTE; 1269 pEl->cbData = width * height * 4; 1270 pEl->pvData = crCalloc(pEl->cbData); 1271 if (!pEl->pvData) 1272 { 1273 crVBoxServerFBImageDataTerm(pData); 1274 crWarning("crVBoxServerFBImageDataInit: crCalloc failed"); 1275 return VERR_NO_MEMORY; 1276 } 1277 ++pData->cElements; 1278 1279 /* there is a lot of code that assumes we have double buffering, just assert here to print a warning in the log 1280 * so that we know that something irregular is going on */ 1292 rc = crVBoxAddFBDataElement( 1293 pData, 1294 pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0, 1295 pData->aElements[1].idFBO ? GL_COLOR_ATTACHMENT0 : GL_FRONT, 1296 width, height, GL_RGBA, GL_UNSIGNED_BYTE); 1297 AssertReturn(rc == VINF_SUCCESS, rc); 1298 1299 /* There is a lot of code that assumes we have double buffering, just assert here to print a warning in the log 1300 * so that we know that something irregular is going on. */ 1281 1301 CRASSERT(pCtxInfo->CreateInfo.requestedVisualBits & CR_DOUBLE_BIT); 1282 if ((pCtxInfo->CreateInfo.requestedVisualBits & CR_DOUBLE_BIT) 1283 || version < SHCROGL_SSM_VERSION_WITH_SINGLE_DEPTH_STENCIL /* <- older version had a typo which lead to back always being used, 1284 * no matter what the visual bits are */ 1285 ) 1286 { 1287 pEl = &pData->aElements[pData->cElements]; 1288 pEl->idFBO = pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_BB_IDX(pMural)] : 0; 1289 pEl->enmBuffer = pData->aElements[1].idFBO ? GL_COLOR_ATTACHMENT0 : GL_BACK; 1290 pEl->posX = 0; 1291 pEl->posY = 0; 1292 pEl->width = width; 1293 pEl->height = height; 1294 pEl->enmFormat = GL_RGBA; 1295 pEl->enmType = GL_UNSIGNED_BYTE; 1296 pEl->cbData = width * height * 4; 1297 pEl->pvData = crCalloc(pEl->cbData); 1298 if (!pEl->pvData) 1299 { 1300 crVBoxServerFBImageDataTerm(pData); 1301 crWarning("crVBoxServerFBImageDataInit: crCalloc failed"); 1302 return VERR_NO_MEMORY; 1303 } 1304 ++pData->cElements; 1302 1303 if (( pCtxInfo->CreateInfo.requestedVisualBits & CR_DOUBLE_BIT) 1304 || version < SHCROGL_SSM_VERSION_WITH_SINGLE_DEPTH_STENCIL) /* <- Older version had a typo which lead to back always being used, 1305 * no matter what the visual bits are. */ 1306 { 1307 rc = crVBoxAddFBDataElement( 1308 pData, 1309 pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_BB_IDX(pMural)] : 0, 1310 pData->aElements[1].idFBO ? GL_COLOR_ATTACHMENT0 : GL_BACK, 1311 width, height, GL_RGBA, GL_UNSIGNED_BYTE); 1312 AssertReturn(rc == VINF_SUCCESS, rc); 1305 1313 } 1306 1314 1307 1315 if (version < SHCROGL_SSM_VERSION_WITH_SAVED_DEPTH_STENCIL_BUFFER) 1308 return VINF_SUCCESS;1316 return VINF_SUCCESS; 1309 1317 1310 1318 if (pCtxInfo->CreateInfo.requestedVisualBits & CR_DEPTH_BIT) 1311 1319 { 1312 AssertCompile(sizeof (GLfloat) == 4); 1313 pEl = &pData->aElements[pData->cElements]; 1314 pEl->idFBO = pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0; 1315 pEl->enmBuffer = pMural ? pMural->idDepthRB : 0; 1316 pEl->posX = 0; 1317 pEl->posY = 0; 1318 pEl->width = width; 1319 pEl->height = height; 1320 pEl->enmFormat = GL_DEPTH_COMPONENT; 1321 pEl->enmType = GL_FLOAT; 1322 pEl->cbData = width * height * 4; 1323 pEl->pvData = crCalloc(pEl->cbData); 1324 if (!pEl->pvData) 1325 { 1326 crVBoxServerFBImageDataTerm(pData); 1327 crWarning("crVBoxServerFBImageDataInit: crCalloc failed"); 1328 return VERR_NO_MEMORY; 1329 } 1330 1331 /* init to default depth value, just in case */ 1320 rc = crVBoxAddFBDataElement( 1321 pData, 1322 pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0, 1323 pMural ? pMural->idDepthRB : 0, 1324 width, height, GL_DEPTH_COMPONENT, GL_FLOAT); 1325 AssertReturn(rc == VINF_SUCCESS, rc); 1326 1327 /* Init to default depth value, just in case. */ 1332 1328 pF = (GLfloat*)pEl->pvData; 1333 1329 for (i = 0; i < width * height; ++i) 1334 {1335 1330 pF[i] = 1.; 1336 }1337 ++pData->cElements;1338 1331 } 1339 1332 1340 1333 if (pCtxInfo->CreateInfo.requestedVisualBits & CR_STENCIL_BIT) 1341 1334 { 1342 AssertCompile(sizeof (GLuint) == 4); 1343 pEl = &pData->aElements[pData->cElements]; 1344 pEl->idFBO = pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0; 1345 pEl->enmBuffer = pMural ? pMural->idDepthRB : 0; 1346 pEl->posX = 0; 1347 pEl->posY = 0; 1348 pEl->width = width; 1349 pEl->height = height; 1350 pEl->enmFormat = GL_STENCIL_INDEX; 1351 pEl->enmType = GL_UNSIGNED_INT; 1352 pEl->cbData = width * height * 4; 1353 pEl->pvData = crCalloc(pEl->cbData); 1354 if (!pEl->pvData) 1355 { 1356 crVBoxServerFBImageDataTerm(pData); 1357 crWarning("crVBoxServerFBImageDataInit: crCalloc failed"); 1358 return VERR_NO_MEMORY; 1359 } 1360 ++pData->cElements; 1335 rc = crVBoxAddFBDataElement( 1336 pData, 1337 pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0, 1338 pMural ? pMural->idDepthRB : 0, 1339 width, height, GL_STENCIL_INDEX, GL_UNSIGNED_INT); 1340 AssertReturn(rc == VINF_SUCCESS, rc); 1361 1341 } 1362 1342
Note:
See TracChangeset
for help on using the changeset viewer.

