Merge pull request #654 from 0lvin/ref_vk

Sync variable names for msaa, retexturing and anisotropic filtering
This commit is contained in:
Yamagi 2021-01-22 12:27:18 +01:00 committed by GitHub
commit 449776d3f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 151 additions and 172 deletions

View file

@ -229,6 +229,32 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable`
display refresh rate, should (but doesn't always) prevent tearing.
Set to `1` for normal vsync and `2` for adaptive vsync.
* **r_anisotropic**: Anisotropic filtering. Possible values are
dependent on the GPU driver, most of them support `1`, `2`, `4`, `8`
and `16`. Anisotropic filtering gives a huge improvement to texture
quality by a negligible performance impact.
If vulkan render have used, flag is only toggle anisotropic filtering
without use specific level.
* **r_msaa_samples**: Full scene anti aliasing samples. The number of
samples depends on the GPU driver, most drivers support at least `2`,
`4` and `8` samples. If an invalid value is set, the value is reverted
to the highest number of samples supported. Especially on OpenGL 3.2
anti aliasing is expensive and can lead to a huge performance hit, so
try setting it to a lower value if the framerate is too low.
* **r_nolerp_list**: list separate by spaces of textures omitted from
bilinear filtering. Used by default to exclude the console and HUD
fonts. Make sure to include the default values when extending the
list.
* **r_retexturing**: If set to `1` (the default) and a retexturing pack
is installed, the high resolution textures are used.
If set to `2` and vulkan render is used, scale up all 8bit textures.
* **r_shadows**: Enables rendering of shadows. Quake IIs shadows are
very simple and are prone to render errors.
* **vid_displayrefreshrate**: Sets the displays refresh rate. The
default `-1` let the game determine the refresh rate automatically.
Often the default setting is okay, but some graphics drivers report
@ -258,29 +284,6 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable`
## Graphics (GL renderers only)
* **gl_anisotropic**: Anisotropic filtering. Possible values are
dependent on the GPU driver, most of them support `1`, `2`, `4`, `8`
and `16`. Anisotropic filtering gives a huge improvement to texture
quality by a negligible performance impact.
* **gl_msaa_samples**: Full scene anti aliasing samples. The number of
samples depends on the GPU driver, most drivers support at least `2`,
`4` and `8` samples. If an invalid value is set, the value is reverted
to the highest number of samples supported. Especially on OpenGL 3.2
anti aliasing is expensive and can lead to a huge performance hit, so
try setting it to a lower value if the framerate is too low.
* **gl_nolerp_list**: list separate by spaces of textures omitted from
bilinear filtering. Used by default to exclude the console and HUD
fonts. Make sure to include the default values when extending the
list.
* **gl_retexturing**: If set to `1` (the default) and a retexturing pack
is installed, the high resolution textures are used.
* **gl_shadows**: Enables rendering of shadows. Quake IIs shadows are
very simple and are prone to render errors.
* **gl_zfix**: Sometimes two or even more surfaces overlap and flicker.
If this cvar is set to `1` the renderer inserts a small gap between
the overlapping surfaces to mitigate the flickering. This may make
@ -353,18 +356,6 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable`
* `1` - only errors and warnings
* `2` - best-practices validation
* **vk_retexturing**: Apply retexturing:
* `0` - dont use retexturing logic and dont load the high resolution
textures,
* `1` - load the high resolution textures if pack is installed.
* `2` - try to load the pack or scale up all 8bit textures if pack is
not installed.
* **vk_nolerp_list**: list separate by spaces of textures omitted from
bilinear filtering. Used by default to exclude the console and HUD
fonts. Make sure to include the default values when extending the
list.
* **vk_strings**: Print some basic Vulkan/GPU information.
* **vk_mem**: Print dynamic vertex/index/uniform/triangle fan buffer
@ -376,13 +367,6 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable`
* `0..n` - use device #n (full list of devices is returned by
`vk_strings` command)
* **vk_msaa**: Toggle MSAA:
* `0` - off (default)
* `1` - MSAAx2
* `2` - MSAAx4
* `3` - MSAAx8
* `4` - MSAAx16
* **vk_sampleshading**: Toggle sample shading for MSAA. (default: `1`)
* **vk_flashblend**: Toggle the blending of lights onto the environment.
@ -420,8 +404,6 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable`
* **vk_particle_max_size**: The maximum size of a rendered particle.
(default: `40`)
* **vk_shadows**: Draw experimental entity shadows. (default: `0`)
* **vk_picmip**: Shrink factor for the textures. (default: `0`)
* **vk_pixel_size**: Pixel size when rendering the world, used to simulate

View file

@ -139,11 +139,11 @@ AnisotropicCallback(void *s)
if (list->curvalue == 0)
{
Cvar_SetValue("gl_anisotropic", 0);
Cvar_SetValue("r_anisotropic", 0);
}
else
{
Cvar_SetValue("gl_anisotropic", pow(2, list->curvalue));
Cvar_SetValue("r_anisotropic", pow(2, list->curvalue));
}
}
@ -248,7 +248,7 @@ ApplyChanges(void *unused)
{
if (gl_msaa_samples->value != 0)
{
Cvar_SetValue("gl_msaa_samples", 0);
Cvar_SetValue("r_msaa_samples", 0);
restart = true;
}
}
@ -256,7 +256,7 @@ ApplyChanges(void *unused)
{
if (gl_msaa_samples->value != pow(2, s_msaa_list.curvalue))
{
Cvar_SetValue("gl_msaa_samples", pow(2, s_msaa_list.curvalue));
Cvar_SetValue("r_msaa_samples", pow(2, s_msaa_list.curvalue));
restart = true;
}
}
@ -410,12 +410,12 @@ VID_MenuInit(void)
if (!gl_anisotropic)
{
gl_anisotropic = Cvar_Get("gl_anisotropic", "0", CVAR_ARCHIVE);
gl_anisotropic = Cvar_Get("r_anisotropic", "0", CVAR_ARCHIVE);
}
if (!gl_msaa_samples)
{
gl_msaa_samples = Cvar_Get("gl_msaa_samples", "0", CVAR_ARCHIVE);
gl_msaa_samples = Cvar_Get("r_msaa_samples", "0", CVAR_ARCHIVE);
}
s_opengl_menu.x = viddef.width * 0.50;

View file

@ -204,16 +204,16 @@ R_TextureMode(char *string)
{
if (gl_anisotropic->value > gl_config.max_anisotropy)
{
ri.Cvar_SetValue("gl_anisotropic", gl_config.max_anisotropy);
ri.Cvar_SetValue("r_anisotropic", gl_config.max_anisotropy);
}
else if (gl_anisotropic->value < 1.0)
{
ri.Cvar_SetValue("gl_anisotropic", 1.0);
ri.Cvar_SetValue("r_anisotropic", 1.0);
}
}
else
{
ri.Cvar_SetValue("gl_anisotropic", 0.0);
ri.Cvar_SetValue("r_anisotropic", 0.0);
}
const char* nolerplist = gl_nolerp_list->string;

View file

@ -1225,7 +1225,7 @@ R_Register(void)
r_modulate = ri.Cvar_Get("r_modulate", "1", CVAR_ARCHIVE);
r_mode = ri.Cvar_Get("r_mode", "4", CVAR_ARCHIVE);
gl_lightmap = ri.Cvar_Get("gl_lightmap", "0", 0);
gl_shadows = ri.Cvar_Get("gl_shadows", "0", CVAR_ARCHIVE);
gl_shadows = ri.Cvar_Get("r_shadows", "0", CVAR_ARCHIVE);
gl1_stencilshadow = ri.Cvar_Get("gl1_stencilshadow", "0", CVAR_ARCHIVE);
gl1_dynamic = ri.Cvar_Get("gl1_dynamic", "1", 0);
gl_nobind = ri.Cvar_Get("gl_nobind", "0", 0);
@ -1245,7 +1245,7 @@ R_Register(void)
gl_texturemode = ri.Cvar_Get("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE);
gl1_texturealphamode = ri.Cvar_Get("gl1_texturealphamode", "default", CVAR_ARCHIVE);
gl1_texturesolidmode = ri.Cvar_Get("gl1_texturesolidmode", "default", CVAR_ARCHIVE);
gl_anisotropic = ri.Cvar_Get("gl_anisotropic", "0", CVAR_ARCHIVE);
gl_anisotropic = ri.Cvar_Get("r_anisotropic", "0", CVAR_ARCHIVE);
r_lockpvs = ri.Cvar_Get("r_lockpvs", "0", 0);
gl1_palettedtexture = ri.Cvar_Get("gl1_palettedtexture", "0", CVAR_ARCHIVE);
@ -1261,12 +1261,12 @@ R_Register(void)
r_customwidth = ri.Cvar_Get("r_customwidth", "1024", CVAR_ARCHIVE);
r_customheight = ri.Cvar_Get("r_customheight", "768", CVAR_ARCHIVE);
gl_msaa_samples = ri.Cvar_Get ( "gl_msaa_samples", "0", CVAR_ARCHIVE );
gl_msaa_samples = ri.Cvar_Get ( "r_msaa_samples", "0", CVAR_ARCHIVE );
gl_retexturing = ri.Cvar_Get("gl_retexturing", "1", CVAR_ARCHIVE);
gl_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
/* don't bilerp characters and crosshairs */
gl_nolerp_list = ri.Cvar_Get("gl_nolerp_list", "pics/conchars.pcx pics/ch1.pcx pics/ch2.pcx pics/ch3.pcx", 0);
gl_nolerp_list = ri.Cvar_Get("r_nolerp_list", "pics/conchars.pcx pics/ch1.pcx pics/ch2.pcx pics/ch3.pcx", 0);
gl1_stereo = ri.Cvar_Get( "gl1_stereo", "0", CVAR_ARCHIVE );
gl1_stereo_separation = ri.Cvar_Get( "gl1_stereo_separation", "-0.4", CVAR_ARCHIVE );
@ -1351,7 +1351,7 @@ R_SetMode(void)
if (gl_msaa_samples->value != 0.0f)
{
R_Printf(PRINT_ALL, "gl_msaa_samples was %d - will try again with gl_msaa_samples = 0\n", (int)gl_msaa_samples->value);
ri.Cvar_SetValue("gl_msaa_samples", 0.0f);
ri.Cvar_SetValue("r_msaa_samples", 0.0f);
gl_msaa_samples->modified = false;
if ((err = SetMode_impl(&vid.width, &vid.height, r_mode->value, 0)) == rserr_ok)

View file

@ -101,7 +101,7 @@ int RI_PrepareForWindow(void)
{
R_Printf(PRINT_ALL, "MSAA is unsupported: %s\n", SDL_GetError());
ri.Cvar_SetValue ("gl_msaa_samples", 0);
ri.Cvar_SetValue ("r_msaa_samples", 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
@ -110,7 +110,7 @@ int RI_PrepareForWindow(void)
{
R_Printf(PRINT_ALL, "MSAA %ix is unsupported: %s\n", msaa_samples, SDL_GetError());
ri.Cvar_SetValue("gl_msaa_samples", 0);
ri.Cvar_SetValue("r_msaa_samples", 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
@ -220,7 +220,7 @@ int RI_InitContext(void* win)
{
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &msaa_samples) == 0)
{
ri.Cvar_SetValue("gl_msaa_samples", msaa_samples);
ri.Cvar_SetValue("r_msaa_samples", msaa_samples);
}
}

View file

@ -76,16 +76,16 @@ GL3_TextureMode(char *string)
{
if (gl_anisotropic->value > gl3config.max_anisotropy)
{
ri.Cvar_SetValue("gl_anisotropic", gl3config.max_anisotropy);
ri.Cvar_SetValue("r_anisotropic", gl3config.max_anisotropy);
}
else if (gl_anisotropic->value < 1.0)
{
ri.Cvar_SetValue("gl_anisotropic", 1.0);
ri.Cvar_SetValue("r_anisotropic", 1.0);
}
}
else
{
ri.Cvar_SetValue("gl_anisotropic", 0.0);
ri.Cvar_SetValue("r_anisotropic", 0.0);
}
gl3image_t *glt;

View file

@ -198,8 +198,8 @@ GL3_Register(void)
gl_drawbuffer = ri.Cvar_Get("gl_drawbuffer", "GL_BACK", 0);
r_vsync = ri.Cvar_Get("r_vsync", "1", CVAR_ARCHIVE);
gl_msaa_samples = ri.Cvar_Get ( "gl_msaa_samples", "0", CVAR_ARCHIVE );
gl_retexturing = ri.Cvar_Get("gl_retexturing", "1", CVAR_ARCHIVE);
gl_msaa_samples = ri.Cvar_Get ( "r_msaa_samples", "0", CVAR_ARCHIVE );
gl_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
gl3_debugcontext = ri.Cvar_Get("gl3_debugcontext", "0", 0);
r_mode = ri.Cvar_Get("r_mode", "4", CVAR_ARCHIVE);
r_customwidth = ri.Cvar_Get("r_customwidth", "1024", CVAR_ARCHIVE);
@ -220,11 +220,11 @@ GL3_Register(void)
r_fixsurfsky = ri.Cvar_Get("r_fixsurfsky", "1", CVAR_ARCHIVE);
/* don't bilerp characters and crosshairs */
gl_nolerp_list = ri.Cvar_Get("gl_nolerp_list", "pics/conchars.pcx pics/ch1.pcx pics/ch2.pcx pics/ch3.pcx", 0);
gl_nolerp_list = ri.Cvar_Get("r_nolerp_list", "pics/conchars.pcx pics/ch1.pcx pics/ch2.pcx pics/ch3.pcx", 0);
gl_nobind = ri.Cvar_Get("gl_nobind", "0", 0);
gl_texturemode = ri.Cvar_Get("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE);
gl_anisotropic = ri.Cvar_Get("gl_anisotropic", "0", CVAR_ARCHIVE);
gl_anisotropic = ri.Cvar_Get("r_anisotropic", "0", CVAR_ARCHIVE);
vid_fullscreen = ri.Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE);
vid_gamma = ri.Cvar_Get("vid_gamma", "1.2", CVAR_ARCHIVE);
@ -235,7 +235,7 @@ GL3_Register(void)
gl3_overbrightbits = ri.Cvar_Get("gl3_overbrightbits", "1.3", CVAR_ARCHIVE);
gl_lightmap = ri.Cvar_Get("gl_lightmap", "0", 0);
gl_shadows = ri.Cvar_Get("gl_shadows", "0", CVAR_ARCHIVE);
gl_shadows = ri.Cvar_Get("r_shadows", "0", CVAR_ARCHIVE);
r_modulate = ri.Cvar_Get("r_modulate", "1", CVAR_ARCHIVE);
gl_zfix = ri.Cvar_Get("gl_zfix", "0", 0);
@ -270,7 +270,7 @@ GL3_Register(void)
//gl_modulate = ri.Cvar_Get("gl_modulate", "1", CVAR_ARCHIVE);
//r_mode = ri.Cvar_Get("r_mode", "4", CVAR_ARCHIVE);
//gl_lightmap = ri.Cvar_Get("gl_lightmap", "0", 0);
//gl_shadows = ri.Cvar_Get("gl_shadows", "0", CVAR_ARCHIVE);
//gl_shadows = ri.Cvar_Get("r_shadows", "0", CVAR_ARCHIVE);
//gl_nobind = ri.Cvar_Get("gl_nobind", "0", 0);
gl_showtris = ri.Cvar_Get("gl_showtris", "0", 0);
gl_showbbox = Cvar_Get("gl_showbbox", "0", 0);
@ -284,7 +284,7 @@ GL3_Register(void)
//gl_texturemode = ri.Cvar_Get("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE);
gl1_texturealphamode = ri.Cvar_Get("gl1_texturealphamode", "default", CVAR_ARCHIVE);
gl1_texturesolidmode = ri.Cvar_Get("gl1_texturesolidmode", "default", CVAR_ARCHIVE);
//gl_anisotropic = ri.Cvar_Get("gl_anisotropic", "0", CVAR_ARCHIVE);
//gl_anisotropic = ri.Cvar_Get("r_anisotropic", "0", CVAR_ARCHIVE);
//r_lockpvs = ri.Cvar_Get("r_lockpvs", "0", 0);
//gl1_palettedtexture = ri.Cvar_Get("gl1_palettedtexture", "0", CVAR_ARCHIVE); NOPE.
@ -299,9 +299,9 @@ GL3_Register(void)
//r_customwidth = ri.Cvar_Get("r_customwidth", "1024", CVAR_ARCHIVE);
//r_customheight = ri.Cvar_Get("r_customheight", "768", CVAR_ARCHIVE);
//gl_msaa_samples = ri.Cvar_Get ( "gl_msaa_samples", "0", CVAR_ARCHIVE );
//gl_msaa_samples = ri.Cvar_Get ( "r_msaa_samples", "0", CVAR_ARCHIVE );
//gl_retexturing = ri.Cvar_Get("gl_retexturing", "1", CVAR_ARCHIVE);
//gl_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
gl1_stereo = ri.Cvar_Get( "gl1_stereo", "0", CVAR_ARCHIVE );
@ -401,7 +401,7 @@ GL3_SetMode(void)
if (gl_msaa_samples->value != 0.0f)
{
R_Printf(PRINT_ALL, "gl_msaa_samples was %d - will try again with gl_msaa_samples = 0\n", (int)gl_msaa_samples->value);
ri.Cvar_SetValue("gl_msaa_samples", 0.0f);
ri.Cvar_SetValue("r_msaa_samples", 0.0f);
gl_msaa_samples->modified = false;
if ((err = SetMode_impl(&vid.width, &vid.height, r_mode->value, 0)) == rserr_ok)

View file

@ -239,7 +239,7 @@ int GL3_PrepareForWindow(void)
{
R_Printf(PRINT_ALL, "MSAA is unsupported: %s\n", SDL_GetError());
ri.Cvar_SetValue ("gl_msaa_samples", 0);
ri.Cvar_SetValue ("r_msaa_samples", 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
@ -248,7 +248,7 @@ int GL3_PrepareForWindow(void)
{
R_Printf(PRINT_ALL, "MSAA %ix is unsupported: %s\n", msaa_samples, SDL_GetError());
ri.Cvar_SetValue("gl_msaa_samples", 0);
ri.Cvar_SetValue("r_msaa_samples", 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
@ -298,7 +298,7 @@ int GL3_InitContext(void* win)
{
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &msaa_samples) == 0)
{
ri.Cvar_SetValue("gl_msaa_samples", msaa_samples);
ri.Cvar_SetValue("r_msaa_samples", msaa_samples);
}
}

View file

@ -375,7 +375,7 @@ R_RegisterVariables (void)
sw_overbrightbits = ri.Cvar_Get("sw_overbrightbits", "1.0", CVAR_ARCHIVE);
sw_custom_particles = ri.Cvar_Get("sw_custom_particles", "0", CVAR_ARCHIVE);
sw_texture_filtering = ri.Cvar_Get("sw_texture_filtering", "0", CVAR_ARCHIVE);
sw_retexturing = ri.Cvar_Get("sw_retexturing", "0", CVAR_ARCHIVE);
sw_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
sw_gunzposition = ri.Cvar_Get("sw_gunzposition", "8", CVAR_ARCHIVE);
// On MacOS texture is cleaned up after render and code have to copy a whole

View file

@ -118,16 +118,10 @@ extern vec3_t r_origin;
extern refdef_t r_newrefdef;
extern int r_viewcluster, r_viewcluster2, r_oldviewcluster, r_oldviewcluster2;
extern cvar_t *r_norefresh;
extern cvar_t *r_lefthand;
extern cvar_t *r_drawentities;
extern cvar_t *r_drawworld;
extern cvar_t *r_speeds;
extern cvar_t *r_fullbright;
extern cvar_t *r_novis;
extern cvar_t *r_nocull;
extern cvar_t *r_lerpmodels;
extern cvar_t *r_mode;
extern cvar_t *r_lockpvs;
extern cvar_t *r_modulate;
extern cvar_t *r_vsync;
@ -138,21 +132,11 @@ extern cvar_t *r_farsee;
extern cvar_t *vk_overbrightbits;
extern cvar_t *vk_validation;
extern cvar_t *vk_bitdepth;
extern cvar_t *vk_picmip;
extern cvar_t *vk_skymip;
extern cvar_t *vk_flashblend;
extern cvar_t *vk_finish;
extern cvar_t *vk_polyblend;
extern cvar_t *vk_shadows;
extern cvar_t *vk_pixel_size;
extern cvar_t *vk_particle_size;
extern cvar_t *vk_particle_att_a;
extern cvar_t *vk_particle_att_b;
extern cvar_t *vk_particle_att_c;
extern cvar_t *vk_particle_min_size;
extern cvar_t *vk_particle_max_size;
extern cvar_t *vk_custom_particles;
extern cvar_t *vk_dynamic;
extern cvar_t *vk_msaa;
extern cvar_t *vk_showtris;
@ -163,7 +147,6 @@ extern cvar_t *vk_aniso;
extern cvar_t *vk_sampleshading;
extern cvar_t *vk_device_idx;
extern cvar_t *vk_retexturing;
extern cvar_t *vk_underwater;
extern cvar_t *vk_nolerp_list;
extern cvar_t *r_fixsurfsky;

View file

@ -224,7 +224,6 @@ extern VkViewport vk_viewport;
extern VkRect2D vk_scissor;
// Vulkan descriptor sets
extern VkDescriptorSetLayout vk_uboDescSetLayout;
extern VkDescriptorSetLayout vk_samplerDescSetLayout;
// *** pipelines ***

View file

@ -86,9 +86,9 @@ VkCommandPool vk_transferCommandPool = VK_NULL_HANDLE;
VkDescriptorPool vk_descriptorPool = VK_NULL_HANDLE;
static VkCommandPool vk_stagingCommandPool[NUM_DYNBUFFERS] = { VK_NULL_HANDLE, VK_NULL_HANDLE };
// Vulkan image views
VkImageView *vk_imageviews = NULL;
static VkImageView *vk_imageviews = NULL;
// Vulkan framebuffers
VkFramebuffer *vk_framebuffers[RP_COUNT];
static VkFramebuffer *vk_framebuffers[RP_COUNT];
// color buffer containing main game/world view
qvktexture_t vk_colorbuffer = QVVKTEXTURE_INIT;
// color buffer with postprocessed game view
@ -96,29 +96,29 @@ qvktexture_t vk_colorbufferWarp = QVVKTEXTURE_INIT;
// depth buffer
qvktexture_t vk_depthbuffer = QVVKTEXTURE_INIT;
// depth buffer for UI renderpass
qvktexture_t vk_ui_depthbuffer = QVVKTEXTURE_INIT;
static qvktexture_t vk_ui_depthbuffer = QVVKTEXTURE_INIT;
// render target for MSAA resolve
qvktexture_t vk_msaaColorbuffer = QVVKTEXTURE_INIT;
static qvktexture_t vk_msaaColorbuffer = QVVKTEXTURE_INIT;
// viewport and scissor
VkViewport vk_viewport = { .0f, .0f, .0f, .0f, .0f, .0f };
VkRect2D vk_scissor = { { 0, 0 }, { 0, 0 } };
// Vulkan command buffers
VkCommandBuffer *vk_commandbuffers = NULL;
static VkCommandBuffer *vk_commandbuffers = NULL;
// command buffer double buffering fences
VkFence vk_fences[NUM_CMDBUFFERS];
static VkFence vk_fences[NUM_CMDBUFFERS];
// semaphore: signal when next image is available for rendering
VkSemaphore vk_imageAvailableSemaphores[NUM_CMDBUFFERS];
static VkSemaphore vk_imageAvailableSemaphores[NUM_CMDBUFFERS];
// semaphore: signal when rendering to current command buffer is complete
VkSemaphore vk_renderFinishedSemaphores[NUM_CMDBUFFERS];
static VkSemaphore vk_renderFinishedSemaphores[NUM_CMDBUFFERS];
// tracker variables
VkCommandBuffer vk_activeCmdbuffer = VK_NULL_HANDLE;
// index of active command buffer
int vk_activeBufferIdx = 0;
// index of currently acquired image
uint32_t vk_imageIndex = 0;
static uint32_t vk_imageIndex = 0;
// index of currently used staging buffer
int vk_activeStagingBuffer = 0;
static int vk_activeStagingBuffer = 0;
// started rendering frame?
qboolean vk_frameStarted = false;
@ -209,9 +209,9 @@ PFN_vkCmdInsertDebugUtilsLabelEXT qvkInsertDebugUtilsLabelEXT;
QVk_DebugSetObjectName((uint64_t)shaders[1].module, VK_OBJECT_TYPE_SHADER_MODULE, "Shader Module: "#namefrag".frag");
// global static buffers (reused, never changing)
qvkbuffer_t vk_texRectVbo;
qvkbuffer_t vk_colorRectVbo;
qvkbuffer_t vk_rectIbo;
static qvkbuffer_t vk_texRectVbo;
static qvkbuffer_t vk_colorRectVbo;
static qvkbuffer_t vk_rectIbo;
// global dynamic buffers (double buffered)
static qvkbuffer_t vk_dynVertexBuffers[NUM_DYNBUFFERS];
@ -247,9 +247,9 @@ static VkDescriptorSet *vk_swapDescriptorSets[NUM_SWAPBUFFER_SLOTS];
#define TRIANGLE_FAN_INDEX_CNT 200
// Vulkan common descriptor sets for UBO, primary texture sampler and optional lightmap texture
VkDescriptorSetLayout vk_uboDescSetLayout;
static VkDescriptorSetLayout vk_uboDescSetLayout;
VkDescriptorSetLayout vk_samplerDescSetLayout;
VkDescriptorSetLayout vk_samplerLightmapDescSetLayout;
static VkDescriptorSetLayout vk_samplerLightmapDescSetLayout;
static const char *renderpassObjectNames[] = {
"RP_WORLD",
@ -280,17 +280,30 @@ VkFormat QVk_FindDepthFormat()
}
// internal helper
static VkSampleCountFlagBits GetSampleCount(int msaa)
static VkSampleCountFlagBits GetSampleCount(int msaa, VkSampleCountFlagBits supportedMsaa)
{
int step = 0, value = 64;
static VkSampleCountFlagBits msaaModes[] = {
VK_SAMPLE_COUNT_1_BIT,
VK_SAMPLE_COUNT_2_BIT,
VK_SAMPLE_COUNT_4_BIT,
VK_SAMPLE_COUNT_64_BIT,
VK_SAMPLE_COUNT_32_BIT,
VK_SAMPLE_COUNT_16_BIT,
VK_SAMPLE_COUNT_8_BIT,
VK_SAMPLE_COUNT_16_BIT
VK_SAMPLE_COUNT_4_BIT,
VK_SAMPLE_COUNT_2_BIT,
VK_SAMPLE_COUNT_1_BIT
};
return msaaModes[msaa];
while ((msaa < value && value > 1) ||
((supportedMsaa & msaaModes[step]) != msaaModes[step]))
{
value >>= 1;
step ++;
}
R_Printf(PRINT_ALL, "MSAAx%d is used...\n", value);
return msaaModes[step];
}
// internal helper
@ -1822,16 +1835,8 @@ qboolean QVk_Init(SDL_Window *window)
vk_renderpasses[i].colorLoadOp = r_clear->value ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_DONT_CARE;
}
VkSampleCountFlagBits msaaMode = GetSampleCount((int)vk_msaa->value);
VkSampleCountFlagBits supportedMsaa = vk_device.properties.limits.framebufferColorSampleCounts;
if (!(supportedMsaa & msaaMode))
{
R_Printf(PRINT_ALL, "MSAAx%d mode not supported, aborting...\n", msaaMode);
ri.Cvar_Set("vk_msaa", "0");
msaaMode = VK_SAMPLE_COUNT_1_BIT;
// avoid secondary video reload
vk_msaa->modified = false;
}
VkSampleCountFlagBits msaaMode = GetSampleCount((int)vk_msaa->value,
vk_device.properties.limits.framebufferColorSampleCounts);
// MSAA setting will be only relevant for the primary world render pass
vk_renderpasses[RP_WORLD].sampleCount = msaaMode;

View file

@ -20,10 +20,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "header/local.h"
// internal helper
static qboolean deviceExtensionsSupported(const VkPhysicalDevice *physicalDevice)
static qboolean deviceExtensionsSupported(const VkPhysicalDevice *physicalDevice, const char* extensionName)
{
uint32_t availableExtCount = 0;
qboolean vk_khr_swapchain_extension_available = false;
qboolean vk_extension_available = false;
VK_VERIFY(vkEnumerateDeviceExtensionProperties(*physicalDevice, NULL, &availableExtCount, NULL));
if (availableExtCount > 0)
@ -33,14 +33,14 @@ static qboolean deviceExtensionsSupported(const VkPhysicalDevice *physicalDevice
for (uint32_t i = 0; i < availableExtCount; ++i)
{
vk_khr_swapchain_extension_available |= strcmp(extensions[i].extensionName, VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0;
vk_extension_available |= strcmp(extensions[i].extensionName, extensionName) == 0;
}
free(extensions);
}
// lack of swapchain extension disqualifies the device
return vk_khr_swapchain_extension_available;
// lack of extension disqualifies the device
return vk_extension_available;
}
// internal helper
@ -68,17 +68,12 @@ static void getBestPhysicalDevice(const VkPhysicalDevice *devices, int preferred
uint32_t presentModesCount = 0;
// check if requested device extensions are present
qboolean extSupported = deviceExtensionsSupported(&devices[i]);
qboolean extSupported = deviceExtensionsSupported(&devices[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME);
// no required extensions? try next device
if (!extSupported)
continue;
if (!deviceFeatures.samplerAnisotropy)
{
R_Printf(PRINT_ALL, "...anisotropy filtering is unsupported.\n");
}
// if extensions are fine, query surface formats and present modes to see if the device can be used
VK_VERIFY(vkGetPhysicalDeviceSurfaceFormatsKHR(devices[i], vk_surface, &formatCount, NULL));
VK_VERIFY(vkGetPhysicalDeviceSurfacePresentModesKHR(devices[i], vk_surface, &presentModesCount, NULL));
@ -158,6 +153,11 @@ static qboolean selectPhysicalDevice(int preferredDeviceIdx)
return false;
}
if (!vk_device.features.samplerAnisotropy)
{
R_Printf(PRINT_ALL, "...anisotropy filtering is unsupported.\n");
}
return true;
}

View file

@ -47,7 +47,7 @@ int r_framecount; // used for dlight push checking
int c_brush_polys, c_alias_polys;
float v_blend[4]; // final blending color
static float v_blend[4]; // final blending color
void Vk_Strings_f(void);
void Vk_Mem_f(void);
@ -76,42 +76,43 @@ refdef_t r_newrefdef;
int r_viewcluster, r_viewcluster2, r_oldviewcluster, r_oldviewcluster2;
cvar_t *r_norefresh;
cvar_t *r_drawentities;
static cvar_t *r_norefresh;
static cvar_t *r_drawentities;
cvar_t *r_drawworld;
cvar_t *r_speeds;
cvar_t *r_fullbright;
static cvar_t *r_speeds;
static cvar_t *r_fullbright;
cvar_t *r_novis;
cvar_t *r_nocull;
static cvar_t *r_nocull;
cvar_t *r_lerpmodels;
cvar_t *r_lefthand;
cvar_t *r_vsync;
cvar_t *r_mode;
static cvar_t *r_mode;
cvar_t *r_gunfov;
cvar_t *r_farsee;
static cvar_t *r_customwidth;
static cvar_t *r_customheight;
cvar_t *r_lightlevel; // FIXME: This is a HACK to get the client's light level
cvar_t *vk_overbrightbits;
cvar_t *vk_validation;
cvar_t *vk_bitdepth;
cvar_t *vk_picmip;
cvar_t *vk_skymip;
cvar_t *vk_flashblend;
cvar_t *vk_finish;
cvar_t *r_clear;
cvar_t *r_lockpvs;
cvar_t *vk_polyblend;
static cvar_t *vk_polyblend;
cvar_t *r_modulate;
cvar_t *vk_shadows;
cvar_t *vk_pixel_size;
cvar_t *vk_particle_size;
cvar_t *vk_particle_att_a;
cvar_t *vk_particle_att_b;
cvar_t *vk_particle_att_c;
cvar_t *vk_particle_min_size;
cvar_t *vk_particle_max_size;
cvar_t *vk_custom_particles;
static cvar_t *vk_pixel_size;
static cvar_t *vk_particle_size;
static cvar_t *vk_particle_att_a;
static cvar_t *vk_particle_att_b;
static cvar_t *vk_particle_att_c;
static cvar_t *vk_particle_min_size;
static cvar_t *vk_particle_max_size;
static cvar_t *vk_custom_particles;
cvar_t *vk_postprocess;
cvar_t *vk_dynamic;
cvar_t *vk_msaa;
@ -124,13 +125,13 @@ cvar_t *vk_mip_nearfilter;
cvar_t *vk_sampleshading;
cvar_t *vk_device_idx;
cvar_t *vk_retexturing;
cvar_t *vk_underwater;
static cvar_t *vk_underwater;
cvar_t *vk_nolerp_list;
cvar_t *r_fixsurfsky;
cvar_t *vid_fullscreen;
cvar_t *vid_gamma;
cvar_t *viewsize;
static cvar_t *viewsize;
/*
=================
@ -1193,10 +1194,11 @@ R_Register( void )
r_vsync = ri.Cvar_Get("r_vsync", "0", CVAR_ARCHIVE);
r_gunfov = ri.Cvar_Get("r_gunfov", "80", CVAR_ARCHIVE);
r_farsee = ri.Cvar_Get("r_farsee", "0", CVAR_LATCH | CVAR_ARCHIVE);
r_customwidth = ri.Cvar_Get("r_customwidth", "1024", CVAR_ARCHIVE);
r_customheight = ri.Cvar_Get("r_customheight", "768", CVAR_ARCHIVE);
vk_overbrightbits = ri.Cvar_Get("vk_overbrightbits", "1.0", CVAR_ARCHIVE);
vk_validation = ri.Cvar_Get("vk_validation", "0", CVAR_ARCHIVE);
vk_bitdepth = ri.Cvar_Get("vk_bitdepth", "0", 0);
vk_picmip = ri.Cvar_Get("vk_picmip", "0", 0);
vk_skymip = ri.Cvar_Get("vk_skymip", "0", 0);
vk_flashblend = ri.Cvar_Get("vk_flashblend", "0", 0);
@ -1205,7 +1207,7 @@ R_Register( void )
r_lockpvs = ri.Cvar_Get("r_lockpvs", "0", 0);
vk_polyblend = ri.Cvar_Get("vk_polyblend", "1", 0);
r_modulate = ri.Cvar_Get("r_modulate", "1", CVAR_ARCHIVE);
vk_shadows = ri.Cvar_Get("vk_shadows", "0", CVAR_ARCHIVE);
vk_shadows = ri.Cvar_Get("r_shadows", "0", CVAR_ARCHIVE);
vk_pixel_size = ri.Cvar_Get("vk_pixel_size", "1", CVAR_ARCHIVE);
vk_particle_size = ri.Cvar_Get("vk_particle_size", "40", CVAR_ARCHIVE);
vk_particle_att_a = ri.Cvar_Get("vk_particle_att_a", "0.01", CVAR_ARCHIVE);
@ -1216,26 +1218,24 @@ R_Register( void )
vk_custom_particles = ri.Cvar_Get("vk_custom_particles", "1", CVAR_ARCHIVE);
vk_postprocess = ri.Cvar_Get("vk_postprocess", "1", CVAR_ARCHIVE);
vk_dynamic = ri.Cvar_Get("vk_dynamic", "1", 0);
vk_msaa = ri.Cvar_Get("vk_msaa", "0", CVAR_ARCHIVE);
vk_msaa = ri.Cvar_Get("r_msaa_samples", "0", CVAR_ARCHIVE);
vk_showtris = ri.Cvar_Get("vk_showtris", "0", 0);
vk_lightmap = ri.Cvar_Get("vk_lightmap", "0", 0);
vk_texturemode = ri.Cvar_Get("vk_texturemode", "VK_MIPMAP_LINEAR", CVAR_ARCHIVE);
vk_lmaptexturemode = ri.Cvar_Get("vk_lmaptexturemode", "VK_MIPMAP_LINEAR", CVAR_ARCHIVE);
vk_aniso = ri.Cvar_Get("vk_aniso", "1", CVAR_ARCHIVE);
vk_aniso = ri.Cvar_Get("r_anisotropic", "0", CVAR_ARCHIVE);
vk_mip_nearfilter = ri.Cvar_Get("vk_mip_nearfilter", "0", CVAR_ARCHIVE);
vk_sampleshading = ri.Cvar_Get("vk_sampleshading", "1", CVAR_ARCHIVE);
vk_device_idx = ri.Cvar_Get("vk_device", "-1", CVAR_ARCHIVE);
vk_retexturing = ri.Cvar_Get("vk_retexturing", "1", CVAR_ARCHIVE);
vk_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE);
vk_underwater = ri.Cvar_Get("vk_underwater", "1", CVAR_ARCHIVE);
/* don't bilerp characters and crosshairs */
vk_nolerp_list = ri.Cvar_Get("vk_nolerp_list", "pics/conchars.pcx pics/ch1.pcx pics/ch2.pcx pics/ch3.pcx", 0);
vk_nolerp_list = ri.Cvar_Get("r_nolerp_list", "pics/conchars.pcx pics/ch1.pcx pics/ch2.pcx pics/ch3.pcx", 0);
r_fixsurfsky = ri.Cvar_Get("r_fixsurfsky", "1", CVAR_ARCHIVE);
// clamp vk_msaa to accepted range so that video menu doesn't crash on us
if (vk_msaa->value < 0)
ri.Cvar_Set("vk_msaa", "0");
else if (vk_msaa->value > 4)
ri.Cvar_Set("vk_msaa", "4");
ri.Cvar_Set("r_msaa_samples", "0");
vid_fullscreen = ri.Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE);
vid_gamma = ri.Cvar_Get("vid_gamma", "1.0", CVAR_ARCHIVE);
@ -1251,7 +1251,7 @@ R_Register( void )
static int
Vkimp_SetMode(int *pwidth, int *pheight, int mode, int fullscreen)
{
R_Printf(PRINT_ALL, "setting mode %d:", mode);
R_Printf(PRINT_ALL, "Setting mode %d:", mode);
/* mode -1 is not in the vid mode table - so we keep the values in pwidth
and pheight and don't even try to look up the mode info */
@ -1271,7 +1271,7 @@ Vkimp_SetMode(int *pwidth, int *pheight, int mode, int fullscreen)
}
}
R_Printf(PRINT_ALL, " %d %d\n", *pwidth, *pheight);
R_Printf(PRINT_ALL, " %dx%d (vid_fullscreen %i)\n", *pwidth, *pheight, fullscreen);
if (!ri.GLimp_InitGraphics(fullscreen, pwidth, pheight))
{
@ -1310,6 +1310,11 @@ qboolean R_SetMode (void)
vk_texturemode->modified = true;
vk_lmaptexturemode->modified = true;
/* a bit hackish approach to enable custom resolutions:
Glimp_SetMode needs these values set for mode -1 */
vid.width = r_customwidth->value;
vid.height = r_customheight->value;
if ((err = Vkimp_SetMode((int*)&vid.width, (int*)&vid.height, r_mode->value, fullscreen)) == rserr_ok)
{
vk_state.prev_mode = r_mode->value;

View file

@ -522,7 +522,7 @@ GLimp_InitGraphics(int fullscreen, int *pwidth, int *pheight)
}
/* Mkay, now the hard work. Let's create the window. */
cvar_t *gl_msaa_samples = Cvar_Get("gl_msaa_samples", "0", CVAR_ARCHIVE);
cvar_t *gl_msaa_samples = Cvar_Get("r_msaa_samples", "0", CVAR_ARCHIVE);
while (1)
{
@ -536,7 +536,7 @@ GLimp_InitGraphics(int fullscreen, int *pwidth, int *pheight)
(int) Cvar_VariableValue("r_mode"), width, height);
/* Try to recover */
Cvar_SetValue("gl_msaa_samples", 0);
Cvar_SetValue("r_msaa_samples", 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);

View file

@ -83,6 +83,11 @@ replacement_t replacements[] = {
{"gl_texturealphamode", "gl1_texturealphamode"},
{"gl_texturesolidmode", "gl1_texturesolidmode"},
{"gl_ztrick", "gl1_ztrick"},
{"gl_msaa_samples", "r_msaa_samples"},
{"gl_nolerp_list", "r_nolerp_list"},
{"gl_retexturing", "r_retexturing"},
{"gl_shadows", "r_shadows"},
{"gl_anisotropic", "r_anisotropic"},
{"intensity", "gl1_intensity"}
};