Changeset 32240 in vbox for trunk/src/VBox
- Timestamp:
- Sep 5, 2010 2:59:54 PM (14 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface.c
r32184 r32240 3122 3122 * However, stretching in x direction can be avoided if not necessary 3123 3123 */ 3124 for(row = dst_rect.top; row < dst_rect.bottom; row++) { 3125 if ((xrel - 1.0f < -eps) || (xrel - 1.0f > eps)) 3126 { 3127 /* Well, that stuff works, but it's very slow. 3128 * find a better way instead 3129 */ 3130 UINT col; 3131 3132 for(col = dst_rect.left; col < dst_rect.right; col++) { 3124 3125 if (!((xrel - 1.0f < -eps) || (xrel - 1.0f > eps)) 3126 && !((yrel - 1.0f < -eps) || (yrel - 1.0f > eps))) 3127 { 3128 /* No stretching involved, so just pass negative height and let host side take care of inverting */ 3129 3130 glCopyTexSubImage2D(This->texture_target, This->texture_level, 3131 dst_rect.left /*xoffset */, dst_rect.top /* y offset */, 3132 src_rect->left, Src->currentDesc.Height - src_rect->bottom, 3133 dst_rect.right - dst_rect.left, -(dst_rect.bottom-dst_rect.top)); 3134 } 3135 else 3136 { 3137 for(row = dst_rect.top; row < dst_rect.bottom; row++) { 3138 if ((xrel - 1.0f < -eps) || (xrel - 1.0f > eps)) 3139 { 3140 /* Well, that stuff works, but it's very slow. 3141 * find a better way instead 3142 */ 3143 UINT col; 3144 3145 for(col = dst_rect.left; col < dst_rect.right; col++) { 3146 glCopyTexSubImage2D(This->texture_target, This->texture_level, 3147 dst_rect.left + col /* x offset */, row /* y offset */, 3148 src_rect->left + col * xrel, yoffset - (int) (row * yrel), 1, 1); 3149 } 3150 } else { 3133 3151 glCopyTexSubImage2D(This->texture_target, This->texture_level, 3134 dst_rect.left + col/* x offset */, row /* y offset */,3135 src_rect->left + col * xrel, yoffset - (int) (row * yrel), 1, 1);3152 dst_rect.left /* x offset */, row /* y offset */, 3153 src_rect->left, yoffset - (int) (row * yrel), dst_rect.right - dst_rect.left, 1); 3136 3154 } 3137 } else {3138 glCopyTexSubImage2D(This->texture_target, This->texture_level,3139 dst_rect.left /* x offset */, row /* y offset */,3140 src_rect->left, yoffset - (int) (row * yrel), dst_rect.right - dst_rect.left, 1);3141 3155 } 3142 3156 } -
trunk/src/VBox/GuestHost/OpenGL/include/cr_pixeldata.h
r15532 r32240 43 43 const GLubyte *srcPtr, const CRPixelPackState *srcPacking ); 44 44 45 45 DECLEXPORT(void) crDumpTGA(GLint w, GLint h, GLvoid *data); 46 46 #ifdef __cplusplus 47 47 } -
trunk/src/VBox/GuestHost/OpenGL/util/pixel.c
r27398 r32240 9 9 #include "cr_mem.h" 10 10 #include "cr_version.h" 11 #include <stdio.h> 11 12 #include <math.h> 12 13 … … 1776 1777 } 1777 1778 } 1779 1780 static int _tnum = 0; 1781 #pragma pack(1) 1782 typedef struct tgaheader_tag 1783 { 1784 char idlen; 1785 1786 char colormap; 1787 1788 char imagetype; 1789 1790 short cm_index; 1791 short cm_len; 1792 char cm_entrysize; 1793 1794 short x, y, w, h; 1795 char depth; 1796 char imagedesc; 1797 1798 } tgaheader_t; 1799 #pragma pack() 1800 1801 void crDumpTGA(GLint w, GLint h, GLvoid *data) 1802 { 1803 char fname[200]; 1804 tgaheader_t header; 1805 FILE *out; 1806 1807 if (!w || !h) return; 1808 1809 sprintf(fname, "tex%i.tga", _tnum++); 1810 out = fopen(fname, "w"); 1811 if (!out) crError("can't create %s!", fname); 1812 1813 header.idlen = 0; 1814 header.colormap = 0; 1815 header.imagetype = 2; 1816 header.cm_index = 0; 1817 header.cm_len = 0; 1818 header.cm_entrysize = 0; 1819 header.x = 0; 1820 header.y = 0; 1821 header.w = w; 1822 header.h = h; 1823 header.depth = 32; 1824 header.imagedesc = 0x08; 1825 fwrite(&header, sizeof(header), 1, out); 1826 1827 fwrite(data, w*h*4, 1, out); 1828 1829 fclose(out); 1830 } -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getteximage.c
r27983 r32240 42 42 43 43 size = crTextureSize(format, type, width, height, depth); 44 45 #if 0 46 { 47 CRContext *ctx = crStateGetCurrent(); 48 CRTextureObj *tobj; 49 CRTextureLevel *tl; 50 GLint id; 51 52 crDebug("GetTexImage: %d, %i, %d, %d", target, level, format, type); 53 crDebug("===StateTracker==="); 54 crDebug("Current TU: %i", ctx->texture.curTextureUnit); 55 56 if (target==GL_TEXTURE_2D) 57 { 58 tobj = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D; 59 CRASSERT(tobj); 60 tl = &tobj->level[0][level]; 61 crDebug("Texture %i(hw %i), w=%i, h=%i", tobj->id, tobj->hwid, tl->width, tl->height, tl->depth); 62 } 63 else 64 { 65 crDebug("Not 2D tex"); 66 } 67 68 crDebug("===GPU==="); 69 cr_server.head_spu->dispatch_table.GetIntegerv(GL_ACTIVE_TEXTURE, &id); 70 crDebug("Current TU: %i", id); 71 if (target==GL_TEXTURE_2D) 72 { 73 cr_server.head_spu->dispatch_table.GetIntegerv(GL_TEXTURE_BINDING_2D, &id); 74 crDebug("Texture: %i, w=%i, h=%i, d=%i", id, width, height, depth); 75 } 76 } 77 #endif 44 78 45 79 if (size && (buffer = crAlloc(size))) { -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c
r31808 r32240 9 9 #include "cr_error.h" 10 10 #include "cr_mem.h" 11 #include "cr_string.h" 12 #include "cr_pixeldata.h" 11 13 12 14 void SERVER_DISPATCH_APIENTRY crServerDispatchSelectBuffer( GLsizei size, GLuint *buffer ) … … 268 270 } 269 271 272 void SERVER_DISPATCH_APIENTRY 273 crServerDispatchCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) 274 { 275 /*@todo pbo/fbo disabled for now as it's slower, check on other gpus*/ 276 static int siHavePBO = 0; 277 static int siHaveFBO = 0; 278 279 if ((target!=GL_TEXTURE_2D) || (height>=0)) 280 { 281 cr_server.head_spu->dispatch_table.CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); 282 } 283 else /* negative height, means we have to Yinvert the source pixels while copying */ 284 { 285 SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table; 286 287 if (siHavePBO<0) 288 { 289 const char *ext = gl->GetString(GL_EXTENSIONS); 290 siHavePBO = crStrstr(ext, "GL_ARB_pixel_buffer_object") ? 1:0; 291 } 292 293 if (siHaveFBO<0) 294 { 295 const char *ext = gl->GetString(GL_EXTENSIONS); 296 siHaveFBO = crStrstr(ext, "GL_EXT_framebuffer_object") ? 1:0; 297 } 298 299 if (siHavePBO==0 && siHaveFBO==0) 300 { 301 GLint dRow, sRow; 302 for (dRow=yoffset, sRow=y-height-1; dRow<yoffset-height; dRow++, sRow--) 303 { 304 gl->CopyTexSubImage2D(target, level, xoffset, dRow, x, sRow, width, 1); 305 } 306 } 307 else if (siHaveFBO==1) /*@todo more states to set and restore here*/ 308 { 309 GLint tID, fboID; 310 GLenum status; 311 CRContext *ctx = crStateGetCurrent(); 312 313 gl->GenTextures(1, &tID); 314 gl->BindTexture(target, tID); 315 gl->CopyTexImage2D(target, level, GL_RGBA, x, y, width, -height, 0); 316 gl->GenFramebuffersEXT(1, &fboID); 317 gl->BindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboID); 318 gl->FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, target, 319 ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->hwid, level); 320 status = gl->CheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); 321 if (status != GL_FRAMEBUFFER_COMPLETE_EXT) 322 { 323 crWarning("Framebuffer status 0x%x", status); 324 } 325 326 gl->Enable(target); 327 gl->PushAttrib(GL_VIEWPORT_BIT); 328 gl->Viewport(xoffset, yoffset, width, -height); 329 gl->MatrixMode(GL_PROJECTION); 330 gl->PushMatrix(); 331 gl->LoadIdentity(); 332 gl->MatrixMode(GL_MODELVIEW); 333 gl->PushMatrix(); 334 gl->LoadIdentity(); 335 336 gl->Disable(GL_DEPTH_TEST); 337 gl->Disable(GL_CULL_FACE); 338 gl->Disable(GL_STENCIL_TEST); 339 gl->Disable(GL_SCISSOR_TEST); 340 341 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); 342 gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); 343 gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 344 gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 345 gl->TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 346 347 gl->Begin(GL_QUADS); 348 gl->TexCoord2f(0.0f, 1.0f); 349 gl->Vertex2f(-1.0, -1.0); 350 351 gl->TexCoord2f(0.0f, 0.0f); 352 gl->Vertex2f(-1.0f, 1.0f); 353 354 gl->TexCoord2f(1.0f, 0.0f); 355 gl->Vertex2f(1.0f, 1.0f); 356 357 gl->TexCoord2f(1.0f, 1.0f); 358 gl->Vertex2f(1.0f, -1.0f); 359 gl->End(); 360 361 gl->PopMatrix(); 362 gl->MatrixMode(GL_PROJECTION); 363 gl->PopMatrix(); 364 gl->PopAttrib(); 365 366 gl->FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, target, 0, level); 367 gl->BindFramebufferEXT(GL_FRAMEBUFFER_EXT, ctx->framebufferobject.drawFB ? ctx->framebufferobject.drawFB->hwid:0); 368 gl->BindTexture(target, ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->hwid); 369 gl->DeleteFramebuffersEXT(1, &fboID); 370 gl->DeleteTextures(1, &tID); 371 372 #if 0 373 { 374 GLint dRow, sRow, w, h; 375 void *img1, *img2; 376 377 w = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->level[0][level].width; 378 h = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->level[0][level].height; 379 380 img1 = crAlloc(4*w*h); 381 img2 = crAlloc(4*w*h); 382 CRASSERT(img1 && img2); 383 384 gl->GetTexImage(target, level, GL_BGRA, GL_UNSIGNED_BYTE, img1); 385 386 387 for (dRow=yoffset, sRow=y-height-1; dRow<yoffset-height; dRow++, sRow--) 388 { 389 gl->CopyTexSubImage2D(target, level, xoffset, dRow, x, sRow, width, 1); 390 } 391 392 gl->GetTexImage(target, level, GL_BGRA, GL_UNSIGNED_BYTE, img2); 393 394 if (crMemcmp(img1, img2, 4*w*h)) 395 { 396 crDebug("MISMATCH! (%x, %i, ->%i,%i <-%i, %i [%ix%i])", target, level, xoffset, yoffset, x, y, width, height); 397 crDumpTGA(w, h, img1); 398 crDumpTGA(w, h, img2); 399 DebugBreak(); 400 } 401 crFree(img1); 402 crFree(img2); 403 } 404 #endif 405 } 406 else 407 { 408 GLint pboId, dRow, sRow; 409 CRContext *ctx = crStateGetCurrent(); 410 411 gl->GenBuffersARB(1, &pboId); 412 gl->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboId); 413 gl->BufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, -width*height*4, 0, GL_STATIC_COPY_ARB); 414 415 #if 1 416 gl->ReadPixels(x, y, width, -height, GL_RGBA, GL_UNSIGNED_BYTE, 0); 417 gl->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, ctx->bufferobject.packBuffer->hwid); 418 419 gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pboId); 420 for (dRow=yoffset, sRow=-height-1; dRow<yoffset-height; dRow++, sRow--) 421 { 422 gl->TexSubImage2D(target, level, xoffset, dRow, width, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)((uintptr_t)sRow*width*4)); 423 } 424 #else /*few times slower again*/ 425 for (dRow=0, sRow=y-height-1; dRow<-height; dRow++, sRow--) 426 { 427 gl->ReadPixels(x, sRow, width, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)((uintptr_t)dRow*width*4)); 428 } 429 gl->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, ctx->bufferobject.packBuffer->hwid); 430 431 gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pboId); 432 gl->TexSubImage2D(target, level, xoffset, yoffset, width, -height, GL_RGBA, GL_UNSIGNED_BYTE, 0); 433 #endif 434 435 gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, ctx->bufferobject.unpackBuffer->hwid); 436 gl->DeleteBuffersARB(1, &pboId); 437 } 438 } 439 } -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_special
r31808 r32240 242 242 GetHandleARB 243 243 GetUniformLocation 244 CopyTexSubImage2D
Note:
See TracChangeset
for help on using the changeset viewer.