[Fix] (MG_State/PSO, GLSLTool): revert to flip y in shader

This commit is contained in:
2025-06-24 17:36:45 +08:00
parent 0c031d3e0b
commit a18360c931
2 changed files with 12 additions and 5 deletions
@@ -268,9 +268,8 @@ namespace MG_Diligent {
depthStencilDesc.DepthFunc = ConvertGLDepthFunc(commonState.depthFunc); depthStencilDesc.DepthFunc = ConvertGLDepthFunc(commonState.depthFunc);
Diligent::RasterizerStateDesc &rasterizerDesc = PSOCreateInfo.GraphicsPipeline.RasterizerDesc; Diligent::RasterizerStateDesc &rasterizerDesc = PSOCreateInfo.GraphicsPipeline.RasterizerDesc;
// rasterizerDesc.CullMode = commonState.capabilities[GL_CULL_FACE] ? rasterizerDesc.CullMode = commonState.capabilities[GL_CULL_FACE] ?
// Diligent::CULL_MODE_BACK : Diligent::CULL_MODE_NONE; Diligent::CULL_MODE_BACK : Diligent::CULL_MODE_NONE;
rasterizerDesc.CullMode = Diligent::CULL_MODE_NONE;
rasterizerDesc.FrontCounterClockwise = false; rasterizerDesc.FrontCounterClockwise = false;
// TODO: Get correct FrontCounterClockwise state and re-enable backface culling. // TODO: Get correct FrontCounterClockwise state and re-enable backface culling.
@@ -702,7 +701,7 @@ namespace MG_EGL::Diligent {
::Diligent::SwapChainDesc SCDesc; ::Diligent::SwapChainDesc SCDesc;
SCDesc.ColorBufferFormat = TEX_FORMAT_RGBA8_UNORM; 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"); MG_Util::Debug::LogD("Creating Vulkan device and contexts");
pFactoryVk->CreateDeviceAndContextsVk( pFactoryVk->CreateDeviceAndContextsVk(
@@ -929,6 +928,14 @@ namespace MG_EGL::Diligent {
} }
const auto& SCDesc = MG_Diligent::g_pSwapChain->GetDesc(); const auto& SCDesc = MG_Diligent::g_pSwapChain->GetDesc();
MG_Util::Debug::LogD("Setting viewport: width=%d, height=%d", SCDesc.Width, SCDesc.Height); 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); MG_Diligent::g_pContext->SetViewports(1, nullptr, 0, 0);
return EGL_TRUE; return EGL_TRUE;
} }
+1 -1
View File
@@ -112,7 +112,7 @@ namespace MG_Util::Program {
// TODO: Use other methods to implement clip space fixing. // TODO: Use other methods to implement clip space fixing.
size_t pos = output_glsl.find("\n gl_Position.y = -gl_Position.y;\n}"); size_t pos = output_glsl.find("\n gl_Position.y = -gl_Position.y;\n}");
if (pos != std::string::npos) { 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; return output_glsl;
} }