void idSimpleWindow::Redraw( float x, float y ) { if( !visible ) { return; } CalcClientRect( 0, 0 ); dc->SetFont( fontNum ); drawRect.Offset( x, y ); clientRect.Offset( x, y ); textRect.Offset( x, y ); SetupTransforms( x, y ); if( flags & WIN_NOCLIP ) { dc->EnableClipping( false ); } DrawBackground( drawRect ); DrawBorderAndCaption( drawRect ); if( textShadow ) { idStr shadowText = text; idRectangle shadowRect = textRect; shadowText.RemoveColors(); shadowRect.x += textShadow; shadowRect.y += textShadow; dc->DrawText( shadowText, textScale, textAlign, colorBlack, shadowRect, !( flags & WIN_NOWRAP ), -1 ); } dc->DrawText( text, textScale, textAlign, foreColor, textRect, !( flags & WIN_NOWRAP ), -1 ); dc->SetTransformInfo( vec3_origin, mat3_identity ); if( flags & WIN_NOCLIP ) { dc->EnableClipping( true ); } drawRect.Offset( -x, -y ); clientRect.Offset( -x, -y ); textRect.Offset( -x, -y ); }
void D3DOverdrawWindow:: SetupDraw(int iViewpoint) { SetupViewport(); SetupWorld(); SetupView(iViewpoint); SetupProjection(); SetupTransforms(); SetupUniforms(); Clear(); }
bool D3DOverdrawWindow:: NormalizedLoop(float& fOverdraw, float& fOverdrawMax) { int nOverdraw = 0; int nOverdrawPix = 0; fOverdrawMax = 0; DWORD numberOfPixelsDrawn; DWORD numberOfPixelsDrawnPix; SetupDraw(0); for (unsigned int iViewpoint = 0; iViewpoint < m_nViewpointCount; iViewpoint += NUM_QUERIES) { for (unsigned int j = 0; j < NUM_QUERIES && iViewpoint + j < m_nViewpointCount; j++) { SetupView(iViewpoint + j); SetupTransforms(); d3d->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); // Add an end marker to the command buffer queue. m_pOcclusionQuery[j]->Issue(D3DISSUE_BEGIN); // Draw scene if (FAILED(DrawModel())) { return false; } // Add an end marker to the command buffer queue. m_pOcclusionQuery[j]->Issue(D3DISSUE_END); // Add an end marker to the command buffer queue. d3d->SetRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL); m_pOcclusionQueryPix[j]->Issue(D3DISSUE_BEGIN); // Draw scene if (FAILED(DrawModel())) { return false; } // Add an end marker to the command buffer queue. m_pOcclusionQueryPix[j]->Issue(D3DISSUE_END); d3d->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESS); } for (unsigned int j = 0; j < NUM_QUERIES && iViewpoint + j < m_nViewpointCount; j++) { // Force the driver to execute the commands from the command buffer. // Empty the command buffer and wait until the GPU is idle. while (S_FALSE == m_pOcclusionQuery[j]->GetData(&numberOfPixelsDrawn, sizeof(DWORD), D3DGETDATA_FLUSH)) ; nOverdraw += numberOfPixelsDrawn; while (S_FALSE == m_pOcclusionQueryPix[j]->GetData(&numberOfPixelsDrawnPix, sizeof(DWORD), D3DGETDATA_FLUSH)) ; nOverdrawPix += numberOfPixelsDrawnPix; if (numberOfPixelsDrawnPix > 0) { fOverdrawMax = max(fOverdrawMax, numberOfPixelsDrawn / (float)numberOfPixelsDrawnPix); } } } if (nOverdrawPix > 0) { fOverdraw = nOverdraw / (float)nOverdrawPix; } else { fOverdraw = 0; } return true; }
int D3DOverdrawWindow:: Loop(int iClusterA, int iClusterB) { int nOverdraw = 0; DWORD numberOfPixelsDrawn; int j = 0; SetupDraw(0); for (unsigned int iViewpoint = 0; iViewpoint < m_nViewpointCount; iViewpoint++) { SetupView(iViewpoint); m_iTested++; if (!CheckIsect(iClusterA, iClusterB)) { continue; } m_iRendered++; SetupTransforms(); d3d->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); //Add this to remove triple dependencies //DrawComplement(iClusterA, iClusterB); // Add an end marker to the command buffer queue. m_pOcclusionQuery[j]->Issue(D3DISSUE_BEGIN); // Draw scene DrawCluster(iClusterA); DrawCluster(iClusterB); // Add an end marker to the command buffer queue. m_pOcclusionQuery[j]->Issue(D3DISSUE_END); // Force the driver to execute the commands from the command buffer. // Empty the command buffer and wait until the GPU is idle. j++; if (j == NUM_QUERIES) { for (j = 0; j < NUM_QUERIES; j++) { while (S_FALSE == m_pOcclusionQuery[j]->GetData(&numberOfPixelsDrawn, sizeof(DWORD), D3DGETDATA_FLUSH)) ; nOverdraw += numberOfPixelsDrawn; } j = 0; } } int jnum = j; for (int j = 0; j < jnum; j++) { while (S_FALSE == m_pOcclusionQuery[j]->GetData(&numberOfPixelsDrawn, sizeof(DWORD), D3DGETDATA_FLUSH)) ; nOverdraw += numberOfPixelsDrawn; } return nOverdraw; }