From 82ef0053eae727f0e6a5e7bc1a2f0708f1d52a8a Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Mon, 12 Oct 2026 08:04:46 -0400 Subject: [PATCH] [Fix] (DirectVulkan): express polygon facing as the pipeline front face --- .../DirectVulkan/Renderer/VulkanRenderer.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp b/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp index d823c9c7..eb680ede 100644 --- a/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp +++ b/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp @@ -3152,9 +3152,17 @@ namespace MobileGL::MG_Backend::DirectVulkan { .viewportCount = ResolveDrawViewportCount(programObj.writesViewportIndexBuiltin), .polygonMode = effectivePolygonMode, .cullMode = cullFaceEnabled - ? MG_Util::ConvertCullFaceModeToVkEnum(MG_Pipe::gPipeInputs->GetCullFaceMode(), invertClockwise) + ? MG_Util::ConvertCullFaceModeToVkEnum(MG_Pipe::gPipeInputs->GetCullFaceMode(), false) : VK_CULL_MODE_NONE, - .frontFace = VK_FRONT_FACE_CLOCKWISE, + // GL's counter-clockwise is Vulkan's clockwise (the two area formulas differ in sign + // over the same rows), and a Y-negated position - the default framebuffer's flip or + // an upper-left clip origin - reverses the winding once more. Expressed as the front + // face rather than as swapped cull bits so gl_FrontFacing agrees with culling, and + // so glFrontFace(GL_CW) is honoured. + .frontFace = ((MG_Pipe::gPipeInputs->GetRenderStateParameters().FrontFaceModeSetting == + FrontFaceMode::Clockwise) != invertClockwise) + ? VK_FRONT_FACE_COUNTER_CLOCKWISE + : VK_FRONT_FACE_CLOCKWISE, // Read the geometry stage off the program's own shader list rather than // programObj.rasterizationProducerStage: that field is filled by the clip-fixup analysis, // which does not run for every program, so it reads Unknown for exactly the