Rework vk_msaa to use number of samples #646

This commit is contained in:
Denis Pauk 2021-01-19 21:39:13 +02:00
parent 2fae58d56b
commit 000c72fecc
2 changed files with 23 additions and 20 deletions

View File

@ -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

@ -1234,8 +1234,6 @@ R_Register( void )
// 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");
vid_fullscreen = ri.Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE);
vid_gamma = ri.Cvar_Get("vid_gamma", "1.0", CVAR_ARCHIVE);
@ -1251,7 +1249,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 +1269,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))
{