Skip to content

Commit

Permalink
Merge pull request #13299 from sebavan/master
Browse files Browse the repository at this point in the history
Fix Texture rebuild on context lost

Former-commit-id: ef8ac3bf0bbb8845a828d842aa981c2d3e5b3f47
  • Loading branch information
sebavan authored Nov 30, 2022
2 parents aaac1ec + b100db9 commit a9fa091
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/dev/core/src/Engines/thinEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,10 @@ export class ThinEngine {

// Rebuild context
await initEngine();

// Ensure webgl and engine states are matching
this.wipeCaches(true);

// Rebuild effects
this._rebuildEffects();
this._rebuildComputeEffects?.();
Expand All @@ -1038,7 +1042,8 @@ export class ThinEngine {
this._rebuildRenderTargetWrappers();
// Rebuild buffers
this._rebuildBuffers();
// Cache

// Reset engine states after all the buffer/textures/... have been rebuilt
this.wipeCaches(true);

this._depthCullingState.depthTest = depthTest;
Expand Down
6 changes: 4 additions & 2 deletions packages/dev/core/src/Materials/Textures/internalTexture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,10 @@ export class InternalTexture extends TextureSampler {
this.invertY,
null,
this.samplingMode,
() => {
proxy._swapAndDie(this, false);
// Do not use Proxy here as it could be fully synchronous
// and proxy would be undefined.
(temp) => {
temp._swapAndDie(this, false);
this.isReady = true;
},
null,
Expand Down

0 comments on commit a9fa091

Please sign in to comment.