Forums - Vulkan x and y directions swapped.

2 posts / 0 new
Last post
Vulkan x and y directions swapped.
choco3.1415
Join Date: 28 Feb 19
Posts: 2
Posted: Thu, 2019-02-28 12:06

Hi,  I am developing a game for android using the Vulkan APIs.  For the most part things work fine, however, on some devices, I have this problem where the x and y coordinates are switched.  I draw on what I think of as the top of the screen, and it draws the objects on the side.  Also, when I do anything with the view point (the view matrix), x and y are reversed.  If I move the view point in the x direction, it actually moves in the y direction.

Also, the width and height reported by the swap chain are reversed.  So that if I plug these values into the perspective matrix like so:

glm::perspective(glm::radians(60.0f), swapchainRetrievedWidth / (float) swapchainRetrievedHeight, 0.1f, 10.0f);

it will draw horribly skewed objects.  But if I reverse the width and height, like so:

glm::perspective(glm::radians(60.0f), swapchainRetrievedHeight / (float) swapchainRetrievedWidth, 0.1f, 10.0f);

The objects look fine.

One device where this happens on is using an Adreno 530, API version 1.0.49, driver version: 35.143.1455, OS: android 8.0, phone vendor: HTC.  For this device, these symptoms only occur if the device is using the split screen mode with the device held in landscape orientation (the app forces portrait mode).  I've seen this happen on other devices too and in the full screen (not split screen) mode.  So, I don't think it is the way I reinitialized the swap chain, pipeline, depth buffer, render pass and command buffers when the screen size changes.  Since the screen would not change size for the devices where this problem occurs in full screen mode.

Am I doing something wrong?  Is there a bug?  I am willing to give more information on this problem, but do not know what is needed.  Thanks for all your support and help.

  • Up0
  • Down0
choco3.1415
Join Date: 28 Feb 19
Posts: 2
Posted: Fri, 2019-03-01 10:52

The problem was that I was just setting VkSwapchainCreateInfoKHR::preTransform to VkSurfaceCapabilitiesKHR::currentTransform, and then doing no transform.  I needed to check the value of VkSurfaceCapabilitiesKHR::currentTransform, set VkSwapchainCreateInfoKHR::preTransform to that (for performance reasons) and then do the stated transformation.

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.