mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
[Fix] (MG_Backend/DirectVulkan): fix 1.21.6+ intermittent crashing
- Try coerce vertex input format to please Vulkan driver - Skip inactive UBO instead of hard fast-fail
This commit is contained in:
@@ -1376,14 +1376,13 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
|||||||
"ProgramFactory::ReflectLayout: UBO binding %u exceeds maxBindings=%u for '%s'",
|
"ProgramFactory::ReflectLayout: UBO binding %u exceeds maxBindings=%u for '%s'",
|
||||||
binding, m_maxBindings, ubo.name.c_str());
|
binding, m_maxBindings, ubo.name.c_str());
|
||||||
|
|
||||||
MOBILEGL_ASSERT(entry.bindingKinds[binding] == DescriptorBindingKind::None ||
|
|
||||||
entry.bindingKinds[binding] == DescriptorBindingKind::UniformBufferDynamic,
|
|
||||||
"ProgramFactory::ReflectLayout: descriptor binding %u has conflicting kinds for UBO '%s'",
|
|
||||||
binding, ubo.name.c_str());
|
|
||||||
entry.bindingKinds[binding] = DescriptorBindingKind::UniformBufferDynamic;
|
|
||||||
|
|
||||||
// Check for global UBO
|
// Check for global UBO
|
||||||
if (std::strstr(ubo.name.c_str(), MG_Util::ShaderTranspiler::GLOBAL_UBO_NAME) != nullptr) {
|
if (std::strstr(ubo.name.c_str(), MG_Util::ShaderTranspiler::GLOBAL_UBO_NAME) != nullptr) {
|
||||||
|
MOBILEGL_ASSERT(entry.bindingKinds[binding] == DescriptorBindingKind::None ||
|
||||||
|
entry.bindingKinds[binding] == DescriptorBindingKind::UniformBufferDynamic,
|
||||||
|
"ProgramFactory::ReflectLayout: descriptor binding %u has conflicting kinds for UBO '%s'",
|
||||||
|
binding, ubo.name.c_str());
|
||||||
|
entry.bindingKinds[binding] = DescriptorBindingKind::UniformBufferDynamic;
|
||||||
MOBILEGL_ASSERT(entry.globalUboBinding < 0 || entry.globalUboBinding == static_cast<Int>(binding),
|
MOBILEGL_ASSERT(entry.globalUboBinding < 0 || entry.globalUboBinding == static_cast<Int>(binding),
|
||||||
"ProgramFactory::ReflectLayout: global UBO binding mismatch (%d vs %u)",
|
"ProgramFactory::ReflectLayout: global UBO binding mismatch (%d vs %u)",
|
||||||
entry.globalUboBinding, binding);
|
entry.globalUboBinding, binding);
|
||||||
@@ -1395,8 +1394,17 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Uint blockIndex = program.GetUniformBlockIndex(ubo.name.c_str());
|
const Uint blockIndex = program.GetUniformBlockIndex(ubo.name.c_str());
|
||||||
MOBILEGL_ASSERT(blockIndex != 0xFFFFFFFFu,
|
if (blockIndex == 0xFFFFFFFFu) {
|
||||||
"ProgramFactory::ReflectLayout: failed to resolve uniform block '%s'", ubo.name.c_str());
|
MGLOG_D("ProgramFactory::ReflectLayout: skipping inactive UBO '%s' at binding %u",
|
||||||
|
ubo.name.c_str(), binding);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MOBILEGL_ASSERT(entry.bindingKinds[binding] == DescriptorBindingKind::None ||
|
||||||
|
entry.bindingKinds[binding] == DescriptorBindingKind::UniformBufferDynamic,
|
||||||
|
"ProgramFactory::ReflectLayout: descriptor binding %u has conflicting kinds for UBO '%s'",
|
||||||
|
binding, ubo.name.c_str());
|
||||||
|
entry.bindingKinds[binding] = DescriptorBindingKind::UniformBufferDynamic;
|
||||||
MOBILEGL_ASSERT(entry.globalUboBinding != static_cast<Int>(binding),
|
MOBILEGL_ASSERT(entry.globalUboBinding != static_cast<Int>(binding),
|
||||||
"ProgramFactory::ReflectLayout: regular UBO '%s' collides with global UBO binding %u",
|
"ProgramFactory::ReflectLayout: regular UBO '%s' collides with global UBO binding %u",
|
||||||
ubo.name.c_str(), binding);
|
ubo.name.c_str(), binding);
|
||||||
|
|||||||
@@ -207,82 +207,106 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
|||||||
outFormat = sourceFormat;
|
outFormat = sourceFormat;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (sourceDomain == NumericDomain::FloatLike || targetDomain == NumericDomain::FloatLike) {
|
if (sourceDomain == NumericDomain::FloatLike) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (sourceFormat) {
|
switch (sourceFormat) {
|
||||||
case VK_FORMAT_R32_SINT:
|
case VK_FORMAT_R32_SINT:
|
||||||
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R32_UINT : sourceFormat;
|
if (targetDomain == NumericDomain::Uint) {
|
||||||
return true;
|
outFormat = VK_FORMAT_R32_UINT;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
case VK_FORMAT_R32G32_SINT:
|
case VK_FORMAT_R32G32_SINT:
|
||||||
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R32G32_UINT : sourceFormat;
|
if (targetDomain == NumericDomain::Uint) {
|
||||||
return true;
|
outFormat = VK_FORMAT_R32G32_UINT;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
case VK_FORMAT_R32G32B32_SINT:
|
case VK_FORMAT_R32G32B32_SINT:
|
||||||
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R32G32B32_UINT : sourceFormat;
|
if (targetDomain == NumericDomain::Uint) {
|
||||||
return true;
|
outFormat = VK_FORMAT_R32G32B32_UINT;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
case VK_FORMAT_R32G32B32A32_SINT:
|
case VK_FORMAT_R32G32B32A32_SINT:
|
||||||
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R32G32B32A32_UINT : sourceFormat;
|
if (targetDomain == NumericDomain::Uint) {
|
||||||
return true;
|
outFormat = VK_FORMAT_R32G32B32A32_UINT;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
case VK_FORMAT_R32_UINT:
|
case VK_FORMAT_R32_UINT:
|
||||||
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R32_SINT : sourceFormat;
|
if (targetDomain == NumericDomain::Sint) {
|
||||||
return true;
|
outFormat = VK_FORMAT_R32_SINT;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
case VK_FORMAT_R32G32_UINT:
|
case VK_FORMAT_R32G32_UINT:
|
||||||
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R32G32_SINT : sourceFormat;
|
if (targetDomain == NumericDomain::Sint) {
|
||||||
return true;
|
outFormat = VK_FORMAT_R32G32_SINT;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
case VK_FORMAT_R32G32B32_UINT:
|
case VK_FORMAT_R32G32B32_UINT:
|
||||||
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R32G32B32_SINT : sourceFormat;
|
if (targetDomain == NumericDomain::Sint) {
|
||||||
return true;
|
outFormat = VK_FORMAT_R32G32B32_SINT;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
case VK_FORMAT_R32G32B32A32_UINT:
|
case VK_FORMAT_R32G32B32A32_UINT:
|
||||||
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R32G32B32A32_SINT : sourceFormat;
|
if (targetDomain == NumericDomain::Sint) {
|
||||||
return true;
|
outFormat = VK_FORMAT_R32G32B32A32_SINT;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
case VK_FORMAT_R16_SINT:
|
case VK_FORMAT_R16_SINT:
|
||||||
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R16_UINT : sourceFormat;
|
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R16_UINT : VK_FORMAT_R16_SSCALED;
|
||||||
return true;
|
return true;
|
||||||
case VK_FORMAT_R16G16_SINT:
|
case VK_FORMAT_R16G16_SINT:
|
||||||
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R16G16_UINT : sourceFormat;
|
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R16G16_UINT : VK_FORMAT_R16G16_SSCALED;
|
||||||
return true;
|
return true;
|
||||||
case VK_FORMAT_R16G16B16_SINT:
|
case VK_FORMAT_R16G16B16_SINT:
|
||||||
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R16G16B16_UINT : sourceFormat;
|
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R16G16B16_UINT : VK_FORMAT_R16G16B16_SSCALED;
|
||||||
return true;
|
return true;
|
||||||
case VK_FORMAT_R16G16B16A16_SINT:
|
case VK_FORMAT_R16G16B16A16_SINT:
|
||||||
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R16G16B16A16_UINT : sourceFormat;
|
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R16G16B16A16_UINT : VK_FORMAT_R16G16B16A16_SSCALED;
|
||||||
return true;
|
return true;
|
||||||
case VK_FORMAT_R16_UINT:
|
case VK_FORMAT_R16_UINT:
|
||||||
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R16_SINT : sourceFormat;
|
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R16_SINT : VK_FORMAT_R16_USCALED;
|
||||||
return true;
|
return true;
|
||||||
case VK_FORMAT_R16G16_UINT:
|
case VK_FORMAT_R16G16_UINT:
|
||||||
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R16G16_SINT : sourceFormat;
|
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R16G16_SINT : VK_FORMAT_R16G16_USCALED;
|
||||||
return true;
|
return true;
|
||||||
case VK_FORMAT_R16G16B16_UINT:
|
case VK_FORMAT_R16G16B16_UINT:
|
||||||
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R16G16B16_SINT : sourceFormat;
|
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R16G16B16_SINT : VK_FORMAT_R16G16B16_USCALED;
|
||||||
return true;
|
return true;
|
||||||
case VK_FORMAT_R16G16B16A16_UINT:
|
case VK_FORMAT_R16G16B16A16_UINT:
|
||||||
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R16G16B16A16_SINT : sourceFormat;
|
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R16G16B16A16_SINT : VK_FORMAT_R16G16B16A16_USCALED;
|
||||||
return true;
|
return true;
|
||||||
case VK_FORMAT_R8_SINT:
|
case VK_FORMAT_R8_SINT:
|
||||||
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R8_UINT : sourceFormat;
|
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R8_UINT : VK_FORMAT_R8_SSCALED;
|
||||||
return true;
|
return true;
|
||||||
case VK_FORMAT_R8G8_SINT:
|
case VK_FORMAT_R8G8_SINT:
|
||||||
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R8G8_UINT : sourceFormat;
|
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R8G8_UINT : VK_FORMAT_R8G8_SSCALED;
|
||||||
return true;
|
return true;
|
||||||
case VK_FORMAT_R8G8B8_SINT:
|
case VK_FORMAT_R8G8B8_SINT:
|
||||||
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R8G8B8_UINT : sourceFormat;
|
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R8G8B8_UINT : VK_FORMAT_R8G8B8_SSCALED;
|
||||||
return true;
|
return true;
|
||||||
case VK_FORMAT_R8G8B8A8_SINT:
|
case VK_FORMAT_R8G8B8A8_SINT:
|
||||||
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R8G8B8A8_UINT : sourceFormat;
|
outFormat = targetDomain == NumericDomain::Uint ? VK_FORMAT_R8G8B8A8_UINT : VK_FORMAT_R8G8B8A8_SSCALED;
|
||||||
return true;
|
return true;
|
||||||
case VK_FORMAT_R8_UINT:
|
case VK_FORMAT_R8_UINT:
|
||||||
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R8_SINT : sourceFormat;
|
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R8_SINT : VK_FORMAT_R8_USCALED;
|
||||||
return true;
|
return true;
|
||||||
case VK_FORMAT_R8G8_UINT:
|
case VK_FORMAT_R8G8_UINT:
|
||||||
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R8G8_SINT : sourceFormat;
|
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R8G8_SINT : VK_FORMAT_R8G8_USCALED;
|
||||||
return true;
|
return true;
|
||||||
case VK_FORMAT_R8G8B8_UINT:
|
case VK_FORMAT_R8G8B8_UINT:
|
||||||
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R8G8B8_SINT : sourceFormat;
|
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R8G8B8_SINT : VK_FORMAT_R8G8B8_USCALED;
|
||||||
return true;
|
return true;
|
||||||
case VK_FORMAT_R8G8B8A8_UINT:
|
case VK_FORMAT_R8G8B8A8_UINT:
|
||||||
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R8G8B8A8_SINT : sourceFormat;
|
outFormat = targetDomain == NumericDomain::Sint ? VK_FORMAT_R8G8B8A8_SINT : VK_FORMAT_R8G8B8A8_USCALED;
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user