GPU: Install the draw engines' invalidation callback from BeginFrame

The draw engine is created on the loader thread while the UI thread may
already be rendering and invoking the callback.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-09-29 13:16:42 -06:00
1 parent 759b494b6a
commit bc581349fd
4 files changed
+19 -4

No files matched your search

+5 -1
View File
@@ -91,7 +91,6 @@ void DrawEngineGLES::InitDeviceObjects() {
entries.push_back({ ATTR_NORMAL, 1, GL_FLOAT, GL_FALSE, offsetof(TransformedVertex, fog) });
softwareInputLayout_ = render_->CreateInputLayout(entries, stride);
draw_->SetInvalidationCallback(std::bind(&DrawEngineGLES::Invalidate, this, std::placeholders::_1));
}
void DrawEngineGLES::DestroyDeviceObjects() {
@@ -99,6 +98,7 @@ void DrawEngineGLES::DestroyDeviceObjects() {
return;
}
draw_->SetInvalidationCallback(InvalidationCallback());
invalidationCallbackInstalled_ = false;
// Beware: this could be called twice in a row, sometimes.
for (int i = 0; i < GLRenderManager::MAX_INFLIGHT_FRAMES; i++) {
@@ -129,6 +129,10 @@ void DrawEngineGLES::ClearInputLayoutMap() {
void DrawEngineGLES::BeginFrame() {
DrawEngineCommon::BeginFrame();
if (!invalidationCallbackInstalled_) {
draw_->SetInvalidationCallback(std::bind(&DrawEngineGLES::Invalidate, this, std::placeholders::_1));
invalidationCallbackInstalled_ = true;
}
FrameData &frameData = frameData_[render_->GetCurFrame()];
frameData.pushIndex->Begin();