Changeset 36052 in vbox for trunk/src/VBox/HostServices/SharedOpenGL
- Timestamp:
- Feb 22, 2011 1:45:06 PM (14 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedOpenGL/crserverlib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/get_components.py
r32078 r36052 31 31 'GL_TEXTURE_HEIGHT': 1, 32 32 'GL_TEXTURE_DEPTH': 1, 33 # 'GL_TEXTURE_INTERNAL_FORMAT': 1, THIS CONFLICTS WITH SOMETHING?!33 # 'GL_TEXTURE_INTERNAL_FORMAT': 1, THIS CONFLICTS WITH GL_TEXTURE_COMPONENTS! 34 34 'GL_TEXTURE_BORDER': 1, 35 35 'GL_TEXTURE_RED_SIZE': 1, … … 110 110 'GL_CURRENT_QUERY_ARB': (1, 'CR_ARB_occlusion_query'), 111 111 'GL_TEXTURE_COMPRESSED_IMAGE_SIZE': (1, 'CR_ARB_texture_compression'), 112 'GL_TEXTURE_COMPRESSED': (1, 'CR_ARB_texture_compression'), 112 113 'GL_COORD_REPLACE_ARB': (1, 'CR_ARB_point_sprite'), 113 114 } -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_config.c
r35969 r36052 57 57 cr_server.screenCount = 0; 58 58 cr_server.bForceOffscreenRendering = GL_FALSE; 59 cr_server.bUsePBOForReadback = GL_FALSE; 59 60 } 60 61 -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c
r36050 r36052 339 339 crStateDiffAPI( &(cr_server.head_spu->dispatch_table) ); 340 340 341 /*Check for PBO support*/ 342 if (crStateGetCurrent()->extensions.ARB_pixel_buffer_object) 343 { 344 cr_server.bUsePBOForReadback=GL_TRUE; 345 } 346 341 347 return GL_TRUE; 342 348 } -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_muralfbo.c
r35998 r36052 189 189 GLuint uid; 190 190 GLenum status; 191 SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table; 191 192 192 193 CRASSERT(mural->idFBO==0); 193 194 194 195 /*Color texture*/ 195 cr_server.head_spu->dispatch_table.GenTextures(1, &mural->idColorTex); 196 cr_server.head_spu->dispatch_table.BindTexture(GL_TEXTURE_2D, mural->idColorTex); 197 cr_server.head_spu->dispatch_table.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 198 cr_server.head_spu->dispatch_table.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 199 cr_server.head_spu->dispatch_table.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); 200 cr_server.head_spu->dispatch_table.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); 201 cr_server.head_spu->dispatch_table.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, mural->width, mural->height, 202 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); 196 gl->GenTextures(1, &mural->idColorTex); 197 gl->BindTexture(GL_TEXTURE_2D, mural->idColorTex); 198 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 199 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 200 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); 201 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); 202 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 203 { 204 gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0); 205 } 206 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, mural->width, mural->height, 207 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); 203 208 204 209 /*Depth&Stencil*/ 205 cr_server.head_spu->dispatch_table.GenRenderbuffersEXT(1, &mural->idDepthStencilRB);206 cr_server.head_spu->dispatch_table.BindRenderbufferEXT(GL_RENDERBUFFER_EXT, mural->idDepthStencilRB);207 cr_server.head_spu->dispatch_table.RenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT,208 210 gl->GenRenderbuffersEXT(1, &mural->idDepthStencilRB); 211 gl->BindRenderbufferEXT(GL_RENDERBUFFER_EXT, mural->idDepthStencilRB); 212 gl->RenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, 213 mural->width, mural->height); 209 214 210 215 /*FBO*/ 211 cr_server.head_spu->dispatch_table.GenFramebuffersEXT(1, &mural->idFBO);212 cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_FRAMEBUFFER_EXT, mural->idFBO);213 214 cr_server.head_spu->dispatch_table.FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,215 216 cr_server.head_spu->dispatch_table.FramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,217 218 cr_server.head_spu->dispatch_table.FramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,219 220 221 status = cr_server.head_spu->dispatch_table.CheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);216 gl->GenFramebuffersEXT(1, &mural->idFBO); 217 gl->BindFramebufferEXT(GL_FRAMEBUFFER_EXT, mural->idFBO); 218 219 gl->FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, 220 GL_TEXTURE_2D, mural->idColorTex, 0); 221 gl->FramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, 222 GL_RENDERBUFFER_EXT, mural->idDepthStencilRB); 223 gl->FramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, 224 GL_RENDERBUFFER_EXT, mural->idDepthStencilRB); 225 226 status = gl->CheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); 222 227 if (status!=GL_FRAMEBUFFER_COMPLETE_EXT) 223 228 { … … 228 233 mural->fboHeight = mural->height; 229 234 235 /*PBO*/ 236 if (cr_server.bUsePBOForReadback) 237 { 238 gl->GenBuffersARB(1, &mural->idPBO); 239 gl->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, mural->idPBO); 240 gl->BufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, mural->width*mural->height*4, 0, GL_STREAM_READ_ARB); 241 gl->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, ctx->bufferobject.packBuffer->hwid); 242 243 if (!mural->idPBO) 244 { 245 crWarning("PBO create failed"); 246 } 247 } 248 230 249 /*Restore gl state*/ 231 250 uid = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->hwid; 232 cr_server.head_spu->dispatch_table.BindTexture(GL_TEXTURE_2D, uid);251 gl->BindTexture(GL_TEXTURE_2D, uid); 233 252 234 253 uid = ctx->framebufferobject.renderbuffer ? ctx->framebufferobject.renderbuffer->hwid:0; 235 cr_server.head_spu->dispatch_table.BindRenderbufferEXT(GL_RENDERBUFFER_EXT, uid);254 gl->BindRenderbufferEXT(GL_RENDERBUFFER_EXT, uid); 236 255 237 256 uid = ctx->framebufferobject.drawFB ? ctx->framebufferobject.drawFB->hwid:0; 238 cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_FRAMEBUFFER_EXT, uid); 257 gl->BindFramebufferEXT(GL_FRAMEBUFFER_EXT, uid); 258 259 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 260 { 261 gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, ctx->bufferobject.unpackBuffer->hwid); 262 } 239 263 } 240 264 … … 252 276 mural->idColorTex = 0; 253 277 mural->idDepthStencilRB = 0; 278 } 279 280 if (mural->idPBO!=0) 281 { 282 CRASSERT(cr_server.bUsePBOForReadback); 283 cr_server.head_spu->dispatch_table.DeleteBuffersARB(1, &mural->idPBO); 284 mural->idPBO = 0; 254 285 } 255 286 } … … 308 339 void crServerPresentFBO(CRMuralInfo *mural) 309 340 { 310 char *pixels , *tmppixels;341 char *pixels=NULL, *tmppixels; 311 342 GLuint uid; 312 343 int i, j; 313 344 CRrecti rect, rectwr, sectr; 345 GLboolean bUsePBO; 314 346 CRContext *ctx = crStateGetCurrent(); 315 347 … … 321 353 } 322 354 323 pixels = crAlloc(4*mural->fboWidth*mural->fboHeight); 324 if (!pixels) 325 { 326 crWarning("Out of memory in crServerPresentFBO"); 355 if (!mural->width || !mural->height) 356 { 327 357 return; 328 358 } 329 359 360 if (cr_server.bUsePBOForReadback && !mural->idPBO) 361 { 362 crWarning("Mural doesn't have PBO even though bUsePBOForReadback is set!"); 363 } 364 365 bUsePBO = cr_server.bUsePBOForReadback && mural->idPBO; 366 330 367 cr_server.head_spu->dispatch_table.BindTexture(GL_TEXTURE_2D, mural->idColorTex); 368 369 if (bUsePBO) 370 { 371 CRASSERT(mural->idPBO); 372 cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, mural->idPBO); 373 } 374 else 375 { 376 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB)) 377 { 378 cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); 379 } 380 381 pixels = crAlloc(4*mural->fboWidth*mural->fboHeight); 382 if (!pixels) 383 { 384 crWarning("Out of memory in crServerPresentFBO"); 385 return; 386 } 387 } 388 389 /*read the texture, note pixels are NULL for PBO case as it's offset in the buffer*/ 331 390 cr_server.head_spu->dispatch_table.GetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels); 391 392 /*restore gl state*/ 332 393 uid = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->hwid; 333 394 cr_server.head_spu->dispatch_table.BindTexture(GL_TEXTURE_2D, uid); 395 396 if (bUsePBO) 397 { 398 pixels = cr_server.head_spu->dispatch_table.MapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY); 399 if (!pixels) 400 { 401 crWarning("Failed to MapBuffer in crServerPresentFBO"); 402 return; 403 } 404 } 334 405 335 406 for (i=0; i<cr_server.screenCount; ++i) … … 383 454 } 384 455 } 385 crFree(pixels); 456 457 if (bUsePBO) 458 { 459 cr_server.head_spu->dispatch_table.UnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB); 460 cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, ctx->bufferobject.packBuffer->hwid); 461 } 462 else 463 { 464 crFree(pixels); 465 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB)) 466 { 467 cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, ctx->bufferobject.packBuffer->hwid); 468 } 469 } 386 470 } 387 471
Note:
See TracChangeset
for help on using the changeset viewer.