Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Quake/common.make
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,7 @@ SHADER_OBJS = \
md5_vert.o \
basic_alphatest_frag.o \
screen_effects_8bit_comp.o \
screen_effects_8bit_scale_comp.o \
screen_effects_8bit_scale_sops_comp.o \
screen_effects_10bit_comp.o \
screen_effects_10bit_scale_comp.o \
screen_effects_10bit_scale_sops_comp.o \
cs_tex_warp_comp.o \
indirect_comp.o \
indirect_clear_comp.o \
Expand Down
1 change: 1 addition & 0 deletions Quake/draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ qpic_t *Draw_TryCachePic (const char *path, unsigned int texflags);
void Draw_NewGame (void);

void GL_Viewport (cb_context_t *cbx, float x, float y, float width, float height, float min_depth, float max_depth);
void GL_Viewport_Scale (cb_context_t *cbx, float x, float y, float width, float height, float min_depth, float max_depth, int scale);
void GL_SetCanvas (cb_context_t *cbx, canvastype newcanvas); // johnfitz

#endif /* _QUAKE_DRAW_H */
19 changes: 15 additions & 4 deletions Quake/gl_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -952,12 +952,23 @@ GL_Viewport
================
*/
void GL_Viewport (cb_context_t *cbx, float x, float y, float width, float height, float min_depth, float max_depth)
{
GL_Viewport_Scale (cbx, x, y, width, height, min_depth, max_depth, 1);
}

/*
================
GL_Viewport_Scale
================
*/
void GL_Viewport_Scale (cb_context_t *cbx, float x, float y, float width, float height, float min_depth, float max_depth, int scale)
{
VkViewport viewport;
viewport.x = x;
viewport.y = vid.height - (y + height);
viewport.width = width;
viewport.height = height;
// when using scale, always put the viewport flush against the corner (even when viewsize < 100) for simplicity
viewport.x = scale == 1 ? x : 0;
viewport.y = scale == 1 ? vid.height - (y + height) : 0;
viewport.width = (width + scale - 1) / scale;
viewport.height = (height + scale - 1) / scale;
viewport.minDepth = min_depth;
viewport.maxDepth = max_depth;

Expand Down
12 changes: 7 additions & 5 deletions Quake/gl_rmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int r_framecount; // used for dlight push checking
mplane_t frustum[4];

qboolean render_warp;
int render_scale;
int render_scale = 1; // when > 1, adjust the viewport size and upsacale after screen effects

// johnfitz -- rendering statistics
atomic_uint32_t rs_brushpolys, rs_aliaspolys, rs_skypolys, rs_particles, rs_fogpolys;
Expand Down Expand Up @@ -352,7 +352,8 @@ R_SetupContext
*/
static void R_SetupContext (cb_context_t *cbx)
{
GL_Viewport (cbx, r_refdef.vrect.x, glheight - r_refdef.vrect.y - r_refdef.vrect.height, r_refdef.vrect.width, r_refdef.vrect.height, 0.0f, 1.0f);
GL_Viewport_Scale (
cbx, r_refdef.vrect.x, glheight - r_refdef.vrect.y - r_refdef.vrect.height, r_refdef.vrect.width, r_refdef.vrect.height, 0.0f, 1.0f, render_scale);
R_BindPipeline (cbx, VK_PIPELINE_BIND_POINT_GRAPHICS, vulkan_globals.basic_blend_pipeline[cbx->render_pass_index]);
R_PushConstants (cbx, VK_SHADER_STAGE_ALL_GRAPHICS, 0, 16 * sizeof (float), vulkan_globals.view_projection_matrix);
}
Expand Down Expand Up @@ -384,7 +385,6 @@ static void R_SetupViewBeforeMark (void *unused)
r_fovx = r_refdef.fov_x;
r_fovy = r_refdef.fov_y;
render_warp = false;
render_scale = (int)r_scale.value;

if (r_waterwarp.value)
{
Expand Down Expand Up @@ -554,14 +554,16 @@ void R_DrawViewModel (cb_context_t *cbx)
R_BeginDebugUtilsLabel (cbx, "View Model");

// hack the depth range to prevent view model from poking into walls
GL_Viewport (cbx, r_refdef.vrect.x, glheight - r_refdef.vrect.y - r_refdef.vrect.height, r_refdef.vrect.width, r_refdef.vrect.height, 0.7f, 1.0f);
GL_Viewport_Scale (
cbx, r_refdef.vrect.x, glheight - r_refdef.vrect.y - r_refdef.vrect.height, r_refdef.vrect.width, r_refdef.vrect.height, 0.7f, 1.0f, render_scale);

int aliaspolys = 0;
R_DrawAliasModel (cbx, currententity, &aliaspolys);
Atomic_AddUInt32 (&rs_aliaspolys, aliaspolys);
Atomic_IncrementUInt32 (&rs_aliaspasses);

GL_Viewport (cbx, r_refdef.vrect.x, glheight - r_refdef.vrect.y - r_refdef.vrect.height, r_refdef.vrect.width, r_refdef.vrect.height, 0.0f, 1.0f);
GL_Viewport_Scale (
cbx, r_refdef.vrect.x, glheight - r_refdef.vrect.y - r_refdef.vrect.height, r_refdef.vrect.width, r_refdef.vrect.height, 0.0f, 1.0f, render_scale);

R_EndDebugUtilsLabel (cbx);
}
Expand Down
61 changes: 1 addition & 60 deletions Quake/gl_rmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ extern cvar_t r_rtshadows;
extern cvar_t r_indirect;
extern cvar_t r_tasks;
extern cvar_t r_parallelmark;
extern cvar_t r_usesops;

#if defined(USE_SIMD)
extern cvar_t r_simd;
Expand Down Expand Up @@ -1701,7 +1700,7 @@ void R_CreatePipelineLayouts ()

ZEROED_STRUCT (VkPushConstantRange, push_constant_range);
push_constant_range.offset = 0;
push_constant_range.size = 3 * sizeof (uint32_t) + 8 * sizeof (float);
push_constant_range.size = 3 * sizeof (uint32_t) + 10 * sizeof (float);
push_constant_range.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;

ZEROED_STRUCT (VkPipelineLayoutCreateInfo, pipeline_layout_create_info);
Expand All @@ -1716,10 +1715,6 @@ void R_CreatePipelineLayouts ()
Sys_Error ("vkCreatePipelineLayout failed");
GL_SetObjectName ((uint64_t)vulkan_globals.screen_effects_pipeline.layout.handle, VK_OBJECT_TYPE_PIPELINE_LAYOUT, "screen_effects_pipeline_layout");
vulkan_globals.screen_effects_pipeline.layout.push_constant_range = push_constant_range;
vulkan_globals.screen_effects_scale_pipeline.layout.handle = vulkan_globals.screen_effects_pipeline.layout.handle;
vulkan_globals.screen_effects_scale_pipeline.layout.push_constant_range = push_constant_range;
vulkan_globals.screen_effects_scale_sops_pipeline.layout.handle = vulkan_globals.screen_effects_pipeline.layout.handle;
vulkan_globals.screen_effects_scale_sops_pipeline.layout.push_constant_range = push_constant_range;
}

{
Expand Down Expand Up @@ -1970,13 +1965,6 @@ void R_InitSamplers ()
break;
}
}

if (r_scale.value >= 8)
lod_bias += 3.0f;
else if (r_scale.value >= 4)
lod_bias += 2.0f;
else if (r_scale.value >= 2)
lod_bias += 1.0f;
}

lod_bias += gl_lodbias.value;
Expand Down Expand Up @@ -2120,11 +2108,7 @@ DECLARE_SHADER_MODULE (sky_cube_frag);
DECLARE_SHADER_MODULE (postprocess_vert);
DECLARE_SHADER_MODULE (postprocess_frag);
DECLARE_SHADER_MODULE (screen_effects_8bit_comp);
DECLARE_SHADER_MODULE (screen_effects_8bit_scale_comp);
DECLARE_SHADER_MODULE (screen_effects_8bit_scale_sops_comp);
DECLARE_SHADER_MODULE (screen_effects_10bit_comp);
DECLARE_SHADER_MODULE (screen_effects_10bit_scale_comp);
DECLARE_SHADER_MODULE (screen_effects_10bit_scale_sops_comp);
DECLARE_SHADER_MODULE (cs_tex_warp_comp);
DECLARE_SHADER_MODULE (indirect_comp);
DECLARE_SHADER_MODULE (indirect_clear_comp);
Expand Down Expand Up @@ -3202,32 +3186,6 @@ static void R_CreateScreenEffectsPipelines ()
if (err != VK_SUCCESS)
Sys_Error ("vkCreateComputePipelines failed (screen_effects_pipeline)");
GL_SetObjectName ((uint64_t)vulkan_globals.screen_effects_pipeline.handle, VK_OBJECT_TYPE_PIPELINE, "screen_effects");

compute_shader_stage.module =
(vulkan_globals.color_format == VK_FORMAT_A2B10G10R10_UNORM_PACK32) ? screen_effects_10bit_scale_comp_module : screen_effects_8bit_scale_comp_module;
infos.compute_pipeline.stage = compute_shader_stage;
assert (vulkan_globals.screen_effects_scale_pipeline.handle == VK_NULL_HANDLE);
err = vkCreateComputePipelines (
vulkan_globals.device, VK_NULL_HANDLE, 1, &infos.compute_pipeline, NULL, &vulkan_globals.screen_effects_scale_pipeline.handle);
if (err != VK_SUCCESS)
Sys_Error ("vkCreateComputePipelines failed (screen_effects_scale_pipeline)");
GL_SetObjectName ((uint64_t)vulkan_globals.screen_effects_scale_pipeline.handle, VK_OBJECT_TYPE_PIPELINE, "screen_effects_scale");

if (vulkan_globals.screen_effects_sops)
{
compute_shader_stage.module = (vulkan_globals.color_format == VK_FORMAT_A2B10G10R10_UNORM_PACK32) ? screen_effects_10bit_scale_sops_comp_module
: screen_effects_8bit_scale_sops_comp_module;
compute_shader_stage.flags =
VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT | VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT_EXT;
infos.compute_pipeline.stage = compute_shader_stage;
assert (vulkan_globals.screen_effects_scale_sops_pipeline.handle == VK_NULL_HANDLE);
err = vkCreateComputePipelines (
vulkan_globals.device, VK_NULL_HANDLE, 1, &infos.compute_pipeline, NULL, &vulkan_globals.screen_effects_scale_sops_pipeline.handle);
if (err != VK_SUCCESS)
Sys_Error ("vkCreateComputePipelines failed (screen_effects_scale_sops_pipeline)");
GL_SetObjectName ((uint64_t)vulkan_globals.screen_effects_scale_sops_pipeline.handle, VK_OBJECT_TYPE_PIPELINE, "screen_effects_scale_sops");
compute_shader_stage.flags = 0;
}
}

/*
Expand Down Expand Up @@ -3347,11 +3305,7 @@ static void R_CreateShaderModules ()
CREATE_SHADER_MODULE (postprocess_vert);
CREATE_SHADER_MODULE (postprocess_frag);
CREATE_SHADER_MODULE (screen_effects_8bit_comp);
CREATE_SHADER_MODULE (screen_effects_8bit_scale_comp);
CREATE_SHADER_MODULE_COND (screen_effects_8bit_scale_sops_comp, vulkan_globals.screen_effects_sops);
CREATE_SHADER_MODULE (screen_effects_10bit_comp);
CREATE_SHADER_MODULE (screen_effects_10bit_scale_comp);
CREATE_SHADER_MODULE_COND (screen_effects_10bit_scale_sops_comp, vulkan_globals.screen_effects_sops);
CREATE_SHADER_MODULE (cs_tex_warp_comp);
CREATE_SHADER_MODULE (indirect_comp);
CREATE_SHADER_MODULE (indirect_clear_comp);
Expand Down Expand Up @@ -3389,11 +3343,7 @@ static void R_DestroyShaderModules ()
DESTROY_SHADER_MODULE (postprocess_vert);
DESTROY_SHADER_MODULE (postprocess_frag);
DESTROY_SHADER_MODULE (screen_effects_8bit_comp);
DESTROY_SHADER_MODULE (screen_effects_8bit_scale_comp);
DESTROY_SHADER_MODULE (screen_effects_8bit_scale_sops_comp);
DESTROY_SHADER_MODULE (screen_effects_10bit_comp);
DESTROY_SHADER_MODULE (screen_effects_10bit_scale_comp);
DESTROY_SHADER_MODULE (screen_effects_10bit_scale_sops_comp);
DESTROY_SHADER_MODULE (cs_tex_warp_comp);
DESTROY_SHADER_MODULE (indirect_comp);
DESTROY_SHADER_MODULE (indirect_clear_comp);
Expand Down Expand Up @@ -3506,13 +3456,6 @@ void R_DestroyPipelines (void)
vulkan_globals.postprocess_pipeline.handle = VK_NULL_HANDLE;
vkDestroyPipeline (vulkan_globals.device, vulkan_globals.screen_effects_pipeline.handle, NULL);
vulkan_globals.screen_effects_pipeline.handle = VK_NULL_HANDLE;
vkDestroyPipeline (vulkan_globals.device, vulkan_globals.screen_effects_scale_pipeline.handle, NULL);
vulkan_globals.screen_effects_scale_pipeline.handle = VK_NULL_HANDLE;
if (vulkan_globals.screen_effects_scale_sops_pipeline.handle != VK_NULL_HANDLE)
{
vkDestroyPipeline (vulkan_globals.device, vulkan_globals.screen_effects_scale_sops_pipeline.handle, NULL);
vulkan_globals.screen_effects_scale_sops_pipeline.handle = VK_NULL_HANDLE;
}
vkDestroyPipeline (vulkan_globals.device, vulkan_globals.cs_tex_warp_pipeline.handle, NULL);
vulkan_globals.cs_tex_warp_pipeline.handle = VK_NULL_HANDLE;
if (vulkan_globals.showtris_pipeline.handle != VK_NULL_HANDLE)
Expand Down Expand Up @@ -3619,7 +3562,6 @@ void R_Init (void)
Cvar_RegisterVariable (&r_scale);
Cvar_RegisterVariable (&r_lodbias);
Cvar_RegisterVariable (&gl_lodbias);
Cvar_SetCallback (&r_scale, R_ScaleChanged_f);
Cvar_SetCallback (&r_lodbias, R_ScaleChanged_f);
Cvar_SetCallback (&gl_lodbias, R_ScaleChanged_f);
Cvar_SetCallback (&r_lavaalpha, R_SetLavaalpha_f);
Expand All @@ -3632,7 +3574,6 @@ void R_Init (void)
Cvar_RegisterVariable (&r_indirect);
Cvar_RegisterVariable (&r_tasks);
Cvar_RegisterVariable (&r_parallelmark);
Cvar_RegisterVariable (&r_usesops);

R_InitParticles ();
SetClearColor (); // johnfitz
Expand Down
6 changes: 3 additions & 3 deletions Quake/gl_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1219,9 +1219,6 @@ void SCR_UpdateScreen (qboolean use_tasks)
}
}

if (vid.recalc_refdef)
SCR_CalcRefdef ();

// decide on the height of the console
con_forcedup = !cl.worldmodel || cls.signon != SIGNONS;

Expand All @@ -1232,6 +1229,9 @@ void SCR_UpdateScreen (qboolean use_tasks)
return;
}

if (vid.recalc_refdef)
SCR_CalcRefdef ();

if (use_tasks)
{
if (prev_end_rendering_task != INVALID_TASK_HANDLE)
Expand Down
Loading