mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 22:28:32 +09:00
[Feat|Perf] (MG_Backend/DirectGLES): Skip whole sampler object when not dirty.
This commit is contained in:
@@ -554,6 +554,14 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Uint currentSamplerVersion = stateTextureObject->GetSamplerObject()->GetVersion();
|
||||||
|
if (m_syncedSamplerVersion == currentSamplerVersion) {
|
||||||
|
MGLOG_D("Sampler parameters have not changed for texture ID: %u, skipping sync.", m_backendTextureId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_syncedSamplerVersion = currentSamplerVersion;
|
||||||
|
|
||||||
MGLOG_D("Syncing texture built-in sampler with backend ID %u to backend for state ID %u",
|
MGLOG_D("Syncing texture built-in sampler with backend ID %u to backend for state ID %u",
|
||||||
m_backendTextureId, stateTextureObject->GetExternalIndex());
|
m_backendTextureId, stateTextureObject->GetExternalIndex());
|
||||||
|
|
||||||
@@ -987,16 +995,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
source = ProcessOutColorLocations(source);
|
source = ProcessOutColorLocations(source);
|
||||||
source = ForceSupporterOutput(source);
|
source = ForceSupporterOutput(source);
|
||||||
|
|
||||||
// TODO: probably a patch system?
|
// Patch for Photon compiler precision issue
|
||||||
// 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 = "1000000.0";
|
String findStr = "1000000.0";
|
||||||
String replaceStr = "65500.0";
|
String replaceStr = "65500.0";
|
||||||
auto pos = source.find(findStr);
|
auto pos = source.find(findStr);
|
||||||
@@ -1006,24 +1005,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
pos = source.find(findStr, pos);
|
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);
|
|
||||||
// }
|
|
||||||
|
|
||||||
const char* sourceCStr = source.c_str();
|
const char* sourceCStr = source.c_str();
|
||||||
MGLOG_D("Setting shader source for backend shader ID: %u\nsrc:\n%s", backendShaderId, sourceCStr);
|
MGLOG_D("Setting shader source for backend shader ID: %u\nsrc:\n%s", backendShaderId, sourceCStr);
|
||||||
MG_External::GLES::glShaderSource(backendShaderId, 1, &sourceCStr, nullptr);
|
MG_External::GLES::glShaderSource(backendShaderId, 1, &sourceCStr, nullptr);
|
||||||
@@ -1110,6 +1091,15 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Uint currentSamplerVersion = stateSamplerObject->GetVersion();
|
||||||
|
if (m_isInitialized && m_syncedSamplerVersion == currentSamplerVersion) {
|
||||||
|
MGLOG_D("Sampler parameters have not changed for sampler ID: %u, skipping sync.",
|
||||||
|
stateSamplerObject->GetExternalIndex());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_syncedSamplerVersion = currentSamplerVersion;
|
||||||
|
|
||||||
MGLOG_D("Syncing sampler with backend ID %u to backend for state ID %u", m_backendSamplerId,
|
MGLOG_D("Syncing sampler with backend ID %u to backend for state ID %u", m_backendSamplerId,
|
||||||
stateSamplerObject->GetExternalIndex());
|
stateSamplerObject->GetExternalIndex());
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
FloatVec4 m_cacheBorderColor = {0.0f, 0.0f, 0.0f, 0.0f};
|
FloatVec4 m_cacheBorderColor = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
Vec4<TextureSwizzleParam> m_cacheSwizzleParams = {TextureSwizzleParam::Red, TextureSwizzleParam::Green,
|
Vec4<TextureSwizzleParam> m_cacheSwizzleParams = {TextureSwizzleParam::Red, TextureSwizzleParam::Green,
|
||||||
TextureSwizzleParam::Blue, TextureSwizzleParam::Alpha};
|
TextureSwizzleParam::Blue, TextureSwizzleParam::Alpha};
|
||||||
|
Uint16 m_syncedSamplerVersion = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern UnorderedMap<SharedPtr<MG_State::GLState::ITextureObject>, SharedPtr<BackendTextureObject>>
|
extern UnorderedMap<SharedPtr<MG_State::GLState::ITextureObject>, SharedPtr<BackendTextureObject>>
|
||||||
@@ -181,6 +182,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
Uint m_backendSamplerId = 0;
|
Uint m_backendSamplerId = 0;
|
||||||
Bool m_isInitialized = false;
|
Bool m_isInitialized = false;
|
||||||
SamplerParameters m_cacheSamplerParameters;
|
SamplerParameters m_cacheSamplerParameters;
|
||||||
|
Uint16 m_syncedSamplerVersion = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern UnorderedMap<SharedPtr<MG_State::GLState::SamplerObject>, SharedPtr<BackendSamplerObject>>
|
extern UnorderedMap<SharedPtr<MG_State::GLState::SamplerObject>, SharedPtr<BackendSamplerObject>>
|
||||||
|
|||||||
Reference in New Issue
Block a user