Changeset 82240 in vbox
- Timestamp:
- Nov 27, 2019 12:07:12 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-glHlp.cpp
r82096 r82240 39 39 GLboolean normalized; 40 40 GLsizei stride; 41 GLsizei offset; 41 42 } VertexAttribDesc; 42 43 … … 66 67 GLuint framebuffer; /* Framebuffer object name. */ 67 68 68 GLuint aVertexBuffers[2]; /* Vertex attribute buffers. Position + texcoord. */69 GLuint vertexBuffer; /* Vertex attribute buffer. Position + texcoord. */ 69 70 } VMSVGA3DFORMATCONVERTER; 70 71 … … 72 73 static const VertexAttribDesc aVertexAttribs[] = 73 74 { 74 {2, GL_FLOAT, GL_FALSE, 8 }, /* Position. */ 75 {2, GL_FLOAT, GL_FALSE, 8 } /* Texcoord. */ 76 }; 77 78 /* Triangle fan positions. */ 79 static float const aAttrib0[] = 80 { 81 -1.0f, -1.0f, 82 1.0f, -1.0f, 83 1.0f, 1.0f, 84 -1.0f, 1.0f 85 }; 86 87 /* Triangle fan texcoords. */ 88 static float const aAttrib1[] = 89 { 90 0.0f, 0.0f, 91 1.0f, 0.0f, 92 1.0f, 1.0f, 93 0.0f, 1.0f 75 {2, GL_FLOAT, GL_FALSE, 16, 0 }, /* Position. */ 76 {2, GL_FLOAT, GL_FALSE, 16, 8 } /* Texcoord. */ 77 }; 78 79 /* Triangle fan */ 80 static float const aAttribData[] = 81 { 82 /* positions texcoords */ 83 -1.0f, -1.0f, 0.0f, 0.0f, 84 1.0f, -1.0f, 1.0f, 0.0f, 85 1.0f, 1.0f, 1.0f, 1.0f, 86 -1.0f, 1.0f, 0.0f, 1.0f 94 87 }; 95 88 … … 432 425 GL_CHECK_ERROR(); 433 426 427 pState->ext.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, pConv->framebuffer); 428 GL_CHECK_ERROR(); 429 430 static GLenum aDrawBuffers[] = { GL_COLOR_ATTACHMENT0 }; 431 pState->ext.glDrawBuffers(RT_ELEMENTS(aDrawBuffers), aDrawBuffers); 432 GL_CHECK_ERROR(); 433 434 pState->ext.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); 435 GL_CHECK_ERROR(); 436 434 437 /* 435 * Vertex attribute array s.438 * Vertex attribute array. 436 439 */ 437 pState->ext.glGenBuffers(RT_ELEMENTS(pConv->aVertexBuffers), pConv->aVertexBuffers); 438 GL_CHECK_ERROR(); 439 440 struct AttribData 441 { 442 GLsizeiptr size; 443 const GLvoid * data; 444 }; 445 446 static struct AttribData attribData[RT_ELEMENTS(pConv->aVertexBuffers)] = 447 { 448 { sizeof(aAttrib0), aAttrib0 }, 449 { sizeof(aAttrib1), aAttrib1 }, 450 }; 451 452 GLuint index; 453 for (index = 0; index < RT_ELEMENTS(pConv->aVertexBuffers); ++index) 454 { 455 pState->ext.glBindBuffer(GL_ARRAY_BUFFER, pConv->aVertexBuffers[index]); 456 GL_CHECK_ERROR(); 457 458 pState->ext.glBufferData(GL_ARRAY_BUFFER, attribData[index].size, attribData[index].data, GL_STATIC_DRAW); 459 GL_CHECK_ERROR(); 460 461 pState->ext.glVertexAttribPointer(index, aVertexAttribs[index].size, aVertexAttribs[index].type, 462 aVertexAttribs[index].normalized, aVertexAttribs[index].stride, 463 (const GLvoid *)(uintptr_t)0); 464 GL_CHECK_ERROR(); 465 } 440 pState->ext.glGenBuffers(1, &pConv->vertexBuffer); 441 GL_CHECK_ERROR(); 442 443 pState->ext.glBindBuffer(GL_ARRAY_BUFFER, pConv->vertexBuffer); 444 GL_CHECK_ERROR(); 445 446 pState->ext.glBufferData(GL_ARRAY_BUFFER, sizeof(aAttribData), aAttribData, GL_STATIC_DRAW); 447 GL_CHECK_ERROR(); 466 448 467 449 pState->ext.glBindBuffer(GL_ARRAY_BUFFER, 0); … … 506 488 deleteShaderProgram(pState, &pConv->programYUY2ToRGB); 507 489 508 if (pConv->aVertexBuffers[0]) 509 { 510 pState->ext.glDeleteBuffers(RT_ELEMENTS(pConv->aVertexBuffers), pConv->aVertexBuffers); 511 GL_CHECK_ERROR(); 512 } 513 RT_ZERO(pConv->aVertexBuffers); 490 if (pConv->vertexBuffer) 491 { 492 pState->ext.glDeleteBuffers(1, &pConv->vertexBuffer); 493 GL_CHECK_ERROR(); 494 495 pConv->vertexBuffer = 0; 496 } 514 497 515 498 pConv->pState = 0; … … 570 553 GL_CHECK_ERROR(); 571 554 572 static GLenum aDrawBuffers[] = { GL_COLOR_ATTACHMENT0 };573 pState->ext.glDrawBuffers(RT_ELEMENTS(aDrawBuffers), aDrawBuffers);574 GL_CHECK_ERROR();575 576 555 Assert(pState->ext.glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE); 577 556 } … … 586 565 PVMSVGA3DCONTEXT pContext = &pState->SharedCtx; 587 566 588 glBindTexture(GL_TEXTURE_2D, texture); 589 GL_CHECK_ERROR(); 567 RT_NOREF(texture); 590 568 591 569 pState->ext.glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); 592 GL_CHECK_ERROR();593 594 glBindTexture(GL_TEXTURE_2D, 0);595 570 GL_CHECK_ERROR(); 596 571 … … 615 590 bool fToRGB) 616 591 { 592 if (!fToRGB) 593 { 594 /** @todo Disable readback transfers for now. They cause crash in glDrawArrays with Mesa 19.2 after 595 * a previously converted texture is deleted and another texture is being converted. 596 * Such transfer are useless anyway for the emulated YUV formats and the guest should not need them usually. 597 */ 598 return; 599 } 600 601 LogFunc(("formatConversion: idActiveContext %u, pConv %p, sid=%u, oglid=%u, oglidEmul=%u, mm=%u, %s\n", 602 pState->idActiveContext, pState->pConv, pSurface->id, pSurface->oglId.texture, pSurface->idEmulated, iMipmap, fToRGB ? "ToRGB" : "FromRGB")); 603 617 604 PVMSVGA3DFORMATCONVERTER pConv = pState->pConv; 618 605 AssertReturnVoid(pConv); … … 661 648 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 662 649 663 GLuint index;664 for (index = 0; index < RT_ELEMENTS(pConv->aVertexBuffers); ++index)665 {666 pState->ext.glEnableVertexAttribArray(index);667 GL_CHECK_ERROR();668 }669 670 650 setShaderProgram(pState, pProgram, cWidth, cHeight); 671 651 … … 691 671 GL_CHECK_ERROR(); 692 672 673 pState->ext.glBindBuffer(GL_ARRAY_BUFFER, pConv->vertexBuffer); 674 GL_CHECK_ERROR(); 675 676 GLuint index; 677 for (index = 0; index < RT_ELEMENTS(aVertexAttribs); ++index) 678 { 679 pState->ext.glEnableVertexAttribArray(index); 680 GL_CHECK_ERROR(); 681 682 pState->ext.glVertexAttribPointer(index, aVertexAttribs[index].size, aVertexAttribs[index].type, 683 aVertexAttribs[index].normalized, aVertexAttribs[index].stride, 684 (const GLvoid *)(uintptr_t)aVertexAttribs[index].offset); 685 GL_CHECK_ERROR(); 686 } 687 693 688 glDrawArrays(GL_TRIANGLE_FAN, 0, 4); 694 689 GL_CHECK_ERROR(); 695 690 691 pState->ext.glBindBuffer(GL_ARRAY_BUFFER, 0); 692 GL_CHECK_ERROR(); 693 696 694 glBindTexture(GL_TEXTURE_2D, 0); 697 695 GL_CHECK_ERROR(); … … 702 700 GL_CHECK_ERROR(); 703 701 704 for (index = 0; index < RT_ELEMENTS( pConv->aVertexBuffers); ++index)702 for (index = 0; index < RT_ELEMENTS(aVertexAttribs); ++index) 705 703 { 706 704 pState->ext.glDisableVertexAttribArray(index);
Note:
See TracChangeset
for help on using the changeset viewer.