diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index 8ba5a8f38c..47368c5071 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -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}) diff --git a/rpcs3/Emu/RSX/VK/VKHelpers.h b/rpcs3/Emu/RSX/VK/VKHelpers.h index 43dc9f2e3b..51427acb87 100644 --- a/rpcs3/Emu/RSX/VK/VKHelpers.h +++ b/rpcs3/Emu/RSX/VK/VKHelpers.h @@ -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 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)) diff --git a/rpcs3/Emu/RSX/VK/VKTexture.cpp b/rpcs3/Emu/RSX/VK/VKTexture.cpp index 718897c366..1232669695 100644 --- a/rpcs3/Emu/RSX/VK/VKTexture.cpp +++ b/rpcs3/Emu/RSX/VK/VKTexture.cpp @@ -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); }