mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 06:34:10 +00:00
bakeEnv* and bakeLightGrids partially work
This commit is contained in:
parent
0c866655f8
commit
43b3375da7
14 changed files with 209 additions and 55 deletions
|
@ -368,6 +368,11 @@ public:
|
|||
return stats_backend.gpuShaderPassMicroSec;
|
||||
}
|
||||
|
||||
uint64 GetRendererGpuTAAMicroseconds() const
|
||||
{
|
||||
return stats_backend.gpuTemporalAntiAliasingMicroSec;
|
||||
}
|
||||
|
||||
uint64 GetRendererGpuPostProcessingMicroseconds() const
|
||||
{
|
||||
return stats_backend.gpuPostProcessingMicroSec;
|
||||
|
|
|
@ -209,6 +209,8 @@ void idConsoleLocal::DrawTextRightAlign( float x, float& y, const char* text, ..
|
|||
idConsoleLocal::DrawFPS
|
||||
==================
|
||||
*/
|
||||
extern bool R_UseTemporalAA();
|
||||
|
||||
#define FPS_FRAMES 6
|
||||
#define FPS_FRAMES_HISTORY 90
|
||||
float idConsoleLocal::DrawFPS( float y )
|
||||
|
@ -288,9 +290,10 @@ float idConsoleLocal::DrawFPS( float y )
|
|||
const uint64 rendererGPU_SSAOTime = commonLocal.GetRendererGpuSSAOMicroseconds();
|
||||
const uint64 rendererGPU_SSRTime = commonLocal.GetRendererGpuSSRMicroseconds();
|
||||
const uint64 rendererGPUAmbientPassTime = commonLocal.GetRendererGpuAmbientPassMicroseconds();
|
||||
const uint64 rendererGPUShadowAtlasPassTime = commonLocal.GetRendererGpuShadowAtlasPassMicroseconds();
|
||||
const uint64 rendererGPUShadowAtlasTime = commonLocal.GetRendererGpuShadowAtlasPassMicroseconds();
|
||||
const uint64 rendererGPUInteractionsTime = commonLocal.GetRendererGpuInteractionsMicroseconds();
|
||||
const uint64 rendererGPUShaderPassesTime = commonLocal.GetRendererGpuShaderPassMicroseconds();
|
||||
const uint64 rendererGPU_TAATime = commonLocal.GetRendererGpuTAAMicroseconds();
|
||||
const uint64 rendererGPUPostProcessingTime = commonLocal.GetRendererGpuPostProcessingMicroseconds();
|
||||
const int maxTime = int( 1000 / com_engineHz_latched ) * 1000;
|
||||
|
||||
|
@ -309,7 +312,7 @@ float idConsoleLocal::DrawFPS( float y )
|
|||
{
|
||||
// start smaller
|
||||
int32 statsWindowWidth = 320;
|
||||
int32 statsWindowHeight = 280;
|
||||
int32 statsWindowHeight = 295;
|
||||
|
||||
if( com_showFPS.GetInteger() > 2 )
|
||||
{
|
||||
|
@ -352,7 +355,17 @@ float idConsoleLocal::DrawFPS( float y )
|
|||
|
||||
extern idCVar r_antiAliasing;
|
||||
static const int aaNumValues = 5;
|
||||
|
||||
static const char* aaValues[aaNumValues] =
|
||||
{
|
||||
"None",
|
||||
"None",
|
||||
"SMAA 1X",
|
||||
"MSAA 2X",
|
||||
"MSAA 4X",
|
||||
};
|
||||
|
||||
static const char* taaValues[aaNumValues] =
|
||||
{
|
||||
"None",
|
||||
"TAA",
|
||||
|
@ -363,7 +376,15 @@ float idConsoleLocal::DrawFPS( float y )
|
|||
|
||||
compile_time_assert( aaNumValues == ( ANTI_ALIASING_MSAA_4X + 1 ) );
|
||||
|
||||
const char* aaMode = aaValues[ r_antiAliasing.GetInteger() ];
|
||||
const char* aaMode = NULL;
|
||||
if( R_UseTemporalAA() )
|
||||
{
|
||||
aaMode = taaValues[ r_antiAliasing.GetInteger() ];
|
||||
}
|
||||
else
|
||||
{
|
||||
aaMode = aaValues[ r_antiAliasing.GetInteger() ];
|
||||
}
|
||||
|
||||
idStr resolutionText;
|
||||
resolutionScale.GetConsoleText( resolutionText );
|
||||
|
@ -431,9 +452,10 @@ float idConsoleLocal::DrawFPS( float y )
|
|||
ImGui::TextColored( gameThreadGameTime > maxTime ? colorRed : colorWhite, "Game: %5llu us SSAO: %5llu us", gameThreadGameTime, rendererGPU_SSAOTime );
|
||||
ImGui::TextColored( gameThreadRenderTime > maxTime ? colorRed : colorWhite, "RF: %5llu us SSR: %5llu us", gameThreadRenderTime, rendererGPU_SSRTime );
|
||||
ImGui::TextColored( rendererBackEndTime > maxTime ? colorRed : colorWhite, "RB: %5llu us Ambient Pass: %5llu us", rendererBackEndTime, rendererGPUAmbientPassTime );
|
||||
ImGui::TextColored( rendererShadowsTime > maxTime ? colorRed : colorWhite, " Shadow Atlas: %5llu us", rendererGPUShadowAtlasPassTime );
|
||||
ImGui::TextColored( rendererGPUShadowAtlasTime > maxTime ? colorRed : colorWhite, " Shadow Atlas: %5llu us", rendererGPUShadowAtlasTime );
|
||||
ImGui::TextColored( rendererShadowsTime > maxTime ? colorRed : colorWhite, "Shadows: %5llu us Interactions: %5llu us", rendererShadowsTime, rendererGPUInteractionsTime );
|
||||
ImGui::TextColored( rendererGPUShaderPassesTime > maxTime ? colorRed : colorWhite, " Shader Pass: %5llu us", rendererGPUShaderPassesTime );
|
||||
ImGui::TextColored( rendererGPU_TAATime > maxTime ? colorRed : colorWhite, " TAA: %5llu us", rendererGPU_TAATime );
|
||||
ImGui::TextColored( rendererGPUPostProcessingTime > maxTime ? colorRed : colorWhite, " PostFX: %5llu us", rendererGPUPostProcessingTime );
|
||||
ImGui::TextColored( totalCPUTime > maxTime || rendererGPUTime > maxTime ? colorRed : colorWhite,
|
||||
"Total: %5llu us Total: %5llu us", totalCPUTime, rendererGPUTime );
|
||||
|
|
|
@ -35,6 +35,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
void CommandlineProgressBar::Start()
|
||||
{
|
||||
#if !defined( USE_NVRHI )
|
||||
// restore the original resolution, same as "vid_restart"
|
||||
glConfig.nativeScreenWidth = sysWidth;
|
||||
glConfig.nativeScreenHeight = sysHeight;
|
||||
|
@ -44,12 +45,17 @@ void CommandlineProgressBar::Start()
|
|||
common->Printf( "|----|----|----|----|----|----|----|----|----|----|\n" );
|
||||
|
||||
common->UpdateScreen( false );
|
||||
#else
|
||||
common->Printf( "0%% 10 20 30 40 50 60 70 80 90 100%%\n" );
|
||||
common->Printf( "|----|----|----|----|----|----|----|----|----|----|\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void CommandlineProgressBar::Increment( bool updateScreen )
|
||||
{
|
||||
if( ( count + 1 ) >= nextTicCount )
|
||||
{
|
||||
#if !defined( USE_NVRHI )
|
||||
if( updateScreen )
|
||||
{
|
||||
// restore the original resolution, same as "vid_restart"
|
||||
|
@ -60,6 +66,7 @@ void CommandlineProgressBar::Increment( bool updateScreen )
|
|||
// resize frame buffers (this triggers SwapBuffers)
|
||||
tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t ticsNeeded = ( size_t )( ( ( double )( count + 1 ) / expectedCount ) * 50.0 );
|
||||
|
||||
|
@ -79,6 +86,7 @@ void CommandlineProgressBar::Increment( bool updateScreen )
|
|||
common->Printf( "\n" );
|
||||
}
|
||||
|
||||
#if !defined( USE_NVRHI )
|
||||
if( updateScreen )
|
||||
{
|
||||
common->UpdateScreen( false );
|
||||
|
@ -86,6 +94,7 @@ void CommandlineProgressBar::Increment( bool updateScreen )
|
|||
// swap front / back buffers
|
||||
tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
count++;
|
||||
|
|
|
@ -98,6 +98,7 @@ void Framebuffer::Shutdown()
|
|||
void Framebuffer::ResizeFramebuffers()
|
||||
{
|
||||
tr.backend.ClearCaches();
|
||||
//framebuffers.DeleteContents( true );
|
||||
|
||||
uint32_t backBufferCount = deviceManager->GetBackBufferCount();
|
||||
globalFramebuffers.swapFramebuffers.Resize( backBufferCount );
|
||||
|
|
|
@ -933,10 +933,12 @@ 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 )
|
||||
{
|
||||
nvrhi::IFramebuffer* framebuffer = Framebuffer::GetActiveFramebuffer()->GetApiObject();
|
||||
|
||||
// TODO: Do something if there is no depth-stencil attachment.
|
||||
if( color )
|
||||
{
|
||||
nvrhi::utils::ClearColorAttachment( commandList, Framebuffer::GetActiveFramebuffer()->GetApiObject(), 0, nvrhi::Color( 0.f ) );
|
||||
nvrhi::utils::ClearColorAttachment( commandList, framebuffer, 0, nvrhi::Color( 0.f ) );
|
||||
}
|
||||
|
||||
if( clearHDR )
|
||||
|
@ -946,9 +948,11 @@ void idRenderBackend::GL_Clear( bool color, bool depth, bool stencil, byte stenc
|
|||
|
||||
if( depth || stencil )
|
||||
{
|
||||
nvrhi::ITexture* depthTexture = ( nvrhi::ITexture* )( globalImages->currentDepthImage->GetTextureID() );
|
||||
const nvrhi::FormatInfo& depthFormatInfo = nvrhi::getFormatInfo( depthTexture->getDesc().format );
|
||||
commandList->clearDepthStencilTexture( depthTexture, nvrhi::AllSubresources, depth, 1.f, depthFormatInfo.hasStencil, stencilValue );
|
||||
nvrhi::utils::ClearDepthStencilAttachment( commandList, framebuffer, 1.0f, stencilValue );
|
||||
|
||||
//nvrhi::ITexture* depthTexture = ( nvrhi::ITexture* )( globalImages->currentDepthImage->GetTextureID() );
|
||||
//const nvrhi::FormatInfo& depthFormatInfo = nvrhi::getFormatInfo( depthTexture->getDesc().format );
|
||||
//commandList->clearDepthStencilTexture( depthTexture, nvrhi::AllSubresources, depth, 1.f, depthFormatInfo.hasStencil, stencilValue );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1030,6 +1034,7 @@ void idRenderBackend::CheckCVars()
|
|||
#endif
|
||||
// SRS end
|
||||
|
||||
#if 0
|
||||
if( r_antiAliasing.IsModified() )
|
||||
{
|
||||
switch( r_antiAliasing.GetInteger() )
|
||||
|
@ -1060,6 +1065,7 @@ void idRenderBackend::CheckCVars()
|
|||
|
||||
r_antiAliasing.ClearModified();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
if( r_usePBR.IsModified() ||
|
||||
|
|
|
@ -5455,7 +5455,7 @@ void idRenderBackend::DrawMotionVectors()
|
|||
return;
|
||||
}
|
||||
|
||||
if( viewDef->renderView.rdflags & RDF_NOAMBIENT )
|
||||
if( viewDef->renderView.rdflags & ( RDF_NOAMBIENT | RDF_IRRADIANCE ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -5595,11 +5595,12 @@ void idRenderBackend::TemporalAAPass( const viewDef_t* _viewDef )
|
|||
return;
|
||||
}
|
||||
|
||||
if( viewDef->renderView.rdflags & RDF_NOAMBIENT )
|
||||
if( viewDef->renderView.rdflags & ( RDF_NOAMBIENT | RDF_IRRADIANCE ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
renderLog.OpenMainBlock( MRB_TAA );
|
||||
renderLog.OpenBlock( "Render_TemporalAA" );
|
||||
|
||||
TemporalAntiAliasingParameters params =
|
||||
|
@ -5613,6 +5614,7 @@ void idRenderBackend::TemporalAAPass( const viewDef_t* _viewDef )
|
|||
prevViewsValid = true;
|
||||
|
||||
renderLog.CloseBlock();
|
||||
renderLog.CloseMainBlock();
|
||||
}
|
||||
|
||||
idVec2 idRenderBackend::GetCurrentPixelOffset() const
|
||||
|
@ -6749,15 +6751,14 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
|
|||
// ensures that depth writes are enabled for the depth clear
|
||||
GL_State( GLS_DEFAULT | GLS_CULL_FRONTSIDED, true );
|
||||
|
||||
// Clear the depth buffer and clear the stencil to 128 for stencil shadows as well as gui masking
|
||||
GL_Clear( false, true, true, STENCIL_SHADOW_TEST_VALUE, 0.0f, 0.0f, 0.0f, 0.0f, false );
|
||||
|
||||
bool useHDR = r_useHDR.GetBool() && !_viewDef->is2Dgui;
|
||||
bool clearColor = false;
|
||||
if( useHDR )
|
||||
{
|
||||
if( _viewDef->renderView.rdflags & RDF_IRRADIANCE )
|
||||
{
|
||||
globalFramebuffers.envprobeFBO->Bind();
|
||||
clearColor = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -6777,6 +6778,9 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
|
|||
#endif
|
||||
}
|
||||
|
||||
// Clear the depth buffer and clear the stencil to 128 for stencil shadows as well as gui masking
|
||||
GL_Clear( clearColor, true, true, STENCIL_SHADOW_TEST_VALUE, 0.0f, 0.0f, 0.0f, 0.0f, false );
|
||||
|
||||
// RB end
|
||||
|
||||
//GL_CheckErrors();
|
||||
|
@ -7053,6 +7057,8 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
|
|||
#if defined( USE_NVRHI )
|
||||
//TODO(Stephen): Move somewhere else?
|
||||
// RB: this needs to be done after next post processing steps later on
|
||||
|
||||
if( !( _viewDef->renderView.rdflags & RDF_IRRADIANCE ) )
|
||||
{
|
||||
BlitParameters blitParms;
|
||||
blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID();
|
||||
|
|
|
@ -1320,6 +1320,16 @@ void R_ScreenShot_f( const idCmdArgs& args );
|
|||
/*
|
||||
====================================================================
|
||||
|
||||
NVRHI helpers
|
||||
|
||||
====================================================================
|
||||
*/
|
||||
bool R_ReadPixelsRGB8( nvrhi::IDevice* device, CommonRenderPasses* pPasses, nvrhi::ITexture* texture, nvrhi::ResourceStates textureState, const char* fullname );
|
||||
bool R_ReadPixelsRGB16F( nvrhi::IDevice* device, CommonRenderPasses* pPasses, nvrhi::ITexture* texture, nvrhi::ResourceStates textureState, void* pic, int picWidth, int picHeight );
|
||||
|
||||
/*
|
||||
====================================================================
|
||||
|
||||
IMPLEMENTATION SPECIFIC FUNCTIONS
|
||||
|
||||
====================================================================
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 2013-2020 Robert Beckebans
|
||||
Copyright (C) 2013-2022 Robert Beckebans
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
|
@ -52,10 +52,10 @@ const char* renderLogMainBlockLabels[] =
|
|||
ASSERT_ENUM_STRING( MRB_GPU_TIME, 0 ),
|
||||
ASSERT_ENUM_STRING( MRB_BEGIN_DRAWING_VIEW, 1 ),
|
||||
ASSERT_ENUM_STRING( MRB_FILL_DEPTH_BUFFER, 2 ),
|
||||
ASSERT_ENUM_STRING( MRB_FILL_GEOMETRY_BUFFER, 3 ), // RB
|
||||
ASSERT_ENUM_STRING( MRB_SSAO_PASS, 4 ), // RB
|
||||
ASSERT_ENUM_STRING( MRB_AMBIENT_PASS, 5 ), // RB
|
||||
ASSERT_ENUM_STRING( MRB_SHADOW_ATLAS_PASS, 6 ), // RB
|
||||
ASSERT_ENUM_STRING( MRB_FILL_GEOMETRY_BUFFER, 3 ),
|
||||
ASSERT_ENUM_STRING( MRB_SSAO_PASS, 4 ),
|
||||
ASSERT_ENUM_STRING( MRB_AMBIENT_PASS, 5 ),
|
||||
ASSERT_ENUM_STRING( MRB_SHADOW_ATLAS_PASS, 6 ),
|
||||
ASSERT_ENUM_STRING( MRB_DRAW_INTERACTIONS, 7 ),
|
||||
ASSERT_ENUM_STRING( MRB_DRAW_SHADER_PASSES, 8 ),
|
||||
ASSERT_ENUM_STRING( MRB_FOG_ALL_LIGHTS, 9 ),
|
||||
|
@ -63,9 +63,10 @@ const char* renderLogMainBlockLabels[] =
|
|||
ASSERT_ENUM_STRING( MRB_DRAW_SHADER_PASSES_POST, 11 ),
|
||||
ASSERT_ENUM_STRING( MRB_DRAW_DEBUG_TOOLS, 12 ),
|
||||
ASSERT_ENUM_STRING( MRB_CAPTURE_COLORBUFFER, 13 ),
|
||||
ASSERT_ENUM_STRING( MRB_POSTPROCESS, 14 ),
|
||||
ASSERT_ENUM_STRING( MRB_DRAW_GUI, 15 ),
|
||||
ASSERT_ENUM_STRING( MRB_TOTAL, 16 )
|
||||
ASSERT_ENUM_STRING( MRB_TAA, 14 ),
|
||||
ASSERT_ENUM_STRING( MRB_POSTPROCESS, 15 ),
|
||||
ASSERT_ENUM_STRING( MRB_DRAW_GUI, 16 ),
|
||||
ASSERT_ENUM_STRING( MRB_TOTAL, 17 )
|
||||
};
|
||||
|
||||
#if defined( USE_VULKAN )
|
||||
|
@ -500,6 +501,10 @@ void idRenderLog::FetchGPUTimers( backEndCounters_t& pc )
|
|||
{
|
||||
pc.gpuShaderPassMicroSec = time;
|
||||
}
|
||||
else if( i == MRB_TAA )
|
||||
{
|
||||
pc.gpuTemporalAntiAliasingMicroSec = time;
|
||||
}
|
||||
else if( i == MRB_POSTPROCESS )
|
||||
{
|
||||
pc.gpuPostProcessingMicroSec = time;
|
||||
|
|
|
@ -53,6 +53,7 @@ enum renderLogMainBlock_t
|
|||
MRB_DRAW_SHADER_PASSES_POST,
|
||||
MRB_DRAW_DEBUG_TOOLS,
|
||||
MRB_CAPTURE_COLORBUFFER,
|
||||
MRB_TAA,
|
||||
MRB_POSTPROCESS,
|
||||
MRB_DRAW_GUI,
|
||||
MRB_TOTAL,
|
||||
|
|
|
@ -676,7 +676,9 @@ void idRenderSystemLocal::SwapCommandBuffers_FinishRendering(
|
|||
|
||||
// keep capturing envprobes completely in the background
|
||||
// and only update the screen when we update the progress bar in the console
|
||||
#if !defined( USE_NVRHI )
|
||||
if( !takingEnvprobe )
|
||||
#endif
|
||||
{
|
||||
#if !IMGUI_BFGUI
|
||||
ImGuiHook::Render();
|
||||
|
|
|
@ -164,6 +164,7 @@ struct backEndCounters_t
|
|||
uint64 gpuShadowAtlasPassMicroSec;
|
||||
uint64 gpuInteractionsMicroSec;
|
||||
uint64 gpuShaderPassMicroSec;
|
||||
uint64 gpuTemporalAntiAliasingMicroSec;
|
||||
uint64 gpuPostProcessingMicroSec;
|
||||
uint64 gpuMicroSec;
|
||||
};
|
||||
|
|
|
@ -892,6 +892,98 @@ bool R_ReadPixelsRGB8( nvrhi::IDevice* device, CommonRenderPasses* pPasses, nvrh
|
|||
return true;
|
||||
}
|
||||
|
||||
bool R_ReadPixelsRGB16F( nvrhi::IDevice* device, CommonRenderPasses* pPasses, nvrhi::ITexture* texture, nvrhi::ResourceStates textureState, void* pic, int picWidth, int picHeight )
|
||||
{
|
||||
nvrhi::TextureDesc desc = texture->getDesc();
|
||||
nvrhi::TextureHandle tempTexture;
|
||||
nvrhi::FramebufferHandle tempFramebuffer;
|
||||
|
||||
if( desc.width != picWidth || desc.height != picHeight )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
nvrhi::CommandListHandle commandList = device->createCommandList();
|
||||
commandList->open();
|
||||
|
||||
if( textureState != nvrhi::ResourceStates::Unknown )
|
||||
{
|
||||
commandList->beginTrackingTextureState( texture, nvrhi::TextureSubresourceSet( 0, 1, 0, 1 ), textureState );
|
||||
}
|
||||
|
||||
switch( desc.format )
|
||||
{
|
||||
case nvrhi::Format::RGBA16_FLOAT:
|
||||
tempTexture = texture;
|
||||
break;
|
||||
default:
|
||||
desc.format = nvrhi::Format::RGBA16_FLOAT;
|
||||
desc.isRenderTarget = true;
|
||||
desc.initialState = nvrhi::ResourceStates::RenderTarget;
|
||||
desc.keepInitialState = true;
|
||||
|
||||
tempTexture = device->createTexture( desc );
|
||||
tempFramebuffer = device->createFramebuffer( nvrhi::FramebufferDesc().addColorAttachment( tempTexture ) );
|
||||
|
||||
pPasses->BlitTexture( commandList, tempFramebuffer, texture );
|
||||
}
|
||||
|
||||
nvrhi::StagingTextureHandle stagingTexture = device->createStagingTexture( desc, nvrhi::CpuAccessMode::Read );
|
||||
commandList->copyTexture( stagingTexture, nvrhi::TextureSlice(), tempTexture, nvrhi::TextureSlice() );
|
||||
|
||||
if( textureState != nvrhi::ResourceStates::Unknown )
|
||||
{
|
||||
commandList->setTextureState( texture, nvrhi::TextureSubresourceSet( 0, 1, 0, 1 ), textureState );
|
||||
commandList->commitBarriers();
|
||||
}
|
||||
|
||||
commandList->close();
|
||||
device->executeCommandList( commandList );
|
||||
|
||||
size_t rowPitch = 0;
|
||||
void* pData = device->mapStagingTexture( stagingTexture, nvrhi::TextureSlice(), nvrhi::CpuAccessMode::Read, &rowPitch );
|
||||
|
||||
if( !pData )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16_t* newData = nullptr;
|
||||
|
||||
if( rowPitch != desc.width * 8 )
|
||||
{
|
||||
newData = new uint16_t[desc.width * desc.height * 2];
|
||||
|
||||
for( uint32_t row = 0; row < desc.height; row++ )
|
||||
{
|
||||
memcpy( newData + row * desc.width, static_cast<char*>( pData ) + row * rowPitch, desc.width * sizeof( uint16_t ) * 4 );
|
||||
}
|
||||
|
||||
pData = newData;
|
||||
}
|
||||
|
||||
// copy from RGBA16F to RGB16F
|
||||
uint16_t* data = static_cast<uint16_t*>( pData );
|
||||
uint16_t* outData = static_cast<uint16_t*>( pic );
|
||||
|
||||
for( int i = 0; i < ( desc.width * desc.height ); i++ )
|
||||
{
|
||||
outData[ i * 3 + 0 ] = data[ i * 4 + 0 ];
|
||||
outData[ i * 3 + 1 ] = data[ i * 4 + 1 ];
|
||||
outData[ i * 3 + 2 ] = data[ i * 4 + 2 ];
|
||||
}
|
||||
|
||||
if( newData )
|
||||
{
|
||||
delete[] newData;
|
||||
newData = nullptr;
|
||||
}
|
||||
|
||||
device->unmapStagingTexture( stagingTexture );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
TakeScreenshot
|
||||
|
|
|
@ -939,7 +939,7 @@ CONSOLE_COMMAND( bakeEnvironmentProbes, "Bake environment probes", NULL )
|
|||
int sysWidth = renderSystem->GetWidth();
|
||||
int sysHeight = renderSystem->GetHeight();
|
||||
|
||||
bool useThreads = true;
|
||||
bool useThreads = false;
|
||||
|
||||
baseName = tr.primaryWorld->mapName;
|
||||
baseName.StripFileExtension();
|
||||
|
@ -1034,17 +1034,9 @@ CONSOLE_COMMAND( bakeEnvironmentProbes, "Bake environment probes", NULL )
|
|||
ref.vieworg = def->parms.origin;
|
||||
ref.viewaxis = tr.cubeAxis[j];
|
||||
|
||||
#if 0
|
||||
byte* float16FRGB = tr.CaptureRenderToBuffer( captureSize, captureSize, &ref );
|
||||
#else
|
||||
glConfig.nativeScreenWidth = captureSize;
|
||||
glConfig.nativeScreenHeight = captureSize;
|
||||
|
||||
int pix = captureSize * captureSize;
|
||||
const int bufferSize = pix * 3 * 2;
|
||||
|
||||
byte* float16FRGB = ( byte* )R_StaticAlloc( bufferSize );
|
||||
|
||||
// discard anything currently on the list
|
||||
tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
|
||||
|
||||
|
@ -1060,13 +1052,21 @@ CONSOLE_COMMAND( bakeEnvironmentProbes, "Bake environment probes", NULL )
|
|||
// discard anything currently on the list (this triggers SwapBuffers)
|
||||
tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
|
||||
|
||||
#if defined(USE_VULKAN)
|
||||
int pix = captureSize * captureSize;
|
||||
const int bufferSize = pix * 3 * 2;
|
||||
|
||||
byte* floatRGB16F = ( byte* )R_StaticAlloc( bufferSize );
|
||||
|
||||
#if defined( USE_VULKAN )
|
||||
// TODO
|
||||
#elif defined( USE_NVRHI )
|
||||
R_ReadPixelsRGB16F( deviceManager->GetDevice(), &tr.backend.GetCommonPasses(), globalImages->envprobeHDRImage->GetTextureHandle() , nvrhi::ResourceStates::RenderTarget, floatRGB16F, captureSize, captureSize );
|
||||
|
||||
#elif defined(USE_NVRHI)
|
||||
|
||||
// TODO
|
||||
#if 0
|
||||
idStr testName;
|
||||
testName.Format( "env/test/envprobe_%i_side_%i.exr", i, j );
|
||||
R_WriteEXR( testName, floatRGB16F, 3, captureSize, captureSize, "fs_basepath" );
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
|
@ -1083,9 +1083,7 @@ CONSOLE_COMMAND( bakeEnvironmentProbes, "Bake environment probes", NULL )
|
|||
|
||||
Framebuffer::Unbind();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
buffers[ j ] = float16FRGB;
|
||||
buffers[ j ] = floatRGB16F;
|
||||
}
|
||||
|
||||
tr.takingEnvprobe = false;
|
||||
|
|
|
@ -1048,7 +1048,6 @@ CONSOLE_COMMAND( bakeLightGrids, "Bake irradiance/vis light grid data", NULL )
|
|||
idStr baseName;
|
||||
idStr filename;
|
||||
renderView_t ref;
|
||||
int blends;
|
||||
int captureSize;
|
||||
|
||||
int limit = MAX_AREA_LIGHTGRID_POINTS;
|
||||
|
@ -1133,7 +1132,6 @@ CONSOLE_COMMAND( bakeLightGrids, "Bake irradiance/vis light grid data", NULL )
|
|||
baseName.StripFileExtension();
|
||||
|
||||
captureSize = ENVPROBE_CAPTURE_SIZE;
|
||||
blends = 1;
|
||||
|
||||
idLib::Printf( "Using limit = %i\n", limit );
|
||||
idLib::Printf( "Using bounces = %i\n", bounces );
|
||||
|
@ -1265,17 +1263,9 @@ CONSOLE_COMMAND( bakeLightGrids, "Bake irradiance/vis light grid data", NULL )
|
|||
ref.vieworg = gridPoint->origin;
|
||||
ref.viewaxis = tr.cubeAxis[ side ];
|
||||
|
||||
#if 0
|
||||
byte* float16FRGB = tr.CaptureRenderToBuffer( captureSize, captureSize, &ref );
|
||||
#else
|
||||
glConfig.nativeScreenWidth = captureSize;
|
||||
glConfig.nativeScreenHeight = captureSize;
|
||||
|
||||
int pix = captureSize * captureSize;
|
||||
const int bufferSize = pix * 3 * 2;
|
||||
|
||||
byte* float16FRGB = ( byte* )R_StaticAlloc( bufferSize );
|
||||
|
||||
// discard anything currently on the list
|
||||
tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
|
||||
|
||||
|
@ -1291,14 +1281,23 @@ CONSOLE_COMMAND( bakeLightGrids, "Bake irradiance/vis light grid data", NULL )
|
|||
// discard anything currently on the list (this triggers SwapBuffers)
|
||||
tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
|
||||
|
||||
#if defined(USE_VULKAN)
|
||||
int pix = captureSize * captureSize;
|
||||
const int bufferSize = pix * 3 * 2;
|
||||
|
||||
byte* floatRGB16F = ( byte* )R_StaticAlloc( bufferSize );
|
||||
|
||||
#if defined( USE_VULKAN )
|
||||
// TODO
|
||||
#elif defined(USE_NVRHI)
|
||||
// TODO
|
||||
#elif defined( USE_NVRHI )
|
||||
R_ReadPixelsRGB16F( deviceManager->GetDevice(), &tr.backend.GetCommonPasses(), globalImages->envprobeHDRImage->GetTextureHandle() , nvrhi::ResourceStates::RenderTarget, floatRGB16F, captureSize, captureSize );
|
||||
|
||||
#if 0
|
||||
idStr testName;
|
||||
testName.Format( "env/test/area%i_envprobe_%i_side_%i.exr", a, tr.lightGridJobs.Num(), side );
|
||||
R_WriteEXR( testName, floatRGB16F, 3, captureSize, captureSize, "fs_basepath" );
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
glFinish();
|
||||
|
||||
glReadBuffer( GL_BACK );
|
||||
|
@ -1312,10 +1311,7 @@ CONSOLE_COMMAND( bakeLightGrids, "Bake irradiance/vis light grid data", NULL )
|
|||
|
||||
Framebuffer::Unbind();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
jobParms->radiance[ side ] = float16FRGB;
|
||||
jobParms->radiance[ side ] = floatRGB16F;
|
||||
}
|
||||
|
||||
tr.lightGridJobs.Append( jobParms );
|
||||
|
|
Loading…
Reference in a new issue