Add EndWorldRenderpass callback

This commit is contained in:
Denis Pauk 2020-02-23 10:52:58 +02:00 committed by Yamagi
parent 31afc11133
commit d3d433bd7f
11 changed files with 78 additions and 13 deletions

View file

@ -1536,6 +1536,7 @@ SCR_UpdateScreen(void)
/* loading plaque over black screen */
int w, h;
R_EndWorldRenderpass();
if(i == 0){
R_SetPalette(NULL);
}
@ -1560,6 +1561,7 @@ SCR_UpdateScreen(void)
cl.cinematicpalette_active = false;
}
R_EndWorldRenderpass();
M_Draw();
}
else if (cls.key_dest == key_console)
@ -1569,11 +1571,12 @@ SCR_UpdateScreen(void)
R_SetPalette(NULL);
cl.cinematicpalette_active = false;
}
R_EndWorldRenderpass();
SCR_DrawConsole();
}
else
{
R_EndWorldRenderpass();
SCR_DrawCinematic();
}
}

View file

@ -443,12 +443,14 @@ V_RenderView(float stereo_separation)
{
if (cls.state != ca_active)
{
R_EndWorldRenderpass();
return;
}
if (!cl.refresh_prepped)
{
return;
R_EndWorldRenderpass();
return; // still loading
}
if (cl_timedemo->value)

View file

@ -1877,6 +1877,16 @@ extern void RI_SetPalette(const unsigned char *palette);
extern qboolean RI_IsVSyncActive(void);
extern void RI_EndFrame(void);
/*
=====================
RI_EndWorldRenderpass
=====================
*/
static void
RI_EndWorldRenderpass( void )
{
}
Q2_DLL_EXPORTED refexport_t
GetRefAPI(refimport_t imp)
{
@ -1917,6 +1927,7 @@ GetRefAPI(refimport_t imp)
re.SetPalette = RI_SetPalette;
re.BeginFrame = RI_BeginFrame;
re.EndWorldRenderpass = RI_EndWorldRenderpass;
re.EndFrame = RI_EndFrame;
return re;

View file

@ -1822,6 +1822,16 @@ GL3_SetPalette(const unsigned char *palette)
glClearColor(1, 0, 0.5, 0.5);
}
/*
=====================
GL3_EndWorldRenderpass
=====================
*/
static void
GL3_EndWorldRenderpass( void )
{
}
Q2_DLL_EXPORTED refexport_t
GetRefAPI(refimport_t imp)
{
@ -1862,6 +1872,7 @@ GetRefAPI(refimport_t imp)
re.SetPalette = GL3_SetPalette;
re.BeginFrame = GL3_BeginFrame;
re.EndWorldRenderpass = GL3_EndWorldRenderpass;
re.EndFrame = GL3_EndFrame;
return re;

View file

@ -1789,6 +1789,16 @@ static int RE_PrepareForWindow(void)
return flags;
}
/*
=====================
RE_EndWorldRenderpass
=====================
*/
static void
RE_EndWorldRenderpass( void )
{
}
/*
===============
GetRefAPI
@ -1835,6 +1845,7 @@ GetRefAPI(refimport_t imp)
refexport.SetPalette = RE_SetPalette;
refexport.BeginFrame = RE_BeginFrame;
refexport.EndWorldRenderpass = RE_EndWorldRenderpass;
refexport.EndFrame = RE_EndFrame;
Swap_Init ();

View file

@ -222,7 +222,7 @@ void Draw_Fill (int x, int y, int w, int h, int c);
void Draw_FadeScreen (void);
void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data);
qboolean R_EndWorldRenderpass( void );
qboolean R_EndWorldRenderReady( void );
struct image_s *R_RegisterSkin (char *name);

View file

@ -1886,7 +1886,7 @@ VkResult QVk_EndFrame(qboolean force)
// this may happen if Sys_Error is issued mid-frame, so we need to properly advance the draw pipeline
if (force)
{
if(!R_EndWorldRenderpass())
if(!R_EndWorldRenderReady())
// buffers is not initialized
return VK_NOT_READY;
}

View file

@ -58,7 +58,7 @@ void Draw_CharScaled (int x, int y, int num, float scale)
int row, col;
float frow, fcol, size;
if(!R_EndWorldRenderpass())
if(!R_EndWorldRenderReady())
// buffers is not initialized
return;
@ -133,7 +133,7 @@ void Draw_StretchPic (int x, int y, int w, int h, char *pic)
{
image_t *vk;
if(!R_EndWorldRenderpass())
if(!R_EndWorldRenderReady())
// buffers is not initialized
return;
@ -161,7 +161,7 @@ void Draw_PicScaled (int x, int y, char *pic, float scale)
{
image_t *vk;
if(!R_EndWorldRenderpass())
if(!R_EndWorldRenderReady())
// buffers is not initialized
return;
@ -187,7 +187,7 @@ void Draw_TileClear (int x, int y, int w, int h, char *pic)
{
image_t *image;
if(!R_EndWorldRenderpass())
if(!R_EndWorldRenderReady())
// buffers is not initialized
return;
@ -221,7 +221,7 @@ void Draw_Fill (int x, int y, int w, int h, int c)
byte v[4];
} color;
if(!R_EndWorldRenderpass())
if(!R_EndWorldRenderReady())
// buffers is not initialized
return;
@ -248,7 +248,7 @@ void Draw_FadeScreen (void)
{
float imgTransform[] = { 0.f, 0.f, vid.width, vid.height, 0.f, 0.f, 0.f, .8f };
if(!R_EndWorldRenderpass())
if(!R_EndWorldRenderReady())
// buffers is not initialized
return;
@ -277,7 +277,7 @@ void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data
int row;
float t;
if(!R_EndWorldRenderpass())
if(!R_EndWorldRenderReady())
// buffers is not initialized
return;

View file

@ -931,7 +931,7 @@ static void RE_RenderView (refdef_t *fd)
}
}
qboolean R_EndWorldRenderpass(void)
qboolean R_EndWorldRenderReady(void)
{
// still some issues?
if (!vk_frameStarted)
@ -970,7 +970,7 @@ static void R_SetVulkan2D (void)
{
// player configuration screen renders a model using the UI renderpass, so skip finishing RP_WORLD twice
if (!(r_newrefdef.rdflags & RDF_NOWORLDMODEL))
if(!R_EndWorldRenderpass())
if(!R_EndWorldRenderReady())
// buffers is not initialized
return;
@ -1351,6 +1351,21 @@ RE_EndFrame( void )
world_rendered = false;
}
/*
=====================
RE_EndWorldRenderpass
=====================
*/
static void
RE_EndWorldRenderpass( void )
{
if (R_EndWorldRenderReady())
{
R_Printf(PRINT_ALL, "%s(): Buffers are not initilized.\n",
__func__);
}
}
/*
=============
RE_SetPalette
@ -1580,6 +1595,7 @@ GetRefAPI(refimport_t imp)
refexport.SetPalette = RE_SetPalette;
refexport.BeginFrame = RE_BeginFrame;
refexport.EndWorldRenderpass = RE_EndWorldRenderpass;
refexport.EndFrame = RE_EndFrame;
Swap_Init ();

View file

@ -192,6 +192,7 @@ typedef struct
void (EXPORT *SetPalette)( const unsigned char *palette); // NULL = game palette
void (EXPORT *BeginFrame)( float camera_separation );
void (EXPORT *EndFrame) (void);
void (EXPORT *EndWorldRenderpass) (void); // finish world rendering, apply postprocess and switch to UI render pass
//void (EXPORT *AppActivate)( qboolean activate );
} refexport_t;
@ -266,6 +267,7 @@ void Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data)
//void R_Shutdown(void);
void R_SetPalette(const unsigned char *palette);
void R_BeginFrame(float camera_separation);
void R_EndWorldRenderpass(void);
void R_EndFrame(void);
#endif

View file

@ -687,6 +687,15 @@ R_BeginFrame(float camera_separation)
}
}
void
R_EndWorldRenderpass(void)
{
if(ref_active)
{
re.EndWorldRenderpass();
}
}
void
R_EndFrame(void)
{