From a18360c93140551f062c8fd853e40641e6f91527 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Tue, 24 Jun 2025 17:36:45 +0800 Subject: [PATCH] [Fix] (MG_State/PSO, GLSLTool): revert to flip y in shader --- .../Implementations/EGL/Diligent/EGL_impl.cpp | 15 +++++++++++---- MG/MG_UTIL/Program/GLSLTool.cpp | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/MG/MG_GL/Implementations/EGL/Diligent/EGL_impl.cpp b/MG/MG_GL/Implementations/EGL/Diligent/EGL_impl.cpp index bcd170b1..9768b1b0 100644 --- a/MG/MG_GL/Implementations/EGL/Diligent/EGL_impl.cpp +++ b/MG/MG_GL/Implementations/EGL/Diligent/EGL_impl.cpp @@ -268,9 +268,8 @@ namespace MG_Diligent { depthStencilDesc.DepthFunc = ConvertGLDepthFunc(commonState.depthFunc); Diligent::RasterizerStateDesc &rasterizerDesc = PSOCreateInfo.GraphicsPipeline.RasterizerDesc; -// rasterizerDesc.CullMode = commonState.capabilities[GL_CULL_FACE] ? -// Diligent::CULL_MODE_BACK : Diligent::CULL_MODE_NONE; - rasterizerDesc.CullMode = Diligent::CULL_MODE_NONE; + rasterizerDesc.CullMode = commonState.capabilities[GL_CULL_FACE] ? + Diligent::CULL_MODE_BACK : Diligent::CULL_MODE_NONE; rasterizerDesc.FrontCounterClockwise = false; // TODO: Get correct FrontCounterClockwise state and re-enable backface culling. @@ -702,7 +701,7 @@ namespace MG_EGL::Diligent { ::Diligent::SwapChainDesc SCDesc; SCDesc.ColorBufferFormat = TEX_FORMAT_RGBA8_UNORM; - SCDesc.PreTransform = SURFACE_TRANSFORM_IDENTITY; + SCDesc.PreTransform = SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180; MG_Util::Debug::LogD("Creating Vulkan device and contexts"); pFactoryVk->CreateDeviceAndContextsVk( @@ -929,6 +928,14 @@ namespace MG_EGL::Diligent { } const auto& SCDesc = MG_Diligent::g_pSwapChain->GetDesc(); MG_Util::Debug::LogD("Setting viewport: width=%d, height=%d", SCDesc.Width, SCDesc.Height); + +// ::Diligent::Viewport viewport; +// viewport.TopLeftX = 0.f; +// viewport.TopLeftY = SCDesc.Height; +// viewport.Width = SCDesc.Width; +// viewport.Height = SCDesc.Height; +// viewport.MinDepth = 0.f; +// viewport.MaxDepth = 1.f; MG_Diligent::g_pContext->SetViewports(1, nullptr, 0, 0); return EGL_TRUE; } diff --git a/MG/MG_UTIL/Program/GLSLTool.cpp b/MG/MG_UTIL/Program/GLSLTool.cpp index 17e7f5e3..d9552ed3 100644 --- a/MG/MG_UTIL/Program/GLSLTool.cpp +++ b/MG/MG_UTIL/Program/GLSLTool.cpp @@ -112,7 +112,7 @@ namespace MG_Util::Program { // TODO: Use other methods to implement clip space fixing. size_t pos = output_glsl.find("\n gl_Position.y = -gl_Position.y;\n}"); if (pos != std::string::npos) { - output_glsl.replace(pos, strlen("\n gl_Position.y = -gl_Position.y;\n}"), "\n gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n}"); + output_glsl.replace(pos, strlen("\n gl_Position.y = -gl_Position.y;\n}"), "\n gl_Position.y = -gl_Position.y;\n gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n}"); } return output_glsl; }