Fix viewsize issues

This commit is contained in:
Denis Pauk 2020-05-10 12:23:50 +03:00 committed by Yamagi
parent 2e5c5974d6
commit 912fca15d9
10 changed files with 64 additions and 56 deletions

View file

@ -517,6 +517,11 @@ M_Popup(void)
return;
}
if (!R_EndWorldRenderpass())
{
return;
}
width = lines = n = 0;
for (str = m_popup_string; *str; str++)
{

View file

@ -1882,9 +1882,10 @@ extern void RI_EndFrame(void);
RI_EndWorldRenderpass
=====================
*/
static void
static qboolean
RI_EndWorldRenderpass( void )
{
return true;
}
Q2_DLL_EXPORTED refexport_t

View file

@ -1827,9 +1827,10 @@ GL3_SetPalette(const unsigned char *palette)
GL3_EndWorldRenderpass
=====================
*/
static void
static qboolean
GL3_EndWorldRenderpass( void )
{
return true;
}
Q2_DLL_EXPORTED refexport_t

View file

@ -1793,9 +1793,10 @@ static int RE_PrepareForWindow(void)
RE_EndWorldRenderpass
=====================
*/
static void
static qboolean
RE_EndWorldRenderpass( void )
{
return true;
}
/*

View file

@ -224,7 +224,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_EndWorldRenderReady( void );
qboolean RE_EndWorldRenderpass( void );
struct image_s *R_RegisterSkin (char *name);

View file

@ -1958,7 +1958,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_EndWorldRenderReady())
if(!RE_EndWorldRenderpass())
// buffers is not initialized
return VK_NOT_READY;
}

View file

@ -57,10 +57,6 @@ void Draw_CharScaled (int x, int y, int num, float scale)
int row, col;
float frow, fcol, size;
if(!R_EndWorldRenderReady())
// buffers is not initialized
return;
num &= 255;
if ((num & 127) == 32)
@ -133,10 +129,6 @@ void Draw_StretchPic (int x, int y, int w, int h, char *name)
{
image_t *vk;
if(!R_EndWorldRenderReady())
// buffers is not initialized
return;
vk = Draw_FindPic(name);
if (!vk)
{
@ -161,10 +153,6 @@ void Draw_PicScaled (int x, int y, char *pic, float factor)
{
image_t *vk;
if(!R_EndWorldRenderReady())
// buffers is not initialized
return;
vk = Draw_FindPic(pic);
if (!vk)
{
@ -187,10 +175,6 @@ void Draw_TileClear (int x, int y, int w, int h, char *name)
{
image_t *image;
if(!R_EndWorldRenderReady())
// buffers is not initialized
return;
image = Draw_FindPic(name);
if (!image)
{
@ -221,10 +205,6 @@ void Draw_Fill (int x, int y, int w, int h, int c)
byte v[4];
} color;
if(!R_EndWorldRenderReady())
// buffers is not initialized
return;
if ((unsigned)c > 255)
ri.Sys_Error(ERR_FATAL, "%s: bad color", __func__);
@ -248,10 +228,6 @@ void Draw_FadeScreen (void)
{
float imgTransform[] = { 0.f, 0.f, vid.width, vid.height, 0.f, 0.f, 0.f, .8f };
if(!R_EndWorldRenderReady())
// buffers is not initialized
return;
QVk_DrawColorRect(imgTransform, sizeof(imgTransform), RP_UI);
}
@ -274,10 +250,6 @@ void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data
float hscale;
float t;
if(!R_EndWorldRenderReady())
// buffers is not initialized
return;
if (rows <= 256)
{
hscale = 1;

View file

@ -971,7 +971,7 @@ static void RE_RenderView (refdef_t *fd)
}
}
qboolean R_EndWorldRenderReady(void)
qboolean RE_EndWorldRenderpass(void)
{
// still some issues?
if (!vk_frameStarted)
@ -1010,7 +1010,7 @@ static void R_SetVulkan2D (const VkViewport* viewport, const VkRect2D* scissor)
{
// player configuration screen renders a model using the UI renderpass, so skip finishing RP_WORLD twice
if (!(r_newrefdef.rdflags & RDF_NOWORLDMODEL))
if(!R_EndWorldRenderReady())
if(!RE_EndWorldRenderpass())
// buffers is not initialized
return;
@ -1066,6 +1066,48 @@ R_SetLightLevel (void)
}
}
static void R_CleanuBorders(void)
{
float h_border, v_border;
float imgTransform[] = { .0f, .0f, .0f, .0f, .0f, .0f, .0f, 1.f };
if (vid.height == r_newrefdef.height && vid.width == r_newrefdef.width)
{
return;
}
h_border = (float)(vid.height - r_newrefdef.height) / vid.height / 2.0f;
v_border = (float)(vid.width - r_newrefdef.width) / vid.width / 2.0f;
// top
imgTransform[0] = 0.0f;
imgTransform[1] = 0.0f;
imgTransform[2] = 1.0f;
imgTransform[3] = h_border;
QVk_DrawColorRect(imgTransform, sizeof(imgTransform), RP_UI);
// bottom
imgTransform[0] = 0.0f;
imgTransform[1] = 1.0f - h_border;
imgTransform[2] = 1.0f;
imgTransform[3] = h_border;
QVk_DrawColorRect(imgTransform, sizeof(imgTransform), RP_UI);
// left
imgTransform[0] = 0.0f;
imgTransform[1] = h_border;
imgTransform[2] = v_border;
imgTransform[3] = 1.0f - (h_border * 2.0f);
QVk_DrawColorRect(imgTransform, sizeof(imgTransform), RP_UI);
// right
imgTransform[0] = 1.0f - v_border;
imgTransform[1] = h_border;
imgTransform[2] = v_border;
imgTransform[3] = 1.0f - (h_border * 2.0f);
QVk_DrawColorRect(imgTransform, sizeof(imgTransform), RP_UI);
}
/*
=====================
RE_RenderFrame
@ -1078,6 +1120,8 @@ RE_RenderFrame (refdef_t *fd)
RE_RenderView( fd );
R_SetLightLevel ();
R_SetVulkan2D (&vk_viewport, &vk_scissor);
R_CleanuBorders();
}
@ -1386,23 +1430,6 @@ 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

View file

@ -192,7 +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
qboolean (EXPORT *EndWorldRenderpass) (void); // finish world rendering, apply postprocess and switch to UI render pass
//void (EXPORT *AppActivate)( qboolean activate );
} refexport_t;
@ -267,7 +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);
qboolean R_EndWorldRenderpass(void);
void R_EndFrame(void);
#endif

View file

@ -687,13 +687,14 @@ R_BeginFrame(float camera_separation)
}
}
void
qboolean
R_EndWorldRenderpass(void)
{
if(ref_active)
{
re.EndWorldRenderpass();
return re.EndWorldRenderpass();
}
return false;
}
void