Fixed black screen after reloadImages #621

This commit is contained in:
Robert Beckebans 2022-03-06 10:10:18 +01:00
parent ec4e7b8c68
commit 219033e26a
8 changed files with 29 additions and 21 deletions

View file

@ -68,10 +68,9 @@ public:
void AddDepthBuffer( int format, int multiSamples = 0 );
void AddStencilBuffer( int format, int multiSamples = 0 );
void AttachImage2D( int target, const idImage* image, int index, int mipmapLod = 0 );
void AttachImage3D( const idImage* image );
void AttachImageDepth( int target, const idImage* image );
void AttachImageDepthLayer( const idImage* image, int layer );
void AttachImage2D( int target, idImage* image, int index, int mipmapLod = 0 );
void AttachImageDepth( int target, idImage* image );
void AttachImageDepthLayer( idImage* image, int layer );
// check for OpenGL errors
void Check();

View file

@ -180,6 +180,7 @@ void idGuiModel::EmitSurfaces( float modelMatrix[16], float modelViewMatrix[16],
drawSurf->shaderRegisters = regs;
shader->EvaluateRegisters( regs, shaderParms, tr.viewDef->renderView.shaderParms, tr.viewDef->renderView.time[1] * 0.001f, NULL );
}
R_LinkDrawSurfToView( drawSurf, tr.viewDef );
if( allowFullScreenStereoDepth )
{

View file

@ -938,18 +938,11 @@ static void R_CreateImGuiFontImage( idImage* image )
int width, height;
io.Fonts->GetTexDataAsRGBA32( &pixels, &width, &height ); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
/*
glGenTextures( 1, &g_FontTexture );
glBindTexture( GL_TEXTURE_2D, g_FontTexture );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels );
*/
image->GenerateImage( ( byte* )pixels, width, height, TF_LINEAR, TR_CLAMP, TD_LOOKUP_TABLE_RGBA );
// Store our identifier
io.Fonts->TexID = ( void* )( intptr_t )image->GetImGuiTextureID();
//io.Fonts->TexID = ( void* )( intptr_t )image->GetImGuiTextureID();
io.Fonts->TexID = ( void* )( intptr_t )declManager->FindMaterial( "_imguiFont" );
// Cleanup (don't clear the input data if you want to append new fonts later)
//io.Fonts->ClearInputData();

View file

@ -753,11 +753,20 @@ idImage::Reload
*/
void idImage::Reload( bool force )
{
// don't break render targets that have this image attached
if( opts.isRenderTarget )
{
return;
}
// always regenerate functional images
if( generatorFunction )
{
common->DPrintf( "regenerating %s.\n", GetName() );
generatorFunction( this );
if( force )
{
common->DPrintf( "regenerating %s.\n", GetName() );
generatorFunction( this );
}
return;
}

View file

@ -492,7 +492,7 @@ void Framebuffer::AddStencilBuffer( int format, int multiSamples )
GL_CheckErrors();
}
void Framebuffer::AttachImage2D( int target, const idImage* image, int index, int mipmapLod )
void Framebuffer::AttachImage2D( int target, idImage* image, int index, int mipmapLod )
{
if( ( target != GL_TEXTURE_2D ) && ( target != GL_TEXTURE_2D_MULTISAMPLE ) && ( target < GL_TEXTURE_CUBE_MAP_POSITIVE_X || target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z ) )
{
@ -507,9 +507,11 @@ void Framebuffer::AttachImage2D( int target, const idImage* image, int index, in
}
glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + index, target, image->texnum, mipmapLod );
image->opts.isRenderTarget = true;
}
void Framebuffer::AttachImageDepth( int target, const idImage* image )
void Framebuffer::AttachImageDepth( int target, idImage* image )
{
if( ( target != GL_TEXTURE_2D ) && ( target != GL_TEXTURE_2D_MULTISAMPLE ) )
{
@ -518,11 +520,15 @@ void Framebuffer::AttachImageDepth( int target, const idImage* image )
}
glFramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, target, image->texnum, 0 );
image->opts.isRenderTarget = true;
}
void Framebuffer::AttachImageDepthLayer( const idImage* image, int layer )
void Framebuffer::AttachImageDepthLayer( idImage* image, int layer )
{
glFramebufferTextureLayer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, image->texnum, 0, layer );
image->opts.isRenderTarget = true;
}
void Framebuffer::Check()

View file

@ -48,6 +48,8 @@ If you have questions concerning this license or the applicable additional terms
#include "../RenderBackend.h"
#include "../../framework/Common_local.h"
#include "../../imgui/imgui.h"
idCVar r_drawFlickerBox( "r_drawFlickerBox", "0", CVAR_RENDERER | CVAR_BOOL, "visual test for dropping frames" );
idCVar stereoRender_warp( "stereoRender_warp", "0", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "use the optical warping renderprog instead of stereoDeGhost" );
idCVar stereoRender_warpStrength( "stereoRender_warpStrength", "1.45", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_FLOAT, "amount of pre-distortion" );
@ -2374,13 +2376,11 @@ void idRenderBackend::ImGui_Shutdown()
void idRenderBackend::ImGui_RenderDrawLists( ImDrawData* draw_data )
{
/*
if( draw_data->CmdListsCount == 0 )
{
// Nothing to do.
return;
}
*/
#if IMGUI_BFGUI

View file

@ -889,6 +889,7 @@ void idRenderBackend::FillDepthBufferGeneric( const drawSurf_t* const* drawSurfs
break;
}
}
if( stage == shader->GetNumStages() )
{
continue;

View file

@ -623,7 +623,6 @@ const emptyCommand_t* idRenderSystemLocal::SwapCommandBuffers(
performanceCounters_t* pc
)
{
SwapCommandBuffers_FinishRendering( frontEndMicroSec, backEndMicroSec, shadowMicroSec, gpuMicroSec, bc, pc );
return SwapCommandBuffers_FinishCommandBuffers();