[renderer] Make the core of SCR_UpdateScreen dynamic

This is a bit of a hack to allow me to work on vulkan's screen update
"pipeline" without having to mess with the other renderers, since it
turns out they're (currently) fundamentally incompatible.
This commit is contained in:
Bill Currie 2023-01-19 00:09:41 +09:00
parent d2467f1424
commit 07d5749a4e
7 changed files with 63 additions and 45 deletions

View file

@ -87,6 +87,8 @@ typedef void (*capfunc_t) (struct tex_s *screencap, void *data);
typedef struct vid_render_funcs_s {
void (*init) (void);
void (*UpdateScreen) (struct transform_s camera, double realtime,
SCR_Func *scr_funcs);
void (*Draw_CharBuffer) (int x, int y, struct draw_charbuffer_s *buffer);
void (*Draw_SetScale) (int scale);
void (*Draw_Character) (int x, int y, unsigned ch);

View file

@ -39,6 +39,8 @@ typedef void (*SCR_Func)(void);
// scr_funcs is a null terminated array
void SCR_UpdateScreen (struct transform_s camera, double realtime,
SCR_Func *scr_funcs);
void SCR_UpdateScreen_legacy (struct transform_s camera, double realtime,
SCR_Func *scr_funcs);
void SCR_SetFOV (float fov);
// control whether the 3d viewport is user-controlled or always fullscreen
void SCR_SetFullscreen (qboolean fullscreen);

View file

@ -218,6 +218,56 @@ render_side (int side)
memcpy (r_refdef.camera_inverse, camera_inverse, sizeof (camera_inverse));
}
void
SCR_UpdateScreen_legacy (transform_t camera, double realtime,
SCR_Func *scr_funcs)
{
if (scr_fisheye && !fisheye_cube_map) {
fisheye_cube_map = r_funcs->create_cube_map (r_data->vid->height);
}
if (r_dowarp && !warp_buffer) {
warp_buffer = r_funcs->create_frame_buffer (r_data->vid->width,
r_data->vid->height);
}
r_funcs->begin_frame ();
if (r_dowarp) {
r_funcs->bind_framebuffer (warp_buffer);
}
if (scr_fisheye && fisheye_cube_map) {
int side = fisheye_cube_map->width;
vrect_t feye = { 0, 0, side, side };
r_funcs->set_viewport (&feye);
r_funcs->set_fov (1, 1); //FIXME shouldn't be every frame (2d stuff)
switch (scr_fviews) {
case 6: render_side (BOX_BEHIND);
case 5: render_side (BOX_BOTTOM);
case 4: render_side (BOX_TOP);
case 3: render_side (BOX_LEFT);
case 2: render_side (BOX_RIGHT);
default:render_side (BOX_FRONT);
}
r_funcs->bind_framebuffer (0);
r_funcs->set_viewport (&r_refdef.vrect);
r_funcs->post_process (fisheye_cube_map);
} else {
r_funcs->set_viewport (&r_refdef.vrect);
render_scene ();
if (r_dowarp) {
r_funcs->bind_framebuffer (0);
r_funcs->post_process (warp_buffer);
}
}
r_funcs->set_2d (0);
//view_draw (r_data->scr_view);
r_funcs->set_2d (1);
while (*scr_funcs) {
(*scr_funcs) ();
scr_funcs++;
}
r_funcs->end_frame ();
}
void
SCR_UpdateScreen (transform_t camera, double realtime, SCR_Func *scr_funcs)
{
@ -229,10 +279,6 @@ SCR_UpdateScreen (transform_t camera, double realtime, SCR_Func *scr_funcs)
r_time1 = Sys_DoubleTime ();
}
if (scr_fisheye && !fisheye_cube_map) {
fisheye_cube_map = r_funcs->create_cube_map (r_data->vid->height);
}
refdef_t *refdef = r_data->refdef;
if (Transform_Valid (camera)) {
Transform_GetWorldMatrix (camera, refdef->camera);
@ -272,52 +318,12 @@ SCR_UpdateScreen (transform_t camera, double realtime, SCR_Func *scr_funcs)
if (r_waterwarp) {
r_dowarp = scr_scene->viewleaf->contents <= CONTENTS_WATER;
}
if (r_dowarp && !warp_buffer) {
warp_buffer = r_funcs->create_frame_buffer (r_data->vid->width,
r_data->vid->height);
}
R_MarkLeaves (scr_scene->viewleaf, r_node_visframes, r_leaf_visframes,
r_face_visframes);
}
r_framecount++;
R_PushDlights (vec3_origin);
r_funcs->begin_frame ();
if (r_dowarp) {
r_funcs->bind_framebuffer (warp_buffer);
}
if (scr_fisheye && fisheye_cube_map) {
int side = fisheye_cube_map->width;
vrect_t feye = { 0, 0, side, side };
r_funcs->set_viewport (&feye);
r_funcs->set_fov (1, 1); //FIXME shouldn't be every frame (2d stuff)
switch (scr_fviews) {
case 6: render_side (BOX_BEHIND);
case 5: render_side (BOX_BOTTOM);
case 4: render_side (BOX_TOP);
case 3: render_side (BOX_LEFT);
case 2: render_side (BOX_RIGHT);
default:render_side (BOX_FRONT);
}
r_funcs->bind_framebuffer (0);
r_funcs->set_viewport (&r_refdef.vrect);
r_funcs->post_process (fisheye_cube_map);
} else {
r_funcs->set_viewport (&r_refdef.vrect);
render_scene ();
if (r_dowarp) {
r_funcs->bind_framebuffer (0);
r_funcs->post_process (warp_buffer);
}
}
r_funcs->set_2d (0);
//view_draw (r_data->scr_view);
r_funcs->set_2d (1);
while (*scr_funcs) {
(*scr_funcs) ();
scr_funcs++;
}
r_funcs->end_frame ();
r_funcs->UpdateScreen (camera, realtime, scr_funcs);
}
static void

View file

@ -501,6 +501,8 @@ gl_capture_screen (capfunc_t callback, void *data)
vid_render_funcs_t gl_vid_render_funcs = {
.init = gl_vid_render_init,
.UpdateScreen = SCR_UpdateScreen_legacy,
.Draw_CharBuffer = gl_Draw_CharBuffer,
.Draw_SetScale = gl_Draw_SetScale,
.Draw_Character = gl_Draw_Character,

View file

@ -445,6 +445,8 @@ glsl_capture_screen (capfunc_t callback, void *data)
vid_render_funcs_t glsl_vid_render_funcs = {
.init = glsl_vid_render_init,
.UpdateScreen = SCR_UpdateScreen_legacy,
.Draw_CharBuffer = glsl_Draw_CharBuffer,
.Draw_SetScale = glsl_Draw_SetScale,
.Draw_Character = glsl_Draw_Character,

View file

@ -459,6 +459,8 @@ sw_capture_screen (capfunc_t callback, void *data)
vid_render_funcs_t sw_vid_render_funcs = {
.init = sw_vid_render_init,
.UpdateScreen = SCR_UpdateScreen_legacy,
.Draw_CharBuffer = sw_Draw_CharBuffer,
.Draw_Character = Draw_Character,
.Draw_String = Draw_String,

View file

@ -774,6 +774,8 @@ vulkan_vid_render_shutdown (void)
vid_render_funcs_t vulkan_vid_render_funcs = {
.init = vulkan_vid_render_init,
.UpdateScreen = SCR_UpdateScreen_legacy,
.Draw_CharBuffer = vulkan_Draw_CharBuffer,
.Draw_SetScale = vulkan_Draw_SetScale,
.Draw_Character = vulkan_Draw_Character,