Remove pre-rotation work

This commit is contained in:
SSimco 2024-07-08 19:19:22 +03:00
parent bab67d7df0
commit bb10cfbf62
7 changed files with 13 additions and 77 deletions

View File

@ -338,7 +338,6 @@ void LatteShaderCache_Load()
if (g_renderer->GetType() == RendererAPI::Vulkan)
LatteShaderCache_LoadVulkanPipelineCache(cacheTitleId);
#if !__ANDROID__
g_renderer->BeginFrame(true);
if (g_renderer->ImguiBegin(true))
{
@ -351,7 +350,7 @@ void LatteShaderCache_Load()
LatteShaderCache_drawBackgroundImage(g_shaderCacheLoaderState.textureDRCId, 854, 480);
g_renderer->ImguiEnd();
}
#endif // __ANDROID__
g_renderer->SwapBuffers(true, true);
if (g_shaderCacheLoaderState.textureTVId)

View File

@ -302,9 +302,6 @@ out gl_PerVertex
{
vec4 gl_Position;
};)";
#if __ANDROID__
vertex_source << "layout (push_constant) uniform PushConstants { mat2 preRotate; } pushConstants;\n";
#endif // __ANDROID__
vertex_source << R"(void main(){
vec2 vPos;
vec2 vUV;
@ -335,11 +332,7 @@ out gl_PerVertex
}
vertex_source << "passUV = vUV;\n";
#if __ANDROID__
vertex_source << "gl_Position = vec4(pushConstants.preRotate * vPos, 0.0, 1.0);}";
#else
vertex_source << "gl_Position = vec4(vPos, 0.0, 1.0);}";
#endif // __ANDROID__
return vertex_source.str();
}
void RendererOutputShader::InitializeStatic()

View File

@ -12,9 +12,6 @@ void SwapchainInfoVk::Create(VkPhysicalDevice physicalDevice, VkDevice logicalDe
const auto details = QuerySwapchainSupport(surface, physicalDevice);
m_surfaceFormat = ChooseSurfaceFormat(details.formats);
m_actualExtent = ChooseSwapExtent(details.capabilities);
#if __ANDROID__
m_preTransform = details.capabilities.currentTransform;
#endif // __ANDROID__
// use at least two swapchain images. fewer than that causes problems on some drivers
uint32_t image_count = std::max(2u, details.capabilities.minImageCount);
@ -404,8 +401,11 @@ VkSwapchainCreateInfoKHR SwapchainInfoVk::CreateSwapchainCreateInfo(VkSurfaceKHR
}
else
createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
#if __ANDROID__
createInfo.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
#else
createInfo.preTransform = swapchainSupport.capabilities.currentTransform;
#endif
createInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
createInfo.presentMode = ChoosePresentMode(swapchainSupport.presentModes);
createInfo.clipped = VK_TRUE;

View File

@ -76,9 +76,6 @@ struct SwapchainInfoVk
bool m_usesSRGB = false;
VSync m_vsyncState = VSync::Immediate;
bool hasDefinedSwapchainImage{}; // indicates if the swapchain image is in a defined state
#if __ANDROID__
VkSurfaceTransformFlagBitsKHR m_preTransform{};
#endif // __ANDROID__
VkPhysicalDevice m_physicalDevice{};
VkDevice m_logicalDevice{};
VkSurfaceKHR surface{};

View File

@ -2646,13 +2646,6 @@ bool VulkanRenderer::AcquireNextSwapchainImage(bool mainWindow)
m_padCloseReadySemaphore.notify();
return false;
}
#if __ANDROID__
std::unique_lock lock(m_surfaceMutex);
m_surfaceCondVar.wait(lock,[&](){
auto& chainInfo = GetChainInfoPtr(mainWindow);
return chainInfo && chainInfo->surface;
});
#endif // __ANDROID__
auto& chainInfo = GetChainInfo(mainWindow);
if (chainInfo.swapchainImageIndex != -1)
@ -2774,9 +2767,14 @@ void VulkanRenderer::SwapBuffer(bool mainWindow)
{
throw std::runtime_error(fmt::format("Failed to present image: {}", result));
}
if(result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR)
if(result == VK_ERROR_OUT_OF_DATE_KHR)
chainInfo.m_shouldRecreate = true;
#if !__ANDROID__
if(result == VK_SUBOPTIMAL_KHR)
chainInfo.m_shouldRecreate = true;
#endif
chainInfo.hasDefinedSwapchainImage = false;
chainInfo.swapchainImageIndex = -1;
@ -2920,25 +2918,6 @@ void VulkanRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutpu
auto descriptSet = backbufferBlit_createDescriptorSet(m_swapchainDescriptorSetLayout, texViewVk, useLinearTexFilter);
vkCmdBeginRenderPass(m_state.currentCommandBuffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
#if __ANDROID__
float radians = 0.0f;
switch (chainInfo.m_preTransform)
{
case VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR:
radians = glm::radians(90.0f);
break;
case VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR:
radians = glm::radians(180.0f);
break;
case VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR:
radians = glm::radians(270.0f);
break;
default:
break;
}
const glm::mat2 preRotate = glm::rotate(glm::mat4(1.0), radians, glm::vec3(0.0F, 0.0F, 1.0F));
vkCmdPushConstants(m_state.currentCommandBuffer, m_pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(preRotate), &preRotate);
#endif // __ANDROID__
vkCmdBindPipeline(m_state.currentCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
m_state.currentPipeline = pipeline;
@ -3762,29 +3741,7 @@ void VulkanRenderer::AppendOverlayDebugInfo()
ImGui::Text("--- Tex heaps ---");
memoryManager->appendOverlayHeapDebugInfo();
}
#if __ANDROID__
void VulkanRenderer::ClearSurface(bool mainWindow)
{
std::lock_guard lock(m_surfaceMutex);
auto& chainInfo = GetChainInfoPtr(mainWindow);
if(!chainInfo || !chainInfo->surface)
return;
vkDestroySurfaceKHR(m_instance, chainInfo->surface, nullptr);
chainInfo->surface = nullptr;
}
void VulkanRenderer::NotifySurfaceChanged(bool mainWindow)
{
std::lock_guard lock(m_surfaceMutex);
auto& chainInfo = GetChainInfoPtr(mainWindow);
if(!chainInfo)
return;
if(mainWindow)
chainInfo->surface = CreateFramebufferSurface(m_instance, GuiSystem::getWindowInfo().canvas_main);
else
chainInfo->surface = CreateFramebufferSurface(m_instance, GuiSystem::getWindowInfo().canvas_pad);
m_surfaceCondVar.notify_one();
}
#endif // __ANDROID__
void VKRDestructibleObject::flagForCurrentCommandBuffer()
{
m_lastCmdBufferId = VulkanRenderer::GetInstance()->GetCurrentCommandBufferId();

View File

@ -184,10 +184,7 @@ public:
void GetDeviceFeatures();
void DetermineVendor();
void InitializeSurface(const Vector2i& size, bool mainWindow);
#if __ANDROID__
void ClearSurface(bool mainWindow);
void NotifySurfaceChanged(bool mainWindow);
#endif // __ANDROID
const std::unique_ptr<SwapchainInfoVk>& GetChainInfoPtr(bool mainWindow) const;
SwapchainInfoVk& GetChainInfo(bool mainWindow) const;
@ -607,11 +604,6 @@ private:
VkPipelineLayout m_pipelineLayout{nullptr};
VkCommandPool m_commandPool{ nullptr };
#if __ANDROID__
std::mutex m_surfaceMutex;
std::condition_variable m_surfaceCondVar;
#endif // __ANDROID__
// buffer to cache uniform vars
VkBuffer m_uniformVarBuffer = VK_NULL_HANDLE;
VkDeviceMemory m_uniformVarBufferMemory = VK_NULL_HANDLE;

View File

@ -54,12 +54,10 @@ class EmulationState {
void clearSurface(bool isMainCanvas)
{
VulkanRenderer::GetInstance()->ClearSurface(isMainCanvas);
}
void notifySurfaceChanged(bool isMainCanvas)
{
VulkanRenderer::GetInstance()->NotifySurfaceChanged(isMainCanvas);
}
void setSurface(JNIEnv* env, jobject surface, bool isMainCanvas)