/* * R_DrawPortals */ void R_DrawPortals( void ) { unsigned int i; if( rn.renderFlags & RF_SKYSHADOWVIEW ) { // render depth mask for skylights // TODO: rewrite this! float depthmin, depthmax; RB_GetDepthRange( &depthmin, &depthmax ); RB_ClearDepth( depthmin ); RB_Clear( GL_DEPTH_BUFFER_BIT, 0, 0, 0, 0 ); if( rn.portalmasklist && rn.portalmasklist->numDrawSurfs ) { RB_SetShaderStateMask( ~0, GLSTATE_DEPTHWRITE | GLSTATE_NO_COLORWRITE | GLSTATE_OFFSET_FILL | GLSTATE_DEPTHFUNC_GT ); RB_FlipFrontFace(); RB_DepthRange( depthmax, depthmax ); R_DrawPortalSurfaces( rn.portalmasklist ); RB_SetShaderStateMask( ~0, GLSTATE_DEPTHWRITE | GLSTATE_NO_COLORWRITE | GLSTATE_OFFSET_FILL ); RB_FlipFrontFace(); RB_DepthRange( depthmin, depthmax ); } RB_ClearDepth( depthmax ); return; } if( rn.renderFlags & ( RF_MIRRORVIEW | RF_LIGHTVIEW | RF_PORTALVIEW ) ) { return; } if( rn.viewcluster == -1 ) { return; } R_DrawPortalsDepthMask(); if( rn.skyportalSurface ) { // render skyportal portalSurface_t *ps = rn.skyportalSurface; R_DrawSkyportal( ps->entity, ps->skyPortal ); } else { // FIXME: move this? // render sky dome that writes to depth R_DrawDepthSkySurf(); } // render regular portals for( i = 0; i < rn.numPortalSurfaces; i++ ) { portalSurface_t ps = rn.portalSurfaces[i]; if( !ps.skyPortal ) { R_DrawPortalSurface( &ps ); rn.portalSurfaces[i] = ps; } } }
/* * R_DrawPortalsDepthMask * * Renders portal or sky surfaces from the BSP tree to depth buffer. Each rendered pixel * receives the depth value of 1.0, everything else is cleared to 0.0. * * The depth buffer is then preserved for portal render stage to minimize overdraw. */ static void R_DrawPortalsDepthMask( void ) { float depthmin, depthmax; if( !rn.portalmasklist || !rn.portalmasklist->numDrawSurfs ) { return; } RB_GetDepthRange( &depthmin, &depthmax ); RB_ClearDepth( depthmin ); RB_Clear( GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT, 0, 0, 0, 0 ); RB_SetShaderStateMask( ~0, GLSTATE_DEPTHWRITE | GLSTATE_DEPTHFUNC_GT | GLSTATE_NO_COLORWRITE ); RB_DepthRange( depthmax, depthmax ); R_DrawPortalSurfaces( rn.portalmasklist ); RB_DepthRange( depthmin, depthmax ); RB_ClearDepth( depthmax ); }
//***************************************************************************** // UART interrupt handler. //***************************************************************************** void UART0_IntHandler(void) { uint32_t status = ROM_UARTIntStatus(UART0_BASE, true); ROM_UARTIntClear(UART0_BASE, status); // drain rx FIFO while(ROM_UARTCharsAvail(UART0_BASE)) { char ch = ROM_UARTCharGetNonBlocking(UART0_BASE); if(inputRB.nbytes < DBG_IN_BUFFER_SIZE) { RB_Push(dbg_inputBuffer, inputRB, ch, DBG_IN_BUFFER_SIZE); if(ch == '\r') ++newlines; } else { // Attempt to report overflow and clear buffer // Must do this to avoid condition where buffer is full and code // is waiting for a newline that can not fit in the buffer. dbg_putstr_nb("\rRXOVF\r\n"); RB_Clear(inputRB); newlines = 0; } } // feed tx FIFO // Echo received characters while(ROM_UARTSpaceAvail(UART0_BASE) && echoPtr != inputRB.wp) { ROM_UARTCharPutNonBlocking(UART0_BASE, dbg_inputBuffer[echoPtr]); echoPtr = (echoPtr + 1) % DBG_IN_BUFFER_SIZE; } // Write pending characters while(ROM_UARTSpaceAvail(UART0_BASE) && outputRB.nbytes > 0) { ROM_UARTCharPutNonBlocking(UART0_BASE, RB_Front(dbg_outputBuffer, outputRB)); RB_Pop(outputRB, DBG_OUT_BUFFER_SIZE); } } // UART0_IntHandler()
/* * R_RenderScene */ void R_RenderScene( const refdef_t *fd ) { int fbFlags = 0; if( r_norefresh->integer ) return; R_Set2DMode( qfalse ); RB_SetTime( fd->time ); if( !( fd->rdflags & RDF_NOWORLDMODEL ) ) rsc.refdef = *fd; rn.refdef = *fd; if( !rn.refdef.minLight ) { rn.refdef.minLight = 0.1f; } if( !rsh.screenWeaponTexture || rn.refdef.weaponAlpha == 1 ) { rn.refdef.rdflags &= ~RDF_WEAPONALPHA; } fd = &rn.refdef; rn.renderFlags = RF_NONE; rn.farClip = R_DefaultFarClip(); rn.clipFlags = 15; if( rsh.worldModel && !( fd->rdflags & RDF_NOWORLDMODEL ) && rsh.worldBrushModel->globalfog ) rn.clipFlags |= 16; rn.meshlist = &r_worldlist; rn.shadowBits = 0; rn.dlightBits = 0; rn.shadowGroup = NULL; fbFlags = 0; rn.fbColorAttachment = rn.fbDepthAttachment = NULL; if( !( fd->rdflags & RDF_NOWORLDMODEL ) ) { // soft particles require GL_EXT_framebuffer_blit as we need to copy the depth buffer // attachment into a texture we're going to read from in GLSL shader if( r_soft_particles->integer && glConfig.ext.framebuffer_blit && ( rsh.screenTexture != NULL ) ) { rn.fbColorAttachment = rsh.screenTexture; rn.fbDepthAttachment = rsh.screenDepthTexture; rn.renderFlags |= RF_SOFT_PARTICLES; fbFlags |= 1; } if( ( fd->rdflags & RDF_WEAPONALPHA ) && ( rsh.screenWeaponTexture != NULL ) ) { fbFlags |= 2; } if( r_fxaa->integer && ( rsh.screenFxaaCopy != NULL ) ) { if( !rn.fbColorAttachment ) { rn.fbColorAttachment = rsh.screenFxaaCopy; } fbFlags |= 4; } } // adjust field of view for widescreen if( glConfig.wideScreen && !( fd->rdflags & RDF_NOFOVADJUSTMENT ) ) AdjustFov( &rn.refdef.fov_x, &rn.refdef.fov_y, glConfig.width, glConfig.height, qfalse ); // clip new scissor region to the one currently set Vector4Set( rn.scissor, fd->scissor_x, fd->scissor_y, fd->scissor_width, fd->scissor_height ); Vector4Set( rn.viewport, fd->x, fd->y, fd->width, fd->height ); VectorCopy( fd->vieworg, rn.pvsOrigin ); VectorCopy( fd->vieworg, rn.lodOrigin ); if( gl_finish->integer && !( fd->rdflags & RDF_NOWORLDMODEL ) ) qglFinish(); if( fbFlags & 2 ) { // clear the framebuffer we're going to render the weapon model to // set the alpha to 0, visible parts of the model will overwrite that, // creating proper alpha mask R_BindFrameBufferObject( rsh.screenWeaponTexture->fbo ); RB_Clear( GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT, 0, 0, 0, 0 ); } R_BindFrameBufferObject( 0 ); R_BuildShadowGroups(); R_RenderView( fd ); R_RenderDebugSurface( fd ); R_RenderDebugBounds(); R_BindFrameBufferObject( 0 ); R_Set2DMode( qtrue ); // blit and blend framebuffers in proper order if( fbFlags & 1 ) { // copy to FXAA or default framebuffer R_BlitTextureToScrFbo( fd, rn.fbColorAttachment, fbFlags & 4 ? rsh.screenFxaaCopy->fbo : 0, GLSL_PROGRAM_TYPE_NONE, colorWhite, 0 ); } if( fbFlags & 2 ) { vec4_t color = { 1, 1, 1, 1 }; color[3] = fd->weaponAlpha; // blend to FXAA or default framebuffer R_BlitTextureToScrFbo( fd, rsh.screenWeaponTexture, fbFlags & 4 ? rsh.screenFxaaCopy->fbo : 0, GLSL_PROGRAM_TYPE_NONE, color, GLSTATE_SRCBLEND_SRC_ALPHA|GLSTATE_DSTBLEND_ONE_MINUS_SRC_ALPHA ); } // blit FXAA to default framebuffer if( fbFlags & 4 ) { // blend to FXAA or default framebuffer R_BlitTextureToScrFbo( fd, rsh.screenFxaaCopy, 0, GLSL_PROGRAM_TYPE_FXAA, colorWhite, 0 ); } }