diff --git a/MobileGL/MG_Backend/DirectVulkan/Renderer/PipelineFactory.cpp b/MobileGL/MG_Backend/DirectVulkan/Renderer/PipelineFactory.cpp index c779d47a..b2790ede 100644 --- a/MobileGL/MG_Backend/DirectVulkan/Renderer/PipelineFactory.cpp +++ b/MobileGL/MG_Backend/DirectVulkan/Renderer/PipelineFactory.cpp @@ -21,6 +21,8 @@ namespace MobileGL::MG_Backend::DirectVulkan { XXHASH_VERIFY(XXH64_update(m_hashState, &payload.renderPass, sizeof(payload.renderPass))); XXHASH_VERIFY(XXH64_update(m_hashState, &payload.subpass, sizeof(payload.subpass))); XXHASH_VERIFY(XXH64_update(m_hashState, &payload.topology, sizeof(payload.topology))); + XXHASH_VERIFY(XXH64_update(m_hashState, &payload.cullMode, sizeof(payload.cullMode))); + XXHASH_VERIFY(XXH64_update(m_hashState, &payload.frontFace, sizeof(payload.frontFace))); XXHASH_VERIFY(XXH64_update(m_hashState, &payload.depthTestEnable, sizeof(payload.depthTestEnable))); XXHASH_VERIFY(XXH64_update(m_hashState, &payload.depthWriteEnable, sizeof(payload.depthWriteEnable))); XXHASH_VERIFY(XXH64_update(m_hashState, &payload.depthCompareOp, sizeof(payload.depthCompareOp))); @@ -79,8 +81,8 @@ namespace MobileGL::MG_Backend::DirectVulkan { VkPipelineRasterizationStateCreateInfo raster{VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO}; raster.polygonMode = VK_POLYGON_MODE_FILL; - raster.cullMode = VK_CULL_MODE_NONE; - raster.frontFace = VK_FRONT_FACE_CLOCKWISE; + raster.cullMode = payload.cullMode; + raster.frontFace = payload.frontFace; raster.lineWidth = 1.0f; VkPipelineMultisampleStateCreateInfo ms{VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO}; diff --git a/MobileGL/MG_Backend/DirectVulkan/Renderer/PipelineFactory.h b/MobileGL/MG_Backend/DirectVulkan/Renderer/PipelineFactory.h index 14aa3372..54039081 100644 --- a/MobileGL/MG_Backend/DirectVulkan/Renderer/PipelineFactory.h +++ b/MobileGL/MG_Backend/DirectVulkan/Renderer/PipelineFactory.h @@ -24,6 +24,8 @@ namespace MobileGL::MG_Backend::DirectVulkan { VkRenderPass renderPass = VK_NULL_HANDLE; Uint32 subpass = 0; VkPrimitiveTopology topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + VkCullModeFlags cullMode = VK_CULL_MODE_NONE; + VkFrontFace frontFace = VK_FRONT_FACE_CLOCKWISE; Bool depthTestEnable = false; Bool depthWriteEnable = false; VkCompareOp depthCompareOp = VK_COMPARE_OP_ALWAYS; diff --git a/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp b/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp index ef0afed9..71bdbd75 100644 --- a/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp +++ b/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp @@ -348,6 +348,7 @@ namespace MobileGL::MG_Backend::DirectVulkan { auto& vis = m_vertexInputStateFactory->GetOrCreateVertexInputState(vao); auto pipelineLayout = m_uniformDescriptorBinder->GetOrCreatePipelineLayout(program); auto& renderPassEntry = m_renderPassManager->GetOrCreateRenderPass(drawFbo, m_imageIndexAcquired); + auto cullFaceEnabled = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::CullFace); auto depthTestEnabled = MG_State::pGLContext->IsCapabilityEnabled(CapabilityInput::DepthTest); BlendFactor srcRGB = BlendFactor::One; BlendFactor dstRGB = BlendFactor::Zero; @@ -363,6 +364,11 @@ namespace MobileGL::MG_Backend::DirectVulkan { .renderPass = renderPassEntry.renderPass, .subpass = 0, .topology = MG_Util::ConvertPrimitiveModeToVkEnum(mode), +// .cullMode = cullFaceEnabled +// ? MG_Util::ConvertCullFaceModeToVkEnum(MG_State::pGLContext->GetCullFaceMode()) +// : VK_CULL_MODE_NONE, + .cullMode = VK_CULL_MODE_NONE, + .frontFace = VK_FRONT_FACE_CLOCKWISE, .depthTestEnable = depthTestEnabled, .depthWriteEnable = depthTestEnabled && MG_State::pGLContext->GetDepthMask(), .depthCompareOp = MG_Util::ConvertDepthTestFuncToVkEnum(MG_State::pGLContext->GetDepthFunc()), diff --git a/MobileGL/MG_Util/Converters/MGToVk/RenderStateEnumConverter.cpp b/MobileGL/MG_Util/Converters/MGToVk/RenderStateEnumConverter.cpp index 23df7906..e7b3ffce 100644 --- a/MobileGL/MG_Util/Converters/MGToVk/RenderStateEnumConverter.cpp +++ b/MobileGL/MG_Util/Converters/MGToVk/RenderStateEnumConverter.cpp @@ -31,6 +31,22 @@ namespace MobileGL { } } + VkCullModeFlags ConvertCullFaceModeToVkEnum(CullFaceMode v) { + switch (v) { + case CullFaceMode::Front: + return VK_CULL_MODE_FRONT_BIT; + case CullFaceMode::Back: + return VK_CULL_MODE_BACK_BIT; + case CullFaceMode::FrontAndBack: + return VK_CULL_MODE_FRONT_AND_BACK; + case CullFaceMode::Unknown: + case CullFaceMode::CullFaceModeCount: + default: + MGLOG_W("Unrecognized cull face mode"); + return VK_CULL_MODE_BACK_BIT; + } + } + VkCompareOp ConvertDepthTestFuncToVkEnum(DepthTestFunc v) { switch (v) { case DepthTestFunc::Never: diff --git a/MobileGL/MG_Util/Converters/MGToVk/RenderStateEnumConverter.h b/MobileGL/MG_Util/Converters/MGToVk/RenderStateEnumConverter.h index 53d8ad79..ecc5fead 100644 --- a/MobileGL/MG_Util/Converters/MGToVk/RenderStateEnumConverter.h +++ b/MobileGL/MG_Util/Converters/MGToVk/RenderStateEnumConverter.h @@ -13,6 +13,7 @@ namespace MobileGL { namespace MG_Util { VkPrimitiveTopology ConvertPrimitiveModeToVkEnum(GLenum mode); + VkCullModeFlags ConvertCullFaceModeToVkEnum(CullFaceMode value); VkCompareOp ConvertDepthTestFuncToVkEnum(DepthTestFunc value); VkBlendFactor ConvertBlendFactorToVkEnum(BlendFactor value); } // namespace MG_Util