mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-07 19:58:32 +09:00
[Feat] (MG_Backend/DirectVulkan): integrating cullmode and frontface render state into vk pipeline
This commit is contained in:
@@ -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};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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()),
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user