Skip to content

Commit

Permalink
Merged pull request "separate out nearest filtering for UI, default i…
Browse files Browse the repository at this point in the history
…t on": NVIDIA#173
  • Loading branch information
apanteleev committed Jan 6, 2022
2 parents c5aeaf3 + 4ff233e commit 22f856d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
11 changes: 10 additions & 1 deletion src/refresh/vkpt/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ cvar_t *cvar_pt_projection = NULL;
cvar_t *cvar_pt_dof = NULL;
cvar_t* cvar_pt_freecam = NULL;
cvar_t *cvar_pt_nearest = NULL;
cvar_t *cvar_pt_bilerp_chars = NULL;
cvar_t *cvar_pt_bilerp_pics = NULL;
cvar_t *cvar_drs_enable = NULL;
cvar_t *cvar_drs_target = NULL;
cvar_t *cvar_drs_minscale = NULL;
Expand Down Expand Up @@ -3568,13 +3570,20 @@ R_Init_RTX(bool total)
// freecam mode toggle
cvar_pt_freecam = Cvar_Get("pt_freecam", "1", CVAR_ARCHIVE);

// texture filtering mode:
// texture filtering mode for non-UI elements:
// 0 -> linear magnification, anisotropic minification
// 1 -> nearest magnification, anisotropic minification
// 2 -> nearest magnification and minification, no mipmaps (noisy)
cvar_pt_nearest = Cvar_Get("pt_nearest", "0", CVAR_ARCHIVE);
cvar_pt_nearest->changed = pt_nearest_changed;

// texture filtering mode for UI elements, follows
// the gl_bilerp_ cvars, except for `cvar_pt_bilerp_pics` which
// is only on/off, since vk has no scrap
cvar_pt_bilerp_chars = Cvar_Get("pt_bilerp_chars", "0", CVAR_ARCHIVE);
cvar_pt_bilerp_pics = Cvar_Get("pt_bilerp_pics", "0", CVAR_ARCHIVE);
cvar_pt_bilerp_chars->changed = cvar_pt_bilerp_pics->changed = pt_nearest_changed;

#ifdef VKPT_DEVICE_GROUPS
cvar_sli = Cvar_Get("sli", "1", CVAR_REFRESH | CVAR_ARCHIVE);
#endif
Expand Down
21 changes: 15 additions & 6 deletions src/refresh/vkpt/textures.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ static uint8_t descriptor_set_dirty_flags[MAX_FRAMES_IN_FLIGHT] = { 0 }; // init
static const float megabyte = 1048576.0f;

extern cvar_t* cvar_pt_nearest;
extern cvar_t* cvar_pt_bilerp_chars;
extern cvar_t* cvar_pt_bilerp_pics;

void vkpt_textures_prefetch()
{
Expand Down Expand Up @@ -1936,14 +1938,21 @@ void vkpt_textures_update_descriptor_set()
image_view = tex_invalid_texture_image_view;

VkSampler sampler = qvk.tex_sampler;
if (!strcmp(q_img->name, "pics/conchars.pcx") || !strcmp(q_img->name, "pics/ch1.pcx"))

if (q_img->type == IT_WALL || q_img->type == IT_SKIN) {
if (cvar_pt_nearest->integer == 1)
sampler = qvk.tex_sampler_nearest_mipmap_aniso;
else if (cvar_pt_nearest->integer >= 2)
sampler = qvk.tex_sampler_nearest;
} else if (q_img->flags & IF_NEAREST) {
sampler = qvk.tex_sampler_nearest;
else if (q_img->type == IT_SPRITE)
} else if (q_img->type == IT_SPRITE) {
sampler = qvk.tex_sampler_linear_clamp;
else if (cvar_pt_nearest->integer == 1)
sampler = qvk.tex_sampler_nearest_mipmap_aniso;
else if (cvar_pt_nearest->integer >= 2)
sampler = qvk.tex_sampler_nearest;
} else if (q_img->type == IT_FONT) {
sampler = (cvar_pt_bilerp_chars->integer == 0) ? qvk.tex_sampler_nearest : qvk.tex_sampler_linear_clamp;
} else if (q_img->type == IT_PIC) {
sampler = (cvar_pt_bilerp_pics->integer == 0) ? qvk.tex_sampler_nearest : qvk.tex_sampler_linear_clamp;
}

VkDescriptorImageInfo img_info = {
.imageLayout = VK_IMAGE_LAYOUT_GENERAL,
Expand Down

0 comments on commit 22f856d

Please sign in to comment.