diff --git a/neo/d3xp/PlayerView.cpp b/neo/d3xp/PlayerView.cpp index 7d781662..1d7869c9 100644 --- a/neo/d3xp/PlayerView.cpp +++ b/neo/d3xp/PlayerView.cpp @@ -1075,8 +1075,8 @@ void FullscreenFX_Helltime::AccumPass( const renderView_t* view ) renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); - float t0 = 1.0f; - float t1 = 0.0f; + float t0 = 0.0f; + float t1 = 1.0f; // capture pass if( clearAccumBuffer ) @@ -1097,8 +1097,8 @@ FullscreenFX_Helltime::HighQuality */ void FullscreenFX_Helltime::HighQuality() { - float t0 = 1.0f; - float t1 = 0.0f; + float t0 = 0.0f; + float t1 = 1.0f; renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); renderSystem->DrawStretchPic( 0.0f, 0.0f, renderSystem->GetVirtualWidth(), renderSystem->GetVirtualHeight(), 0.0f, t0, 1.0f, t1, drawMaterial ); @@ -1200,8 +1200,8 @@ void FullscreenFX_Multiplayer::AccumPass( const renderView_t* view ) { renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); - float t0 = 1.0f; - float t1 = 0.0f; + float t0 = 0.0f; + float t1 = 1.0f; // capture pass if( clearAccumBuffer ) @@ -1222,8 +1222,8 @@ FullscreenFX_Multiplayer::HighQuality */ void FullscreenFX_Multiplayer::HighQuality() { - float t0 = 1.0f; - float t1 = 0.0f; + float t0 = 0.0f; + float t1 = 1.0f; renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); renderSystem->DrawStretchPic( 0.0f, 0.0f, renderSystem->GetVirtualWidth(), renderSystem->GetVirtualHeight(), 0.0f, t0, 1.0f, t1, drawMaterial ); @@ -1439,9 +1439,9 @@ void FullscreenFX_EnviroSuit::HighQuality() { renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); float s0 = 0.0f; - float t0 = 1.0f; + float t0 = 0.0f; float s1 = 1.0f; - float t1 = 0.0f; + float t1 = 1.0f; renderSystem->DrawStretchPic( 0.0f, 0.0f, renderSystem->GetVirtualWidth(), renderSystem->GetVirtualHeight(), s0, t0, s1, t1, material ); } @@ -1527,9 +1527,9 @@ void FullscreenFX_DoubleVision::HighQuality() // uv coordinates float s0 = shift; - float t0 = 1.0f; + float t0 = 0.0f; float s1 = 1.0f; - float t1 = 0.0f; + float t1 = 1.0f; renderSystem->SetColor4( color.x, color.y, color.z, 1.0f ); @@ -1537,9 +1537,9 @@ void FullscreenFX_DoubleVision::HighQuality() renderSystem->SetColor4( color.x, color.y, color.z, 0.5f ); s0 = 0.0f; - t0 = 1.0f; + t0 = 0.0f; s1 = ( 1.0 - shift ); - t1 = 0.0f; + t1 = 1.0f; renderSystem->DrawStretchPic( 0.0f, 0.0f, renderSystem->GetVirtualWidth(), renderSystem->GetVirtualHeight(), s0, t0, s1, t1, material ); } @@ -1884,9 +1884,9 @@ void FullscreenFXManager::Blendback( float alpha ) { renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f - alpha ); float s0 = 0.0f; - float t0 = 1.0f; + float t0 = 0.0f; float s1 = 1.0f; - float t1 = 0.0f; + float t1 = 1.0f; renderSystem->DrawStretchPic( 0.0f, 0.0f, renderSystem->GetVirtualWidth(), renderSystem->GetVirtualHeight(), s0, t0, s1, t1, blendBackMaterial ); } } @@ -1947,9 +1947,6 @@ void FullscreenFXManager::Process( const renderView_t* view ) return; } -// RB: skip for now so the game is playable. These old effects really suck with modern APIs -#if !defined( USE_NVRHI ) - // do the process for( int i = 0; i < fx.Num(); i++ ) { @@ -1977,9 +1974,10 @@ void FullscreenFXManager::Process( const renderView_t* view ) // handle the accum pass if we have one if( pfx->HasAccum() ) { - // we need to crop the accum pass - renderSystem->CropRenderSize( 512, 512 ); pfx->AccumPass( view ); + // we need to crop the accum pass + // + renderSystem->CropRenderSize( 512, 512 ); renderSystem->CaptureRenderToImage( "_accum" ); renderSystem->UnCrop(); } @@ -1991,7 +1989,6 @@ void FullscreenFXManager::Process( const renderView_t* view ) Blendback( pfx->GetFadeAlpha() ); } } -#endif } diff --git a/neo/renderer/Framebuffer.h b/neo/renderer/Framebuffer.h index cb3f52e2..44e8b673 100644 --- a/neo/renderer/Framebuffer.h +++ b/neo/renderer/Framebuffer.h @@ -158,6 +158,7 @@ struct globalFramebuffers_t Framebuffer* smaaEdgesFBO; Framebuffer* smaaBlendFBO; Framebuffer* guiRenderTargetFBO; + Framebuffer* accumFBO; }; extern globalFramebuffers_t globalFramebuffers; diff --git a/neo/renderer/Image_intrinsic.cpp b/neo/renderer/Image_intrinsic.cpp index 6b0266fe..00554616 100644 --- a/neo/renderer/Image_intrinsic.cpp +++ b/neo/renderer/Image_intrinsic.cpp @@ -219,6 +219,11 @@ static void R_RGBA8Image( idImage* image, nvrhi::ICommandList* commandList ) image->GenerateImage( ( byte* )data, DEFAULT_SIZE, DEFAULT_SIZE, TF_DEFAULT, TR_REPEAT, TD_LOOKUP_TABLE_RGBA, commandList ); } +static void R_RGBA8Image_RT( idImage* image, nvrhi::ICommandList* commandList ) +{ + image->GenerateImage( nullptr, 512, 512, TF_NEAREST, TR_CLAMP, TD_LOOKUP_TABLE_RGBA, nullptr, true, false, 1 ); +} + static void R_RGBA8LinearImage( idImage* image, nvrhi::ICommandList* commandList ) { byte data[DEFAULT_SIZE][DEFAULT_SIZE][4]; @@ -1116,8 +1121,8 @@ void idImageManager::CreateIntrinsicImages() // scratchImage is used for screen wipes/doublevision etc.. scratchImage = ImageFromFunction( "_scratch", R_RGBA8Image ); scratchImage2 = ImageFromFunction( "_scratch2", R_RGBA8Image ); - accumImage = ImageFromFunction( "_accum", R_RGBA8Image ); - currentRenderImage = ImageFromFunction( "_currentRender", R_HDR_RGBA16FImage_ResNative ); + accumImage = ImageFromFunction( "_accum", R_RGBA8Image_RT ); + currentRenderImage = globalImages->ImageFromFunction( "_currentRender", R_LdrNativeImage );; currentDepthImage = ImageFromFunction( "_currentDepth", R_DepthImage ); // save a copy of this for material comparison, because currentRenderImage may get diff --git a/neo/renderer/NVRHI/Framebuffer_NVRHI.cpp b/neo/renderer/NVRHI/Framebuffer_NVRHI.cpp index 2df45989..444a0dbe 100644 --- a/neo/renderer/NVRHI/Framebuffer_NVRHI.cpp +++ b/neo/renderer/NVRHI/Framebuffer_NVRHI.cpp @@ -210,6 +210,10 @@ void Framebuffer::ResizeFramebuffers( bool reloadImages ) .addColorAttachment( globalImages->guiEdit->texture ) .setDepthAttachment( globalImages->guiEditDepthStencilImage->texture ) ); + globalFramebuffers.accumFBO = new Framebuffer( "_accum", + nvrhi::FramebufferDesc() + .addColorAttachment( globalImages->accumImage->texture ) ); + Framebuffer::Unbind(); } @@ -243,6 +247,7 @@ void Framebuffer::ReloadImages() globalImages->bloomRenderImage[i]->Reload( false, tr.backend.commandList ); } globalImages->guiEdit->Reload( false, tr.backend.commandList ); + globalImages->accumImage->Reload( false, tr.backend.commandList ); tr.backend.commandList->close(); deviceManager->GetDevice()->executeCommandList( tr.backend.commandList ); } diff --git a/neo/renderer/RenderBackend.cpp b/neo/renderer/RenderBackend.cpp index f0c2c806..3343fc67 100644 --- a/neo/renderer/RenderBackend.cpp +++ b/neo/renderer/RenderBackend.cpp @@ -5926,12 +5926,32 @@ void idRenderBackend::CopyRender( const void* data ) if( cmd->image ) { + renderLog.OpenBlock( cmd->image->GetName() ); + + BlitParameters blitParms; + blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID(); + nvrhi::IFramebuffer* framebuffer = globalFramebuffers.postProcFBO->GetApiObject(); + if( cmd->image == globalImages->accumImage ) + { + framebuffer = globalFramebuffers.accumFBO->GetApiObject(); + } + blitParms.targetFramebuffer = framebuffer; + blitParms.targetViewport = nvrhi::Viewport( cmd->imageWidth, cmd->imageHeight ); + commonPasses.BlitTexture( commandList, blitParms, &bindingCache ); + cmd->image->CopyFramebuffer( cmd->x, cmd->y, cmd->imageWidth, cmd->imageHeight ); + + renderLog.CloseBlock(); } if( cmd->clearColorAfterCopy ) { - GL_Clear( true, false, false, STENCIL_SHADOW_TEST_VALUE, 0, 0, 0, 0 ); + nvrhi::IFramebuffer* framebuffer = globalFramebuffers.postProcFBO->GetApiObject(); + if( cmd->image == globalImages->accumImage ) + { + framebuffer = globalFramebuffers.accumFBO->GetApiObject(); + } + nvrhi::utils::ClearColorAttachment( commandList, framebuffer, 0, nvrhi::Color( 0.f ) ); } renderLog.CloseBlock(); @@ -6126,8 +6146,8 @@ void idRenderBackend::PostProcess( const void* data ) #if defined( USE_NVRHI ) BlitParameters blitParms; blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID(); - blitParms.targetFramebuffer = deviceManager->GetCurrentFramebuffer(); - blitParms.targetViewport = nvrhi::Viewport( renderSystem->GetWidth(), renderSystem->GetHeight() ); + blitParms.targetFramebuffer = globalFramebuffers.postProcFBO->GetApiObject(); + blitParms.targetViewport = nvrhi::Viewport( viewport.x1, viewport.x2, viewport.y1, viewport.y2, viewport.zmin, viewport.zmax ); commonPasses.BlitTexture( commandList, blitParms, &bindingCache ); GL_SelectTexture( 0 ); diff --git a/neo/renderer/RenderBackend.h b/neo/renderer/RenderBackend.h index 4be66a51..49a2f205 100644 --- a/neo/renderer/RenderBackend.h +++ b/neo/renderer/RenderBackend.h @@ -344,6 +344,8 @@ public: float slopeScaleBias; float depthBias; + CommonRenderPasses commonPasses; + private: uint64 glStateBits; @@ -387,7 +389,6 @@ private: Framebuffer* currentFrameBuffer; Framebuffer* lastFrameBuffer; nvrhi::CommandListHandle commandList; - CommonRenderPasses commonPasses; SsaoPass* ssaoPass; MipMapGenPass* hiZGenPass; TonemapPass* toneMapPass;