Fix vulkan swap modes for nvidia

CMakeLists edits

Check for linear tiling support for all usage attributes
This commit is contained in:
kd-11 2016-03-08 00:21:28 +03:00
parent f384d87044
commit d910d2c572
3 changed files with 59 additions and 11 deletions

View File

@ -191,7 +191,7 @@ if(WIN32) # I'm not sure we need all of these libs, but we link them in vs
else()
target_link_libraries(rpcs3 dxgi.lib d2d1.lib dwrite.lib)
endif()
target_link_libraries(rpcs3 asmjit.lib avformat.lib avcodec.lib avutil.lib swresample.lib swscale.lib png16_static ${wxWidgets_LIBRARIES} ${OPENAL_LIBRARY} ${ADDITIONAL_LIBS} vulkan glslang OSDependent OGLCompiler SPIRV)
target_link_libraries(rpcs3 asmjit.lib avformat.lib avcodec.lib avutil.lib swresample.lib swscale.lib png16_static ${wxWidgets_LIBRARIES} ${OPENAL_LIBRARY} ${ADDITIONAL_LIBS} ${vulkan} ${glslang} ${OSDependent} ${OGLCompiler} ${SPIRV})
else()
if(LLVM_FOUND)
target_link_libraries(rpcs3 asmjit.a ${wxWidgets_LIBRARIES} ${OPENAL_LIBRARY} ${GLEW_LIBRARY} ${OPENGL_LIBRARIES})

View File

@ -726,7 +726,29 @@ namespace vk
height = surface_descriptors.currentExtent.height;
}
VkPresentModeKHR swapchain_present_mode = VK_PRESENT_MODE_IMMEDIATE_KHR;
uint32_t nb_available_modes = 0;
CHECK_RESULT(vkGetPhysicalDeviceSurfacePresentModesKHR(gpu, m_surface, &nb_available_modes, nullptr));
std::vector<VkPresentModeKHR> present_modes(nb_available_modes);
CHECK_RESULT(vkGetPhysicalDeviceSurfacePresentModesKHR(gpu, m_surface, &nb_available_modes, present_modes.data()));
VkPresentModeKHR swapchain_present_mode = VK_PRESENT_MODE_FIFO_KHR;
for (VkPresentModeKHR mode : present_modes)
{
if (mode == VK_PRESENT_MODE_MAILBOX_KHR)
{
//If we can get a mailbox mode, use it
swapchain_present_mode = mode;
break;
}
//If we can get out of using the FIFO mode, take it. Fifo is very high latency (generic vsync)
if (swapchain_present_mode == VK_PRESENT_MODE_FIFO_KHR &&
(mode == VK_PRESENT_MODE_IMMEDIATE_KHR || mode == VK_PRESENT_MODE_FIFO_RELAXED_KHR))
swapchain_present_mode = mode;
}
uint32_t nb_swap_images = surface_descriptors.minImageCount + 1;
if ((surface_descriptors.maxImageCount > 0) && (nb_swap_images > surface_descriptors.maxImageCount))

View File

@ -233,18 +233,44 @@ namespace vk
{
VkImageTiling tiling = VK_IMAGE_TILING_OPTIMAL;
if (usage & VK_IMAGE_USAGE_SAMPLED_BIT)
{
VkFormatProperties props;
vkGetPhysicalDeviceFormatProperties(device.gpu(), format, &props);
/* The spec mandates checking against all usage bits for support in either linear or optimal tiling modes.
* Ideally, no assumptions should be made, but for simplification, we'll assume optimal mode suppoorts everything
*/
//Enable linear tiling if supported and we request a sampled image..
if (props.linearTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)
tiling = VK_IMAGE_TILING_LINEAR;
else
usage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
VkFormatProperties props;
vkGetPhysicalDeviceFormatProperties(device.gpu(), format, &props);
bool linear_is_supported = true;
if (!!(usage & VK_IMAGE_USAGE_SAMPLED_BIT))
{
if (!(props.linearTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))
linear_is_supported = false;
}
if (linear_is_supported && !!(usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT))
{
if (!(props.linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
linear_is_supported = false;
}
if (linear_is_supported && !!(usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT))
{
if (!(props.linearTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
linear_is_supported = false;
}
if (linear_is_supported && !!(usage & VK_IMAGE_USAGE_STORAGE_BIT))
{
if (!(props.linearTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT))
linear_is_supported = false;
}
if (linear_is_supported)
tiling = VK_IMAGE_TILING_LINEAR;
else
usage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
create(device, format, usage, tiling, width, height, mipmaps, gpu_only, swizzle);
}