| 1577 | } |
| 1578 | |
| 1579 | void GLReplay::FillWithDiscardPattern(DiscardType type, GLuint framebuffer, GLsizei numAttachments, |
| 1580 | const GLenum *attachments, GLint x, GLint y, GLsizei width, |
| 1581 | GLsizei height) |
| 1582 | { |
| 1583 | RDCASSERT(type == DiscardType::InvalidateCall); |
| 1584 | |
| 1585 | WrappedOpenGL &drv = *m_pDriver; |
| 1586 | |
| 1587 | GLMarkerRegion region("FillWithDiscardPattern FBO"); |
| 1588 | |
| 1589 | GLRenderState rs; |
| 1590 | rs.FetchState(&drv); |
| 1591 | |
| 1592 | // we use the original framebuffer, and mask off any attachments that shouldn't be discarded |
| 1593 | drv.glBindFramebuffer(eGL_DRAW_FRAMEBUFFER, framebuffer); |
| 1594 | |
| 1595 | int numviews = 1; |
| 1596 | |
| 1597 | if(IsGLES && HasExt[OVR_multiview]) |
| 1598 | { |
| 1599 | GL.glGetNamedFramebufferAttachmentParameterivEXT( |
| 1600 | framebuffer, eGL_COLOR_ATTACHMENT0, eGL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR, |
| 1601 | &numviews); |
| 1602 | } |
| 1603 | |
| 1604 | drv.glBindBufferBase(eGL_UNIFORM_BUFFER, 0, DebugData.discardPatternBuffer); |
| 1605 | |
| 1606 | drv.glDisable(eGL_BLEND); |
| 1607 | drv.glDisable(eGL_CULL_FACE); |
| 1608 | drv.glEnable(eGL_DEPTH_TEST); |
| 1609 | drv.glEnable(eGL_STENCIL_TEST); |
| 1610 | drv.glDepthFunc(eGL_ALWAYS); |
| 1611 | drv.glStencilFunc(eGL_ALWAYS, 0, 0xff); |
| 1612 | if(!IsGLES) |
| 1613 | drv.glPolygonMode(eGL_FRONT_AND_BACK, eGL_FILL); |
| 1614 | |
| 1615 | // scissor to the rect |
| 1616 | drv.glEnable(eGL_SCISSOR_TEST); |
| 1617 | drv.glScissor(x, y, width, height); |
| 1618 | |
| 1619 | GLint maxview[2] = {2048, 2048}; |
| 1620 | drv.glGetIntegerv(eGL_MAX_VIEWPORT_DIMS, maxview); |
| 1621 | drv.glViewport(0, 0, maxview[0], maxview[1]); |
| 1622 | |
| 1623 | // disable all masks at first |
| 1624 | drv.glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); |
| 1625 | drv.glDepthMask(GL_FALSE); |
| 1626 | drv.glStencilMask(0); |
| 1627 | |
| 1628 | int intIdx = -1; |
| 1629 | |
| 1630 | // enable masks specified by attachments |
| 1631 | bool stencil = false; |
| 1632 | for(GLsizei i = 0; i < numAttachments; i++) |
| 1633 | { |
| 1634 | if(attachments[i] == eGL_DEPTH_STENCIL_ATTACHMENT) |
| 1635 | { |
| 1636 | drv.glDepthMask(GL_TRUE); |
no test coverage detected