Backported SMAA and TAA bugfixes from openvr3 branch

This commit is contained in:
Robert Beckebans 2024-11-26 21:18:42 +01:00
parent 685e02a2f9
commit 025627b155
41 changed files with 541 additions and 469 deletions

View file

@ -18,5 +18,5 @@ bind "F7" "toggle r_renderMode 0 1 2 3 4 5 6 7 8 9 10 11"
bind "F8" "toggle r_useCRTPostFX 0 1 2 3"
bind "F9" "loadgame quick"
// bind "F10" "toggle com_fixedTic"
bind F10 "toggle r_antiAliasing"
bind F10 "toggle r_antiAliasing 0 1 2"
bind "F11" "toggle r_useFilmicPostFX"

View file

@ -665,25 +665,13 @@ void idPlayerView::ScreenFade()
}
}
idCVar stereoRender_interOccularCentimeters( "stereoRender_interOccularCentimeters", "3.0", CVAR_ARCHIVE | CVAR_RENDERER, "Distance between eyes" );
idCVar stereoRender_interOccularCentimeters( "stereoRender_interOccularCentimeters", "6.5", CVAR_ARCHIVE | CVAR_RENDERER, "Distance between eyes" );
idCVar stereoRender_convergence( "stereoRender_convergence", "6", CVAR_RENDERER, "0 = head mounted display, otherwise world units to convergence plane" );
extern idCVar stereoRender_screenSeparation; // screen units from center to eyes
extern idCVar stereoRender_swapEyes;
// In a head mounted display with separate displays for each eye,
// screen separation will be zero and world separation will be the eye distance.
struct stereoDistances_t
{
// Offset to projection matrix, positive one eye, negative the other.
// Total distance is twice this, so 0.05 would give a 10% of screen width
// separation for objects at infinity.
float screenSeparation;
// Game world units from one eye to the centerline.
// Total distance is twice this.
float worldSeparation;
};
float CentimetersToInches( const float cm )
{
@ -782,10 +770,6 @@ The crosshair is swapped for a laser sight in stereo rendering
*/
bool IsGameStereoRendered()
{
if( renderSystem->GetStereo3DMode() != STEREO3D_OFF )
{
return true;
}
return false;
}
@ -802,6 +786,7 @@ idPlayerView::RenderPlayerView
void idPlayerView::RenderPlayerView( idMenuHandler_HUD* hudManager )
{
const renderView_t* view = player->GetRenderView();
#if 0
if( renderSystem->GetStereo3DMode() != STEREO3D_OFF )
{
// render both eye views each frame on the PC
@ -811,6 +796,7 @@ void idPlayerView::RenderPlayerView( idMenuHandler_HUD* hudManager )
}
}
else
#endif
{
SingleView( view, hudManager );
}

View file

@ -874,28 +874,19 @@ void idMenuHandler_Shell::SetupPCOptions()
}
else
{
#if !defined( ID_RETAIL )
navOptions.Append( "DEV" ); // DEV
#endif
navOptions.Append( "#str_swf_campaign" ); // singleplayer
navOptions.Append( "#str_swf_multiplayer" ); // multiplayer
navOptions.Append( "#str_swf_settings" ); // settings
navOptions.Append( "#str_swf_credits" ); // credits
// Leyland VR: moved DEV menu down
#if !defined ( ID_RETAIL )
navOptions.Append( "DEV" ); // DEV
#endif
navOptions.Append( "#str_swf_quit" ); // quit
idMenuWidget_MenuButton* buttonWidget = NULL;
int index = 0;
#if !defined( ID_RETAIL )
buttonWidget = dynamic_cast< idMenuWidget_MenuButton* >( &menuBar->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
buttonWidget->ClearEventActions();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, SHELL_CMD_DEV, index );
buttonWidget->SetDescription( "View a list of maps available for play" );
}
index++;
#endif
buttonWidget = dynamic_cast< idMenuWidget_MenuButton* >( &menuBar->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
@ -928,6 +919,17 @@ void idMenuHandler_Shell::SetupPCOptions()
buttonWidget->SetDescription( "#str_02219" );
}
index++;
#if !defined ( ID_RETAIL )
buttonWidget = dynamic_cast< idMenuWidget_MenuButton* >( &menuBar->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
buttonWidget->ClearEventActions();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, SHELL_CMD_DEV, index );
buttonWidget->SetDescription( "View a list of maps available for play" );
}
index++;
#endif
// Leyland end
buttonWidget = dynamic_cast< idMenuWidget_MenuButton* >( &menuBar->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{

View file

@ -211,19 +211,6 @@ void idMenuScreen_Shell_Root::ShowScreen( const mainMenuTransition_t transitionT
idMenuWidget_Button* buttonWidget = NULL;
#if !defined( ID_RETAIL )
option.Append( "DEV" ); // DEV
menuOptions.Append( option );
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, ROOT_CMD_DEV );
buttonWidget = dynamic_cast< idMenuWidget_Button* >( &options->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
buttonWidget->SetDescription( "View a list of maps available for play" );
}
index++;
#endif
option.Clear();
option.Append( "#str_swf_campaign" ); // singleplayer
menuOptions.Append( option );
@ -273,6 +260,22 @@ void idMenuScreen_Shell_Root::ShowScreen( const mainMenuTransition_t transitionT
}
index++;
// Leyland VR: moved DEV menu down
#if !defined ( ID_RETAIL )
option.Clear();
option.Append( "DEV" ); // DEV
menuOptions.Append( option );
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, ROOT_CMD_DEV );
buttonWidget = dynamic_cast< idMenuWidget_Button* >( &options->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
buttonWidget->SetDescription( "View a list of maps available for play" );
}
index++;
#endif
// Leyland end
// only add quit option for PC
option.Clear();
option.Append( "#str_swf_quit" ); // quit
@ -432,6 +435,7 @@ bool idMenuScreen_Shell_Root::HandleAction( idWidgetAction& action, const idWidg
{
if( menuData->GetPlatform() == 2 )
{
idMenuHandler_Shell* shell = dynamic_cast< idMenuHandler_Shell* >( menuData );
if( !shell )
{
@ -459,6 +463,7 @@ bool idMenuScreen_Shell_Root::HandleAction( idWidgetAction& action, const idWidg
}
case WIDGET_ACTION_SCROLL_HORIZONTAL:
{
if( menuData->GetPlatform() != 2 )
{
return true;

View file

@ -71,11 +71,13 @@ void idMenuScreen_Shell_Settings::Initialize( idMenuHandler* data )
menuOptions.Append( option );
option.Clear();
if( renderSystem->IsStereoScopicRenderingSupported() )
#if VR_OPTIONS
//if( renderSystem->IsStereoScopicRenderingSupported() )
{
option.Append( "#str_swf_stereoscopics" ); // Stereoscopic Rendering
menuOptions.Append( option );
}
#endif
options->SetListData( menuOptions );
options->SetNumVisibleOptions( NUM_SETTING_OPTIONS );

View file

@ -350,7 +350,7 @@ idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::LoadData
void idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::LoadData()
{
fields[ STEREO_FIELD_ENABLE ].SetInteger( renderSystem->GetStereoScopicRenderingMode() );
fields[ STEREO_FIELD_ENABLE ].SetInteger( 0 ); //vr_enable.GetInteger() );
fields[ STEREO_FIELD_SEPERATION ].SetFloat( 100.0f * ( stereoRender_interOccularCentimeters.GetFloat() / MAX_INTEROCCULAR_DISTANCE ) );
@ -385,17 +385,15 @@ void idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::AdjustFi
if( fieldIndex == STEREO_FIELD_ENABLE )
{
int numOptions = NUM_STEREO_ENABLE;
if( !renderSystem->HasQuadBufferSupport() )
{
numOptions--;
}
int numOptions = 2;
int adjusted = fields[ fieldIndex ].ToInteger() + adjustAmount;
adjusted += numOptions;
adjusted %= numOptions;
fields[fieldIndex].SetInteger( adjusted );
renderSystem->EnableStereoScopicRendering( ( stereo3DMode_t )adjusted );
// TODO
// renderSystem->EnableStereoScopicRendering( ( stereo3DMode_t )adjusted );
gameLocal.Shell_ClearRepeater();
@ -468,6 +466,8 @@ idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::IsRestartRequ
*/
bool idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::IsRestartRequired() const
{
#if 0
// TODO
if( fields[ STEREO_FIELD_ENABLE ].ToInteger() != originalFields[ STEREO_FIELD_ENABLE ].ToInteger() )
{
if( fields[ STEREO_FIELD_ENABLE ].ToInteger() == STEREO3D_QUAD_BUFFER || originalFields[ STEREO_FIELD_ENABLE ].ToInteger() == STEREO3D_QUAD_BUFFER )
@ -475,6 +475,8 @@ bool idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::IsRestar
return true;
}
}
#endif
return false;
}

View file

@ -599,10 +599,11 @@ void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::AdjustFi
ANTI_ALIASING_MSAA_4X,
};
#else
static const int numValues = 2;
static const int numValues = 3;
static const int values[numValues] =
{
ANTI_ALIASING_NONE,
ANTI_ALIASING_SMAA_1X,
ANTI_ALIASING_TAA,
};
#endif
@ -779,10 +780,11 @@ idSWFScriptVar idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings
compile_time_assert( numValues == ( ANTI_ALIASING_MSAA_4X + 1 ) );
#else
static const int numValues = 2;
static const int numValues = 3;
static const char* values[numValues] =
{
"None",
"SMAA",
"TAA"
};

View file

@ -415,17 +415,19 @@ float idConsoleLocal::DrawFPS( float y )
compile_time_assert( aaNumValues == ( ANTI_ALIASING_MSAA_4X + 1 ) );
#else
static const int aaNumValues = 2;
static const int aaNumValues = 3;
static const char* aaValues[aaNumValues] =
{
"None",
"SMAA",
"None",
};
static const char* taaValues[aaNumValues] =
{
"None",
"SMAA",
"TAA",
};

View file

@ -97,6 +97,13 @@ ALIGNTYPE16 const idRenderMatrix renderMatrix_clipSpaceToWindowSpace(
0.0f, 0.0f, 0.5f, 0.5f,
0.0f, 0.0f, 0.0f, 1.0f
);
ALIGNTYPE16 const idRenderMatrix renderMatrix_fullscreen(
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, -1.0f, 0.0f, 0.0f, // flip Y for DX12 / Vulkan
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
);
// RB end
/*

View file

@ -172,6 +172,7 @@ extern const idRenderMatrix renderMatrix_flipToOpenGL;
extern const idRenderMatrix renderMatrix_windowSpaceToClipSpace;
// RB begin
extern const idRenderMatrix renderMatrix_clipSpaceToWindowSpace;
extern const idRenderMatrix renderMatrix_fullscreen;
// RB end
/*

View file

@ -154,6 +154,7 @@ struct globalFramebuffers_t
Framebuffer* ambientOcclusionFBO[MAX_SSAO_BUFFERS];
Framebuffer* csDepthFBO[MAX_HIERARCHICAL_ZBUFFERS];
Framebuffer* geometryBufferFBO;
Framebuffer* smaaInputFBO;
Framebuffer* smaaEdgesFBO;
Framebuffer* smaaBlendFBO;
Framebuffer* guiRenderTargetFBO;

View file

@ -245,7 +245,7 @@ void idGuiModel::EmitFullScreen( Framebuffer* renderTarget )
tr.GetCroppedViewport( &viewDef->viewport );
}
bool stereoEnabled = ( renderSystem->GetStereo3DMode() != STEREO3D_OFF );
bool stereoEnabled = false; //( renderSystem->GetStereo3DMode() != STEREO3D_OFF );
if( stereoEnabled )
{
const float screenSeparation = GetScreenSeparationForGuis();

View file

@ -592,10 +592,10 @@ public:
idImage* taaFeedback1Image;
idImage* taaFeedback2Image;
idImage* bloomRenderImage[2];
idImage* glowImage[2]; // contains any glowable surface information.
idImage* glowDepthImage[2];
idImage* accumTransparencyImage;
idImage* revealTransparencyImage;
//idImage* glowImage[2]; // contains any glowable surface information.
//idImage* glowDepthImage[2];
//idImage* accumTransparencyImage;
//idImage* revealTransparencyImage;
idImage* envprobeHDRImage;
idImage* envprobeDepthImage;
idImage* heatmap5Image;

View file

@ -1082,21 +1082,20 @@ void idImageManager::CreateIntrinsicImages()
bloomRenderImage[0] = globalImages->ImageFromFunction( "_bloomRender0", R_HDR_RGBA16FImage_ResQuarter_Linear );
bloomRenderImage[1] = globalImages->ImageFromFunction( "_bloomRender1", R_HDR_RGBA16FImage_ResQuarter_Linear );
glowImage[0] = globalImages->ImageFromFunction( "_glowImage0", R_RGBA8Image_ResGui );
glowImage[1] = globalImages->ImageFromFunction( "_glowImage1", R_RGBA8Image_ResGui );
glowDepthImage[0] = globalImages->ImageFromFunction( "_glowDepthImage0", R_DepthImage );
glowDepthImage[1] = globalImages->ImageFromFunction( "_glowDepthImage1", R_DepthImage );
//glowImage[0] = globalImages->ImageFromFunction( "_glowImage0", R_RGBA8Image_ResGui );
//glowImage[1] = globalImages->ImageFromFunction( "_glowImage1", R_RGBA8Image_ResGui );
//glowDepthImage[0] = globalImages->ImageFromFunction( "_glowDepthImage0", R_DepthImage );
//glowDepthImage[1] = globalImages->ImageFromFunction( "_glowDepthImage1", R_DepthImage );
accumTransparencyImage = globalImages->ImageFromFunction( "_accumTransparencyImage", R_HDR_RGBA16FImage_ResNative_Linear );
revealTransparencyImage = globalImages->ImageFromFunction( "_revealTransparencyImage", R_R8Image_ResNative_Linear );
//accumTransparencyImage = globalImages->ImageFromFunction( "_accumTransparencyImage", R_HDR_RGBA16FImage_ResNative_Linear );
//revealTransparencyImage = globalImages->ImageFromFunction( "_revealTransparencyImage", R_R8Image_ResNative_Linear );
heatmap5Image = ImageFromFunction( "_heatmap5", R_CreateHeatmap5ColorsImage );
heatmap7Image = ImageFromFunction( "_heatmap7", R_CreateHeatmap7ColorsImage );
grainImage1 = globalImages->ImageFromFunction( "_grain1", R_CreateGrainImage1 );
smaaInputImage = ImageFromFunction( "_smaaInput", R_RGBA8LinearImage );
smaaInputImage = ImageFromFunction( "_smaaInput", R_SMAAImage_ResNative );
smaaAreaImage = globalImages->ImageFromFunction( "_smaaArea", R_CreateSMAAAreaImage );
smaaSearchImage = globalImages->ImageFromFunction( "_smaaSearch", R_CreateSMAASearchImage );
@ -1115,6 +1114,9 @@ void idImageManager::CreateIntrinsicImages()
chromeSpecImage = ImageFromFunction( "_chromeSpec", R_ChromeSpecImage );
plasticSpecImage = ImageFromFunction( "_plasticSpec", R_PlasticSpecImage );
brdfLutImage = ImageFromFunction( "_brdfLut", R_CreateBrdfLutImage );
defaultUACIrradianceCube = ImageFromFunction( "_defaultUACIrradiance", R_CreateEnvprobeImage_UAC_lobby_irradiance );
defaultUACRadianceCube = ImageFromFunction( "_defaultUACRadiance", R_CreateEnvprobeImage_UAC_lobby_radiance );
// RB end
// scratchImage is used for screen wipes/doublevision etc..
@ -1132,16 +1134,6 @@ void idImageManager::CreateIntrinsicImages()
loadingIconImage = ImageFromFile( "textures/loadingicon2", TF_DEFAULT, TR_CLAMP, TD_DEFAULT, CF_2D );
hellLoadingIconImage = ImageFromFile( "textures/loadingicon3", TF_DEFAULT, TR_CLAMP, TD_DEFAULT, CF_2D );
// RB begin
#if 0
defaultUACIrradianceCube = ImageFromFile( "env/UAC5_amb", TF_DEFAULT, TR_CLAMP, TD_R11G11B10F, CF_2D_PACKED_MIPCHAIN );
defaultUACRadianceCube = ImageFromFile( "env/UAC5_spec", TF_DEFAULT, TR_CLAMP, TD_R11G11B10F, CF_2D_PACKED_MIPCHAIN );
#else
defaultUACIrradianceCube = ImageFromFunction( "_defaultUACIrradiance", R_CreateEnvprobeImage_UAC_lobby_irradiance );
defaultUACRadianceCube = ImageFromFunction( "_defaultUACRadiance", R_CreateEnvprobeImage_UAC_lobby_radiance );
#endif
// RB end
guiEdit = ImageFromFunction( "_guiEdit", R_GuiEditFunction );
guiEditDepthStencilImage = ImageFromFunction( "_guiEditDepthStencil", R_GuiEditDepthStencilFunction );

View file

@ -186,6 +186,10 @@ void Framebuffer::ResizeFramebuffers( bool reloadImages )
.addColorAttachment( globalImages->gbufferNormalsRoughnessImage->texture )
.setDepthAttachment( globalImages->currentDepthImage->texture ) );
globalFramebuffers.smaaInputFBO = new Framebuffer( "_smaaInput",
nvrhi::FramebufferDesc()
.addColorAttachment( globalImages->smaaInputImage->texture ) );
globalFramebuffers.smaaEdgesFBO = new Framebuffer( "_smaaEdges",
nvrhi::FramebufferDesc()
.addColorAttachment( globalImages->smaaEdgesImage->texture ) );
@ -227,11 +231,14 @@ void Framebuffer::ReloadImages()
globalImages->hierarchicalZbufferImage->Reload( false, tr.backend.commandList );
globalImages->gbufferNormalsRoughnessImage->Reload( false, tr.backend.commandList );
globalImages->taaMotionVectorsImage->Reload( false, tr.backend.commandList );
globalImages->taaResolvedImage->Reload( false, tr.backend.commandList );
globalImages->taaFeedback1Image->Reload( false, tr.backend.commandList );
globalImages->taaFeedback2Image->Reload( false, tr.backend.commandList );
globalImages->taaResolvedImage->Reload( false, tr.backend.commandList );
globalImages->smaaInputImage->Reload( false, tr.backend.commandList );
globalImages->smaaEdgesImage->Reload( false, tr.backend.commandList );
globalImages->smaaBlendImage->Reload( false, tr.backend.commandList );
globalImages->shadowAtlasImage->Reload( false, tr.backend.commandList );
for( int i = 0; i < MAX_SHADOWMAP_RESOLUTIONS; i++ )
{

View file

@ -1565,6 +1565,72 @@ void idRenderBackend::GetCurrentBindingLayout( int type )
desc[1].bindings[1].resourceHandle = commonPasses.m_LinearWrapSampler;
}
}
else if( type == BINDING_LAYOUT_SMAA_EDGE_DETECTION )
{
if( desc[0].bindings.empty() )
{
desc[0].bindings =
{
nvrhi::BindingSetItem::ConstantBuffer( 0, paramCb, range ),
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() )
};
}
else
{
desc[0].bindings[0].resourceHandle = paramCb;
desc[0].bindings[0].range = range;
desc[0].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID();
}
if( desc[1].bindings.empty() )
{
desc[1].bindings =
{
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_LinearClampSampler ),
nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_PointClampSampler )
};
}
else
{
desc[1].bindings[0].resourceHandle = commonPasses.m_LinearClampSampler;
desc[1].bindings[1].resourceHandle = commonPasses.m_PointClampSampler;
}
}
else if( type == BINDING_LAYOUT_SMAA_WEIGHT_CALC )
{
if( desc[0].bindings.empty() )
{
desc[0].bindings =
{
nvrhi::BindingSetItem::ConstantBuffer( 0, paramCb, range ),
nvrhi::BindingSetItem::Texture_SRV( 0, ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID() ),
nvrhi::BindingSetItem::Texture_SRV( 1, ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID() ),
nvrhi::BindingSetItem::Texture_SRV( 2, ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID() )
};
}
else
{
desc[0].bindings[0].resourceHandle = paramCb;
desc[0].bindings[0].range = range;
desc[0].bindings[1].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 0 )->GetTextureID();
desc[0].bindings[2].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 1 )->GetTextureID();
desc[0].bindings[3].resourceHandle = ( nvrhi::ITexture* )GetImageAt( 2 )->GetTextureID();
}
if( desc[1].bindings.empty() )
{
desc[1].bindings =
{
nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_LinearClampSampler ),
nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_PointClampSampler )
};
}
else
{
desc[1].bindings[0].resourceHandle = commonPasses.m_LinearClampSampler;
desc[1].bindings[1].resourceHandle = commonPasses.m_PointClampSampler;
}
}
else if( type == BINDING_LAYOUT_POST_PROCESS_CRT )
{
if( desc[0].bindings.empty() )
@ -1838,6 +1904,58 @@ void idRenderBackend::GL_StartFrame()
renderLog.StartFrame( commandList );
renderLog.OpenMainBlock( MRB_GPU_TIME );
// -------------------------
// make sure textures and render passes are initialized
void* textureId = globalImages->hierarchicalZbufferImage->GetTextureID();
// RB: we need to load all images left before rendering
// this can be expensive here because of the runtime image compression
//globalImages->LoadDeferredImages( commandList );
extern idCVar r_useNewSsaoPass;
if( !ssaoPass && r_useNewSsaoPass.GetBool() )
{
ssaoPass = new SsaoPass(
deviceManager->GetDevice(),
&commonPasses, globalImages->currentDepthImage->GetTextureHandle(),
globalImages->gbufferNormalsRoughnessImage->GetTextureHandle(),
globalImages->ambientOcclusionImage[0]->GetTextureHandle() );
}
if( globalImages->hierarchicalZbufferImage->GetTextureID() != textureId || !hiZGenPass )
{
if( hiZGenPass )
{
delete hiZGenPass;
}
hiZGenPass = new MipMapGenPass( deviceManager->GetDevice(), globalImages->hierarchicalZbufferImage->GetTextureHandle() );
}
if( !toneMapPass )
{
TonemapPass::CreateParameters createParms;
toneMapPass = new TonemapPass();
toneMapPass->Init( deviceManager->GetDevice(), &commonPasses, createParms, globalFramebuffers.ldrFBO->GetApiObject() );
}
if( !taaPass )
{
TemporalAntiAliasingPass::CreateParameters taaParams;
taaParams.sourceDepth = globalImages->currentDepthImage->GetTextureHandle();
taaParams.motionVectors = globalImages->taaMotionVectorsImage->GetTextureHandle();
taaParams.unresolvedColor = globalImages->currentRenderHDRImage->GetTextureHandle();
taaParams.resolvedColor = globalImages->taaResolvedImage->GetTextureHandle();
taaParams.feedback1 = globalImages->taaFeedback1Image->GetTextureHandle();
taaParams.feedback2 = globalImages->taaFeedback2Image->GetTextureHandle();
taaParams.motionVectorStencilMask = 0; //0x01;
taaParams.useCatmullRomFilter = true;
taaPass = new TemporalAntiAliasingPass();
taaPass->Init( deviceManager->GetDevice(), &commonPasses, NULL, taaParams );
}
}
/*
@ -1885,10 +2003,6 @@ void idRenderBackend::GL_BlockingSwapBuffers()
OPTICK_CATEGORY( "BlockingSwapBuffers", Optick::Category::Wait );
//OPTICK_TAG( "Waiting for swapIndex", swapIndex );
// SRS - device-level sync kills perf by serializing command queue processing (CPU) and rendering (GPU)
// - instead, use alternative sync method (based on command queue event queries) inside Present()
//deviceManager->GetDevice()->waitForIdle();
// Make sure that all frames have finished rendering
deviceManager->Present();
@ -2038,18 +2152,21 @@ void idRenderBackend::GL_Color( float r, float g, float b, float a )
idRenderBackend::GL_Clear
========================
*/
void idRenderBackend::GL_Clear( bool color, bool depth, bool stencil, byte stencilValue, float r, float g, float b, float a, bool clearHDR )
void idRenderBackend::GL_Clear( bool color, bool depth, bool stencil, byte stencilValue, float r, float g, float b, float a, bool clearHDR, bool clearVR, const int stereoEye )
{
nvrhi::IFramebuffer* framebuffer = Framebuffer::GetActiveFramebuffer()->GetApiObject();
nvrhi::Color colorValue( r, g, b, a );
if( color )
{
nvrhi::utils::ClearColorAttachment( commandList, framebuffer, 0, nvrhi::Color( 0.f ) );
nvrhi::utils::ClearColorAttachment( commandList, framebuffer, 0, colorValue );
}
if( clearHDR )
{
nvrhi::utils::ClearColorAttachment( commandList, globalFramebuffers.hdrFBO->GetApiObject(), 0, nvrhi::Color( 0.f ) );
nvrhi::utils::ClearColorAttachment( commandList, globalFramebuffers.hdrFBO->GetApiObject(), 0, colorValue );
nvrhi::utils::ClearColorAttachment( commandList, globalFramebuffers.ldrFBO->GetApiObject(), 0, colorValue );
}
if( depth || stencil )
@ -2221,7 +2338,7 @@ void idRenderBackend::SetBuffer( const void* data )
currentScissor.Clear();
currentScissor.AddPoint( 0, 0 );
currentScissor.AddPoint( tr.GetWidth(), tr.GetHeight() );
currentScissor.AddPoint( renderSystem->GetWidth(), renderSystem->GetHeight() );
// clear screen for debugging
// automatically enable this with several other debug tools
@ -2233,19 +2350,19 @@ void idRenderBackend::SetBuffer( const void* data )
float c[3];
if( sscanf( r_clear.GetString(), "%f %f %f", &c[0], &c[1], &c[2] ) == 3 )
{
GL_Clear( true, false, false, 0, c[0], c[1], c[2], 1.0f, true );
GL_Clear( true, false, false, 0, c[0], c[1], c[2], 1.0f, true, true );
}
else if( r_clear.GetInteger() == 2 )
{
GL_Clear( true, false, false, 0, 0.0f, 0.0f, 0.0f, 1.0f, true );
GL_Clear( true, false, false, 0, 0.0f, 0.0f, 0.0f, 1.0f, true, true );
}
else if( r_showOverDraw.GetBool() )
{
GL_Clear( true, false, false, 0, 1.0f, 1.0f, 1.0f, 1.0f, true );
GL_Clear( true, false, false, 0, 1.0f, 1.0f, 1.0f, 1.0f, true, true );
}
else
{
GL_Clear( true, false, false, 0, 0.4f, 0.0f, 0.25f, 1.0f, true );
GL_Clear( true, false, false, 0, 0.4f, 0.0f, 0.25f, 1.0f, true, true );
}
}
@ -2360,3 +2477,4 @@ void idRenderBackend::ResetPipelineCache()
{
pipelineCache.Clear();
}

View file

@ -87,17 +87,17 @@ void TemporalAntiAliasingPass::Init(
auto taaMotionVectorsShaderInfo = renderProgManager.GetProgramInfo( BUILTIN_TAA_MOTION_VECTORS );
m_MotionVectorPS = taaMotionVectorsShaderInfo.ps;
switch( r_antiAliasing.GetInteger() )
//switch( r_antiAliasing.GetInteger() )
{
#if ID_MSAA
case ANTI_ALIASING_MSAA_2X:
case ANTI_ALIASING_MSAA_2X:
{
auto taaResolveShaderInfo = renderProgManager.GetProgramInfo( BUILTIN_TAA_RESOLVE_MSAA_2X );
m_TemporalAntiAliasingCS = taaResolveShaderInfo.cs;
break;
}
case ANTI_ALIASING_MSAA_4X:
case ANTI_ALIASING_MSAA_4X:
{
auto taaResolveShaderInfo = renderProgManager.GetProgramInfo( BUILTIN_TAA_RESOLVE_MSAA_4X );
m_TemporalAntiAliasingCS = taaResolveShaderInfo.cs;
@ -108,11 +108,11 @@ void TemporalAntiAliasingPass::Init(
#pragma warning( disable : 4065 ) // C4065: switch statement contains 'default' but no 'case'
#endif
default:
//default:
{
auto taaResolveShaderInfo = renderProgManager.GetProgramInfo( BUILTIN_TAA_RESOLVE );
m_TemporalAntiAliasingCS = taaResolveShaderInfo.cs;
break;
//break;
}
}
#if !ID_MSAA && defined( _MSC_VER )

View file

@ -2088,9 +2088,7 @@ void idRenderBackend::AmbientPass( const drawSurf_t* const* drawSurfs, int numDr
renderProgManager.SetRenderParm( RENDERPARM_TEXGEN_0_ENABLED, texGenEnabled );
currentSpace = NULL;
auto mvp = renderMatrix_identity;
mvp[1][1] = -mvp[1][1]; // flip y
RB_SetMVP( mvp );
RB_SetMVP( renderMatrix_fullscreen );
renderProgManager.BindShader_Texture();
GL_Color( 1, 1, 1, 1 );
@ -2116,7 +2114,7 @@ void idRenderBackend::AmbientPass( const drawSurf_t* const* drawSurfs, int numDr
{
globalFramebuffers.geometryBufferFBO->Bind();
GL_Clear( true, false, false, 0, 0.0f, 0.0f, 0.0f, 1.0f, false );
GL_Clear( true, false, false, 0, 0.0f, 0.0f, 0.0f, 1.0f );
}
// RB: not needed
@ -2172,11 +2170,6 @@ void idRenderBackend::AmbientPass( const drawSurf_t* const* drawSurfs, int numDr
specularColor = lightColor;// * 0.5f;
float ambientBoost = 1.0f;
//if( !r_usePBR.GetBool() )
//{
// ambientBoost += r_useSSAO.GetBool() ? 0.2f : 0.0f;
// ambientBoost *= 1.1f;
//}
ambientColor.x = r_forceAmbient.GetFloat() * ambientBoost;
ambientColor.y = r_forceAmbient.GetFloat() * ambientBoost;
@ -3425,7 +3418,7 @@ void idRenderBackend::ShadowAtlasPass( const viewDef_t* _viewDef )
continue;
}
if( vLight->shadowLOD == -1 )
if( vLight->shadowLOD == -1 || vLight->globalShadows == NULL )
{
// light doesn't cast shadows
continue;
@ -3563,7 +3556,7 @@ void idRenderBackend::ShadowAtlasPass( const viewDef_t* _viewDef )
continue;
}
if( vLight->shadowLOD == -1 )
if( vLight->shadowLOD == -1 || vLight->globalShadows == NULL )
{
// light doesn't cast shadows
vLight->imageSize.x = vLight->imageSize.y = -1;
@ -4699,19 +4692,26 @@ void idRenderBackend::DrawMotionVectors()
renderLog.OpenMainBlock( MRB_MOTION_VECTORS );
renderLog.OpenBlock( "Render_MotionVectors" );
// clear the alpha buffer and draw only the hands + weapon into it so
// we can avoid blurring them
// clear the alpha buffer
GL_State( GLS_COLORMASK | GLS_DEPTHMASK );
//globalFramebuffers.smaaInputFBO->Bind();
//commandList->clearTextureFloat( globalImages->smaaInputImage->GetTextureHandle(), nvrhi::AllSubresources, nvrhi::Color( 0, 0, 0, 1 ) );
// draw only the hands + weapon into the alpha buffer so
// we can avoid blurring them
GL_State( GLS_COLORMASK | GLS_DEPTHMASK | GLS_DEPTHFUNC_ALWAYS | GLS_CULL_TWOSIDED );
GL_Color( 0, 0, 0, 1 );
renderProgManager.BindShader_Color();
currentSpace = &viewDef->worldSpace;
RB_SetMVP( viewDef->worldSpace.mvp );
currentSpace = NULL;
RB_SetMVP( renderMatrix_fullscreen );
DrawElementsWithCounters( &unitSquareSurface );
// draw the hands + weapon with alpha 0
GL_State( GLS_COLORMASK | GLS_DEPTHMASK );
GL_Color( 0, 0, 0, 0 );
GL_SelectTexture( 0 );
@ -4723,7 +4723,7 @@ void idRenderBackend::DrawMotionVectors()
{
const drawSurf_t* surf = drawSurfs[ surfNum ];
if( !surf->space->weaponDepthHack && !surf->space->skipMotionBlur && !surf->material->HasSubview() && !surf->space->isGuiSurface )
if( !surf->space->weaponDepthHack && !surf->space->skipMotionBlur && !surf->material->HasSubview() )//&& !surf->space->isGuiSurface )
{
// don't apply TAA to this object
continue;
@ -5318,62 +5318,14 @@ void idRenderBackend::ExecuteBackEndCommands( const emptyCommand_t* cmds )
return;
}
if( renderSystem->GetStereo3DMode() != STEREO3D_OFF )
{
StereoRenderExecuteBackEndCommands( cmds );
return;
}
//if( renderSystem->GetStereo3DMode() != STEREO3D_OFF )
//{
// StereoRenderExecuteBackEndCommands( cmds );
// return;
//}
GL_StartFrame();
void* textureId = globalImages->hierarchicalZbufferImage->GetTextureID();
// RB: we need to load all images left before rendering
// this can be expensive here because of the runtime image compression
//globalImages->LoadDeferredImages( commandList );
if( !ssaoPass && r_useNewSsaoPass.GetBool() )
{
ssaoPass = new SsaoPass(
deviceManager->GetDevice(),
&commonPasses, globalImages->currentDepthImage->GetTextureHandle(),
globalImages->gbufferNormalsRoughnessImage->GetTextureHandle(),
globalImages->ambientOcclusionImage[0]->GetTextureHandle() );
}
if( globalImages->hierarchicalZbufferImage->GetTextureID() != textureId || !hiZGenPass )
{
if( hiZGenPass )
{
delete hiZGenPass;
}
hiZGenPass = new MipMapGenPass( deviceManager->GetDevice(), globalImages->hierarchicalZbufferImage->GetTextureHandle() );
}
if( !toneMapPass )
{
TonemapPass::CreateParameters createParms;
toneMapPass = new TonemapPass();
toneMapPass->Init( deviceManager->GetDevice(), &commonPasses, createParms, globalFramebuffers.ldrFBO->GetApiObject() );
}
if( !taaPass )
{
TemporalAntiAliasingPass::CreateParameters taaParams;
taaParams.sourceDepth = globalImages->currentDepthImage->GetTextureHandle();
taaParams.motionVectors = globalImages->taaMotionVectorsImage->GetTextureHandle();
taaParams.unresolvedColor = globalImages->currentRenderHDRImage->GetTextureHandle();
taaParams.resolvedColor = globalImages->taaResolvedImage->GetTextureHandle();
taaParams.feedback1 = globalImages->taaFeedback1Image->GetTextureHandle();
taaParams.feedback2 = globalImages->taaFeedback2Image->GetTextureHandle();
taaParams.motionVectorStencilMask = 0; //0x01;
taaParams.useCatmullRomFilter = true;
taaPass = new TemporalAntiAliasingPass();
taaPass->Init( deviceManager->GetDevice(), &commonPasses, NULL, taaParams );
}
uint64 backEndStartTime = Sys_Microseconds();
// needed for editor rendering
@ -5484,19 +5436,33 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
// ugly but still faster than building the string
if( !_viewDef->viewEntitys || _viewDef->is2Dgui )
{
renderLog.OpenBlock( "Render_DrawView2D", colorRed );
if( stereoEye == -1 )
{
renderLog.OpenBlock( "Render_DrawView2D_LeftEye", colorRed );
}
else if( stereoEye == 1 )
{
renderLog.OpenBlock( "Render_DrawView2D_RightEye", colorRed );
}
else
{
renderLog.OpenBlock( "Render_DrawView2D", colorRed );
}
}
else if( stereoEye == -1 )
else
{
renderLog.OpenBlock( "Render_DrawView3D_LeftEye", colorRed );
}
else if( stereoEye == 1 )
{
renderLog.OpenBlock( "Render_DrawView3D_RightEye", colorRed );
}
else if( stereoEye == 0 )
{
renderLog.OpenBlock( "Render_DrawView3D", colorRed );
if( stereoEye == -1 )
{
renderLog.OpenBlock( "Render_DrawView3D_LeftEye", colorRed );
}
else if( stereoEye == 1 )
{
renderLog.OpenBlock( "Render_DrawView3D_RightEye", colorRed );
}
else
{
renderLog.OpenBlock( "Render_DrawView3D", colorRed );
}
}
//-------------------------------------------------
@ -5562,7 +5528,7 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
{
OPTICK_GPU_EVENT( "Render_ClearDepthStencil" );
GL_Clear( clearColor, true, true, STENCIL_SHADOW_TEST_VALUE, 0.0f, 0.0f, 0.0f, 0.0f, false );
GL_Clear( clearColor, true, true, STENCIL_SHADOW_TEST_VALUE, 0.0f, 0.0f, 0.0f, 0.0f );
}
// RB end
@ -5840,7 +5806,7 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
BlitParameters blitParms;
blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID();
blitParms.targetFramebuffer = deviceManager->GetCurrentFramebuffer();
blitParms.targetViewport = nvrhi::Viewport( renderSystem->GetWidth(), renderSystem->GetHeight() );
blitParms.targetViewport = nvrhi::Viewport( renderSystem->GetNativeWidth(), renderSystem->GetNativeHeight() );
commonPasses.BlitTexture( commandList, blitParms, &bindingCache );
// blit envprobe over it for quick review where we are
@ -5852,15 +5818,62 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
}
else
{
OPTICK_GPU_EVENT( "Blit_Rendered" );
OPTICK_GPU_EVENT( "Blit_Rendered2SwapChain" );
renderLog.OpenBlock( "Blit_Rendered2SwapChain", colorBlue );
// copy LDR result to DX12 / Vulkan swapchain image
#if 0
if( vrSystem->IsActive() )
{
uint32_t swapChainIndex = deviceManager->GetCurrentBackBufferIndex();
BlitParameters blitParms;
blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID();
blitParms.targetFramebuffer = deviceManager->GetCurrentFramebuffer();
blitParms.targetViewport = nvrhi::Viewport( renderSystem->GetWidth(), renderSystem->GetHeight() );
commonPasses.BlitTexture( commandList, blitParms, &bindingCache );
globalFramebuffers.swapFramebuffers[ swapChainIndex ]->Bind();
int width = globalFramebuffers.swapFramebuffers[ swapChainIndex ]->GetWidth();
int height = globalFramebuffers.swapFramebuffers[ swapChainIndex ]->GetHeight();
// set the window clipping
GL_Viewport( 0, 0, width, width );
GL_Scissor( 0, 0, width, height );
renderProgManager.BindShader_TextureVertexColor_sRGB();
//renderProgManager.BindShader_Screen();
currentSpace = NULL;
RB_SetMVP( renderMatrix_fullscreen );
renderProgManager.SetRenderParm( RENDERPARM_ALPHA_TEST, vec4_zero.ToFloatPtr() );
float texS[4] = { 1.0f, 0.0f, 0.0f, 0.0f };
float texT[4] = { 0.0f, 1.0f, 0.0f, 0.0f };
renderProgManager.SetRenderParm( RENDERPARM_TEXTUREMATRIX_S, texS );
renderProgManager.SetRenderParm( RENDERPARM_TEXTUREMATRIX_T, texT );
float texGenEnabled[4] = { 0, 0, 0, 0 };
renderProgManager.SetRenderParm( RENDERPARM_TEXGEN_0_ENABLED, texGenEnabled );
RB_SetVertexColorParms( SVC_IGNORE );
GL_State( GLS_DEPTHFUNC_ALWAYS | GLS_DEPTHMASK | GLS_CULL_TWOSIDED );
GL_SelectTexture( 0 );
globalImages->ldrImage->Bind();
DrawElementsWithCounters( &unitSquareSurface );
ResetViewportAndScissorToDefaultCamera( _viewDef );
}
else
#endif
//if( stereoEye == 1 || stereoEye == 0 )
{
BlitParameters blitParms;
blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID();
blitParms.targetFramebuffer = deviceManager->GetCurrentFramebuffer();
blitParms.targetViewport = nvrhi::Viewport( renderSystem->GetNativeWidth(), renderSystem->GetNativeHeight() );
commonPasses.BlitTexture( commandList, blitParms, &bindingCache );
}
renderLog.CloseBlock();
}
renderLog.CloseBlock();
@ -6145,21 +6158,20 @@ void idRenderBackend::PostProcess( const void* data )
if( viewDef->renderView.rdflags & RDF_IRRADIANCE )
{
#if defined( USE_NVRHI )
OPTICK_GPU_EVENT( "Blit_EnvProbePostFX" );
// we haven't changed ldrImage so it's basically the previewsRenderLDR
BlitParameters blitParms;
blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID();
blitParms.targetFramebuffer = deviceManager->GetCurrentFramebuffer();
blitParms.targetViewport = nvrhi::Viewport( renderSystem->GetWidth(), renderSystem->GetHeight() );
blitParms.targetViewport = nvrhi::Viewport( renderSystem->GetNativeWidth(), renderSystem->GetNativeHeight() );
commonPasses.BlitTexture( commandList, blitParms, &bindingCache );
blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->envprobeHDRImage->GetTextureID();
blitParms.targetFramebuffer = deviceManager->GetCurrentFramebuffer();
blitParms.targetViewport = nvrhi::Viewport( ENVPROBE_CAPTURE_SIZE, ENVPROBE_CAPTURE_SIZE );
commonPasses.BlitTexture( commandList, blitParms, &bindingCache );
#endif
return;
}
@ -6179,11 +6191,14 @@ void idRenderBackend::PostProcess( const void* data )
GL_Viewport( 0, 0, screenWidth, screenHeight );
GL_Scissor( 0, 0, screenWidth, screenHeight );
#if 0
#if 1
// SMAA
int aaMode = r_antiAliasing.GetInteger();
if( aaMode == ANTI_ALIASING_SMAA_1X )
{
OPTICK_GPU_EVENT( "Render_SMAA" );
renderLog.OpenBlock( "Render_SMAA" );
/*
* The shader has three passes, chained together as follows:
*
@ -6202,8 +6217,6 @@ void idRenderBackend::PostProcess( const void* data )
* |output|
*/
globalImages->smaaInputImage->CopyFramebuffer( 0, 0, screenWidth, screenHeight );
// set SMAA_RT_METRICS = rpScreenCorrectionFactor
float screenCorrectionParm[4];
screenCorrectionParm[0] = 1.0f / screenWidth;
@ -6212,53 +6225,60 @@ void idRenderBackend::PostProcess( const void* data )
screenCorrectionParm[3] = screenHeight;
SetFragmentParm( RENDERPARM_SCREENCORRECTIONFACTOR, screenCorrectionParm ); // rpScreenCorrectionFactor
globalFramebuffers.smaaEdgesFBO->Bind();
BlitParameters blitParms;
blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID();
blitParms.targetFramebuffer = globalFramebuffers.smaaInputFBO->GetApiObject();
glClearColor( 0, 0, 0, 0 );
glClear( GL_COLOR_BUFFER_BIT );
blitParms.targetViewport = nvrhi::Viewport( renderSystem->GetWidth(), renderSystem->GetHeight() );
commonPasses.BlitTexture( commandList, blitParms, &bindingCache );
GL_SelectTexture( 0 );
globalImages->smaaInputImage->Bind();
{
// [ SMAA*EdgeDetection ]
globalFramebuffers.smaaEdgesFBO->Bind();
renderProgManager.BindShader_SMAA_EdgeDetection();
DrawElementsWithCounters( &unitSquareSurface );
GL_Clear( true, false, false, 128, 0, 0, 0, 0 );
#if 1
//globalImages->smaaEdgesImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
GL_SelectTexture( 0 );
globalImages->smaaInputImage->Bind();
globalFramebuffers.smaaBlendFBO->Bind();
//Framebuffer::Unbind();
renderProgManager.BindShader_SMAA_EdgeDetection();
DrawElementsWithCounters( &unitSquareSurface );
}
glClear( GL_COLOR_BUFFER_BIT );
{
// [ SMAABlendingWeightCalculation ]
globalFramebuffers.smaaBlendFBO->Bind();
GL_SelectTexture( 0 );
globalImages->smaaEdgesImage->Bind();
GL_Clear( true, false, false, 128, 0, 0, 0, 0 );
GL_SelectTexture( 1 );
globalImages->smaaAreaImage->Bind();
GL_SelectTexture( 0 );
globalImages->smaaEdgesImage->Bind();
GL_SelectTexture( 2 );
globalImages->smaaSearchImage->Bind();
GL_SelectTexture( 1 );
globalImages->smaaAreaImage->Bind();
renderProgManager.BindShader_SMAA_BlendingWeightCalculation();
DrawElementsWithCounters( &unitSquareSurface );
GL_SelectTexture( 2 );
globalImages->smaaSearchImage->Bind();
Framebuffer::Unbind();
#endif
renderProgManager.BindShader_SMAA_BlendingWeightCalculation();
DrawElementsWithCounters( &unitSquareSurface );
}
#if 1
//GL_SelectTexture( 0 );
//globalImages->smaaBlendImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
{
// [ SMAANeighborhoodBlending ]
globalFramebuffers.ldrFBO->Bind();
GL_SelectTexture( 0 );
globalImages->smaaInputImage->Bind();
GL_SelectTexture( 0 );
globalImages->smaaInputImage->Bind();
GL_SelectTexture( 1 );
globalImages->smaaBlendImage->Bind();
GL_SelectTexture( 1 );
globalImages->smaaBlendImage->Bind();
renderProgManager.BindShader_SMAA_NeighborhoodBlending();
DrawElementsWithCounters( &unitSquareSurface );
#endif
renderProgManager.BindShader_SMAA_NeighborhoodBlending();
DrawElementsWithCounters( &unitSquareSurface );
}
renderLog.CloseBlock();
}
#endif
@ -6457,7 +6477,7 @@ void idRenderBackend::PostProcess( const void* data )
BlitParameters blitParms;
blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID();
blitParms.targetFramebuffer = deviceManager->GetCurrentFramebuffer();
blitParms.targetViewport = nvrhi::Viewport( renderSystem->GetWidth(), renderSystem->GetHeight() );
blitParms.targetViewport = nvrhi::Viewport( renderSystem->GetNativeWidth(), renderSystem->GetNativeHeight() );
commonPasses.BlitTexture( commandList, blitParms, &bindingCache );
// copy LDR result to postProcFBO which is HDR but also used by postFX
@ -6623,7 +6643,7 @@ void idRenderBackend::CRTPostProcess()
BlitParameters blitParms;
blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID();
blitParms.targetFramebuffer = deviceManager->GetCurrentFramebuffer();
blitParms.targetViewport = nvrhi::Viewport( renderSystem->GetWidth(), renderSystem->GetHeight() );
blitParms.targetViewport = nvrhi::Viewport( renderSystem->GetNativeWidth(), renderSystem->GetNativeHeight() );
commonPasses.BlitTexture( commandList, blitParms, &bindingCache );
}

View file

@ -136,13 +136,10 @@ public:
void StereoRenderExecuteBackEndCommands( const emptyCommand_t* const allCmds );
void GL_BlockingSwapBuffers();
void Print();
void CheckCVars();
void ClearCaches();
static void ImGui_Init();
static void ImGui_Shutdown();
static void ImGui_RenderDrawLists( ImDrawData* draw_data );
void DrawElementsWithCounters( const drawSurf_t* surf, bool shadowCounter = false );
@ -151,9 +148,6 @@ private:
void DrawFlickerBox();
void GetCurrentBindingLayout( int bindingLayoutType );
void DrawStencilShadowPass( const drawSurf_t* drawSurf, const bool renderZPass );
void SetColorMappings();
void ResizeImages();
void DrawViewInternal( const viewDef_t* viewDef, const int stereoEye );
@ -239,7 +233,7 @@ private:
// void GL_CopyDepthBuffer( idImage* image, int x, int y, int imageWidth, int imageHeight );
// RB: HDR parm
void GL_Clear( bool color, bool depth, bool stencil, byte stencilValue, float r, float g, float b, float a, bool clearHDR = false );
void GL_Clear( bool color, bool depth, bool stencil, byte stencilValue, float r, float g, float b, float a, bool clearHDR = false, bool clearVR = false, const int stereoEye = 0 );
void GL_DepthBoundsTest( const float zmin, const float zmax );
void GL_PolygonOffset( float scale, float bias );

View file

@ -835,6 +835,10 @@ enum bindingLayoutType_t
BINDING_LAYOUT_BINK_VIDEO,
// SMAA
BINDING_LAYOUT_SMAA_EDGE_DETECTION,
BINDING_LAYOUT_SMAA_WEIGHT_CALC,
// NVRHI render passes specific
BINDING_LAYOUT_TAA_MOTION_VECTORS,
BINDING_LAYOUT_TAA_RESOLVE,
@ -876,13 +880,10 @@ public:
virtual void ShutdownOpenGL();
virtual bool IsOpenGLRunning() const;
virtual bool IsFullScreen() const;
virtual stereo3DMode_t GetStereo3DMode() const;
virtual bool HasQuadBufferSupport() const;
virtual bool IsStereoScopicRenderingSupported() const;
virtual stereo3DMode_t GetStereoScopicRenderingMode() const;
virtual void EnableStereoScopicRendering( const stereo3DMode_t mode ) const;
virtual int GetWidth() const;
virtual int GetHeight() const;
virtual int GetNativeWidth() const;
virtual int GetNativeHeight() const;
virtual int GetVirtualWidth() const;
virtual int GetVirtualHeight() const;
virtual float GetPixelAspect() const;
@ -956,8 +957,6 @@ public:
idRenderSystemLocal();
~idRenderSystemLocal();
void UpdateStereo3DMode();
void Clear();
void GetCroppedViewport( idScreenRect* viewport );
void PerformResolutionScaling( int& newWidth, int& newHeight );
@ -1380,7 +1379,6 @@ struct glimpParms_t
int fullScreen; // 0 = windowed, otherwise 1 based monitor number to go full screen on
// -1 = borderless window for spanning multiple displays
bool startMaximized = false;
bool stereo;
int displayHz;
int multiSamples;
};

View file

@ -377,6 +377,23 @@ void idRenderProgManager::Init( nvrhi::IDevice* device )
bindingLayouts[BINDING_LAYOUT_BINK_VIDEO] = { device->createBindingLayout( binkVideoBindingLayout ), samplerOneBindingLayout };
auto smaaEdgeDetectionBindingLayout = nvrhi::BindingLayoutDesc()
.setVisibility( nvrhi::ShaderType::All )
.addItem( renderParmLayoutItem )
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 0 ) ); // _smaaInput
//.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 1 ) ) // _motionVectors
bindingLayouts[BINDING_LAYOUT_SMAA_EDGE_DETECTION] = { device->createBindingLayout( smaaEdgeDetectionBindingLayout ), samplerTwoBindingLayout };
auto smaaWeightCalcBindingLayout = nvrhi::BindingLayoutDesc()
.setVisibility( nvrhi::ShaderType::All )
.addItem( renderParmLayoutItem )
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 0 ) ) // _smaaEdges
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 1 ) ) // _smaaArea
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 2 ) ); // _smaaSearch
bindingLayouts[BINDING_LAYOUT_SMAA_WEIGHT_CALC] = { device->createBindingLayout( smaaWeightCalcBindingLayout ), samplerTwoBindingLayout };
auto motionVectorsBindingLayout = nvrhi::BindingLayoutDesc()
.setVisibility( nvrhi::ShaderType::All )
.addItem( renderParmLayoutItem )
@ -548,9 +565,9 @@ void idRenderProgManager::Init( nvrhi::IDevice* device )
{ BUILTIN_HDR_GLARE_CHROMATIC, "builtin/post/hdr_glare_chromatic", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
{ BUILTIN_HDR_DEBUG, "builtin/post/tonemap", "_debug", { { "BRIGHTPASS", "0" }, { "HDR_DEBUG", "1"} }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
{ BUILTIN_SMAA_EDGE_DETECTION, "builtin/post/SMAA_edge_detection", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
{ BUILTIN_SMAA_BLENDING_WEIGHT_CALCULATION, "builtin/post/SMAA_blending_weight_calc", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
{ BUILTIN_SMAA_NEIGHBORHOOD_BLENDING, "builtin/post/SMAA_final", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
{ BUILTIN_SMAA_EDGE_DETECTION, "builtin/post/SMAA_edge_detection", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_SMAA_EDGE_DETECTION },
{ BUILTIN_SMAA_BLENDING_WEIGHT_CALCULATION, "builtin/post/SMAA_blending_weight_calc", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_SMAA_WEIGHT_CALC },
{ BUILTIN_SMAA_NEIGHBORHOOD_BLENDING, "builtin/post/SMAA_final", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_POST_PROCESS_FINAL },
{ BUILTIN_MOTION_BLUR, "builtin/post/motionBlur", "_vectors", { { "VECTORS_ONLY", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_TAA_MOTION_VECTORS },
{ BUILTIN_TAA_RESOLVE, "builtin/post/taa", "", { { "SAMPLE_COUNT", "1" }, { "USE_CATMULL_ROM_FILTER", "1" } }, false, SHADER_STAGE_COMPUTE, LAYOUT_UNKNOWN, BINDING_LAYOUT_TAA_RESOLVE },

View file

@ -736,7 +736,7 @@ const emptyCommand_t* idRenderSystemLocal::SwapCommandBuffers_FinishCommandBuffe
// possibly change the stereo3D mode
// PC
UpdateStereo3DMode();
// TODO vrSystem->UpdateStereo3DMode();
if( !commandList )
{

View file

@ -39,27 +39,24 @@ If you have questions concerning this license or the applicable additional terms
===============================================================================
*/
enum stereo3DMode_t
// In a head mounted display with separate displays for each eye,
// screen separation will be zero and world separation will be the eye distance.
struct stereoDistances_t
{
STEREO3D_OFF,
// Offset to projection matrix, positive one eye, negative the other.
// Total distance is twice this, so 0.05 would give a 10% of screen width
// separation for objects at infinity.
float screenSeparation;
// half-resolution, non-square pixel views
STEREO3D_SIDE_BY_SIDE_COMPRESSED,
STEREO3D_TOP_AND_BOTTOM_COMPRESSED,
// Game world units from one eye to the centerline.
// Total distance is twice this.
float worldSeparation;
// two full resolution views side by side, as for a dual cable display
STEREO3D_SIDE_BY_SIDE,
STEREO3D_INTERLACED,
// OpenGL quad buffer
STEREO3D_QUAD_BUFFER,
// two full resolution views stacked with a 30 pixel guard band
// On the PC this can be configured as a custom video timing, but
// it definitely isn't a consumer level task. The quad_buffer
// support can handle 720P-3D with apropriate driver support.
STEREO3D_HDMI_720
// RB: offset behind both eyes considering the FOV
// see https://github.com/RobertBeckebans/RBDOOM-3-BFG/issues/878
float combinedSeperation;
};
typedef enum
@ -91,6 +88,7 @@ enum graphicsVendor_t
enum antiAliasingMode_t
{
ANTI_ALIASING_NONE,
ANTI_ALIASING_SMAA_1X,
ANTI_ALIASING_TAA,
#if ID_MSAA
@ -191,15 +189,12 @@ struct glconfig_t
bool timerQueryAvailable;
stereo3DMode_t stereo3Dmode;
int nativeScreenWidth; // this is the native screen width resolution of the renderer
int nativeScreenHeight; // this is the native screen height resolution of the renderer
int displayFrequency;
int isFullscreen; // monitor number
bool isStereoPixelFormat;
bool stereoPixelFormatAvailable;
int multisamples;
// Screen separation for stereoscopic rendering is set based on this.
@ -255,6 +250,8 @@ public:
virtual bool IsFullScreen() const = 0;
virtual int GetWidth() const = 0;
virtual int GetHeight() const = 0;
virtual int GetNativeWidth() const = 0;
virtual int GetNativeHeight() const = 0;
virtual int GetVirtualWidth() const = 0;
virtual int GetVirtualHeight() const = 0;
@ -266,14 +263,6 @@ public:
// This is used to calculate stereoscopic screen offset for a given interocular distance.
virtual float GetPhysicalScreenWidthInCentimeters() const = 0;
// GetWidth() / GetHeight() return the size of a single eye
// view, which may be replicated twice in a stereo display
virtual stereo3DMode_t GetStereo3DMode() const = 0;
virtual bool IsStereoScopicRenderingSupported() const = 0;
virtual stereo3DMode_t GetStereoScopicRenderingMode() const = 0;
virtual void EnableStereoScopicRendering( const stereo3DMode_t mode ) const = 0;
virtual bool HasQuadBufferSupport() const = 0;
// allocate a renderWorld to be used for drawing
virtual idRenderWorld* AllocRenderWorld() = 0;
virtual void FreeRenderWorld( idRenderWorld* rw ) = 0;

View file

@ -82,7 +82,7 @@ idCVar r_useValidationLayers( "r_useValidationLayers", "1", CVAR_INTEGER | CVAR_
#if ID_MSAA
idCVar r_antiAliasing( "r_antiAliasing", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER | CVAR_NEW, " 0 = None\n 1 = TAA 1x\n 2 = TAA + SMAA 1x\n 3 = MSAA 2x\n 4 = MSAA 4x\n", 0, ANTI_ALIASING_MSAA_4X );
#else
idCVar r_antiAliasing( "r_antiAliasing", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER | CVAR_NEW, " 0 = None\n 1 = TAA 1x", 0, ANTI_ALIASING_TAA );
idCVar r_antiAliasing( "r_antiAliasing", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER | CVAR_NEW, " 0 = None\n 1 = SMAA 1x, 2 = TAA", 0, ANTI_ALIASING_TAA );
#endif
// RB end
idCVar r_vidMode( "r_vidMode", "0", CVAR_ARCHIVE | CVAR_RENDERER | CVAR_INTEGER, "fullscreen video mode number" );
@ -335,7 +335,7 @@ bool R_UseTemporalAA()
return false;
}
if( r_renderMode.GetInteger() == RENDERMODE_PSX )
if( r_renderMode.GetInteger() != RENDERMODE_DOOM )
{
return false;
}
@ -398,9 +398,9 @@ void R_SetNewMode( const bool fullInit )
{
// try up to three different configurations
for( int i = 0 ; i < 3 ; i++ )
for( int i = 0 ; i < 3; i++ )
{
if( i == 0 && stereoRender_enable.GetInteger() != STEREO3D_QUAD_BUFFER )
if( i == 0 /*&& vr_enable.GetInteger() != STEREO3D_QUAD_BUFFER*/ )
{
continue; // don't even try for a stereo mode
}
@ -483,15 +483,6 @@ void R_SetNewMode( const bool fullInit )
#pragma warning( pop )
#endif
if( i == 0 )
{
parms.stereo = ( stereoRender_enable.GetInteger() == STEREO3D_QUAD_BUFFER );
}
else
{
parms.stereo = false;
}
if( fullInit )
{
// create the context as well as setting up the window
@ -502,7 +493,7 @@ void R_SetNewMode( const bool fullInit )
if( GLimp_Init( parms ) )
#endif
{
ImGuiHook::Init( glConfig.nativeScreenWidth, glConfig.nativeScreenHeight );
ImGuiHook::Init( renderSystem->GetWidth(), renderSystem->GetHeight() );
break;
}
}
@ -517,14 +508,14 @@ void R_SetNewMode( const bool fullInit )
#endif
{
Framebuffer::ResizeFramebuffers();
ImGuiHook::NotifyDisplaySizeChanged( glConfig.nativeScreenWidth, glConfig.nativeScreenHeight );
ImGuiHook::NotifyDisplaySizeChanged( renderSystem->GetWidth(), renderSystem->GetHeight() );
break;
}
}
if( i == 2 )
{
common->FatalError( "Unable to initialize OpenGL" );
common->FatalError( "Unable to initialize renderer" );
}
if( i == 0 )
@ -1520,7 +1511,7 @@ void GfxInfo_f( const idCmdArgs& args )
common->Printf( "-------\n" );
if( r_swapInterval.GetInteger() )//&& wglSwapIntervalEXT != NULL )
if( r_swapInterval.GetInteger() )
{
common->Printf( "Forcing swapInterval %i\n", r_swapInterval.GetInteger() );
}
@ -1529,49 +1520,7 @@ void GfxInfo_f( const idCmdArgs& args )
common->Printf( "swapInterval not forced\n" );
}
if( glConfig.stereoPixelFormatAvailable && glConfig.isStereoPixelFormat )
{
idLib::Printf( "OpenGl quad buffer stereo pixel format active\n" );
}
else if( glConfig.stereoPixelFormatAvailable )
{
idLib::Printf( "OpenGl quad buffer stereo pixel available but not selected\n" );
}
else
{
idLib::Printf( "OpenGl quad buffer stereo pixel format not available\n" );
}
idLib::Printf( "Stereo mode: " );
switch( renderSystem->GetStereo3DMode() )
{
case STEREO3D_OFF:
idLib::Printf( "STEREO3D_OFF\n" );
break;
case STEREO3D_SIDE_BY_SIDE_COMPRESSED:
idLib::Printf( "STEREO3D_SIDE_BY_SIDE_COMPRESSED\n" );
break;
case STEREO3D_TOP_AND_BOTTOM_COMPRESSED:
idLib::Printf( "STEREO3D_TOP_AND_BOTTOM_COMPRESSED\n" );
break;
case STEREO3D_SIDE_BY_SIDE:
idLib::Printf( "STEREO3D_SIDE_BY_SIDE\n" );
break;
case STEREO3D_HDMI_720:
idLib::Printf( "STEREO3D_HDMI_720\n" );
break;
case STEREO3D_INTERLACED:
idLib::Printf( "STEREO3D_INTERLACED\n" );
break;
case STEREO3D_QUAD_BUFFER:
idLib::Printf( "STEREO3D_QUAD_BUFFER\n" );
break;
default:
idLib::Printf( "Unknown (%i)\n", renderSystem->GetStereo3DMode() );
break;
}
idLib::Printf( "%i multisamples\n", glConfig.multisamples );
//idLib::Printf( "%i multisamples\n", glConfig.multisamples );
common->Printf( "%5.1f cm screen width (%4.1f\" diagonal)\n",
glConfig.physicalScreenWidthInCentimeters, glConfig.physicalScreenWidthInCentimeters / 2.54f
@ -2214,8 +2163,6 @@ void idRenderSystemLocal::Init()
guiModel->Clear();
tr_guiModel = guiModel; // for DeviceContext fast path
UpdateStereo3DMode();
globalImages->Init();
// RB begin
@ -2580,10 +2527,13 @@ idRenderSystemLocal::GetWidth
*/
int idRenderSystemLocal::GetWidth() const
{
// do something similar in case the VR API requires it
/*
if( glConfig.stereo3Dmode == STEREO3D_SIDE_BY_SIDE || glConfig.stereo3Dmode == STEREO3D_SIDE_BY_SIDE_COMPRESSED )
{
return glConfig.nativeScreenWidth >> 1;
}
*/
return glConfig.nativeScreenWidth;
}
@ -2595,6 +2545,8 @@ idRenderSystemLocal::GetHeight
*/
int idRenderSystemLocal::GetHeight() const
{
// do something similar in case the VR API requires it
/*
if( glConfig.stereo3Dmode == STEREO3D_HDMI_720 )
{
return 720;
@ -2605,13 +2557,25 @@ int idRenderSystemLocal::GetHeight() const
// for the Rift, render a square aspect view that will be symetric for the optics
return glConfig.nativeScreenWidth >> 1;
}
if( glConfig.stereo3Dmode == STEREO3D_INTERLACED || glConfig.stereo3Dmode == STEREO3D_TOP_AND_BOTTOM_COMPRESSED )
{
return glConfig.nativeScreenHeight >> 1;
}
*/
return glConfig.nativeScreenHeight;
}
// RB: return swap chain width
int idRenderSystemLocal::GetNativeWidth() const
{
return glConfig.nativeScreenWidth;
}
// RB: return swap chain height
int idRenderSystemLocal::GetNativeHeight() const
{
return glConfig.nativeScreenHeight;
}
// RB end
/*
========================
idRenderSystemLocal::GetVirtualWidth
@ -2644,82 +2608,6 @@ int idRenderSystemLocal::GetVirtualHeight() const
return glConfig.nativeScreenHeight / 2;
}
/*
========================
idRenderSystemLocal::GetStereo3DMode
========================
*/
stereo3DMode_t idRenderSystemLocal::GetStereo3DMode() const
{
return glConfig.stereo3Dmode;
}
/*
========================
idRenderSystemLocal::IsStereoScopicRenderingSupported
========================
*/
bool idRenderSystemLocal::IsStereoScopicRenderingSupported() const
{
#if VR_OPTIONS
return true;
#else
return false;
#endif
}
/*
========================
idRenderSystemLocal::HasQuadBufferSupport
========================
*/
bool idRenderSystemLocal::HasQuadBufferSupport() const
{
return glConfig.stereoPixelFormatAvailable;
}
/*
========================
idRenderSystemLocal::UpdateStereo3DMode
========================
*/
void idRenderSystemLocal::UpdateStereo3DMode()
{
if( glConfig.nativeScreenWidth == 1280 && glConfig.nativeScreenHeight == 1470 )
{
glConfig.stereo3Dmode = STEREO3D_HDMI_720;
}
else
{
glConfig.stereo3Dmode = GetStereoScopicRenderingMode();
}
}
/*
========================
idRenderSystemLocal::GetStereoScopicRenderingMode
========================
*/
stereo3DMode_t idRenderSystemLocal::GetStereoScopicRenderingMode() const
{
// RB: only support in VR builds
#if VR_OPTIONS
return ( !IsStereoScopicRenderingSupported() ) ? STEREO3D_OFF : ( stereo3DMode_t )stereoRender_enable.GetInteger();
#else
return STEREO3D_OFF;
#endif
}
/*
========================
idRenderSystemLocal::IsStereoScopicRenderingSupported
========================
*/
void idRenderSystemLocal::EnableStereoScopicRendering( const stereo3DMode_t mode ) const
{
stereoRender_enable.SetInteger( mode );
}
/*
========================
idRenderSystemLocal::GetPixelAspect
@ -2727,6 +2615,7 @@ idRenderSystemLocal::GetPixelAspect
*/
float idRenderSystemLocal::GetPixelAspect() const
{
/*
switch( glConfig.stereo3Dmode )
{
case STEREO3D_SIDE_BY_SIDE_COMPRESSED:
@ -2737,6 +2626,9 @@ float idRenderSystemLocal::GetPixelAspect() const
default:
return glConfig.pixelAspect;
}
*/
return glConfig.pixelAspect;
}
/*

View file

@ -959,9 +959,6 @@ CONSOLE_COMMAND_SHIP( bakeEnvironmentProbes, "Bake environment probes", NULL )
// make sure the game / draw thread has completed
commonLocal.WaitGameThread();
//glConfig.nativeScreenWidth = captureSize;
//glConfig.nativeScreenHeight = captureSize;
// disable scissor, so we don't need to adjust all those rects
r_useScissor.SetBool( false );

View file

@ -694,7 +694,6 @@ void R_RenderView( viewDef_t* parms )
// RB: we need a unprojection matrix to calculate the vertex position based on the depth image value
// for some post process shaders
R_SetupUnprojection( tr.viewDef );
// RB end
// setup render matrices for faster culling
idRenderMatrix::Transpose( *( idRenderMatrix* )tr.viewDef->projectionMatrix, tr.viewDef->projectionRenderMatrix );
@ -716,9 +715,8 @@ void R_RenderView( viewDef_t* parms )
// remove the Z-near to avoid portals from being near clipped
tr.viewDef->frustums[FRUSTUM_PRIMARY][4][3] -= r_znear.GetFloat();
// RB begin
// RB: prepare subfrustums for cascaded shadow mapping of sun lights
R_SetupSplitFrustums( tr.viewDef );
// RB end
// identify all the visible portal areas, and create view lights and view entities
// for all the the entityDefs and lightDefs that are in the visible portal areas

View file

@ -295,6 +295,11 @@
* macros will be ignored if set in the "Configurable Defines" section.
*/
// RB begin
#define SMAA_RT_METRICS rpScreenCorrectionFactor
#define SMAA_PRESET_HIGH
// RB end
#if defined(SMAA_PRESET_LOW)
#define SMAA_THRESHOLD 0.15
#define SMAA_MAX_SEARCH_STEPS 4

View file

@ -36,16 +36,16 @@ If you have questions concerning this license or the applicable additional terms
#include "SMAA.inc.hlsl"
// *INDENT-OFF*
Texture2D t_SmaaEdges : register( t0 VK_DESCRIPTOR_SET( 1 ) );
Texture2D t_SmaaArea : register( t1 VK_DESCRIPTOR_SET( 1 ) );
Texture2D t_SmaaSearch : register( t2 VK_DESCRIPTOR_SET( 1 ) );
Texture2D t_SmaaEdges : register( t0 VK_DESCRIPTOR_SET( 0 ) );
Texture2D t_SmaaArea : register( t1 VK_DESCRIPTOR_SET( 0 ) );
Texture2D t_SmaaSearch : register( t2 VK_DESCRIPTOR_SET( 0 ) );
SamplerState LinearSampler : register( s0 VK_DESCRIPTOR_SET( 2 ) );
SamplerState PointSampler : register( s1 VK_DESCRIPTOR_SET( 2 ) );
SamplerState LinearSampler : register( s0 VK_DESCRIPTOR_SET( 1 ) );
SamplerState PointSampler : register( s1 VK_DESCRIPTOR_SET( 1 ) );
struct PS_IN
{
float4 position : VPOS;
float4 position : SV_Position;
float2 texcoord0 : TEXCOORD0_centroid;
float4 texcoord1 : TEXCOORD1_centroid;
float4 texcoord2 : TEXCOORD2_centroid;

View file

@ -48,12 +48,12 @@ struct VS_IN
struct VS_OUT
{
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
float4 texcoord3 : TEXCOORD3;
float4 texcoord4 : TEXCOORD4;
float4 position : SV_Position;
float2 texcoord0 : TEXCOORD0_centroid;
float4 texcoord1 : TEXCOORD1_centroid;
float4 texcoord2 : TEXCOORD2_centroid;
float4 texcoord3 : TEXCOORD3_centroid;
float4 texcoord4 : TEXCOORD4_centroid;
};
// *INDENT-ON*
@ -61,8 +61,8 @@ void main( VS_IN vertex, out VS_OUT result )
{
result.position = vertex.position;
float2 texcoord = vertex.texcoord;
//float2 texcoord = float2( vertex.texcoord.s, 1.0 - vertex.texcoord.t );
// RB: flip Y for DX12 / Vulkan
float2 texcoord = float2( vertex.texcoord.x, 1.0 - vertex.texcoord.y );
result.texcoord0 = texcoord;
float4 offset[3];

View file

@ -36,15 +36,19 @@ If you have questions concerning this license or the applicable additional terms
#include "SMAA.inc.hlsl"
// *INDENT-OFF*
Texture2D t_CurrentRender : register( t0 VK_DESCRIPTOR_SET( 1 ) );
Texture2D t_PredictColor : register( t1 VK_DESCRIPTOR_SET( 1 ));
Texture2D t_CurrentRender : register( t0 VK_DESCRIPTOR_SET( 0 ) );
SamplerState samp0 : register( s0 VK_DESCRIPTOR_SET( 1 ) ); // _currentColor
SamplerState samp1 : register( s1 VK_DESCRIPTOR_SET( 1 ) ); // TODO _predictColor
#if SMAA_PREDICATION
Texture2D t_PredictColor : register( t1 VK_DESCRIPTOR_SET( 0 ));
#endif
SamplerState samp0 : register( s0 VK_DESCRIPTOR_SET( 2 ) ); // _currentColor
SamplerState samp1 : register( s1 VK_DESCRIPTOR_SET( 2 ) ); // TODO _predictColor
struct PS_IN
{
float4 position : VPOS;
float4 position : SV_Position;
float2 texcoord0 : TEXCOORD0_centroid;
float4 texcoord1 : TEXCOORD1_centroid;
float4 texcoord2 : TEXCOORD2_centroid;

View file

@ -48,11 +48,11 @@ struct VS_IN
struct VS_OUT
{
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
float4 texcoord3 : TEXCOORD3;
float4 position : SV_Position;
float2 texcoord0 : TEXCOORD0_centroid;
float4 texcoord1 : TEXCOORD1_centroid;
float4 texcoord2 : TEXCOORD2_centroid;
float4 texcoord3 : TEXCOORD3_centroid;
};
// *INDENT-ON*
@ -60,9 +60,8 @@ void main( VS_IN vertex, out VS_OUT result )
{
result.position = vertex.position;
float2 texcoord = vertex.texcoord;
//float2 texcoord = float2( vertex.texcoord.s, 1.0 - vertex.texcoord.t );
// RB: flip Y for DX12 / Vulkan
float2 texcoord = float2( vertex.texcoord.x, 1.0 - vertex.texcoord.y );
result.texcoord0 = texcoord;
float4 offset[3];

View file

@ -36,16 +36,19 @@ If you have questions concerning this license or the applicable additional terms
#include "SMAA.inc.hlsl"
// *INDENT-OFF*
Texture2D t_CurrentColor : register( t0 VK_DESCRIPTOR_SET( 1 ) );
Texture2D t_SmaaBlend : register( t1 VK_DESCRIPTOR_SET( 1 ) );
//Texture2D t_Velocity : register( t2 VK_DESCRIPTOR_SET( 1 ) );
Texture2D t_CurrentColor : register( t0 VK_DESCRIPTOR_SET( 0 ) );
Texture2D t_SmaaBlend : register( t1 VK_DESCRIPTOR_SET( 0 ) );
SamplerState LinearSampler : register( s0 VK_DESCRIPTOR_SET( 2 ) );
SamplerState PointSampler : register( s1 VK_DESCRIPTOR_SET( 2 ) );
#if SMAA_REPROJECTION
Texture2D t_Velocity : register( t2 VK_DESCRIPTOR_SET( 0 ) );
#endif
SamplerState LinearSampler : register( s0 VK_DESCRIPTOR_SET( 1 ) );
SamplerState PointSampler : register( s1 VK_DESCRIPTOR_SET( 1 ) );
struct PS_IN
{
float4 position : VPOS;
float4 position : SV_Position;
float2 texcoord0 : TEXCOORD0_centroid;
float4 texcoord1 : TEXCOORD1_centroid;
};

View file

@ -48,9 +48,9 @@ struct VS_IN
struct VS_OUT
{
float4 position : POSITION;
float2 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 position : SV_Position;
float2 texcoord0 : TEXCOORD0_centroid;
float4 texcoord1 : TEXCOORD1_centroid;
};
// *INDENT-ON*
@ -58,10 +58,12 @@ void main( VS_IN vertex, out VS_OUT result )
{
result.position = vertex.position;
result.texcoord0 = vertex.texcoord;
// RB: flip Y for DX12 / Vulkan
float2 texcoord = float2( vertex.texcoord.x, 1.0 - vertex.texcoord.y );
result.texcoord0 = texcoord;
float4 offset;
SMAANeighborhoodBlendingVS( vertex.texcoord, offset );
SMAANeighborhoodBlendingVS( texcoord, offset );
result.texcoord1 = offset;
}

View file

@ -48,11 +48,34 @@ struct VS_OUT {
void main( VS_IN vertex, out VS_OUT result )
{
#if 0
result.position = vertex.position;
result.position.y = -result.position.y;
//result.position.x = vertex.position; //dot4( vertex.position, rpMVPmatrixX );
//result.position.y = dot4( vertex.position, rpMVPmatrixY );
//result.position.z = dot4( vertex.position, rpMVPmatrixZ );
//result.position.w = dot4( vertex.position, rpMVPmatrixW );
result.texcoord0 = vertex.texcoord;
#else
result.position.x = dot4( vertex.position, rpMVPmatrixX );
result.position.y = dot4( vertex.position, rpMVPmatrixY );
result.position.z = dot4( vertex.position, rpMVPmatrixZ );
result.position.w = dot4( vertex.position, rpMVPmatrixW );
// compute oldschool texgen or multiply by texture matrix
BRANCH if( rpTexGen0Enabled.x > 0.0 )
{
result.texcoord0.x = dot4( vertex.position, rpTexGen0S );
result.texcoord0.y = dot4( vertex.position, rpTexGen0T );
}
else
{
result.texcoord0.x = dot4( vertex.texcoord.xy, rpTextureMatrixS );
result.texcoord0.y = dot4( vertex.texcoord.xy, rpTextureMatrixT );
}
// RB: flip Y for DX12 / Vulkan
result.texcoord0.y = 1.0 - result.texcoord0.y;
#endif
}

View file

@ -604,4 +604,3 @@ float DitherArray8x8Anim( float2 pos, int frameIndexMod4 )
}
#define SMAA_RT_METRICS float4(1.0 / 1280.0, 1.0 / 720.0, 1280.0, 720.0)

View file

@ -77,7 +77,7 @@ void main( VS_IN vertex, out VS_OUT result )
// using the X axis to the Y axis to calculate R1. It is an approximation to closely match
// what the original game did
const float magicProjectionAdjust = 0.43f;
float x = dot4( vec, rpProjectionMatrixY ) * magicProjectionAdjust;
float x = vec.y * rpProjectionMatrixY.y * magicProjectionAdjust;
float w = dot4( vec, rpProjectionMatrixW );
// don't let the recip get near zero for polygons that cross the view plane

View file

@ -74,7 +74,7 @@ void main( VS_IN vertex, out VS_OUT result )
// using the X axis to the Y axis to calculate x. It is an approximation to closely match
// what the original game did
const float magicProjectionAdjust = 0.43f;
float x = dot4( vec, rpProjectionMatrixY ) * magicProjectionAdjust;
float x = vec.y * rpProjectionMatrixY.y * magicProjectionAdjust;
float w = dot4( vec, rpProjectionMatrixW );
// don't let the recip get near zero for polygons that cross the view plane

View file

@ -72,7 +72,7 @@ void main( VS_IN vertex, out VS_OUT result )
// using the X axis to the Y axis to calculate x. It is an approximation to closely match
// what the original game did
const float magicProjectionAdjust = 0.43f;
float x = dot4( vec, rpProjectionMatrixY ) * magicProjectionAdjust;
float x = vec.y * rpProjectionMatrixY.y * magicProjectionAdjust;
float w = dot4( vec, rpProjectionMatrixW );
// don't let the recip get near zero for polygons that cross the view plane

View file

@ -146,6 +146,12 @@ public:
void UpdateWindowSize( const glimpParms_t& params );
// RB: for OpenVR to submit native Vulkan images
virtual int GetGraphicsFamilyIndex() const
{
return -1;
}
protected:
friend class idRenderBackend;
friend class idImage;

View file

@ -1,7 +1,7 @@
/*
* Copyright (c) 2014-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (C) 2022 Stephen Pridham (id Tech 4x integration)
* Copyright (C) 2023 Stephen Saunders (id Tech 4x integration)
* Copyright (C) 2023-2024 Stephen Saunders (id Tech 4x integration)
* Copyright (C) 2023 Robert Beckebans (id Tech 4x integration)
*
* Permission is hereby granted, free of charge, to any person obtaining a
@ -118,6 +118,11 @@ public:
return nvrhi::GraphicsAPI::VULKAN;
}
int GetGraphicsFamilyIndex() const override
{
return m_GraphicsQueueFamily;
}
protected:
bool CreateDeviceAndSwapChain() override;
void DestroyDeviceAndSwapChain() override;

View file

@ -921,9 +921,6 @@ static bool GLW_CreateWindow( glimpParms_t parms )
return false;
}
// TODO
glConfig.stereoPixelFormatAvailable = false;
SetForegroundWindow( win32.hWnd );
SetFocus( win32.hWnd );
@ -1129,7 +1126,6 @@ bool GLimp_Init( glimpParms_t parms )
}
glConfig.isFullscreen = parms.fullScreen;
glConfig.isStereoPixelFormat = parms.stereo;
if( parms.fullScreen )
{
@ -1220,8 +1216,6 @@ bool GLimp_SetScreenParms( glimpParms_t parms )
glConfig.isFullscreen = parms.fullScreen;
glConfig.pixelAspect = 1.0f; // FIXME: some monitor modes may be distorted
glConfig.isStereoPixelFormat = parms.stereo;
// SRS - Get window's client area dimensions to set new render size
RECT rect;
if( !GetClientRect( win32.hWnd, &rect ) )