cancel
Showing results for 
Search instead for 
Did you mean: 

Vulkan driver bug when running PPSSPP on STM32MP257D

zhangtinglu
Associate III

I ported PPSSPP 1.20.3 to run on the STM32MP257D platform.
With the GLES backend, everything looks fine and normal games run without issues. But when I try heavier 3D games like Tekken 6, it gets extremely choppy – single-core CPU usage stays around 95%.

Then I tried switching to Vulkan. At first, the emulator crashed on startup. I debugged it by adding some print statements and found that a function call was returning an incorrect value – which shouldn't happen according to the Vulkan spec. Because of that, another function (vkCreateSwapchainKHR) ended up failing.

 1) PPSSPP Crash Log:

Spoiler

08:00:074 Vulkan/VulkanContext.cpp:1416 I[G3D]: surfCapabilities_.current: 960x544 min: 1x1 max: -1x-1 computed: -1x-1 
08:00:079 Vulkan/VulkanContext.cpp:1579 E[G3D]: vkCreateSwapchainKHR failed! VK_ERROR_DEVICE_LOST

 2) Source Files: ppsspp-1.20.3/Common/GPU/Vulkan/VulkanContext.h

VkResult res = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_devices_[physical_device_], surface_, &surfCapabilities_);
	if (res == VK_ERROR_SURFACE_LOST_KHR) {
		// Not much to do.
		ERROR_LOG(Log::G3D, "VK: Surface lost in InitSwapchain");
		return false;
	}
                                   .........

swapChainExtent_.width = clamp(currentExtent.width, surfCapabilities_.minImageExtent.width, surfCapabilities_.maxImageExtent.width);
	swapChainExtent_.height = clamp(currentExtent.height, surfCapabilities_.minImageExtent.height, surfCapabilities_.maxImageExtent.height);
                                   .........

INFO_LOG(Log::G3D, "surfCapabilities_.current: %dx%d min: %dx%d max: %dx%d computed: %dx%d",
		currentExtent.width, currentExtent.height,
		surfCapabilities_.minImageExtent.width, surfCapabilities_.minImageExtent.height,
		surfCapabilities_.maxImageExtent.width, surfCapabilities_.maxImageExtent.height,
		swapChainExtent_.width, swapChainExtent_.height);

                                   .........
VkSwapchainKHR oldSwapchain = swapchain_;

	VkSwapchainCreateInfoKHR swap_chain_info{ VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR };
	swap_chain_info.surface = surface_;
	swap_chain_info.minImageCount = desiredNumberOfSwapChainImages;
	swap_chain_info.imageFormat = swapchainFormat_;
	swap_chain_info.imageColorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
	swap_chain_info.imageExtent.width = swapChainExtent_.width;
	swap_chain_info.imageExtent.height = swapChainExtent_.height;
	swap_chain_info.preTransform = preTransform;
	swap_chain_info.imageArrayLayers = 1;
	swap_chain_info.presentMode = swapchainPresentMode;
	swap_chain_info.oldSwapchain = swapchain_;
	swap_chain_info.clipped = true;
	swap_chain_info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;

	presentMode_ = swapchainPresentMode;
                                .........
res = vkCreateSwapchainKHR(device_, &swap_chain_info, NULL, &swapchain_);
	if (res != VK_SUCCESS) {
		ERROR_LOG(Log::G3D, "vkCreateSwapchainKHR failed! %s", VulkanResultToString(res));
		return false;
	}

    I found that the values of surfCapabilities_.maxImageExtent.width and .height were both -1(max: -1x-1 computed: -1x-1 ), which does not conform to the Vulkan standard, and Vulkan simply couldn't work. So I forcibly modified both values to 4096 (the current resolution being used is 1270x720), and then the Vulkan driver was able to run.

zhangtinglu_0-1779074418786.png
    Vulkan started up properly, and the frame rate improved a lot – Tekken 6 runs at about 49 FPS now, with CPU usage dropping to 50%.

 

zhangtinglu_1-1779075016205.png

   Now I'm stuck with another issue: screen tearing. It shows up as random radial tears spreading outward from the center of the screen. This didn't happen with GLES. I've tried debugging but no luck. My guess is Vulkan 1.3.3 isn't fully supported on this platform yet. Any way to fix this?

0 REPLIES 0