From 9b784ec0c7c350f581bf3c346cdee6b7aa1dc98b Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 29 Dec 2021 13:51:15 -0500 Subject: [PATCH 1/2] separate out nearest filtering for UI, default it on --- src/refresh/vkpt/main.c | 9 ++++++++- src/refresh/vkpt/textures.c | 22 +++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/refresh/vkpt/main.c b/src/refresh/vkpt/main.c index 5e40cd02d..c40954d7d 100644 --- a/src/refresh/vkpt/main.c +++ b/src/refresh/vkpt/main.c @@ -68,6 +68,7 @@ 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_nearest_2d = NULL; cvar_t *cvar_drs_enable = NULL; cvar_t *cvar_drs_target = NULL; cvar_t *cvar_drs_minscale = NULL; @@ -3568,13 +3569,19 @@ 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: + // 0 -> linear magnification + // 1 -> nearest magnification + cvar_pt_nearest_2d = Cvar_Get("pt_nearest_2d", "1", CVAR_ARCHIVE); + cvar_pt_nearest_2d->changed = pt_nearest_changed; + #ifdef VKPT_DEVICE_GROUPS cvar_sli = Cvar_Get("sli", "1", CVAR_REFRESH | CVAR_ARCHIVE); #endif diff --git a/src/refresh/vkpt/textures.c b/src/refresh/vkpt/textures.c index 6645cc02c..2f73535c2 100644 --- a/src/refresh/vkpt/textures.c +++ b/src/refresh/vkpt/textures.c @@ -91,6 +91,7 @@ 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_nearest_2d; void vkpt_textures_prefetch() { @@ -1936,14 +1937,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")) - sampler = qvk.tex_sampler_nearest; - else if (q_img->type == IT_SPRITE) + // 2d elements + if (q_img->type == IT_PIC || q_img->type == IT_FONT) { + if (cvar_pt_nearest_2d->integer || q_img->type == IT_FONT || !strcmp(q_img->name, "pics/ch1.pcx")) { + sampler = qvk.tex_sampler_nearest; + } else { + sampler = qvk.tex_sampler_linear_clamp; + } + } 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 (cvar_pt_nearest->integer == 1) + sampler = qvk.tex_sampler_nearest_mipmap_aniso; + else if (cvar_pt_nearest->integer >= 2) + sampler = qvk.tex_sampler_nearest; + } VkDescriptorImageInfo img_info = { .imageLayout = VK_IMAGE_LAYOUT_GENERAL, From 4ff233e05fd9db701f92b9d9db9139e4a9e65120 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 30 Dec 2021 19:05:54 -0500 Subject: [PATCH 2/2] follow GL mode standards as suggested by res2k; note that pt_bilerp_pics defaults to 0 instead of 1, though, as the 1 value in gl_bilerp_pics is a bit special as it affects the scrap as well (which is most pics, just not large ones like inven/help). The scrap isn't a thing in VK, so it's collapsed into on/off values for VK. --- src/refresh/vkpt/main.c | 14 ++++++++------ src/refresh/vkpt/textures.c | 25 +++++++++++++------------ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/refresh/vkpt/main.c b/src/refresh/vkpt/main.c index c40954d7d..026e96c33 100644 --- a/src/refresh/vkpt/main.c +++ b/src/refresh/vkpt/main.c @@ -68,7 +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_nearest_2d = 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; @@ -3576,11 +3577,12 @@ R_Init_RTX(bool total) cvar_pt_nearest = Cvar_Get("pt_nearest", "0", CVAR_ARCHIVE); cvar_pt_nearest->changed = pt_nearest_changed; - // texture filtering mode for UI elements: - // 0 -> linear magnification - // 1 -> nearest magnification - cvar_pt_nearest_2d = Cvar_Get("pt_nearest_2d", "1", CVAR_ARCHIVE); - cvar_pt_nearest_2d->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); diff --git a/src/refresh/vkpt/textures.c b/src/refresh/vkpt/textures.c index 2f73535c2..5f589ca52 100644 --- a/src/refresh/vkpt/textures.c +++ b/src/refresh/vkpt/textures.c @@ -91,7 +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_nearest_2d; +extern cvar_t* cvar_pt_bilerp_chars; +extern cvar_t* cvar_pt_bilerp_pics; void vkpt_textures_prefetch() { @@ -1937,21 +1938,21 @@ void vkpt_textures_update_descriptor_set() image_view = tex_invalid_texture_image_view; VkSampler sampler = qvk.tex_sampler; - // 2d elements - if (q_img->type == IT_PIC || q_img->type == IT_FONT) { - if (cvar_pt_nearest_2d->integer || q_img->type == IT_FONT || !strcmp(q_img->name, "pics/ch1.pcx")) { - sampler = qvk.tex_sampler_nearest; - } else { - sampler = qvk.tex_sampler_linear_clamp; - } - } else if (q_img->type == IT_SPRITE) { - sampler = qvk.tex_sampler_linear_clamp; - } else { + + 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) { + sampler = qvk.tex_sampler_linear_clamp; + } 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,