From 5570e2c06b4dc69e91053c1f180a0f3cd6d8c5e6 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 30 Jan 2023 20:11:55 -0600 Subject: [PATCH] nvk: Flip the front-face setting Part-of: --- src/nouveau/vulkan/nvk_cmd_draw.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/nouveau/vulkan/nvk_cmd_draw.c b/src/nouveau/vulkan/nvk_cmd_draw.c index 559e5ebc05a..784fa26e879 100644 --- a/src/nouveau/vulkan/nvk_cmd_draw.c +++ b/src/nouveau/vulkan/nvk_cmd_draw.c @@ -772,13 +772,18 @@ vk_to_nv9097_cull_mode(VkCullModeFlags vk_cull_mode) static uint32_t vk_to_nv9097_front_face(VkFrontFace vk_face) { + /* Vulkan and OpenGL are backwards here because Vulkan assumes the D3D + * convention in which framebuffer coordinates always start in the upper + * left while OpenGL has framebuffer coordinates starting in the lower + * left. Therefore, we want the reverse of the hardware enum name. + */ ASSERTED static const uint16_t vk_to_nv9097[] = { - [VK_FRONT_FACE_COUNTER_CLOCKWISE] = NV9097_OGL_SET_FRONT_FACE_V_CW, - [VK_FRONT_FACE_CLOCKWISE] = NV9097_OGL_SET_FRONT_FACE_V_CCW, + [VK_FRONT_FACE_COUNTER_CLOCKWISE] = NV9097_OGL_SET_FRONT_FACE_V_CCW, + [VK_FRONT_FACE_CLOCKWISE] = NV9097_OGL_SET_FRONT_FACE_V_CW, }; assert(vk_face < ARRAY_SIZE(vk_to_nv9097)); - uint32_t nv9097_face = 0x900 | vk_face; + uint32_t nv9097_face = 0x900 | (1 - vk_face); assert(nv9097_face == vk_to_nv9097[vk_face]); return nv9097_face; }