mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-07 19:58:32 +09:00
[Fix] (MG_State/Program): properly invoke SPIR-V sanitize routine
This commit is contained in:
@@ -899,41 +899,41 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
source = ForceSupporterOutput(source);
|
||||
|
||||
// TODO: probably a patch system?
|
||||
String findStr = "if (distance_weight_sum == 0.0)";
|
||||
String replaceStr = "if (distance_weight_sum <= 0.0001)";
|
||||
auto pos = source.find(findStr);
|
||||
while (pos != String::npos) {
|
||||
MGLOG_D("Applying patch #1 to Photon...");
|
||||
source.replace(pos, findStr.length(), replaceStr);
|
||||
pos = source.find(findStr, pos);
|
||||
}
|
||||
// String findStr = "if (distance_weight_sum == 0.0)";
|
||||
// String replaceStr = "if (distance_weight_sum <= 0.0001)";
|
||||
// auto pos = source.find(findStr);
|
||||
// while (pos != String::npos) {
|
||||
// MGLOG_D("Applying patch #1 to Photon...");
|
||||
// source.replace(pos, findStr.length(), replaceStr);
|
||||
// pos = source.find(findStr, pos);
|
||||
// }
|
||||
|
||||
findStr = "1000000.0";
|
||||
replaceStr = "65500.0";
|
||||
pos = source.find(findStr);
|
||||
String findStr = "1000000.0";
|
||||
String replaceStr = "65500.0";
|
||||
auto pos = source.find(findStr);
|
||||
while (pos != String::npos) {
|
||||
MGLOG_D("Applying patch #2 to Photon...");
|
||||
source.replace(pos, findStr.length(), replaceStr);
|
||||
pos = source.find(findStr, pos);
|
||||
}
|
||||
|
||||
findStr = "if (gtao.w == 0.0)";
|
||||
replaceStr = "if (abs(gtao.w) <= 0.00001)";
|
||||
pos = source.find(findStr);
|
||||
while (pos != String::npos) {
|
||||
MGLOG_D("Applying patch #3 to Photon...");
|
||||
source.replace(pos, findStr.length(), replaceStr);
|
||||
pos = source.find(findStr, pos);
|
||||
}
|
||||
// findStr = "if (gtao.w == 0.0)";
|
||||
// replaceStr = "if (abs(gtao.w) <= 0.00001)";
|
||||
// pos = source.find(findStr);
|
||||
// while (pos != String::npos) {
|
||||
// MGLOG_D("Applying patch #3 to Photon...");
|
||||
// source.replace(pos, findStr.length(), replaceStr);
|
||||
// pos = source.find(findStr, pos);
|
||||
// }
|
||||
|
||||
findStr = "== 0.0";
|
||||
replaceStr = "<= 0.00001";
|
||||
pos = source.find(findStr);
|
||||
while (pos != String::npos) {
|
||||
MGLOG_D("Applying patch #4 to Photon...");
|
||||
source.replace(pos, findStr.length(), replaceStr);
|
||||
pos = source.find(findStr, pos);
|
||||
}
|
||||
// findStr = "== 0.0";
|
||||
// replaceStr = "<= 0.00001";
|
||||
// pos = source.find(findStr);
|
||||
// while (pos != String::npos) {
|
||||
// MGLOG_D("Applying patch #4 to Photon...");
|
||||
// source.replace(pos, findStr.length(), replaceStr);
|
||||
// pos = source.find(findStr, pos);
|
||||
// }
|
||||
|
||||
const char* sourceCStr = source.c_str();
|
||||
MGLOG_D("Setting shader source for backend shader ID: %u\nsrc:\n%s", backendShaderId, sourceCStr);
|
||||
|
||||
@@ -453,11 +453,13 @@ namespace MobileGL {
|
||||
MGLOG_D("ProgramObject %u: GenerateBinary - generated %zu SPIR-V modules", m_externalIndex,
|
||||
m_generatedSpirv.size());
|
||||
|
||||
for (SizeT i = 0; i < m_generatedSpirv.size(); i++) {
|
||||
auto& spv = m_generatedSpirv[i];
|
||||
|
||||
for (auto& spv: m_generatedSpirv) {
|
||||
auto success = ShaderCompiler::SanitizeBinary(spv, spv);
|
||||
MOBILEGL_ASSERT(success, "SanitizeBinary failed");
|
||||
}
|
||||
|
||||
for (SizeT i = 0; i < m_generatedSpirv.size(); i++) {
|
||||
auto& spv = m_generatedSpirv[i];
|
||||
|
||||
auto shaderType = shaderTypes[i];
|
||||
MGLOG_D("ProgramObject %u: GenerateBinary - parsing SPIR-V meta data for module %zu "
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace MobileGL {
|
||||
}
|
||||
|
||||
// --- Found it, continue to patch it ---
|
||||
MGLOG_D("Found 1 occurrence of `FloatEqualsZero`, patching");
|
||||
|
||||
// 1. Get var type (Float) and result type (Bool)
|
||||
uint32_t float_type_id = def_use_mgr->GetDef(var_id)->type_id();
|
||||
|
||||
Reference in New Issue
Block a user